]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Able to add response information to transaction (TRATYP) record
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 10 Jun 2025 10:28:47 +0000 (06:28 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 10 Jun 2025 10:28:47 +0000 (06:28 -0400)
lib/geseml.c
lib/lvleml.c
lib/subrou.c
lib/subrou.h

index b6c11e8cb769577a57760d4dc251f6763e012e1d..530c4f5043e7de0fb3df697d821b0fca801d105a 100644 (file)
@@ -144,7 +144,8 @@ static void print_tra(FILE *qfile,char *line,char *temps)
 if (qfile==(FILE *)0)  
   (void) rou_alert(0,"TRA=<%s>",line);
 else {
-  (void) fprintf(qfile,"%s\n",temps);
+  if (temps!=(char *)0)
+    (void) fprintf(qfile,"%s\n",temps);
   (void) fprintf(qfile,"%s\n",line);
   }
 }
@@ -160,6 +161,7 @@ else {
 PUBLIC _Bool eml_dump_one_tra(FILE *qfile,TRATYP *tra)
 
 {
+#define OPEP    "geseml.c:eml_dump_one_tra,"
 _Bool status;
 
 status=false;
@@ -179,8 +181,20 @@ if (tra!=(TRATYP *)0) {
                                     tra->rcptto
                                     );
   (void) print_tra(qfile,line,temps);
+  if (tra->resp!=(char **)0) {
+    char **ptr;
+
+    ptr=tra->resp;
+    while (*ptr!=(char *)0) {
+      (void) rou_alert(0,"%s JMPDBG ptr=<%s>",OPEP,*ptr);
+      (void) snprintf(line,sizeof(line),"\t%s",*ptr);
+      (void) print_tra(qfile,line,(char *)0);
+      ptr++;
+      }
+    }
   }
 return status;
+#undef  OPEP
 }
 /*
 \f
@@ -288,10 +302,13 @@ PUBLIC TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile)
 
 {
 #define OPEP    "geseml.c:eml_scanqfile,"
+#define FMT     "%c %ld %d %s %s %s"
 
+TRATYP *cur;    //previous trans record
 char *ptr;
 char line[300];
 
+cur=(TRATYP *)0;
 while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
   char id[300];
   char from[100];
@@ -309,27 +326,44 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
       case 0    :       //Removing comment
         if ((ptr=strchr(line,'#'))!=(char *)0)
           *ptr='\000';
+        (void) rou_stripcrlf(line);
         if (strlen(line)==0)
           phase=999;    //No data within line
         break;
       case 1    :       //scanning line contents
-        if (sscanf(line,"%c %ld %d %s %s %s",&code,&date,&delay,id,from,to)!=6) {
-          (void) rou_alert(0,"%s Unable to scan <line=%s> (config?)",OPEP,line);
-          phase=999;    //No data within line
+        switch (line[0]) {
+          case '\t'     :       //extra response line
+            (void) rou_alert(0,"%s JMPDBG extra=<%s> cur='%p'",OPEP,line,cur);
+            if ((cur!=(TRATYP *)0)&&(strlen(line)>1)) 
+              cur->resp=(char **)rou_addlist((void **)cur->resp,strdup(line+1));
+            phase=999;    //not a scanable trans line
+            break;
+          case 'C'      :       //Directives
+          case 'L'      :       
+          case 'R'      :       
+          case 'W'      :       
+            if (sscanf(line,FMT,&code,&date,&delay,id,from,to)!=6) {
+              (void) rou_alert(0,"%s Unable to scan <line=%s> (config?)",OPEP,line);
+              phase=999;    //No data within line
+              }
+            break;
+          default       :
+            (void) rou_alert(0,"%s Unexpected code within  <line=%s> (config?)",
+                                OPEP,line);
+            phase=999;    //No data within line
+            break;
           }
         break;
       case 2    :       //scanning line contents
         if (strlen(id)>0) {     //always?
-          TRATYP *tra;
-          tra=(TRATYP *)calloc(1,sizeof(TRATYP));
-          tra->code=code;
-          tra->date=date;
-          tra->delay=delay;
-          tra->sessid=strdup(id);
-          tra->mailfrom=strdup(from);
-          tra->rcptto=strdup(to);
-          list=(TRATYP **)rou_addlist((void **)list,(void *)tra); 
+          cur=(TRATYP *)calloc(1,sizeof(TRATYP));
+          cur->code=code;
+          cur->date=date;
+          cur->delay=delay;
+          cur->sessid=strdup(id);
+          cur->mailfrom=strdup(from);
+          cur->rcptto=strdup(to);
+          list=(TRATYP **)rou_addlist((void **)list,(void *)cur); 
           }
         break;
       default   :       //SAFE Guard
index a01b4d10935127339e48f96b05d35b6088268952..ff816fedfeec9dc3fa5982f3650b7bced2ccd709 100644 (file)
@@ -1046,8 +1046,9 @@ while (proceed==true) {
             (*dest)->sendcode=rspcode;
             break;
           case UKNUSER    :     //originator accepted
-            (*dest)->code='C';  //completed (Temporary JMPDBG);
+            (*dest)->code='W';  //Need to send a Warning
             (*dest)->sendcode=rspcode;
+            (*dest)->resp=(char **)rou_addlist((void **)(*dest)->resp,strdup("bigre"));
             break;
           default         :     //Not accepted recipient
             (void) rou_alert(0,"%s sessid=<%s>, unknwon code='%d'",
index d33cde7b40b8410c083d04ccdfc20a4ec74a269e..cb5777f4b3f194e938b0a504bd79e0d33b4a993f 100644 (file)
@@ -261,6 +261,35 @@ if (str!=(char *)0) {
   }
 return str;
 }
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to get rid of any \r or \n at the end */
+/*     of a string.                                    */
+/*                                                     */
+/********************************************************/
+char *rou_stripcrlf(char *line)
+
+{
+if (line!=(char *)0) {
+  register int taille;
+  register char *ptr;
+
+  taille=strlen(line)-1;
+  ptr=line+taille;
+  while ((*ptr=='\n') || (*ptr=='\r')) {
+    *ptr='\000';
+    taille--;
+    if (taille<0)
+      break;
+    ptr--;
+    }
+  }
+return line;
+}
+
 /*
 \f
 */
index bba6e83ddaa15228dc0e72867d91137f6b79d7c8..281dd3081ad2483b1d0b8b02775ace29e74d3a65 100644 (file)
@@ -58,6 +58,9 @@ extern const char *rou_getversion();
 //a NULL pointer
 extern char *rou_freestr(char *str);
 
+//procedure to remove '\r' or '\n' at end of a line
+extern char *rou_stripcrlf(char *line);
+
 //to return the number of element within a list
 extern int rou_nbrlist(void **list);