*/
/********************************************************/
/* */
+/* 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;
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* 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;
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) {
}
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
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) {
break;
case 3 : //doing main task
for (int i=2;i<params->argc;i++) {
- if (scanfile(params->argv[i])==false)
+ if (scanfile(socptr,params->argv[i])==false)
break;
numfile++;
}