Blame


1 fb1a36c0 2022-01-09 op /*
2 fb1a36c0 2022-01-09 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 fb1a36c0 2022-01-09 op *
4 fb1a36c0 2022-01-09 op * Permission to use, copy, modify, and distribute this software for any
5 fb1a36c0 2022-01-09 op * purpose with or without fee is hereby granted, provided that the above
6 fb1a36c0 2022-01-09 op * copyright notice and this permission notice appear in all copies.
7 fb1a36c0 2022-01-09 op *
8 fb1a36c0 2022-01-09 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 fb1a36c0 2022-01-09 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 fb1a36c0 2022-01-09 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 fb1a36c0 2022-01-09 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 fb1a36c0 2022-01-09 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 fb1a36c0 2022-01-09 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 fb1a36c0 2022-01-09 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 fb1a36c0 2022-01-09 op */
16 fb1a36c0 2022-01-09 op
17 fb1a36c0 2022-01-09 op #ifndef UTILS_H
18 fb1a36c0 2022-01-09 op #define UTILS_H
19 fb1a36c0 2022-01-09 op
20 fb1a36c0 2022-01-09 op #define MIN(a, b) ((a) < (b) ? (a) : (b))
21 fb1a36c0 2022-01-09 op
22 fb1a36c0 2022-01-09 op struct imsgev {
23 fb1a36c0 2022-01-09 op struct imsgbuf ibuf;
24 fb1a36c0 2022-01-09 op void (*handler)(int, short, void *);
25 fb1a36c0 2022-01-09 op struct event ev;
26 fb1a36c0 2022-01-09 op short events;
27 fb1a36c0 2022-01-09 op };
28 fb1a36c0 2022-01-09 op
29 fb1a36c0 2022-01-09 op void *xmalloc(size_t);
30 fb1a36c0 2022-01-09 op void *xcalloc(size_t, size_t);
31 fb1a36c0 2022-01-09 op char *xstrdup(const char *);
32 fb1a36c0 2022-01-09 op void *xmemdup(const void *, size_t);
33 fb1a36c0 2022-01-09 op
34 fb1a36c0 2022-01-09 op const char *pp_msg_type(uint8_t);
35 fb1a36c0 2022-01-09 op const char *pp_qid_type(uint8_t);
36 fb1a36c0 2022-01-09 op
37 fb1a36c0 2022-01-09 op void hexdump(const char *, uint8_t *data, size_t len);
38 fb1a36c0 2022-01-09 op
39 fb1a36c0 2022-01-09 op void imsg_event_add(struct imsgev *);
40 fb1a36c0 2022-01-09 op int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t,
41 fb1a36c0 2022-01-09 op int, const void *, uint16_t);
42 fb1a36c0 2022-01-09 op
43 fb1a36c0 2022-01-09 op #endif