* 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
* 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;
}
(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;
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);
}
-
/*
* 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"
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);
}
/* 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
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
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
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
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.
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) {
/* 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);
}}
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) {