[Nagiosplug-devel] printf calls in library functions
Matthias Eble
matthias.eble at mailing.kaufland-informationssysteme.com
Tue Jul 24 18:42:38 CEST 2007
Hi Holger,
> I'd document that by not returning success/failure from such
> functions at all (that is, by returning void if the function doesn't
> return other stuff). Obviously, in this case the dying function must
> print the reason for the suicide to STDOUT itself.
I don't know if defining this for a complete function is possible.
Of course it would be clearer.
> However, if the caller might want to handle some error condition
> himself, I'd never die within that function, as all callers will then
> always have to check for success anyway. Another reason not to die
> might be that the desired exit status might depend on the context. In
> these cases, I'd only return failure and make the error message
> available to the caller by using some global errno(3)-like variable or
> some errstr() function which uses a static errno within the library, for
> example. (If we extended our libraries to provide the caller with a
> struct holding the library state, this struct could hold the errno
> variable, but this would of course require more work.)
Good idea.
> Whether or not library functions should optionally provide verbose
> output and how to implement that seems to be an unrelated issue to me.
> (I'd simply use a global variable, initialized to "no verbose output"
> optionally modifiable by the caller.)
To me it would be fine, too, if we only put sth. out in libraries, when
a global verbosity variable variable is set. The plugin output could
then be handled with some errstr()-like functionality.
Matthias
More information about the Devel
mailing list