]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Good line count with feed comment and data.
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 24 May 2025 04:17:59 +0000 (00:17 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 24 May 2025 04:17:59 +0000 (00:17 -0400)
app/feeder.c
data-feed/feed02.tst
data-feed/xxfeed.tst

index 8e512586e92c8dba8eec64f04cfcbac1b281992a..1c56f8cb47be6261ba897315c088b5285b752696 100644 (file)
@@ -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
 }
 /*
 \f
@@ -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;
           }
index 050495784749a25a3d9df39ba12e224e698dde65..9a2c8e42514edb7c494dd26e674cff01797f1255 100644 (file)
@@ -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...
index 050495784749a25a3d9df39ba12e224e698dde65..9a2c8e42514edb7c494dd26e674cff01797f1255 100644 (file)
@@ -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...