]> SAFE projects GIT repository - jmp/mailleur/commitdiff
make actions seems to be working properly
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 6 Jun 2025 14:42:44 +0000 (10:42 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 6 Jun 2025 14:42:44 +0000 (10:42 -0400)
Makefile
app/Makefile
app/emlrcvr.c
app/sender.c
app/sorter.c
lib/geseml.c
lib/lvleml.c
lib/unieml.c

index 741e6f23904f94741817a352ebdcb75d1a729848..e0d6414768546334b0eeddc1aeaaf5bee0a54047 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ EXTPORT =     25
 TESTITER=      1
 #--------------------------------------------------------------------
 #To test sorter
-dosorter:  debug
+dosorter:  
           @ bin/sorter                                 \
                   -d 2                                 \
                   -c ./conf/mailleur.conf.dvl          \
@@ -103,16 +103,19 @@ sender    :  clean debug newtest
                        tr '\\n' ' ' `
 
 dbgsend        :  clean debug
+          @ rm -fr $(TESTDIR)/var/spool/$(APPNAME)/queue
+          @ mkdir -p $(TESTDIR)/var/spool/$(APPNAME)/queue
           @ cp -a                                      \
-               ./data-$@/*                             \
+               ./data-sender/*                         \
                $(TESTDIR)/var/spool/$(APPNAME)/queue/
           @ gdb                                        \
                --args                                  \
-                       bin/sender                      \
-                         -f                            \
-                         -d2                           \
-                         -c ./conf/mailleur.conf.dvl   \
-                         -r $(TESTDIR) 
+                 bin/sender                            \
+                   -d2                                 \
+                   -c ./conf/mailleur.conf.dvl         \
+                   -r $(TESTDIR)                       \
+                   `basename -a data-sender/*.todo  |  \
+                    tr '\\n' ' ' `
 
 #--------------------------------------------------------------------
 #testing feed
@@ -251,7 +254,7 @@ EMLPAR      =                                               \
           -d 2                                         \
           $(TESTPROT):$(TESTIP):$(TESTPORT):
 
-dorcvr :  debug
+dorcvr :  
           @ bin/emlrcvr                                \
                $(EMLPAR)$(TESTITER)
 
@@ -260,6 +263,7 @@ emlrcvr     :  #starting email receiver
           @ echo "--------------"
           @ echo "starting $@"
           @ $(TESTDIR)/$(SBINDIR)/$@                   \
+               -f                                      \
                $(EMLPAR)$(TESTITER)
           @ echo "--------------"
 
@@ -302,7 +306,7 @@ norcvr      :
                        `cat $(LOCKDIR)/emlrcvr.lock`;  \
                 fi
 
-prepare        :  debug newtest
+prepare        :  clean debug newtest
 
 #to kill all remaining emlrcvr process
 killall        :
index 0b084ae4f3442b317ea3a40ea1107a276ac0f1c7..6ea69d428ee52e2cbda945309f3a09d40643625d 100644 (file)
@@ -86,6 +86,10 @@ feeder.o:  feeder.c                          \
 
 sorter.o:  sorter.c                            \
           ../lib/geseml.h                      \
+          ../lib/unisig.h                      \
+          ../lib/uniprc.h                      \
+          ../lib/unipar.h                      \
+          ../lib/unieml.h                      \
           ../lib/subrou.h
 
 sender.o:  sender.c                            \
@@ -93,6 +97,7 @@ sender.o:  sender.c                           \
           ../lib/geseml.h                      \
           ../lib/unieml.h                      \
           ../lib/unipar.h                      \
+          ../lib/uniprc.h                      \
           ../lib/unisig.h                      \
           ../lib/subrou.h
 
index cc2df1d5715b672caa2f93fc4f81272ef5e8d80d..bcfd6d2c7cf8fd4f4e4c8a680b966216e874a0e3 100644 (file)
@@ -63,7 +63,7 @@ while (proceed==true) {
     case 2      :       //sett lock
       if (foreground==false) {
         if (prc_divedivedive()!=0)
-          exit(0);
+          phase=999;    //direct exit
         }
       else
         (void) fprintf(stdout,"Running application in foreground\n");
index e16d01b61fc0a6bbbaac447245b0ab92fcfdeb5b..e91caad64ecad481c4b1ff7a413d45a24b4f99a3 100644 (file)
@@ -19,6 +19,7 @@
 #include       "subrou.h"
 #include       "unieml.h"
 #include       "unipar.h"
+#include       "uniprc.h"
 #include       "unisig.h"
 #include       "geseml.h"
 #include       "lvleml.h"
@@ -155,6 +156,7 @@ int main(int argc,char *argv[])
 
 {
 #define OPEP    "sender.c:main,"
+
 int status;
 ARGTYP *params;
 int phase;
@@ -162,11 +164,11 @@ _Bool proceed;
 
 status=0;
 params=(ARGTYP *)0;
-foreground=true;
+foreground=false;
 phase=0;
 proceed=true;
 while (proceed==true) {
-  //(void) fprintf(stdout,"%s JMPDBG main phase='%d'\n",OPEP,phase);
+  //(void) fprintf(stdout,"%s (pid=%08d) JMPDBG phase='%d'\n",OPEP,getpid(),phase);
   switch (phase) {
     case 0      :       //checking parameters
       if ((params=par_getparams(argc,argv,"c:d:fh:r:v"))==(ARGTYP *)0) {
@@ -185,7 +187,10 @@ while (proceed==true) {
       (void) rou_setappname(SENDER);
       (void) rou_loadconfig(config,true);
       (void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON);
-      (void) closelog();
+      if (foreground==false) {
+        if (prc_divedivedive()!=0)
+          phase=999;    //direct exit
+        }
       break;
     case 3      :       //scanning parameters list
       if (params!=(ARGTYP *)0) {        //always
@@ -197,18 +202,18 @@ while (proceed==true) {
           char *ptr;
 
           fname=params->argv[num];
-          (void) rou_alert(0,"%s fname file <%s>",appname,fname);
+          (void) rou_alert(0,"%s fname file <%s>",OPEP,fname);
           if ((hangup==true)||(reload==true))
             break;
           if ((ptr=strrchr(fname,'.'))==(char *)0) {
-            (void) rou_alert(0,"%s unable to find <%s> extension",SENDER,fname);
+            (void) rou_alert(0,"%s unable to find <%s> extension",OPEP,fname);
             break;
             }
           *ptr='\000';
           ptr++;
           if (strcmp(ptr,EXTODO)!=0) {
             (void) rou_alert(0,"%s wrong extension for file <%s.%s>",
-                                SENDER,fname,ptr);
+                                OPEP,fname,ptr);
             break;
             }
           (void) rou_alert(0,"%s scanning file <%s>",appname,fname);
index f513bdea4f2fe93ae61dce894b89e160eb20172e..0dffc0b75d6297aabac34a94b9391fb8b6059a29 100644 (file)
@@ -15,6 +15,7 @@
 #include       "subrou.h"
 #include       "unieml.h"
 #include       "unipar.h"
+#include       "uniprc.h"
 #include       "unisig.h"
 #include       "geseml.h"
 
@@ -122,8 +123,13 @@ while (proceed==true) {
       (void) rou_setappname(SORTER);
       (void) rou_loadconfig(config,true);
       (void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON);
+      if (foreground==false) {
+        if (prc_divedivedive()!=0)
+          phase=999;    //direct exit
+        }
       break;
     case 2      :       //check about signal process
+      (void) sleep(5);
       if (hangup==true) {
         (void) rou_alert(0,"%s got hangup signal",OPEP);
         phase=999;      //exiting loop
@@ -140,10 +146,8 @@ while (proceed==true) {
       (void) scantrans(EXDONE,false);
       break;
     case 5      :       //one shot deal??
-      if (foreground==false) {
-        (void) sleep(5);
+      if (foreground==false)
         phase=1;       //restarting
-        }
       break;
     default     :       //end of task
       params=par_freeparams(params);
index 27462c4cea3dbdaef6b774c5d1b45f38423ac9a2..31bcea7cdf1c3af66aee683db31a87b21ca85533 100644 (file)
@@ -625,12 +625,10 @@ switch (fork()) {
                         OPEP,strerror(errno));
     break;
   case 0        :       //the forked process
-    int exitval;
     char *execpath;
     char *argv[10];
     char buffer[300];
 
-    exitval=0;
     (void) memset(argv,'\000',sizeof(argv));
     (void) snprintf(buffer,sizeof(buffer),"%s%s",SBINDIR,SENDER);        
     execpath=rou_apppath(buffer);
@@ -649,12 +647,12 @@ switch (fork()) {
     if (execv(execpath,argv)<0) {
       (void) rou_alert(0,"%s Unable to exec process=<%s> (error=<%s> Bug?)",
                         OPEP,execpath,strerror(errno));
-      exitval=-1;
+      (void) rou_freestr(execpath);
+      (void) system("ls -ails /home/jmp/safe-mailleur/mailleur/test_area/var/spool/mailleur/queue/");
+      (void) exit(-1);
       }
-    (void) rou_freestr(execpath);
-    (void) exit(exitval);
     break;
-  default       :       //the forking process itself
+  default       :               //the forking process itself
     (void) usleep(10000);       //relax delay
     status=true;
     break;
index a7ce213251c9823ec45cc0b43edfa003b02f939a..a2d676426ed63333f945283585f1f8ca388d7f56 100644 (file)
@@ -1047,6 +1047,6 @@ PUBLIC void eml_remote_email(TRATYP **tra)
 {
 #define OPEP    "lvleml.c:eml_remote_email,"
 
-(void) rou_alert(0,"%s JMPDBG",OPEP);
+(void) rou_alert(0,"%s JMPDBG foreground='%d'",OPEP,foreground);
 #undef  OPEP
 }
index 0a893562ab2f154e2bba2c433ca26fffdd3b3d75..be2e7dd449914ad4b6a3ca8b3122eac45db970c1 100644 (file)
@@ -288,8 +288,13 @@ filename=rou_apppath(QDIR);
 (void) snprintf(fold,sizeof(fold),"%s/%s.%s",filename,qfilename,oldext);
 (void) snprintf(fnew,sizeof(fnew),"%s/%s.%s",filename,qfilename,newext);
 if (rename(fold,fnew)<0) {
+  char *cwd;
+
+  cwd=get_current_dir_name();
   (void) rou_alert(0,"%s Unable to rename file <%s>  to <%s> (error=<%s>)",
                            OPEP,fold,fnew,strerror(errno));
+  (void) rou_alert(0,"%s current working dir=<%s>",OPEP,cwd);
+  cwd=rou_freestr(cwd);
   status=false;
   }
 filename=rou_freestr(filename);