From fbde3963b780b606c4fb791f22387d9b04b6aa68 Mon Sep 17 00:00:00 2001 From: Jean-Marc Pigeon Date: Sun, 16 Nov 2025 15:03:28 -0500 Subject: [PATCH] Improving rou_dbglive procedure --- app/receiver.c | 2 +- app/scanner.c | 2 +- app/sender.c | 2 +- app/sorter.c | 2 +- lib/subrou.c | 10 +++++----- lib/subrou.h | 1 + lib/unipar.c | 8 ++++++++ sysconfig/mailleur | 2 +- 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/receiver.c b/app/receiver.c index 46137d3..f126022 100644 --- a/app/receiver.c +++ b/app/receiver.c @@ -50,7 +50,7 @@ proceed=true; while (proceed==true) { switch (phase) { case 0 : //checking parameters - if ((params=par_getparams(argc,argv,"c:d:fhr:v"))==(ARGTYP *)0) { + if ((params=par_getparams(argc,argv,"c:d:D:fhr:v"))==(ARGTYP *)0) { phase=999; //no need to go further } break; diff --git a/app/scanner.c b/app/scanner.c index 2e578ec..a9a566a 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -356,7 +356,7 @@ while (proceed==true) { //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase); switch (phase) { case 0 : //checking parameters - if ((params=par_getparams(argc,argv,"c:d:fhi:r:v"))==(ARGTYP *)0) { + if ((params=par_getparams(argc,argv,"c:d:D:fhi:r:v"))==(ARGTYP *)0) { proceed=false; //no need to go further } break; diff --git a/app/sender.c b/app/sender.c index a7b73f0..c519459 100644 --- a/app/sender.c +++ b/app/sender.c @@ -329,7 +329,7 @@ while (proceed==true) { //(void) fprintf(stdout,"%s (pid=%08d) JMPDBG phase='%d'\n",OPEP,getpid(),phase); switch (phase) { case 0 : //checking parameters - if ((params=par_getparams(argc,argv,"c:d:fh:r:v"))==(ARGTYP *)0) { + if ((params=par_getparams(argc,argv,"c:d:D:fh:r:v"))==(ARGTYP *)0) { proceed=false; //no need to go further } break; diff --git a/app/sorter.c b/app/sorter.c index 818df72..2c0e19f 100644 --- a/app/sorter.c +++ b/app/sorter.c @@ -194,7 +194,7 @@ while (proceed==true) { //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase); switch (phase) { case 0 : //checking parameters - if ((params=par_getparams(argc,argv,"c:d:fhi:r:v"))==(ARGTYP *)0) { + if ((params=par_getparams(argc,argv,"c:d:D:fhi:r:v"))==(ARGTYP *)0) { proceed=false; //no need to go further } break; diff --git a/lib/subrou.c b/lib/subrou.c index f949722..449d894 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -23,6 +23,7 @@ //Public variables PUBLIC int debug=0; //debug level +PUBLIC char *dbglive; //procedure reference to be debugged live PUBLIC _Bool foreground=false; //process is always started in background mode PUBLIC char *rootdir=(char *)0;//working directory (debugging) @@ -639,11 +640,10 @@ PUBLIC void rou_dbglive(const int dlevel,const char *prcref,const char *fmt,...) { #define DBG "DBGLIVE" -char *ptr; - -if ((debug>=dlevel)&&((ptr=getenv(DBG))!=(char *)0)) { - (void) rou_alert(0,"Bigre ptr=<%s>",ptr); - if (strstr(ptr,prcref)!=(char *)0) { +(void) rou_alert(0,"BIGRE Bigre dbglive=<%s>",dbglive); +if ((debug>=dlevel)&&(dbglive!=(char *)0)) { + (void) rou_alert(0,"Bigre dbglive=<%s>",dbglive); + if (strstr(dbglive,prcref)!=(char *)0) { char *nstr; va_list args; diff --git a/lib/subrou.h b/lib/subrou.h index 18a7f79..c7318a2 100644 --- a/lib/subrou.h +++ b/lib/subrou.h @@ -33,6 +33,7 @@ typedef struct timespec TIMESPEC; extern int debug; //application debug mode extern _Bool foreground; //process is in foreground mode +extern char *dbglive; //string to check for live debugging extern char *rootdir; //application root directory extern char *appname; //application "official" name extern char execname[]; //Application exec/binary name diff --git a/lib/unipar.c b/lib/unipar.c index 11e7d73..52feeb9 100644 --- a/lib/unipar.c +++ b/lib/unipar.c @@ -49,6 +49,7 @@ static void usage_aid(char *name,const char *select) static char *options[]={ "c[-c config]", "d[-d debug]", + "D[-D dbglive]", "f[-f]", "h[-h]", "i[-i IP]", @@ -60,6 +61,7 @@ static char *options[]={ static char *details[]={ "-c config\t: set config file\n", "-d level\t: debug level [1-10]\n", + "-D dbglive\t: Procedure name to use with live debug\n", "-f\t\t: start program in foreground (CLI) mode\n", "-h\t\t: print this help message\n", "-i IP\t\t: IP to be used as source IP\n", @@ -119,6 +121,8 @@ if (params!=(ARGTYP *)0) { } (void) free(params); params=(ARGTYP *)0; + rou_freestr(dbglive); + dbglive=(char *)0; } return params; } @@ -156,6 +160,10 @@ while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) { debug=atoi(optarg); (void) rou_alert(1,"debug level is now '%d'",debug); break; + case 'D' : //debug level + dbglive=strdup(optarg); + (void) rou_alert(1,"debug live string=<%s>",dbglive); + break; case 'f' : //background/daemon mode foreground=true; (void) fprintf(stdout,"%s-%s, foreground mode requested\n", diff --git a/sysconfig/mailleur b/sysconfig/mailleur index 03cb8bb..9c599db 100644 --- a/sysconfig/mailleur +++ b/sysconfig/mailleur @@ -2,6 +2,6 @@ #options available to debug mailleur #OPTIONS="-d9" #this is to debug a specific function within a specific module -#DBGLIV="lvleml.c:checkto,modrec.c:docontact" +#OPTIONS="-d9 -Dlvleml.c:checkto,modrec.c:docontact #------------------------------------------- -- 2.47.3