2 * vim:ts=4:sw=4:expandtab
4 * i3 - an improved dynamic tiling window manager
5 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
14 /* Get the maximum/minimum of x and y */
16 #define MAX(x, y) ((x) > (y) ? (x) : (y))
18 #define MIN(x, y) ((x) < (y) ? (x) : (y))
20 #define STARTS_WITH(string, len, needle) (((len) >= strlen((needle))) && strncasecmp((string), (needle), strlen((needle))) == 0)
31 /* Securely free single-linked list */
32 #define FREE_SLIST(l, type) \
34 type *walk = SLIST_FIRST(l); \
35 while (!SLIST_EMPTY(l)) { \
36 SLIST_REMOVE_HEAD(l, slist); \
38 walk = SLIST_FIRST(l); \
42 /* Securely free tail queue */
43 #define FREE_TAILQ(l, type) \
45 type *walk = TAILQ_FIRST(l); \
46 while (!TAILQ_EMPTY(l)) { \
47 TAILQ_REMOVE(l, TAILQ_FIRST(l), tailq); \
49 walk = TAILQ_FIRST(l); \
56 /* Use cool logging macros */
57 #define DLOG(fmt, ...) \
59 if (config.verbose) { \
60 printf("[%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
64 /* We will include libi3.h which define its own version of ELOG.
65 * We want *our* version, so we undef the libi3 one. */
69 #define ELOG(fmt, ...) \
71 fprintf(stderr, "[%s:%d] ERROR: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \