OSSP CVS Repository

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

ossp-pkg/rc/rc_cliopt.c 1.5 -> 1.6

--- rc_cliopt.c  2002/04/22 15:22:39     1.5
+++ rc_cliopt.c  2002/04/23 12:30:29     1.6
@@ -34,9 +34,11 @@
 #include "rc.h"
 #include "rc_const.h"
 #include "rc_config.h"
-#include "popt.h"       /* OSSP popt options library    */
+#include "popt.h"                       /* OSSP popt options library*/
 
-static char *m_szOptuples[RC_NUMOPTS];  /* Option name value tuples */
+static char *m_pszOptuples[RC_NUMOPTS]; /* Option name value tuples */
+static char *m_szRcfile = NULL;         /* rc file                  */
+static char *m_szSec   = NULL;          /* Section names            */
 
 
 /***************************************
@@ -55,7 +57,7 @@
 /*    s_pBintab->pOptlist->pvData = NULL;
     s_pBintab->pOptlist->pvNext = NULL;*/
 
-    memset(m_szOptuples, NULL, sizeof(m_szOptuples));
+    memset(m_pszOptuples, NULL, sizeof(m_pszOptuples));
 
 TRACE("cliopt constructed.\n");
     return(RC_THROW(RC_OK));
@@ -70,7 +72,25 @@
     if (!(Optname < RC_NUMOPTS))    /* Validate option range    */
         RC_THROW(RC_ERR_USE);
 
-    return((const char *)m_szOptuples[Optname]);
+    return((const char *)m_pszOptuples[Optname]);
+}
+
+/***************************************
+* clioptGetrcfile(void)                *
+* Command line rc file accessor        *
+***************************************/
+const char *clioptGetrcfile(void)
+{
+    return((const char *)m_szRcfile);
+}
+
+/***************************************
+* clioptGetsec(void)                   *
+* Command line section accessor        *
+***************************************/
+const char *clioptGetsec(void)
+{
+    return((const char *)m_szSec);
 }
 
 /***************************************
@@ -84,67 +104,68 @@
     switch (cliOption) {
     /* Begin concrete (digital) options */
         case RC_USE_VAL:
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Usage    */
+            m_pszOptuples[cliOption] = strdup("1");          /* Usage    */
+            return(RC_THROW(RC_ERR_USE));
         case RC_DBG_VAL:
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Debug    */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Debug    */
         case RC_VER_VAL:
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Version  */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Version  */
         case RC_EVL_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Eval     */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Eval     */
         case RC_HLP_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Help     */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Help     */
         case RC_INF_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Info     */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Info     */
         case RC_LBL_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Label    */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Label    */
         case RC_PRN_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Print    */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Print    */
         case RC_SIL_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Silent   */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Silent   */
         case RC_RAW_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Raw      */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Raw      */
         case RC_VRB_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Verbose  */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Verbose  */
         case RC_EXC_VAL:                                   
-            m_szOptuples[cliOption] = strdup("1"); break;   /* Exec     */
+            m_pszOptuples[cliOption] = strdup("1"); break;   /* Exec     */
 
     /* Begin abstract (nondigital) options */
         case RC_LOC_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Locations    */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Locations    */
         case RC_CNF_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Conf file    */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Conf file    */
         case RC_FNC_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Func file    */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Func file    */
         case RC_QRY_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Format       */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Format       */
         case RC_TMP_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Temp dir     */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Temp dir     */
         case RC_OWN_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* User name    */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* User name    */
         case RC_GRP_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Group name   */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Group name   */
         case RC_MSK_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Umask        */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Umask        */
 
         case RC_ASS_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Assignregex  */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Assignregex  */
         case RC_DEF_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Labelregex   */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Labelregex   */
         case RC_REF_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Refregex     */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Refregex     */
         case RC_PRM_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Paramregex   */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Paramregex   */
         case RC_TRM_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Termregex    */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Termregex    */
 
         case RC_NCF_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Configname   */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Configname   */
         case RC_CMN_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Commonname   */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Commonname   */
         case RC_DFL_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Defaultname  */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Defaultname  */
         case RC_ERR_VAL:
-            m_szOptuples[cliOption] = strdup(szArg); break; /* Errorname    */
+            m_pszOptuples[cliOption] = strdup(szArg); break; /* Errorname    */
         default : break;
     }
 
@@ -274,14 +295,21 @@
         rethrow;
     }*/
 
-    for (i = 0; i < RC_NUMOPTS; i++)                      /* Free the tuple */
-        m_szOptuples[i] ? free(m_szOptuples[i]) : RC_NOP; /* or do nothing  */
+    for (i = 0; i < RC_NUMOPTS; i++) {  /* Free the tuples themselves */
+        if (m_pszOptuples[i]) {
+            free(m_pszOptuples[i]);
+            m_pszOptuples[i] = NULL;
+        }
+    }
 
-    memset(m_szOptuples, NULL, sizeof(m_szOptuples));     /* Clear tuples   */
+    if (m_szRcfile)                     /* Free the rc file arg       */
+        free(m_szRcfile);
+    if (m_szSec)                        /* Free the section name arg  */
+        free(m_szSec);
 
 /* FIXME BEGIN DEBUG */
 for (i = 0; i < RC_NUMOPTS; i++)
-    if (m_szOptuples[i])
+    if (m_pszOptuples[i])
         TRACE("Problem! Destructor failed!\n");
 TRACE("cliopt destructed.\n");
 /* FIXME END DEBUG */

CVSTrac 2.0.1