--- rc_cliopt.c 2002/04/22 12:16:39 1.4
+++ rc_cliopt.c 2002/04/22 15:22:39 1.5
@@ -74,15 +74,6 @@
}
/***************************************
-* clioptSummarize(void) *
-* Command line option summary *
-***************************************/
-const char *clioptSummarize(void)
-{
- return (NULL);
-}
-
-/***************************************
* clioptProcess(int) *
* Switch through available options *
* processing the corresponding option *
@@ -93,95 +84,68 @@
switch (cliOption) {
/* Begin concrete (digital) options */
case RC_USE_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Usage */
- break;
+ m_szOptuples[cliOption] = strdup("1"); break; /* Usage */
case RC_DBG_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Debug */
- break;
+ m_szOptuples[cliOption] = strdup("1"); break; /* Debug */
case RC_VER_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Version */
- break;
- case RC_EVL_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Eval */
- break;
- case RC_HLP_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Help */
- break;
- case RC_INF_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Info */
- break;
- case RC_LBL_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Label */
- break;
- case RC_PRN_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Print */
- break;
- case RC_SIL_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Silent */
- break;
- case RC_RAW_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Raw */
- break;
- case RC_VRB_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Verbose */
- break;
- case RC_EXC_VAL:
- m_szOptuples[cliOption] = strdup("1"); /* Exec */
- break;
+ m_szOptuples[cliOption] = strdup("1"); break; /* Version */
+ case RC_EVL_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Eval */
+ case RC_HLP_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Help */
+ case RC_INF_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Info */
+ case RC_LBL_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Label */
+ case RC_PRN_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Print */
+ case RC_SIL_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Silent */
+ case RC_RAW_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Raw */
+ case RC_VRB_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Verbose */
+ case RC_EXC_VAL:
+ m_szOptuples[cliOption] = strdup("1"); break; /* Exec */
+
/* Begin abstract (nondigital) options */
case RC_LOC_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Locations */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Locations */
case RC_CNF_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Conf file */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Conf file */
case RC_FNC_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Func file */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Func file */
case RC_QRY_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Format */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Format */
case RC_TMP_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Temp dir */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Temp dir */
case RC_OWN_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* User name */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* User name */
case RC_GRP_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Group name */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Group name */
case RC_MSK_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Umask */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Umask */
+
case RC_ASS_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Assign regex */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Assignregex */
case RC_DEF_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Label regex */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Labelregex */
case RC_REF_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Ref regex */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Refregex */
case RC_PRM_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Params regex */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Paramregex */
case RC_TRM_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Terminal regex */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Termregex */
+
case RC_NCF_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Config name */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Configname */
case RC_CMN_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Common name */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Commonname */
case RC_DFL_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Default name */
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Defaultname */
case RC_ERR_VAL:
- m_szOptuples[cliOption] = strdup(szArg); /* Error name */
- break;
- default :
- break;
+ m_szOptuples[cliOption] = strdup(szArg); break; /* Errorname */
+ default : break;
}
return(RC_THROW(RC_OK));
@@ -243,28 +207,35 @@
popt_setotheroptionhelp(optCon, "[options] <rcfile> <sections [args]>");
if (argc < 3) {
+ fprintf(stderr, "Please enter at least one rcfile and section.\n");
popt_printusage(optCon, stderr, 0);
return(RC_THROW(RC_ERR_USE));
}
/* Now do options processing */
- while ((cliOpt = popt_getnextopt(optCon)) >= 0)
- ex_try {
- clioptProcess(cliOpt, popt_getoptarg(optCon));
- }
- ex_catch(Except) {
- if ((rc_return_t)Except.ex_value != RC_ERR_USE)
- fprintf(stderr, "Nonusage exception: %d\n",\
- (rc_return_t)Except.ex_value);
-
- fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\
- (char *)Except.ex_class, *(int *)Except.ex_value,\
- Except.ex_file, Except.ex_func, Except.ex_line);
+ while ((cliOpt = popt_getnextopt(optCon)) >= 0) { /* Loop, each time */
+ ex_try { /* eating a new option */
+ clioptProcess(cliOpt, popt_getoptarg(optCon));
+ }
+ ex_catch(Except) {
+ if ((rc_return_t)Except.ex_value == RC_ERR_USE) {
+ popt_printusage(optCon, stderr, 0);
+ rethrow;
+ }
+ else { /* Some error condition probably deserves attention */
+ fprintf(stderr, "Class '%s' threw exception %d in %s:%s():\
+ %d.\n", (char *)Except.ex_class, *(int *)Except.ex_value,\
+ Except.ex_file, Except.ex_func, Except.ex_line);
+ rethrow;
+ }
+ }
}
+ /* At this point we should be finished parsing options, so now we use */
+ /* popt as a transport to read the user specified rcfile and sections. */
szCLIBuf = (char *)popt_getarg(optCon);
if ((szCLIBuf == NULL)) {
- fprintf(stderr, "Please specify at least one rcfile and section.\n");
+ fprintf(stderr, "Please enter at least one rcfile and section.\n");
popt_printusage(optCon, stderr, 0);
return(RC_THROW(RC_ERR_USE));
}
@@ -281,6 +252,7 @@
popt_freecontext(optCon);
return(RC_THROW(RC_OK));
}
+
/***************************************
* clioptDestruct(void) *
* Destruct a command line option *
|