get rid of perror() calls, use ERROR() instead
[project/procd.git] / procd.h
1 /*
2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 2.1
7 * as published by the Free Software Foundation
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15 #ifndef __PROCD_H
16 #define __PROCD_H
17
18 #include <libubox/uloop.h>
19 #include <libubox/utils.h>
20 #include <libubus.h>
21
22 #include <stdio.h>
23 #include <syslog.h>
24
25 #include "syslog.h"
26
27 #define __init __attribute__((constructor))
28
29 #define DEBUG(level, fmt, ...) do { \
30 if (debug >= level) \
31 fprintf(stderr, "procd: %s(%d): " fmt, __func__, __LINE__, ## __VA_ARGS__); \
32 } while (0)
33
34 #define LOG(fmt, ...) do { \
35 syslog(LOG_INFO, fmt, ## __VA_ARGS__); \
36 fprintf(stderr, "procd: "fmt, ## __VA_ARGS__); \
37 } while (0)
38
39 #define ERROR(fmt, ...) do { \
40 syslog(LOG_ERR, fmt, ## __VA_ARGS__); \
41 fprintf(stderr, "procd: "fmt, ## __VA_ARGS__); \
42 } while (0)
43
44 extern char *ubus_socket;
45
46 extern unsigned int debug;
47 void debug_init(void);
48
49 void procd_connect_ubus(void);
50 void ubus_init_service(struct ubus_context *ctx);
51 void ubus_init_log(struct ubus_context *ctx);
52 void ubus_init_system(struct ubus_context *ctx);
53 void ubus_notify_log(struct log_head *l);
54
55 void procd_state_next(void);
56 void procd_shutdown(int event);
57 void procd_early(void);
58 void procd_preinit(void);
59 void procd_coldplug(void);
60 void procd_signal(void);
61 void procd_inittab(void);
62 void procd_inittab_run(const char *action);
63
64 int mkdev(const char *progname, int progmode);
65
66 #endif