]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/bus-get-properties.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
8 int bus_property_get_bool(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);
9 int bus_property_set_bool(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*value
, void *userdata
, sd_bus_error
*error
);
10 int bus_property_get_tristate(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);
11 int bus_property_get_id128(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);
13 #define bus_property_get_usec ((sd_bus_property_get_t) NULL)
14 #define bus_property_set_usec ((sd_bus_property_set_t) NULL)
16 assert_cc(sizeof(int) == sizeof(int32_t));
17 #define bus_property_get_int ((sd_bus_property_get_t) NULL)
19 assert_cc(sizeof(unsigned) == sizeof(uint32_t));
20 #define bus_property_get_unsigned ((sd_bus_property_get_t) NULL)
22 /* On 64bit machines we can use the default serializer for size_t and
23 * friends, otherwise we need to cast this manually */
24 #if __SIZEOF_SIZE_T__ == 8
25 #define bus_property_get_size ((sd_bus_property_get_t) NULL)
27 int bus_property_get_size(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);
30 #if __SIZEOF_LONG__ == 8
31 #define bus_property_get_long ((sd_bus_property_get_t) NULL)
32 #define bus_property_get_ulong ((sd_bus_property_get_t) NULL)
34 int bus_property_get_long(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);
35 int bus_property_get_ulong(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);
38 /* uid_t and friends on Linux 32 bit. This means we can just use the
39 * default serializer for 32bit unsigned, for serializing it, and map
41 assert_cc(sizeof(uid_t
) == sizeof(uint32_t));
42 #define bus_property_get_uid ((sd_bus_property_get_t) NULL)
44 assert_cc(sizeof(gid_t
) == sizeof(uint32_t));
45 #define bus_property_get_gid ((sd_bus_property_get_t) NULL)
47 assert_cc(sizeof(pid_t
) == sizeof(uint32_t));
48 #define bus_property_get_pid ((sd_bus_property_get_t) NULL)
50 assert_cc(sizeof(mode_t
) == sizeof(uint32_t));
51 #define bus_property_get_mode ((sd_bus_property_get_t) NULL)
53 int bus_property_get_rlimit(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);
55 #define BUS_DEFINE_PROPERTY_GET_GLOBAL(function, bus_type, val) \
56 int function(sd_bus *bus, \
58 const char *interface, \
59 const char *property, \
60 sd_bus_message *reply, \
62 sd_bus_error *error) { \
67 return sd_bus_message_append(reply, bus_type, val); \
70 #define BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, get2) \
71 int function(sd_bus *bus, \
73 const char *interface, \
74 const char *property, \
75 sd_bus_message *reply, \
77 sd_bus_error *error) { \
79 data_type *data = ASSERT_PTR(userdata); \
84 return sd_bus_message_append(reply, bus_type, \
89 #define BUS_DEFINE_PROPERTY_GET(function, bus_type, data_type, get1) \
90 BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, ident)
93 #define BUS_DEFINE_PROPERTY_GET_REF(function, bus_type, data_type, get) \
94 BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, ref, get)
96 #define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \
97 BUS_DEFINE_PROPERTY_GET_REF(function, "s", type, name##_to_string)
99 #define BUS_PROPERTY_DUAL_TIMESTAMP(name, offset, flags) \
100 SD_BUS_PROPERTY(name, "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, realtime), (flags)), \
101 SD_BUS_PROPERTY(name "Monotonic", "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, monotonic), (flags))