--- rc.c 2002/04/22 15:22:39 1.21
+++ rc.c 2002/04/24 16:47:07 1.22
@@ -27,41 +27,72 @@
** rc.c: Run-command processor ISO C source file
*/
-#include <stdio.h>
#include <stdlib.h>
-#include "rc.h"
-#include "rc_const.h"
-#include "rc_private.h"
+#include "rc.h" /* Public interfaces */
+#include "rc_const.h" /* Englisch string constants */
+#include "rc_config.h" /* For RC_XXX_VAL definitions */
+/************************************************
+* rcIntro(void) *
+* Introduction to rc: help, usage, or version *
+************************************************/
+rc_return_t rcIntro(void)
+{
+ ex_t Except;
+
+ ex_try { /* Basic checks of version, usage, and help options */
+ if (configGetval(RC_VER_VAL))
+ fprintf(stdout, "OSSP rc %s\n", RC_VERSION);
+ if (configGetval(RC_USE_VAL))
+ clioptPrintusage();
+ if (configGetval(RC_HLP_VAL))
+ clioptPrintusage(); /* FIXME Replace with real help FIXME */
+ }
+ ex_catch(Except) {
+ rethrow;
+ }
+
+ return(RC_THROW(RC_OK));
+}
+
+/************************************************
+* main(int, char **) *
+* Main rc control block *
+************************************************/
int main(int argc, char *argv[])
{
ex_t Except;
+ rc_t *pRc = NULL;
ex_try {
- configConstruct();
- configLoad(argc, argv);
- /* Processing the runcommands */
-/* procOpen(szRcfilist, szFuncfilist, szTmpfile);
- procConf(szEnvass, szSecdef, szSecref, szSecparm);
- procParse();
- procSec(szUmask, szUser, szGroup);
- procEval(szSection1, szSection2, ...);
- configDestruct();*/
+ configNew(); /* Construct a new configuration */
+ configLoad(argc, argv); /* Read configuration from cli, env, and conf */
+ configDebug(); /* FIXME Remove FIXME */
+ rcIntro(); /* Test for usage, help, and version options */
+
+/* pRc = procNew();
+ procReadrc(pRc);
+ procReadfuncs(pRc);
+ procReadtmp(pRc);
+ for (i = 0; i < clioptGetseclen; procSection(pRc, configGetsec(i)));
+ procParse(pRc); /- Script generation -/
+ procOut(pRc); /- [Execute|Evaluate|Print] script -/
+
+ procDelete(pRc);*/
+ configDelete();
}
ex_catch(Except) {
- if ((int)Except.ex_value == RC_CNF_VRS)
- fprintf(stdout, "This is OSSP rc, version %s\n", RC_VERSION);
-
- 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);
+ if ((rc_return_t)Except.ex_value == RC_ERR_USE) {
+ clioptPrintusage();
+ }
+ else
+ 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);
exit(1); /* Failure */
}
-fprintf(stderr, configSummarize());
-configDestruct(); /* FIXME Remove, allow first scope */
-TRACE("No exceptions caught\n");
exit(0); /* Success */
}
|