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