* Numerous warning fixes and cleanups for compile on Linux for IBM S/390
authorArt Cancro <ajc@citadel.org>
Tue, 15 Oct 2002 17:41:20 +0000 (17:41 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 15 Oct 2002 17:41:20 +0000 (17:41 +0000)
* Name temp files with source code location of who created them

12 files changed:
citadel/ChangeLog
citadel/aidepost.c
citadel/citadel.h
citadel/citadel_ipc.c
citadel/citadel_ipc.h
citadel/citmail.c
citadel/dynloader.c
citadel/file_ops.c
citadel/housekeeping.c
citadel/msgbase.c
citadel/tools.c
citadel/tools.h

index cef2bd98bddeba1bcbf08a11cb62b20888744c15..e2c8e543fd339a802cc41c1a3b60c031363d434c 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index c7a7265c60787eb995c01b9dea6e5d641cf2be38..56f5781347f8106510a7af5ff4fb014dd3e4a4ed 100644 (file)
@@ -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);
index ed51301c21bd53c28bb42e767651b41ea8a46a3c..b62239f78abece7a6d5ea326c22c787f9478c5cd 100644 (file)
@@ -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 */
index fb5633203c34de9a4f09ab998bac29960ff80c3a..3db0d89e361d3337854fcf9e074ef508e59abe8a 100644 (file)
@@ -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;
index e1705acdc758ce4cf593f23af80376e56bc27bec..2443ee1a281f8974748eaf9fd7e631e1ae2d82e4 100644 (file)
@@ -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
 }
index f1b8d7431a29eed3dc59bf400c2a36786f21fb5e..cadb6b25ebb0f52f7a870ae206628958f6ce4668 100644 (file)
@@ -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) {
index c1e3c64b3d60e42395f9f11c3301eff2372a6756..043dcd187321c104a563a7647e86801bad5ae508 100644 (file)
@@ -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)
index a6ce2f82a931832a7a1929276246d46c56a2c0f2..a9de64ae65819f172536ede4bfde557d42c52a13 100644 (file)
@@ -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);
 }
 
index 451f6491dfebbf9bb682b25e0c6cf688c7bf7bd9..98d4c2c16db58e6b4af2ba638f8cfb6c3cac83b4 100644 (file)
@@ -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
index f392382b904581f75e450b394a143e2c3207d574..f8391787761db6e3afbdee69ed215bf87bdc6e76 100644 (file)
@@ -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);
index d9bdb8991dbd922bac0b7408c2d0cd0797d5c8f8..049987bd4ea4f901b1aee0561059b68fbac2c1e9 100644 (file)
@@ -10,6 +10,8 @@
 #endif
 
 #include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -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);
+}
index 3e353f298046a9048a0a06039e975acb371d1c3a..9dda38cae65d18e9f931fa7f64ed67ea2aff9c0e 100644 (file)
@@ -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);