proceed=true;
while (proceed==true) {
switch (phase) {
- case 0 : //initialising process
- (void) rou_modesubrou(true);
- (void) uni_modeunipar(true);
- break;
- case 1 : //checking parameters
- if ((params=par_getparams(argc,argv,"d:hr:v"))==(ARGTYP *)0) {
+ case 0 : //checking parameters
+ if ((params=par_getparams(argc,argv,"d:fhr:v"))==(ARGTYP *)0) {
phase=999; //no need to go further
}
break;
+ case 1 : //initialising process
+ (void) rou_modesubrou(true);
+ (void) uni_modeunipar(true);
+ break;
default : //end of task
(void) uni_modeunipar(false);
(void) rou_modesubrou(false);
static void usage_aid(char *name)
{
-(void) fprintf(stderr,"%s-%s\n",name,rou_getversion());
(void) fprintf(stderr,"usage:\n ");
(void) fprintf(stderr,"%s\t"
"[-d debug] "
+ "[-f] "
"[-h] "
"[-r root] "
"[-v] "
"\n",name);
(void) fprintf(stderr,"\twhere:\n");
(void) fprintf(stderr,"\t\t-d level\t: debug level [1-10]\n");
+(void) fprintf(stderr,"\t\t-f\t\t: start program in foreground (CLI) mode\n");
(void) fprintf(stderr,"\t\t-h\t\t: print this help message\n");
(void) fprintf(stderr,"\t\t-r root\t\t: root working directory\n");
(void) fprintf(stderr,"\t\t-v\t\t: Print program version number\n");
}
/*
-\f
-*/
-/********************************************************/
-/* */
-/* Display aidobj usage parameter */
-/* */
-/********************************************************/
-static void usage_obj(char *name)
-
-{
-(void) fprintf(stderr,"%s-%s\n",name,rou_getversion());
-(void) fprintf(stderr,"usage:\n ");
-(void) fprintf(stderr,"%s\t"
- "[-d debug] "
- "[-h] "
- "[-r root] "
- "[-v] "
- "\n",name);
-(void) fprintf(stderr,"\twhere:\n");
-(void) fprintf(stderr,"\t\t-d level\t: debug level [1-10]\n");
-(void) fprintf(stderr,"\t\t-h\t\t: print this help message\n");
-(void) fprintf(stderr,"\t\t-r root\t\t: root working directory\n");
-(void) fprintf(stderr,"\t\t-v\t\t: Print program version number\n");
-}
-/*
-\f
-*/
-/********************************************************/
-/* */
-/* Display a list of parameters available according*/
-/* the name used to call the backd program */
-/* */
-/********************************************************/
-static int usage(char *name)
-
-{
-static char *prg[]={
- "aid",
- "aidhud",
- "aidobj",
- (char *)0
- };
-int status;
-int seq;
-char *shortname;
-
-status=0;
-if ((shortname=strrchr(name,'/'))==(char *)0)
- shortname=name;
-else
- shortname++;
-for (seq=0;prg[seq]!=(char *)0;seq++) {
- if (strcmp(prg[seq],shortname)==0)
- break;
- }
-switch (seq) {
- case 0 : //aid
- case 1 : //aidhud
- (void) usage_aid(name);
- break;
- case 2 : //aidobj
- (void) usage_obj(name);
- break;
- default :
- (void) usage_aid(name); //unexpected default!
- break;
- }
-return status;
-}
-/*
^L
*/
/********************************************************/
{
ARGTYP *params;
+char *shortname;
int c;
params=initparams();
+if ((shortname=strrchr(argv[0],'/'))==(char *)0)
+ shortname=argv[0];
+else
+ shortname++;
opterr=0; //no error message from getopt library routine
while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) {
switch(c) {
debug=atoi(optarg);
(void) rou_alert(1,"debug level is now '%d'",debug);
break;
- case 'f' : //foreground mode
+ case 'f' : //background/daemon mode
foreground=true;
+ (void) fprintf(stderr,"%s-%s, foreground mode requested\n",shortname,rou_getversion());
break;
case 'h' : //requestion program help
- (void) usage(argv[0]);
+ (void) fprintf(stderr,"%s-%s\n",shortname,rou_getversion());
+ (void) usage_aid(shortname);
params=par_freeparams(params);
break;
case 'r' :
rootdir=strdup(optarg);
break;
case 'v' :
- (void) fprintf(stderr,"%s Version <%s>\n",argv[0],rou_getversion());
+ (void) fprintf(stderr,"%s:\tVersion <%s>\n",shortname,rou_getversion());
(void) exit(0); //just display version
break;
default :
- (void) usage(argv[0]);
- (void) rou_alert(0,"\"%s\" unexpected argument designator",argv[optind-1]);
+ (void) fprintf(stderr,"%s-%s\n",shortname,rou_getversion());
+ (void) fprintf(stderr,"\"%s\" unexpected argument designator\n\n",
+ argv[optind-1]);
+ (void) usage_aid(shortname);
params=par_freeparams(params);
break;
}