]> code.citadel.org Git - citadel.git/blobdiff - citadel/msgbase.c
* Numerous warning fixes and cleanups for compile on Linux for IBM S/390
[citadel.git] / citadel / msgbase.c
index b8498a53680d53af4c2ecb25be75cd5bc2491e78..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);
@@ -1056,21 +1056,9 @@ int CtdlOutputMsg(long msg_num,          /* message number (local) to fetch */
         */
 
        /*
-        * Fetch the message from disk.  We also keep the most recently
-        * read message in memory, in case we want to read it again, or fetch
-        * MIME parts out of it, or whatever.
+        * Fetch the message from disk.
         */
-       if ( (CC->cached_msg != NULL) && (CC->cached_msgnum == msg_num) ) {
-               TheMessage = CC->cached_msg;
-       }
-       else {
-               TheMessage = CtdlFetchMessage(msg_num);
-               if (CC->cached_msg != NULL) {
-                       phree(CC->cached_msg);
-               }
-               CC->cached_msg = TheMessage;
-               CC->cached_msgnum = msg_num;
-       }
+       TheMessage = CtdlFetchMessage(msg_num);
 
        if (TheMessage == NULL) {
                if (do_proto) cprintf("%d Can't locate msg %ld on disk\n",
@@ -1082,8 +1070,7 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
                        TheMessage, msg_num, mode,
                        headers_only, do_proto, crlf);
 
-       /* don't free the memory; we're keeping it in the cache */
-       /* CtdlFreeMessage(TheMessage); */
+       CtdlFreeMessage(TheMessage);
 
        return(retcode);
 }
@@ -1896,7 +1883,12 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,      /* message to save */
                }
        }
 
-       strcpy(force_room, force);
+       if (force == NULL) {
+               strcpy(force_room, "");
+       }
+       else {
+               strcpy(force_room, force);
+       }
 
        /* Learn about what's inside, because it's what's inside that counts */
        lprintf(9, "Learning what's inside\n");
@@ -2136,25 +2128,32 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,     /* message to save */
 /*
  * Convenience function for generating small administrative messages.
  */
-void quickie_message(char *from, char *to, char *room, char *text)
+void quickie_message(char *from, char *to, char *room, char *text, 
+                       int format_type, char *subject)
 {
        struct CtdlMessage *msg;
+       struct recptypes *recp = NULL;
 
        msg = mallok(sizeof(struct CtdlMessage));
        memset(msg, 0, sizeof(struct CtdlMessage));
        msg->cm_magic = CTDLMESSAGE_MAGIC;
        msg->cm_anon_type = MES_NORMAL;
-       msg->cm_format_type = 0;
+       msg->cm_format_type = format_type;
        msg->cm_fields['A'] = strdoop(from);
-       msg->cm_fields['O'] = strdoop(room);
+       if (room != NULL) msg->cm_fields['O'] = strdoop(room);
        msg->cm_fields['N'] = strdoop(NODENAME);
-       if (to != NULL)
+       if (to != NULL) {
                msg->cm_fields['R'] = strdoop(to);
+               recp = validate_recipients(to);
+       }
+       if (subject != NULL) {
+               msg->cm_fields['U'] = strdoop(subject);
+       }
        msg->cm_fields['M'] = strdoop(text);
 
-       CtdlSubmitMsg(msg, NULL, room);
+       CtdlSubmitMsg(msg, recp, room);
        CtdlFreeMessage(msg);
-       syslog(LOG_NOTICE, text);
+       if (recp != NULL) phree(recp);
 }
 
 
@@ -2199,11 +2198,10 @@ char *CtdlReadMessageBody(char *terminator,     /* token signalling EOT */
        /* read in the lines of message text one by one */
        while ( (client_gets(buf)>0) && strcmp(buf, terminator) ) {
 
-               /* strip trailing newline type stuff */
-               if (buf[strlen(buf)-1]==10) buf[strlen(buf)-1]=0;
-               if (buf[strlen(buf)-1]==13) buf[strlen(buf)-1]=0;
-
+               /* Measure the line and strip trailing newline characters */
                linelen = strlen(buf);
+               if (linelen > 0) if (buf[linelen-1]==13) buf[linelen--]=0;
+               if (linelen > 0) if (buf[linelen-1]==10) buf[linelen--]=0;
 
                /* augment the buffer if we have to */
                if ((message_len + linelen + 2) > buffer_len) {