while (fgets(line,sizeof(line),fd->datatst)!=(char *)0) {
char *ptr;
- (void) rou_alert(0,"%s num='%02d' <%s>","sender",numline,line);
+ (void) rou_alert(5,"%s num='%02d' <%s>","feeder",numline,line);
while ((ptr=strrchr(line,'\n'))!=(char *)0)
*ptr='\000';
if ((fd->commented==true)&&(strncmp(line,"C:",2)!=0)) {
while (*ptr!=(TRATYP *)0) {
switch ((*ptr)->code) {
case 'L' : //local delivery
- (*ptr)->code='C'; //delivery done
+ (*ptr)->code='C'; //delivery done 'C'ompleted
if (eml_store_email(*ptr)==false) {
- (*ptr)->code='D'; //delivery done
+ (*ptr)->code='D'; //delivery done 'D'elayed
(void) rou_alert(0,"%s Unable to deliver email <%s> to <%s>",
OPEP,(*ptr)->sessid,(*ptr)->rcptto);
}
break;
+ case 'R' : //remote delivery
+ (*ptr)->code='C'; //delivery completed Temporary JMPDBG
+ break;
default :
- (void) eml_dumptra((FILE *)0,*ptr);
(void) rou_alert(0,"%s unexpected code '%c'",OPEP,(*ptr)->code);
status=false;
break;
}
ptr++;
}
+ (void) eml_dumptra((FILE *)0,tra);
}
return status;
#undef OPEP
}
break;
case 4 : //updating transfile
- if (tra!=(TRATYP **)0) { //record to update
- TRATYP **ptr;
+ (void) eml_dumptra(qfile,tra);
+ break;
- ptr=tra;
- (void) rewind(qfile);
- while (*ptr!=(TRATYP *)0) {
- (void) eml_dumptra(qfile,*ptr);
- ptr++;
- }
- }
+ case 5 : //closing file
+ qfile=eml_closeqfile(qfile);
break;
- case 5 : //job completed renameing file
+ case 6 : //job completed renameing file
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;
- case 6 : //job fully compltedt, good
+ case 7 : //job fully compltedt, good
status=true;
break;
default : //SAFE Guard
- if (qfile!=(FILE *)0)
- (void) eml_closeqfile(qfile);
+ qfile=eml_closeqfile(qfile);
proceed=false;
break;
}
/* Procedure to display/debug TRATYP record content*/
/* */
/********************************************************/
-PUBLIC void eml_dumptra(FILE *out,TRATYP *tra)
+PUBLIC void eml_dumptra(FILE *qfile,TRATYP **tra)
{
-char line[300];
+if (tra!=(TRATYP **)0) {
+ if (qfile!=(FILE *)0) {
+ (void) fprintf(qfile,"#'C', completed email task\n");
+ (void) fprintf(qfile,"#'D', delayed email\n");
+ (void) fprintf(qfile,"#'L', Local email\n");
+ (void) fprintf(qfile,"#'R', Remote email\n");
+ }
+ while (*tra!=(TRATYP *)0) {
+ char line[300];
-(void) strcpy(line,"Empty");
-if (tra!=(TRATYP *)0) {
- (void) snprintf(line,sizeof(line),"%c %lu %u %s %s %s",
- tra->code,
- tra->date,
- tra->delay,
- tra->sessid,
- tra->mailfrom,
- tra->rcptto
- );
+ (void) snprintf(line,sizeof(line),"%c %lu %u %s %s %s",
+ (*tra)->code,
+ (*tra)->date,
+ (*tra)->delay,
+ (*tra)->sessid,
+ (*tra)->mailfrom,
+ (*tra)->rcptto
+ );
+ if (qfile==(FILE *)0)
+ (void) rou_alert(0,"TRA=<%s>",line);
+ else
+ (void) fprintf(qfile,"%s\n",line);
+ tra++;
+ }
}
-if (out==(FILE *)0)
- (void) rou_alert(0,"TRA=<%s>",line);
-else
- (void) fprintf(out,"%s\n",line);
}
/*
\f
if ((qfile=eml_createqfile(qname,EXTOBE))==(FILE *)0)
phase=999; //Trouble trouble
break;
- case 1 : //Opening qfile
- if ((*ptr)->todo!=(TRATYP **)0) {
- TRATYP **todo;
-
- todo=(*ptr)->todo;
- while (*todo!=(TRATYP *)0) {
- (void) eml_dumptra(qfile,*todo);
- todo++;
- }
- }
+ case 1 : //dumping TRANS data to file
+ (void) eml_dumptra(qfile,(*ptr)->todo);
break;
case 2 : //Closing file
(void) eml_closeqfile(qfile);
if ((tra!=(TRATYP *)0)&&(tra->rcptto!=(char *)0)&&(strlen(tra->rcptto)>0))
locdom=strrchr(tra->rcptto,'@');
if (locdom==(char *)0) {
- (void) rou_alert(0,"%s Unable to extract recipient domain! (Bug?)",OPEP);
- (void) eml_dumptra((FILE *)0,tra);
+ (void) rou_alert(0,"%s Unable to get recipient domain in <%s> (Bug?)",
+ OPEP,tra->rcptto);
phase=999; //Big trouble
}
else
//structure to define an email transport directive
typedef struct {
char code; //Transaction code
- u_long date; //Transaction date
+ time_t date; //Transaction date
u_int delay; //Transaction execution delay
char *sessid; //session id
char *mailfrom; //EMail Originator
}TRATYP;
//procedure to dump a transfert record (debug purpose)
-extern void eml_dumptra(FILE *out,TRATYP *tra);
+extern void eml_dumptra(FILE *out,TRATYP **tra);
//procedure to fee memory used by a TRATYP structure
extern TRATYP *eml_freetra(TRATYP *tra);
#include "unidns.h"
#include "unieml.h"
#include "devlog.h"
+#include "geseml.h"
#include "lvleml.h"
/*
if ((queue=eml_createqfile(contact->cursesid,""))==(FILE *)0)
phase=999; //trouble trouble
break;
- case 1 : //sending go ahed to remote
+ case 1 : //sending go ahaed to remote
if (addreceived(contact,queue)==false)
phase=999; //trouble trouble
break;
status=true;
if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) {
RCPTYP **ptr;
+ TRATYP **tralist;
time_t isnow;
ptr=contact->recipients;
+ tralist=(TRATYP **)0;
isnow=time((time_t *)0);
while (*ptr!=(RCPTYP *)0) {
+ TRATYP *tra;
char data[300];
- (void) snprintf(data,sizeof(data),"%c %ld %d %s %s %s@%s",
- (*ptr)->code,
- isnow,
- 0,
- contact->cursesid,
- contact->mailfrom,
- (*ptr)->userid,
- (*ptr)->domain);
- if (fprintf(qfile,"%s\n",data)<0) {
- (void) rou_alert(0,"%s Unable to write transfile (error=<%s>)",
- OPEP,strerror(errno));
- status=false;
- }
+
+ (void) snprintf(data,sizeof(data),"%s@%s",(*ptr)->userid,(*ptr)->domain);
+ tra=(TRATYP *)calloc(1,sizeof(TRATYP));
+ tra->code=(*ptr)->code;
+ tra->date=isnow;
+ tra->delay=0;
+ tra->sessid=strdup(contact->cursesid);
+ tra->mailfrom=strdup(contact->mailfrom);
+ tra->rcptto=strdup(data);
+ tralist=(TRATYP **)rou_addlist((void **)tralist,(void *)tra);
ptr++;
}
+ (void) eml_dumptra(qfile,tralist);
+ tralist=(TRATYP **)rou_freelist((void **)tralist,(genfree_t)eml_freetra);
}
return status;
#undef OPEP
/* stored within queue. */
/* */
/********************************************************/
-PUBLIC int eml_closeqfile(FILE *qfile)
+PUBLIC FILE *eml_closeqfile(FILE *qfile)
{
#define OPEP "unieml.c:eml_closeqfile,"
-int status;
-if ((status=fclose(qfile))<0) {
- (void) rou_alert(0,"%s Unable to close qfile (error=<%s>)",
- OPEP,strerror(errno));
+if (qfile!=(FILE *)0) {
+ if (fclose(qfile)<0) {
+ (void) rou_alert(0,"%s Unable to close qfile (error=<%s>)",
+ OPEP,strerror(errno));
+ }
+ else
+ qfile=(FILE *)0;
}
-return status;
+return qfile;
#undef OPEP
}
/*
extern FILE *eml_createqfile(char *qfilename,const char *ext);
//procedure to close a file within the queue directory
-extern int eml_closeqfile(FILE *qfile);
+extern FILE *eml_closeqfile(FILE *qfile);
//Procedure to list all file within queue directory
//and with a specific extenstion