]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-bus-vtable.h
tree-wide: drop 'This file is part of systemd' blurb
[thirdparty/systemd.git] / src / systemd / sd-bus-vtable.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
29ddb38f
LP
2#ifndef foosdbusvtablehfoo
3#define foosdbusvtablehfoo
4
5/***
29ddb38f
LP
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
0095c454
LP
22#include "_sd-common.h"
23
24_SD_BEGIN_DECLARATIONS;
6695ed7a 25
29ddb38f
LP
26typedef struct sd_bus_vtable sd_bus_vtable;
27
28#include "sd-bus.h"
29
30enum {
adacb957
LP
31 _SD_BUS_VTABLE_START = '<',
32 _SD_BUS_VTABLE_END = '>',
33 _SD_BUS_VTABLE_METHOD = 'M',
34 _SD_BUS_VTABLE_SIGNAL = 'S',
35 _SD_BUS_VTABLE_PROPERTY = 'P',
e0c0b07d 36 _SD_BUS_VTABLE_WRITABLE_PROPERTY = 'W'
29ddb38f
LP
37};
38
39enum {
df98a87b
LP
40 SD_BUS_VTABLE_DEPRECATED = 1ULL << 0,
41 SD_BUS_VTABLE_HIDDEN = 1ULL << 1,
42 SD_BUS_VTABLE_UNPRIVILEGED = 1ULL << 2,
43 SD_BUS_VTABLE_METHOD_NO_REPLY = 1ULL << 3,
44 SD_BUS_VTABLE_PROPERTY_CONST = 1ULL << 4,
45 SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE = 1ULL << 5,
46 SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION = 1ULL << 6,
33702051 47 SD_BUS_VTABLE_PROPERTY_EXPLICIT = 1ULL << 7,
df98a87b 48 _SD_BUS_VTABLE_CAPABILITY_MASK = 0xFFFFULL << 40
29ddb38f
LP
49};
50
adacb957
LP
51#define SD_BUS_VTABLE_CAPABILITY(x) ((uint64_t) (((x)+1) & 0xFFFF) << 40)
52
29ddb38f
LP
53struct sd_bus_vtable {
54 /* Please do not initialize this structure directly, use the
55 * macros below instead */
56
adacb957
LP
57 uint8_t type:8;
58 uint64_t flags:56;
29ddb38f
LP
59 union {
60 struct {
61 size_t element_size;
62 } start;
63 struct {
64 const char *member;
65 const char *signature;
66 const char *result;
67 sd_bus_message_handler_t handler;
09c8a7c6 68 size_t offset;
29ddb38f
LP
69 } method;
70 struct {
71 const char *member;
72 const char *signature;
73 } signal;
74 struct {
75 const char *member;
76 const char *signature;
77 sd_bus_property_get_t get;
78 sd_bus_property_set_t set;
79 size_t offset;
80 } property;
77a874a3 81 } x;
29ddb38f
LP
82};
83
84#define SD_BUS_VTABLE_START(_flags) \
85 { \
86 .type = _SD_BUS_VTABLE_START, \
87 .flags = _flags, \
aa328850
KK
88 .x = { \
89 .start = { \
90 .element_size = sizeof(sd_bus_vtable) \
91 }, \
92 }, \
29ddb38f
LP
93 }
94
29ddae7b 95#define SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, _offset, _flags) \
29ddb38f
LP
96 { \
97 .type = _SD_BUS_VTABLE_METHOD, \
98 .flags = _flags, \
aa328850
KK
99 .x = { \
100 .method = { \
101 .member = _member, \
102 .signature = _signature, \
103 .result = _result, \
104 .handler = _handler, \
105 .offset = _offset, \
106 }, \
107 }, \
29ddb38f 108 }
09c8a7c6 109#define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \
29ddae7b 110 SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, 0, _flags)
29ddb38f
LP
111
112#define SD_BUS_SIGNAL(_member, _signature, _flags) \
113 { \
114 .type = _SD_BUS_VTABLE_SIGNAL, \
115 .flags = _flags, \
aa328850
KK
116 .x = { \
117 .signal = { \
118 .member = _member, \
119 .signature = _signature, \
120 }, \
121 }, \
29ddb38f
LP
122 }
123
77a874a3 124#define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \
29ddb38f
LP
125 { \
126 .type = _SD_BUS_VTABLE_PROPERTY, \
127 .flags = _flags, \
aa328850
KK
128 .x = { \
129 .property = { \
130 .member = _member, \
131 .signature = _signature, \
132 .get = _get, \
cc9daff2 133 .set = NULL, \
aa328850
KK
134 .offset = _offset, \
135 }, \
136 }, \
29ddb38f
LP
137 }
138
139#define SD_BUS_WRITABLE_PROPERTY(_member, _signature, _get, _set, _offset, _flags) \
140 { \
141 .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \
142 .flags = _flags, \
aa328850
KK
143 .x = { \
144 .property = { \
145 .member = _member, \
146 .signature = _signature, \
147 .get = _get, \
148 .set = _set, \
149 .offset = _offset, \
150 }, \
151 }, \
29ddb38f
LP
152 }
153
154#define SD_BUS_VTABLE_END \
155 { \
156 .type = _SD_BUS_VTABLE_END, \
cc9daff2 157 .flags = 0, \
d579a56c 158 .x = { { 0 } }, \
29ddb38f
LP
159 }
160
0095c454 161_SD_END_DECLARATIONS;
6695ed7a 162
29ddb38f 163#endif