From 3552a07e73d4e21c66c322409e451b43645852f9 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Mon, 19 May 2025 19:37:00 -0400 Subject: [PATCH] Able to store local email --- lib/unieml.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/lib/unieml.c b/lib/unieml.c index 40ab120..7d9fc56 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -505,10 +505,83 @@ return status; PUBLIC _Bool eml_dupqfile(char *qfilename,const char *dest) { +#define OPEP "unieml.c:eml_dupqfile," _Bool status; +char *filename; +FILE *fin; +FILE *fout; +int phase; +_Bool proceed; status=false; +filename=rou_apppath(QDIR); +fin=(FILE *)0; +fout=(FILE *)0; +phase=0; +proceed=true; +while (proceed==true) { + //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase); + switch (phase) { + case 0 : //lets open the queue directory + if ((qfilename==(char *)0)||(dest==(char *)0)) { + (void) rou_alert(0,"%s filename=<%s> or dest=<%s> missing (Bug?)", + OPEP,qfilename,dest); + phase=999; //Big trouble + } + break; + case 1 : //opening origin file + if (qfilename!=(char *)0) { //always + char name[300]; + + (void) snprintf(name,sizeof(name),"%s/%s",filename,qfilename); + if ((fin=fopen(name,"r"))==(FILE *)0) { + (void) rou_alert(0,"%s unable to open source <%s> (error=<%s>)", + OPEP,name,strerror(errno)); + phase=999; //Big trouble + } + } + break; + case 2 : //opening destination file + if (fin!=(FILE *)0) { //always + char name[300]; + + (void) snprintf(name,sizeof(name),"%s/%s",dest,qfilename); + if ((fout=fopen(name,"w"))==(FILE *)0) { + (void) rou_alert(0,"%s unable to open destination <%s> (error=<%s>)", + OPEP,name,strerror(errno)); + (void) fclose(fin); + phase=999; //Big trouble + } + } + break; + case 3 : //duplicating file + if (fout!=(FILE *)0) { + int count; + char buffer[2048]; + + while ((count=fread(buffer,sizeof(char),sizeof(buffer),fin))>0) { + if (fwrite(buffer,sizeof(char),count,fout)!=count) { + (void) rou_alert(0,"%s unable to fully write destination (error=<%s>)", + OPEP,strerror(errno)); + phase=999; + } + } + (void) fclose(fout); + (void) fclose(fin); + } + break; + case 4 : //duplication is a success + status=true; + break; + default : //SAFE Guard + proceed=false; + break; + } + phase++; + } +filename=rou_freestr(filename); return status; +#undef OPEP } /* ^L -- 2.47.3