From: Jean-Marc Pigeon (Delson) Date: Sat, 24 May 2025 04:17:59 +0000 (-0400) Subject: Good line count with feed comment and data. X-Git-Tag: tag-0.8~86 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=279dc56fb8dbdb4565b7947830684e80a17e07a4;p=jmp%2Fmailleur Good line count with feed comment and data. --- diff --git a/app/feeder.c b/app/feeder.c index 8e51258..1c56f8c 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -137,7 +137,7 @@ return done; /* server. */ /* */ /************************************************/ -static _Bool dosenddata(FEEDTYP *fd) +static _Bool dosenddata(FEEDTYP *fd,int *numline) { #define OPEP "feeder.c:dosenddata," @@ -184,6 +184,7 @@ while (proceed==true) { _Bool completed; completed=true; + (*numline)++; (void) eml_removecrlf(data); switch (data[0]) { case 'D' : @@ -353,9 +354,11 @@ return code; /* protocol. */ /* */ /********************************************************/ -static _Bool docommand(FEEDTYP *fd,int numline,char *line) +static _Bool docommand(FEEDTYP *fd,int *numline,char *line) { +#define OPEP "docommand" + _Bool status; char *param; @@ -367,45 +370,46 @@ if ((param=strchr(line,' '))!=(char *)0) { switch (getcmd(line)) { case cmd_comment : //detect comment flag if (setcomment(fd,param)==false) - (void) report(numline,line,"Unable to set comment mode"); + (void) report(*numline,line,"Unable to set comment mode"); break; case cmd_data : //sending email content to remote - if ((status=dosenddata(fd))==false) - (void) report(numline,line,"Unable to fully send data"); + if ((status=dosenddata(fd,numline))==false) + (void) report(*numline,line,"Unable to fully send data"); break; case cmd_gotls : //GOTLS if ((status=gomodetls(fd->socptr))==false) - (void) report(numline,line,"Unable to set TLS mode"); + (void) report(*numline,line,"Unable to set TLS mode"); break; case cmd_orgn : //Changing PEERIP if (param!=(char *)0) { if(( status=dorestart(fd,param))==false) - (void) report(numline,line,"Unable to change srcip!"); + (void) report(*numline,line,"Unable to change srcip!"); } else { - (void) report(numline,line,"Missing new PEER IP value"); + (void) report(*numline,line,"Missing new PEER IP value"); status=false; } break; case cmd_restart : //restart link if ((status=dorestart(fd,(char *)0))==false) - (void) report(numline,line,"Unable to restart feed socket!"); + (void) report(*numline,line,"Unable to restart feed socket!"); break; case cmd_wait : //SLEEP mode if (param!=(char *)0) (void) sleep(atoi(param)); else { - (void) report(numline,line,"Missing 'seconds' parameters"); + (void) report(*numline,line,"Missing 'seconds' parameters"); status=false; } break; case cmd_unknown : default : - (void) report(numline,line,"Unknown command"); + (void) report(*numline,line,"Unknown command"); status=false; break; } return status; +#undef OPEP } /* @@ -506,7 +510,7 @@ return status; /* Scanning one line from test file */ /* */ /********************************************************/ -static _Bool scanline(FEEDTYP *fd,int numline,char *line) +static _Bool scanline(FEEDTYP *fd,int *numline,char *line) { #define OPEP "feeder.c:scanline" @@ -525,12 +529,14 @@ while (proceed==true) { case 0 : //removing first space while ((line[0]==' ')||(line[0]=='\t')) (void) memmove(line,line+1,(strlen(line+1)+1)); - if (line[0]=='#') //line is a comment. - proceed=false;; //discarding line + if (line[0]=='#') { //line is a comment. + proceed=false;; //discarding line + (*numline)++; + } break; case 1 : //checking if test file format is OK if (line[1]!=':') { - (void) report(numline,line,"Malformed test data"); + (void) report(*numline,line,"Malformed test data"); status=false; proceed=false; //discarding line } @@ -543,7 +549,7 @@ while (proceed==true) { status=docommand(fd,numline,line); break; case 'R' : //Receiving data - status=doincoming(fd->socptr,numline,line); + status=doincoming(fd->socptr,*numline,line); break; case 'S' : //sending data (void) dooutgoing(fd->socptr,line); @@ -553,10 +559,11 @@ while (proceed==true) { break; default : //Unexpected line-=2; - (void) report(numline,line,"Unexpected directive"); + (void) report(*numline,line,"Unexpected directive"); status=false; break; } + (*numline)++; break; default : //SAFE Guard proceed=false; @@ -586,7 +593,7 @@ _Bool proceed; status=false; (void) strcpy(testname,""); -numline=0; +numline=1; (void) strcpy(line,""); phase=0; proceed=true; @@ -624,12 +631,14 @@ while (proceed==true) { while (fgets(line,sizeof(line),fd->datatst)!=(char *)0) { char *ptr; - numline++; + (void) rou_alert(0,"%s num='%02d' <%s>","sender",numline,line); while ((ptr=strrchr(line,'\n'))!=(char *)0) *ptr='\000'; - if ((fd->commented==true)&&(strncmp(line,"C:",2)!=0)) - continue; - if (scanline(fd,numline,line)==false) { + if ((fd->commented==true)&&(strncmp(line,"C:",2)!=0)) { + numline++; + continue; + } + if (scanline(fd,&numline,line)==false) { phase=999; //Trouble trouble exiting break; } diff --git a/data-feed/feed02.tst b/data-feed/feed02.tst index 0504957..9a2c8e4 100644 --- a/data-feed/feed02.tst +++ b/data-feed/feed02.tst @@ -1,4 +1,8 @@ #very simple test to feed SMTP server +C:COMMENT START +LINE 1 +LINE 2 +C:COMMENT STOP #==================================================== T:Sending a very Simple Email R:220 mailleur.example.com ESMTP (cleartext) emlrcvr... diff --git a/data-feed/xxfeed.tst b/data-feed/xxfeed.tst index 0504957..9a2c8e4 100644 --- a/data-feed/xxfeed.tst +++ b/data-feed/xxfeed.tst @@ -1,4 +1,8 @@ #very simple test to feed SMTP server +C:COMMENT START +LINE 1 +LINE 2 +C:COMMENT STOP #==================================================== T:Sending a very Simple Email R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...