TESTITER= 4
#--------------------------------------------------------------------
#To test sorter
-sorter : clean debug
- @ bin/sorter \
+sorter : clean debug
+ @ bin/sorter \
+ -f \
-d 2 \
-c ./conf/mailleur.conf.dvl \
-r $(TESTDIR)
+ @ cp -a \
+ $(TESTDIR)/var/spool/$(APPNAME)/queue/* \
+ ./data-queue/
+
#--------------------------------------------------------------------
#To test sender
sender : clean debug newtest
- @ bin/$@ \
+ @ cp -a \
+ ./data-queue/* \
+ $(TESTDIR)/var/spool/$(APPNAME)/queue
+ @ ./bin/$@ \
-d 2 \
-c ./conf/mailleur.conf.dvl \
-r $(TESTDIR) \
- example.com-1747698127-0000.todo
+ `basename -a data-queue/*.todo | \
+ tr '\\n' ' ' `
dbgsend : clean debug
@ gdb \
# # -i 127.63.31.15
#direct test
-tstfeed : debug
+tstfeed : debug newtest
+ @ rm -fr ./data-queue/*
+ @ rm -fr $(TESTDIR)/var/spool/$(APPNAME)/queue/*
@ bin/feeder \
-c ./conf/feeder.conf.dvl \
$(FEEDPAR)
+ @ cp -a \
+ $(TESTDIR)/var/spool/$(APPNAME)/queue/* \
+ ./data-queue
+
#using gdb
dbgfeed : debug
@ cp -a \
bin \
$(TESTDIR)/$(SBINDIR)
- @ cp -a \
- data-queue/* \
- $(TESTDIR)/var/spool/$(APPNAME)/queue
deltest :
@ rm -fr $(TESTDIR)
}
}
break;
- case 5 : //job completed
+ case 5 : //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
+ status=true;
+ break;
default : //SAFE Guard
if (qfile!=(FILE *)0)
(void) eml_closeqfile(qfile);
char *ptr;
fname=params->argv[num];
+ (void) rou_alert(0,"%s fname file <%s>",appname,fname);
if ((hangup==true)||(reload==true))
break;
if ((ptr=strrchr(fname,'.'))==(char *)0) {
SENDER,fname,ptr);
break;
}
+ (void) rou_alert(0,"%s scanning file <%s>",appname,fname);
if (scantodo(fname)==false)
break;
num++;
(void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON);
(void) closelog();
break;
- case 2 : //Scanning all file
- phase--; //Looping on same phase
+ case 2 : //check about signal
if ((hangup==true)||(reload==true))
phase=999; //Process
+ break;
+ case 3 : //Scanning all file
if (scantrans()==false)
phase=999;
- (void) sleep(5);
+ break;
+ case 4 : //one shot deal??
+ if (foreground==false) {
+ (void) sleep(5);
+ phase=1; //restarting
+ }
break;
default : //end of task
params=par_freeparams(params);
--- /dev/null
+webmaster@example.com:{plain}BigreA3::::
/* Log management implementation module */
/* */
/********************************************************/
+#include <sys/file.h>
#include <errno.h>
#include <malloc.h>
#include <stdbool.h>
proceed=false; //trouble trouble
}
break;
- case 1 : //locking access to event file
- if (prc_locking(EVENT,true,5)==false) {
- (void) rou_alert(0,"%s Unable to log event (Timing!?)",OPEP);
- proceed=false; //trouble trouble
- }
- break;
- case 2 : //duplicat logname
+ case 1 : //duplicat logname
(void) strncpy(daily,logname,sizeof(daily)-strlen(daily));
if (strlen(daily)>0) {
char *ptr;
}
(void) rou_asprintf(&event,"%s/event-%s.jrl",daily,asctemps);
break;
- case 3 : //opening log file
+ case 2 : //opening log file
if ((flog=fopen(logname,"r"))==(FILE *)0) {
(void) rou_alert(0,"%s Unable to open log file <%s> (error=<%s>)",
OPEP,logname,strerror(errno));
phase=999; //no need to go further
}
break;
- case 4 : //opening log file
+ case 3 : //opening log file
if ((fevent=fopen(event,"a+"))==(FILE *)0) {
(void) rou_alert(0,"%s Unable to open event file <%s> (error=<%s>)",
OPEP,event,strerror(errno));
phase=999; //no need to go further
}
break;
+ case 4 : //locking access to logname
+ if (flock(fileno(fevent),LOCK_EX)<0) {
+ (void) rou_alert(0,"%s Unable to lock acces to log file <%s> "
+ "(error=<%s>) (Bug?)",
+ OPEP,event,strerror(errno));
+ (void) fclose(fevent);
+ (void) fclose(flog);
+ phase=999; //no need to go further
+ }
+ break;
case 5 : //merging file
if (fevent!=(FILE *)0) { //always
char ch;
while ((ch=fgetc(flog))!=EOF)
fputc(ch,fevent);
}
+ (void) flock(fileno(fevent),LOCK_UN);
(void) fclose(fevent);
(void) fclose(flog);
break;
}
break;
default : //SAFE guard
- (void) prc_locking(EVENT,false,1);
event=rou_freestr(event);
proceed=false;
break;
char *path;
path=rou_apppath(getenv(DIRDOV));
- (void) snprintf(dirname,sizeof(dirname),"%s/%s/%s/",path,locdom,tra->rcptto);
+ (void) snprintf(dirname,sizeof(dirname),"%s/%s/%s",path,locdom,tra->rcptto);
*(strrchr(dirname,'@'))='\000'; //keeping username only
+ (void) strncat(dirname,"/new",sizeof(dirname)-strlen(dirname));
if ((dir=opendir(dirname))==(DIR *)0) {
int status;
char cmd[400];
/* exchange. */
/* */
/********************************************************/
+#include <sys/file.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
}
}
break;
- case 3 : //duplicating file
+ case 3 : //lock the fout file
+ if (flock(fileno(fout),LOCK_EX)<0) {
+ (void) rou_alert(0,"%s unable to lock destination file <%s> "
+ "(error=<%s> (Bug?))",
+ OPEP,qfilename,strerror(errno));
+ (void) fclose(fout);
+ (void) fclose(fin);
+ phase=999; //Big trouble
+ }
+ break;
+ case 4 : //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));
+ (void) rou_alert(0,"%s unable to fully write destination file "
+ "<%s> (error=<%s>)",
+ OPEP,qfilename,strerror(errno));
phase=999;
}
}
+ (void) flock(fileno(fout),LOCK_UN);
(void) fclose(fout);
(void) fclose(fin);
}
break;
- case 4 : //duplication is a success
+ case 5 : //duplication is a success
status=true;
break;
default : //SAFE Guard