From 53266a0d5a76ca15b624b02ebe0fd16c5eb08a7e Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Fri, 31 Jul 2020 21:31:03 +0100 Subject: [PATCH] include/: refactor header files --- include/{ => common}/buf.h | 0 include/common/bug-on.h | 13 +++++++++++++ include/rcxml.h | 10 +--------- src/common/buf.c | 2 +- src/config/rcxml.c | 1 + src/theme/xbm/parse.c | 2 +- tools/rcxml/Makefile | 11 +++++++++-- tools/rcxml/rcxml-print-nodenames.c | 2 +- 8 files changed, 27 insertions(+), 14 deletions(-) rename include/{ => common}/buf.h (100%) create mode 100644 include/common/bug-on.h diff --git a/include/buf.h b/include/common/buf.h similarity index 100% rename from include/buf.h rename to include/common/buf.h diff --git a/include/common/bug-on.h b/include/common/bug-on.h new file mode 100644 index 00000000..c9c3be51 --- /dev/null +++ b/include/common/bug-on.h @@ -0,0 +1,13 @@ +#ifndef __LABWC_BUG_ON_H +#define __LABWC_BUG_ON_H + +#define BUG_ON(condition) \ + do { \ + if ((condition) != 0) { \ + fprintf(stderr, "Badness in %s() at %s:%d\n", \ + __func__, __FILE__, __LINE__); \ + } \ + } while (0) + +#endif /* __LABWC_BUT_ON_H */ + diff --git a/include/rcxml.h b/include/rcxml.h index dcc496d6..eda86a13 100644 --- a/include/rcxml.h +++ b/include/rcxml.h @@ -7,15 +7,7 @@ #include #include -#include "buf.h" - -#define BUG_ON(condition) \ - do { \ - if ((condition) != 0) { \ - fprintf(stderr, "Badness in %s() at %s:%d\n", \ - __func__, __FILE__, __LINE__); \ - } \ - } while (0) +#include "common/buf.h" struct keybind { uint32_t modifiers; diff --git a/src/common/buf.c b/src/common/buf.c index 87c0d30f..9e79f30c 100644 --- a/src/common/buf.c +++ b/src/common/buf.c @@ -1,4 +1,4 @@ -#include "buf.h" +#include "common/buf.h" void buf_init(struct buf *s) { diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 653d62c6..dbdf9f84 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -12,6 +12,7 @@ #include "rcxml.h" #include "config/config-dir.h" +#include "common/bug-on.h" static bool in_keybind = false; static bool is_attribute = false; diff --git a/src/theme/xbm/parse.c b/src/theme/xbm/parse.c index 7cc25784..89bbbcf0 100644 --- a/src/theme/xbm/parse.c +++ b/src/theme/xbm/parse.c @@ -11,7 +11,7 @@ #include #include -#include "buf.h" +#include "common/buf.h" #include "theme/xbm/parse.h" /* TODO: should be window.active.button.unpressed.image.color */ diff --git a/tools/rcxml/Makefile b/tools/rcxml/Makefile index 507db21b..9973985e 100644 --- a/tools/rcxml/Makefile +++ b/tools/rcxml/Makefile @@ -9,11 +9,18 @@ LDFLAGS += `xml2-config --libs` LDFLAGS += `pkg-config --cflags --libs glib-2.0 wayland-server xkbcommon` PROGS = rcxml-print-nodenames +SRC = \ + rcxml-print-nodenames.c \ + ../../src/config/rcxml.c \ + ../../src/config/config-dir.c \ + ../../src/common/buf.c \ + ../../src/config/keybind.c + all: $(PROGS) -rcxml-print-nodenames: rcxml-print-nodenames.c - $(CC) $(CFLAGS) -o $@ $^ ../../src/config/rcxml.c ../../src/common/buf.c ../../src/config/keybind.c $(LDFLAGS) +rcxml-print-nodenames: $(SRC) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) clean: rm -f $(PROGS) diff --git a/tools/rcxml/rcxml-print-nodenames.c b/tools/rcxml/rcxml-print-nodenames.c index 3e51db88..d5df9f38 100644 --- a/tools/rcxml/rcxml-print-nodenames.c +++ b/tools/rcxml/rcxml-print-nodenames.c @@ -3,7 +3,7 @@ #include #include "rcxml.h" -#include "buf.h" +#include "common/buf.h" struct rcxml rc = { 0 };