]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_network.c
warning fixes and cleanups for 64-bit machines
[citadel.git] / citadel / serv_network.c
index 68348937d1c1ffdb19951750bcc3388da851e7c0..37feb4079c198d6be6a93217795252b6c3df80cf 100644 (file)
@@ -12,7 +12,6 @@
 /*
  * FIXME
  * Don't allow polls during network processing
- * Use table isn't saving properly across sessions
  */
 
 #include "sysdep.h"
 #include "clientsocket.h"
 #include "file_ops.h"
 
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
 
 /*
  * When we do network processing, it's accomplished in two passes; one to
@@ -159,13 +162,16 @@ int network_usetable(int operation, struct CtdlMessage *msg) {
                                stlen = stlen + strlen(uptr->message_id) + 20;
                        }
                        serialized_table = mallok(stlen);
+                       memset(serialized_table, 0, stlen);
 
                        while (ut != NULL) {
-                               if (serialized_table != NULL) {
+                               if ( (serialized_table != NULL) 
+                                  && ( (ut->timestamp - time(NULL)) <
+                                     USETABLE_RETAIN) ) {
                                        sprintf(&serialized_table[strlen(
                                          serialized_table)], "%s|%ld\n",
                                            ut->message_id,
-                                           ut->timestamp);
+                                           (long)ut->timestamp);
                                }
 
                                /* Now free the memory */
@@ -231,7 +237,7 @@ void write_network_map(void) {
                                sprintf(&serialized_map[strlen(serialized_map)],
                                        "%s|%ld|%s\n",
                                        nmptr->nodename,
-                                       nmptr->lastcontact,
+                                       (long)nmptr->lastcontact,
                                        nmptr->nexthop);
                        }
                }
@@ -440,7 +446,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                sprintf(instr,
                        "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
                        "bounceto|postmaster@%s\n" ,
-                       SPOOLMIME, msgnum, time(NULL), config.c_fqdn );
+                       SPOOLMIME, msgnum, (long)time(NULL), config.c_fqdn );
        
                /* Generate delivery instructions for each recipient */
                for (nptr = sc->listrecps; nptr != NULL; nptr = nptr->next) {
@@ -729,7 +735,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
                phree(msg->cm_fields['I']);
        }
        sprintf(buf, "%ld.%04x.%04x@%s",
-               time(NULL), getpid(), ++serialnum, config.c_fqdn);
+               (long)time(NULL), getpid(), ++serialnum, config.c_fqdn);
        msg->cm_fields['I'] = strdoop(buf);
 
        /*
@@ -825,6 +831,7 @@ void network_process_buffer(char *buffer, long size) {
        char *oldpath = NULL;
        char filename[SIZ];
        FILE *fp;
+       char buf[SIZ];
 
        /* Set default target room to trash */
        strcpy(target_room, TWITROOM);
@@ -898,7 +905,9 @@ void network_process_buffer(char *buffer, long size) {
         * Check to see if we already have a copy of this message
         */
        if (network_usetable(UT_INSERT, msg) != 0) {
-               /* FIXME - post a msg in Aide> telling us what happened */
+               sprintf(buf, "Loopzapper rejected message <%s>\n",
+                       msg->cm_fields['I']);
+               aide_message(buf);
                CtdlFreeMessage(msg);
                msg = NULL;
                return;