]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Able to transmit '.' within email data flow
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 22 May 2025 00:43:05 +0000 (20:43 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 22 May 2025 00:43:05 +0000 (20:43 -0400)
app/feeder.c
data-feed/feed02.tst
data-feed/xxfeed.tst
lib/lvleml.c

index b6dd848918a9e4e4c031757fd6c54d4ac77ed67d..8e512586e92c8dba8eec64f04cfcbac1b281992a 100644 (file)
@@ -144,21 +144,21 @@ static _Bool dosenddata(FEEDTYP *fd)
 
 int status;
 char *line;
-char *action;
 _Bool empty;
+char *action;
 char data[300];
 int phase;
 _Bool proceed;
 
 status=false;
 line=(char *)0;
-action="data";
 empty=false;
+action="DATA";
 (void) strcpy(data,"");
 phase=0;
 proceed=true;
 while (proceed==true) {
-  (void) rou_alert(0,"%s phase='%d'",OPEP,phase);
+  //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase);
   switch (phase) {
     case 0      :       //Transmit "DATA" to remote
       if (dooutgoing(fd->socptr,action)!=(strlen(action)+2))
@@ -173,7 +173,6 @@ while (proceed==true) {
         int code;
 
         code=0;
-        (void) rou_alert(0,"%s JMPDBG line=<%s>",OPEP,line);
         (void) sscanf(line,"%d",&code); 
         if (code!=DATAOK) 
           phase=999;
@@ -182,23 +181,38 @@ while (proceed==true) {
       break;
     case 3      :       //
       while (fgets(data,sizeof(data),fd->datatst)!=(char *)0) {
+        _Bool completed;
+
+        completed=true;
         (void) eml_removecrlf(data);
-        (void) dooutgoing(fd->socptr,data);
-        if ((empty==true)&&(strcmp(data,".")==0)) {
-          phase++;      //Eveything is fine
-          break;
+        switch (data[0]) {
+          case 'D'      :
+            if ((strcmp(data+2,".")==0)&&(empty==true))
+              (void) strcat(data,".");
+            (void) dooutgoing(fd->socptr,data+2);
+            empty=(strlen(data+2)==0);
+            completed=false;
+            break;
+          case 'C'      :
+            if (data[2]=='.') {
+              (void) dooutgoing(fd->socptr,"");
+              (void) dooutgoing(fd->socptr,".");
+              }
+            else
+              (void) rou_alert(0,"%s Unexpected data close <%s> (Bug?)",
+                                  OPEP,data);
+            break;
+          default       :
+            (void) rou_alert(0,"%s Unexpected data to be send <%s> (Bug?)",
+                                  OPEP,data);
+            break;
+          }
+        if (completed==true) {
+          status=true;
+          break;        //All data sent.
           }
-        empty=false;
-        if (strlen(data)==0)
-          empty=true;
         }
       break;
-    case 4      :       //phase reached only by data exhaustion
-      phase=999;        //Trouble trouble
-      break;
-    case 5      :       //all data sent lets say it is good
-      status=true;
-      break;
     default     :       //SAFE Guard
       proceed=false;
       break;
index 0ab50ab437c3326d7463c86d268f212c6ca4ea01..cff9b248524c8675ec64d3813040c960639b3ce6 100644 (file)
@@ -2,9 +2,6 @@
 #====================================================
 T:Sending a very Simple Email
 R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-C:ORGN 127.127.0.2
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-#C:WAIT 100
 #====================================================
 S:HELO example.com
 #R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com]
@@ -22,18 +19,20 @@ R:250 2.6.4 Address accepted
 #-------------------------------------------------------------------------
 #-sending data
 C:DATA
-Subject: Very Simple email contents
-From: Maitre Post <postmaster@example.com>
-To: Maitre WEB <webmaster@example.com>
-
-FIRST Line
-SECOND Line
-LAST Line
-
-this is a line with a dot
-..
-end
-.
+D:Subject: Very Simple email contents
+D:From: Maitre Post <postmaster@example.com>
+D:To: Maitre WEB <webmaster@example.com>
+D:
+D:FIRST Line
+D:SECOND Line
+D:LAST Line
+D:.
+D:this is a line with a dot
+D:
+D:.
+D:end
+D:ligne court|
+C:.
 #-------------------------------------------------------------------------
 R:250 3.5.3 Message accepted for delivery
 S:QUIT
@@ -58,13 +57,14 @@ R:250 2.6.4 Address accepted
 #-------------------------------------------------------------------------
 #-sending data
 C:DATA
-Subject: Second email contents
-
-SECOND FIRST Line
-SECOND SECOND Line
-SECOND LAST Line
-
-.
+D:Subject: Second email contents
+D:
+D:SECOND FIRST Line
+D:SECOND SECOND Line
+D:SECOND LAST Line
+D:
+D:
+C:.
 #-------------------------------------------------------------------------
 R:250 3.5.3 Message accepted for delivery
 S:QUIT
@@ -88,13 +88,13 @@ R:250 2.6.4 Address accepted
 #-------------------------------------------------------------------------
 #-sending data
 C:DATA
-Subject: Third email contents
-
-THIRD FIRST Line
-THIRD SECOND Line
-THIRD LAST Line
-
-.
+D:Subject: Third email contents
+D:
+D:THIRD FIRST Line
+D:THIRD SECOND Line
+D:THIRD LAST Line
+D:
+C:.
 #-------------------------------------------------------------------------
 R:250 3.5.3 Message accepted for delivery
 S:QUIT
index 0ab50ab437c3326d7463c86d268f212c6ca4ea01..cff9b248524c8675ec64d3813040c960639b3ce6 100644 (file)
@@ -2,9 +2,6 @@
 #====================================================
 T:Sending a very Simple Email
 R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-C:ORGN 127.127.0.2
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-#C:WAIT 100
 #====================================================
 S:HELO example.com
 #R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com]
@@ -22,18 +19,20 @@ R:250 2.6.4 Address accepted
 #-------------------------------------------------------------------------
 #-sending data
 C:DATA
-Subject: Very Simple email contents
-From: Maitre Post <postmaster@example.com>
-To: Maitre WEB <webmaster@example.com>
-
-FIRST Line
-SECOND Line
-LAST Line
-
-this is a line with a dot
-..
-end
-.
+D:Subject: Very Simple email contents
+D:From: Maitre Post <postmaster@example.com>
+D:To: Maitre WEB <webmaster@example.com>
+D:
+D:FIRST Line
+D:SECOND Line
+D:LAST Line
+D:.
+D:this is a line with a dot
+D:
+D:.
+D:end
+D:ligne court|
+C:.
 #-------------------------------------------------------------------------
 R:250 3.5.3 Message accepted for delivery
 S:QUIT
@@ -58,13 +57,14 @@ R:250 2.6.4 Address accepted
 #-------------------------------------------------------------------------
 #-sending data
 C:DATA
-Subject: Second email contents
-
-SECOND FIRST Line
-SECOND SECOND Line
-SECOND LAST Line
-
-.
+D:Subject: Second email contents
+D:
+D:SECOND FIRST Line
+D:SECOND SECOND Line
+D:SECOND LAST Line
+D:
+D:
+C:.
 #-------------------------------------------------------------------------
 R:250 3.5.3 Message accepted for delivery
 S:QUIT
@@ -88,13 +88,13 @@ R:250 2.6.4 Address accepted
 #-------------------------------------------------------------------------
 #-sending data
 C:DATA
-Subject: Third email contents
-
-THIRD FIRST Line
-THIRD SECOND Line
-THIRD LAST Line
-
-.
+D:Subject: Third email contents
+D:
+D:THIRD FIRST Line
+D:THIRD SECOND Line
+D:THIRD LAST Line
+D:
+C:.
 #-------------------------------------------------------------------------
 R:250 3.5.3 Message accepted for delivery
 S:QUIT
index e59a2954f459fa0bef7bcede913fa9a308e53792..c8876c800b2b308749201e255eed9b6695fe56f9 100644 (file)
@@ -307,18 +307,20 @@ static _Bool getdata(CONTYP *contact)
 #define        OPEP    "lvleml.c:getdata,"
 
 _Bool done;
-_Bool empty;
 FILE *queue;
+_Bool empty;
+_Bool completed;
 int phase;
 _Bool proceed;
 
 done=false;
-empty=false;
 queue=(FILE *)0;
+empty=false;
+completed=false;
 phase=0;
 proceed=setdirectives(contact,"tmp");
 while (proceed==true) {
-  (void) rou_alert(0,"JMPDBG %s phase='%d' empty='%d'",OPEP,phase,empty);
+  //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
   switch (phase) {
     case 0      :       //opening the queue email
       if ((queue=eml_createqfile(contact->cursesid,""))==(FILE *)0) 
@@ -333,8 +335,7 @@ while (proceed==true) {
                               DATAOK,"End data with <CR><LF>.<CR><LF>");
       break;
     case 3      :       //get incoming line, detect 'single dot' as end
-      while (proceed==true) {
-        int completed;
+      while (completed==false) {
         int got;
         char *line;
         
@@ -344,31 +345,31 @@ while (proceed==true) {
           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
+        if ((empty==true)&&(strcmp(line,".")==0)) {
           completed=true;
-        empty=(strlen(line)==0);
+          }
+        else {
+          if (empty==true) {
+            (void) fprintf(queue,"\n"); 
+            if (strcmp(line,"..")==0) 
+              line[1]='\000';   //removing double dot
+            }
+          empty=(strlen(line)==0);
+          if (empty==false)
+            (void) fprintf(queue,"%s\n",line); 
+          }
         line=rou_freestr(line);
-        if (completed==true)
-          break;
         }
       break;
-    case 4      :       //just display line
-      empty=false;
-      break;
-    case 5      :       //got all data
+    case 4      :       //got all data
       if (eml_closeqfile(queue)<0)
         phase=999;              //Trouble trouble
       break;
-    case 6      :       //renameing directive
+    case 5      :       //renameing directive
       if (eml_renameqfile(contact->cursesid,"tmp",EXTRANS)==false)
         phase=999;              //Trouble trouble
       break;
-    case 7      :       //everything fine
+    case 6      :       //everything fine
       (void) transmit(contact,"%d 3.5.3 %s",
                               CMDOK,"Message accepted for delivery");
       done=true;
@@ -698,7 +699,9 @@ while (proceed==true) {
                                                "condition=<%s>",str);
     //(void) rou_alert(0,"%s exit status='%d'",OPEP,status);
     break;              //no need to go further
+
     }
+  (void) rou_alert(0,"%s JMPDBG got <%s>",OPEP,line);
   (void) log_fprintlog(contact->logptr,false,"%s",line);
   code=eml_getcode(line);
   switch (code) {