EXTIP = safemail3.safe.ca
EXTPORT = 25
TESTITER= 4
+#--------------------------------------------------------------------
+#To test sorter
+sorter : clean debug
+ @ bin/sorter \
+ -d 2 \
+ -c ./conf/feeder.conf.dvl \
+ -r $(TESTDIR)
+
#--------------------------------------------------------------------
#testing feed
FEEDPAR = \
-c ./conf/feeder.conf.dvl \
$(EXTIP) \
$(EXTPORT) \
- $(DATATST)/extfeed00.tst
+ ./$(DATATST)/extfeed00.tst
onefeed : debug
bin/feeder \
-c ./conf/feeder.conf.dvl \
$(TESTIP) \
$(TESTPORT) \
- $(DATATST)/xxfeed.tst
+ ./$(DATATST)/xxfeed.tst
# # -i 127.63.31.15
-c ./conf/feeder.conf.dvl \
$(TESTIP) \
$(TESTPORT) \
- $(DATATST)/xxfeed.tst
+ $./(DATATST)/xxfeed.tst
valfeed : debug #valgring of emlrcvr
@ echo "feed valgrind test"
-c ./conf/feeder.conf.dvl \
$(TESTIP) \
$(TESTPORT) \
- $(DATATST)/feed00.tst
+ ./$(DATATST)/xxfeed.tst
# --track-fds=yes \
bin \
$(TESTDIR)/$(SBINDIR)
@ cp -a \
- $(DATATST) \
- $(TESTDIR)
+ data-queue/* \
+ $(TESTDIR)/var/spool/$(APPNAME)/queue
deltest :
@ rm -fr $(TESTDIR)
/* feeder ip port [file1 file2...] */
/* */
/********************************************************/
+#include <dirent.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
#include "subrou.h"
-#include "unisig.h"
+#include "unieml.h"
#include "unipar.h"
+#include "unisig.h"
#define SORTER "sorter" //application name
+//structure to build a email directive
+typedef struct {
+ char code; //Transaction code
+ u_long date; //Transaction date
+ u_int delay; //Transaction execution delay
+ char *sessid; //session id
+ char *mailfrom; //EMail Originator
+ char *recptto; //EMail Recipient
+ }TRATYP;
+
/********************************************************/
/* */
/* procedure to scan all files */
{
_Bool status;
+char **list;
status=false;
-(void) sleep(2);
+list=(char **)0;
(void) rou_alert(0,"JMPDBG sorter");
-(void) sleep(5);
+if ((list=eml_getqfilelist(".trans"))!=(char **)0) {
+ list=(char **)rou_freelist((void *)list,(freehandler_t)rou_freestr);
+ }
status=true;
+(void) sleep(5);
return status;
}
/*
(void) rou_modesubrou(true);
(void) sig_modeunisig(true);
(void) rou_setappname(SORTER);
- (void) rou_loadconfig(config,true);
+ (void) rou_loadconfig(config,true);
(void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON);
(void) closelog();
break;
case 2 : //Scanning all file
+ phase--; //Looping on same phase
if ((hangup==true)||(reload==true))
phase=999; //Process
if (scantrans()==false)
/* exchange. */
/* */
/********************************************************/
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
*/
/********************************************************/
/* */
+/* Procedure to list all file with a specific */
+/* extension with the queue directory. */
+/* Return a list or NULL if no file. */
+/* */
+/********************************************************/
+PUBLIC char **eml_getqfilelist(char *ext)
+
+{
+#define OPEP "unieml.c:eml_getqfilelist"
+
+char **dirlst;
+DIR *dir;
+int phase;
+_Bool proceed;
+
+dirlst=(char **)0;
+dir=(DIR *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
+ switch (phase) {
+ case 0 : //lets open the queue directory
+ char *dirname;
+
+ dirname=rou_apppath(QDIR);
+ if ((dir=opendir(dirname))==(DIR *)0) {
+ (void) rou_alert(0,"%s Unable to open director <%s> (error=<%s>, config?)",
+ OPEP,dirname,strerror(errno));
+ phase=999; //No need to go further
+ }
+ dirname=rou_freestr(dirname);
+ break;
+ case 1 : //scanning directory contents
+ struct dirent *data;
+ register int taille;
+
+ taille=0;
+ if (ext!=(char *)0)
+ taille=strlen(ext);
+ while ((data=readdir(dir))!=(struct dirent *)0) {
+ register char *ptr;
+
+ ptr=data->d_name;
+ if (taille>0) {
+ ptr=strstr(data->d_name,ext);
+ if ((ptr!=(char *)0)&&(strlen(ptr)!=taille))
+ ptr=(char *)0;
+ }
+ if (ptr!=(char *)0) {
+ (void) rou_alert(0,"%s JMPDBG got <%s>",OPEP,data->d_name);
+ dirlst=(char **)rou_addlist((void **)dirlst,(void *)strdup(data->d_name));
+ }
+ }
+ break;
+ case 2 : //closing directory
+ if (closedir(dir)<0) {
+ (void) rou_alert(0,"%s Unable to close queue directory (error=<%s>, bug?)",
+ OPEP,strerror(errno));
+ }
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return dirlst;
+#undef OPEP
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
/* Procedure to store an email to a list of email */
/* retune true if successful, false otherwise. */
/* */
//procedure to close a file within the queue directory
extern int eml_closeqfile(FILE *qfile);
+//Procedure to list all file within queue directory
+//and with a specific extenstion
+extern char **eml_getqfilelist(char *ext);
+
+//procedure to open a specific qfile
+extern FILE *eml_openqfile(char *qfilename);
+
//procedure to add an email address to a chain
//of email address
extern _Bool eml_addemail(char ***emails,char *email);