]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-bus/test-bus-introspect.c
tree-wide: remove Emacs lines from all files
[thirdparty/systemd.git] / src / libsystemd / sd-bus / test-bus-introspect.c
1 /***
2 This file is part of systemd.
3
4 Copyright 2013 Lennart Poettering
5
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 "bus-introspect.h"
21 #include "log.h"
22
23 static int prop_get(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
24 return -EINVAL;
25 }
26
27 static int prop_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
28 return -EINVAL;
29 }
30
31 static const sd_bus_vtable vtable[] = {
32 SD_BUS_VTABLE_START(0),
33 SD_BUS_METHOD("Hello", "ssas", "a(uu)", NULL, 0),
34 SD_BUS_METHOD("DeprecatedHello", "", "", NULL, SD_BUS_VTABLE_DEPRECATED),
35 SD_BUS_METHOD("DeprecatedHelloNoReply", "", "", NULL, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_METHOD_NO_REPLY),
36 SD_BUS_SIGNAL("Wowza", "sss", 0),
37 SD_BUS_SIGNAL("DeprecatedWowza", "ut", SD_BUS_VTABLE_DEPRECATED),
38 SD_BUS_WRITABLE_PROPERTY("AProperty", "s", prop_get, prop_set, 0, 0),
39 SD_BUS_PROPERTY("AReadOnlyDeprecatedProperty", "(ut)", prop_get, 0, SD_BUS_VTABLE_DEPRECATED),
40 SD_BUS_PROPERTY("ChangingProperty", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
41 SD_BUS_PROPERTY("Invalidating", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
42 SD_BUS_PROPERTY("Constant", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_PROPERTY_EXPLICIT),
43 SD_BUS_VTABLE_END
44 };
45
46 int main(int argc, char *argv[]) {
47 struct introspect intro;
48
49 log_set_max_level(LOG_DEBUG);
50
51 assert_se(introspect_begin(&intro, false) >= 0);
52
53 fprintf(intro.f, " <interface name=\"org.foo\">\n");
54 assert_se(introspect_write_interface(&intro, vtable) >= 0);
55 fputs(" </interface>\n", intro.f);
56
57 fflush(intro.f);
58 fputs(intro.introspection, stdout);
59
60 introspect_free(&intro);
61
62 return 0;
63 }