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