Fix warnings all over citserver; handle function replies; remove unused code.
[citadel.git] / citadel / modules / imap / imap_fetch.c
index 7667ab68a60891798cac5052572502722ee214ca..5fedc283afde9e2a7670625bab768e63f8e1415b 100644 (file)
@@ -2,9 +2,9 @@
  * Implements the FETCH command in IMAP.
  * This is a good example of the protocol's gratuitous complexity.
  *
- * Copyright (c) 2001-2009 by the citadel.org team
+ * Copyright (c) 2001-2011 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  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
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
@@ -240,10 +240,10 @@ void imap_fetch_rfc822(long msgnum, const char *whichfmt) {
                text_size = 0;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, 
+       syslog(LOG_DEBUG, 
                "RFC822: headers=" SIZE_T_FMT 
                ", text=" SIZE_T_FMT
-               ", total=" SIZE_T_FMT "\n",
+               ", total=" SIZE_T_FMT,
                headers_size, text_size, total_size);
 
        if (!strcasecmp(whichfmt, "RFC822.SIZE")) {
@@ -288,13 +288,13 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp,
        char *desired_section;
 
        desired_section = (char *)cbuserdata;
-       CtdlLogPrintf(CTDL_DEBUG, "imap_load_part() looking for %s, found %s\n",
+       syslog(LOG_DEBUG, "imap_load_part() looking for %s, found %s",
                desired_section,
                partnum
        );
 
        if (!strcasecmp(partnum, desired_section)) {
-               client_write(content, length);
+               iaputs(content, length);
        }
 
        snprintf(mimebuf2, sizeof mimebuf2, "%s.MIME", partnum);
@@ -671,7 +671,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
        if (strchr(ChrPtr(section), '[') != NULL) {
                StrBufStripAllBut(section, '[', ']');
        }
-       CtdlLogPrintf(CTDL_DEBUG, "Section is: [%s]\n", 
+       syslog(LOG_DEBUG, "Section is: [%s]", 
              (StrLength(section) == 0) ? "(empty)" : ChrPtr(section)
        );
 
@@ -705,7 +705,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
                is_partial = 1;
        }
        if ( (is_partial == 1) && (StrLength(partial) > 0) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "Partial is <%s>\n", ChrPtr(partial));
+               syslog(LOG_DEBUG, "Partial is <%s>", ChrPtr(partial));
        }
 
        if (Imap->cached_body == NULL) {
@@ -1133,17 +1133,16 @@ void imap_do_fetch(citimap_command *Cmd) {
 /* debug output the parsed vector */
        {
                int i;
-               CtdlLogPrintf(CTDL_DEBUG, "----- %ld params \n",
-                             Cmd->num_parms);
+               syslog(LOG_DEBUG, "----- %ld params", Cmd->num_parms);
 
        for (i=0; i < Cmd->num_parms; i++) {
                if (Cmd->Params[i].len != strlen(Cmd->Params[i].Key))
-                       CtdlLogPrintf(CTDL_DEBUG, "*********** %ld != %ld : %s\n",
+                       syslog(LOG_DEBUG, "*********** %ld != %ld : %s",
                                      Cmd->Params[i].len, 
                                      strlen(Cmd->Params[i].Key),
                                      Cmd->Params[i].Key);
                else
-                       CtdlLogPrintf(CTDL_DEBUG, "%ld : %s\n",
+                       syslog(LOG_DEBUG, "%ld : %s",
                                      Cmd->Params[i].len, 
                                      Cmd->Params[i].Key);
        }}
@@ -1259,7 +1258,6 @@ int imap_extract_data_items(citimap_command *Cmd)
        int nArgs;
        int nest = 0;
        const char *pch, *end;
-       long initial_len;
 
        /* Convert all whitespace to ordinary space characters. */
        pch = ChrPtr(Cmd->CmdBuf);
@@ -1294,7 +1292,6 @@ int imap_extract_data_items(citimap_command *Cmd)
         */
        nArgs = StrLength(Cmd->CmdBuf) / 10 + 10;
        nArgs = CmdAdjust(Cmd, nArgs, 0);
-       initial_len = StrLength(Cmd->CmdBuf);
        Cmd->num_parms = 0;
        Cmd->Params[Cmd->num_parms].Key = pch = ChrPtr(Cmd->CmdBuf);
        end = Cmd->Params[Cmd->num_parms].Key + StrLength(Cmd->CmdBuf);
@@ -1468,7 +1465,7 @@ void imap_uidfetch(int num_parms, ConstStr *Params) {
 
        MakeStringOf(Cmd.CmdBuf, 4);
 #if 0
-       CtdlLogPrintf(CTDL_DEBUG, "-------%s--------\n", ChrPtr(Cmd.CmdBuf));
+       syslog(LOG_DEBUG, "-------%s--------", ChrPtr(Cmd.CmdBuf));
 #endif
        num_items = imap_extract_data_items(&Cmd);
        if (num_items < 1) {