X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/5749c5e97a8b984720cef75f328944270874d713..c81b3f9cfa09bcf212214f006d879585774619e2:/src/tools.h diff --git a/src/tools.h b/src/tools.h index 315d965..c2c10ff 100644 --- a/src/tools.h +++ b/src/tools.h @@ -20,13 +20,28 @@ #ifndef TOOLS_H_ #define TOOLS_H_ +#include + void tool_init(const char *name, int argc, char **argv); void tool_version(void); const char *tool_invocation(void); -#define errmsg(fmt, ...) (\ - fprintf(stderr, "%s: " fmt, tool_invocation(), __VA_ARGS__)\ -) +/* + * Error messaging routines. Similar to printf, but writes to standard error + * and prefixes the output with the program invocation name, automatically + * appending a newline. If err is 0, the result of strerror(errno) is also + * printed in a similar manner as perror. If err is positive, then that + * value is used instead of errno. + */ +int tool_verr(int err, const char *fmt, va_list ap); +int tool_err(int err, const char *fmt, ...); + +/* + * Messaging routines similar to the above, except that they write to standard + * output and there is no option to include strerror(errno). + */ +int tool_vmsg(const char *fmt, va_list ap); +int tool_msg(const char *fmt, ...); #endif