/* Display aid,aidhud usage parameter */
/* */
/********************************************************/
-static void usage_aid(char *name)
+static void usage_aid(char *name,const char *select)
{
+static char *options[]={
+ "c[-c config]",
+ "d[-d debug]",
+ "f[-f]",
+ "h[-h]",
+ "r[-r root]",
+ "v[-v]",
+ (char *)0
+ };
+
+static char *details[]={
+ "-c config\t: set config file\n",
+ "-d level\t: debug level [1-10]\n",
+ "-f\t\t: start program in foreground (CLI) mode\n",
+ "-h\t\t: print this help message\n",
+ "-r root\t\t: root working directory\n",
+ "-v\t\t: Print program version number\n",
+ (char *)0
+ };
+
+int num;
+char msg[200];
+char explain[1000];
+
+num=0;
+(void) sprintf(explain,"\twhere:\n");
(void) fprintf(stderr,"usage:\n ");
-(void) fprintf(stderr,"%s\t"
- "[-d debug] "
- "[-c config] "
- "[-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-c config\t: set config file\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");
+(void) sprintf(msg,"%s\t",name);
+while (options[num]!=(char *)0) {
+ char *ptr;
+
+ ptr=options[num];
+ if (strchr(select,*ptr)!=(char *)0) {
+ ptr++;
+ (void) strcat(msg," ");
+ (void) strcat(msg,ptr);
+ (void) strcat(explain,"\t\t");
+ (void) strcat(explain,details[num]);
+ }
+ num++;
+ }
+(void) fprintf(stderr,"%s\n",msg);
+if ((select!=(char *)0)&&(strlen(select)>0)) {
+ (void) fprintf(stderr,"%s",explain);
+ }
}
/*
^L
break;
case 'h' : //requestion program help
(void) fprintf(stderr,"%s-%s\n",shortname,rou_getversion());
- (void) usage_aid(shortname);
+ (void) usage_aid(shortname,optstring);
params=par_freeparams(params);
break;
case 'r' :
(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);
+ (void) usage_aid(shortname,optstring);
params=par_freeparams(params);
break;
}