]> code.citadel.org Git - citadel.git/blobdiff - citadel/tools.c
* Numerous warning fixes and cleanups for compile on Linux for IBM S/390
[citadel.git] / citadel / tools.c
index 21c1ce91eaef46358cad439e41c3d2bfb92d872f..049987bd4ea4f901b1aee0561059b68fbac2c1e9 100644 (file)
@@ -10,6 +10,8 @@
 #endif
 
 #include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -252,7 +254,7 @@ long extract_long(char *source, long int parmnum)
 
 
 /*
- * decode_base64() and encode_base64() are adaptations of code by
+ * CtdlDecodeBase64() and encode_base64() are adaptations of code by
  * John Walker, found in full in the file "base64.c" included with this
  * distribution.  The difference between those functions and these is that
  * these are intended to encode/decode small string buffers, and those are
@@ -319,7 +321,7 @@ void encode_base64(char *dest, char *source)
  * Convert base64-encoded to binary.  Returns the length of the decoded data.
  * It will stop after reading 'length' bytes.
  */
-int decode_base64(char *dest, char *source, size_t length)
+int CtdlDecodeBase64(char *dest, char *source, size_t length)
 {
     int i, c;
     int dpos = 0;
@@ -634,3 +636,33 @@ void urlesc(char *outbuf, char *strbuf)
 }
 
 
+/*
+ * Citadelian replacement for tmpnam()
+ */
+char *CtdlTempFileName(char *prefix1, int prefix2) {
+       static int seq = 0;
+       static char buf[SIZ];
+
+       sprintf(buf, "/tmp/Citadel-%s-%d-%04x-%04x",
+               prefix1,
+               prefix2,
+               (int)getpid(),
+               ++seq
+       );
+       
+       return(buf);
+}
+
+
+/*
+ * Citadelian replacement for tmpfile()
+ */
+FILE *CtdlTempFile(void) {
+       char filename[SIZ];
+       FILE *fp;
+
+       strcpy(filename, tmpnam(NULL));
+       fp = fopen(filename, "w+b");
+       unlink(filename);
+       return(fp);
+}