]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/imap/imap_fetch.c
map_fetch_body() pass StrBuf* into the mimeparser instead of char*, so we fix one...
[citadel.git] / citadel / modules / imap / imap_fetch.c
index db0fbeae83aa1c04260dc11f0c13468aa5c1ab76..aa9a3dfc0a147eb5f08800ed9a9a1fca4d3a153d 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.
@@ -285,51 +285,51 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp,
                    char *cbid, void *cbuserdata)
 {
        char mimebuf2[SIZ];
-       char *desired_section;
+       StrBuf *desired_section;
 
-       desired_section = (char *)cbuserdata;
+       desired_section = (StrBuf *)cbuserdata;
        syslog(LOG_DEBUG, "imap_load_part() looking for %s, found %s",
-               desired_section,
-               partnum
+              ChrPtr(desired_section),
+              partnum
        );
 
-       if (!strcasecmp(partnum, desired_section)) {
-               iaputs(content, length);
+       if (!strcasecmp(partnum, ChrPtr(desired_section))) {
+               client_write(content, length);
        }
 
        snprintf(mimebuf2, sizeof mimebuf2, "%s.MIME", partnum);
 
-       if (!strcasecmp(desired_section, mimebuf2)) {
-               IAPuts("Content-type: ");
-               _iaputs(cbtype);
+       if (!strcasecmp(ChrPtr(desired_section), mimebuf2)) {
+               client_write(HKEY("Content-type: "));
+               client_write(cbtype, strlen(cbtype));
                if (!IsEmptyStr(cbcharset)) {
-                       IAPuts("; charset=\"");
-                       _iaputs(cbcharset);
-                       IAPuts("\"");
+                       client_write(HKEY("; charset=\""));
+                       client_write(cbcharset, strlen(cbcharset));
+                       client_write(HKEY("\""));
                }
                if (!IsEmptyStr(name)) {
-                       IAPuts("; name=\"");
-                       _iaputs(name);
-                       IAPuts("\"");
+                       client_write(HKEY("; name=\""));
+                       client_write(name, strlen(name));
+                       client_write(HKEY("\""));
                }
-               IAPuts("\r\n");
+               client_write(HKEY("\r\n"));
                if (!IsEmptyStr(encoding)) {
-                       IAPuts("Content-Transfer-Encoding: ");
-                       _iaputs(encoding);
-                       IAPuts("\r\n");
+                       client_write(HKEY("Content-Transfer-Encoding: "));
+                       client_write(encoding, strlen(encoding));
+                       client_write(HKEY("\r\n"));
                }
                if (!IsEmptyStr(encoding)) {
-                       IAPuts("Content-Disposition: ");
-                       _iaputs(disp);
+                       client_write(HKEY("Content-Disposition: "));
+                       client_write(disp, strlen(disp));
                
                        if (!IsEmptyStr(filename)) {
-                               IAPuts("; filename=\"");
-                               _iaputs(filename);
-                               IAPuts("\"");
+                               client_write(HKEY("; filename=\""));
+                               client_write(filename, strlen(filename));
+                               client_write(HKEY("\""));
                        }
-                       IAPuts("\r\n");
+                       client_write(HKEY("\r\n"));
                }
-               IAPrintf("Content-Length: %ld\r\n\r\n", (long)length);
+               cprintf("Content-Length: %ld\r\n\r\n", (long)length);
        }
 }
 
@@ -754,10 +754,10 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
         */
        else {
                mime_parser(msg->cm_fields['M'], NULL,
-                               *imap_load_part, NULL, NULL,
-                               ChrPtr(section),
-                               1
-               );
+                           *imap_load_part, NULL, NULL,
+                           section,
+                           1
+                       );
        }
 
        if (loading_body_now) {
@@ -1258,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);
@@ -1293,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);