From: Jean-Marc Pigeon (Delson) Date: Tue, 9 Jul 2024 15:05:33 +0000 (-0400) Subject: Adding command line title capability X-Git-Tag: tag-0.2~4 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=caa2d3bd83ed2219d6a7d3a55a3fc1eda7f1bd3f;p=jmp%2Fmailleur Adding command line title capability --- diff --git a/app/maild.c b/app/maild.c index 7e2ba5e..bea11be 100644 --- a/app/maild.c +++ b/app/maild.c @@ -24,7 +24,8 @@ static void task() { (void) rou_alert(0,"JMPDBG starting task"); -(void) sleep(5); +(void) prc_settitle("JMPDBG bingo!"); +(void) sleep(10); (void) rou_alert(0,"JMPDBG task completed"); } /* @@ -63,6 +64,7 @@ while (proceed==true) { proceed=false;//Dive mode break; case 2 : //initialising process + (void) prc_preptitle(argc,argv,environ); (void) rou_modesubrou(true); (void) par_modeunipar(true); (void) prc_modeuniprc(true); @@ -70,10 +72,13 @@ while (proceed==true) { case 3 : //doing main tash (void) task(); break; - default : //end of task + case 4 : //doing main tash + (void) prc_cleantitle(); (void) prc_modeuniprc(false); (void) par_modeunipar(false); (void) rou_modesubrou(false); + break; + default : //end of task proceed=false; break; } diff --git a/lib/subrou.c b/lib/subrou.c index aca5e46..ae0ddd9 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -14,7 +14,7 @@ //version definition #define VERSION "0.1" -#define RELEASE "9" +#define RELEASE "10" //Public variables PUBLIC int debug=0; //debug level diff --git a/lib/uniprc.c b/lib/uniprc.c index f07cef6..4ff3b29 100644 --- a/lib/uniprc.c +++ b/lib/uniprc.c @@ -21,11 +21,19 @@ #include "subrou.h" #include "uniprc.h" - //directory to set lock #define DIRLOCK "/var/run/"APPNAME -static _Bool modopen; //boolean module open/close +/*Process command override structure (proc) */ +typedef struct { + int max; //title max size + char *title; //title storage area + }TITLTYP; + +static TITLTYP *title=(TITLTYP *)0; //storage area for /proc + //title display +static _Bool modopen; //boolean module open/close + /* */ @@ -258,6 +266,96 @@ return childpid; #undef OPEP } /* + +*/ +/********************************************************/ +/* */ +/* Procedure to free used by "title" struct memory.*/ +/* */ +/********************************************************/ +void prc_cleantitle() + +{ +if (title!=(TITLTYP *)0) { + if (environ!=(char **)0) { + int i; + + for (i=0;environ[i]!=(char *)0;i++) { + (void) free(environ[i]); + environ[i]=(char *)0; + } + (void) free(environ); + environ=(char **)0; + } + (void) free(title); + title=(TITLTYP *)0; + } +} +/* + +*/ +/********************************************************/ +/* */ +/* */ +/* Procedure to find and limit space to */ +/* be used as status information available */ +/* from proc (ps ax) */ +/* */ +/********************************************************/ +void prc_preptitle(int argc,char *argv[],char *env[]) + +{ +char *lastend; + +lastend=(char *)0; +(void) prc_cleantitle(); +title=(TITLTYP *)calloc(1,sizeof(TITLTYP)); +if (argv!=(char **)0) { + int i; + + title->title=argv[0]; + for (i=1;imax=lastend-title->title; +} +/* +^L +*/ +/********************************************************/ +/* */ +/* Procedure to update title information. */ +/* Title information is avalable via the */ +/* CLI (commande line interface) "ps" */ +/* */ +/********************************************************/ +void prc_settitle(const char *fmt,...) + +{ +va_list args; + +va_start(args,fmt); +if ((title!=(TITLTYP *)0)&&(title->title!=(char *)0)) { + (void) memset(title->title,'\000',title->max); + (void) vsnprintf(title->title,title->max,fmt,args); + } +va_end(args); +} +/* ^L */ /********************************************************/ diff --git a/lib/uniprc.h b/lib/uniprc.h index 0bea404..d188ae2 100644 --- a/lib/uniprc.h +++ b/lib/uniprc.h @@ -13,9 +13,20 @@ #include "subrou.h" +extern char **environ; //context enviromenent variable + #define LCK_UNLOCK 0 /*unlocking request */ #define LCK_LOCK 1 /*locking requets */ +//To clean the command line title area +extern void prc_cleantitle(); + +//To duplicate enviromenet library and used as command line data +extern void prc_preptitle(int argc,char *argv[],char *env[]); + +//To insert a string in the command area +extern void prc_settitle(const char *fmt,...); + //To allow application to core dump is memory is //big trouble need to be investigated extern void prc_allow_core_dump();