]> git.sur5r.net Git - i3/i3/blob - include/util.h
Implement slog() and the LOG() macro, convert printf() to LOG()
[i3/i3] / include / util.h
1 /*
2  * vim:ts=8:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  *
6  * (c) 2009 Michael Stapelberg and contributors
7  *
8  * See file LICENSE for license information.
9  *
10  */
11 #include <xcb/xcb.h>
12
13 #include "data.h"
14
15 #ifndef _UTIL_H
16 #define _UTIL_H
17
18 #define exit_if_null(pointer, ...) { if (pointer == NULL) die(__VA_ARGS__); }
19 #define CIRCLEQ_NEXT_OR_NULL(head, elm, field) (CIRCLEQ_NEXT(elm, field) != CIRCLEQ_END(head) ? \
20                                                 CIRCLEQ_NEXT(elm, field) : NULL)
21 #define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? \
22                                                 CIRCLEQ_PREV(elm, field) : NULL)
23 /* ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that is,
24    delete the preceding comma */
25 #define LOG(fmt, ...) slog("%s:%d - " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
26
27
28 int min(int a, int b);
29 int max(int a, int b);
30 void slog(char *fmt, ...);
31 void die(char *fmt, ...);
32 void *smalloc(size_t size);
33 void *scalloc(size_t size);
34 char *sstrdup(const char *str);
35 void start_application(const char *command);
36 void check_error(xcb_connection_t *conn, xcb_void_cookie_t cookie, char *err_message);
37 void set_focus(xcb_connection_t *conn, Client *client);
38 void leave_stack_mode(xcb_connection_t *conn, Container *container);
39 void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode);
40 void warp_pointer_into(xcb_connection_t *conn, Client *client);
41 void toggle_fullscreen(xcb_connection_t *conn, Client *client);
42
43 #endif