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