utils: use O_PATH when opening /dev
[project/procd.git] / service / service.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_SERVICE_H
16 #define __PROCD_SERVICE_H
17
18 #include <libubox/avl.h>
19 #include <libubox/vlist.h>
20 #include <libubox/list.h>
21
22 extern struct avl_tree services;
23
24 struct vrule {
25         struct avl_node avl;
26         char *option;
27         char *rule;
28 };
29
30 struct validate {
31         struct avl_node avl;
32         struct list_head list;
33
34         char *package;
35         char *type;
36
37         struct avl_tree rules;
38 };
39
40 struct service {
41         struct avl_node avl;
42         const char *name;
43
44         struct blob_attr *trigger;
45         struct vlist_tree instances;
46         struct list_head validators;
47 };
48
49 void service_validate_add(struct service *s, struct blob_attr *attr);
50 void service_validate_dump(struct blob_buf *b, struct service *s);
51 void service_validate_dump_all(struct blob_buf *b, char *p, char *s);
52 int service_start_early(char *name, char *cmdline);
53 void service_validate_del(struct service *s);
54 void service_event(const char *type, const char *service, const char *instance);
55
56 #endif