]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
392d5b37 LP |
2 | #pragma once |
3 | ||
392d5b37 LP |
4 | #include "sd-bus.h" |
5 | ||
07630cea LP |
6 | #include "hashmap.h" |
7 | ||
392d5b37 LP |
8 | enum bus_match_node_type { |
9 | BUS_MATCH_ROOT, | |
10 | BUS_MATCH_VALUE, | |
11 | BUS_MATCH_LEAF, | |
12 | ||
13 | /* The following are all different kinds of compare nodes */ | |
392d5b37 | 14 | BUS_MATCH_SENDER, |
ae7bed3f | 15 | BUS_MATCH_MESSAGE_TYPE, |
392d5b37 LP |
16 | BUS_MATCH_DESTINATION, |
17 | BUS_MATCH_INTERFACE, | |
18 | BUS_MATCH_MEMBER, | |
19 | BUS_MATCH_PATH, | |
20 | BUS_MATCH_PATH_NAMESPACE, | |
21 | BUS_MATCH_ARG, | |
22 | BUS_MATCH_ARG_LAST = BUS_MATCH_ARG + 63, | |
23 | BUS_MATCH_ARG_PATH, | |
24 | BUS_MATCH_ARG_PATH_LAST = BUS_MATCH_ARG_PATH + 63, | |
25 | BUS_MATCH_ARG_NAMESPACE, | |
26 | BUS_MATCH_ARG_NAMESPACE_LAST = BUS_MATCH_ARG_NAMESPACE + 63, | |
eccd47c5 LP |
27 | BUS_MATCH_ARG_HAS, |
28 | BUS_MATCH_ARG_HAS_LAST = BUS_MATCH_ARG_HAS + 63, | |
392d5b37 LP |
29 | _BUS_MATCH_NODE_TYPE_MAX, |
30 | _BUS_MATCH_NODE_TYPE_INVALID = -1 | |
31 | }; | |
32 | ||
33 | struct bus_match_node { | |
34 | enum bus_match_node_type type; | |
35 | struct bus_match_node *parent, *next, *prev, *child; | |
36 | ||
37 | union { | |
38 | struct { | |
392d5b37 | 39 | char *str; |
7286037f | 40 | uint8_t u8; |
392d5b37 LP |
41 | } value; |
42 | struct { | |
19befb2d | 43 | struct match_callback *callback; |
392d5b37 LP |
44 | } leaf; |
45 | struct { | |
46 | /* If this is set, then the child is NULL */ | |
47 | Hashmap *children; | |
48 | } compare; | |
49 | }; | |
50 | }; | |
51 | ||
c7819669 LP |
52 | struct bus_match_component { |
53 | enum bus_match_node_type type; | |
54 | uint8_t value_u8; | |
55 | char *value_str; | |
56 | }; | |
57 | ||
cc65fe5e LP |
58 | enum bus_match_scope { |
59 | BUS_MATCH_GENERIC, | |
60 | BUS_MATCH_LOCAL, | |
61 | BUS_MATCH_DRIVER, | |
62 | }; | |
63 | ||
eb01ba5d | 64 | int bus_match_run(sd_bus *bus, struct bus_match_node *root, sd_bus_message *m); |
392d5b37 | 65 | |
19befb2d LP |
66 | int bus_match_add(struct bus_match_node *root, struct bus_match_component *components, unsigned n_components, struct match_callback *callback); |
67 | int bus_match_remove(struct bus_match_node *root, struct match_callback *callback); | |
68 | ||
392d5b37 LP |
69 | void bus_match_free(struct bus_match_node *node); |
70 | ||
71 | void bus_match_dump(struct bus_match_node *node, unsigned level); | |
72 | ||
73 | const char* bus_match_node_type_to_string(enum bus_match_node_type t, char buf[], size_t l); | |
74 | enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n); | |
c7819669 LP |
75 | |
76 | int bus_match_parse(const char *match, struct bus_match_component **_components, unsigned *_n_components); | |
77 | void bus_match_parse_free(struct bus_match_component *components, unsigned n_components); | |
53461b74 | 78 | char *bus_match_to_string(struct bus_match_component *components, unsigned n_components); |
cc65fe5e LP |
79 | |
80 | enum bus_match_scope bus_match_get_scope(const struct bus_match_component *components, unsigned n_components); |