$Log$
+ Revision 645.18 2005/05/02 20:52:42 ajc
+ * More IMAP optimizations, including the application of our latest "don't
+ fetch the message body" trick to ENVELOPE and INTERNALDATE fetches, to
+ make MS-Outbreak spread email viruses faster.
+
Revision 645.17 2005/05/02 16:09:52 ajc
* serv_imap.c: implemented the RFC 3501 suggestion that the initial
greeting, and the response to the LOGIN command, include an output
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
* Note that the imap_strout() function can cleverly output NULL fields as NIL,
* so we don't have to check for that condition like we do elsewhere.
*/
-void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
+void imap_fetch_envelope(struct CtdlMessage *msg) {
char datestringbuf[SIZ];
time_t msgdate;
char *fieldptr = NULL;
void imap_do_fetch_msg(int seq, int num_items, char **itemlist) {
int i;
struct CtdlMessage *msg = NULL;
+ int body_loaded = 0;
cprintf("* %d FETCH (", seq);
/* Otherwise, load the message into memory.
*/
else if (!strcasecmp(itemlist[i], "BODYSTRUCTURE")) {
- if (msg == NULL) msg = CtdlFetchMessage(IMAP->msgids[seq-1], 1);
+ if ((msg != NULL) && (!body_loaded)) {
+ CtdlFreeMessage(msg); /* need the whole thing */
+ msg = NULL;
+ }
+ if (msg == NULL) {
+ msg = CtdlFetchMessage(IMAP->msgids[seq-1], 1);
+ body_loaded = 1;
+ }
imap_fetch_bodystructure(IMAP->msgids[seq-1],
itemlist[i], msg);
}
else if (!strcasecmp(itemlist[i], "ENVELOPE")) {
- if (msg == NULL) msg = CtdlFetchMessage(IMAP->msgids[seq-1], 1);
- imap_fetch_envelope(IMAP->msgids[seq-1], msg);
+ if (msg == NULL) {
+ msg = CtdlFetchMessage(IMAP->msgids[seq-1], 0);
+ body_loaded = 0;
+ }
+ imap_fetch_envelope(msg);
}
else if (!strcasecmp(itemlist[i], "INTERNALDATE")) {
- if (msg == NULL) msg = CtdlFetchMessage(IMAP->msgids[seq-1], 1);
+ if (msg == NULL) {
+ msg = CtdlFetchMessage(IMAP->msgids[seq-1], 0);
+ body_loaded = 0;
+ }
imap_fetch_internaldate(msg);
}
*/
void imap_fetch(int num_parms, char *parms[]) {
char items[SIZ];
- char *itemlist[SIZ];
+ char *itemlist[512];
int num_items;
int i;
*/
void imap_uidfetch(int num_parms, char *parms[]) {
char items[SIZ];
- char *itemlist[SIZ];
+ char *itemlist[512];
int num_items;
int i;
int have_uid_item = 0;
}
/* If the "UID" item was not included, we include it implicitly
- * because this is a UID FETCH command
+ * (at the beginning) because this is a UID FETCH command
*/
for (i=0; i<num_items; ++i) {
if (!strcasecmp(itemlist[i], "UID")) ++have_uid_item;
}
- if (have_uid_item == 0) itemlist[num_items++] = "UID";
+ if (have_uid_item == 0) {
+ memmove(&itemlist[1], &itemlist[0], (sizeof(itemlist[0]) * num_items));
+ ++num_items;
+ itemlist[0] = "UID";
+ }
imap_do_fetch(num_items, itemlist);
cprintf("%s OK UID FETCH completed\r\n", parms[0]);