From: Jean-Marc Pigeon (Delson) Date: Mon, 9 Jun 2025 11:44:40 +0000 (-0400) Subject: Improving sending '.' within email X-Git-Tag: tag-0.8~44 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=defc5ad1af7d67b7c773bb401ef7ca214d17d40f;p=jmp%2Fmailleur Improving sending '.' within email --- diff --git a/app/feeder.c b/app/feeder.c index 86f47fb..708fb85 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -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; diff --git a/data-feed/feed01.tst b/data-feed/feed01.tst index b771745..1234295 100644 --- a/data-feed/feed01.tst +++ b/data-feed/feed01.tst @@ -28,6 +28,7 @@ D:. D:this is a line with a dot D: D:. +D:.single dot D:end D:ligne court| C:. diff --git a/lib/gestcp.c b/lib/gestcp.c index f666582..dc9253d 100644 --- a/lib/gestcp.c +++ b/lib/gestcp.c @@ -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); diff --git a/lib/lvleml.c b/lib/lvleml.c index 790f2b4..862e470 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -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,".");