1#include <stdlib.h>
2
3#include <swc.h>
4
5#include "util.h"
6#include "tohu.h"
7
8void die(int ret, const char* fmt, ...)
9{
10 va_list ap;
11
12 fprintf(stderr, "tohu: ");
13
14 va_start(ap, fmt);
15 vfprintf(stderr, fmt, ap);
16 va_end(ap);
17
18 fputc('\n', stderr);
19 fflush(stderr);
20
21 exit(ret);
22}
23
24void _log(FILE* fd, const char* fmt, ...)
25{
26 va_list ap;
27
28 fprintf(fd, "tohu: ");
29
30 va_start(ap, fmt);
31 vfprintf(fd, fmt, ap);
32 va_end(ap);
33
34 fputc('\n', fd);
35 fflush(fd);
36}
37
38void sig_handler(int s)
39{
40 (void)s;
41
42 if (wm.dpy)
43 wl_display_terminate(wm.dpy);
44}