]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting to read feed test file
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 25 Mar 2025 12:31:54 +0000 (08:31 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 25 Mar 2025 12:31:54 +0000 (08:31 -0400)
app/feeder.c
data-tst/feed00.tst [new file with mode: 0644]
data-tst/feed01.tst [new file with mode: 0644]
lib/subrou.c

index 0af822ee7d60967bdad4315803c384eee029c700..85005d5d7a07299c91c9e6966cbdc60ee372742d 100644 (file)
@@ -8,9 +8,11 @@
 /*              feeder ip port [file1 file2...]         */
 /*                                                     */
 /********************************************************/
+#include       <errno.h>
 #include       <signal.h>
 #include       <stdlib.h>
 #include       <stdio.h>
+#include       <string.h>
 #include       <unistd.h>
 
 #include       "subrou.h"
@@ -47,6 +49,49 @@ static void usage(const char *name)
 */
 /********************************************************/
 /*                                                     */
+/*     Scanning data file.                             */
+/*                                                     */
+/********************************************************/
+static _Bool scanfile(const char *filename)
+
+{
+_Bool status;
+FILE *fichier;
+int phase;
+_Bool proceed;
+
+status=false;
+fichier=(FILE *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  switch (phase) {
+    case 0      :       //checking parameters
+      if ((fichier=fopen(filename,"r"))==(FILE *)0) {
+        (void) fprintf(stdout,"Unable to open file <%s> (error=<%s>\n",
+                               filename,strerror(errno));
+        proceed=false;
+        }
+      break;
+    case 1      :       //reading line;
+      (void) fprintf(stdout,"reading file <%s>\n",filename);
+      (void) sleep(1);
+      status=true;
+      break;
+    default     :       //SAFE Guard
+      (void) fclose(fichier);
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+return status;
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
 /*     Main routine                                    */
 /*             Start a channel to a remote ip.port     */
 /*              read file and transmit contecnts to     */
@@ -92,12 +137,11 @@ while (proceed==true) {
       break;
     case 3      :       //doing main task
       for (int i=2;i<params->argc;i++) {
+        if (scanfile(params->argv[i])==false) 
+          break;
         numfile++;
-      
-        (void) fprintf(stdout,"sending <%s>\n",params->argv[i]);
-        (void) sleep(3);
         }
-      (void) fprintf(stdout,"%d file transmetted to <%s.%s>\n",
+      (void) fprintf(stdout,"%d file successfully transmetted to <%s.%s>\n",
                              numfile,params->argv[0],params->argv[1]);
       break;
     case 4      :       //closing remote channel
diff --git a/data-tst/feed00.tst b/data-tst/feed00.tst
new file mode 100644 (file)
index 0000000..f425c26
--- /dev/null
@@ -0,0 +1 @@
+#basic test to feed SMTP server
diff --git a/data-tst/feed01.tst b/data-tst/feed01.tst
new file mode 100644 (file)
index 0000000..1ce1aba
--- /dev/null
@@ -0,0 +1 @@
+#specific test to feed smtp server
index eb2e84424cc6231c18a1dfe4a6084b815d6dda59..c21f6d8e39023ef87f464841b47c6ef00cf5dc4b 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.6"
-#define RELEASE "8"
+#define RELEASE "9"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level