howm
howm
helper.h
Go to the documentation of this file.
1 #ifndef HELPER_H
2 #define HELPER_H
3 
4 #include <stdio.h>
5 
21 #define MOVE_RESIZE_MASK (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | \
22  XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT)
23 
24 #define LENGTH(x) (unsigned int)(sizeof(x) / sizeof(*x))
25 
26 #define FFT(c) (c->is_transient || c->is_floating || c->is_fullscreen)
27 
28 #define UNUSED(x) (void)(x)
29 
30 #define MAX_FD(x, y) ((x) > (y) ? (x + 1) : (y + 1))
31 
40 #define LOG_LEVEL LOG_DEBUG
41 
43 #define DEBUG_ENABLE false
44 
45 /* Add comments so that splint ignores this as it doesn't support variadic
46  * macros.
47  */
48 /*@ignore@*/
49 
50 #define LOG_DEBUG 1
51 #define LOG_INFO 2
52 #define LOG_WARN 3
53 #define LOG_ERR 4
54 #define LOG_NONE 5
55 
56 #if LOG_LEVEL == LOG_DEBUG
57 #define log_debug(M, ...) fprintf(stderr, "[DEBUG] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
58 #else
59 #define log_debug(x, ...) do {} while (0)
60 #endif
61 
62 
63 #if LOG_LEVEL <= LOG_INFO
64 #define log_info(M, ...) fprintf(stderr, "[INFO] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
65 #else
66 #define log_info(x, ...) do {} while (0)
67 #endif
68 
69 #if LOG_LEVEL <= LOG_WARN
70 #define log_warn(M, ...) fprintf(stderr, "[WARN] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
71 #else
72 #define log_warn(x, ...) do {} while (0)
73 #endif
74 
75 #if LOG_LEVEL <= LOG_ERR
76 #define log_err(M, ...) fprintf(stderr, "[ERROR] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
77 #else
78 #define log_err(x, ...) do {} while (0)
79 #endif
80 /*@end@*/
81 
82 
83 #endif