]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
29ddb38f LP |
2 | #ifndef foosdbusvtablehfoo |
3 | #define foosdbusvtablehfoo | |
4 | ||
5 | /*** | |
29ddb38f LP |
6 | |
7 | systemd is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU Lesser General Public License as published by | |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public License | |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
19 | ***/ | |
20 | ||
0095c454 LP |
21 | #include "_sd-common.h" |
22 | ||
23 | _SD_BEGIN_DECLARATIONS; | |
6695ed7a | 24 | |
29ddb38f LP |
25 | typedef struct sd_bus_vtable sd_bus_vtable; |
26 | ||
27 | #include "sd-bus.h" | |
28 | ||
29 | enum { | |
adacb957 LP |
30 | _SD_BUS_VTABLE_START = '<', |
31 | _SD_BUS_VTABLE_END = '>', | |
32 | _SD_BUS_VTABLE_METHOD = 'M', | |
33 | _SD_BUS_VTABLE_SIGNAL = 'S', | |
34 | _SD_BUS_VTABLE_PROPERTY = 'P', | |
e0c0b07d | 35 | _SD_BUS_VTABLE_WRITABLE_PROPERTY = 'W' |
29ddb38f LP |
36 | }; |
37 | ||
38 | enum { | |
df98a87b LP |
39 | SD_BUS_VTABLE_DEPRECATED = 1ULL << 0, |
40 | SD_BUS_VTABLE_HIDDEN = 1ULL << 1, | |
41 | SD_BUS_VTABLE_UNPRIVILEGED = 1ULL << 2, | |
42 | SD_BUS_VTABLE_METHOD_NO_REPLY = 1ULL << 3, | |
43 | SD_BUS_VTABLE_PROPERTY_CONST = 1ULL << 4, | |
44 | SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE = 1ULL << 5, | |
45 | SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION = 1ULL << 6, | |
33702051 | 46 | SD_BUS_VTABLE_PROPERTY_EXPLICIT = 1ULL << 7, |
df98a87b | 47 | _SD_BUS_VTABLE_CAPABILITY_MASK = 0xFFFFULL << 40 |
29ddb38f LP |
48 | }; |
49 | ||
adacb957 LP |
50 | #define SD_BUS_VTABLE_CAPABILITY(x) ((uint64_t) (((x)+1) & 0xFFFF) << 40) |
51 | ||
29ddb38f LP |
52 | struct sd_bus_vtable { |
53 | /* Please do not initialize this structure directly, use the | |
54 | * macros below instead */ | |
55 | ||
adacb957 LP |
56 | uint8_t type:8; |
57 | uint64_t flags:56; | |
29ddb38f LP |
58 | union { |
59 | struct { | |
60 | size_t element_size; | |
61 | } start; | |
62 | struct { | |
63 | const char *member; | |
64 | const char *signature; | |
65 | const char *result; | |
66 | sd_bus_message_handler_t handler; | |
09c8a7c6 | 67 | size_t offset; |
29ddb38f LP |
68 | } method; |
69 | struct { | |
70 | const char *member; | |
71 | const char *signature; | |
72 | } signal; | |
73 | struct { | |
74 | const char *member; | |
75 | const char *signature; | |
76 | sd_bus_property_get_t get; | |
77 | sd_bus_property_set_t set; | |
78 | size_t offset; | |
79 | } property; | |
77a874a3 | 80 | } x; |
29ddb38f LP |
81 | }; |
82 | ||
83 | #define SD_BUS_VTABLE_START(_flags) \ | |
84 | { \ | |
85 | .type = _SD_BUS_VTABLE_START, \ | |
86 | .flags = _flags, \ | |
aa328850 KK |
87 | .x = { \ |
88 | .start = { \ | |
89 | .element_size = sizeof(sd_bus_vtable) \ | |
90 | }, \ | |
91 | }, \ | |
29ddb38f LP |
92 | } |
93 | ||
29ddae7b | 94 | #define SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, _offset, _flags) \ |
29ddb38f LP |
95 | { \ |
96 | .type = _SD_BUS_VTABLE_METHOD, \ | |
97 | .flags = _flags, \ | |
aa328850 KK |
98 | .x = { \ |
99 | .method = { \ | |
100 | .member = _member, \ | |
101 | .signature = _signature, \ | |
102 | .result = _result, \ | |
103 | .handler = _handler, \ | |
104 | .offset = _offset, \ | |
105 | }, \ | |
106 | }, \ | |
29ddb38f | 107 | } |
09c8a7c6 | 108 | #define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \ |
29ddae7b | 109 | SD_BUS_METHOD_WITH_OFFSET(_member, _signature, _result, _handler, 0, _flags) |
29ddb38f LP |
110 | |
111 | #define SD_BUS_SIGNAL(_member, _signature, _flags) \ | |
112 | { \ | |
113 | .type = _SD_BUS_VTABLE_SIGNAL, \ | |
114 | .flags = _flags, \ | |
aa328850 KK |
115 | .x = { \ |
116 | .signal = { \ | |
117 | .member = _member, \ | |
118 | .signature = _signature, \ | |
119 | }, \ | |
120 | }, \ | |
29ddb38f LP |
121 | } |
122 | ||
77a874a3 | 123 | #define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \ |
29ddb38f LP |
124 | { \ |
125 | .type = _SD_BUS_VTABLE_PROPERTY, \ | |
126 | .flags = _flags, \ | |
aa328850 KK |
127 | .x = { \ |
128 | .property = { \ | |
129 | .member = _member, \ | |
130 | .signature = _signature, \ | |
131 | .get = _get, \ | |
cc9daff2 | 132 | .set = NULL, \ |
aa328850 KK |
133 | .offset = _offset, \ |
134 | }, \ | |
135 | }, \ | |
29ddb38f LP |
136 | } |
137 | ||
138 | #define SD_BUS_WRITABLE_PROPERTY(_member, _signature, _get, _set, _offset, _flags) \ | |
139 | { \ | |
140 | .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \ | |
141 | .flags = _flags, \ | |
aa328850 KK |
142 | .x = { \ |
143 | .property = { \ | |
144 | .member = _member, \ | |
145 | .signature = _signature, \ | |
146 | .get = _get, \ | |
147 | .set = _set, \ | |
148 | .offset = _offset, \ | |
149 | }, \ | |
150 | }, \ | |
29ddb38f LP |
151 | } |
152 | ||
153 | #define SD_BUS_VTABLE_END \ | |
154 | { \ | |
155 | .type = _SD_BUS_VTABLE_END, \ | |
cc9daff2 | 156 | .flags = 0, \ |
d579a56c | 157 | .x = { { 0 } }, \ |
29ddb38f LP |
158 | } |
159 | ||
0095c454 | 160 | _SD_END_DECLARATIONS; |
6695ed7a | 161 | |
29ddb38f | 162 | #endif |