Removed some leftover dependencies on message fields which no longer exist
[citadel.git] / citadel / modules / imap / imap_fetch.c
index 8fcd6bd813ab6c2bc3055f65cde7dbb176e4d288..293fecca019eec5c160b7c7531a63cfd4c32f818 100644 (file)
@@ -2,7 +2,7 @@
  * Implements the FETCH command in IMAP.
  * This is a good example of the protocol's gratuitous complexity.
  *
- * Copyright (c) 2001-2015 by the citadel.org team
+ * Copyright (c) 2001-2020 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -141,8 +141,7 @@ void imap_fetch_rfc822(long msgnum, const char *whichfmt) {
         * us to fetch the message body from disk.  If not, we can save
         * on some disk operations...
         */
-       if ( (!strcasecmp(whichfmt, "RFC822"))
-          || (!strcasecmp(whichfmt, "RFC822.TEXT")) ) {
+       if ( (!strcasecmp(whichfmt, "RFC822")) || (!strcasecmp(whichfmt, "RFC822.TEXT")) ) {
                need_body = 1;
        }
 
@@ -188,7 +187,9 @@ void imap_fetch_rfc822(long msgnum, const char *whichfmt) {
                        (need_body ? HEADERS_ALL : HEADERS_FAST),
                        0, 1, NULL, SUPPRESS_ENV_TO, NULL, NULL, NULL
                );
-               if (!need_body) IAPuts("\r\n"); /* extra trailing newline */
+               if (!need_body) {
+                       client_write(HKEY("\r\n"));             // extra trailing newline -- to the redirect_buffer, *not* to the client
+               }
                Imap->cached_rfc822 = CCC->redirect_buffer;
                CCC->redirect_buffer = NULL;
                Imap->cached_rfc822_msgnum = msgnum;
@@ -229,16 +230,11 @@ void imap_fetch_rfc822(long msgnum, const char *whichfmt) {
                FreeStrBuf(&Line);
        }
        else {
-               headers_size = 
-                       total_size = StrLength(Imap->cached_rfc822);
+               headers_size = total_size = StrLength(Imap->cached_rfc822);
                text_size = 0;
        }
 
-       IMAP_syslog(LOG_DEBUG, 
-                   "RFC822: headers=" SIZE_T_FMT 
-                   ", text=" SIZE_T_FMT
-                   ", total=" SIZE_T_FMT,
-                   headers_size, text_size, total_size);
+       syslog(LOG_DEBUG, "imap: RFC822 headers=" SIZE_T_FMT ", text=" SIZE_T_FMT ", total=" SIZE_T_FMT, headers_size, text_size, total_size);
 
        if (!strcasecmp(whichfmt, "RFC822.SIZE")) {
                IAPrintf("RFC822.SIZE " SIZE_T_FMT, total_size);
@@ -265,7 +261,6 @@ void imap_fetch_rfc822(long msgnum, const char *whichfmt) {
 }
 
 
-
 /*
  * Load a specific part of a message into the temp file to be output to a
  * client.  FIXME we can handle parts like "2" and "2.1" and even "2.MIME"
@@ -278,15 +273,11 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp,
                    void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
                    char *cbid, void *cbuserdata)
 {
-       struct CitContext *CCC = CC;
        char mimebuf2[SIZ];
        StrBuf *desired_section;
 
        desired_section = (StrBuf *)cbuserdata;
-       IMAP_syslog(LOG_DEBUG, "imap_load_part() looking for %s, found %s",
-                   ChrPtr(desired_section),
-                   partnum
-               );
+       syslog(LOG_DEBUG, "imap: imap_load_part() looking for %s, found %s", ChrPtr(desired_section), partnum);
 
        if (!strcasecmp(partnum, ChrPtr(desired_section))) {
                client_write(content, length);
@@ -350,33 +341,26 @@ void imap_output_envelope_from(struct CtdlMessage *msg) {
        }
 
        /* For everything else, we do stuff. */
-       IAPuts("(("); /* open double-parens */
-       IPutMsgField(eAuthor);  /* personal name */
-       IAPuts(" NIL ");        /* source route (not used) */
-
+       IAPuts("((");                           // open double-parens
+       IPutMsgField(eAuthor);                  // display name
+       IAPuts(" NIL ");                        // source route (not used)
 
        if (!CM_IsEmpty(msg, erFc822Addr)) {
                process_rfc822_addr(msg->cm_fields[erFc822Addr], user, node, name);
-               IPutStr(user, strlen(user));            /* mailbox name (user id) */
+               IPutStr(user, strlen(user));                    /* mailbox name (user id) */
                IAPuts(" ");
-               if (!strcasecmp(node, CtdlGetConfigStr("c_nodename"))) {
-                       IPutStr(CtdlGetConfigStr("c_fqdn"), strlen(CtdlGetConfigStr("c_fqdn")));
-               }
-               else {
-                       IPutStr(node, strlen(node));            /* host name */
-               }
+               IPutStr(node, strlen(node));                    /* host name */
        }
        else {
-               IPutMsgField(eAuthor); /* mailbox name (user id) */
+               IPutMsgField(eAuthor);                          /* Make up a synthetic address */
                IAPuts(" ");
-               IPutMsgField(eNodeName);        /* host name */
+               IPutStr(CtdlGetConfigStr("c_fqdn"), strlen(CtdlGetConfigStr("c_fqdn")));
        }
        
        IAPuts(")) "); /* close double-parens */
 }
 
 
-
 /*
  * Output an envelope address (or set of addresses) in the official,
  * convoluted, braindead format.  (Note that we can't use this for
@@ -447,8 +431,7 @@ void imap_fetch_envelope(struct CtdlMessage *msg) {
        else {
                msgdate = time(NULL);
        }
-       len = datestring(datestringbuf, sizeof datestringbuf,
-                        msgdate, DATESTRING_IMAP);
+       len = datestring(datestringbuf, sizeof datestringbuf, msgdate, DATESTRING_IMAP);
 
        /* Now start spewing data fields.  The order is important, as it is
         * defined by the protocol specification.  Nonexistent fields must
@@ -517,10 +500,9 @@ void imap_fetch_envelope(struct CtdlMessage *msg) {
        len = msg->cm_lengths[emessageId];
        
        if ((len == 0) || (
-                   (msg->cm_fields[emessageId][0] == '<') && 
-                   (msg->cm_fields[emessageId][len - 1] == '>'))
-               )
-       {
+               (msg->cm_fields[emessageId][0] == '<') && 
+               (msg->cm_fields[emessageId][len - 1] == '>'))
+       ) {
                IPutMsgField(emessageId);
        }
        else 
@@ -547,6 +529,7 @@ void imap_fetch_envelope(struct CtdlMessage *msg) {
        IAPuts(")");
 }
 
+
 /*
  * This function is called only when CC->redirect_buffer contains a set of
  * RFC822 headers with no body attached.  Its job is to strip that set of
@@ -666,9 +649,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
        if (strchr(ChrPtr(section), '[') != NULL) {
                StrBufStripAllBut(section, '[', ']');
        }
-       IMAP_syslog(LOG_DEBUG, "Section is: [%s]", 
-                   (StrLength(section) == 0) ? "(empty)" : ChrPtr(section)
-       );
+       syslog(LOG_DEBUG, "imap: selected section is [%s]", (StrLength(section) == 0) ? "(empty)" : ChrPtr(section));
 
        /* Burn the cache if we don't have the same section of the 
         * same message again.
@@ -700,7 +681,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
                is_partial = 1;
        }
        if ( (is_partial == 1) && (StrLength(partial) > 0) ) {
-               IMAP_syslog(LOG_DEBUG, "Partial is <%s>", ChrPtr(partial));
+               syslog(LOG_DEBUG, "imap: selected partial is <%s>", ChrPtr(partial));
        }
 
        if (Imap->cached_body == NULL) {
@@ -1125,16 +1106,16 @@ void imap_do_fetch(citimap_command *Cmd) {
 /* debug output the parsed vector */
        {
                int i;
-               IMAP_syslog(LOG_DEBUG, "----- %ld params", Cmd->num_parms);
+               syslog(LOG_DEBUG, "imap: ----- %ld params", Cmd->num_parms);
 
        for (i=0; i < Cmd->num_parms; i++) {
                if (Cmd->Params[i].len != strlen(Cmd->Params[i].Key))
-                       IMAP_syslog(LOG_DEBUG, "*********** %ld != %ld : %s",
+                       syslog(LOG_DEBUG, "imap: *********** %ld != %ld : %s",
                                    Cmd->Params[i].len, 
                                    strlen(Cmd->Params[i].Key),
                                    Cmd->Params[i].Key);
                else
-                       IMAP_syslog(LOG_DEBUG, "%ld : %s",
+                       syslog(LOG_DEBUG, "imap: %ld : %s",
                                    Cmd->Params[i].len, 
                                    Cmd->Params[i].Key);
        }}
@@ -1457,7 +1438,7 @@ void imap_uidfetch(int num_parms, ConstStr *Params) {
 
        MakeStringOf(Cmd.CmdBuf, 4);
 #if 0
-       IMAP_syslog(LOG_DEBUG, "-------%s--------", ChrPtr(Cmd.CmdBuf));
+       syslog(LOG_DEBUG, "imap: -------%s--------", ChrPtr(Cmd.CmdBuf));
 #endif
        num_items = imap_extract_data_items(&Cmd);
        if (num_items < 1) {