From c7d817ad9254be0effa49beb511d7622140a5ebc Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Tue, 27 May 2025 09:16:18 -0400 Subject: [PATCH] Able to remove session ID --- Makefile | 13 ++++++++++++ lib/geseml.c | 32 +++++++++++++++++++++++++++- lib/unieml.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/unieml.h | 21 +++++++++++++++++++ 4 files changed, 124 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fb93f83..014cb57 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,19 @@ sorter : clean debug ./data-queue/ +dbgsorter: clean debug + @ mkdir -p $(TESTDIR)/var/spool/$(APPNAME)/queue + @ cp -a \ + data-queue/* \ + $(TESTDIR)/var/spool/$(APPNAME)/queue + @ gdb \ + --args \ + bin/sorter \ + -f \ + -d 2 \ + -c ./conf/mailleur.conf.dvl \ + -r $(TESTDIR) + #-------------------------------------------------------------------- #To test sender sender : clean debug newtest diff --git a/lib/geseml.c b/lib/geseml.c index 2937da3..0f074bc 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -331,9 +331,39 @@ PUBLIC _Bool eml_doneqfile(TRATYP **list) #define OPEP "geseml.c:eml_doneqfile," _Bool check; +SIDTYP **sids; check=true; -(void) rou_alert(0,"%s JMPDBG check done",OPEP); +sids=(SIDTYP **)0; +(void) rou_alert(0,"%s JMPDBG trying check",OPEP); +if (list!=(TRATYP **)0) { + while (*list!=(TRATYP *)0) { + SIDTYP *found; + + found=eml_addsid(&sids,(*list)->sessid); + switch ((*list)->code) { + case 'C' : //completed + break; + default : + found->count++; + break; + } + list++; + } + } +if (sids!=(SIDTYP **)0) { + SIDTYP **ptr; + + ptr=sids; + while (*ptr!=(SIDTYP *)0) { + if ((*ptr)->count==0) { + (void) rou_alert(0,"%s JMPDBG need to remove <%s>",OPEP,(*ptr)->sessid); + (void) eml_deleteqfile((*ptr)->sessid); + } + ptr++; + } + sids=eml_freesid(sids); + } return check; #undef OPEP diff --git a/lib/unieml.c b/lib/unieml.c index a3e1ba6..31f6bc8 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -44,6 +44,65 @@ static VOCTYP vocsmtp[]={ /********************************************************/ /* */ /* Procedure to free memory used by a list of */ +/* session id. */ +/* */ +/********************************************************/ +PUBLIC SIDTYP **eml_freesid(SIDTYP **list) + +{ +if (list!=(SIDTYP **)0) { + SIDTYP **ptr; + + ptr=list; + while (*ptr!=(SIDTYP *)0) { + (void) free(*ptr); + ptr++; + } + (void) free(list); + list=(SIDTYP **)0; + } +return list; +} +/* +^L +*/ +/********************************************************/ +/* */ +/* Procedure to add an session ID to a list of */ +/* session ID */ +/* */ +/********************************************************/ +PUBLIC SIDTYP *eml_addsid(SIDTYP ***list,char *sessid) + +{ +SIDTYP *found; + +found=(SIDTYP *)0; +if (*list!=(SIDTYP **)0) { + SIDTYP **ptr; + + ptr=*list; + while (*ptr!=(SIDTYP *)0) { + if (strcmp(sessid,(*ptr)->sessid)==0) { + found=*ptr; + break; + } + ptr++; + } + } +if (found==(SIDTYP *)0) { + found=(SIDTYP *)calloc(1,sizeof(SIDTYP)); + found->sessid=sessid; + *list=(SIDTYP **)rou_addlist((void **)*list,(void *)found); + } +return found; +} +/* +^L +*/ +/********************************************************/ +/* */ +/* Procedure to free memory used by a list of */ /* recipient. */ /* */ /********************************************************/ diff --git a/lib/unieml.h b/lib/unieml.h index f38c061..4be728e 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -48,6 +48,27 @@ typedef struct { //*definition of recipient char *userid; //recipient email userid }RCPTYP; +typedef struct { //definition of SID reference + int count; //Number of SESSID reference + char *sessid; //Session ID reference + }SIDTYP; + +//Freeing list of sessid +extern SIDTYP **eml_freesid(SIDTYP **list); + +//adding an session ID to a list of session +extern SIDTYP *eml_addsid(SIDTYP ***list,char *sessid); + +//procedure to Free one recipient info +extern RCPTYP *eml_freerecipient(RCPTYP *info); + +//get a session unique id +extern char *eml_getmainsesid(); + +//procedure to add recipient to a recipient list +//adding an session ID to a list of session +extern SIDTYP *eml_addsid(SIDTYP ***list,char *sessid); + //procedure to Free one recipient info extern RCPTYP *eml_freerecipient(RCPTYP *info); -- 2.47.3