]> code.citadel.org Git - citadel.git/blobdiff - citadel/msgbase.c
removed all references to sprintf from several files (not all files yet)
[citadel.git] / citadel / msgbase.c
index f6c7b5e2ab0782325fc9a3faed24b8c2a9aa98f4..0cd11884316994fa95a8731c3e023b80d8642d61 100644 (file)
 extern struct config config;
 long config_msgnum;
 
+
+/* 
+ * This really belongs in serv_network.c, but I don't know how to export
+ * symbols between modules.
+ */
+struct FilterList *filterlist = NULL;
+
+
 /*
  * These are the four-character field headers we use when outputting
  * messages in Citadel format (as opposed to RFC822 format).
@@ -982,6 +990,7 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
        char display_name[SIZ];
        char *mptr;
        char *nl;       /* newline string */
+       int suppress_f = 0;
 
        /* buffers needed for RFC822 translation */
        char suser[SIZ];
@@ -1076,6 +1085,17 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
                        }
                }
 
+               /* Don't show Internet address for users on the
+                * local Citadel network.
+                */
+               suppress_f = 0;
+               if (TheMessage->cm_fields['N'] != NULL)
+                  if (strlen(TheMessage->cm_fields['N']) > 0)
+                     if (haschar(TheMessage->cm_fields['N'], '.') == 0) {
+                       suppress_f = 1;
+               }
+               
+               /* Now spew the header fields in the order we like them. */
                strcpy(allkeys, FORDER);
                for (i=0; i<strlen(allkeys); ++i) {
                        k = (int) allkeys[i];
@@ -1087,17 +1107,8 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
                                                        msgkeys[k],
                                                        display_name);
                                        }
-                                       /* Don't show Internet address for
-                                        * local users
-                                        */
-                                       else if (k == 'F') {
-                                               if (do_proto) if (TheMessage->cm_fields['N'] != NULL) if (strcasecmp(TheMessage->cm_fields['N'], config.c_nodename)) {
-                                                       cprintf("%s=%s\n",
-                                                               msgkeys[k],
-                                                               TheMessage->cm_fields[k]
-                                                       );
-
-                                               }
+                                       else if ((k == 'F') && (suppress_f)) {
+                                               /* do nothing */
                                        }
                                        /* Masquerade display name if needed */
                                        else {
@@ -1154,7 +1165,7 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
                                else if (i == 'R')
                                        cprintf("To: %s%s", mptr, nl);
                                else if (i == 'T') {
-                                       datestring(datestamp, atol(mptr),
+                                       datestring(datestamp, sizeof datestamp, atol(mptr),
                                                DATESTRING_RFC822 );
                                        cprintf("Date: %s%s", datestamp, nl);
                                }
@@ -2021,10 +2032,18 @@ char *CtdlReadMessageBody(char *terminator,     /* token signalling EOT */
 
        if (exist == NULL) {
                m = mallok(4096);
+               m[0] = 0;
+               buffer_len = 4096;
+               message_len = 0;
        }
        else {
-               m = reallok(exist, strlen(exist) + 4096);
-               if (m == NULL) phree(exist);
+               message_len = strlen(exist);
+               buffer_len = message_len + 4096;
+               m = reallok(exist, buffer_len);
+               if (m == NULL) {
+                       phree(exist);
+                       return m;
+               }
        }
 
        /* flush the input if we have nowhere to store it */
@@ -2033,12 +2052,6 @@ char *CtdlReadMessageBody(char *terminator,      /* token signalling EOT */
                return(NULL);
        }
 
-       /* otherwise read it into memory */
-       else {
-               buffer_len = 4096;
-               m[0] = 0;
-               message_len = 0;
-       }
        /* read in the lines of message text one by one */
        while ( (client_gets(buf)>0) && strcmp(buf, terminator) ) {
 
@@ -2409,7 +2422,13 @@ void cmd_ent0(char *entargs)
        }
        CC->cs_flags |= CS_POSTING;
 
-       if (CC->quickroom.QRflags & QR_MAILBOX) {
+       /* In the Mail> room we have to behave a little differently --
+        * make sure the user has specified at least one recipient.  Then
+        * validate the recipient(s).
+        */
+       if ( (CC->quickroom.QRflags & QR_MAILBOX)
+          && (!strcasecmp(&CC->quickroom.QRname[11], MAILROOM)) ) {
+
                if (CC->usersupp.axlevel < 2) {
                        strcpy(recp, "sysop");
                }