hardcoded /tmp into them.
}
#endif
-#ifdef tmpnam
-#undef tmpnam
-#endif
-#define tmpnam(x) CtdlTempFileName(__FILE__, __LINE__)
-
-#ifdef tmpfile
-#undef tmpfile
-#endif
-#define tmpfile() CtdlTempFile()
#endif /* CITADEL_H */
int main(int argc, char **argv) {
char buf[1024];
char fromline[1024];
- char tempfilename[SIZ];
FILE *fp;
get_config();
- sprintf(tempfilename, "/tmp/citmail.%04x.%04x",
- (int)time(NULL),
- (int)getpid()
- );
- fp = fopen(tempfilename, "w+b");
- unlink(tempfilename);
+ fp = tmpfile();
if (fp == NULL) return(errno);
snprintf(fromline, sizeof fromline, "From: someone@somewhere.org");
while (fgets(buf, 1024, stdin) != NULL) {
}
-/*
- * 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);
-}
-
-
/*
* bmstrstr() is a variant of strstr() that uses the Boyer-Moore search
* algorithm, and can use any caller-supplied string compare function whose