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);
}
#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;
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
}
phase++;
}
+sessata=rou_freestr(sessata);
return done;
#undef OPEP