--- rc.c 2002/05/13 16:57:00 1.25
+++ rc.c 2002/05/22 09:47:27 1.26
@@ -41,26 +41,18 @@
int main(int argc, char *argv[])
{
ex_t Except;
- rc_proc_t *pProc = NULL;
+ rc_anal_t *pAnal = NULL; /* Holds preprocessed configuration */
- ex_try {
+ ex_try { /* Configuration and abstract analysis block */
configNew(); /* Construct a new configuration */
configLoad(argc, argv); /* Read configuration from cli, env, and conf */
configDebug(); /* FIXME Remove FIXME */
configVerify(); /* Test for usage, help, and version options */
- pProc = procNew();
- procReadtmp(pProc, configGetval(RC_TMP_VAL));
-/* procReadfuncs(pProc, configGetval(RC_FNC_VAL));
- procReadrc(pProc, configGetrcfile());
- for (i = 0; i < clioptGetseclen; procSection(pProc, configGetsec(i++)));
- procParse(pProc); /- Script generation -/
- procRun(pProc);*/ /* [Execute|Evaluate|Print] script */
-
- procDelete(pProc);
- configDelete();
+ pAnal = analNew(); /* Construct a new analyzer */
+ analParse(pAnal); /* Preprocess the analyzed configuration */
}
- ex_catch(Except) {
+ ex_catch(Except) { /* Exceptions thrown during configuration and analysis */
if ((rc_return_t)Except.ex_value == RC_ERR_USE) {
clioptPrintusage();
}
@@ -68,8 +60,38 @@
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 */
+ exit(1); /* Report failure and exit the program */
+ }
+
+ ex_try { /* Main script building and processing block */
+ rc_script_t *pScript = NULL;
+ rc_proc_t *pProc = NULL;
+
+ pScript = scriptNew(pAnal); /* Construct a new script */
+ scriptBuild(pScript);
+
+ pProc = procNew(pScript); /* Construct a new processor */
+ procRun(pProc); /* [Execute|Evaluate|Print] script */
+ procDelete(pProc); /* Destroy the processor */
+ scriptDelete(pScript); /* Destroy the script */
+ }
+ ex_catch(Except) { /* Exceptions thrown during script processing */
+ 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); /* Return failure */
+ }
+
+ ex_try { /* Start shutdown of main program */
+ analDelete(pAnal); /* Destroy the analyzer */
+ configDelete(); /* Destroy the configuration */
+ }
+ ex_catch(Except) { /* Exceptions thrown during program shutdown */
+ 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); /* Return failure */
}
- exit(0); /* Success */
+ exit(0); /* Return success */
}
|