OSSP CVS Repository

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

ossp-pkg/rc/rc_config.c 1.19 -> 1.20

--- rc_config.c  2002/06/27 15:35:58     1.19
+++ rc_config.c  2002/07/01 15:03:33     1.20
@@ -35,35 +35,43 @@
 #include "rc_const.h"               /* String constants                     */
 
 static int m_nLocks = 0;            /* Server locks, not thread-safe FIXME  */
-static char *m_szSummary = NULL;    /* Configuration summary storage        */
 
 
 /***************************************
-* configDebug(void)                    *
-* Debug a configuration                *
-* Warning: There is no error checking  *
-*          or debugging of this        *
-*          debugger block              *
+* configInfo(void)                     *
+* Print the configuration information  *
 ***************************************/
-void configDebug(void)
+rc_return_t configInfo(void)
 {
-    int i = 0;
     ex_t Except;
-    char **szTemp = NULL;
+    int i = 0;
+    char **pszTemp = NULL;  /* For holding the section string vector        */
 
     try {
         fprintf(stderr, "Run command file: %s\n", configGetrcfile());
 
-        szTemp = (char **)configGetsecs();
+        pszTemp = (char **)configGetsecs();
         fprintf(stderr, "Sections:");
-        while (szTemp[i])
-            fprintf(stderr, " %s", szTemp[i++]);
+        for (i = 0; pszTemp[i]; i++)
+            fprintf(stderr, " %s", pszTemp[i]);
+        fputc('\n', stderr);
 
-        fprintf(stderr, "\n%s", configSummarize());
+        /* FIXME Not threadsafe, wrap with crit section */
+        for (i = 0; i < RC_NUMOPTS; i++) {
+            if (configGetval(i) == NULL); /* NOP */
+            else if (!(strcmp(configGetval(i), "1")))
+                fprintf(stderr, "Option %s is on.\n", configGetname(i));
+            else
+                fprintf(stderr, "Option %s is %s.\n", configGetname(i),\
+                    configGetval(i));
+        }
     }
+
     catch(Except) {
         rethrow;
     }
+
+    return(RC_THROW(RC_OK));
 }
 
 /***************************************
@@ -181,58 +189,6 @@
     return(NULL);   /* Not reached  */
 }
 
-/***************************************
-* configSummarize(void)                *
-* Configuration summary                *
-***************************************/
-const char *configSummarize(void)
-{
-    ex_t Except;
-    int i = 0;
-    char *szTemp = NULL;
-
-    /* Make sure we start with a blank slate */
-    if (m_szSummary) {
-        free(m_szSummary);
-        m_szSummary = NULL;
-    }
-
-    for (i = 0; i < RC_NUMOPTS; i++)
-    {
-        try { /* FIXME Not threadsafe, wrap with crit section */
-            if (configGetval(i) == NULL); /* NOP */
-            else if (!(strcmp(configGetval(i), "1"))) {
-                szTemp = calloc(1, (m_szSummary ? strlen(m_szSummary) : 0) + strlen(configGetval(i)));
-                if (m_szSummary)
-                    strcpy(szTemp, m_szSummary);
-                strcat(szTemp, "Option ");
-                strcat(szTemp, configGetname(i));
-                strcat(szTemp, " is on.\n");
-                if (m_szSummary)
-                    free(m_szSummary);
-                m_szSummary = szTemp;
-            }
-            else {
-                szTemp = malloc(strlen(m_szSummary) + strlen(configGetval(i)));
-                strcpy(szTemp, m_szSummary);
-                strcat(szTemp, "Option ");
-                strcat(szTemp, configGetname(i));
-                strcat(szTemp, " is ");
-                strcat(szTemp, configGetval(i));
-                strcat(szTemp, ".\n");
-                if (m_szSummary)
-                    free(m_szSummary);
-                m_szSummary = szTemp;
-            }
-        }               /* FIXME Not threadsafe, wrap with crit section */
-        catch(Except) {     /* Breaks the otherwise endless loop above  */
-            rethrow;
-        }
-    }
-
-    return ((const char *)m_szSummary);
-}
-
 /************************************************
 * configLoad(int, const char **)                *
 * Load a configuration                          *
@@ -264,25 +220,29 @@
     short bStop = FALSE;
 
     try { /* Basic checks of version, usage, and help options */
-        if (configGetval(RC_VER_VAL)) {
-            fprintf(stdout, "OSSP rc %s\n", RC_VERSION);
-            bStop = TRUE;
-        }
         if (configGetval(RC_USE_VAL)) {
             clioptPrintusage();
             bStop = TRUE;
         }
-        if (configGetval(RC_HLP_VAL)) {
+        else if (configGetval(RC_HLP_VAL)) {
             clioptPrintusage(); /* FIXME Replace with real help FIXME */
             bStop = TRUE;
         }
+        else if (configGetval(RC_VER_VAL)) {
+            fprintf(stdout, "OSSP rc %s\n", RC_VERSION);
+            bStop = TRUE;
+        }
+        else if (configGetval(RC_INF_VAL)) {
+            configInfo();
+            bStop = TRUE;
+        }
     }
     catch(Except) {
         rethrow;
     }
 
     if (bStop)                          /* Did user request a non-operation?  */
-        return(RC_THROW(RC_WRN_TRM));   /* Yes, so terminate after handling.  */
+        return(RC_THROW(RC_ERR_TRM));   /* Yes, so terminate after handling.  */
     else
         return(RC_THROW(RC_OK));        /* No, we should continue processing. */
 }
@@ -298,8 +258,6 @@
     if (--m_nLocks == 0) {          /* If m_nLocks is 0, deallocate */
         try {                       /* FIXME, not thread-safe       */
             clioptDelete();
-            if (m_szSummary)
-                free(m_szSummary);
         }
         catch(Except) {
             rethrow;

CVSTrac 2.0.1