the message number, because it is being supplied a preloaded message.
* msgbase.c: fixed a problem where HEADERS_NONE mode was broken when
outputting a message in RFC822 format. This was breaking IMAP commands
such as xx FETCH nn BODY[TEXT]
$Log$
+Revision 655.20 2005/10/04 16:38:17 ajc
+* CtdlOutputPreLoadedMsg() calling syntax has changed. It no longer needs
+ the message number, because it is being supplied a preloaded message.
+* msgbase.c: fixed a problem where HEADERS_NONE mode was broken when
+ outputting a message in RFC822 format. This was breaking IMAP commands
+ such as xx FETCH nn BODY[TEXT]
+
Revision 655.19 2005/10/02 04:40:58 ajc
* The EUID index is now built, and replication checks are being performed
using it. It is much faster now because we don't have to scan the entire
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
cmd_isme(&cmdbuf[5]);
}
+ else if (!strncasecmp(cmdbuf, "FUCK", 4)) {
+ cprintf("100\n");
+
+ struct CtdlMessage *msg;
+ msg = CtdlFetchMessage(3115, 1);
+ cprintf("\nCtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1);\n--\n");
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1);
+ cprintf("--\nCtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);\n--\n");
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);
+ cprintf("--\nCtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);\n--\n");
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
+ cprintf("--\n");
+ cprintf("000\n");
+ CtdlFreeMessage(msg);
+ }
+
else if (!DLoader_Exec_Cmd(cmdbuf)) {
cprintf("%d Unrecognized or unsupported command.\n",
ERROR + CMD_NOT_SUPPORTED);
if (strchr(section, '[') != NULL) {
stripallbut(section, '[', ']');
}
- /* lprintf(CTDL_DEBUG, "Section is: %s%s\n", section, ((strlen(section)==0) ? "(empty)" : "") ); */
+ lprintf(CTDL_DEBUG, "Section is: %s%s\n", section, ((strlen(section)==0) ? "(empty)" : "") );
if (!strncasecmp(section, "HEADER", 6)) {
need_body = 0;
}
}
else if ( (!strcmp(section, "1")) && (msg->cm_format_type != 4) ) {
- CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_NONE, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);
}
else if (!strcmp(section, "")) {
- CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_ALL, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
}
/*
* fields, strip it down.
*/
else if (!strncasecmp(section, "HEADER", 6)) {
- CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_ONLY, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1);
imap_strip_headers(section);
}
* Strip it down if the client asked for everything _except_ headers.
*/
else if (!strncasecmp(section, "TEXT", 4)) {
- CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_NONE, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);
}
/*
CC->redirect_buffer = malloc(SIZ);
CC->redirect_len = 0;
CC->redirect_alloc = SIZ;
- CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, 0, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, 0, 0, 1);
rfc822 = CC->redirect_buffer;
rfc822_len = CC->redirect_len;
CC->redirect_buffer = NULL;
}
retcode = CtdlOutputPreLoadedMsg(
- TheMessage, msg_num, mode,
+ TheMessage, mode,
headers_only, do_proto, crlf);
CtdlFreeMessage(TheMessage);
*/
int CtdlOutputPreLoadedMsg(
struct CtdlMessage *TheMessage,
- long msg_num,
int mode, /* how would you like that message? */
int headers_only, /* eschew the message body? */
int do_proto, /* do Citadel protocol responses? */
char mid[100];
char datestamp[100];
- lprintf(CTDL_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %ld, %d, %d, %d, %d\n",
+ lprintf(CTDL_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %d, %d, %d, %d\n",
((TheMessage == NULL) ? "NULL" : "not null"),
- msg_num,
mode, headers_only, do_proto, crlf);
- snprintf(mid, sizeof mid, "%ld", msg_num);
+ strcpy(mid, "unknown");
nl = (crlf ? "\r\n" : "\n");
if (!is_valid_message(TheMessage)) {
}
/* now for the user-mode message reading loops */
- if (do_proto) cprintf("%d Message %ld:\n", LISTING_FOLLOWS, msg_num);
+ if (do_proto) cprintf("%d msg:\n", LISTING_FOLLOWS);
/* Does the caller want to skip the headers? */
if (headers_only == HEADERS_NONE) goto START_TEXT;
(void *)&ma, 0);
}
else if (mode == MT_RFC822) { /* unparsed RFC822 dump */
- /* FIXME ... we have to put some code in here to avoid
- * printing duplicate header information when both
- * Citadel and RFC822 headers exist. Preference should
- * probably be given to the RFC822 headers.
- */
- int done_rfc822_hdrs = 0;
- while (ch=*(mptr++), ch!=0) {
+ char *start_of_text = NULL;
+ start_of_text = strstr(mptr, "\n\r\n");
+ if (start_of_text == NULL) start_of_text = strstr(mptr, "\n\n");
+ if (start_of_text == NULL) start_of_text = mptr;
+ ++start_of_text;
+ start_of_text = strstr(start_of_text, "\n");
+ ++start_of_text;
+ while (ch=*mptr, ch!=0) {
if (ch==13) {
/* do nothing */
}
- else if (ch==10) {
- if (!done_rfc822_hdrs) {
- if (headers_only != HEADERS_NONE) {
- cprintf("%s", nl);
+ else switch(headers_only) {
+ case HEADERS_NONE:
+ if (mptr >= start_of_text) {
+ if (ch == 10) cprintf("%s", nl);
+ else cprintf("%c", ch);
}
- }
- else {
- if (headers_only != HEADERS_ONLY) {
- cprintf("%s", nl);
+ break;
+ case HEADERS_ONLY:
+ if (mptr < start_of_text) {
+ if (ch == 10) cprintf("%s", nl);
+ else cprintf("%c", ch);
}
- }
- if ((*(mptr) == 13) || (*(mptr) == 10)) {
- done_rfc822_hdrs = 1;
- }
- }
- else {
- if (done_rfc822_hdrs) {
- if (headers_only != HEADERS_NONE) {
- cprintf("%c", ch);
- }
- }
- else {
- if (headers_only != HEADERS_ONLY) {
- cprintf("%c", ch);
- }
- }
- if ((*mptr == 13) || (*mptr == 10)) {
- done_rfc822_hdrs = 1;
- }
+ break;
+ default:
+ if (ch == 10) cprintf("%s", nl);
+ else cprintf("%c", ch);
+ break;
}
+ ++mptr;
}
goto DONE;
}
CC->redirect_buffer = malloc(SIZ);
CC->redirect_len = 0;
CC->redirect_alloc = SIZ;
- CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, HEADERS_ALL, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
smi.meta_rfc822_length = CC->redirect_len;
free(CC->redirect_buffer);
CC->redirect_buffer = NULL;
int do_proto, /* do Citadel protocol responses? */
int crlf);
int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
- long,
int mode, /* how would you like that message? */
int headers_only, /* eschew the message body? */
int do_proto, /* do Citadel protocol responses? */
CC->redirect_alloc = SIZ;
safestrncpy(CC->preferred_formats, "text/plain", sizeof CC->preferred_formats);
- CtdlOutputPreLoadedMsg(msg, 0L, MT_CITADEL, HEADERS_NONE, 0, 0);
+ CtdlOutputPreLoadedMsg(msg, MT_CITADEL, HEADERS_NONE, 0, 0);
striplt(CC->redirect_buffer);
fprintf(sc->digestfp, "\n%s\n", CC->redirect_buffer);
CC->redirect_buffer = malloc(SIZ);
CC->redirect_len = 0;
CC->redirect_alloc = SIZ;
- CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, HEADERS_ALL, 0, 1);
+ CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
msgtext = CC->redirect_buffer;
msglen = CC->redirect_len;
CC->redirect_buffer = NULL;