]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Able to merge trans if partly transmittes
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 27 May 2025 18:55:35 +0000 (14:55 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 27 May 2025 18:55:35 +0000 (14:55 -0400)
app/Makefile
lib/geseml.c
lib/geseml.h
lib/unieml.h

index 3fe0d9b3886408cf8d34efe3eb5606442a8b6b3a..99bb17a1515efbcdd0d7f3945ef47bc5e19493fb 100644 (file)
@@ -42,6 +42,7 @@ LD    =  gcc -g
 CFLAGS =  -I ../lib -Wall $(OPTIME)
 LIBMAIL        =  ../lib/libmail.a
 LIBS   =       $(LIBMAIL)                      \
+               -luuid                          \
                -lpq                            \
                -lcrypto                        \
                -lssl                           \
index f4a4d2f6b4794fc9449dedd213faefced449dcaa..e12d4d72c191575c70f7ab762d3055777ce95979 100644 (file)
@@ -7,6 +7,7 @@
 /********************************************************/
 #include        <dirent.h>
 #include        <string.h>
+#include        <uuid/uuid.h>
 
 #include       "subrou.h"
 #include       "unieml.h"
@@ -174,6 +175,31 @@ return trans;
 */
 /********************************************************/
 /*                                                      */
+/*      Procedure to duplicate TRATYP structure         */
+/*                                                      */
+/********************************************************/
+PUBLIC TRATYP *eml_duptra(TRATYP *trans)
+
+{
+TRATYP *dup;
+
+dup=(TRATYP *)0;
+if (trans!=(TRATYP *)0) {
+  dup=(TRATYP *)calloc(1,sizeof(TRATYP));
+  dup->code=trans->code;
+  dup->date=trans->date;
+  dup->delay=trans->delay;
+  dup->rcptto=strdup(trans->rcptto);
+  dup->mailfrom=strdup(trans->mailfrom);
+  dup->sessid=strdup(trans->sessid);
+  }
+return dup;
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
 /*      Procedure to scan the a qfile and build a       */
 /*      list of email transport directive.              */
 /*                                                      */
@@ -249,7 +275,6 @@ PUBLIC void eml_todoqfile(TRATYP **list)
 
 {
 #define OPEP    "geseml.c:eml_todoqfile,"
-#define EXTOBE  "tobedone"
 
 REFTYP **domlist;
 
@@ -310,7 +335,6 @@ if (domlist!=(REFTYP **)0) {
   (void) free(domlist);
   }
 
-#undef  EXTOBE
 #undef  OPEP
 }
 /*
@@ -327,8 +351,10 @@ PUBLIC void eml_doneqfile(TRATYP **list)
 #define OPEP    "geseml.c:eml_doneqfile,"
 
 SIDTYP **sids;
+TRATYP **next;
 
 sids=(SIDTYP **)0;
+next=(TRATYP **)0;
 (void) rou_alert(0,"%s JMPDBG trying check",OPEP);
 if (list!=(TRATYP **)0) {
   TRATYP **ptr;
@@ -342,6 +368,7 @@ if (list!=(TRATYP **)0) {
       case 'C'  :       //completed
         break;
       default   :
+        next=(TRATYP **)rou_addlist((void **)next,(void *)eml_duptra(*ptr));
         found->count++;
         break;
       }
@@ -361,7 +388,43 @@ if (sids!=(SIDTYP **)0) {
     }
   sids=eml_freesid(sids);
   }
-
+if (next!=(TRATYP **)0) {
+  FILE *qfile;
+  uuid_t id;
+  char qname[150];
+  char struuid[40];
+  int phase;
+  _Bool proceed;
+   
+  qfile=(FILE *)0;
+  (void) uuid_generate(id);
+  (void) uuid_unparse(id,struuid);
+  (void) snprintf(qname,sizeof(qname),"%s-%s-%04d",struuid,"redo",0);
+  phase=0;
+  proceed=true;
+  while (proceed==true) {
+    switch (phase) {
+      case 0  :       //Opening qfile
+        if ((qfile=eml_createqfile(qname,EXTOBE))==(FILE *)0) 
+          phase=999;  //Trouble trouble
+        break;
+      case 1  :       //dumping TRANS data to file
+        (void) eml_dumptra(qfile,next);
+        break;
+      case 2  :       //Closing file
+        (void) eml_closeqfile(qfile);
+        break;
+      case 3  :       //file ready, renaming file, 
+        (void) eml_renameqfile(qname,EXTOBE,EXTRANS);
+        break;
+      default :       //SAFE Guard
+        proceed=false;
+        break;
+      }
+    phase++;
+    }
+  next=(TRATYP **)rou_freelist((void **)next,(genfree_t)eml_freetra);
+  }
 #undef  OPEP
 }
 /*
index cd7a4d377c223cbce7e69a0b11a6bb5602503628..99e0cb44dfe1b5756ba12c949f47a0d255ee6ebb 100644 (file)
@@ -11,6 +11,8 @@
 #include        <stdlib.h>
 #include        <stdio.h>
 
+#define EXTOBE  "tobedone"      //directive enxtension in progress
+
 //structure to define an email transport directive
 typedef struct  {
         char code;      //Transaction code
@@ -27,6 +29,9 @@ extern void eml_dumptra(FILE *out,TRATYP **tra);
 //procedure to fee memory used by a TRATYP structure
 extern TRATYP *eml_freetra(TRATYP *tra);
 
+//procedure to duplicate a TRATYP structure
+extern TRATYP *eml_duptra(TRATYP *tra);
+
 //procedure to open a specific qfile
 extern TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile);
 
index 4be728e906744968cdcaf44b83250040319f9a3c..99bdd76b61d09fe4ac89bb88ecaa1748e171987d 100644 (file)
@@ -62,19 +62,6 @@ extern SIDTYP *eml_addsid(SIDTYP ***list,char *sessid);
 //procedure to Free one recipient info
 extern RCPTYP *eml_freerecipient(RCPTYP *info);
 
-//get a session unique id
-extern char *eml_getmainsesid();
-
-//procedure to add recipient to a recipient list
-//adding an session ID to a list of session
-extern SIDTYP *eml_addsid(SIDTYP ***list,char *sessid);
-
-//procedure to Free one recipient info
-extern RCPTYP *eml_freerecipient(RCPTYP *info);
-
-//get a session unique id
-extern char *eml_getmainsesid();
-
 //procedure to add recipient to a recipient list
 extern _Bool eml_addrecipient(RCPTYP ***list,RCPTYP *rcpt);