]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting to implement feed command (GOTLS, SLEEP)
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 1 Apr 2025 23:45:06 +0000 (19:45 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 1 Apr 2025 23:45:06 +0000 (19:45 -0400)
app/feeder.c
data-tst/feed00.tst
lib/subrou.c

index e2d1fe1a106b7e8f706c821924ff96ae0f86a171..e076379fa4715ee4348117d14826857a82a18a84 100644 (file)
@@ -82,6 +82,78 @@ static void dooutgoing(SOCPTR *socptr,char *line)
 */
 /********************************************************/
 /*                                                     */
+/*     Procedure to execute a command to test SMTP     */
+/*      protocol.                                       */
+/*                                                     */
+/********************************************************/
+static int getcmd(const char *command)
+
+
+{
+static struct   {
+      int code;
+      const char *cmd;
+      }cmdavail[]={
+            {1,"GOTLS"},
+            {2,"SLEEP"},
+            {0,(const char *)0}
+            };
+
+int code;
+
+code=0;
+for (int i=0;cmdavail[i].cmd!=(const char *)0;i++) {
+  if (strcasecmp(cmdavail[i].cmd,command)==0) {
+    code=cmdavail[i].code;
+    break;      //Code found
+    }
+  }
+return code;
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to execute a command to test SMTP     */
+/*      protocol.                                       */
+/*                                                     */
+/********************************************************/
+static _Bool docommand(SOCPTR *socptr,int numline,char *line)
+
+{
+_Bool status;
+char *param;
+
+status=false;
+if ((param=strchr(line,' '))!=(char *)0) {
+  *param='\000';         //cut line
+  param++;              //pointer on parameter
+  }
+switch (getcmd(line)) {
+  case 1        :       //GOTLS
+    (void) rou_alert(0,"JMPDBG got GOTTLS");
+    status=true;
+    break;
+  case 2        :       //GOTLS
+    if (param==(char *)0)  
+      (void) report(numline,line,"Missing 'seconds' parameters");
+    else {
+      (void) sleep(atoi(param));
+      status=true;
+      }
+    break;
+  default       :
+    (void) report(numline,line,"Unknown command");
+    break;
+  }
+return status;
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
 /*     Procedure to compare incoming data with expected*/
 /*                                                     */
 /********************************************************/
@@ -203,8 +275,8 @@ while (proceed==true) {
       break;
     case 2      :       //discarding comment
       switch (line[0]) {
-        case 'T'        :       //Get the test titre
-          status=strncpy(testname,line+2,sizeof(testname));
+        case 'C'        :       //command to execute
+          status=docommand(socptr,numline,line+2);
           break;
         case 'R'        :       //Receiving data
           status=doincoming(socptr,numline,line+2);
@@ -212,8 +284,11 @@ while (proceed==true) {
         case 'S'        :       //sending data
           (void) dooutgoing(socptr,line+2);
           break;
+        case 'T'        :       //Get the test titre
+          status=strncpy(testname,line+2,sizeof(testname));
+          break;
         default         :       //Unexpected
-          (void) report(numline,line+2,"Bigre unexpected directive");
+          (void) report(numline,line+2,"Unexpected directive");
           status=false;
           break;
         }
index 82cbe58088a1bf495ba8b43dfc275e38104a6def..12be1b2005d639e260d1bf258649787c6521a0ef 100644 (file)
@@ -3,9 +3,12 @@
 #127.127.10.25         emlrcvr
 ##to have proper reverss-address within test
 # # comment
+# C: command to execute
+#      GOTLS           - Going in TLS mode
+#      SLEEP X         - Stop for X seconds
 # R: incoming data
 # S: outgoing data
-# T: Test titre
+# T: Test titre or Info
 T:basic test function
 R:220 emlrcvr ESMTP emlrcvr...
 S:EHLO example.com
@@ -17,6 +20,8 @@ R:250-8BITMIME
 R:250-ENHANCEDSTATUSCODES
 R:250-AUTH PLAIN LOGIN
 R:250 HELP
+C:GOTLS
+C:SLEEP 10
 #send a empty ehlo
 S:EHLO
 R:501 5.5.4 syntax error (domain part missing), closing connection.
index b9aeb41223f6481f06cec4169fa31879c93a7d5b..abd688988169ff707e29b0faaf4475294c254c1f 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.6"
-#define RELEASE "41"
+#define RELEASE "42"
 #define BRANCH "dvl"
 
 //Public variables