--- lmtp2nntp_msg.c 2002/05/29 10:21:33 1.27
+++ lmtp2nntp_msg.c 2002/05/29 21:35:52 1.28
@@ -159,14 +159,12 @@
free(msg->cpMsg);
msg->cpMsg = NULL;
- logbook(msg->l2, L2_LEVEL_DEBUG, "replace envelope From w/o colon by X-F: pseudotag");
+ logbook(msg->l2, L2_LEVEL_DEBUG, "replace envelope-from by -FE: pseudoheader");
/* This eliminates the special case of having one header, which is really
* an embedded envelope, not ending with a colon while all others do.
- * After splitting headers into name and value pairs this envelope ist
- * stripped off.
*/
if (strncasecmp(cpHeaders, "From", 4) == 0)
- memcpy(cpHeaders, "X-F:", 4);
+ memcpy(cpHeaders, "-EF:", 4);
logbook(msg->l2, L2_LEVEL_DEBUG, "unwrap header lines");
/* poor man's s///g simulator as current str library doesn't support global substitution */
@@ -186,22 +184,11 @@
}
logbook(msg->l2, L2_LEVEL_DEBUG, "check for headers we care about and do whatever neccessary");
- msg->cpMsgid = NULL;
msg->azNewsgroups = NULL;
msg->asNewsgroups = 0;
cp = msg->azHeaders;
while (cp != NULL) {
- logbook(msg->l2, L2_LEVEL_DEBUG, "processing header \"%s\"", cp);
- if (strcasecmp("X-F:", cp) == 0) {
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */
- continue;
- }
- if (strcasecmp("Path:", cp) == 0) {
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */
- continue;
- }
+ logbook(msg->l2, L2_LEVEL_DEBUG, "processing header \"%s\" in split", cp);
if (strcasecmp("Received:", cp) == 0) {
argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */
if ((msg->cpFid == NULL) &&
@@ -210,32 +197,13 @@
argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */
continue;
}
- if (strcasecmp("To:", cp) == 0) {
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */
- continue;
- }
- if (strcasecmp("Cc:", cp) == 0) {
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */
- continue;
- }
- if (strcasecmp("Message-ID:", cp) == 0) {
- if (msg->cpMsgid != NULL)
- return MSG_ERR_SPLITIDMULTI;
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */
- if ((cp == NULL) || (strlen(cp) == 0)) /* get value */
- return MSG_ERR_SPLITIDEMPTY;
- if ((msg->cpMsgid = strdup(cp)) == NULL)
- return MSG_ERR_MEM;
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */
- continue;
- }
if (strcasecmp("Newsgroups:", cp) == 0) {
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del name */
+ if ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) == NULL) /* next value */
+ break;
if (argz_add(&msg->azNewsgroups, &msg->asNewsgroups, cp) != 0) /* get value */
return MSG_ERR_MEM;
- argz_delete(&msg->azHeaders, &msg->asHeaders, cp); /* del value */
+ if ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) == NULL) /* next value */
+ break;
continue;
}
if ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) == NULL) /* next value */
@@ -244,10 +212,6 @@
break;
}
- logbook(msg->l2, L2_LEVEL_DEBUG, "checking Message-ID");
- if (msg->cpMsgid == NULL)
- return MSG_ERR_SPLITIDNONE;
-
logbook(msg->l2, L2_LEVEL_DEBUG, "checking Newsgroups");
if (msg->azNewsgroups != NULL) {
argz_stringify(msg->azNewsgroups, msg->asNewsgroups, ',');
@@ -255,10 +219,6 @@
return MSG_ERR_MEM;
}
- logbook(msg->l2, L2_LEVEL_DEBUG, "adding mandatory Path: header");
- argz_add(&msg->azHeaders, &msg->asHeaders, "Path:");
- argz_add(&msg->azHeaders, &msg->asHeaders, "lmtp2nntp!not-for-mail");
-
logbook(msg->l2, L2_LEVEL_DEBUG, "split complete");
return MSG_OK;
}
@@ -289,12 +249,31 @@
argz_add(&msg->azHeaders, &msg->asHeaders, msg->azNewsgroups);
logbook(msg->l2, L2_LEVEL_DEBUG, "verify Message-ID");
+ cp = msg->azHeaders;
+ while (cp != NULL) {
+ logbook(msg->l2, L2_LEVEL_DEBUG, "processing header \"%s\" in join", cp);
+ if (strcasecmp("Message-ID:", cp) == 0) {
+ if (msg->cpMsgid != NULL)
+ return MSG_ERR_JOINIDMULTI;
+ if ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) == NULL) /* next value */
+ break;
+ if ((cp == NULL) || (strlen(cp) == 0)) /* get value */
+ return MSG_ERR_JOINIDEMPTY;
+ if ((msg->cpMsgid = strdup(cp)) == NULL)
+ return MSG_ERR_MEM;
+ if ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) == NULL) /* next value */
+ break;
+ continue;
+ }
+ if ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) == NULL) /* next value */
+ break;
+ if ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) == NULL) /* next name */
+ break;
+ }
if (msg->cpMsgid == NULL)
return MSG_ERR_JOINIDNONE;
if (strlen(msg->cpMsgid) == 0)
return MSG_ERR_JOINIDEMPTY;
- argz_add(&msg->azHeaders, &msg->asHeaders, "Message-ID:");
- argz_add(&msg->azHeaders, &msg->asHeaders, msg->cpMsgid);
logbook(msg->l2, L2_LEVEL_DEBUG, "merge name/value pairs into single string");
argz_add(&msg->azHeaders, &msg->asHeaders, ""); /* append empty string */
@@ -465,13 +444,11 @@
else if (rc == MSG_ERR_SPLITHEADBODY ) str = "MSG: split into header and body failed";
else if (rc == MSG_ERR_SPLITLEN ) str = "MSG: header is too short";
else if (rc == MSG_ERR_SPLITMISSINGFROM ) str = "MSG: header is missing 'From ' envelope";
- else if (rc == MSG_ERR_SPLITIDNONE ) str = "MSG: header is missing 'Message-ID'";
- else if (rc == MSG_ERR_SPLITIDEMPTY ) str = "MSG: header has empty 'Message-ID'";
- else if (rc == MSG_ERR_SPLITIDMULTI ) str = "MSG: header has multiple 'Message-ID's";
else if (rc == MSG_ERR_JOINGROUPNONE ) str = "MSG: join with no 'Newsgroup'";
else if (rc == MSG_ERR_JOINGROUPEMPTY ) str = "MSG: join with empty 'Newsgroup'";
else if (rc == MSG_ERR_JOINIDNONE ) str = "MSG: join with no 'Message-ID'";
else if (rc == MSG_ERR_JOINIDEMPTY ) str = "MSG: join with empty 'Message-ID'";
+ else if (rc == MSG_ERR_JOINIDMULTI ) str = "MSG: join with multiple 'Message-ID's";
return str;
}
@@ -724,6 +701,13 @@
int maxsize;
char *format;
+ if (nVal > 2 && cpVal[0] == '<' && cpVal[nVal-1] == '>') {
+ *cppOut = strdupex(cpVal);
+ *pnOutsize = nVal;
+ *pnOut = nVal;
+ return VAR_OK;
+ }
+
if (val_get(prival, "msgcount", &msgcount) != VAL_OK)
msgcount = 0;
@@ -757,12 +741,6 @@
else
cp = strdupex("<>"); /* if format fails, do not end the wholly program abnormally */
- if (msg != NULL) {
- if (msg->cpMsgid != NULL)
- free(msg->cpMsgid);
- msg->cpMsgid = strdupex(cp);
- }
-
*cppOut = strdupex(cp);
*pnOutsize = strlen(cp) + 1;
*pnOut = strlen(cp);
@@ -778,13 +756,7 @@
{
val_t *prival = _prival;
- if (val_ptr == NULL) {
- *out_ptr = "";
- *out_len = 0;
- *out_size = 0;
- return VAR_OK;
- }
- else if (op_len == 15 && strncmp(op_ptr, "createmessageid", 15) == 0) {
+ if (op_len == 15 && strncmp(op_ptr, "createmessageid", 15) == 0) {
return createmessageid(prival, arg_ptr, arg_len, val_ptr, val_len, out_ptr, out_len, out_size);
}
else if (op_len == 12 && strncmp(op_ptr, "canonifydate", 12) == 0) {
|