]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Majour code adjustment
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 11 Jul 2025 11:38:47 +0000 (07:38 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 11 Jul 2025 11:38:47 +0000 (07:38 -0400)
lib/Makefile
lib/geseml.c
lib/geseml.h
lib/gessql.c
lib/gessql.h
lib/lvleml.c
lib/unieml.c
lib/unieml.h

index ea2db41fbcf9ad8278053be248302e8dcd29355f..0f5cfe216b3938aaf39c95e91df944660bc1dfe8 100644 (file)
@@ -143,8 +143,13 @@ gestcp.h:                                  \
           unidns.h                             \
           devlog.h devsoc.h
 
+gessql.h:                                      \
+          unieml.h                             \
+          devsql.h
+
 gesspf.h:                                      \
           subafn.h
+
 devsoc.h:                                      \
           unitls.h
 
index 7a725c065bb94dedbfcbe95529a177ca88cd5b45..a1e99aafaf2594da8ce965c5ee8a9f95a1913497 100644 (file)
@@ -157,27 +157,6 @@ return reflist;
 */
 /********************************************************/
 /*                                                      */
-/*      Procedure to free memory used by a TRATYP record*/
-/*                                                      */
-/********************************************************/
-static TRATYP *eml_freetra(TRATYP *tra)
-
-{
-if (tra!=(TRATYP *)0) {
-  (void) eml_freetra_resp(tra);
-  tra->rcptto=rou_freestr(tra->rcptto);
-  tra->mailfrom=rou_freestr(tra->mailfrom);
-  tra->sessid=rou_freestr(tra->sessid);
-  (void) free(tra);
-  tra=(TRATYP *)0;
-  }
-return tra;
-}
-/*
-\f
-*/
-/********************************************************/
-/*                                                      */
 /*      Procedure to display/debug TRATYP record content*/
 /*                                                      */
 /********************************************************/
@@ -281,22 +260,6 @@ return action;
 */
 /********************************************************/
 /*                                                      */
-/*      Procedure to free memory used by the TRATYP     */
-/*      response part.                                  */
-/*                                                      */
-/********************************************************/
-PUBLIC void eml_freetra_resp(TRATYP *tra)
-
-{
-if (tra!=(TRATYP *)0) {
-  tra->resp=(char **)rou_freelist((void **)tra->resp,(genfree_t)rou_freestr);
-  }
-}
-/*
-\f
-*/
-/********************************************************/
-/*                                                      */
 /*      Procedure to duplicate an resp list within a tra*/
 /*      record.                                         */
 /*                                                      */
@@ -353,21 +316,6 @@ return dup;
 */
 /********************************************************/
 /*                                                      */
-/*      Procedure to free memory used by a tra list     */
-/*                                                      */
-/********************************************************/
-PUBLIC TRATYP **eml_freeall_tra(TRATYP **tra)
-
-{
-(void) eml_update_tradb(tra);
-tra=(TRATYP **)rou_freelist((void **)tra,(genfree_t)eml_freetra);
-return tra;
-}
-/*
-\f
-*/
-/********************************************************/
-/*                                                      */
 /*      Procedure to scan the a qfile and build a       */
 /*      list of email transport directive.              */
 /*                                                      */
@@ -990,67 +938,3 @@ return extracted;
 
 #undef  OPEP
 }
-/*
-^L
-*/
-/********************************************************/
-/*                                                      */
-/*     Procedure to update the database with respond   */
-/*      Record associated with TRA.                     */
-/*      Return the number of record stored within the   */
-/*      database.                                       */
-/*                                                      */
-/********************************************************/
-PUBLIC int eml_update_tradb(TRATYP **tra)
-
-{
-#define OPEP    "geseml.c:eml_update_tradb,"
-
-int num;
-
-num=0;
-if (tra!=(TRATYP **)0) {
-  SQLPTR *sqlptr;
-  int phase;
-  _Bool proceed;
-
-  sqlptr=(SQLPTR *)0;
-  phase=0;
-  proceed=(*tra!=(TRATYP *)0);
-  while (proceed==true) {
-    switch (phase) {
-      case 0    :       //opening the database
-        if ((sqlptr=sql_opensql())==(SQLPTR *)0) {
-          (void) rou_alert(0,"%s Unable to open database (system?)",OPEP);
-          phase=999;
-          }
-        break;
-      case 1    :       //checking all transation
-        while (*tra!=(TRATYP *)0) {
-          if ((*tra)->resp!=(char **)0) {
-            ACTTYP action;
-
-            action.sessid=(*tra)->sessid;
-            action.code=(*tra)->code;
-            action.rcptto=(*tra)->rcptto;
-            action.resp=(*tra)->resp;
-            (void) sql_mngact(sqlptr,sql_delete,&action); 
-            num++;
-            }
-          tra++;
-          }
-        break;
-      case 2    :       //closing the database
-        sqlptr=sql_closesql(sqlptr);
-        break;
-      default   :       //SAFE Guard
-        proceed=false;
-        break;
-      }
-    phase++;
-    }
-  }
-return num;
-
-#undef  OPEP
-}
index c6f16db3d4ddb14c99dc6de1f3053da7a45a30e2..5edb50110f4b506135325ef0a7a0d358f6b871c5 100644 (file)
 
 #include        "unisql.h"
 
-//structure to define an email transport directive
-typedef struct  {
-        char code;      //Transaction code
-        time_t date;    //Transaction date
-        u_int delay;    //Transaction execution delay
-        char *sessid;   //session id
-        char *mailfrom; //Email Originator
-        char *rcptto;   //Email Recipient
-        int sendcode;   //Email sending status;
-        char **resp;    //Transfer response status
-        }TRATYP;
-
 //procedure to dump a list of transfert record 
 extern _Bool eml_dump_one_tra(FILE *out,TRATYP *tra);
 
 //procedure to dump a list of transfert record 
 extern _Bool eml_dump_list_tra(FILE *out,TRATYP **tra);
 
-//procedure to fee memory used by the resp record within TRATYP structure
-extern void eml_freetra_resp(TRATYP *tra);
-
 //procedure to fee memory used to duplicate a resp list to tra resp
 extern void eml_duptra_resp(TRATYP *tra,char **resp);
 
@@ -42,7 +27,7 @@ extern void eml_duptra_resp(TRATYP *tra,char **resp);
 extern TRATYP *eml_duptra(TRATYP *tra);
 
 //procedure to fee memory used by a TRATYP structure
-extern TRATYP **eml_freeall_tra(TRATYP **tra);
+//extern TRATYP **eml_freeall_tra(TRATYP **tra);
 
 //procedure to open a specific qfile
 extern TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile);
index 0df04f59a4f3b81f612add5e609df6bf95a24b09..2854530d66ddf196fc55fb6e464a7a8953ff62d8 100644 (file)
 #define ACTTBL  "actions"       //action tables
 #define SESTBL  "sessions"      //session tables
 
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to update database information about  */
+/*      emails echange current and last status.         */
+/*                                                      */
+/********************************************************/
+PUBLIC _Bool mngact(SQLPTR *sqlptr,ACTTYP *act)
+
+{
+#define OPEP    "gessql.c:sql_mngact,"
+
+static const char *del="DELETE FROM "ACTTBL" WHERE sessid=%s AND rcptto=%s";
+static const char *ins="INSERT INTO "ACTTBL" (%s) VALUES(%s,%s,%s,%d,%s)";
+
+_Bool isok;
+
+isok=false;
+if (act!=(ACTTYP *)0) {
+  char strcode[10];
+  char *goodid;
+  char *goodrcpt;
+  char *goodcode;
+
+  (void) memset(strcode,'\000',sizeof(strcode));
+  strcode[0]=act->code;
+  goodid=sql_gooddata(sqlptr,act->sessid);
+  goodrcpt=sql_gooddata(sqlptr,act->rcptto);
+  goodcode=sql_gooddata(sqlptr,strcode);
+  if (act->resp!=(char **)0) {
+    char *field;
+
+    field="code,sessid,rcptto,numline,info";
+    (void) sql_request(sqlptr,del,goodid,goodrcpt);
+    if (act->resp!=(char **)0) {
+      char **resp;
+      int num;
+  
+      resp=act->resp;
+      num=1;
+      while (*resp!=(char *)0) {
+        char *goodinfo;
+
+        goodinfo=sql_gooddata(sqlptr,*resp);
+        (void) sql_request(sqlptr,ins,field,goodcode,goodid,goodrcpt,num,goodinfo);
+        goodinfo=rou_freestr(goodinfo);
+        resp++;
+        num++;
+        }
+      }
+    }
+  goodcode=rou_freestr(goodcode);
+  goodrcpt=rou_freestr(goodrcpt);
+  goodid=rou_freestr(goodid);
+  isok=true;
+  }
+return isok;
+
+#undef  OPEP
+}
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
+/*     Procedure to update the database with respond   */
+/*      Record associated with TRA.                     */
+/*      Return the number of record stored within the   */
+/*      database.                                       */
+/*                                                      */
+/********************************************************/
+PUBLIC int sql_update_tradb(SQLPTR *sqlptr,TRATYP **tralist)
+
+{
+#define OPEP    "gesql.c:qlupdate_tradb,"
+
+int num;
+
+num=0;
+if (tralist!=(TRATYP **)0) {
+  while (*tralist!=(TRATYP *)0) {
+    if ((*tralist)->resp!=(char **)0) {
+      ACTTYP action;
+
+      action.sessid=(*tralist)->sessid;
+      action.code=(*tralist)->code;
+      action.rcptto=(*tralist)->rcptto;
+      action.resp=(*tralist)->resp;
+      (void) mngact(sqlptr,&action); 
+      num++;
+      }
+    tralist++;
+    }
+  }
+return num;
+
+#undef  OPEP
+}
 /*
 \f
 */
@@ -339,68 +439,6 @@ while (proceed==true) {
   }
 return isok;
 
-#undef  OPEP
-}
-/*
-\f
-*/
-/********************************************************/
-/*                                                      */
-/*      Procedure to update database information about  */
-/*      emails echange current and last status.         */
-/*                                                      */
-/********************************************************/
-PUBLIC _Bool sql_mngact(SQLPTR *sqlptr,SQLENUM action,ACTTYP *act)
-
-{
-#define OPEP    "gessql.c:sql_mngact,"
-
-static const char *del="DELETE FROM "ACTTBL" WHERE sessid=%s AND rcptto=%s";
-static const char *ins="INSERT INTO "ACTTBL" (%s) VALUES(%s,%s,%s,%d,%s)";
-
-_Bool isok;
-
-isok=false;
-if (act!=(ACTTYP *)0) {
-  char strcode[10];
-  char *goodid;
-  char *goodrcpt;
-  char *goodcode;
-
-  (void) memset(strcode,'\000',sizeof(strcode));
-  strcode[0]=act->code;
-  goodid=sql_gooddata(sqlptr,act->sessid);
-  goodrcpt=sql_gooddata(sqlptr,act->rcptto);
-  goodcode=sql_gooddata(sqlptr,strcode);
-  if (act->resp!=(char **)0) {
-    char *field;
-
-    field="code,sessid,rcptto,numline,info";
-    (void) sql_request(sqlptr,del,goodid,goodrcpt);
-    if (act->resp!=(char **)0) {
-      char **resp;
-      int num;
-  
-      resp=act->resp;
-      num=1;
-      while (*resp!=(char *)0) {
-        char *goodinfo;
-
-        goodinfo=sql_gooddata(sqlptr,*resp);
-        (void) sql_request(sqlptr,ins,field,goodcode,goodid,goodrcpt,num,goodinfo);
-        goodinfo=rou_freestr(goodinfo);
-        resp++;
-        num++;
-        }
-      }
-    }
-  goodcode=rou_freestr(goodcode);
-  goodrcpt=rou_freestr(goodrcpt);
-  goodid=rou_freestr(goodid);
-  isok=true;
-  }
-return isok;
-
 #undef  OPEP
 }
 /*
index 64b44eef27b5e2865e2f0c21c9201f334e5de7fd..f73677341ae85229c6ff3c8d0849fa038d78a511 100644 (file)
@@ -9,14 +9,15 @@
 
 #include        <stdbool.h>
 
+#include        "unieml.h"
 #include        "devsql.h"
 
+//procedure to update transaction information
+extern int sql_update_tradb(SQLPTR *sqlptr,TRATYP **tralist);
+
 //procedure to manage information on exiting user
 extern _Bool sql_mngusr(SQLPTR *sqlptr,SQLENUM action,char *key,USRTYP **usr);
 
-//procedure to manage action stats on email exhange status
-extern _Bool sql_mngact(SQLPTR *sqlptr,SQLENUM action,ACTTYP *act);
-
 //procedure to manage information on email exchange session
 extern _Bool sql_mngses(SQLPTR *sqlptr,SQLENUM action,SESTYP **ses);
 
index 8aaf1122d4ab924fdc6cb2d9240c407a1b2ed99d..de17d152e1a1f641df7f3e64b5c56c903607f273 100644 (file)
@@ -24,6 +24,7 @@
 #include       "unieml.h"
 #include       "devlog.h"
 #include       "gestcp.h"
+#include       "gessql.h"
 #include       "geseml.h"
 #include       "lvleml.h"
 
@@ -2346,7 +2347,8 @@ if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) {
     ptr++;
     }
   (void) eml_dump_list_tra(qfile,tralist);
-  tralist=eml_freeall_tra(tralist);
+  (void) sql_update_tradb(contact->sqlptr,tralist);
+  tralist=(TRATYP **)rou_freelist((void **)tralist,(genfree_t)eml_freetra);
   }
 return status;
 #undef  OPEP
index cd06745f9573e638f15fed63023f560481064185..5a6ef9eab65c00762f4296cbc3842b9831386f4f 100644 (file)
@@ -62,6 +62,43 @@ if (info!=(RCPTYP *)0) {
 return info;
 }
 /*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to free memory used by the TRATYP     */
+/*      response part.                                  */
+/*                                                      */
+/********************************************************/
+PUBLIC void eml_freetra_resp(TRATYP *tra)
+
+{
+if (tra!=(TRATYP *)0) {
+  tra->resp=(char **)rou_freelist((void **)tra->resp,(genfree_t)rou_freestr);
+  }
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to free memory used by a TRATYP record*/
+/*                                                      */
+/********************************************************/
+PUBLIC TRATYP *eml_freetra(TRATYP *tra)
+
+{
+if (tra!=(TRATYP *)0) {
+  (void) eml_freetra_resp(tra);
+  tra->rcptto=rou_freestr(tra->rcptto);
+  tra->mailfrom=rou_freestr(tra->mailfrom);
+  tra->sessid=rou_freestr(tra->sessid);
+  (void) free(tra);
+  tra=(TRATYP *)0;
+  }
+return tra;
+}
+/*
 ^L
 */
 /********************************************************/
index b5a7fb4e8816f67896a3385769be5293e7ec8087..d35bc07ab3e222c668e548ebf93caa8640936405 100644 (file)
 
 //list of keyword
 typedef enum    {               //list of SMTP protocol keyword
-                c_auth,         //Requesting authentication
-                c_data,         //DATA email contents transfer request
-                c_ehlo,         //EHLO command
-                c_helo,         //Basic Helo command
-                c_mail,         //'mail from:' sequence detected
-                c_noop,         //No Operation request
-                c_quit,         //quit exchange
-                c_rcpt,         //'rcpt to:' sequence detected
-                c_rset,         //resetting session
-                c_starttls,     //Starting a TLS crypted link
-                c_unknown       //key word unknown
-                }CODTYP;
+        c_auth,                 //Requesting authentication
+        c_data,                 //DATA email contents transfer request
+        c_ehlo,                 //EHLO command
+        c_helo,                 //Basic Helo command
+        c_mail,                 //'mail from:' sequence detected
+        c_noop,                 //No Operation request
+        c_quit,                 //quit exchange
+        c_rcpt,                 //'rcpt to:' sequence detected
+        c_rset,                 //resetting session
+        c_starttls,             //Starting a TLS crypted link
+        c_unknown               //key word unknown
+        }CODTYP;
 
 typedef struct  {               //*definition of recipient
         char code;              //'L' rcipient local, 'R' recipient remote
@@ -74,9 +74,27 @@ typedef struct  {               //*definition of recipient
         char *userid;           //recipient email userid
         }RCPTYP;
 
+//structure to define an email transport directive
+typedef struct  {
+        char code;      //Transaction code
+        time_t date;    //Transaction date
+        u_int delay;    //Transaction execution delay
+        char *sessid;   //session id
+        char *mailfrom; //Email Originator
+        char *rcptto;   //Email Recipient
+        int sendcode;   //Email sending status;
+        char **resp;    //Transfer response status
+        }TRATYP;
+
 //procedure to Free one recipient info
 extern RCPTYP *eml_freerecipient(RCPTYP *info);
 
+//procedure to fee memory used by the resp record within TRATYP structure
+extern void eml_freetra_resp(TRATYP *tra);
+
+//procedure to Free one transaction inf
+extern TRATYP *eml_freetra(TRATYP *tra);
+
 //procedure to add recipient to a recipient list
 extern _Bool eml_addrecipient(RCPTYP ***list,RCPTYP *rcpt);