#include "uniprc.h"
#include "gesspf.h"
-#define CHKNAME "checkdns"
+#define VALNAME "emlval" //validator application
/*
\f
*/
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) {
phase++;
}
return status;
+
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* 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
}
/*
\f
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;i<params->argc;i++) {
char *basedir;
+ char *basepath;
char *fname;
char *ptr;
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;
}
curdir=rou_freestr(curdir);
return status;
+
+#undef OPEP
}
/*
\f
}
break;
case 2 :
- (void) rou_setappname(CHKNAME);
+ (void) rou_setappname(VALNAME);
(void) afn_modesubafn(true);
(void) rou_modesubrou(true);
(void) par_modeunipar(true);