]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-bus/test-bus-introspect.c
core: convert PID 1 to libsystemd-bus
[thirdparty/systemd.git] / src / libsystemd-bus / test-bus-introspect.c
CommitLineData
29ddb38f
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3/***
4 This file is part of systemd.
5
6 Copyright 2013 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
22#include "util.h"
23#include "log.h"
24#include "bus-introspect.h"
25
26static int prop_get(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, sd_bus_error *error, void *userdata) {
27 return -EINVAL;
28}
29
30static int prop_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, sd_bus_error *error, void *userdata) {
31 return -EINVAL;
32}
33
34static const sd_bus_vtable vtable[] = {
35 SD_BUS_VTABLE_START(0),
adcdb374
LP
36 SD_BUS_METHOD("Hello", "ssas", "a(uu)", NULL, 0),
37 SD_BUS_METHOD("DeprecatedHello", "", "", NULL, SD_BUS_VTABLE_DEPRECATED),
38 SD_BUS_METHOD("DeprecatedHelloNoReply", "", "", NULL, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_METHOD_NO_REPLY),
29ddb38f
LP
39 SD_BUS_SIGNAL("Wowza", "sss", 0),
40 SD_BUS_SIGNAL("DeprecatedWowza", "ut", SD_BUS_VTABLE_DEPRECATED),
41 SD_BUS_WRITABLE_PROPERTY("AProperty", "s", prop_get, prop_set, 0, 0),
42 SD_BUS_PROPERTY("AReadOnlyDeprecatedProperty", "(ut)", prop_get, 0, SD_BUS_VTABLE_DEPRECATED),
43 SD_BUS_PROPERTY("ChangingProperty", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
44 SD_BUS_PROPERTY("Invalidating", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE|SD_BUS_VTABLE_PROPERTY_INVALIDATE_ONLY),
45 SD_BUS_VTABLE_END
46};
47
48int main(int argc, char *argv[]) {
49 struct introspect intro;
50
51 log_set_max_level(LOG_DEBUG);
52
53 assert_se(introspect_begin(&intro) >= 0);
54
718db961
LP
55 fprintf(intro.f, " <interface name=\"org.foo\">\n");
56 assert_se(introspect_write_interface(&intro, vtable) >= 0);
57 fputs(" </interface>\n", intro.f);
29ddb38f
LP
58
59 fflush(intro.f);
60 fputs(intro.introspection, stdout);
61
62 introspect_free(&intro);
63
64 return 0;
65}