]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting to scan dnstst file
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 18 Aug 2024 01:17:29 +0000 (21:17 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 18 Aug 2024 01:17:29 +0000 (21:17 -0400)
app/chkdns.c
lib/subrou.c

index 5f1a35601546dd742b04113bfb78b7e84bc469b1..2cda53976e122d5747ec440ea77b58f710b6ae9d 100644 (file)
@@ -5,6 +5,7 @@
 /*      library.                                        */
 /*                                                     */
 /********************************************************/
+#include       <errno.h>
 #include       <stdio.h>
 #include       <stdlib.h>
 #include       <string.h>
 */
 /********************************************************/
 /*                                                     */
+/*     Procedure to scan a line from the test file     */
+/*                                                     */
+/********************************************************/
+static int scanline(FILE *fichier)
+
+{
+int status;
+int num;
+char line[300];
+
+status=0;
+num=0;
+while (fgets(line,sizeof(line),fichier)!=(char *)0) {
+  char *ptr;
+
+  num++;
+  if ((ptr=strchr(line,'#'))!=(char *)0)
+    *ptr='\000';
+  if (strlen(line)==0)
+    continue;
+  (void) rou_alert(0,"JMPDBG line='%d' <%s>",num,line);
+  }
+return status;
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
 /*     Procedure to scan one file stop at soon test    */
 /*      line is not successful.                         */
 /*                                                     */
@@ -31,8 +61,38 @@ static int scantest(char *testfile)
 
 {
 int status;
+char *rootname;
+FILE *fichier;
+int phase;
+_Bool proceed;
 
-status=0;
+status=-1;
+rootname=rou_apppath(testfile);
+phase=0;
+proceed=true;
+while (proceed==true) {
+  switch (phase) {
+    case 0      :       //using root directory if need
+      if ((fichier=fopen(rootname,"r"))==(FILE *)0) {
+        (void) rou_alert(0,"Unable to open file <%s> (error=<%s>)",
+                          rootname,strerror(errno));
+        phase=999;      //no need to go further
+        }
+      break;
+    case 1      :       //scan the file
+      (void) scanline(fichier);
+      break;
+    case 2      :       //scan the file
+      (void) fclose(fichier);
+      status=0;
+      break;
+    default     :       //SAFE guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+rootname=rou_freestr(rootname);
 return status;
 }
 /*
@@ -101,6 +161,7 @@ while (proceed==true) {
       (void) prc_modeuniprc(true);
       (void) spf_modegesspf(true);
       (void) prc_preptitle(argc,argv,environ);
+      foreground=true;
       break;
     case 3      :       //doing main tash
       (void) testfiles(params);
index 6be2ead24a7704fb8fbd6736b1bb4658294019d3..a159a2d25e0dc59bcbfe703adc6eb0cf76e61f53 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.4.2"
-#define RELEASE "20"
+#define RELEASE "21"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level