static _Bool dispatcher(TRATYP **tra)
{
+#define OPEP "sorter.c:dispatcher,"
_Bool status;
status=false;
TRATYP **ptr;
ptr=tra;
+ status=true;
while (*ptr!=(TRATYP *)0) {
- (void) eml_dumptra((FILE *)0,*ptr);
+ switch ((*ptr)->code) {
+ case 'L' : //local delivery
+ (*ptr)->code='D'; //delivery done
+ break;
+ default :
+ (void) eml_dumptra((FILE *)0,*ptr);
+ (void) rou_alert(0,"%s unexpected code '%c'",OPEP,(*ptr)->code);
+ status=false;
+ break;
+ }
ptr++;
}
}
return status;
+#undef OPEP
}
/*
\f
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
if (eml_renameqfile(fname,EXTODO,EXDOING)==false) {
break;
case 2 : //reading the todo file
tra=eml_scanqfile(tra,qfile);
- (void) eml_closeqfile(qfile);
- if (tra!=(TRATYP **)0) { //No record found
+ if (tra==(TRATYP **)0) { //No record found
(void) rou_alert(0,"%s No transport directive within <%s.%s> (Bug?)",
OPEP,fname,EXDOING);
phase=999;
break;
case 3 : //dispatching email
if (dispatcher(tra)==false) { //trouble backtracking file
- (void)eml_renameqfile(fname,EXDONE,EXTODO);
+ (void)eml_renameqfile(fname,EXDOING,EXTODO);
phase=999; //No need to go further
}
break;
- case 4 : //job completed
+ case 4 : //updating transfile
+ if (tra!=(TRATYP **)0) { //record to update
+ TRATYP **ptr;
+
+ ptr=tra;
+ (void) rewind(qfile);
+ while (*ptr!=(TRATYP *)0) {
+ (void) eml_dumptra(qfile,*ptr);
+ ptr++;
+ }
+ }
+ break;
+ case 5 : //job completed
if (eml_renameqfile(fname,EXDOING,EXDONE)==false) {
(void) rou_alert(0,"%s Unable to rename file <%s.%s>",OPEP,fname,EXDONE);
phase=999; //No need to go further
}
break;
default : //SAFE Guard
+ if (qfile!=(FILE *)0)
+ (void) eml_closeqfile(qfile);
proceed=false;
break;
}
(void) strcat(fullname,".");
(void) strcat(fullname,ext);
}
-if ((qfile=fopen(fullname,"r"))==(FILE *)0) {
+if ((qfile=fopen(fullname,"r+"))==(FILE *)0) {
(void) rou_alert(0,"%s Unable to open file <%s> (error-<%s> bug?)",
OPEP,fullname,strerror(errno));
}