From a36694456d8c3a6ab5fa8db051101839dded1c32 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Tue, 27 May 2025 07:10:39 -0400 Subject: [PATCH] Starting to implement done list cleaning process. --- app/sorter.c | 32 +++++++++++++++++++------------- lib/geseml.c | 32 +++++++++++++++++++++++++++++--- lib/geseml.h | 3 +++ lib/unieml.c | 2 +- lib/unieml.h | 2 +- 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/app/sorter.c b/app/sorter.c index 4ff820c..e07bc6b 100644 --- a/app/sorter.c +++ b/app/sorter.c @@ -25,7 +25,7 @@ /* procedure to scan all files */ /* */ /********************************************************/ -static _Bool scantrans() +static _Bool scantrans(const char *ext,_Bool todo) { #define OPEP "sorter.c:scantrans," @@ -42,14 +42,15 @@ trans=(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 - fname=eml_getqfilelist(fname,EXTRANS); + fname=eml_getqfilelist(fname,ext); if (fname==(char **)0) phase=999; //Nothing to do break; case 1 : //Building the "trans" list - if (fname!=(char **)0) { //walways + if (fname!=(char **)0) { //always char **ptr; ptr=fname; @@ -68,14 +69,15 @@ while (proceed==true) { } break; case 2 : //scanning translit - if (trans!=(TRATYP **)0) { - TRATYP **ptr; - - ptr=trans; - (void) eml_todoqfile(ptr); - trans=(TRATYP **)rou_freelist((void **)trans,(genfree_t)eml_freetra); - status=true; + switch (todo) { + case true : //Doing todo file + status=eml_todoqfile(trans); + break; + case false : + status=eml_doneqfile(trans); + break; } + trans=(TRATYP **)rou_freelist((void **)trans,(genfree_t)eml_freetra); break; default : //SAFE Guard proceed=false; @@ -130,11 +132,15 @@ while (proceed==true) { if ((hangup==true)||(reload==true)) phase=999; //Process break; - case 3 : //Scanning all file - if (scantrans()==false) + case 3 : //Scanning all ".trans" file + if (scantrans(EXTRANS,true)==false) + phase=999; + break; + case 4 : //Scanning all ".done" file + if (scantrans(EXDONE,false)==false) phase=999; break; - case 4 : //one shot deal?? + case 5 : //one shot deal?? if (foreground==false) { (void) sleep(5); phase=1; //restarting diff --git a/lib/geseml.c b/lib/geseml.c index b603b19..2937da3 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -127,6 +127,7 @@ if (tra!=(TRATYP **)0) { (void) fprintf(qfile,"#'C', completed email task\n"); (void) fprintf(qfile,"#'D', delayed email\n"); (void) fprintf(qfile,"#'L', Local email\n"); + (void) fprintf(qfile,"#'O', Obsolete email\n"); (void) fprintf(qfile,"#'R', Remote email\n"); } while (*tra!=(TRATYP *)0) { @@ -255,9 +256,11 @@ REFTYP **domlist; done=false; domlist=(REFTYP **)0; -while (*list!=(TRATYP *)0) { - domlist=sortref(domlist,*list); - list++; +if (list!=(TRATYP **)0) { + while (*list!=(TRATYP *)0) { + domlist=sortref(domlist,*list); + list++; + } } if (domlist!=(REFTYP **)0) { int iter; @@ -295,6 +298,7 @@ if (domlist!=(REFTYP **)0) { break; case 3 : //file ready, renaming file, (void) eml_renameqfile(qname,EXTOBE,EXTODO); + done=true; break; default : //SAFE Guard proceed=false; @@ -309,7 +313,29 @@ if (domlist!=(REFTYP **)0) { (void) free(domlist); } return done; + #undef EXTOBE +#undef OPEP +} +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to clean/remove 'done' file. */ +/* */ +/********************************************************/ +PUBLIC _Bool eml_doneqfile(TRATYP **list) + +{ +#define OPEP "geseml.c:eml_doneqfile," + +_Bool check; + +check=true; +(void) rou_alert(0,"%s JMPDBG check done",OPEP); +return check; + #undef OPEP } /* diff --git a/lib/geseml.h b/lib/geseml.h index 59ca0c6..787e37f 100644 --- a/lib/geseml.h +++ b/lib/geseml.h @@ -33,6 +33,9 @@ extern TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile); //procedure to Generate todolist file within queue extern _Bool eml_todoqfile(TRATYP **list); +//procedure to clean/remove done file within queue +extern _Bool eml_doneqfile(TRATYP **list); + //procedure to store an email to the local email storage area extern _Bool eml_store_email(TRATYP *tra); diff --git a/lib/unieml.c b/lib/unieml.c index b9e2663..a3e1ba6 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -370,7 +370,7 @@ return qfile; /* Return a list or NULL if no file. */ /* */ /********************************************************/ -PUBLIC char **eml_getqfilelist(char **dnames,char *ext) +PUBLIC char **eml_getqfilelist(char **dnames,const char *ext) { #define OPEP "unieml.c:eml_getqfilelist" diff --git a/lib/unieml.h b/lib/unieml.h index 55b7ec8..f38c061 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -83,7 +83,7 @@ extern FILE *eml_closeqfile(FILE *qfile); //Procedure to list all file within queue directory //and with a specific extenstion -extern char **eml_getqfilelist(char **dnames,char *ext); +extern char **eml_getqfilelist(char **dnames,const char *ext); //procedure to open a specific qfile extern FILE *eml_openqfile(char *qfilename,const char *ext); -- 2.47.3