]> code.citadel.org Git - citadel.git/blobdiff - webcit/tools.c
* Eliminated the use of tmpnam() to shut up compiler warnings.
[citadel.git] / webcit / tools.c
index 2de3e881b61a37ebfa822d648f592dcda601d388..a4c7c2c20dfa98e8aff0034e4b4f28b13f3bf3ff 100644 (file)
@@ -465,3 +465,22 @@ void generate_uuid(char *buf) {
                (seq++)
        );
 }
+
+
+/*
+ * 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;
+               }
+       }
+}