xref: /openbmc/sdbusplus/test/vtable/vtable_c.c (revision 3e3a665a)
1 #include <systemd/sd-bus.h>
2 
3 #define UNUSED(x) (void)(x)
4 
5 int test_handler(sd_bus_message* m, void* userdata, sd_bus_error* ret_error)
6 {
7     UNUSED(m);
8     UNUSED(userdata);
9     UNUSED(ret_error);
10     return 0;
11 }
12 int test_get(sd_bus* bus, const char* path, const char* interface,
13              const char* property, sd_bus_message* reply, void* userdata,
14              sd_bus_error* ret_error)
15 {
16     UNUSED(bus);
17     UNUSED(path);
18     UNUSED(interface);
19     UNUSED(property);
20     UNUSED(reply);
21     UNUSED(userdata);
22     UNUSED(ret_error);
23     return 0;
24 }
25 int test_set(sd_bus* bus, const char* path, const char* interface,
26              const char* property, sd_bus_message* value, void* userdata,
27              sd_bus_error* ret_error)
28 {
29     UNUSED(bus);
30     UNUSED(path);
31     UNUSED(interface);
32     UNUSED(property);
33     UNUSED(value);
34     UNUSED(userdata);
35     UNUSED(ret_error);
36     return 0;
37 }
38 
39 typedef int (*sd_bus_message_handler_t)(sd_bus_message* m, void* userdata,
40                                         sd_bus_error* ret_error);
41 const sd_bus_vtable example2[] = {
42     SD_BUS_VTABLE_START(0),
43     SD_BUS_METHOD("1", "2", "3", &test_handler, 0),
44     SD_BUS_SIGNAL("5", "6", 0),
45     SD_BUS_PROPERTY("7", "8", &test_get, 0, SD_BUS_VTABLE_PROPERTY_CONST),
46     SD_BUS_WRITABLE_PROPERTY("10", "11", &test_get, &test_set, 0, 0),
47     SD_BUS_PROPERTY("14", "15", NULL, 16, 0),
48     SD_BUS_VTABLE_END,
49 };
50 
51 const size_t example2_size = sizeof(example2);
52