]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Better way to scan email incoming line
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 21 May 2025 20:49:06 +0000 (16:49 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 21 May 2025 20:49:06 +0000 (16:49 -0400)
data-feed/feed02.tst
data-feed/xxfeed.tst
lib/lvleml.c

index 45110589ee621c37eea393f6ef57184110be4779..0ab50ab437c3326d7463c86d268f212c6ca4ea01 100644 (file)
@@ -30,6 +30,9 @@ FIRST Line
 SECOND Line
 LAST Line
 
+this is a line with a dot
+..
+end
 .
 #-------------------------------------------------------------------------
 R:250 3.5.3 Message accepted for delivery
index 45110589ee621c37eea393f6ef57184110be4779..0ab50ab437c3326d7463c86d268f212c6ca4ea01 100644 (file)
@@ -30,6 +30,9 @@ FIRST Line
 SECOND Line
 LAST Line
 
+this is a line with a dot
+..
+end
 .
 #-------------------------------------------------------------------------
 R:250 3.5.3 Message accepted for delivery
index ad53518a59f9330b59d2382d3ce2a6aeff554c18..e59a2954f459fa0bef7bcede913fa9a308e53792 100644 (file)
@@ -307,18 +307,14 @@ static _Bool getdata(CONTYP *contact)
 #define        OPEP    "lvleml.c:getdata,"
 
 _Bool done;
-char *line;
 _Bool empty;
 FILE *queue;
-int got;
 int phase;
 _Bool proceed;
 
 done=false;
-line=(char *)0;
 empty=false;
 queue=(FILE *)0;
-got=0;
 phase=0;
 proceed=setdirectives(contact,"tmp");
 while (proceed==true) {
@@ -336,20 +332,33 @@ while (proceed==true) {
       (void) transmit(contact,"%d 3.5.0 %s",
                               DATAOK,"End data with <CR><LF>.<CR><LF>");
       break;
-    case 3      :       //get incoming line
-      got=tcp_getline(contact->socptr,WAITLINE,&line);
-      if (got<0)        //data timeout
-        phase=999;      //Trouble trouble
+    case 3      :       //get incoming line, detect 'single dot' as end
+      while (proceed==true) {
+        int completed;
+        int got;
+        char *line;
+        
+        completed=false;
+        got=tcp_getline(contact->socptr,WAITLINE,&line);
+        if (got<0) {    //data timeout
+          phase=999;    //trouble trouble
+          break;        //exiting loop
+          }
+        if ((empty==false)||(strcmp(line,".")!=0)) {
+          if (strcmp(line,"..")==0)
+            line[1]='\000';
+          (void) fprintf(queue,"%s\n",line); 
+          }
+        else
+          completed=true;
+        empty=(strlen(line)==0);
+        line=rou_freestr(line);
+        if (completed==true)
+          break;
+        }
       break;
     case 4      :       //just display line
-      if ((empty==false)||(strcmp(line,".")!=0)) {
-        (void) fprintf(queue,"%s\n",line);
-        phase=1;        //Wait for next line
-        }
       empty=false;
-      if (strlen(line)==0)
-        empty=true;
-      line=rou_freestr(line);
       break;
     case 5      :       //got all data
       if (eml_closeqfile(queue)<0)