From baedc1a6c21fea3e318a11a98e0021d7ec8b62e2 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Tue, 25 Mar 2025 09:55:48 -0400 Subject: [PATCH] Starting to scanline of feeder test files --- app/feeder.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++---- lib/subrou.c | 2 +- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/app/feeder.c b/app/feeder.c index 85005d5..8936909 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -49,14 +49,56 @@ static void usage(const char *name) */ /********************************************************/ /* */ +/* Scanning one line from test file */ +/* */ +/********************************************************/ +static _Bool scanline(SOCPTR *socptr,char *line) + +{ +_Bool status; +int phase; +_Bool proceed; + +status=false; +phase=0; +proceed=true; +while (proceed==true) { + //(void) fprintf(stdout,"JMPDBG scanline phase='%d'\n",phase); + switch (phase) { + case 0 : //removing first space + while ((line[0]==' ')||(line[0]=='\t')) + (void) memmove(line,line+1,(strlen(line+1)+1)); + break; + case 1 : //discarding comment + if (line[0]=='#') { + status=true; + phase=999; //line is a comment no need to go further + } + break; + case 2 : //checking line + break; + default : //SAFE Guard + proceed=false; + break; + } + phase++; + } +return status; +} +/* + +*/ +/********************************************************/ +/* */ /* Scanning data file. */ /* */ /********************************************************/ -static _Bool scanfile(const char *filename) +static _Bool scanfile(SOCPTR *socptr,const char *filename) { _Bool status; FILE *fichier; +char line[200]; int phase; _Bool proceed; @@ -65,6 +107,7 @@ fichier=(FILE *)0; phase=0; proceed=true; while (proceed==true) { + //(void) fprintf(stdout,"JMPDBG scanfile phase='%d'\n",phase); switch (phase) { case 0 : //checking parameters if ((fichier=fopen(filename,"r"))==(FILE *)0) { @@ -74,8 +117,15 @@ while (proceed==true) { } break; case 1 : //reading line; - (void) fprintf(stdout,"reading file <%s>\n",filename); - (void) sleep(1); + (void) fprintf(stdout,"Scanning file <%s>\n",filename); + while (fgets(line,sizeof(line),fichier)!=(char *)0) { + if (scanline(socptr,line)==false) { + phase=999; //Trouble trouble exiting + break; + } + } + break; + case 2 : //scanning went well status=true; break; default : //SAFE Guard @@ -115,6 +165,7 @@ numfile=0; 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,"d:fh:r:v"))==(ARGTYP *)0) { @@ -137,7 +188,7 @@ while (proceed==true) { break; case 3 : //doing main task for (int i=2;iargc;i++) { - if (scanfile(params->argv[i])==false) + if (scanfile(socptr,params->argv[i])==false) break; numfile++; } diff --git a/lib/subrou.c b/lib/subrou.c index c21f6d8..f31beae 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -21,7 +21,7 @@ //version definition #define VERSION "0.6" -#define RELEASE "9" +#define RELEASE "10" //Public variables PUBLIC int debug=0; //debug level -- 2.47.3