From 8f2a555f900228b531edba5e44e2e0cd7e8fe61e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 31 Dec 2021 23:20:41 +0100 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 common.h (limited to 'common.h') diff --git a/common.h b/common.h new file mode 100644 index 0000000..b2d0a4e --- /dev/null +++ b/common.h @@ -0,0 +1,57 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include + +#define EXIT_STYLE 1 +#define EXIT_WARNING 2 +#define EXIT_UNSPECIFIED 3 +#define EXIT_NONCONFIRMING 4 +#define EXIT_UNDEFINED 5 +#define EXIT_CRITICAL 6 +#define EXIT_ERROR 7 + + +#define LIST_WARNING_CLASSES(X)\ + X(WC_MAKEFILE, "makefile", INFORM)\ + X(WC_EXTRA_MAKEFILE, "extra-makefile", WARN)\ + X(WC_CMDLINE, "cmdline", WARN)\ + X(WC_TEXT, "text", WARN) + + +enum action { + IGNORE, + INFORM, + WARN +}; + +enum warning_class { +#define X(ENUM, NAME, ACTION) ENUM, + LIST_WARNING_CLASSES(X) +#undef X + NUM_WARNING_CLASS +}; + +struct warning_class_data { + const char *name; + enum action action; +}; + +struct line { + char *data; + size_t len; + const char *path; + size_t lineno; +}; + + +extern int exit_status; + + +/* ui.c */ +extern struct warning_class_data warning_classes[]; +void xprintwarningf(enum warning_class class, int severity, const char *fmt, ...); +#define printinfof(CLASS, ...) xprintwarningf(CLASS, EXIT_STYLE, __VA_ARGS__) +#define warnf_warning(CLASS, ...) xprintwarningf(CLASS, EXIT_WARNING, __VA_ARGS__) +#define warnf_unspecified(CLASS, ...) xprintwarningf(CLASS, EXIT_UNSPECIFIED, __VA_ARGS__) +#define warnf_undefined(CLASS, ...) xprintwarningf(CLASS, EXIT_UNDEFINED, __VA_ARGS__) +void printerrorf(const char *fmt, ...); -- cgit v1.2.3-70-g09d2