OSSP CVS Repository

ossp - Check-in [2203]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2203
Date: 2002-Jun-28 20:23:10 (local)
2002-Jun-28 18:23:10 (UTC)
User:ms
Branch:
Comment: Cleaned main program block and consolidated error handling into rcError(). Also made output of missing section warnings optional according to --debug flag.
Tickets:
Inspections:
Files:
ossp-pkg/rc/00TODO      1.27 -> 1.28     1 inserted, 0 deleted
ossp-pkg/rc/rc.c      1.35 -> 1.36     39 inserted, 43 deleted
ossp-pkg/rc/rc_proc.c      1.8 -> 1.9     1 inserted, 1 deleted

ossp-pkg/rc/00TODO 1.27 -> 1.28

--- 00TODO       2002/06/28 17:43:23     1.27
+++ 00TODO       2002/06/28 18:23:10     1.28
@@ -33,6 +33,7 @@
   Write interlocking increment for thread-safe increments.
   Convert some normal assert() to real runtime checks.
   Use str_hash von ossp str or static RC_XXX_VAL array from rc_option.h.
+  Restore lost multiple location merging logic.
 
 Implementation
   Correct assertion, sanity check, and if () checks according to one standard.


ossp-pkg/rc/rc.c 1.35 -> 1.36

--- rc.c 2002/06/28 17:43:23     1.35
+++ rc.c 2002/06/28 18:23:10     1.36
@@ -33,38 +33,52 @@
 
 
 /************************************************
-* main(int, char **)                            *
-* Main rc control block                         *
+* rcError(ex_t)                                 *
+* Main rc error handler                         *
 ************************************************/
-int main(int argc, char *argv[])
+void rcError(ex_t Localerr)
 {
-    ex_t Except;
-
-    try {                /* Configuration block                        */
-        configNew();        /* Construct a new configuration              */
-        configLoad(argc, (const char **)argv); /* Load cli, env, and conf */
-        configVerify();     /* Test for usage, help, and version options  */
-    }
-    catch(Except) {      /* Exceptions of the configuration block      */
-        if ((rc_return_t)Except.ex_value == RC_WRN_TRM)
+    if (FAILED((rc_return_t)Localerr.ex_value)) { /* Error condition */
+        if ((rc_return_t)Localerr.ex_value == RC_WRN_TRM)
             exit(0);
-        else if ((rc_return_t)Except.ex_value == RC_ERR_USE)
+        else if ((rc_return_t)Localerr.ex_value == RC_ERR_USE)
             clioptPrintusage();
+        else if ((rc_return_t)Localerr.ex_value == RC_ERR_FNC)
+            fprintf(stderr, "    Error condition, function file could not be opened.\n");
+        else if ((rc_return_t)Localerr.ex_value == RC_ERR_DIR)
+            fprintf(stderr, "    Error condition, location dir could not be opened.\n");
+        else if ((rc_return_t)Localerr.ex_value == RC_ERR_RCF)
+            fprintf(stderr, "    Error condition, rc file could not be opened.\n");
         else
-        if (FAILED((rc_return_t)Except.ex_value)) { /* Error condition */
-            fprintf(stderr, "    Error condition in proc, class '%s',\n    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 */
-        }
+            fprintf(stderr, "    Error condition of class '%s',\n    exception %d in %s:%s():%d.\n", (char *)Localerr.ex_class, (int)Localerr.ex_value, Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
+        exit(1); /* Return failure */
+    }
 #ifdef DEBUG
-        else /* Warning condition */
-            fprintf(stderr, "    Warning condition in proc, class '%s',\n    exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line);
+    else        /* Warning condition */
+        fprintf(stderr, "    Warning condition of class '%s',\n    exception %d in %s:%s():%d.\n", (char *)Localerr.ex_class, (int)Localerr.ex_value, Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
 #else
-        else /* Warning condition */
-            RC_NOP;  /* No operation on warnings */
+    else        /* Warning condition */
+        RC_NOP; /* No operation on warnings */
 #endif
+}
+
+/************************************************
+* main(int, char **)                            *
+* Main rc control block                         *
+************************************************/
+int main(int argc, char *argv[])
+{
+    ex_t Except;
+
+    try {                       /* Configuration block                      */
+        configNew();            /* Construct a new configuration            */
+        configLoad(argc, (const char **)argv);   /* Load cli, env, and conf */
+        configVerify();         /* Test for usage, help and version options */
     }
+    catch(Except)               /* Exceptions of the configuration block    */
+        rcError(Except);
 
-    try { /* Main processing block, the script is built here */
+    try {                       /* Main processing block, script built here */
         rc_proc_t *pProc = NULL;
         pProc = procNew();      /* Construct a new processor, build script  */
         procPopulate(pProc);    /* Populate with run commands               */
@@ -72,27 +86,9 @@
         procDelete(pProc);      /* Destroy the processor                    */
         configDelete();         /* Destroy the configuration                */
     }
-    catch(Except) {  /* Error exceptions thrown during script processing */
-        if (FAILED((rc_return_t)Except.ex_value)) { /* Error condition */
-            if ((rc_return_t)Except.ex_value == RC_ERR_FNC)
-                fprintf(stderr, "    Error condition, function file could not be opened.\n");
-            else if ((rc_return_t)Except.ex_value == RC_ERR_DIR)
-                fprintf(stderr, "    Error condition, location dir could not be opened.\n");
-            else if ((rc_return_t)Except.ex_value == RC_ERR_RCF)
-                fprintf(stderr, "    Error condition, rc file could not be opened.\n");
-            else
-                fprintf(stderr, "    Error condition in proc, class '%s',\n    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 */
-        }
-#ifdef DEBUG
-        else /* Warning condition */
-            fprintf(stderr, "    Warning condition in proc, class '%s',\n    exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line);
-#else
-        else /* Warning condition */
-            RC_NOP;  /* No operation on warnings */
-#endif
-    }
+    catch(Except)               /* Exception thrown while script processing */
+        rcError(Except);
 
-    exit(0);        /* Return success */
+    exit(0);                    /* Return success */
 }
 


ossp-pkg/rc/rc_proc.c 1.8 -> 1.9

--- rc_proc.c    2002/06/28 17:43:23     1.8
+++ rc_proc.c    2002/06/28 18:23:10     1.9
@@ -132,7 +132,7 @@
 
             if (szSec) /* Only call append if the section lookup succeeded */
                 scriptAppend(pRc->m_pScript, szSec, strlen(szSec));
-            else
+            else if (configGetval(RC_DBG_VAL)) /* Only show when debug is set */
                 fprintf(stderr, "#Warning: Missing section '%s' in %s!\n", pRc->m_pAnal->m_pszSecs[i], pRc->m_pAnal->m_szRcs[nIter]);
 
             if (szSec) { /* Cleanup section string */

CVSTrac 2.0.1