]> code.citadel.org Git - citadel.git/blobdiff - citadel/tools.c
* Eliminated the use of tmpnam() to shut up the compiler warnings.
[citadel.git] / citadel / tools.c
index 982d1ae1bee027edbbe5a3fa9d6fd08e2b16c08f..e8a1abc9798e04e57db37accbd21a087468dc4e0 100644 (file)
@@ -634,3 +634,20 @@ char *bmstrcasestr(char *text, char *pattern) {
 
 
 
+/*
+ * Local replacement for controversial C library function that generates
+ * names for temporary files.  Included to shut up compiler warnings.
+ */
+void CtdlMakeTempFileName(char *name, int len) {
+       int i = 0;
+
+       while (i++, i < 100) {
+               snprintf(name, len, "/tmp/ctdl.%04x.%04x",
+                       getpid(),
+                       rand()
+               );
+               if (!access(name, F_OK)) {
+                       return;
+               }
+       }
+}