[Nagiosplug-devel] nagios-plugins.ini & argument parsing
dermoth at aei.ca
Sat Mar 15 21:17:51 CET 2008
-----BEGIN PGP SIGNED MESSAGE-----
On 14/03/08 08:01 PM, Thomas Guyot-Sionnest wrote:
> 2. Do something similar for parse_ini.c. I'm not an expert, but I guess
> the best way would be to pass a linked list from the ini parser to the
> argument parser (not yet written), and then the argument parser can
> build a replacement array that can be processed by process_arguments.
> Ideally the C plugins should have a library that do all the work behind
> the scenes like Nagios::Plugins, but in the mean time it would be nice
> to have ini file support.
I started implementing this part and fixing bugs in parse_ini.c, and so
far I went across two big differences in ini handling:
1. N::P allows '#' to be part of the argument, while parse_ini treat
them as comments. Since it's a one-line change I left the original
behavior in parse_ini (mainly because the ini/tests have to be changed
too) but I really think '#' should be allowed.
2. N::P seems do do some smart parsing based on getopts... in either
case it doesn't allow parameters without values (no '=' sign on the
line) while parse_ini does, and append the '=' is there's one.
While I'd be tempted to follow N::P's behavior for #2, this raises one
question: N::P is able to make the difference between parameters that
requires arguments and those that don't and could smartly insert an
empty arg if there's nothing after the '='. This means we wouldn't be
able to emulate empty arguments in the c plugins as long as we don't
implement N::P-like argument parsing routines.
Alternatively, I could append an empty argument when there's a '=' and
keep allowing empty arguments, but for consistency I guess we should
also allow it in N::P (Moth may want to use the config. This also seems
to be a violation of the ini standard. In a perfect world we could just
always add empty arguments but it seems that some backward-compatibility
stuff fail with that. I could also reject lines missing a '=' and never
add an argument since there aren't many plugins that require empty args...
So for now I'll follow N::P behavior and never add an empty argument.
The code isn't even used yet so this is still open for comments.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the Devel