]> SAFE projects GIT repository - jmp/mailleur/commitdiff
emval scan wirth error
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 18 Sep 2024 11:52:50 +0000 (07:52 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 18 Sep 2024 11:52:50 +0000 (07:52 -0400)
app/emlval.c
lib/subrou.c

index 3fc4771d926de8bf67f9b2708326a2829240283a..91a99e3132658e2ba7208c3e8e814be1f10dd328 100644 (file)
@@ -18,7 +18,7 @@
 #include       "uniprc.h"
 #include       "gesspf.h"
 
-#define CHKNAME "checkdns"
+#define VALNAME "emlval"        //validator application
 /*
 \f
 */
@@ -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
+}
+/*
+\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
@@ -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;i<params->argc;i++) {
   char *basedir;
+  char *basepath;
   char *fname;
   char *ptr;
 
@@ -207,27 +272,15 @@ for (int i=0;i<params->argc;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;i<params->argc;i++) {
   }
 curdir=rou_freestr(curdir);
 return status;
+
+#undef  OPEP
 }
 /*
 \f
@@ -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);
index 5e2870c9e6de7b025b1617385fb911235a5445c3..9d0a65c9b799a6fe70f4141199e28cb66223d89c 100644 (file)
@@ -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