]> git.proxmox.com Git - systemd.git/blame - src/systemd/sd-bus-vtable.h
New upstream version 240
[systemd.git] / src / systemd / sd-bus-vtable.h
CommitLineData
52ad194e 1/* SPDX-License-Identifier: LGPL-2.1+ */
60f067b4
JS
2#ifndef foosdbusvtablehfoo
3#define foosdbusvtablehfoo
4
5/***
60f067b4
JS
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.
10
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.
15
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/>.
18***/
19
20#include "_sd-common.h"
21
22_SD_BEGIN_DECLARATIONS;
23
24typedef struct sd_bus_vtable sd_bus_vtable;
25
26#include "sd-bus.h"
27
28enum {
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',
aa27b158 34 _SD_BUS_VTABLE_WRITABLE_PROPERTY = 'W'
60f067b4
JS
35};
36
37enum {
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,
13d276d0 45 SD_BUS_VTABLE_PROPERTY_EXPLICIT = 1ULL << 7,
60f067b4
JS
46 _SD_BUS_VTABLE_CAPABILITY_MASK = 0xFFFFULL << 40
47};
48
49#define SD_BUS_VTABLE_CAPABILITY(x) ((uint64_t) (((x)+1) & 0xFFFF) << 40)
50
51struct sd_bus_vtable {
52 /* Please do not initialize this structure directly, use the
53 * macros below instead */
54
55 uint8_t type:8;
56 uint64_t flags:56;
57 union {
58 struct {
59 size_t element_size;
60 } start;
61 struct {
62 const char *member;
63 const char *signature;
64 const char *result;
65 sd_bus_message_handler_t handler;
7035cd9e 66 size_t offset;
60f067b4
JS
67 } method;
68 struct {
69 const char *member;
70 const char *signature;
71 } signal;
72 struct {
73 const char *member;
74 const char *signature;
75 sd_bus_property_get_t get;
76 sd_bus_property_set_t set;
77 size_t offset;
78 } property;
79 } x;
80};
81
82#define SD_BUS_VTABLE_START(_flags) \
83 { \
84 .type = _SD_BUS_VTABLE_START, \
85 .flags = _flags, \
2897b343
MP
86 .x = { \
87 .start = { \
88 .element_size = sizeof(sd_bus_vtable) \
89 }, \
90 }, \
60f067b4
JS
91 }
92
7035cd9e 93#define SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, _offset, _flags) \
60f067b4
JS
94 { \
95 .type = _SD_BUS_VTABLE_METHOD, \
96 .flags = _flags, \
2897b343
MP
97 .x = { \
98 .method = { \
99 .member = _member, \
100 .signature = _signature, \
101 .result = _result, \
102 .handler = _handler, \
103 .offset = _offset, \
104 }, \
105 }, \
60f067b4 106 }
7035cd9e
MP
107#define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \
108 SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, 0, _flags)
60f067b4
JS
109
110#define SD_BUS_SIGNAL(_member, _signature, _flags) \
111 { \
112 .type = _SD_BUS_VTABLE_SIGNAL, \
113 .flags = _flags, \
2897b343
MP
114 .x = { \
115 .signal = { \
116 .member = _member, \
117 .signature = _signature, \
118 }, \
119 }, \
60f067b4
JS
120 }
121
122#define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \
123 { \
124 .type = _SD_BUS_VTABLE_PROPERTY, \
125 .flags = _flags, \
2897b343
MP
126 .x = { \
127 .property = { \
128 .member = _member, \
129 .signature = _signature, \
130 .get = _get, \
81c58355 131 .set = NULL, \
2897b343
MP
132 .offset = _offset, \
133 }, \
134 }, \
60f067b4
JS
135 }
136
137#define SD_BUS_WRITABLE_PROPERTY(_member, _signature, _get, _set, _offset, _flags) \
138 { \
139 .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \
140 .flags = _flags, \
2897b343
MP
141 .x = { \
142 .property = { \
143 .member = _member, \
144 .signature = _signature, \
145 .get = _get, \
146 .set = _set, \
147 .offset = _offset, \
148 }, \
149 }, \
60f067b4
JS
150 }
151
152#define SD_BUS_VTABLE_END \
153 { \
154 .type = _SD_BUS_VTABLE_END, \
81c58355 155 .flags = 0, \
b012e921 156 .x = { { 0 } }, \
60f067b4
JS
157 }
158
159_SD_END_DECLARATIONS;
160
161#endif