]> SAFE projects GIT repository - jmp/mailleur/commitdiff
First scetch of sorter.c
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 10 May 2025 23:56:36 +0000 (19:56 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 10 May 2025 23:57:27 +0000 (19:57 -0400)
app/Makefile
app/sorter.c [new file with mode: 0644]

index b269fcb365975cf3edab585bb64da56478571ee7..5cf068abd84e85d7e8619b46f3198587c2662014 100644 (file)
@@ -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 (file)
index 0000000..150d994
--- /dev/null
@@ -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        <stdlib.h>
+#include        <syslog.h>
+#include        <unistd.h>
+
+#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;
+}
+/*
+\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[])
+
+{
+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);
+}