From dce1d2c10059953d261c537243aa3e3217b251b9 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 17 Dec 1999 22:42:04 +0000 Subject: [PATCH] * More header parsing stuff. Still needs work. --- citadel/internet_addressing.c | 40 +++++++++++++++++++++++++++++------ citadel/internet_addressing.h | 4 +++- citadel/serv_smtp.c | 7 ++++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 6dc5a1fc6..80c7e05ae 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -263,12 +264,12 @@ int convert_internet_address(char *destuser, char *desthost, char *source) struct CtdlMessage *convert_internet_message(char *rfc822) { struct CtdlMessage *msg; - char *buf; - int pos; + int pos, beg, end; int msglen; int done; - char *field; char buf[256]; + char field[256]; + int i; msg = mallok(sizeof(struct CtdlMessage)); if (msg == NULL) return msg; @@ -283,15 +284,42 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { msglen = strlen(rfc822); pos = 0; done = 0; - field = NULL; while (!done) { - for (i=pos; i<=strlen(rfc822); ++i) { + /* Locate beginning and end of field, keeping in mind that + * some fields might be multiline + */ + beg = pos; + end = (-1); + for (pos=beg; ((pos<=strlen(rfc822))&&(end<0)); ++pos) { + if ((rfc822[pos]=='\n') + && (!isspace(rfc822[pos+1]))) { + end = pos; + } + if ( (rfc822[pos]=='\n') /* done w. headers? */ + && ( (rfc822[pos+1]=='\n') + ||(rfc822[pos+1]=='\r'))) { + end = pos; + done = 1; + } + + } - + /* At this point we have a field. Are we interested in it? */ + strcpy(field, ""); + for (i = beg; i <= end; ++i) { + if ((rfc822[i] == ':') && ((i-beg)\n", + beg, end, field); + /* If we've hit the end of the message, bail out */ + if (pos > strlen(rfc822)) done = 1; } diff --git a/citadel/internet_addressing.h b/citadel/internet_addressing.h index 81913878b..7ce714a2c 100644 --- a/citadel/internet_addressing.h +++ b/citadel/internet_addressing.h @@ -1,8 +1,8 @@ int fuzzy_match(struct usersupp *us, char *matchstring); void process_rfc822_addr(char *rfc822, char *user, char *node, char *name); -int convert_internet_address(char *destuser, char *desthost, char *source); +int convert_internet_address(char *destuser, char *desthost, char *source); enum { rfc822_address_locally_validated, rfc822_no_such_user, @@ -10,3 +10,5 @@ enum { rfc822_address_invalid }; + +struct CtdlMessage *convert_internet_message(char *rfc822); diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index d370d03fe..fe7859288 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -368,7 +368,9 @@ void smtp_rcpt(char *argbuf) { */ void smtp_data(void) { char *body; + struct CtdlMessage *msg; +/* if (strlen(SMTP->from) == 0) { cprintf("503 Need MAIL command first.\n"); return; @@ -379,6 +381,8 @@ void smtp_data(void) { return; } +*/ + cprintf("354 Transmit message now; terminate with '.' by itself\n"); body = CtdlReadMessageBody(".", config.c_maxmsglen); if (body == NULL) { @@ -386,6 +390,9 @@ void smtp_data(void) { return; } + fprintf(stderr, "Converting message...\n"); + msg = convert_internet_message(body); + phree(body); cprintf("599 command unfinished\n"); } -- 2.30.2