From 8158f15c72eb1e5e37cb90e24b57196b42259e33 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sat, 17 Aug 2024 16:20:16 -0400 Subject: [PATCH] Improving chkdns to test a test file --- app/chkdns.c | 89 +++++++++++++++++++++++++++++++++++----------------- lib/subrou.c | 2 +- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/app/chkdns.c b/app/chkdns.c index 89c95ec..5f1a356 100644 --- a/app/chkdns.c +++ b/app/chkdns.c @@ -13,8 +13,49 @@ #include "subrou.h" #include "subafn.h" #include "unidns.h" +#include "unipar.h" +#include "uniprc.h" #include "gesspf.h" +#define CHKNAME "checkdns" +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to scan one file stop at soon test */ +/* line is not successful. */ +/* */ +/********************************************************/ +static int scantest(char *testfile) + +{ +int status; + +status=0; +return status; +} +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to scan filename present within the */ +/* parameter list */ +/* */ +/********************************************************/ +static int testfiles(ARGTYP *params) + +{ +int status; + +status=0; +for (int i=0;iargc;i++) { + (void) fprintf(stdout,"Doing test pattern <%s>\n",params->argv[i]); + (void) scantest(params->argv[i]); + } +return status; +} /* */ @@ -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; diff --git a/lib/subrou.c b/lib/subrou.c index e2e6fb7..6be2ead 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -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 -- 2.47.3