]> SAFE projects GIT repository - jmp/mailleur/commitdiff
starting sender local delivery implementation
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 19 May 2025 14:46:09 +0000 (10:46 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 19 May 2025 14:46:09 +0000 (10:46 -0400)
Makefile
app/sender.c
lib/unieml.c

index 5b9fd4934d8132907cab9bc40cca86c443e70303..78805e3210f70a44a1a49e8544d09c9ee423c9a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ sender        :       clean debug newtest
                   -d 2                                 \
                   -c ./conf/feeder.conf.dvl            \
                   -r $(TESTDIR)                        \
-                  example.com-1747652224-0002.todo
+                  example.com-1747663900-0002.todo
 
 dbgsend        :       clean debug
           @ gdb                                        \
index 620518223dba214b87ad8282798433452b5a6010..d0404d041b306a641618975f6f0ab2d8146db4bf 100644 (file)
@@ -33,6 +33,7 @@
 static _Bool dispatcher(TRATYP **tra)
 
 {
+#define OPEP    "sorter.c:dispatcher,"
 _Bool status;
 
 status=false;
@@ -40,12 +41,23 @@ if (tra!=(TRATYP **)0) {
   TRATYP **ptr;
 
   ptr=tra;
+  status=true;
   while (*ptr!=(TRATYP *)0) {
-    (void) eml_dumptra((FILE *)0,*ptr);
+    switch ((*ptr)->code) {
+      case 'L'  :       //local delivery
+        (*ptr)->code='D';       //delivery done
+        break;
+      default   :
+        (void) eml_dumptra((FILE *)0,*ptr);
+        (void) rou_alert(0,"%s unexpected code '%c'",OPEP,(*ptr)->code);
+        status=false;
+        break;
+      }
     ptr++;
     }
   }
 return status;
+#undef  OPEP
 }
 /*
 \f
@@ -72,6 +84,7 @@ tra=(TRATYP **)0;
 phase=0;
 proceed=true;
 while (proceed==true) {
+  //(void) fprintf(stdout,"%s JMPDBG phase='%d'\n",OPEP,phase);
   switch (phase) {
     case 0      :       //Getting the list of file
       if (eml_renameqfile(fname,EXTODO,EXDOING)==false) {
@@ -87,8 +100,7 @@ while (proceed==true) {
       break;
     case 2      :       //reading the todo file
       tra=eml_scanqfile(tra,qfile);
-      (void) eml_closeqfile(qfile);
-      if (tra!=(TRATYP **)0) { //No record found
+      if (tra==(TRATYP **)0) { //No record found
         (void) rou_alert(0,"%s No transport directive within <%s.%s> (Bug?)",
                             OPEP,fname,EXDOING); 
         phase=999;
@@ -96,17 +108,31 @@ while (proceed==true) {
       break;
     case 3      :       //dispatching email
       if (dispatcher(tra)==false) {       //trouble backtracking file
-        (void)eml_renameqfile(fname,EXDONE,EXTODO);
+        (void)eml_renameqfile(fname,EXDOING,EXTODO);
         phase=999;      //No need to go further
         }
       break;
-    case 4      :       //job completed
+    case 4      :       //updating transfile 
+      if (tra!=(TRATYP **)0) { //record to update
+        TRATYP **ptr;
+
+        ptr=tra;
+        (void) rewind(qfile);
+        while (*ptr!=(TRATYP *)0) {
+          (void) eml_dumptra(qfile,*ptr);
+          ptr++;
+          }
+        }
+      break;
+    case 5      :       //job completed
       if (eml_renameqfile(fname,EXDOING,EXDONE)==false) {
         (void) rou_alert(0,"%s Unable to rename file <%s.%s>",OPEP,fname,EXDONE);
         phase=999;      //No need to go further
         }
       break;
     default     :       //SAFE Guard
+      if (qfile!=(FILE *)0)
+        (void) eml_closeqfile(qfile);
       proceed=false;
       break;
     }
index 92c59425785b9a61e9846f041dca903fcf1ed04a..17dfbc2d2a57dd9b71ced48cf56c5fe5e4896ff3 100644 (file)
@@ -454,7 +454,7 @@ if ((ext!=(const char *)0)&&((strlen(fullname)+strlen(ext)+3)<sizeof(fullname)))
   (void) strcat(fullname,".");
   (void) strcat(fullname,ext);
   }
-if ((qfile=fopen(fullname,"r"))==(FILE *)0) {
+if ((qfile=fopen(fullname,"r+"))==(FILE *)0) {
   (void) rou_alert(0,"%s Unable to open file <%s> (error-<%s> bug?)",
                      OPEP,fullname,strerror(errno));
   }