#include <ctype.h>
#include <string.h>
#include <limits.h>
+#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
#include "sysdep_decls.h"
#include "policy.h"
#include "database.h"
#include "msgbase.h"
-#include "tools.h"
#include "internet_addressing.h"
-#include "mime_parser.h"
#include "serv_imap.h"
#include "imap_tools.h"
#include "imap_fetch.h"
#include "genstamp.h"
+#include "ctdl_module.h"
CC->redirect_len = 0;
CC->redirect_alloc = SIZ;
CtdlOutputMsg(msgnum, MT_RFC822,
- (need_body ? HEADERS_ALL : HEADERS_ONLY),
- 0, 1, NULL);
+ (need_body ? HEADERS_ALL : HEADERS_FAST),
+ 0, 1, NULL, 0);
if (!need_body) cprintf("\r\n"); /* extra trailing newline */
IMAP->cached_rfc822_data = CC->redirect_buffer;
IMAP->cached_rfc822_len = CC->redirect_len;
text_size = 0;
}
- lprintf(CTDL_DEBUG,
+ CtdlLogPrintf(CTDL_DEBUG,
"RFC822: headers=" SIZE_T_FMT
", text=" SIZE_T_FMT
", total=" SIZE_T_FMT "\n",
if (strchr(section, '[') != NULL) {
stripallbut(section, '[', ']');
}
- lprintf(CTDL_DEBUG, "Section is: %s%s\n",
+ CtdlLogPrintf(CTDL_DEBUG, "Section is: %s%s\n",
section,
IsEmptyStr(section) ? "(empty)" : "");
is_partial = 1;
}
if (is_partial == 0) strcpy(partial, "");
- /* if (!IsEmptyStr(partial)) lprintf(CTDL_DEBUG, "Partial is %s\n", partial); */
+ /* if (!IsEmptyStr(partial)) CtdlLogPrintf(CTDL_DEBUG, "Partial is %s\n", partial); */
if (IMAP->cached_body == NULL) {
CC->redirect_buffer = malloc(SIZ);
}
else if ( (!strcmp(section, "1")) && (msg->cm_format_type != 4) ) {
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1, 0);
}
else if (!strcmp(section, "")) {
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1, 0);
}
/*
* fields, strip it down.
*/
else if (!strncasecmp(section, "HEADER", 6)) {
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_FAST, 0, 1, 0);
imap_strip_headers(section);
}
* Strip it down if the client asked for everything _except_ headers.
*/
else if (!strncasecmp(section, "TEXT", 4)) {
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1, 0);
}
/*
CC->redirect_buffer = malloc(SIZ);
CC->redirect_len = 0;
CC->redirect_alloc = SIZ;
- CtdlOutputPreLoadedMsg(msg, MT_RFC822, 0, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, 0, 0, 1, 0);
rfc822 = CC->redirect_buffer;
rfc822_len = CC->redirect_len;
CC->redirect_buffer = NULL;
*/
void imap_macro_replace(char *str, char *find, char *replace) {
char holdbuf[SIZ];
+ int findlen;
- if (!strncasecmp(str, find, strlen(find))) {
- if (str[strlen(find)]==' ') {
- strcpy(holdbuf, &str[strlen(find)+1]);
+ findlen = strlen(find);
+
+ if (!strncasecmp(str, find, findlen)) {
+ if (str[findlen]==' ') {
+ strcpy(holdbuf, &str[findlen+1]);
strcpy(str, replace);
strcat(str, " ");
strcat(str, holdbuf);
}
- if (str[strlen(find)]==0) {
- strcpy(holdbuf, &str[strlen(find)+1]);
+ if (str[findlen]==0) {
+ strcpy(holdbuf, &str[findlen+1]);
strcpy(str, replace);
}
}
char setstr[SIZ], lostr[SIZ], histr[SIZ];
long lo, hi;
char actual_range[SIZ];
+ struct citimap *Imap;
/*
* Handle the "ALL" macro
safestrncpy(actual_range, supplied_range, sizeof actual_range);
}
+ Imap = IMAP;
/*
* Clear out the IMAP_SELECTED flags for all messages.
*/
- for (i = 0; i < IMAP->num_msgs; ++i) {
- IMAP->flags[i] = IMAP->flags[i] & ~IMAP_SELECTED;
+ for (i = 0; i < Imap->num_msgs; ++i) {
+ Imap->flags[i] = Imap->flags[i] & ~IMAP_SELECTED;
}
/*
hi = atol(histr);
/* Loop through the array, flipping bits where appropriate */
- for (i = 1; i <= IMAP->num_msgs; ++i) {
+ for (i = 1; i <= Imap->num_msgs; ++i) {
if (is_uid) { /* fetch by sequence number */
- if ( (IMAP->msgids[i-1]>=lo)
- && (IMAP->msgids[i-1]<=hi)) {
- IMAP->flags[i-1] |= IMAP_SELECTED;
+ if ( (Imap->msgids[i-1]>=lo)
+ && (Imap->msgids[i-1]<=hi)) {
+ Imap->flags[i-1] |= IMAP_SELECTED;
}
}
else { /* fetch by uid */
if ( (i>=lo) && (i<=hi)) {
- IMAP->flags[i-1] |= IMAP_SELECTED;
+ Imap->flags[i-1] |= IMAP_SELECTED;
}
}
}