OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc.c versions 1.35 and 1.36
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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 */
 }
 

CVSTrac 2.0.1