From: Jean-Marc Pigeon (Delson) Date: Tue, 13 May 2025 23:58:21 +0000 (-0400) Subject: Sorting transfer request seems to be working X-Git-Tag: tag-0.8~107 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=06f141fe08832e3a19f40de5f714f43efba0024f;p=jmp%2Fmailleur Sorting transfer request seems to be working --- diff --git a/app/sorter.c b/app/sorter.c index 03ff987..c5b6aad 100644 --- a/app/sorter.c +++ b/app/sorter.c @@ -61,6 +61,7 @@ while (proceed==true) { (void) rou_alert(0,"%s fame=<%s>",OPEP,*ptr); if ((qfile=eml_openqfile(*ptr))!=(FILE *)0) { trans=eml_scanqfile(trans,qfile); + (void) eml_closeqfile(qfile); } ptr++; } @@ -72,10 +73,7 @@ while (proceed==true) { TRATYP **ptr; ptr=trans; - while (*ptr!=(TRATYP *)0) { - (void) eml_dumptra(*ptr); - ptr++; - } + (void) eml_todoqfile(ptr); trans=(TRATYP **)rou_freelist((void **)trans,(freehandler_t)eml_freetra); status=true; } diff --git a/lib/geseml.c b/lib/geseml.c index 33fdc87..cd575fe 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -10,6 +10,94 @@ #include "subrou.h" #include "geseml.h" +typedef struct { + char *domain; //common domain + TRATYP **todo; //Transfer reference + }REFTYP; +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to display/debug TRATYP record content*/ +/* */ +/********************************************************/ +static REFTYP *findref(REFTYP **reflist,char *domain) + + +{ +REFTYP *found; + +found=(REFTYP *)0; +if (reflist!=(REFTYP **)0) { + while (*reflist!=(REFTYP *)0) { + if (strcmp((*reflist)->domain,domain)==0) { + found=*reflist; + break; + } + reflist++; + } + } +return found; +} +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to display/debug TRATYP record content*/ +/* */ +/********************************************************/ +static REFTYP **sortref(REFTYP **reflist,TRATYP *trans) + +{ +#define OPEP "geseml.c:sortref," + +char *dom; +REFTYP *ref; +int phase; +_Bool proceed; + +dom=(char *)0; +ref=(REFTYP *)0; +phase=0; +proceed=true; +while (proceed==true) { + switch (phase) { + case 0 : //Firsy Check if we have data + if (trans==(TRATYP *)0) { + (void) rou_alert(0,"%s trans is NULL (Bug?)",OPEP); + phase=999; //No need to gi further + } + break; + case 1 : //Do we hav a domain + if ((dom=strchr(trans->rcptto,'@'))==(char *)0) { + (void) rou_alert(0,"%s unable to find domain within <%s> (Bug?)", + OPEP,trans->rcptto); + phase=999; //No dmain + } + break; + case 2 : //do we know domain + if ((ref=findref(reflist,dom))!=(REFTYP *)0) + phase++; //we have reference already + break; + case 3 : //Adding reference + ref=(REFTYP *)calloc(1,sizeof(REFTYP)); + ref->domain=dom; + reflist=(REFTYP **)rou_addlist((void **)reflist,(void *)ref); + break; + case 4 : //Adding transaction within reference + ref->todo=(TRATYP **)rou_addlist((void **)ref->todo,(void *)trans); + break; + default : //SAFE Guard + proceed=false; + break; + } + phase++; + } +return reflist; +#undef OPEP +} /* */ @@ -118,5 +206,51 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) { } } return list; -#undef OEP +#undef OPEP +} +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to generate a list of todo file to */ +/* sender MTA. */ +/* */ +/********************************************************/ +PUBLIC _Bool eml_todoqfile(TRATYP **list) + +{ +#define OPEP "geseml.c:eml_todoqfile," + +_Bool done; +REFTYP **domlist; + +done=false; +domlist=(REFTYP **)0; +while (*list!=(TRATYP *)0) { + domlist=sortref(domlist,*list); + list++; + } +if (domlist!=(REFTYP **)0) { + REFTYP **ptr; + + ptr=domlist; + while (*ptr!=(REFTYP *)0) { + (void) rou_alert(0,"%s JMPDBG refdomain=<%s>",OPEP,(*ptr)->domain); + if ((*ptr)->todo!=(TRATYP **)0) { + TRATYP **todo; + + todo=(*ptr)->todo; + while (*todo!=(TRATYP *)0) { + (void) eml_dumptra(*todo); + todo++; + } + } + (void) free(*ptr); + ptr++; + } + (void) free(domlist); + } +return done; +#undef OPEP } diff --git a/lib/geseml.h b/lib/geseml.h index 6c172f5..b242e2e 100644 --- a/lib/geseml.h +++ b/lib/geseml.h @@ -30,4 +30,7 @@ extern TRATYP *eml_freetra(TRATYP *tra); //procedure to open a specific qfile extern TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile); +//procedure to Generate todolist file within queue +extern _Bool eml_todoqfile(TRATYP **list); + #endif