From 041ab247e6bfbae17da8a0c6c1870a6f84d1980b Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Mon, 19 May 2025 10:46:09 -0400 Subject: [PATCH] starting sender local delivery implementation --- Makefile | 2 +- app/sender.c | 36 +++++++++++++++++++++++++++++++----- lib/unieml.c | 2 +- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 5b9fd49..78805e3 100644 --- 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 \ diff --git a/app/sender.c b/app/sender.c index 6205182..d0404d0 100644 --- a/app/sender.c +++ b/app/sender.c @@ -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 } /* @@ -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; } diff --git a/lib/unieml.c b/lib/unieml.c index 92c5942..17dfbc2 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -454,7 +454,7 @@ if ((ext!=(const char *)0)&&((strlen(fullname)+strlen(ext)+3) (error-<%s> bug?)", OPEP,fullname,strerror(errno)); } -- 2.47.3