
The definition of SMI_LOAD_DEFAULT does not make much sense. If at all, it should be defined to be "" but even then you really like to pass the name of your application.
Understood. Life is never as simple as it seems.
I still think the code example on the website must be changed to either smiInit("") or smiInit("example") - because with smiInit(NULL) the example will never output anything useful.
Roddy Pratt Technical Director
Rascular Technology Ltd. The Oak House, Whitcott Keysett, Craven Arms, UK. SY7 8QE Tel: +44 1588 640971 Fax: +44 8432161733
www.rascular.com
On 14 December 2010 15:43, Juergen Schoenwaelder < j.schoenwaelder@jacobs-university.de> wrote:
On Tue, Dec 14, 2010 at 02:04:22PM +0000, Roddy Pratt wrote:
The one parameter to smiInit does two functions: It's a tag that controls which of the MIBS specified in the configuration file are loaded - and it also determines if the default configuration file is read or ignored.
This
'overloading' of one parameter with two functions was the cause of my confusion.
I have two independent simple "patches" which might help, without modifying/extending the library interface, or breaking current code.
In smi.h, add a #define
#define SMI_LOAD_DEFAULT "__Default" // Use this with smiInit to
load
the default configuration file
Users can then call smiInit(SMI_LOAD_DEFAULT) rather than smiInit("foo"). More readable, and should help make the intention clear. The actual code
for
smiInit() remains unchanged.
Nope, this would be wrong:
smiInit(NULL) - no configuration file is loaded at all smiInit("foo") - all global configuration statements and all configuration statements tagged "foo:" are loaded smiInit("foo:bar") - all global configuration statements and all configuration statements tagged "foo:" are loaded into the MIB module dataset "bar".
The definition of SMI_LOAD_DEFAULT does not make much sense. If at all, it should be defined to be "" but even then you really like to pass the name of your application.
My second 'patch' is to the code example on the website: http://www.ibr.cs.tu-bs.de/projects/libsmi/example.html?lang=de
As you can see, it calls smiInit(NULL), so won't load any MIBs. This
example
is probably why I struggled in the first place. I believe this should
call
smiInit("foo"); // force loading of default config // or, if you like the previous suggestion, smiInit(SMI_LOAD_DEFAULT)
As explained above, "foo" causes the default and the "foo" config to be loaded. Here is an attempt to improve the documentation:
The smiInit() function should be the first SMI function called in an application. It initializes internal structures. If tag is not NULL, the global configuration file and (on UNIX systems) a user configuration file are read implicitly, if existent. All global statements and those statements with a tag (a "tag:" prefix) that matches the tag argument are executed (see also CONFIGURATION FILES below). If tag is NULL, no configuration files are read, leaving full control to the application. smiInit() returns zero on success, or otherwise a negative value.
The smiInit() function can also be used to support multiple different sets of loaded MIB modules. In this case, the tag argument consists of the tag followed by a colon and a name to differentiate the loaded MIB module data sets. Any library function call subsequent to an smiInit("tag:dataset") call is using the most recently selected data set.
/js
-- Juergen Schoenwaelder Jacobs University Bremen gGmbH Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany Fax: +49 421 200 3103 http://www.jacobs-university.de/