I came to look on read_config.c. This I found:

get_persistent_directory-const:
        The persdir variable should really be const since
        NETSNMP_PERSISTENT_DIRECTORY is a string constant

register_config_handler-empty-is-app:
        Currently you can call register_config_handler with NULL as the
        type_param argument and then you get registered in the
        application config file or you can call it with a colon
        separated list of config files and then you get registered in
        those config files.
        There is no way to say that you want to be in both the
        application and some specific config files. I have added that
        the empty string is parsed as the application config file.
        Earlier strtok was used for parsing and since strtok ignores
        empty strings no current application is affected.

netsnmp_register_service_handlers-register-multi:
        Use register_config_handler-empty-is-app to register the
        defTarget and defDomain tokens in both the application and the
        snmp config files.

/MF
Index: clean/snmplib/read_config.c
===================================================================
--- clean.orig/snmplib/read_config.c	2006-12-17 23:42:05.000000000 +0100
+++ clean/snmplib/read_config.c	2006-12-17 23:43:01.000000000 +0100
@@ -967,7 +967,7 @@
 {
     if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
 				      NETSNMP_DS_LIB_PERSISTENT_DIR)) {
-        char *persdir = netsnmp_getenv("SNMP_PERSISTENT_DIR");
+        const char *persdir = netsnmp_getenv("SNMP_PERSISTENT_DIR");
         if (NULL == persdir)
             persdir = NETSNMP_PERSISTENT_DIRECTORY;
         set_persistent_directory(persdir);
Index: clean/snmplib/read_config.c
===================================================================
--- clean.orig/snmplib/read_config.c	2006-12-17 23:43:01.000000000 +0100
+++ clean/snmplib/read_config.c	2006-12-17 23:43:07.000000000 +0100
@@ -172,9 +172,11 @@
  * management of where to put tokens as the module or modules get more complex
  * in regard to handling token registrations.
  *
- * @param type_param the configuration file used, e.g., if snmp.conf is the file
- *                 where the token is located use "snmp" here.
- *                 If NULL the configuration file used will be snmpd.conf.
+ * @param type_param the configuration file used, e.g., if snmp.conf is the
+ *                 file where the token is located use "snmp" here.
+ *                 Multiple colon separated tokens might be used.
+ *                 If NULL or "" then the configuration file used will be
+ *                 <application>.conf.
  *
  * @param token    the token being parsed from the file.  Must be non-NULL.
  *
@@ -199,12 +201,10 @@
                         void (*releaser) (void), const char *help)
 {
     struct config_files **ctmp = &config_files;
-    struct config_line **ltmp, *ltmp2;
-    const char     *type = type_param;
-    char           *cptr, buf[STRINGMAX];
-    char           *st;
+    struct config_line  **ltmp;
+    const char           *type = type_param;
 
-    if (type == NULL) {
+    if (type == NULL || *type == '\0') {
         type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
 				     NETSNMP_DS_LIB_APPTYPE);
     }
@@ -212,15 +212,20 @@
     /*
      * Handle multiple types (recursively)
      */
-    cptr = strchr( type, ':' );
-    if (cptr) {
-        strncpy(buf, type, STRINGMAX);
+    if (strchr(type, ':')) {
+        struct config_line *ltmp2 = NULL;
+        char                buf[STRINGMAX];
+        char               *cptr = buf;
+        strncpy(buf, type, STRINGMAX - 1);
         buf[STRINGMAX - 1] = '\0';
-        ltmp2 = NULL;
-        cptr = strtok_r(buf, ":", &st);
         while (cptr) {
-            ltmp2 = register_config_handler(cptr, token, parser, releaser, help);
-            cptr  = strtok_r(NULL, ":", &st);
+            char* c = cptr;
+            cptr = strchr(cptr, ':');
+            if(cptr) {
+                *cptr = '\0';
+                ++cptr;
+            }
+            ltmp2 = register_config_handler(c, token, parser, releaser, help);
         }
         return ltmp2;
     }
Index: clean/snmplib/snmp_service.c
===================================================================
--- clean.orig/snmplib/snmp_service.c	2006-12-17 03:05:54.000000000 +0100
+++ clean/snmplib/snmp_service.c	2006-12-17 03:06:00.000000000 +0100
@@ -337,11 +337,11 @@
 void
 netsnmp_register_service_handlers(void)
 {
-    register_config_handler(NULL, "defDomain",
+    register_config_handler("snmp:", "defDomain",
 			    netsnmp_register_user_domain,
 			    netsnmp_clear_user_domain,
 			    "application domain");
-    register_config_handler(NULL, "defTarget",
+    register_config_handler("snmp:", "defTarget",
 			    netsnmp_register_user_target,
 			    netsnmp_clear_user_target,
 			    "application domain target");
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to