OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp.c versions 1.12 and 1.13
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.12 -> 1.13

--- lmtp2nntp.c  2001/08/08 09:26:28     1.12
+++ lmtp2nntp.c  2001/08/08 10:43:00     1.13
@@ -754,6 +754,7 @@
     char  *azNewsgroups;
     int    asNewsgroups;
     char **aHeaders;
+    char  *cpMsgid;
     int    i;
     char  *cpCut;
     char  *cpWrap;
@@ -783,7 +784,7 @@
      */
     // fprintf(stderr, "DEBUG: unwrapped ***%s***\n", ctx->message.cpHeaders);
 
-    while (str_parse(ctx->message.cpHeaders, "m/^([\\w-]+?:)\\s*([\\S \\t]*?)\\n(.*)/s", &cpName, &cpValue, &cpRem)) {
+    while (str_parse(ctx->message.cpHeaders, "m/^([\\w-]+?:)[ \\t]*(.*?)[ \\t]*\\n(.*)/s", &cpName, &cpValue, &cpRem)) {
         free(ctx->message.cpHeaders);
         ctx->message.cpHeaders = cpRem;
         //fprintf(stderr, "DEBUG: raw    Name(%s) = Value(%s)\n", cpName, cpValue);
@@ -798,18 +799,38 @@
                                  * MANIPULATE HEADER *                              FIXME make it nice
                                  *********************/
 
-    /* throw out headers we don't want anymore */
-    cp = NULL;
-    while ((cp = argz_next(ctx->message.azHeaders, ctx->message.asHeaders, cp)) != NULL) {
+    /* check for headers we care about and verfiy them, throw them away ... */
+    cpMsgid = NULL;
+    cp = ctx->message.azHeaders;
+    while (cp != NULL) {
+        fprintf(stderr, "DEBUG: checking header ***%s***\n", cp);
         if (strcasecmp("To:", cp) == 0) {
             argz_delete(&ctx->message.azHeaders, &ctx->message.asHeaders, cp); /* name  */
             argz_delete(&ctx->message.azHeaders, &ctx->message.asHeaders, cp); /* value */
+            continue;
         } //FIXME what bad things can happen here (odd number of argz, delete fails ...
         if (strcasecmp("Cc:", cp) == 0) {
             argz_delete(&ctx->message.azHeaders, &ctx->message.asHeaders, cp); /* name  */
             argz_delete(&ctx->message.azHeaders, &ctx->message.asHeaders, cp); /* value */
+            continue;
         } //FIXME what bad things can happen here (odd number of argz, delete fails ...
+        if (strcasecmp("Message-ID:", cp) == 0) {
+            if ((cp = argz_next(ctx->message.azHeaders, ctx->message.asHeaders, cp)) == NULL)
+                break;
+            cpMsgid = cp;
+            if ((cp = argz_next(ctx->message.azHeaders, ctx->message.asHeaders, cp)) == NULL)
+                break;
+            continue;
+        }
+        if ((cp = argz_next(ctx->message.azHeaders, ctx->message.asHeaders, cp)) == NULL)
+            break;
+        if ((cp = argz_next(ctx->message.azHeaders, ctx->message.asHeaders, cp)) == NULL)
+            break;
     }
+    if (cpMsgid == NULL)
+        exit(1); //FIXME
+    else
+        fprintf(stderr, "DEBUG: Message-ID = ***%s***\n", cpMsgid);
 
     /* create a proper Newsgroups: header */
     cp = NULL;
@@ -855,6 +876,7 @@
                 if (i < WRAPAT)
                     i++; /* we don't care about the whitespace itself */
                 cpCut = str_dup(cpRem, i);
+                //FIXME 1.) continue searching downwards skipping all whitespaces and 2.) as we know the length replace str_dup/ strcat/ free with strncat only
                 if (cpWrap == NULL) {
                     if ((cpWrap = (char *)malloc(strlen(cpCut)+strlen(WRAPUSING)+1)) == NULL)
                         exit(1); //FIXME
@@ -880,7 +902,6 @@
             argz_delete(&ctx->message.azHeaders, &ctx->message.asHeaders, cp);
             argz_insert(&ctx->message.azHeaders, &ctx->message.asHeaders, cp, cpWrap);
             free(cpWrap);
-//fprintf(stderr, "DEBUG: after  wrap = ***%s***\n", cp);
         }
     }
 

CVSTrac 2.0.1