/* 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"
*/
/********************************************************/
/* */
+/* 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 */
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