]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting to populate feeed00.tst with real directive
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 28 Mar 2025 23:32:02 +0000 (19:32 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 28 Mar 2025 23:32:02 +0000 (19:32 -0400)
Makefile
app/feeder.c
data-tst/feed00.tst
lib/devlog.c
lib/modrec.c
lib/subrou.c

index 4539da9cb39643df0b5ab19ad4effdd137c57d09..257e39c771626a5b6453785f39dcd052c32944ac 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -40,12 +40,12 @@ FEEDPAR     =                                               \
                $(TESTPORT)                             \
                $(TESTDIR)/$(DATATST)/feed*.tst         \
 
-onefeed        :       
+onefeed        :       debug
                @ bin/feeder                            \
                        -d3                             \
                        $(TESTIP)                       \
                        $(TESTPORT)                     \
-                       $(DATATST)/feed00.tst
+                       $(DATATST)/feed*.tst
 
 #direct test
 tstfeed        :       debug
index 0cf3277a1d49aa91533a06fc73d228fb7699cfaf..9a98dc6ccf1c31b4c1b1e833739e663d7b2b354c 100644 (file)
@@ -74,7 +74,6 @@ static void dooutgoing(SOCPTR *socptr,char *line)
 {
 (void) soc_writebuffer(socptr,line,strlen(line));
 (void) soc_writebuffer(socptr,"\r\n",2);
-(void) fprintf(stdout,"JMPDBG sending <%s>\n",line);
 }
 /*
 \f
@@ -88,28 +87,50 @@ static _Bool doincoming(SOCPTR *socptr,int numline,char *line)
 
 {
 #define OPEP    "tstfeed.c:doincoming"
+#define STRETC  "..."
 
 _Bool status;
 char *received;
+int tocheck;
 int phase;
 _Bool proceed;
 
 status=false;
 received=(char *)0;
+tocheck=strlen(line);
 phase=0;
 proceed=true;
 while (proceed==true) {
   //(void) fprintf(stdout,"JMPDBG %s, phase='%d'\n",OPEP,phase);
   switch (phase) {
-    case 0      :       //waiting for a line with CRLF
+    case 0      :       //do we have a "..." sequence at the end
+      if (tocheck>0) {
+        char *ptr;
+
+        if ((ptr=strstr(line,STRETC))!=(char *)0) {
+          if (strlen(ptr)==strlen(STRETC)) {
+            tocheck-=strlen(STRETC);
+            }
+          }
+        }
+      break;
+    case 1      :       //waiting for a line with CRLF
       if (tcp_getline(socptr,WAITLINE,&received)==0) {
         (void) fprintf(stdout,"Unable to receive line in due time\n");
         phase=999;      //No need to go further
         }
       break;
-    case 1      :       //get available character
-      (void) fprintf(stdout,"Remote say <%s>\n",received);
+    case 2      :       //get available character
+      if (strncmp(line,received,tocheck)!=0) {
+        (void) fprintf(stdout,"Line %04d: Error!\n",numline);
+        (void) fprintf(stdout,"expecting\t'%s'\n",line);
+        (void) fprintf(stdout,"found\t\t'%s'\n",received);
+        phase=999;
+        }
       received=rou_freestr(received);
+      break;
+    case 3      :       //everything fine
+      //(void) fprintf(stdout,"JMPDBG line <%s> OK!\n",line);
       status=true;
       break;
     default     :       //SAFE Guard
@@ -144,20 +165,26 @@ 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
       break;
-    case 1      :       //discarding comment
+    case 1      :       //checking if test file format is OK
+      if (line[1]!=':') {
+        (void) report(numline,line,"Malformed test data");
+        status=false;
+        proceed=false; //discarding line
+        }
+      break;
+    case 2      :       //discarding comment
       switch (line[0]) {
-        case '#'        :       //line is comment
-          break;
-        case '<'        :       //incoming expected
-          status=doincoming(socptr,numline,line);
+        case 'R'        :       //Receiving data
+          status=doincoming(socptr,numline,line+2);
           break;
-        case '>'        :       //incoming expected
-          (void) dooutgoing(socptr,line+1);
+        case 'S'        :       //sending data
+          (void) dooutgoing(socptr,line+2);
           break;
         default         :       //Unexpected
-          line[1]='\000';
-          (void) report(numline,line,"unexpected directive");
+          (void) report(numline,line+2,"Bigre unexpected directive");
           status=false;
           break;
         }
index 496c008be73fcd2da6c0b0217ed39c108c31268b..cac9442c452d5b47b62a0d1a8c45a316b1576a58 100644 (file)
@@ -3,8 +3,16 @@
 #127.127.10.25         emlrcvr
 ##to have proper reverss-address within test
 # # comment
-# < incoming data
-# > outgoing data
-<test test test
->quit
-<test test test
+# R: incoming data
+# S: outgoing data
+R:220 emlrcvr ESMTP emlrcvr...
+S:EHLO example.com
+R:250-emlrcvr ready, your IP/FQDN=[127.0.0.1/localhost.localdomain]
+R:250-SIZE 52428800
+R:250-STARTTLS
+R:250-8BITMIME
+R:250-ENHANCEDSTATUSCODES
+R:250-AUTH PLAIN LOGIN
+R:250 HELP
+S:QUIT
+R:221 2.0.0 Bye, closing connection...
index dcbaa32f2c724e9e4211e3f1da1a92eef8b4ea1a..cb1c64f86fb81666954dacff19c86fa037b88e41 100644 (file)
@@ -95,7 +95,7 @@ while (proceed==true) {
         }
       break;
     case 2      :       //duplicat logname
-      (void) strncpy(daily,logname,sizeof(daily));
+      (void) strncpy(daily,logname,sizeof(daily)-strlen(daily));
       if (strlen(daily)>0) {
         char *ptr;
 
index ae8277df113f550cc9b43bb3449863c8b11dda43..1f07abefe274eb76bc4574cea6d47a1ab82af1bc 100644 (file)
@@ -55,7 +55,8 @@ for (int i=0;i<argc;i++) {
   char *ptr;
   char config[80];
 
-  (void) strncpy(config,argv[i],sizeof(config));
+  (void) strcpy(config,"");
+  (void) strncpy(config,argv[i],sizeof(config)-strlen(config));
   ptr=config;
   iteration=1;
   proto=pro_smtp; 
index a71bc4b630fb1c615388ed70676237b5045bc653..a6c0d810fe7a6f66d10617dad6e4d283c894267b 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.6"
-#define RELEASE "24"
+#define RELEASE "25"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level