//========================================================================
#include <aconf.h>
+#include "../../config.h"
#ifdef WIN32
extern "C" {
-# ifndef _MSC_VER
-# include <kpathsea/win32lib.h>
-# endif
+//# ifndef _MSC_VER
+//# include <kpathsea/win32lib.h>
+//# endif
}
#else // !WIN32
# if defined(MACOS)
return statBuf.st_mtime;
#endif
}
+
+static char tmpbuf[128];
+
+char* mktmpname(char*ptr) {
+ // used to be mktemp. This does remove the warnings, but
+ // It's not exactly an improvement.
+#ifdef HAVE_LRAND48
+ sprintf(tmpbuf, "/tmp/%08x%08x",lrand48(),lrand48());
+#else
+# ifdef HAVE_RAND
+ sprintf(tmpbuf, "/tmp/%08x%08x",rand(),rand());
+# else
+ sprintf(tmpbuf, "/tmp/%08x%08x",time(0),(unsigned int)tmpbuf);
+# endif
+#endif
+ return tmpbuf;
+}
GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
#if defined(WIN32)
// with this file name after the tmpnam call and before the fopen
// call. I will happily accept fixes to this function for non-Unix
// OSs.
- if (!(s = tmpnam(NULL))) {
+ if (!(s = mktmpname(NULL))) { //was: tmpnam
return gFalse;
}
*name = new GString(s);
(*name)->append("/XXXXXX")->append(ext);
fd = mkstemps((*name)->getCString(), strlen(ext));
#else
- if (!(s = tmpnam(NULL))) {
+ if (!(s = mktmpname(NULL))) { //was: tmpnam
return gFalse;
}
*name = new GString(s);
(*name)->append("/XXXXXX");
fd = mkstemp((*name)->getCString());
#else // HAVE_MKSTEMP
- if (!(s = tmpnam(NULL))) {
+ if (!(s = mktmpname(NULL))) { //was: tmpnam
return gFalse;
}
*name = new GString(s);