1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #ifndef foosdbusvtablehfoo
3 #define foosdbusvtablehfoo
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 #include "_sd-common.h"
22 _SD_BEGIN_DECLARATIONS
;
24 typedef struct sd_bus_vtable sd_bus_vtable
;
29 _SD_BUS_VTABLE_START
= '<',
30 _SD_BUS_VTABLE_END
= '>',
31 _SD_BUS_VTABLE_METHOD
= 'M',
32 _SD_BUS_VTABLE_SIGNAL
= 'S',
33 _SD_BUS_VTABLE_PROPERTY
= 'P',
34 _SD_BUS_VTABLE_WRITABLE_PROPERTY
= 'W'
38 SD_BUS_VTABLE_DEPRECATED
= 1ULL << 0,
39 SD_BUS_VTABLE_HIDDEN
= 1ULL << 1,
40 SD_BUS_VTABLE_UNPRIVILEGED
= 1ULL << 2,
41 SD_BUS_VTABLE_METHOD_NO_REPLY
= 1ULL << 3,
42 SD_BUS_VTABLE_PROPERTY_CONST
= 1ULL << 4,
43 SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
= 1ULL << 5,
44 SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION
= 1ULL << 6,
45 SD_BUS_VTABLE_PROPERTY_EXPLICIT
= 1ULL << 7,
46 _SD_BUS_VTABLE_CAPABILITY_MASK
= 0xFFFFULL
<< 40
49 #define SD_BUS_VTABLE_CAPABILITY(x) ((uint64_t) (((x)+1) & 0xFFFF) << 40)
52 _SD_BUS_VTABLE_PARAM_NAMES
= 1 << 0,
55 struct sd_bus_vtable
{
56 /* Please do not initialize this structure directly, use the
57 * macros below instead */
68 const char *signature
;
70 sd_bus_message_handler_t handler
;
76 const char *signature
;
81 const char *signature
;
82 sd_bus_property_get_t get
;
83 sd_bus_property_set_t set
;
89 #define SD_BUS_VTABLE_START(_flags) \
91 .type = _SD_BUS_VTABLE_START, \
95 .element_size = sizeof(sd_bus_vtable), \
96 .features = _SD_BUS_VTABLE_PARAM_NAMES \
101 /* helper macro to format method and signal parameters, one at a time */
102 #define SD_BUS_PARAM(x) #x "\0"
104 #define SD_BUS_METHOD_WITH_NAMES_OFFSET(_member, _signature, _in_names, _result, _out_names, _handler, _offset, _flags) \
106 .type = _SD_BUS_VTABLE_METHOD, \
111 .signature = _signature, \
113 .handler = _handler, \
115 .names = _in_names _out_names, \
119 #define SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, _offset, _flags) \
120 SD_BUS_METHOD_WITH_NAMES_OFFSET(_member, _signature, "", _result, "", _handler, _offset, _flags)
121 #define SD_BUS_METHOD_WITH_NAMES(_member, _signature, _in_names, _result, _out_names, _handler, _flags) \
122 SD_BUS_METHOD_WITH_NAMES_OFFSET(_member, _signature, _in_names, _result, _out_names, _handler, 0, _flags)
123 #define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \
124 SD_BUS_METHOD_WITH_NAMES_OFFSET(_member, _signature, "", _result, "", _handler, 0, _flags)
126 #define SD_BUS_SIGNAL_WITH_NAMES(_member, _signature, _out_names, _flags) \
128 .type = _SD_BUS_VTABLE_SIGNAL, \
133 .signature = _signature, \
134 .names = _out_names, \
138 #define SD_BUS_SIGNAL(_member, _signature, _flags) \
139 SD_BUS_SIGNAL_WITH_NAMES(_member, _signature, "", _flags)
141 #define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \
143 .type = _SD_BUS_VTABLE_PROPERTY, \
148 .signature = _signature, \
156 #define SD_BUS_WRITABLE_PROPERTY(_member, _signature, _get, _set, _offset, _flags) \
158 .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \
163 .signature = _signature, \
171 #define SD_BUS_VTABLE_END \
173 .type = _SD_BUS_VTABLE_END, \
178 _SD_END_DECLARATIONS
;