OSSP CVS Repository

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

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

--- rc_config.c  2002/04/09 17:01:54     1.8
+++ rc_config.c  2002/04/11 16:52:45     1.9
@@ -31,12 +31,9 @@
 #include <stdlib.h>
 
 #include "rc.h"
-#include "rc_private.h"
 #include "rc_const.h"               /* String constants                 */
-#include "rc_config.h"              /* Config types and constants       */
-#include "rc_option.h"              /* Option operations rely on popt   */
 
-static rc_config_t *s_pInst = NULL; /* Singleton config instance        */
+static int s_nLocks = 0;            /* Server locks, not thread-safe FIXME  */
 
 
 /***************************************
@@ -47,36 +44,38 @@
 {
     ex_t Except;
 
-    if (s_pInst == NULL) {                  /* If we don't have one     */
-        s_pInst = malloc(sizeof(s_pInst));  /* yet, then allocate       */
-        if (!s_pInst)                       /* a config instance        */
-            return(RC_THROW(RC_ERR_MEM));
-        s_pInst->m_nLocks = 0;
-
-        ex_try {
-            clioptConstruct();              /* Make a config instance   */
+    if (s_nLocks == 0) {                    /* If we don't have one yet */
+        ex_try {                            /* then construct a new one */
+            clioptConstruct();              /* Member cliopt instance   */
         }
         ex_catch(Except) {
             rethrow;
         }
     }
-    s_pInst->m_nLocks++;                    /* FIXME not threadsafe     */
+    s_nLocks++;                             /* FIXME not threadsafe     */
 
     return(RC_THROW(RC_OK));
 }
 
 /***************************************
-* configGetXXXX(void)                  *
+* configGetoptval(rc_opt_t)            *
 * Configuration accessors              *
 ***************************************/
-short configGetvers(void)
+const char *configGetoptval(rc_opt_t Optname)
 {
     ex_t Except;
-    short nVer = 0;
+    char *szTemp = NULL;
 
-    if (s_pInst != NULL) {
+    if (s_nLocks) {                         /* Make sure config exists      */
         ex_try {
-
+            if ((szTemp = (char *)clioptGetval(Optname)))
+                return((const char *)szTemp);
+/*            else if (szTemp = envoptGetval(Optname))
+                return((const char *)szTemp);
+            else if (szTemp = cnfoptGetval(Optname))
+                return((const char *)szTemp);*/
+            else
+                return(NULL);               /* Special case when not found  */
         }
         ex_catch(Except) {
             rethrow;
@@ -84,10 +83,8 @@
     }
     else {
         RC_THROW(RC_ERR_USE);
-        return(NULL);
     }
-
-    return(nVer);
+    return(NULL);   /* Not reached  */
 }
 
 /************************************************
@@ -98,13 +95,10 @@
 {
     ex_t Except;
 
-    ex_try {    /* Parse through each type of option           */
-/* FIXME s_pInst->pOpt will hold a copy of the command line */
-//        coptParse(s_pInst->pOpt);   /* First priority options  */
-//        eoptParse(s_pInst->pOpt);   /* Medium priority options */
-//        foptParse(s_pInst->pOpt);   /* Low priority options    */
-        coptParse(argc, argv); /* FIXME Patch for now */
-/* FIXME s_pInst->pOpt will hold a copy of the command line */
+    ex_try {    /* Parse option groups in order of priority     */
+        clioptParse(argc, argv);        /* Command line options */
+/*        envoptParse(s_nLocks->pOpt);*/    /* Environment options  */
+/*        cnfoptParse(s_nLocks->pOpt);*/    /* Configfile options   */
     }
     ex_catch(Except) {
         rethrow;
@@ -127,17 +121,12 @@
 {
     ex_t Except;
 
-    if (s_pInst) {
-        if (--s_pInst->m_nLocks == 0) { /* If m_nLocks is 0, dealloc    */
-            ex_try {                    /* FIXME, not thread-safe       */
-                clioptDestruct();
-            }
-            ex_catch(Except) {
-                rethrow;
-            }
-
-            free(s_pInst);              /* Deallocate config and        */
-            s_pInst = NULL;             /* clear its reference          */
+    if (--s_nLocks == 0) {          /* If m_nLocks is 0, deallocate */
+        ex_try {                    /* FIXME, not thread-safe       */
+            clioptDestruct();
+        }
+        ex_catch(Except) {
+            rethrow;
         }
     }
     else

CVSTrac 2.0.1