--- lmtp2nntp_config.c 2002/02/28 15:21:02 1.62
+++ lmtp2nntp_config.c 2002/02/28 15:57:09 1.63
@@ -104,30 +104,10 @@
return L2_OK;
}
-static void headersimulation(lmtp2nntp_t *); //FIXME
static void msg_headermatrixbuildup(msg_t *msg);
static void msg_headermatrixteardwn(msg_t *msg);
static void headerrewrite(lmtp2nntp_t *ctx);
-static void extest(void)
-{
- ex_t ex;
-
- try {
- fprintf(stderr, "try\n");
- throw(0,0,0);
- }
- cleanup {
- fprintf(stderr, "cleanup\n");
- }
- catch (ex) {
- fprintf(stderr, "catch\n");
- rethrow;
- }
- exit(0);
-
-}
-
static var_syntax_t syntax_regex = {
'\\', /* escape */
'$', /* varinit */
@@ -146,8 +126,6 @@
//char *cp;
int rc;
- //FIXME ex is broken!? extest();
-
/* create L2 environment */
if (l2_env_create(&ctx->l2_env) != L2_OK) {
fprintf(stderr, "%s:Error: failed to create L2 environment\n", ctx->progname);
@@ -599,7 +577,6 @@
hrNew->pcreRegex = NULL;
hrNew->pcreExtra = NULL;
- //FIXME cp = hrNew->carve = strdupex(cp);
/* priority */
cpP = cp;
if ((cp = strchr(cp, ':')) == NULL) {
@@ -1167,86 +1144,10 @@
}
catch (ex)
rethrow;
-
-
-#if 0
-//void testpcre(void)
-{
- char *szRegex;
- pcre *pcreRegex;
- pcre_extra *pcreExtra;
- const char *szError;
- int nErrorOffset;
- int iCheck;
- int opt;
- char *buf;
- int buf_size;
-#define OVECSIZE 30
- int ovec[OVECSIZE];
- int i;
- const char **cpList;
-
- // 0 1 2
- // 012345678901234567890
- buf = "In-Reply-To: MailTo: Tom & Jerry";
- buf_size = strlen(buf);
- szRegex = "(To|Cc|Bcc):.*(Tom|Snoopy).+&(.*)";
- fprintf(stderr, "DEBUG: 0 1 2 3 4\n");
- fprintf(stderr, "DEBUG: 01234567890123456789012345678901234567890\n");
- fprintf(stderr, "DEBUG: buf =\"%s\"\n", buf);
- fprintf(stderr, "DEBUG: szRegex=\"%s\"\n", szRegex);
- /*
- buf = "In-Reply-To: MailTo: Tom & Jerry";
- szRegex = "(To|Cc|Bcc):.*(Tom|Snoopy).+&(.*)";
- iCheck=4 [0]="To: MailTo: Tom & Jerry" [1]="To" [2]="Tom" [3]=" Jerry"
- */
-
- /* compile regular expression into finite state machine */
- opt = 0;
- // opt |= PCRE_CASELESS;
- // opt |= PCRE_ANCHORED;
- if ((pcreRegex = pcre_compile(szRegex, opt, &szError, &nErrorOffset, NULL)) == NULL) {
- fprintf(stderr, "DEBUG: \"%s\" '%c'\n", szError, szRegex[nErrorOffset]);
- throw(0,0,0);
- }
- /* study finite state machine for more performance */
- pcreExtra = pcre_study(pcreRegex, 0, &szError);
- if (szError != NULL) {
- free(pcreRegex);
- pcreRegex = NULL;
- fprintf(stderr, "DEBUG: \"%s\"\n", szError);
- throw(0,0,0);
- }
-
- /* apply filter */
- iCheck = pcre_exec(pcreRegex, pcreExtra, buf, buf_size, 0, 0, ovec, OVECSIZE);
- fprintf(stderr, "DEBUG: iCheck=%d\n", iCheck);
- for (i = 0; i < iCheck; i++)
- fprintf(stderr, "DEBUG: ovec[%d]=%3d, ovec[%d]=%3d\n", 2*i, ovec[2*i], 2*i+1, ovec[2*i+1]);
-
-
- pcre_get_substring_list(buf, ovec, iCheck, &cpList);
- if (cpList != NULL)
- for (i = 0; i < iCheck; i++)
- fprintf(stderr, "DEBUG: list[%d]=\"%s\"\n", i, cpList[i] == NULL ? "(NULL)" : cpList[i]);
-
- /* destroy channel configuration */
- if (cpList != NULL)
- pcre_free_substring_list(cpList);
- if (pcreRegex != NULL)
- free(pcreRegex);
- if (pcreExtra != NULL)
- free(pcreExtra);
-
-}
-#endif
-
CUS:
return;
}
-
-
static void headerdestroy(headerdata_t *hdC)
{
int i;
@@ -1265,9 +1166,9 @@
if (hdC->name != NULL)
free(hdC->name);
if (hdC->prev != NULL && hdC->prev->next == hdC)
- return; //FIXME still linked, cannot be destroyed
+ throw(0,0,0);
if (hdC->next != NULL && hdC->next->prev == hdC)
- return; //FIXME still linked, cannot be destroyed
+ throw(0,0,0);
free(hdC);
}
@@ -1359,11 +1260,9 @@
cp = NULL;
while ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) != NULL) { /* for each message header */
- //log2(msg, DEBUG, "FIXME trace loop cp=%.8lx, cp=\"%s\"", cp, cp);
/*FIXME we want O(1) here */
for (hdP = NULL, hdI = msg->hdFirst; hdI != NULL; hdP = hdI, hdI = hdI->next) { /* for each matrix header */
- //log2(msg, DEBUG, "FIXME trace loop hdI=%.8lx, hI->name=\"%s\"", hdI, hdI->name);
if (hdI->name == NULL || strlen(hdI->name) == 0 || hdI->ndata == 0)
continue;
if (strcasecmp(cp, hdI->name) == 0)
@@ -1404,23 +1303,6 @@
hdI->data.m[hdI->ndata] = NULL;
}
}
-#if 0
- { //FIXME debug code block
- int i;
- headerdata_t *hdD;
-
- log0(msg, DEBUG, "FIXME trace ---------- msg_headermatrixbuildup() ----------");
- for (hdD = msg->hdFirst; hdD != NULL; hdD = hdD->next) {
- if (hdD->ndata == 0)
- log1(msg, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name);
- if (hdD->ndata == 1)
- log2(msg, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s);
- if (hdD->ndata > 1)
- for (i = 0; i < hdD->ndata; i++)
- log3(msg, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]);
- }
- }
-#endif
}
cleanup {
if (hdNew != NULL)
@@ -1463,57 +1345,16 @@
}
}
}
-#if 0
- { //FIXME debug code block
- int i;
- headerdata_t *hdD;
-
- log0(msg, DEBUG, "FIXME trace ---------- msg_headermatrixteardwn() ----------");
- for (hdD = msg->hdFirst; hdD != NULL; hdD = hdD->next) {
- if (hdD->ndata == 0)
- log1(msg, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name);
- if (hdD->ndata == 1)
- log2(msg, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s);
- if (hdD->ndata > 1)
- for (i = 0; i < hdD->ndata; i++)
- log3(msg, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]);
- }
- }
-#endif
}
catch(ex) {
rethrow;
}
}
-
static void headerrewrite(lmtp2nntp_t *ctx)
{
headerrule_t *hrI;
headerdata_t *hdI, *hdNew;
- /*
- char *cp;
- int i;
- char *cpPri;
- char *cpRegex;
- char *cpHeader;
- char *cpVal;
- headerrule_t *hrP;
- hrNew->pri = atoi(cpPri);
- hrNew->regex = cpRegex;
- hrNew->header = cpHeader;
- hrNew->val = cpVal;
- char *szRegex;
- pcre *pcreRegex;
- pcre_extra *pcreExtra;
- const char *szError;
- int nErrorOffset;
- int opt;
- char *buf;
- int buf_size;
- int ovec[OVECSIZE];
- const char **cpList;
- */
regex_ctx_t *regex_ctx;
#define OVECSIZE 30
int ovec[OVECSIZE];
@@ -1548,7 +1389,6 @@
throw(0,0,0);
}
for (hrI = ctx->option_firstheaderrule; hrI != NULL; hrI = hrI->next) { /* for each rule */
- //log1(ctx, DEBUG, "FIXME trace loop hrI=%.8lx", hrI);
{ //FIXME debug code block
int i;
headerrule_t *hrD;
@@ -1571,7 +1411,6 @@
if (hrI->regex != NULL) {
log1(ctx, DEBUG, "rule has regex %s", hrI->regex);
for (hdI = ctx->msg->hdFirst; hdI != NULL; hdI = hdI->next) { /* for each header */
- //log2(ctx, DEBUG, "FIXME trace loop hdI=%.8lx, hI->name=\"%s\"", hdI, hdI->name);
if (hdI->name == NULL || strlen(hdI->name) == 0 || hdI->ndata == 0)
continue;
regex_ctx->nMatch = pcre_exec(hrI->pcreRegex, hrI->pcreExtra, hdI->name, strlen(hdI->name), 0, 0, ovec, OVECSIZE);
@@ -1679,20 +1518,14 @@
}
for (hdI = ctx->msg->hdFirst; hdI != NULL; hdI = hdI->next) { /* for each header */
if (hdI->name == NULL || strlen(hdI->name) == 0)
- continue; //FIXME header w/o name cannot happen normally
+ continue;
log2(ctx, DEBUG, "hrI->header=%s, hdI->name=%s", hrI->header, hdI->name);
if (strcasecmp(hrI->header, hdI->name) == 0)
break;
}
if (hdI != NULL) {
log1(ctx, DEBUG, "replacing header %s", hrI->header);
- log3(ctx, DEBUG, "ctx->msg->hdFirst=%.8lx, hdI =%.8lx, hdNew =%.8lx", ctx->msg->hdFirst, hdI, hdNew);
- log2(ctx, DEBUG, " hdI->prev=%.8lx, hdNew->prev=%.8lx", hdI->prev, hdNew->prev);
- log2(ctx, DEBUG, " hdI->next=%.8lx, hdNew->next=%.8lx", hdI->next, hdNew->next);
headerreplace(hdI, hdNew);
- log3(ctx, DEBUG, "ctx->msg->hdFirst=%.8lx, hdI =%.8lx, hdNew =%.8lx", ctx->msg->hdFirst, hdI, hdNew);
- log2(ctx, DEBUG, " hdI->prev=%.8lx, hdNew->prev=%.8lx", hdI->prev, hdNew->prev);
- log2(ctx, DEBUG, " hdI->next=%.8lx, hdNew->next=%.8lx", hdI->next, hdNew->next);
if (hdNew->prev == NULL) {
log0(ctx, DEBUG, "FIXME trace #1");
ctx->msg->hdFirst = hdNew;
@@ -1726,56 +1559,3 @@
}
}
}
-
-static void headersimulation(lmtp2nntp_t *ctx)
-{
- headerdata_t *hdI, *hdNew;
- char *replyto[4] = { "foo@example.com", "bar@example.com", "quux@example.com", NULL };
-
- log0(ctx, DEBUG, "FIXME simulation - GO");
-
- ctx->msg = msg_create();
-
- hdNew = headercreate();
- hdNew->name = "To";
- hdNew->data.s = "foo@invalid.com";
- hdNew->ndata = 1;
- ctx->msg->hdFirst = hdNew;
- hdNew->prev = NULL;
- hdI = hdNew;
-
- hdNew = headercreate();
- hdNew->name = "Reply-To";
- hdNew->data.m = replyto;
- hdNew->ndata = 3;
- hdI->next = hdNew;
- hdNew->prev = hdI;
- hdI = hdNew;
-
- hdNew = headercreate();
- hdNew->name = "Subject";
- hdNew->data.s = "a tiny little test";
- hdNew->ndata = 1;
- hdI->next = hdNew;
- hdNew->prev = hdI;
- hdI = hdNew;
-
- hdNew = headercreate();
- hdNew->name = "Date";
- hdNew->data.s = "Mon, 18 Feb 2002 09:43:52 +0100";
- hdNew->ndata = 1;
- hdI->next = hdNew;
- hdNew->prev = hdI;
- hdI = hdNew;
-
- hdNew = headercreate();
- hdNew->name = "Message-ID";
- hdNew->data.s = "<200201172300.AAA29400@procter012.pg-cw.de>";
- hdNew->ndata = 1;
- hdI->next = hdNew;
- hdNew->prev = hdI;
- hdI = hdNew;
-
- hdI->next = NULL;
- headerrewrite(ctx);
-}
|