Alex Burger wrote:
[EMAIL PROTECTED] wrote:

Agreed.  Very nicely done, Alex!

I recommend one small change:
don't define char *temp ahead of the ifdef.
Other than that, the patch looks good!!
[and familiar, too %^)]


Yes! It is similar to Dirk Krause's patch 850782, except it is using setenv instead of a static variable. Same idea also as Bernhard Penz's except his used functions to be called for each variable. I think everyone likes the idea of SOFTWARE\Net-SNMP\xxx. :)

I like it because it looks like the standard/traditional way for a windows application. I like it for the same reason I have been pushing Program Files (echos of discussions to come? Perhaps).


The other patches you sent me from Dirk and yourself look like they are for moving the contents of snmp.conf etc into the registry and for defining a new storage mechanism for the data, similar to the environment space, correct? I've only skimmed over that one. I'm not ready for that yet!

BTW, if we apply these changes, we (I) still need to update all the Perl scripts to load from the registry instead of only the environment variables. Until that is done, we can't switch over the installer script to use the registry.

The applications can still use the registry though.

Should I put it in to main even though the Perl scripts may not be ready before pre2? I am assuming pre2 will be out very soon..

Alex


I would say sure. Add the registry keys and patch the applications to use them. Once the Perl modules are ready then yank the environment variables. That allows for time to catch anything quirky or unforseen with the registry code...no wait...nothing quirky or unforseen ever happens on Windows...what am I thinking.... ;-)


Andy

From: Andy Smith <[EMAIL PROTECTED]>
Date: 2004/10/07 Thu PM 07:25:12 EDT
To: Alex Burger <[EMAIL PROTECTED]>
CC: Mike Slifcak <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: Re: Win32: Registry support


That works for me. I would much rather see wrapper functions than continue adding to the #ifdef hell in application code. Very nice!

Andy

Alex Burger wrote:

Attached is a patch that allows you to use the registry to store variables that are normally defined as environment variables.

A new function called netsnmp_getenv has been created in tools.c. For *nix it simply returns what getenv() would return.

For Windows it:

-returns a pointer to the environment variable if it is defined

-otherwise looks up the variable in HKCU\Software\Net-SNMP. If it is defined, it copies it to the environment variable and then returns a pointer to the environment variable

-otherwise looks up the variable in HKLM\Software\Net-SNMP. If it is defined, it copies it to the environment variable and then returns a pointer to the environment variable

-otherwise returns a NULL

The real environment variables are looked at first because when specifying MIBDIRS on the command line, it actually stores the passed values in the environment variable which is then used when reading the MIB files during initialization. This means if you have the env vars defined, the registry values will be ignored.

The following variables can be defined in the registry under either HKCU\Software\Net-SNMP or HKLM\Software\Net-SNMP:

-MIBDIRS
-MIBFILES
-MIBS
-PREFIX
-SNMP_PERSISTENT_FILE
-SNMPCONFPATH
-HOME

For example:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Net-SNMP]
"SNMPCONFPATH"="d:/Program Files/Net-SNMP/etc/snmp"
"SNMP_PERSISTENT_FILE"="c:/temp/persist/snmpd.conf"
"MIBDIRS"="$HOME;c:/usr/share/snmp/mibs"
"HOME"="c:/mymibs"

(HOME would not normally be used, but I used the above as a test and it worked. Use -Dfixup_mib_directory to see it. Use -Dread_config and -Dinit_mib to see the others).

By using this patch and modifying the NSIS installer script, the problem of having to reboot the machine after registering the snmpd and snmptrapd service will go away (tested).

I think this is the simplest way to implement registry access for Windows. It will work with any environment variable as long as netsnmp_getenv is used instead of getenv so if any are added in the future, we don't have to worry about porting it to the registry.

What does everyone think?

Alex






-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to