#ifndef TOOLS_H_
#define TOOLS_H_
+#include <stdarg.h>
+
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