]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Implemented count qfile concept
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 12 Jun 2025 12:56:07 +0000 (08:56 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 12 Jun 2025 12:56:07 +0000 (08:56 -0400)
lib/geseml.h
lib/lvleml.c
lib/modrec.c
lib/unieml.h

index 47919448a1c27e568b4143f43402c95258424678..76f533ab5ce0366f21c4ab6c6977c96d8d5c42a3 100644 (file)
@@ -12,8 +12,6 @@
 #include        <stdio.h>
 #include        <time.h>
 
-#define EXTOBE  "tobedone"      //directive enxtension in progress
-
 //structure to define an email transport directive
 typedef struct  {
         char code;      //Transaction code
index 433e8553ae4b04f49f2377e9e436e13ee4550622..57182edd5991f8d47ce5e32fd1f6784401951f51 100644 (file)
@@ -284,6 +284,81 @@ while (proceed==true) {
   phase++;
   }
 return done;
+#undef  OPEP
+}
+/*
+\f
+*/
+/************************************************/
+/*                                             */
+/*     Procedure to set create the sessid count*/
+/*      file. This file is used to keep track   */
+/*      of the number of the sessionid|(rcpt)   */
+/*      used to send email to all recipient.    */
+/*                                             */
+/************************************************/
+static _Bool setcountfile(CONTYP *contact)
+
+{
+#define OPEP    "lvleml.c:setcountfile,"
+
+_Bool status;
+int num;
+FILE *qfile;
+int phase;
+_Bool proceed;
+
+status=false;
+num=0;
+qfile=(FILE *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  switch (phase) {
+    case 0      :       //is contact good
+      if (contact==(CONTYP *)0) {
+        (void) rou_alert(0,"%s contact pointer is NULL (bug?)",OPEP);
+        phase=999;
+        }
+      break;
+    case 1      :       //counting recipient number
+      if ((num=rou_nbrlist((void **)contact->recipients))==0)
+        phase=999;      //No recipient!
+      break;
+    case 2      :       //creating the count file
+      if ((qfile=eml_createqfile(contact->cursesid,EXTCNT))==(FILE *)0) {
+        (void) rou_alert(0,"%s Unable to open 'count' qfile <%s> (error=<%s>)",
+                            OPEP,contact->cursesid,strerror(errno));
+        phase=999;
+        }
+      break;
+    case 3      :       //inserting number of receipient
+      if (fprintf(qfile,"%d\n",num)<1) {
+        (void) rou_alert(0,"%s Unable to set 'count' in qfile <%s> (error=<%s>)",
+                            OPEP,contact->cursesid,strerror(errno));
+        (void) fclose(qfile);
+        phase=999;      //trouble trouble
+        }
+      break;
+    case 4      :       //closing count file
+      if (fclose(qfile)!=0) {
+        (void) rou_alert(0,"%s Unable to close qfile <%s> (error=<%s>)",
+                            OPEP,contact->cursesid,strerror(errno));
+        phase=999;      //trouble trouble
+        }
+      break;
+    case 5      :       //everything fine
+      status=true;
+      break;
+    default     :       //SAFE Guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+return status;
+
+
 #undef  OPEP
 }
 /*
@@ -372,6 +447,7 @@ static _Bool getdata(CONTYP *contact)
 
 {
 #define        OPEP    "lvleml.c:getdata,"
+#define EXTMP  "tmp"
 
 _Bool done;
 FILE *queue;
@@ -386,7 +462,7 @@ queue=(FILE *)0;
 completed=false;
 total=0;
 phase=0;
-proceed=setdirectives(contact,"tmp");
+proceed=setdirectives(contact,EXTMP);
 while (proceed==true) {
   //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
   switch (phase) {
@@ -430,11 +506,15 @@ while (proceed==true) {
       if (eml_closeqfile(queue)<0)
         phase=999;              //Trouble trouble
       break;
-    case 5      :       //renameing directive
-      if (eml_renameqfile(contact->cursesid,"tmp",EXTRANS)==false)
+    case 5      :       //creating the count file
+      if (setcountfile(contact)==false) 
+        phase=999;      //Unable to create count file???
+      break;
+    case 6      :       //renameing directive
+      if (eml_renameqfile(contact->cursesid,EXTMP,EXTRANS)==false)
         phase=999;              //Trouble trouble
       break;
-    case 6      :       //everything fine
+    case 7      :       //everything fine
       const char *fmt;
       unsigned int delta;
 
@@ -457,6 +537,8 @@ while (proceed==true) {
   phase++;
   }
 return done;
+
+#undef  EXTMP
 #undef  OPEP
 }
 /*
index 21298012c9e56a4f070347c0fbea5207cb2759c8..d66af6bd77f821694944b33815417c206337b3c1 100644 (file)
@@ -98,7 +98,7 @@ while (proceed==true) {
     case 2      :       //do contact
       intstat=eml_docontact(contact);
       switch (intstat) {
-        case  1 :       //command 'quit' receoved
+        case  1 :       //command 'quit' recieved
           break;
         case  0 :       //exit under timeout
           (void) rou_alert(0,"Contact timeout with peer <%s>",contact->peerip);
index 2c755e2249ecf26f3d031eb313237142becd6d3b..06ab772ef4da8b46edda289b18b33f5691557ede 100644 (file)
 
 //defining extensions
 #define EXTODO  "todo"          //todo qfile extension
-#define EXDONE  "done"          //todo file processing completed
-#define EXDOING "doing"         //todo file in sending mode
+#define EXDONE  "done"          //todo qfile processing completed
+#define EXDOING "doing"         //todo qfile in sending mode
 #define EXTRANS "trans"         //trans qfile extension
+#define EXTCNT  "count"         //count sessid by email extension
+#define EXTOBE  "tobedone"      //in progess qfile extension
+
 
 #define SBINDIR "/usr/sbin/"    //appliaction installation directory
 #define SENDER  "sender"        //application email sender