EXTPORT = 25
TESTITER= 1
-EMLPAR = \
+DBGPAR = \
-r $(TESTDIR) \
-c ./conf/$(APPNAME).conf.dvl \
-d 2 \
+
+EMLPAR = \
+ $(DBGPAR) \
"$(TESTPROT)|$(TESTIP)|$(TESTPORT)|"
#====================================================================
#procedure to start all needed components to have
#a full complete test
-restart : killall dosortr dorcvr
+restart : killall dosortr dorcvr doscarmt
@ echo "Restart completed"
actions : debug newtest restart
bin/receiver \
$(EMLPAR)$(TESTITER)
-#to kill all remaining emlrcvr process
+doscarmt:
+ @ echo "Starting scanner"
+ @ \
+ bin/scarmt \
+ $(DBGPAR)
+
+#to kill all remaining mailleur process
killall :
- kill -TERM receiver
- kill -TERM sender
- kill -TERM sorter
+ - kill -TERM scarmt
#--------------------------------------------------------------------
#procedure to call debugger for each main component
#--------------------------------------------------------------------
#Equivalences
#--------------------------------------------------------------------
-EXE = \
- chkspf \
- feeder \
- receiver \
- sender \
- sorter \
-
-SRC = \
- chkspf.c \
- receiver.c \
- feeder.c \
- scanner.c \
- sender.c \
- sorter.c \
+EXE = \
+ chkspf \
+ feeder \
+ receiver \
+ scarmt \
+ sender \
+ sorter \
+
+SRC = \
+ chkspf.c \
+ feeder.c \
+ receiver.c \
+ scarmt.c \
+ sender.c \
+ sorter.c \
+
+OBJS = \
+ chkspf.o \
+ feeder.o \
+ receiver.o \
+ scarmt.o \
+ sorter.o \
+ sender.o \
#--------------------------------------------------------------------
#definitions
CFLAGS = -I ../lib -Wall $(OPTIME)
LIBMAIL = ../lib/libmail.a
-LIBS = $(LIBMAIL) \
- -luuid \
- -lcrypto \
- -lcrypt \
- -lssl \
+LIBS = $(LIBMAIL) \
+ -luuid \
+ -lcrypto \
+ -lcrypt \
+ -lssl \
#--------------------------------------------------------------------
#Dependances
#--------------------------------------------------------------------
-chkspf : toremake chkspf.o
+chkspf \
+feeder \
+ : toremake $(OBJS)
@ $(LD) $(LDFLAGS) -o ../bin-posql/$@ $@.o $(LIBS)
@ $(LD) $(LDFLAGS) -o ../bin-mysql/$@ $@.o $(LIBS)
-feeder : toremake feeder.o
- @ $(LD) $(LDFLAGS) -o ../bin-posql/$@ $@.o $(LIBS)
- @ $(LD) $(LDFLAGS) -o ../bin-mysql/$@ $@.o $(LIBS)
-
-receiver: toremake receiver.o
+receiver \
+scarmt \
+sender \
+sorter \
+ : toremake $(OBJS)
@ $(LD) $(LDFLAGS) \
- -o ../bin-posql/receiver receiver.o \
+ -o ../bin-posql/$@ $@.o \
$(LIBS) \
../lib/libpos.a \
-lpq
@ $(LD) $(LDFLAGS) \
- -o ../bin-mysql/receiver receiver.o \
+ -o ../bin-mysql/$@ $@.o \
$(LIBS) \
../lib/libmar.a \
-lmysqlclient
-sender: toremake sender.o
- @ $(LD) $(LDFLAGS) \
- -o ../bin-posql/sender sender.o \
- $(LIBS) \
- ../lib/libpos.a \
- -lpq
- @ $(LD) $(LDFLAGS) \
- -o ../bin-mysql/sender sender.o \
- $(LIBS) \
- ../lib/libmar.a \
- -lmysqlclient
-sorter: toremake sorter.o
- @ $(LD) $(LDFLAGS) \
- -o ../bin-posql/sorter sorter.o \
- $(LIBS) \
- ../lib/libpos.a \
- -lpq
- @ $(LD) $(LDFLAGS) \
- -o ../bin-mysql/sorter sorter.o \
- $(LIBS) \
- ../lib/libmar.a \
- -lmysqlclient
+chkspf.o: chkspf.c \
+ ../lib/unidns.h \
+ ../lib/subafn.h \
+ ../lib/subrou.h
-chkspf.o: chkspf.c \
- ../lib/unidns.h \
- ../lib/subafn.h \
+receiver.o:receiver.c \
+ ../lib/modrec.h \
+ ../lib/unitls.h \
+ ../lib/unisig.h \
+ ../lib/uniprc.h \
+ ../lib/unipar.h \
+ ../lib/unidns.h \
../lib/subrou.h
-receiver.o:receiver.c \
- ../lib/modrec.h \
- ../lib/unitls.h \
- ../lib/unisig.h \
- ../lib/uniprc.h \
- ../lib/unipar.h \
- ../lib/unidns.h \
+feeder.o: feeder.c \
+ ../lib/gestcp.h \
+ ../lib/devsoc.h \
+ ../lib/unieml.h \
+ ../lib/unipar.h \
../lib/subrou.h
-feeder.o: feeder.c \
- ../lib/gestcp.h \
- ../lib/devsoc.h \
- ../lib/unieml.h \
- ../lib/unipar.h \
+sorter.o: sorter.c \
+ ../lib/geseml.h \
+ ../lib/unisig.h \
+ ../lib/uniprc.h \
+ ../lib/unipar.h \
+ ../lib/unieml.h \
+ ../lib/unidns.h \
../lib/subrou.h
-sorter.o: sorter.c \
- ../lib/geseml.h \
- ../lib/unisig.h \
- ../lib/uniprc.h \
- ../lib/unipar.h \
- ../lib/unieml.h \
- ../lib/unidns.h \
+scarmt.o: scarmt.c \
+ ../lib/devsql.h \
+ ../lib/unipar.h \
+ ../lib/uniprc.h \
+ ../lib/unisig.h \
../lib/subrou.h
-sender.o: sender.c \
- ../lib/lvleml.h \
- ../lib/geseml.h \
- ../lib/unieml.h \
- ../lib/unipar.h \
- ../lib/uniprc.h \
- ../lib/unisig.h \
+sender.o: sender.c \
+ ../lib/lvleml.h \
+ ../lib/geseml.h \
+ ../lib/unieml.h \
+ ../lib/unipar.h \
+ ../lib/uniprc.h \
+ ../lib/unisig.h \
../lib/subrou.h
toremake: Makefile
+++ /dev/null
-#--------------------------------------------------------------------
-#Executable generation area
-#--------------------------------------------------------------------
-debug :
- @ $(MAKE) OPTIME="-g" DEBUG="-DDEBUG" exe
- @ echo "application compiled in '$@' mode now ready"
-
-prod :
- @ $(MAKE) OPTIME="-g -O2" exe
- @ echo "application compiled in '$@' mode now ready"
-
-exe :
- $(MAKE) $(EXE)
-
-
-clean :
- - rm -fr *.o $(EXE)
- - rm -fr ../bin-*/*
-
-#--------------------------------------------------------------------
-#Equivalences
-#--------------------------------------------------------------------
-EXE = \
- bigre \
- receiver \
- sender \
- sorter \
-
-
-SRC = \
- receiver.c \
- sender.c \
- sorter.c \
-
-#--------------------------------------------------------------------
-#definitions
-#--------------------------------------------------------------------
-CC = gcc
-LD = gcc -g
-CFLAGS = -I ../lib -Wall $(OPTIME)
-LIBMAIL = ../lib/libmail.a
-
-LIBS = $(LIBMAIL) \
- -luuid \
- -lcrypto \
- -lcrypt \
- -lssl \
-
-#--------------------------------------------------------------------
-#Dependances
-#--------------------------------------------------------------------
-receiver: toremake $@.o
- @ $(LD) $(LDFLAGS) \
- -o ../bin-posql/$@ $@.o \
- $(LIBS) \
- ../lib/libpos.a \
- -lpq
-
-sndrpsql: toremake sender.o
- @ $(LD) $(LDFLAGS) \
- -o ../bin-posql/sender sender.o \
- $(LIBS) \
- ../lib/libpos.a \
- -lpq
-
-sndrmsql: toremake sender.o
- @ $(LD) $(LDFLAGS) \
- -o ../bin-mysql/sender sender.o \
- $(LIBS) \
- ../lib/libmar.a \
- -lmysqlclient
-
-srtrpsql: toremake sorter.o
- @ $(LD) $(LDFLAGS) \
- -o ../bin-posql/sorter sorter.o \
- $(LIBS) \
- ../lib/libpos.a \
- -lpq
-
-srtrmsql: toremake sorter.o
- @ $(LD) $(LDFLAGS) \
- -o ../bin-mysql/sorter sorter.o \
- $(LIBS) \
- ../lib/libmar.a \
- -lmysqlclient
-
-
-
-sender : toremake sender.o
- @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS)
-
-chkspf.o: chkspf.c \
- ../lib/unidns.h \
- ../lib/subafn.h \
- ../lib/subrou.h
-
-receiver.o:receiver.c \
- ../lib/modrec.h \
- ../lib/unitls.h \
- ../lib/unisig.h \
- ../lib/uniprc.h \
- ../lib/unipar.h \
- ../lib/unidns.h \
- ../lib/subrou.h
-
-feeder.o: feeder.c \
- ../lib/gestcp.h \
- ../lib/devsoc.h \
- ../lib/unieml.h \
- ../lib/unipar.h \
- ../lib/subrou.h
-
-sorter.o: sorter.c \
- ../lib/geseml.h \
- ../lib/unisig.h \
- ../lib/uniprc.h \
- ../lib/unipar.h \
- ../lib/unieml.h \
- ../lib/unidns.h \
- ../lib/subrou.h
-
-sender.o: sender.c \
- ../lib/lvleml.h \
- ../lib/geseml.h \
- ../lib/unieml.h \
- ../lib/unipar.h \
- ../lib/uniprc.h \
- ../lib/unisig.h \
- ../lib/subrou.h
-
-toremake: Makefile
- touch toremake
- @ - mkdir -p ../bin-common
- @ - mkdir -p ../bin-posql
- @ - mkdir -p ../bin-mysql
- - echo Bingo
- - rm -f $(EXE) *.o
-
-#--------------------------------------------------------------------
-.PHONY: toremake
-#--------------------------------------------------------------------
+++ /dev/null
-// vim: smarttab tabstop=8 shiftwidth=2 expandtab
-/********************************************************/
-/* */
-/* SMTP protocol domain destination sorter */
-/* Used to take the trans directive and generate */
-/* a todo list a email to be send. */
-/* */
-/* */
-/********************************************************/
-#include <dirent.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#include "subrou.h"
-#include "unidns.h"
-#include "unieml.h"
-#include "unipar.h"
-#include "uniprc.h"
-#include "unisig.h"
-#include "geseml.h"
-
-/*
-\f
-*/
-/********************************************************/
-/* */
-/* procedure to scan all files */
-/* */
-/********************************************************/
-static _Bool scantrans(const char *ext,_Bool todo)
-
-{
-#define OPEP "sorter.c:scantrans,"
-
-_Bool action;
-char **fname;
-TRATYP **trans;
-int phase;
-_Bool proceed;
-
-action=false;
-fname=(char **)0;
-trans=(TRATYP **)0;
-phase=0;
-proceed=true;
-while (proceed==true) {
- //(void) fprintf(stdout,"%s JMPDBG phase='%d' ext=<%s>\n",OPEP,phase,ext);
- switch (phase) {
- case 0 : //Getting the list of file
- fname=eml_getqfilelist(fname,ext);
- if (fname==(char **)0)
- phase=999; //Nothing to do
- break;
- case 1 : //Building the "trans" list
- action=true;
- if (fname!=(char **)0) { //always
- char **ptr;
-
- ptr=fname;
- while (*ptr!=(char *)0) {
- FILE *qfile;
-
- (void) rou_alert(5,"%s fame=<%s>",OPEP,*ptr);
- if ((qfile=eml_openqfile(*ptr,(const char *)0))!=(FILE *)0) {
- trans=eml_scanqfile(trans,qfile);
- (void) eml_closeqfile(qfile);
- (void) eml_deleteqfile(*ptr);
- }
- ptr++;
- }
- trans=eml_freeall_tra(trans);
- fname=(char **)rou_freelist((void *)fname,(genfree_t)rou_freestr);
- }
- break;
- case 2 : //scanning translit
- switch (todo) {
- case true : //Doing todo file
- (void) eml_todoqfile(trans);
- break;
- case false :
- (void) eml_doneqfile(trans);
- break;
- }
- trans=eml_freeall_tra(trans);
- break;
- default : //SAFE Guard
- proceed=false;
- break;
- }
- phase++;
- }
-#undef OPEP
-return action;
-}
-/*
-\f
-*/
-/********************************************************/
-/* */
-/* sorter central task */
-/* */
-/********************************************************/
-static void sorting()
-
-{
-#define OPEP "sorter.c:sorting,"
-#define TSLEEP 10
-
-_Bool action;
-int delay;
-int phase;
-_Bool proceed;
-
-action=false;
-delay=1;
-phase=0;
-proceed=true;
-while (proceed==true) {
- //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase);
- switch (phase) {
- case 0 : //Locking access
- if (prc_locking(appname,true,5)==false) {
- (void) rou_alert(0,"%s Unable to lock %s exclusif acccess (system?)",
- OPEP,appname);
- proceed=false;
- }
- break;
- case 1 : //got signal
- action=false;
- if ((hangup==true)||((reload==true))) {
- (void) rou_alert(0,"%s got hangup or reload signal",OPEP);
- phase=999;
- }
- break;
- case 2 : //got signal
- action|=scantrans(EXTRANS,true);
- break;
- case 3 : //got signal
- action|=scantrans(EXDONE,false);
- break;
- case 4 : //one passe only?
- if (foreground==true)
- phase=999; //Immediate ending
- break;
- case 5 : //lets time pass according "busy"
- delay=TSLEEP;
- if (action==true)
- delay=1;
- (void) sleep(delay);
- phase=0; //Looping
- break;
- default : //SAFE Guard
- (void) prc_locking(appname,false,1);
- proceed=false;
- break;
- }
- phase++;
- }
-
-#undef OPEP
-}
-/*
-\f
-*/
-/********************************************************/
-/* */
-/* Main routine */
-/* Start a channel to a remote ip.port */
-/* read file and transmit contecnts to */
-/* remote SMTP server. */
-/* */
-/********************************************************/
-int main(int argc,char *argv[])
-
-{
-#define OPEP "sorter.c:main,"
-
-int status;
-ARGTYP *params;
-int phase;
-_Bool proceed;
-
-status=0;
-params=(ARGTYP *)0;
-phase=0;
-proceed=true;
-while (proceed==true) {
- //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase);
- switch (phase) {
- case 0 : //checking parameters
- if ((params=par_getparams(argc,argv,"c:d:fhi:r:v"))==(ARGTYP *)0) {
- proceed=false; //no need to go further
- }
- break;
- case 1 : //Preparing scan
- (void) rou_setappname(SORTER);
- (void) rou_modesubrou(true);
- (void) prc_chgid(argv[0]);
- (void) sig_modeunisig(true);
- (void) sig_trapsignal(true,sig_alrm);
- (void) rou_loadconfig(config,true);
- break;
- case 2 : //checking if we need to go background
- if (foreground==false) {
- if (prc_divedivedive()!=0)
- phase=999; //direct exit
- }
- break;
- case 3 : //checking if we need to go background
- (void) sorting();
- break;
- default : //end of task
- params=par_freeparams(params);
- (void) rou_loadconfig(config,false);
- (void) sig_trapsignal(false,sig_alrm);
- (void) sig_modeunisig(false);
- (void) rou_modesubrou(false);
- (void) closelog();
- proceed=false;
- break;
- }
- phase++;
- }
-(void) exit(status);
-
-#undef TSLEEP
-#undef OPEP
-}
--- /dev/null
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+/********************************************************/
+/* */
+/* Handle all remote IP creditbilty level */
+/* By scanning database for new entry within */
+/* database tables remotes and try to establish */
+/* remote server "credibility" according remote IP.*/
+/* */
+/* */
+/********************************************************/
+#include <dirent.h>
+#include <stdlib.h>
+#include <syslog.h>
+#include <unistd.h>
+
+#include "devsql.h"
+#include "unipar.h"
+#include "uniprc.h"
+#include "unisig.h"
+#include "subrou.h"
+
+#define SCANNER "scarmt" //application name
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to check database and check new */
+/* remote ip credibility. */
+/* */
+/********************************************************/
+static void doscanning()
+
+{
+#define OPEP "scarmt.c:doscanning,"
+
+SQLPTR *sqlptr;
+int delay;
+int phase;
+_Bool proceed;
+
+sqlptr=(SQLPTR *)0;
+delay=10; //10 second sleeping time
+phase=0;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //opening database
+ if ((sqlptr=sql_opensql())==(SQLPTR *)0) {
+ (void) rou_alert(0,"%s Unable to open database (Config?)",OPEP);
+ }
+ break;
+ case 1 : //check about signal
+ if ((hangup==true)||((reload==true))) {
+ (void) rou_alert(0,"%s got hangup or reload signal",OPEP);
+ phase=999;
+ }
+ break;
+ case 2 : //check for new entry
+ break;
+ case 3 : //check entries
+ break;
+ case 4 : //let continue
+ sleep(delay);
+ phase=0; //looping the job again
+ break;
+ default : //SAFE Guard
+ sqlptr=sql_closesql(sqlptr);
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Main routine */
+/* Start a channel to a remote ip.port */
+/* read file and transmit contecnts to */
+/* remote SMTP server. */
+/* */
+/********************************************************/
+int main(int argc,char *argv[])
+
+{
+#define OPEP "scarmt.c:main,"
+
+int status;
+ARGTYP *params;
+int phase;
+_Bool proceed;
+
+status=0;
+params=(ARGTYP *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase);
+ switch (phase) {
+ case 0 : //checking parameters
+ if ((params=par_getparams(argc,argv,"c:d:fhi:r:v"))==(ARGTYP *)0) {
+ proceed=false; //no need to go further
+ }
+ break;
+ case 1 : //Preparing scan
+ (void) rou_setappname(SCANNER);
+ (void) rou_modesubrou(true);
+ (void) prc_chgid(argv[0]);
+ (void) sig_modeunisig(true);
+ (void) sig_trapsignal(true,sig_alrm);
+ (void) rou_loadconfig(config,true);
+ break;
+ case 2 : //checking if we need to go background
+ if (foreground==false) {
+ if (prc_divedivedive()!=0)
+ phase=999; //direct exit
+ }
+ break;
+ case 3 : //do program main purpose
+ (void) doscanning();
+ break;
+ default : //end of task
+ params=par_freeparams(params);
+ (void) rou_loadconfig(config,false);
+ (void) sig_trapsignal(false,sig_alrm);
+ (void) sig_modeunisig(false);
+ (void) rou_modesubrou(false);
+ (void) closelog();
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+(void) exit(status);
+
+#undef TSLEEP
+#undef OPEP
+}
phase=999; //direct exit
}
break;
- case 3 : //checking if we need to go background
+ case 3 : //do program main purpose
(void) sorting();
break;
default : //end of task
-bin-posql
\ No newline at end of file
+bin-mysql
\ No newline at end of file