OSSP CVS Repository

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

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

--- rc_config.c  2002/04/22 12:16:39     1.11
+++ rc_config.c  2002/04/22 15:22:39     1.12
@@ -29,11 +29,13 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "rc.h"
 #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        */
 
 
 /***************************************
@@ -109,6 +111,45 @@
     return(NULL);   /* Not reached  */
 }
 
+/***************************************
+* configSummarize(void)                *
+* Configuration summary                *
+***************************************/
+const char *configSummarize(void)
+{
+    ex_t Except;
+    int i = 0;
+    int bCaught = FALSE;
+
+    while (!bCaught) {
+        ex_try {    /* FIXME Not threadsafe, wrap with crit section */
+            if (configGetval(i)) { /* FIXME Is realloc portable here? */
+                /* FIXME Unportable kludge to ensure storage FIXME */
+                m_szSummary = realloc(m_szSummary, sizeof("OptionXXis") + \
+                    sizeof(configGetname(i)) + sizeof(configGetval(i) + 8));
+                if (!(strcmp(configGetval(i), "1"))) {
+                    strcat(m_szSummary, "Option ");
+                    strcat(m_szSummary, configGetname(i));
+                    strcat(m_szSummary, " is on.\n");
+                }
+                else {
+                    strcat(m_szSummary, "Option ");
+                    strcat(m_szSummary, configGetname(i));
+                    strcat(m_szSummary, " is ");
+                    strcat(m_szSummary, configGetval(i));
+                    strcat(m_szSummary, ".\n");
+                }
+            }
+        }           /* FIXME Not threadsafe, wrap with crit section */
+        ex_catch(Except) {  /* Breaks the otherwise endless loop above */
+            bCaught = TRUE;
+        }
+        i++;
+    }
+
+    return ((const char *)m_szSummary);
+}
+
 /************************************************
 * configLoad(int, char **)                      *
 * Load a configuration                          *
@@ -146,6 +187,8 @@
     if (--m_nLocks == 0) {          /* If m_nLocks is 0, deallocate */
         ex_try {                    /* FIXME, not thread-safe       */
             clioptDestruct();
+            if (m_szSummary)
+                free(m_szSummary);
         }
         ex_catch(Except) {
             rethrow;

CVSTrac 2.0.1