1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2013 Lennart Poettering
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.
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.
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/>.
28 enum bus_match_node_type {
33 /* The following are all different kinds of compare nodes */
35 BUS_MATCH_MESSAGE_TYPE,
36 BUS_MATCH_DESTINATION,
40 BUS_MATCH_PATH_NAMESPACE,
42 BUS_MATCH_ARG_LAST = BUS_MATCH_ARG + 63,
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,
47 _BUS_MATCH_NODE_TYPE_MAX,
48 _BUS_MATCH_NODE_TYPE_INVALID = -1
51 struct bus_match_node {
52 enum bus_match_node_type type;
53 struct bus_match_node *parent, *next, *prev, *child;
61 struct match_callback *callback;
64 /* If this is set, then the child is NULL */
70 struct bus_match_component {
71 enum bus_match_node_type type;
76 int bus_match_run(sd_bus *bus, struct bus_match_node *root, sd_bus_message *m);
78 int bus_match_add(struct bus_match_node *root, struct bus_match_component *components, unsigned n_components, struct match_callback *callback);
79 int bus_match_remove(struct bus_match_node *root, struct match_callback *callback);
81 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);
83 void bus_match_free(struct bus_match_node *node);
85 void bus_match_dump(struct bus_match_node *node, unsigned level);
87 const char* bus_match_node_type_to_string(enum bus_match_node_type t, char buf[], size_t l);
88 enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n);
90 int bus_match_parse(const char *match, struct bus_match_component **_components, unsigned *_n_components);
91 void bus_match_parse_free(struct bus_match_component *components, unsigned n_components);
92 char *bus_match_to_string(struct bus_match_component *components, unsigned n_components);