From: Jean-Marc Pigeon (Delson) Date: Wed, 18 Sep 2024 11:52:50 +0000 (-0400) Subject: emval scan wirth error X-Git-Tag: tag-0.4.2-end~6 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=a0628454a5e542e8631412e703363145b9630fee;p=jmp%2Fmailleur emval scan wirth error --- diff --git a/app/emlval.c b/app/emlval.c index 3fc4771..91a99e3 100644 --- a/app/emlval.c +++ b/app/emlval.c @@ -18,7 +18,7 @@ #include "uniprc.h" #include "gesspf.h" -#define CHKNAME "checkdns" +#define VALNAME "emlval" //validator application /* */ @@ -146,14 +146,14 @@ return status; static int scantest(char *tfile) { -#define OPEP "valide.c:scantest" +#define OPEP "emlval.c:scantest" -int status; +_Bool status; FILE *fichier; int phase; _Bool proceed; -status=-1; +status=false; phase=0; proceed=true; while (proceed==true) { @@ -179,6 +179,68 @@ while (proceed==true) { phase++; } return status; + +#undef OPEP +} +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to scan one filename to be a pattern */ +/* file to test */ +/* */ +/********************************************************/ +static _Bool testonefile(char *tdir,char *tfile) + +{ +#define OPEP "emlval.c:testonefile" + +_Bool status; +char *curdir; +char *basedir; +int phase; +_Bool proceed; + +status=false; +if (tdir==(char *)0) + tdir=""; +curdir=getcwd((char *)0,0); +basedir=rou_apppath(tdir); +phase=0; +proceed=true; +while (proceed==true) { + (void) rou_alert(0,"%s phase='%d'",OPEP,phase); + switch (phase) { + case 0 : //going to the right directory + if (chdir(basedir)<0) { + (void) rou_alert(0,"%s Unable to chdir to <%s> within <%s> (error=<%s>)", + OPEP,basedir,curdir,strerror(errno)); + phase=999; //Trouble trouble + } + break; + case 1 : //going to the right directory + status=scantest(tfile); + break; + case 2 : //going back to the original directory + if (chdir(curdir)<0) { + (void) rou_alert(0,"%s Unable to reach directory <%s> (error=<%s>) Bug?", + OPEP,curdir,strerror(errno)); + status=false; + phase=999; //Trouble trouble + } + break; + default : //SAFE guard + proceed=false; + break; + } + phase++; + } +basedir=rou_freestr(basedir); +curdir=rou_freestr(curdir); +return status; + +#undef OPEP } /* @@ -192,13 +254,16 @@ return status; static int testfiles(ARGTYP *params) { -int status; +#define OPEP "emlval.c:testfiles" + +_Bool status; char *curdir; -status=0; +status=false; curdir=getcwd((char *)0,0); for (int i=0;iargc;i++) { char *basedir; + char *basepath; char *fname; char *ptr; @@ -207,27 +272,15 @@ for (int i=0;iargc;i++) { ptr=strrchr(fname,'/'); if (ptr!=(char *)0) { *ptr='\000'; - (void) free(basedir); - basedir=strdup(fname); - ptr++; - (void) strcpy(fname,ptr); - } - if (strlen(basedir)>0) { - if (chdir(basedir)<0) { - (void) rou_alert(0,"%s Unable to chdir to <%s> (error=<%s>)", - OPEP,basedir,strerror(errno)); - fname=rou_freestr(fname); - basedir=rou_freestr(basedir); - continue; - } + (void) free(basedir); + basedir=strdup(fname); + ptr++; + (void) strcpy(fname,ptr); } - status=scantest(fname); - if (chdir(curdir)<0) - (void) rou_alert(0,"%s Unable to return <%s> (error=<%s>) (Bug?)", - OPEP,curdir,strerror(errno)); - fname=rou_freestr(fname); + status=testonefile(basedir,fname); + basepath=rou_freestr(basepath); basedir=rou_freestr(basedir); - if (status<0) { + if (status==false) { (void) rou_alert(0,"%s, <%s> test is no successfull exiting", OPEP,params->argv[i]); break; @@ -235,6 +288,8 @@ for (int i=0;iargc;i++) { } curdir=rou_freestr(curdir); return status; + +#undef OPEP } /* @@ -274,7 +329,7 @@ while (proceed==true) { } break; case 2 : - (void) rou_setappname(CHKNAME); + (void) rou_setappname(VALNAME); (void) afn_modesubafn(true); (void) rou_modesubrou(true); (void) par_modeunipar(true); diff --git a/lib/subrou.c b/lib/subrou.c index 5e2870c..9d0a65c 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -21,7 +21,7 @@ //version definition #define VERSION "0.4.2" -#define RELEASE "29" +#define RELEASE "30" //Public variables PUBLIC int debug=0; //debug level