]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting to implement action table
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 29 Jun 2025 22:26:13 +0000 (18:26 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 29 Jun 2025 22:26:13 +0000 (18:26 -0400)
12 files changed:
Makefile
app/Makefile
app/sender.c
app/sorter.c
lib/Makefile
lib/devsql.c
lib/devsql.h
lib/geseml.c
lib/geseml.h
lib/lvleml.c
lib/unisql.h
mailleur.spec.in

index a7b1aa49cfc546abee302b8e8ff746c51b6fdbfd..f393b97bc52a3e7f528129a38b51b29b4654c6ba 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@ debug                                                 \
               done
           @ ln -nsf rcvrpsql bin/receiver
           @ ln -nsf sndrpsql bin/sender
+          @ ln -nsf srtrpsql bin/sorter
        
        
 
index c4c05d456cc20dc924f96f557c8c76fdcc8d7388..adb60be8c3e1210fe643d476e60c3b9a6840409f 100644 (file)
@@ -27,7 +27,8 @@ EXE=                                                          \
        feeder                                                  \
        sndrpsql                                                \
        sndrmsql                                                \
-       sorter                                                  \
+       srtrpsql                                                \
+       srtrmsql                                                \
 
 SRC=                                                           \
        chkspf.c                                                \
@@ -86,15 +87,27 @@ sndrmsql:  toremake receiver.o
                 ../lib/libmar.a                        \
                 -lmysqlclient
 
+srtrpsql:  toremake sorter.o
+          @ $(LD) $(LDFLAGS)                           \
+                -o ../bin/$@ sorter.o                  \
+                $(LIBS)                                \
+                ../lib/libpos.a                        \
+                -lpq
+
+srtrmsql:  toremake sorter.o
+          @ $(LD) $(LDFLAGS)                           \
+                -o ../bin/$@ sorter.o                  \
+                $(LIBS)                                \
+                ../lib/libmar.a                        \
+                -lmysqlclient
+
+
 feeder :  toremake feeder.o
           @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS)
 
 sender :  toremake sender.o
           @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS)
 
-sorter :  toremake sorter.o
-          @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS)
-
 chkspf.o:  chkspf.c                            \
           ../lib/unidns.h                      \
           ../lib/subafn.h                      \
index 08ea3205d3290a355fabc757e9ce7b760345414b..6e4e2c776811464d2c194caeddd5907a244f9b3f 100644 (file)
@@ -124,7 +124,7 @@ while (proceed==true) {
     case 5      :       //updating transfile 
       (void) eml_dump_list_tra(qfile,tra);
       (void) eml_update_tradb(tra);
-      tra=(TRATYP **)rou_freelist((void **)tra,(genfree_t)eml_freetra);
+      tra=eml_freeall_tra(tra);
       break;
     case 6      :       //closing file
       qfile=eml_closeqfile(qfile);
index ffd6979b02ebdf60b55ec7f4ac916244a6299a34..461be075420e0bdd5bd6fe4f4cdd865f92807f0f 100644 (file)
@@ -82,7 +82,7 @@ while (proceed==true) {
           (void) eml_doneqfile(trans);
           break;
         }
-      trans=(TRATYP **)rou_freelist((void **)trans,(genfree_t)eml_freetra);
+      trans=eml_freeall_tra(trans);
       break;
     default     :       //SAFE Guard
       proceed=false;
index 143d38699656937c220a0fb966828006053d4877..69afed401dcb3befa84d85660cf1d17ca5a30959 100644 (file)
@@ -55,6 +55,7 @@ gesspf.o:                                     \
 geseml.o:                                      \
           subrou.h                             \
           unidns.h unieml.h unipar.h unitls.h  \
+          devsql.h                             \
           geseml.h geseml.h
 
 gestcp.o:                                      \
index 32d3e47ce90a2b8d9100830feb2c6cf1d2265e30..cb16ce40b195b7b6809837bb5cca5fc4fc37e22d 100644 (file)
@@ -809,3 +809,35 @@ 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)
+
+{
+_Bool isok;
+
+isok=false;
+if (act!=(ACTTYP *)0) {
+  (void) rou_alert(0,"JMPDBG ses=<%s>d rcpt=<%s>",act->sessid,act->rcptto);
+  if (act->resp!=(char **)0) {
+    char **resp;
+    int num;
+  
+    resp=act->resp;
+    num=0;
+    while (*resp!=(char *)0) {
+      num++;
+      (void) rou_alert(0,"\tRESP[%0d]=<%s>",num,*resp);
+      resp++;
+      }
+    }
+  }
+return isok;
+}
index 547e98b25fa9c4ff8285b57851940550e9b470e1..a9b68fa667391c8a3b8ff085837054b6f540345b 100644 (file)
@@ -29,4 +29,7 @@ extern _Bool sql_mngusr(SQLPTR *sqlptr,SQLENUM action,char *email,USRTYP **usr);
 //procedure to manage information on email exchange session
 extern _Bool sql_mngses(SQLPTR *sqlptr,SQLENUM action,SESTYP **ses);
 
+//procedure to manage action stats on email exhange status
+extern _Bool sql_mngact(SQLPTR *sqlptr,SQLENUM action,ACTTYP *act);
+
 #endif
index cd474044f62bb4d53c2d471a0034520a154f0f09..0dfa0283308766e3eecc2293a9daeb5cc823258a 100644 (file)
@@ -16,6 +16,7 @@
 #include       "unieml.h"
 #include       "unipar.h"
 #include       "unitls.h"
+#include       "devsql.h"
 #include       "geseml.h"
 
 //dovecot local storage directory
@@ -156,6 +157,27 @@ 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*/
 /*                                                      */
 /********************************************************/
@@ -275,28 +297,7 @@ if (tra!=(TRATYP *)0) {
 */
 /********************************************************/
 /*                                                      */
-/*      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;
-}
-/*
-\f
-*/
-/********************************************************/
-/*                                                      */
-/*      Procedure to duplcate an resp list within a tra */
+/*      Procedure to duplicate an resp list within a tra*/
 /*      record.                                         */
 /*                                                      */
 /********************************************************/
@@ -352,6 +353,21 @@ 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.              */
 /*                                                      */
@@ -982,11 +998,19 @@ PUBLIC int eml_update_tradb(TRATYP **tra)
 
 {
 int num;
+SQLPTR *sqlptr;
 
 num=0;
+sqlptr=(SQLPTR *)0;
 if (tra!=(TRATYP **)0) {
   while (*tra!=(TRATYP *)0) {
-    (void) rou_alert(0,"JMPDBG ses=<%s>d rcpt=<%s>",(*tra)->sessid,(*tra)->rcptto);
+    ACTTYP action;
+
+    action.sessid=(*tra)->sessid;
+    action.rcptto=(*tra)->rcptto;
+    action.resp=(*tra)->resp;
+    (void) sql_mngact(sqlptr,sql_delete,&action); 
+    num++;
     tra++;
     }
   }
index 0d2d49384286efcd7d62799e2771afd399b52bf8..c6f16db3d4ddb14c99dc6de1f3053da7a45a30e2 100644 (file)
@@ -38,12 +38,12 @@ 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);
 
-//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 fee memory used by a TRATYP structure
+extern TRATYP **eml_freeall_tra(TRATYP **tra);
+
 //procedure to open a specific qfile
 extern TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile);
 
index a25fa07362f891950fe074312c7c74542d1a471b..39c5c8b8a57011caed276998de4f31bbcde328b8 100644 (file)
@@ -1836,7 +1836,7 @@ if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) {
     ptr++;
     }
   (void) eml_dump_list_tra(qfile,tralist);
-  tralist=(TRATYP **)rou_freelist((void **)tralist,(genfree_t)eml_freetra);
+  tralist=eml_freeall_tra(tralist);
   }
 return status;
 #undef  OPEP
index ba874e66255db1b428f6d07dade8e4bf8c725a71..30e8986aec3c1a1503d29fa2979c4b6eafdd004a 100644 (file)
@@ -38,6 +38,13 @@ typedef struct  {
         u_long taille;  //Email size
         }SESTYP;
 
+//Tructure about email action status (managing email)
+typedef struct  {
+        char *sessid;   //session id
+        char *rcptto;   //email recipient
+        char **resp;    //Multiline status
+        }ACTTYP;
+
 //procedure to free space used by an USRTYP
 extern USRTYP *sql_freeusr(USRTYP *usr);
 
index 54332863dbd433d5a3da69281f1cda3ccb45e379..6a7cf81aac84d7ae294f7359d598a7d7d612f01d 100644 (file)
@@ -45,7 +45,6 @@ search about email exchange within time and transaction context.
 %attr(0640,%{name},dovecot) %config(noreplace) %{dovedir}/passfile
 %{_sbindir}/chkspf
 %{_sbindir}/feeder
-%attr(0755,%{name},mail) %{_sbindir}/sorter
 %attr(0754,root,root) %{_libdir}/%{name}/shell/*.sh
 %attr(0754,root,root) %{_libdir}/%{name}/support/addconfig.sh
 %attr(0754,root,root) %{_libdir}/%{name}/support/crdb.sh
@@ -167,6 +166,7 @@ Obsoletes   :       %{name}-mysql           <= %{version}-%{release}
 %defattr(-,root,root,-)
 %attr(0755,%{name},mail) %{_sbindir}/rcvrpsql
 %attr(0755,%{name},mail) %{_sbindir}/sndrpsql
+%attr(0755,%{name},mail) %{_sbindir}/srtrpsql
 
 %post                  postgresql
 if [ "$1" = 1 ]; then
@@ -183,10 +183,15 @@ if [ "$1" = 1 ]; then
 %{__ln_s} -nf                                  \
        ./sndrpsql                              \
        %{_sbindir}/sender
+%{__ln_s} -nf                                  \
+       ./srtrpsql                              \
+       %{_sbindir}/sorter
 
 %postun                        postgresql
 if [ "$1" = 0 ]; then
-  rm -f %{_sbindir}/%{name}
+  rm -f %{_sbindir}/receiver
+  rm -f %{_sbindir}/sender
+  rm -f %{_sbindir}/sorter
   fi
 
 #=============================================================================
@@ -209,6 +214,7 @@ Obsoletes   :       %{name}-postgresql      <= %{version}-%{release}
 %defattr(-,root,root,-)
 %attr(0755,%{name},mail) %{_sbindir}/rcvrmsql
 %attr(0755,%{name},mail) %{_sbindir}/sndrmsql
+%attr(0755,%{name},mail) %{_sbindir}/srtrmsql
 
 %post                  mysql
 if [ "$1" = 1 ]; then
@@ -224,11 +230,15 @@ if [ "$1" = 1 ]; then
 %{__ln_s} -nf                                  \
        ./sndrmsql                              \
        %{_sbindir}/sender
+%{__ln_s} -nf                                  \
+       ./srtrmsql                              \
+       %{_sbindir}/sorter
 
 %postun                        mysql
 if [ "$1" = 0 ]; then
   rm -f %{_sbindir}/receiver
   rm -f %{_sbindir}/sender
+  rm -f %{_sbindir}/sorter
   fi
 
 #=============================================================================
@@ -252,9 +262,11 @@ if [ "$1" = 0 ]; then
         DESTDIR="%{buildroot}"         \
         install
 
+#removing default link generated by make
 %{__rm} -fr                            \
+       %{buildroot}%{_sbindir}/receiver\
        %{buildroot}%{_sbindir}/sender  \
-       %{buildroot}%{_sbindir}/receiver
+       %{buildroot}%{_sbindir}/sorter  \
        
 #=============================================================================
 %changelog