]> SAFE projects GIT repository - jmp/mailleur/commitdiff
hfrom information is properly inserted within data-base
authorJean-Marc Pigeon <jmp@safe.c>
Thu, 11 Sep 2025 17:06:43 +0000 (13:06 -0400)
committerJean-Marc Pigeon <jmp@safe.c>
Thu, 11 Sep 2025 17:06:43 +0000 (13:06 -0400)
lib/geseml.c
lib/gessql.c
lib/lvleml.c
lib/unieml.c
lib/unieml.h
lib/unisql.h

index 36f0c49fb779114c6eb28a50b52c3bbf7c31354d..b7aef4e590358b39db60f2c4be00f949ca2e53e7 100644 (file)
@@ -194,14 +194,14 @@ if (tra!=(TRATYP *)0) {
   status=true;
   (void) strftime(temps,sizeof(temps),"#%Y-%m-%d %H:%M:%S",
                                       localtime(&(tra->date)));
-  (void) snprintf(line,sizeof(line),"%c\t%lu\t%05u%*s %*s %*s %*s",
+  (void) snprintf(line,sizeof(line),"%c\t%lu\t%05u%*s %*s %*s \"%*s\"",
                                     tra->code,
                                     tra->date,
                                     tra->delay,
                                     32,tra->sessid,
                                     30,tra->rcptto,
                                     30,tra->sfrom,
-                                    30,tra->efrom
+                                    30,tra->hfrom
                                     );
   (void) print_tra(qfile,line,temps);
   if (tra->resp!=(char **)0) {
@@ -302,7 +302,7 @@ if (tra!=(TRATYP *)0) {
   dup->date=tra->date;
   dup->delay=tra->delay;
   dup->sfrom=strdup(tra->sfrom);
-  dup->efrom=strdup(tra->efrom);
+  dup->hfrom=strdup(tra->hfrom);
   dup->rcptto=strdup(tra->rcptto);
   dup->sessid=strdup(tra->sessid);
   if (tra->resp!=(char **)0) {
@@ -330,7 +330,7 @@ PUBLIC TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile)
 
 {
 #define OPEP    "geseml.c:eml_scanqfile,"
-#define FMT     "%c %ld %d %s %s %s %s"
+#define FMT     "%c %ld %d %s %s %s \"%[^\"]\""
 
 TRATYP *cur;    //previous trans record
 char *ptr;
@@ -340,7 +340,7 @@ cur=(TRATYP *)0;
 while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
   char id[300];
   char sfrom[100];
-  char efrom[100];
+  char hfrom[100];
   char to[100];
   char code;
   u_long date;
@@ -370,7 +370,8 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
           case 'L'      :       
           case 'R'      :       
           case 'W'      :       
-            if (sscanf(line,FMT,&code,&date,&delay,id,to,sfrom,efrom)!=7) {
+            (void) memset(hfrom,'\000',sizeof(hfrom));
+            if (sscanf(line,FMT,&code,&date,&delay,id,to,sfrom,hfrom)!=7) {
               (void) rou_alert(0,"%s Unable to scan <line=%s> (config?)",OPEP,line);
               phase=999;    //No data within line
               }
@@ -382,16 +383,21 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
             break;
           }
         break;
-      case 2    :       //scanning line contents
+      case 2    :       //cleaning element
+        while ((ptr=strchr(hfrom,'\"'))!=(char *)0)
+          *ptr=' ';
+        break;
+      case 3    :       //storing line contents
         if (strlen(id)>0) {     //always?
           cur=(TRATYP *)calloc(1,sizeof(TRATYP));
           cur->code=code;
           cur->date=date;
           cur->delay=delay;
           cur->sessid=strdup(id);
-          cur->sfrom=strdup(sfrom);
-          cur->efrom=strdup(efrom);
           cur->rcptto=strdup(to);
+          cur->sfrom=strdup(sfrom);
+          cur->hfrom=strdup(hfrom);
+          (void) rou_alert(0,"%s hfrom=<%s>",OPEP,cur->hfrom);
           list=(TRATYP **)rou_addlist((void **)list,(void *)cur); 
           }
         break;
@@ -922,6 +928,7 @@ const char *look[]={HFROM,HTITLE,(char *)0};
 
 extracted=false;
 if ((line!=(char *)0)&&(strlen(line)>0)) {
+  (void) rou_alert(0,"%s JMPDBG scan header <%s>",OPEP,line);
   for (int i=0;(extracted==false)&&(look[i]!=(char *)0);i++) {
     int max;
 
index 173be49fe9ce900f05045835c99a1f92db311409..40f0735e0eb0943a18e9d8d6c2928e06613fb46b 100644 (file)
@@ -55,7 +55,7 @@ if (act!=(ACTTYP *)0) {
   char strcode[10];
   char *gid;
   char *gsfrom;         //SMTP "mail from:"
-  char *gefrom;         //email Header "From:"
+  char *ghfrom;         //email Header "From:"
   char *grcpt;
   char *gcode;
 
@@ -63,7 +63,7 @@ if (act!=(ACTTYP *)0) {
   strcode[0]=act->code;
   gid=sql_gooddata(sqlptr,act->sessid);
   gsfrom=sql_gooddata(sqlptr,act->sfrom);
-  gefrom=sql_gooddata(sqlptr,act->efrom);
+  ghfrom=sql_gooddata(sqlptr,act->hfrom);
   grcpt=sql_gooddata(sqlptr,act->rcptto);
   gcode=sql_gooddata(sqlptr,strcode);
   if (act->resp!=(char **)0) {
@@ -83,7 +83,7 @@ if (act!=(ACTTYP *)0) {
         ginfo=sql_gooddata(sqlptr,*resp);
         (void) sql_request(sqlptr,ins,field,
                                       gcode,gid,
-                                      gsfrom,gefrom,
+                                      gsfrom,ghfrom,
                                       grcpt,num,ginfo);
         ginfo=rou_freestr(ginfo);
         resp++;
@@ -93,7 +93,7 @@ if (act!=(ACTTYP *)0) {
     }
   gcode=rou_freestr(gcode);
   grcpt=rou_freestr(grcpt);
-  gefrom=rou_freestr(gefrom);
+  ghfrom=rou_freestr(ghfrom);
   gsfrom=rou_freestr(gsfrom);
   gid=rou_freestr(gid);
   isok=true;
@@ -142,7 +142,7 @@ if (tralist!=(TRATYP **)0) {
       action.sessid=(*tralist)->sessid;
       action.code=(*tralist)->code;
       action.sfrom=(*tralist)->sfrom;
-      action.efrom=(*tralist)->efrom;
+      action.hfrom=(*tralist)->hfrom;
       action.rcptto=(*tralist)->rcptto;
       action.resp=(*tralist)->resp;
       (void) mngact(sqlptr,&action); 
index 03cc7181274110c58085739b8773223908e34df5..bcc5776045b01bacc16a1a2189cf1518a648b324 100644 (file)
@@ -1285,7 +1285,7 @@ inheader=true;
 completed=false;
 total=0;
 phase=0;
-proceed=setdirectives(contact,EXTMP);
+proceed=true;
 while (proceed==true) {
   //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
   switch (phase) {
@@ -1350,6 +1350,7 @@ while (proceed==true) {
       break;
     case 7      :       //renameing directive
       contact->session->taille=total;
+      (void) setdirectives(contact,EXTMP);
       if (eml_renameqfile(contact->session->sessid,EXTMP,EXTRANS)==false)
         phase=999;              //Trouble trouble
       break;
@@ -2835,7 +2836,6 @@ if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) {
     TRATYP *tra;
     char data[300];
 
-    
     (void) snprintf(data,sizeof(data),"%s@%s",(*ptr)->userid,(*ptr)->domain);
     tra=(TRATYP *)calloc(1,sizeof(TRATYP));
     tra->code=(*ptr)->code;
@@ -2843,9 +2843,11 @@ if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) {
     tra->delay=0;
     tra->sessid=strdup(contact->session->sessid);
     tra->sfrom=strdup(contact->mailfrom);
-    tra->sfrom=strdup(contact->mailfrom);
-    tra->efrom=strdup("XXX");
     tra->rcptto=strdup(data);
+    (void) strcpy(data,"hfrom missing");
+    if (contact->session->hfrom!=(char *)0) 
+      (void) strcpy(data,contact->session->hfrom);
+    tra->hfrom=strdup(data);
     tralist=(TRATYP **)rou_addlist((void **)tralist,(void *)tra);
     ptr++;
     }
index d713bd60f651acfbfad4dcb981154da546012d6e..bc5ec08862d3cb7fbf7a9f1a53c9a1578323da5e 100644 (file)
@@ -98,7 +98,7 @@ if (tra!=(TRATYP *)0) {
   (void) eml_freetra_resp(tra);
   tra->rcptto=rou_freestr(tra->rcptto);
   tra->sfrom=rou_freestr(tra->sfrom);
-  tra->efrom=rou_freestr(tra->efrom);
+  tra->hfrom=rou_freestr(tra->hfrom);
   tra->rcptto=rou_freestr(tra->rcptto);
   tra->sessid=rou_freestr(tra->sessid);
   (void) free(tra);
index 4e61fed3afe23781d8000ec67ac183b9df605a0b..ea2b37bf7dcc6adc9fe51ecc9fe390fdd4e7cf9a 100644 (file)
@@ -100,7 +100,7 @@ typedef struct  {
         u_int delay;    //Transaction execution delay
         char *sessid;   //session id
         char *sfrom;    //Email SMTP Originator
-        char *efrom;    //Email HEADER originator
+        char *hfrom;    //Email HEADER originator
         char *rcptto;   //Email Recipient
         int sendcode;   //Email sending status;
         char **resp;    //Transfer response status
index 59994b55a259bc44d224e3baf069c09c70d41761..20bf8f4f945a94111606eebba2bb257f3bfe2ffc 100644 (file)
@@ -53,7 +53,7 @@ typedef struct  {
         char *sessid;   //session id
         char code;      //Email status code
         char *sfrom;    //the "MAIL FROM:" within the SMTP exchange
-        char *efrom;    //the "From:" within the email header
+        char *hfrom;    //the "From:" within the email header
         char *rcptto;   //email recipient
         char **resp;    //Multiline status
         }ACTTYP;