From: Art Cancro Date: Tue, 15 Oct 2002 17:41:20 +0000 (+0000) Subject: * Numerous warning fixes and cleanups for compile on Linux for IBM S/390 X-Git-Tag: v7.86~6179 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=c37a284b5bcd01add96c605c44ce85b5e89cd947 * Numerous warning fixes and cleanups for compile on Linux for IBM S/390 * Name temp files with source code location of who created them --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index cef2bd98b..e2c8e543f 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 601.28 2002/10/15 17:41:20 ajc + * Numerous warning fixes and cleanups for compile on Linux for IBM S/390 + * Name temp files with source code location of who created them + Revision 601.27 2002/10/15 06:47:11 error * IPC support for resumable downloads @@ -4076,4 +4080,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/aidepost.c b/citadel/aidepost.c index c7a7265c6..56f578134 100644 --- a/citadel/aidepost.c +++ b/citadel/aidepost.c @@ -101,7 +101,10 @@ int main(int argc, char **argv) "./network/spoolin/ap.%04x", getpid()); - tempfp = tmpfile(); + unlink(tempspool); + + tempfp = fopen(tempspool, "w+b"); + unlink(tempspool); if (tempfp == NULL) { perror("cannot open temp file"); exit(errno); diff --git a/citadel/citadel.h b/citadel/citadel.h index ed51301c2..b62239f78 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -317,4 +317,14 @@ enum { } #endif +#ifdef tmpnam +#undef tmpnam +#endif +#define tmpnam(x) CtdlTempFileName(__FILE__, __LINE__) + +#ifdef tmpfile +#undef tmpfile +#endif +#define tmpfile() CtdlTempFile() + #endif /* CITADEL_H */ diff --git a/citadel/citadel_ipc.c b/citadel/citadel_ipc.c index fb5633203..3db0d89e3 100644 --- a/citadel/citadel_ipc.c +++ b/citadel/citadel_ipc.c @@ -1123,7 +1123,7 @@ int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf, /* ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, resume, progress_gauge_callback, cret); */ ret = CtdlIPCEndDownload(ipc, cret); if (ret / 100 == 2) - sprintf(cret, "%d|%ld|%s|%s", bytes, last_mod, + sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod, filename, mimetype); } return ret; @@ -1162,7 +1162,7 @@ int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part, void ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret); ret = CtdlIPCEndDownload(ipc, cret); if (ret / 100 == 2) - sprintf(cret, "%d|%ld|%s|%s", bytes, last_mod, + sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod, filename, mimetype); } return ret; @@ -1199,7 +1199,7 @@ int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf, ret = CtdlIPCReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret); ret = CtdlIPCEndDownload(ipc, cret); if (ret / 100 == 2) - sprintf(cret, "%d|%ld|%s|%s", bytes, last_mod, + sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod, filename, mimetype); } return ret; @@ -2025,7 +2025,7 @@ size_t CtdlIPCPartialRead(CtdlIPC *ipc, void **buf, size_t offset, size_t bytes, if (offset < 0) return -1; CtdlIPC_lock(ipc); - sprintf(aaa, "READ %d|%d", offset, bytes); + sprintf(aaa, "READ %d|%d", (int)offset, (int)bytes); CtdlIPC_putline(ipc, aaa); CtdlIPC_getline(ipc, aaa); if (aaa[0] != '6') @@ -2133,7 +2133,7 @@ int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, /* Send all requests at once */ for (i = 0; i < calls; i++) { - sprintf(aaa, "READ %d|4096", i * 4096 + resume); + sprintf(aaa, "READ %d|4096", (int)(i * 4096 + resume) ); CtdlIPC_putline(ipc, aaa); } @@ -2204,7 +2204,7 @@ int CtdlIPCWriteUpload(CtdlIPC *ipc, const char *path, if (!to_write) { if (feof(fd) || ferror(fd)) break; } - sprintf(aaa, "WRIT %d", to_write); + sprintf(aaa, "WRIT %d", (int)to_write); CtdlIPC_putline(ipc, aaa); CtdlIPC_getline(ipc, aaa); strcpy(cret, &aaa[4]); @@ -2538,7 +2538,7 @@ static void serv_read_ssl(CtdlIPC* ipc, char *buf, int bytes) } error_printf("SSL_read in serv_read:\n"); ERR_print_errors_fp(stderr); - connection_died(); + connection_died(NULL); return; } len += rlen; @@ -2581,7 +2581,7 @@ static void serv_write_ssl(CtdlIPC *ipc, const char *buf, int nbytes) } error_printf("SSL_write in serv_write:\n"); ERR_print_errors_fp(stderr); - connection_died(); + connection_died(NULL); return; } bytes_written += retval; diff --git a/citadel/citadel_ipc.h b/citadel/citadel_ipc.h index e1705acdc..2443ee1a2 100644 --- a/citadel/citadel_ipc.h +++ b/citadel/citadel_ipc.h @@ -250,6 +250,9 @@ void setCryptoStatusHook(void (*hook)(char *s)); extern int (*error_printf)(char *s, ...); void setIPCDeathHook(void (*hook)(void)); void setIPCErrorPrintf(int (*func)(char *s, ...)); +void connection_died(CtdlIPC *ipc); +int CtdlIPC_getsockfd(CtdlIPC* ipc); +char CtdlIPC_get(CtdlIPC* ipc); #ifdef __cplusplus } diff --git a/citadel/citmail.c b/citadel/citmail.c index f1b8d7431..cadb6b25e 100644 --- a/citadel/citmail.c +++ b/citadel/citmail.c @@ -169,11 +169,17 @@ void cleanup(int exitcode) { int main(int argc, char **argv) { char buf[1024]; char fromline[1024]; + char tempfilename[SIZ]; FILE *fp; get_config(); - fp = tmpfile(); + sprintf(tempfilename, "/tmp/citmail.%04x.%04x", + (int)time(NULL), + (int)getpid() + ); + fp = fopen(tempfilename, "w+b"); + unlink(tempfilename); if (fp == NULL) return(errno); snprintf(fromline, sizeof fromline, "From: someone@somewhere.org"); while (fgets(buf, 1024, stdin) != NULL) { diff --git a/citadel/dynloader.c b/citadel/dynloader.c index c1e3c64b3..043dcd187 100644 --- a/citadel/dynloader.c +++ b/citadel/dynloader.c @@ -551,11 +551,16 @@ void PerformSessionHooks(int EventType) { struct SessionFunctionHook *fcn; + TRACE; for (fcn = SessionHookTable; fcn != NULL; fcn = fcn->next) { + TRACE; if (fcn->eventtype == EventType) { + TRACE; (*fcn->h_function_pointer) (); } + TRACE; } + TRACE; } void PerformLogHooks(int loglevel, char *logmsg) diff --git a/citadel/file_ops.c b/citadel/file_ops.c index a6ce2f82a..a9de64ae6 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -697,7 +697,7 @@ void cmd_read(char *cmdbuf) fseek(CC->download_fp, start_pos, 0); actual_bytes = fread(buf, 1, bytes, CC->download_fp); - cprintf("%d %d\n", BINARY_FOLLOWS, actual_bytes); + cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes); client_write(buf, actual_bytes); } diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 451f6491d..98d4c2c16 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -128,6 +128,7 @@ void do_housekeeping(void) { static int housekeeping_in_progress = 0; static time_t last_timer = 0L; int do_housekeeping_now = 0; + time_t now; /* * We do it this way instead of wrapping the whole loop in an @@ -135,14 +136,19 @@ void do_housekeeping(void) { * potentially have multiple concurrent mutexes in progress. */ begin_critical_section(S_HOUSEKEEPING); - if ( ((time(NULL) - last_timer) > 60L) - && (housekeeping_in_progress == 0) ) { - do_housekeeping_now = 1; - housekeeping_in_progress = 1; - last_timer = time(NULL); + now = time(NULL); + if ( (now - last_timer) > (time_t)60 ) { + if (housekeeping_in_progress == 0) { + do_housekeeping_now = 1; + housekeeping_in_progress = 1; + last_timer = time(NULL); + } } end_critical_section(S_HOUSEKEEPING); - if (do_housekeeping_now == 0) return; + + if (do_housekeeping_now == 0) { + return; + } /* * Ok, at this point we've made the decision to run the housekeeping diff --git a/citadel/msgbase.c b/citadel/msgbase.c index f392382b9..f83917877 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1002,7 +1002,7 @@ void output_preferred(char *name, char *filename, char *partnum, char *disp, cprintf("Content-type: %s\n", cbtype); cprintf("Content-length: %d\n", - length + add_newline); + (int)(length + add_newline) ); cprintf("Content-transfer-encoding: %s\n", encoding); cprintf("\n"); client_write(content, length); diff --git a/citadel/tools.c b/citadel/tools.c index d9bdb8991..049987bd4 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -10,6 +10,8 @@ #endif #include "sysdep.h" +#include +#include #include #include #include @@ -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); +} diff --git a/citadel/tools.h b/citadel/tools.h index 3e353f298..9dda38cae 100644 --- a/citadel/tools.h +++ b/citadel/tools.h @@ -28,3 +28,5 @@ void stripallbut(char *str, char leftboundary, char rightboundary); char *myfgets(char *s, int size, FILE *stream); void urlesc(char *outbuf, char *strbuf); +char *CtdlTempFileName(char *prefix1, int prefix2); +FILE *CtdlTempFile(void);