]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Sorting transfer request seems to be working
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 13 May 2025 23:58:21 +0000 (19:58 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 13 May 2025 23:58:21 +0000 (19:58 -0400)
app/sorter.c
lib/geseml.c
lib/geseml.h

index 03ff9876e954e3b400fbbc51bd7bb23982339e26..c5b6aada485a1f17d2de7fd51a9e4a979141a593 100644 (file)
@@ -61,6 +61,7 @@ while (proceed==true) {
           (void) rou_alert(0,"%s fame=<%s>",OPEP,*ptr);
           if ((qfile=eml_openqfile(*ptr))!=(FILE *)0) {
             trans=eml_scanqfile(trans,qfile);
+            (void) eml_closeqfile(qfile);
             }
           ptr++;
           }
@@ -72,10 +73,7 @@ while (proceed==true) {
         TRATYP **ptr;
 
         ptr=trans;
-        while (*ptr!=(TRATYP *)0) {
-          (void) eml_dumptra(*ptr); 
-          ptr++;
-          }
+        (void) eml_todoqfile(ptr);
         trans=(TRATYP **)rou_freelist((void **)trans,(freehandler_t)eml_freetra);
         status=true;
         }
index 33fdc876377f36ab5e624a834d5f4d91e16ced73..cd575fe9ce6c048026e6b14cfc6736f51d645d73 100644 (file)
 #include       "subrou.h"
 #include       "geseml.h"
 
+typedef struct  {
+        char *domain;   //common domain
+        TRATYP **todo;  //Transfer reference
+        }REFTYP;
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to display/debug TRATYP record content*/
+/*                                                      */
+/********************************************************/
+static REFTYP *findref(REFTYP **reflist,char *domain)
+
+
+{
+REFTYP *found;
+
+found=(REFTYP *)0;
+if (reflist!=(REFTYP **)0) {
+  while (*reflist!=(REFTYP *)0) {
+    if (strcmp((*reflist)->domain,domain)==0) {
+      found=*reflist;
+      break;
+      }
+    reflist++;
+    }
+  }
+return found;
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to display/debug TRATYP record content*/
+/*                                                      */
+/********************************************************/
+static REFTYP **sortref(REFTYP **reflist,TRATYP *trans)
+
+{
+#define OPEP    "geseml.c:sortref,"
+
+char *dom;
+REFTYP *ref;
+int phase;
+_Bool proceed;
+
+dom=(char *)0;
+ref=(REFTYP *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  switch (phase) {
+    case 0    :         //Firsy Check if we have data
+      if (trans==(TRATYP *)0) {
+        (void) rou_alert(0,"%s trans is NULL (Bug?)",OPEP);
+        phase=999;      //No need to gi further
+        }
+      break;
+    case 1    :         //Do we hav a domain
+      if ((dom=strchr(trans->rcptto,'@'))==(char *)0) {
+        (void) rou_alert(0,"%s unable to find domain within <%s> (Bug?)",
+                            OPEP,trans->rcptto);
+        phase=999;    //No dmain
+        }
+      break;
+    case 2    :       //do we know domain
+      if ((ref=findref(reflist,dom))!=(REFTYP *)0)
+        phase++;      //we have reference already
+      break;
+    case 3    :       //Adding reference
+      ref=(REFTYP *)calloc(1,sizeof(REFTYP));
+      ref->domain=dom;
+      reflist=(REFTYP **)rou_addlist((void **)reflist,(void *)ref);
+      break;
+    case 4    :       //Adding transaction within reference
+      ref->todo=(TRATYP **)rou_addlist((void **)ref->todo,(void *)trans);
+      break;
+    default   :       //SAFE Guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+return reflist;
+#undef  OPEP
+}
 /*
 \f
 */
@@ -118,5 +206,51 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
     }
   }
 return list;
-#undef  OEP
+#undef  OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to generate a list of todo file to    */
+/*      sender MTA.                                     */
+/*                                                      */
+/********************************************************/
+PUBLIC _Bool eml_todoqfile(TRATYP **list)
+
+{
+#define OPEP    "geseml.c:eml_todoqfile,"
+
+_Bool done;
+REFTYP **domlist;
+
+done=false;
+domlist=(REFTYP **)0;
+while (*list!=(TRATYP *)0) {
+  domlist=sortref(domlist,*list);
+  list++;
+  }
+if (domlist!=(REFTYP **)0) {
+  REFTYP **ptr;
+
+  ptr=domlist;
+  while (*ptr!=(REFTYP *)0) {
+    (void) rou_alert(0,"%s JMPDBG refdomain=<%s>",OPEP,(*ptr)->domain);
+    if ((*ptr)->todo!=(TRATYP **)0) {
+      TRATYP **todo;
+
+      todo=(*ptr)->todo;
+      while (*todo!=(TRATYP *)0) {
+        (void) eml_dumptra(*todo);
+        todo++;
+        }
+      }
+    (void) free(*ptr);
+    ptr++;
+    }
+  (void) free(domlist);
+  }
+return done;
+#undef  OPEP
 }
index 6c172f57d8ebc2a0bbc80548832effb84655347c..b242e2e051a3348eefb7de166497726c8624ed55 100644 (file)
@@ -30,4 +30,7 @@ extern TRATYP *eml_freetra(TRATYP *tra);
 //procedure to open a specific qfile
 extern TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile);
 
+//procedure to Generate todolist file within queue
+extern _Bool eml_todoqfile(TRATYP **list);
+
 #endif