OSSP CVS Repository

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

Check-in Number: 2190
Date: 2002-Jun-26 16:42:53 (local)
2002-Jun-26 14:42:53 (UTC)
User:ms
Branch:
Comment: Relocate debug config dumping logic and clean up terminal option handling.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc.c      1.32 -> 1.33     3 inserted, 4 deleted
ossp-pkg/rc/rc.h      1.29 -> 1.30     11 inserted, 10 deleted
ossp-pkg/rc/rc_cliopt.c      1.11 -> 1.12     2 inserted, 3 deleted
ossp-pkg/rc/rc_config.c      1.17 -> 1.18     14 inserted, 4 deleted
ossp-pkg/rc/rc_proc.c      1.4 -> 1.5     5 inserted, 0 deleted

ossp-pkg/rc/rc.c 1.32 -> 1.33

--- rc.c 2002/06/26 14:11:16     1.32
+++ rc.c 2002/06/26 14:42:53     1.33
@@ -43,14 +43,13 @@
     ex_try {                /* Configuration block                        */
         configNew();        /* Construct a new configuration              */
         configLoad(argc, (const char **)argv); /* Load cli, env, and conf */
-        configDebug();      /* FIXME Remove FIXME */
         configVerify();     /* Test for usage, help, and version options  */
     }
     ex_catch(Except) {      /* Exceptions of the configuration block      */
-        TRACE("Hopla, in config exception block");
-        if ((rc_return_t)Except.ex_value == RC_ERR_USE) {
+        if ((rc_return_t)Except.ex_value == RC_WRN_TRM)
+            exit(0);
+        else 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,\


ossp-pkg/rc/rc.h 1.29 -> 1.30

--- rc.h 2002/06/26 14:11:16     1.29
+++ rc.h 2002/06/26 14:42:53     1.30
@@ -52,16 +52,17 @@
 
 /* Rc return codes */
 typedef enum {
-    RC_OK      = 1, /* Success                  */
-    RC_ERR_0   = 2, /* Error base               */
-    RC_ERR_USE = 3, /* Usage error              */
-    RC_ERR_MEM = 4, /* Memory error             */
-    RC_ERR_SYS = 5, /* System error (see errno) */
-    RC_ERR_IO  = 6, /* Input/output error       */
-    RC_ERR_INT = 7, /* Internal error           */
-    RC_WRN_0   = 8, /* Warning base             */
-    RC_WRN_OWR = 9, /* Overwrite warning        */
-    RC_WRN_NUL = 10 /* NULL pointer warning     */
+    RC_OK      = 1,  /* Success                  */
+    RC_ERR_0   = 2,  /* Error base               */
+    RC_ERR_USE = 3,  /* Usage error              */
+    RC_ERR_MEM = 4,  /* Memory error             */
+    RC_ERR_SYS = 5,  /* System error (see errno) */
+    RC_ERR_IO  = 6,  /* Input/output error       */
+    RC_ERR_INT = 7,  /* Internal error           */
+    RC_WRN_0   = 8,  /* Warning base             */
+    RC_WRN_OWR = 9,  /* Overwrite warning        */
+    RC_WRN_NUL = 10, /* NULL pointer warning     */
+    RC_WRN_TRM = 11  /* Request to terminate app */
 } rc_return_t;
 
 /* Config function prototypes */


ossp-pkg/rc/rc_cliopt.c 1.11 -> 1.12

--- rc_cliopt.c  2002/06/26 14:11:16     1.11
+++ rc_cliopt.c  2002/06/26 14:42:53     1.12
@@ -290,12 +290,11 @@
         }
     }
 
-    if (cliOpt < -1) {
-        /* An error occurred during option processing */
+    if (cliOpt < -1) { /* The option given was not found in the index */
         fprintf(stderr, "%s: %s\n",
                 popt_badoption(m_Optcon, POPT_BADOPTION_NOALIAS),
                 popt_strerror(cliOpt));
-        return(RC_THROW(RC_ERR_INT));
+        return(RC_THROW(RC_ERR_USE));
     }
 
     return(RC_THROW(RC_OK));


ossp-pkg/rc/rc_config.c 1.17 -> 1.18

--- rc_config.c  2002/06/26 14:11:16     1.17
+++ rc_config.c  2002/06/26 14:42:53     1.18
@@ -255,20 +255,30 @@
 rc_return_t configVerify(void)
 {
     ex_t Except;
+    short bStop = FALSE;
 
     try { /* Basic checks of version, usage, and help options */
-        if (configGetval(RC_VER_VAL))
+        if (configGetval(RC_VER_VAL)) {
             fprintf(stdout, "OSSP rc %s\n", RC_VERSION);
-        if (configGetval(RC_USE_VAL))
+            bStop = TRUE;
+        }
+        if (configGetval(RC_USE_VAL)) {
             clioptPrintusage();
-        if (configGetval(RC_HLP_VAL))
+            bStop = TRUE;
+        }
+        if (configGetval(RC_HLP_VAL)) {
             clioptPrintusage(); /* FIXME Replace with real help FIXME */
+            bStop = TRUE;
+        }
     }
     catch(Except) {
         rethrow;
     }
 
-    return(RC_THROW(RC_OK));
+    if (bStop)                          /* Did user request a non-operation?  */
+        return(RC_THROW(RC_WRN_TRM));   /* Yes, so terminate after handling.  */
+    else
+        return(RC_THROW(RC_OK));        /* No, we should continue processing. */
 }
 
 /***************************************


ossp-pkg/rc/rc_proc.c 1.4 -> 1.5

--- rc_proc.c    2002/06/26 14:11:16     1.4
+++ rc_proc.c    2002/06/26 14:42:53     1.5
@@ -36,6 +36,7 @@
 #include <sys/stat.h>
 
 #include "rc.h"         /* Public interfaces        */
+#include "rc_config.h"  /* Option definitions       */
 
 
 /************************************************
@@ -135,6 +136,10 @@
 ************************************************/
 rc_return_t procRun(rc_proc_t *pRc)
 {
+    
+    if (configGetval(RC_DBG_VAL)) /* Dump the running config table */
+        configDebug();            /* if debug switch is turned on  */
+
     scriptDump(pRc->m_pScript);
 
     return(RC_THROW(RC_OK));

CVSTrac 2.0.1