]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Improving sending '.' within email
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 9 Jun 2025 11:44:40 +0000 (07:44 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 9 Jun 2025 11:44:40 +0000 (07:44 -0400)
app/feeder.c
data-feed/feed01.tst
lib/gestcp.c
lib/lvleml.c

index 86f47fba0dc160b437c6d88193eb41b30b37c178..708fb85fc38c280f9a141cd2a9da7d9e56f2117d 100644 (file)
@@ -127,7 +127,6 @@ static _Bool dosenddata(FEEDTYP *fd,int *numline)
 
 int status;
 char *line;
-_Bool empty;
 char *action;
 char data[300];
 int phase;
@@ -135,7 +134,6 @@ _Bool proceed;
 
 status=false;
 line=(char *)0;
-empty=false;
 action="DATA";
 (void) strcpy(data,"");
 phase=0;
@@ -176,15 +174,14 @@ while (proceed==true) {
           }
         switch (data[0]) {
           case 'D'      :       //pure data
-            if ((strcmp(data+2,".")==0)&&(empty==true))
-              (void) strcat(data,".");
+            if (data[2]=='.') {
+              (void) memmove(data+3,data+2,strlen(data+2));
+              }
             (void) tcp_write(fd->socptr,data+2);
-            empty=(strlen(data+2)==0);
             break;
           case 'C'      :       //data marker
             switch (data[2]) {
               case '.'  :       //end of data marker
-                (void) tcp_write(fd->socptr,"");
                 (void) tcp_write(fd->socptr,".");
                 completed=true;
                 break;
index b77174582d4b4d005fbf1aed007285359c2625b8..1234295cadd05c84613b66d7f74aaf933de77a08 100644 (file)
@@ -28,6 +28,7 @@ D:.
 D:this is a line with a dot
 D:
 D:.
+D:.single dot
 D:end
 D:ligne court|
 C:.
index f666582c1e5ece0c6135767b9992b99ce9e29de6..dc9253d80f8e3944fba3f338b55de1af45e24f6b 100644 (file)
@@ -217,22 +217,32 @@ while (proceed==true) {
         }
       break;
     case 1      :  {    //transmitting data to remote
-      _Bool empty;
       char data[300];
 
       sent=0;
-      empty=false;
       while (fgets(data,sizeof(data),qfile)!=(char *)0) {
-        if ((empty==true)&&(strcmp(data,".")==0))
-          (void) strcat(data,".");
-        empty=(strlen(data)==0);
+        do {    //cleaning line
+          register int taille;
+          register char *ptr;
+
+          taille=strlen(data)-1;
+          if (taille<0)
+            break;
+          ptr=data+taille;
+          if ((*ptr!='\n')&&(*ptr!='\r'))
+            break;
+          *ptr='\000';
+          }
+        while (strlen(data)>0);
+        if ((strlen(data)>0)&&(data[0]=='.'))
+          //dot escape
+          (void) memmove(data+1,data,strlen(data));
         sent+=tcp_write(rmt->socptr,data);
         (void) rou_alert(0,"%s JMPDBG data=<%s>",OPEP,data);
         }
       break;
       }
-    case 2      :       //transmitting and empty line
-      (void) tcp_write(rmt->socptr,"");
+    case 2      :       //end of transmission
       break;
     case 3      :       //closing datafile
       qfile=eml_closeqfile(qfile);
index 790f2b4237e7f1f04fb46cf3c62bd1d632559153..862e47087af068699da59215c89af7f354727ce5 100644 (file)
@@ -343,14 +343,12 @@ static _Bool getdata(CONTYP *contact)
 
 _Bool done;
 FILE *queue;
-_Bool empty;
 _Bool completed;
 int phase;
 _Bool proceed;
 
 done=false;
 queue=(FILE *)0;
-empty=false;
 completed=false;
 phase=0;
 proceed=setdirectives(contact,"tmp");
@@ -380,18 +378,13 @@ while (proceed==true) {
           phase=999;    //trouble trouble
           break;        //exiting loop
           }
-        if ((empty==true)&&(strcmp(line,".")==0)) {
+        if (strcmp(line,".")==0) {
           completed=true;
           }
         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); 
+          if ((strlen(line)>1)&&(line[0]=='.'))
+            (void) memmove(line,line+1,strlen(line));
+          (void) fprintf(queue,"%s\n",line); 
           }
         line=rou_freestr(line);
         }
@@ -846,10 +839,12 @@ static int senddata(RMTTYP *rmt,TRATYP **tosend,const char *sessid)
 #define OPEP    "lvleml.c:senddata,"
 
 int rspcode;
+int sent;
 int phase;
 _Bool proceed;
 
 rspcode=0;
+sent=0;
 phase=0;
 proceed=true;
 while (proceed==true) {
@@ -865,7 +860,10 @@ while (proceed==true) {
         }
       break;
     case 1      :       //sending session data
-      (void) tcp_send_smtp_data(rmt,sessid);
+      sent=tcp_send_smtp_data(rmt,sessid);
+      (void) log_fprintlog(rmt->logptr,false,"Sent '%05d' bytes",sent);
+      if (sent<0)
+        phase=999;      //No need to wait form response code
       break;
     case 2      :       //sending session data
       rspcode=tcp_smtp_command(rmt,".");