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