]> code.citadel.org Git - citadel.git/blobdiff - citadel/msgbase.c
- declare *printf format specifiers if gcc detected
[citadel.git] / citadel / msgbase.c
index f1b8c0530bffe54c5fb3f46f346f715b9faa5c66..ff346d3d71f5996db4aa912085d256c414744902 100644 (file)
@@ -679,7 +679,7 @@ void list_this_part(char *name, char *filename, char *partnum, char *disp,
                    void *cbuserdata)
 {
 
-       cprintf("part=%s|%s|%s|%s|%s|%d\n",
+       cprintf("part=%s|%s|%s|%s|%s|%ld\n",
                name, filename, partnum, disp, cbtype, length);
 }
 
@@ -821,7 +821,14 @@ void CtdlFreeMessage(struct CtdlMessage *msg)
 
 
 /*
- * Pre callback function for mime parser that wants to display text
+ * Pre callback function for multipart/alternative
+ *
+ * NOTE: this differs from the standard behavior for a reason.  Normally when
+ *       displaying multipart/alternative you want to show the _last_ usable
+ *       format in the message.  Here we show the _first_ one, because it's
+ *       usually text/plain.  Since this set of functions is designed for text
+ *       output to non-MIME-aware clients, this is the desired behavior.
+ *
  */
 void fixed_output_pre(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, size_t length, char *encoding,
@@ -831,13 +838,12 @@ void fixed_output_pre(char *name, char *filename, char *partnum, char *disp,
                if (!strcasecmp(cbtype, "multipart/alternative")) {
                        ma->is_ma = 1;
                        ma->did_print = 0;
-                       lprintf(9, "multipart/alternative: <%s>\n", ma->prefix);
                        return;
                }
 }
 
 /*
- * Pre callback function for mime parser that wants to display text
+ * Post callback function for multipart/alternative
  */
 void fixed_output_post(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, size_t length, char *encoding,
@@ -847,7 +853,6 @@ void fixed_output_post(char *name, char *filename, char *partnum, char *disp,
                if (!strcasecmp(cbtype, "multipart/alternative")) {
                        ma->is_ma = 0;
                        ma->did_print = 0;
-                       lprintf(9, "multipart/alternative: <%s>\n", ma->prefix);
                        return;
                }
 }
@@ -865,12 +870,15 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
                CIT_UBYTE ch = 0;
 
                lprintf(9, "fixed_output() type=<%s>\n", cbtype);       
-       
+
+               /*
+                * If we're in the middle of a multipart/alternative scope and
+                * we've already printed another section, skip this one.
+                */     
                if ( (ma->is_ma == 1) && (ma->did_print == 1) ) {
                        lprintf(9, "Skipping part %s (%s)\n", partnum, cbtype);
                        return;
                }
-       
                ma->did_print = 1;
        
                if ( (!strcasecmp(cbtype, "text/plain")) 
@@ -899,7 +907,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
                        phree(ptr);
                }
                else if (strncasecmp(cbtype, "multipart/", 10)) {
-                       cprintf("Part %s: %s (%s) (%d bytes)\r\n",
+                       cprintf("Part %s: %s (%s) (%ld bytes)\r\n",
                                partnum, filename, cbtype, length);
                }
        }
@@ -1571,7 +1579,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
                ret->len = ret->len +
                        strlen(msg->cm_fields[(int)forder[i]]) + 2;
 
-       lprintf(9, "serialize_message() calling malloc(%d)\n", ret->len);
+       lprintf(9, "serialize_message() calling malloc(%ld)\n", ret->len);
        ret->ser = mallok(ret->len);
        if (ret->ser == NULL) {
                ret->len = 0;
@@ -1588,7 +1596,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
                strcpy(&ret->ser[wlen], msg->cm_fields[(int)forder[i]]);
                wlen = wlen + strlen(msg->cm_fields[(int)forder[i]]) + 1;
        }
-       if (ret->len != wlen) lprintf(3, "ERROR: len=%d wlen=%d\n",
+       if (ret->len != wlen) lprintf(3, "ERROR: len=%ld wlen=%ld\n",
                ret->len, wlen);
 
        return;
@@ -1701,7 +1709,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */
         */
        if (msg->cm_fields['T'] == NULL) {
                lprintf(9, "Generating timestamp\n");
-               sprintf(aaa, "%ld", time(NULL));
+               sprintf(aaa, "%ld", (long)time(NULL));
                msg->cm_fields['T'] = strdoop(aaa);
        }
 
@@ -1911,7 +1919,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */
                        "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
                        "bounceto|%s@%s\n"
                        "remote|%s|0||\n",
-                       SPOOLMIME, newmsgid, time(NULL),
+                       SPOOLMIME, newmsgid, (long)time(NULL),
                        msg->cm_fields['A'], msg->cm_fields['N'],
                        recipient );
 
@@ -2007,7 +2015,7 @@ char *CtdlReadMessageBody(char *terminator,       /* token signalling EOT */
                        } else {
                                buffer_len = (buffer_len * 2);
                                m = ptr;
-                               lprintf(9, "buffer_len is %d\n", buffer_len);
+                               lprintf(9, "buffer_len is %ld\n", buffer_len);
                        }
                }
 
@@ -2037,7 +2045,7 @@ char *CtdlReadMessageBody(char *terminator,       /* token signalling EOT */
  * Build a binary message to be saved on disk.
  */
 
-struct CtdlMessage *make_message(
+static struct CtdlMessage *make_message(
        struct usersupp *author,        /* author's usersupp structure */
        char *recipient,                /* NULL if it's not mail */
        char *room,                     /* room where it's going */
@@ -2083,7 +2091,7 @@ struct CtdlMessage *make_message(
        sprintf(buf, "cit%ld", author->usernum);                /* Path */
        msg->cm_fields['P'] = strdoop(buf);
 
-       sprintf(buf, "%ld", time(NULL));                        /* timestamp */
+       sprintf(buf, "%ld", (long)time(NULL));                  /* timestamp */
        msg->cm_fields['T'] = strdoop(buf);
 
        if (fake_name[0])                                       /* author */
@@ -2357,21 +2365,21 @@ void cmd_ent3(char *entargs)
 
        cprintf("%d %ld\n", SEND_BINARY, msglen);
 
-       client_read(&ch, 1);                            /* 0xFF magic number */
+       client_read((char*)&ch, 1);                             /* 0xFF magic number */
        msg->cm_magic = CTDLMESSAGE_MAGIC;
-       client_read(&ch, 1);                            /* anon type */
+       client_read((char*)&ch, 1);                             /* anon type */
        msg->cm_anon_type = ch;
-       client_read(&ch, 1);                            /* format type */
+       client_read((char*)&ch, 1);                             /* format type */
        msg->cm_format_type = ch;
        msglen = msglen - 3;
 
        while (msglen > 0) {
-               client_read(&which_field, 1);
+               client_read((char*)&which_field, 1);
                if (!isalpha(which_field)) valid_msg = 0;
                --msglen;
                tempbuf[0] = 0;
                do {
-                       client_read(&ch, 1);
+                       client_read((char*)&ch, 1);
                        --msglen;
                        a = strlen(tempbuf);
                        tempbuf[a+1] = 0;