]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Improving chkdns to test a test file
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 17 Aug 2024 20:20:16 +0000 (16:20 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 17 Aug 2024 20:20:16 +0000 (16:20 -0400)
app/chkdns.c
lib/subrou.c

index 89c95ec3e32bb8002c74384daa73647b8822a7ed..5f1a35601546dd742b04113bfb78b7e84bc469b1 100644 (file)
 #include       "subrou.h"
 #include       "subafn.h"
 #include       "unidns.h"
+#include       "unipar.h"
+#include       "uniprc.h"
 #include       "gesspf.h"
 
+#define CHKNAME "checkdns"
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to scan one file stop at soon test    */
+/*      line is not successful.                         */
+/*                                                     */
+/********************************************************/
+static int scantest(char *testfile)
+
+{
+int status;
+
+status=0;
+return status;
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to scan filename present within the   */
+/*      parameter list                                  */
+/*                                                     */
+/********************************************************/
+static int testfiles(ARGTYP *params)
+
+{
+int status;
+
+status=0;
+for (int i=0;i<params->argc;i++) {
+  (void) fprintf(stdout,"Doing test pattern <%s>\n",params->argv[i]);
+  (void) scantest(params->argv[i]);
+  }
+return status;
+}
 /*
 \f
 */
@@ -30,56 +71,46 @@ int main(int argc,char *argv[])
 
 {
 int status;
-int try;
-AFNTYP *afnnum;
-char *curname;
 int phase;
+ARGTYP *params;
 _Bool proceed;
 
 status=0;
-try=0;
-afnnum=(AFNTYP *)0;
-if ((curname=strrchr(argv[0],'/'))==(char *)0)
-  curname=argv[0];
-else
-  curname++;
+params=(ARGTYP *)0;
 phase=0;
 proceed=true;
 while (proceed==true) {
   switch (phase) {
     case 0      :       //checking parameters
-      foreground=true;
-      debug=5;
-      (void) rou_setappname(curname);
-      if (argc<2) {
-        (void) rou_alert(0,"%s need 2 arguments (domain,IP)",appname);
-        for (int i=1;i<=argc;i++) 
-          (void) rou_alert(0,"\targ[%d]=<%s>",i,argv[i]);
-        phase=999;
-        }
+      if ((params=par_getparams(argc,argv,"d:hr:v"))==(ARGTYP *)0) 
+        phase=999;      //no need to go further
       break;
-    case 1      :       //checking IP
-      if ((afnnum=afn_getipnum(argv[2]))==(AFNTYP *)0) {
-        (void) rou_alert(0,"%s is not an IP (aborting)",argv[2]);
+    case 1      :       //check if we have file to scan
+      if (params->argc==0) {
+        (void) fprintf(stderr,"Unable to proceed with test\n");
+        (void) fprintf(stderr,"\tthe filenames (of test pattern) are missing\n");
+        status=-1;
         phase=999;
         }
       break;
-    case 2      :       //initialisation
+    case 2      :
+      (void) rou_setappname(CHKNAME);
       (void) afn_modesubafn(true);
       (void) rou_modesubrou(true);
+      (void) par_modeunipar(true);
+      (void) prc_modeuniprc(true);
       (void) spf_modegesspf(true);
+      (void) prc_preptitle(argc,argv,environ);
       break;
     case 3      :       //doing main tash
-      if (argc>1) {     //always
-        SPFENU spf;
-
-        spf=spf_getstatus(&try,argv[1],afnnum);
-        (void) rou_alert(0,"%s %s ==> %s",argv[1],argv[2],spf_spfASCII(spf));
-        }
-      afnnum=afn_freeipnum(afnnum);
+      (void) testfiles(params);
       break;
     case 4      :       //doing main tash
+      (void) prc_cleantitle();
+      params=par_freeparams(params);
       (void) spf_modegesspf(false);
+      (void) prc_modeuniprc(false);
+      (void) par_modeunipar(false);
       (void) rou_modesubrou(false);
       (void) afn_modesubafn(false);
       break;
index e2e6fb7b38d7e39b564dfc04eb3067bd1b2999f6..6be2ead24a7704fb8fbd6736b1bb4658294019d3 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.4.2"
-#define RELEASE "19"
+#define RELEASE "20"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level