]>
Commit | Line | Data |
---|---|---|
663996b3 MS |
1 | #pragma once |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2013 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
663996b3 MS |
22 | #include "sd-bus.h" |
23 | ||
db2df898 MP |
24 | #include "hashmap.h" |
25 | ||
663996b3 MS |
26 | enum bus_match_node_type { |
27 | BUS_MATCH_ROOT, | |
28 | BUS_MATCH_VALUE, | |
29 | BUS_MATCH_LEAF, | |
30 | ||
31 | /* The following are all different kinds of compare nodes */ | |
663996b3 | 32 | BUS_MATCH_SENDER, |
60f067b4 | 33 | BUS_MATCH_MESSAGE_TYPE, |
663996b3 MS |
34 | BUS_MATCH_DESTINATION, |
35 | BUS_MATCH_INTERFACE, | |
36 | BUS_MATCH_MEMBER, | |
37 | BUS_MATCH_PATH, | |
38 | BUS_MATCH_PATH_NAMESPACE, | |
39 | BUS_MATCH_ARG, | |
40 | BUS_MATCH_ARG_LAST = BUS_MATCH_ARG + 63, | |
41 | BUS_MATCH_ARG_PATH, | |
42 | BUS_MATCH_ARG_PATH_LAST = BUS_MATCH_ARG_PATH + 63, | |
43 | BUS_MATCH_ARG_NAMESPACE, | |
44 | BUS_MATCH_ARG_NAMESPACE_LAST = BUS_MATCH_ARG_NAMESPACE + 63, | |
13d276d0 MP |
45 | BUS_MATCH_ARG_HAS, |
46 | BUS_MATCH_ARG_HAS_LAST = BUS_MATCH_ARG_HAS + 63, | |
663996b3 MS |
47 | _BUS_MATCH_NODE_TYPE_MAX, |
48 | _BUS_MATCH_NODE_TYPE_INVALID = -1 | |
49 | }; | |
50 | ||
51 | struct bus_match_node { | |
52 | enum bus_match_node_type type; | |
53 | struct bus_match_node *parent, *next, *prev, *child; | |
54 | ||
55 | union { | |
56 | struct { | |
57 | char *str; | |
58 | uint8_t u8; | |
59 | } value; | |
60 | struct { | |
60f067b4 | 61 | struct match_callback *callback; |
663996b3 MS |
62 | } leaf; |
63 | struct { | |
64 | /* If this is set, then the child is NULL */ | |
65 | Hashmap *children; | |
66 | } compare; | |
67 | }; | |
68 | }; | |
69 | ||
14228c0d MB |
70 | struct bus_match_component { |
71 | enum bus_match_node_type type; | |
72 | uint8_t value_u8; | |
73 | char *value_str; | |
74 | }; | |
663996b3 | 75 | |
86f210e9 MP |
76 | enum bus_match_scope { |
77 | BUS_MATCH_GENERIC, | |
78 | BUS_MATCH_LOCAL, | |
79 | BUS_MATCH_DRIVER, | |
80 | }; | |
81 | ||
14228c0d MB |
82 | int bus_match_run(sd_bus *bus, struct bus_match_node *root, sd_bus_message *m); |
83 | ||
60f067b4 JS |
84 | int bus_match_add(struct bus_match_node *root, struct bus_match_component *components, unsigned n_components, struct match_callback *callback); |
85 | int bus_match_remove(struct bus_match_node *root, struct match_callback *callback); | |
86 | ||
87 | int bus_match_find(struct bus_match_node *root, struct bus_match_component *components, unsigned n_components, sd_bus_message_handler_t callback, void *userdata, struct match_callback **ret); | |
663996b3 MS |
88 | |
89 | void bus_match_free(struct bus_match_node *node); | |
90 | ||
91 | void bus_match_dump(struct bus_match_node *node, unsigned level); | |
92 | ||
93 | const char* bus_match_node_type_to_string(enum bus_match_node_type t, char buf[], size_t l); | |
94 | enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n); | |
14228c0d MB |
95 | |
96 | int bus_match_parse(const char *match, struct bus_match_component **_components, unsigned *_n_components); | |
97 | void bus_match_parse_free(struct bus_match_component *components, unsigned n_components); | |
60f067b4 | 98 | char *bus_match_to_string(struct bus_match_component *components, unsigned n_components); |
86f210e9 MP |
99 | |
100 | enum bus_match_scope bus_match_get_scope(const struct bus_match_component *components, unsigned n_components); |