From: Jean-Marc Pigeon (Delson) Date: Fri, 13 Jun 2025 19:21:51 +0000 (-0400) Subject: Attachement is almost fully working X-Git-Tag: tag-0.8~4 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=930652b601204ae21852323448be7d9000d98e4b;p=jmp%2Fmailleur Attachement is almost fully working --- diff --git a/lib/geseml.c b/lib/geseml.c index 02829f1..2ce1289 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -509,7 +509,6 @@ if (list!=(TRATYP **)0) { char fname[200]; (void) rou_alert(0,"%s JMPDBG need to remove <%s>",OPEP,(*ptr)->sessid); - (void) eml_deleteqfile((*ptr)->sessid); (void) snprintf(fname,sizeof(fname),"%s.%s",(*ptr)->sessid,EXTCNT); (void) eml_deleteqfile(fname); } @@ -770,16 +769,76 @@ PUBLIC _Bool eml_do_warning(TRATYP *tra) #define OPEP "geseml.c:eml_do_warning," _Bool done; +char *sessata; //attachement session number +FILE *qout; +char orig[100]; +char cmt[200]; int phase; _Bool proceed; done=false; +sessata=eml_getmainsesid(); +(void) snprintf(orig,sizeof(orig),"%s@%s","noreply",getenv("DFLTDOMAIN")); +qout=(FILE *)0; phase=0; proceed=true; while (proceed==true) { //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase); switch (phase) { - case 0 : //check if email is FROM local or remote + case 0 : //create the new attachement file + if ((qout=eml_createqfile(sessata,(char *)0))==(FILE *)0) { + (void) rou_alert(0,"%s Unable to create attachement file (system?)", + OPEP); + phase=999; + } + break; + case 1 : //Preparing attachement email + (void) fprintf(qout,"From: %s Email daemon <%s>\n",APPNAME,orig); + (void) fprintf(qout,"To: <%s>\n",tra->mailfrom); + (void) fprintf(qout,"Date: %s\n",rou_ascsysstamp(time((time_t *)0))); + (void) fprintf(qout,"Subject: %s\n",*(tra->resp)+4); + (void) fprintf(qout,"\n"); + (void) fprintf(qout,"Bigre\n"); + (void) fprintf(qout,"Bigre\n"); + break; + case 2 : //attaching email itself + done=eml_attache(qout,tra->sessid); + qout=eml_closeqfile(qout); + if (done==false) { + (void) rou_alert(0,"%s Unable to create attachement session (system?)", + OPEP); + phase=999; + } + break; + case 3 : //creating a count file for attachement file + if ((qout=eml_createqfile(sessata,EXTCNT))==(FILE *)0) { + (void) rou_alert(0,"%s Unable to open 'count' qfile <%s> (error=<%s>)", + OPEP,sessata,strerror(errno)); + (void) eml_deleteqfile(sessata); + done=false; + phase=999; + } + break; + case 4 : //set number winthin sessata count file + (void) fprintf(qout,"1\n"); + (void) eml_closeqfile(qout); + break; + case 5 : //counting original session + switch (eml_countqfile(tra->sessid,-1)) { + case -1 : + (void) rou_alert(0,"%s Unable to count down sessid <%s>", + OPEP,tra->sessid); + phase=999; + break; + case 0 : //session file is not needed anymore + (void) snprintf(cmt,sizeof(cmt),"%s.%s",tra->sessid,EXTCNT); + (void) eml_deleteqfile(cmt); + break; + default : //Nothing to do + break; + } + break; + case 6 : //check if email is FROM local or remote char *domain; int status; @@ -804,17 +863,16 @@ while (proceed==true) { break; } break; - case 1 : //reversing originator/recipient - char orig[100]; - - (void) snprintf(orig,sizeof(orig),"%s@%s","noreply",getenv("DFLTDOMAIN")); + case 7 : //reversing originator/recipient + tra->delay=0; + tra->sessid=rou_freestr(tra->sessid); + tra->sessid=strdup(sessata); tra->rcptto=rou_freestr(tra->rcptto); tra->rcptto=tra->mailfrom; tra->mailfrom=strdup(orig); - tra->delay=0; done=true; break; - case 2 : //building the new sessid file + case 8 : //building the new sessid file tra->resp=(char **)rou_freelist((void **)tra->resp,(genfree_t)rou_freestr); break; default : //SAFE Guard @@ -823,6 +881,7 @@ while (proceed==true) { } phase++; } +sessata=rou_freestr(sessata); return done; #undef OPEP diff --git a/lib/unieml.c b/lib/unieml.c index 93a03b0..16df7ef 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -698,6 +698,10 @@ while (proceed==true) { } (void) fclose(fcount); break; + case 5 : //removing file count if result is zero + if (result==0) + (void) eml_deleteqfile(qfilename); + break; default : //SAFE Guard proceed=false; break; @@ -807,3 +811,20 @@ while (proceed==true) { return info; #undef OPEP } +/* +^L +*/ +/********************************************************/ +/* */ +/* Procedure to attach a part of text to a file */ +/* acceptable. */ +/* */ +/********************************************************/ +PUBLIC int eml_attache(FILE *fout,char *toaddfile) + +{ +int success; + +success=true; +return success; +} diff --git a/lib/unieml.h b/lib/unieml.h index 2fe17f3..3a3c464 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -112,4 +112,7 @@ extern int eml_countqfile(char *qfilename,int count); //of an email address extern RCPTYP *eml_isemailok(char *email,char **report); +//procedure to create an attachement for email data part. +extern int eml_attache(FILE *fout,char *toaddfile); + #endif