From: Jean-Marc Pigeon (Delson) Date: Tue, 25 Mar 2025 12:31:54 +0000 (-0400) Subject: Starting to read feed test file X-Git-Tag: tag-0.7~66 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=918ce77d327904abc3cc5cbd3be96bc678b01439;p=jmp%2Fmailleur Starting to read feed test file --- diff --git a/app/feeder.c b/app/feeder.c index 0af822e..85005d5 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -8,9 +8,11 @@ /* feeder ip port [file1 file2...] */ /* */ /********************************************************/ +#include #include #include #include +#include #include #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; +} +/* + +*/ +/********************************************************/ +/* */ /* 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;iargc;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 index 0000000..f425c26 --- /dev/null +++ b/data-tst/feed00.tst @@ -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 index 0000000..1ce1aba --- /dev/null +++ b/data-tst/feed01.tst @@ -0,0 +1 @@ +#specific test to feed smtp server diff --git a/lib/subrou.c b/lib/subrou.c index eb2e844..c21f6d8 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -21,7 +21,7 @@ //version definition #define VERSION "0.6" -#define RELEASE "8" +#define RELEASE "9" //Public variables PUBLIC int debug=0; //debug level