From: Jean-Marc Pigeon (Delson) Date: Sat, 10 May 2025 23:56:36 +0000 (-0400) Subject: First scetch of sorter.c X-Git-Tag: tag-0.8~112 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=1d1535488a645aa0c5e5e5db892ee89dbd912641;p=jmp%2Fmailleur First scetch of sorter.c --- diff --git a/app/Makefile b/app/Makefile index b269fcb..5cf068a 100644 --- a/app/Makefile +++ b/app/Makefile @@ -21,14 +21,16 @@ clean : #Equivalences #-------------------------------------------------------------------- EXE= \ + chkspf \ emlrcvr \ feeder \ - chkspf \ + sorter \ SRC= \ + chkspf.c \ emlrcvr.c \ freeder.c \ - chkspf.c \ + sorter.c \ #-------------------------------------------------------------------- #definitions @@ -45,13 +47,16 @@ LIBS = $(LIBMAIL) \ #-------------------------------------------------------------------- #Dependances #-------------------------------------------------------------------- +chkspf : toremake chkspf.o + @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS) + emlrcvr : toremake emlrcvr.o @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS) feeder : toremake feeder.o @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS) -chkspf : toremake chkspf.o +sorter : toremake sorter.o @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS) chkspf.o: chkspf.c \ @@ -73,6 +78,9 @@ feeder.o: feeder.c \ ../lib/unipar.h \ ../lib/subrou.h +sorter.o: sorter.c \ + ../lib/subrou.h + toremake: Makefile $(LIBAI) touch toremake - rm -f $(EXE) *.o diff --git a/app/sorter.c b/app/sorter.c new file mode 100644 index 0000000..150d994 --- /dev/null +++ b/app/sorter.c @@ -0,0 +1,96 @@ +// vim: smarttab tabstop=8 shiftwidth=2 expandtab +/********************************************************/ +/* */ +/* SMTP protocol feeder. */ +/* Used to transmit data to remote SMTP server. */ +/* */ +/* Format is: */ +/* feeder ip port [file1 file2...] */ +/* */ +/********************************************************/ +#include +#include +#include + +#include "subrou.h" +#include "unisig.h" +#include "unipar.h" + +#define SORTER "sorter" //application name + +/********************************************************/ +/* */ +/* procedure to scan all files */ +/* */ +/********************************************************/ +static _Bool scantrans() + +{ +_Bool status; + +status=false; +(void) sleep(2); +(void) rou_alert(0,"JMPDBG sorter"); +(void) sleep(5); +status=true; +return status; +} +/* + +*/ +/********************************************************/ +/* */ +/* 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[]) + +{ +int status; +ARGTYP *params; +int phase; +_Bool proceed; + +status=0; +params=(ARGTYP *)0; +foreground=true; +phase=0; +proceed=true; +while (proceed==true) { + //(void) fprintf(stdout,"JMPDBG main phase='%d'\n",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_modesubrou(true); + (void) sig_modeunisig(true); + (void) rou_setappname(SORTER); + (void) rou_loadconfig(config,true); + (void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON); + (void) closelog(); + break; + case 2 : //Scanning all file + if ((hangup==true)||(reload==true)) + phase=999; //Process + if (scantrans()==false) + phase=999; + (void) sleep(5); + break; + default : //end of task + params=par_freeparams(params); + (void) rou_loadconfig(config,false); + (void) sig_modeunisig(false); + (void) rou_modesubrou(false); + proceed=false; + break; + } + phase++; + } +(void) exit(status); +}