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