diff options
Diffstat (limited to 'upstream/debian-unstable/man3/sd_bus_add_object.3')
-rw-r--r-- | upstream/debian-unstable/man3/sd_bus_add_object.3 | 127 |
1 files changed, 56 insertions, 71 deletions
diff --git a/upstream/debian-unstable/man3/sd_bus_add_object.3 b/upstream/debian-unstable/man3/sd_bus_add_object.3 index 559034e1..e71906e3 100644 --- a/upstream/debian-unstable/man3/sd_bus_add_object.3 +++ b/upstream/debian-unstable/man3/sd_bus_add_object.3 @@ -1,5 +1,5 @@ '\" t -.TH "SD_BUS_ADD_OBJECT" "3" "" "systemd 255" "sd_bus_add_object" +.TH "SD_BUS_ADD_OBJECT" "3" "" "systemd 256~rc3" "sd_bus_add_object" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,7 +28,6 @@ sd_bus_add_object, sd_bus_add_fallback, sd_bus_add_object_vtable, sd_bus_add_fal #include <systemd/sd\-bus\-vtable\&.h> .fi .ft -.sp .HP \w'typedef\ int\ (*sd_bus_message_handler_t)('u .BI "typedef int (*sd_bus_message_handler_t)(sd_bus_message\ *" "m" ", void\ *" "userdata" ", sd_bus_error\ *" "ret_error" ");" .HP \w'typedef\ int\ (*sd_bus_property_get_t)('u @@ -234,8 +233,6 @@ is a combination of flags, see below\&. is a shorthand for calling \fBSD_BUS_METHOD_WITH_ARGS_OFFSET()\fR with an offset of zero\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_METHOD_WITH_NAMES_OFFSET()\fR, \fBSD_BUS_METHOD_WITH_NAMES()\fR, \fBSD_BUS_METHOD_WITH_OFFSET()\fR, \fBSD_BUS_METHOD()\fR @@ -267,8 +264,6 @@ Prefer using and \fBSD_BUS_METHOD_WITH_ARGS()\fR over these macros as they allow specifying argument types and names next to each other which is less error\-prone than first specifying all argument types followed by specifying all argument names\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_SIGNAL_WITH_ARGS()\fR @@ -287,8 +282,6 @@ to \fIargs\fR\&. The elements at uneven indices describe the names of the signal\*(Aqs arguments\&. Parameter \fIflags\fR is a combination of flags\&. See below for a complete example\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_SIGNAL_WITH_NAMES()\fR, \fBSD_BUS_SIGNAL()\fR @@ -314,8 +307,6 @@ parameter unset (i\&.e\&. no parameter names)\&. Prefer using \fBSD_BUS_SIGNAL_WITH_ARGS()\fR over these macros as it allows specifying argument types and names next to each other which is less error\-prone than first specifying all argument types followed by specifying all argument names\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_WRITABLE_PROPERTY()\fR, \fBSD_BUS_PROPERTY()\fR @@ -346,15 +337,11 @@ parameters must together point to a valid variable of the corresponding type\&. .sp \fBSD_BUS_PROPERTY()\fR is used to define a read\-only property\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_PARAM()\fR .RS 4 Parameter names should be wrapped in this macro, see the example below\&. -.sp -Added in version 246\&. .RE .SS "Flags" .PP @@ -369,16 +356,12 @@ Mark this vtable entry as deprecated using the \fBorg\&.freedesktop\&.DBus\&.Deprecated\fR annotation in introspection data\&. If specified for \fBSD_BUS_VTABLE_START()\fR, the annotation is applied to the enclosing interface\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_VTABLE_HIDDEN\fR .RS 4 Make this vtable entry hidden\&. It will not be shown in introspection data\&. If specified for \fBSD_BUS_VTABLE_START()\fR, all entries in the array are hidden\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_VTABLE_METHOD_NO_REPLY\fR @@ -386,8 +369,6 @@ Added in version 246\&. Mark this vtable entry as a method that will not return a reply using the \fBorg\&.freedesktop\&.DBus\&.Method\&.NoReply\fR annotation in introspection data\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_VTABLE_PROPERTY_CONST\fR, \fBSD_BUS_VTABLE_PROPERTY_EMITS_CHANGE\fR, \fBSD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION\fR @@ -409,8 +390,6 @@ and means that the signal is emitted\&. corresponds to \fBinvalidates\fR and means that the signal is emitted, but the value is not included in the signal\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_VTABLE_PROPERTY_EXPLICIT\fR @@ -420,23 +399,17 @@ Mark this vtable property entry as requiring explicit request to for the value t \fBbusctl introspect\fR)\&. This corresponds to the \fBorg\&.freedesktop\&.systemd1\&.Explicit\fR annotation in introspection data\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_VTABLE_SENSITIVE\fR .RS 4 Mark this vtable method entry as processing sensitive data\&. When set, incoming method call messages and their outgoing reply messages are marked as sensitive using \fBsd_bus_message_sensitive\fR(3), so that they are erased from memory when freed\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_VTABLE_ABSOLUTE_OFFSET\fR .RS 4 Mark this vtable method or property entry so that the user data pointer passed to its associated handler functions is determined slightly differently: instead of adding the offset parameter of the entry to the user data pointer specified during vtable registration, the offset is passed directly, converted to a pointer, without taking the user data pointer specified during vtable registration into account\&. -.sp -Added in version 246\&. .RE .PP \fBSD_BUS_VTABLE_CAPABILITY(\fR\fB\fIcapability\fR\fR\fB)\fR @@ -453,8 +426,6 @@ for information about capabilities\&. Note that vtable entries may be marked as unprivileged and the whole bus may be marked as trusted, see the discussion of \fBSD_BUS_VTABLE_UNPRIVILEGED\fR below\&. -.sp -Added in version 251\&. .RE .PP \fBSD_BUS_VTABLE_UNPRIVILEGED\fR @@ -475,8 +446,6 @@ will be shown in introspection data\&. .sp Note that this page describes checks implemented in the D\-Bus client\&. The D\-Bus server has an additional policy that may permit or deny connections, see "CONFIGURATION FILE" in \fBdbus-daemon\fR(1)\&. -.sp -Added in version 246\&. .RE .SH "EXAMPLES" .PP @@ -488,6 +457,7 @@ Added in version 246\&. .nf /* SPDX\-License\-Identifier: MIT\-0 */ +#define _GNU_SOURCE 1 #include <errno\&.h> #include <stdbool\&.h> #include <stddef\&.h> @@ -497,20 +467,14 @@ Added in version 246\&. #define _cleanup_(f) __attribute__((cleanup(f))) -#define check(x) ({ \e - int r = (x); \e - errno = r < 0 ? \-r : 0; \e - printf(#x ": %m\en"); \e - if (r < 0) \e - return EXIT_FAILURE; \e - }) - typedef struct object { char *name; uint32_t number; } object; static int method(sd_bus_message *m, void *userdata, sd_bus_error *error) { + int r; + printf("Got called with userdata=%p\en", userdata); if (sd_bus_message_is_method_call(m, @@ -519,8 +483,17 @@ static int method(sd_bus_message *m, void *userdata, sd_bus_error *error) { return 1; const char *string; - check(sd_bus_message_read(m, "s", &string)); - check(sd_bus_reply_method_return(m, "s", string)); + r = sd_bus_message_read(m, "s", &string); + if (r < 0) { + fprintf(stderr, "sd_bus_message_read() failed: %s\en", strerror(\-r)); + return 0; + } + + r = sd_bus_reply_method_return(m, "s", string); + if (r < 0) { + fprintf(stderr, "sd_bus_reply_method_return() failed: %s\en", strerror(\-r)); + return 0; + } return 1; } @@ -572,28 +545,55 @@ static const sd_bus_vtable vtable[] = { int main(int argc, char **argv) { _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; + int r; sd_bus_default(&bus); object object = { \&.number = 666 }; - check((object\&.name = strdup("name")) != NULL); + object\&.name = strdup("name"); + if (!object\&.name) { + fprintf(stderr, "OOM\en"); + return EXIT_FAILURE; + } - check(sd_bus_add_object_vtable(bus, NULL, - "/org/freedesktop/systemd/VtableExample", - "org\&.freedesktop\&.systemd\&.VtableExample", - vtable, - &object)); + r = sd_bus_add_object_vtable(bus, NULL, + "/org/freedesktop/systemd/VtableExample", + "org\&.freedesktop\&.systemd\&.VtableExample", + vtable, + &object); + if (r < 0) { + fprintf(stderr, "sd_bus_add_object_vtable() failed: %s\en", strerror(\-r)); + return EXIT_FAILURE; + } - check(sd_bus_request_name(bus, - "org\&.freedesktop\&.systemd\&.VtableExample", - 0)); + r = sd_bus_request_name(bus, + "org\&.freedesktop\&.systemd\&.VtableExample", + 0); + if (r < 0) { + fprintf(stderr, "sd_bus_request_name() failed: %s\en", strerror(\-r)); + return EXIT_FAILURE; + } for (;;) { - check(sd_bus_wait(bus, UINT64_MAX)); - check(sd_bus_process(bus, NULL)); + r = sd_bus_wait(bus, UINT64_MAX); + if (r < 0) { + fprintf(stderr, "sd_bus_wait() failed: %s\en", strerror(\-r)); + return EXIT_FAILURE; + } + + r = sd_bus_process(bus, NULL); + if (r < 0) { + fprintf(stderr, "sd_bus_process() failed: %s\en", strerror(\-r)); + return EXIT_FAILURE; + } + } + + r = sd_bus_release_name(bus, "org\&.freedesktop\&.systemd\&.VtableExample"); + if (r < 0) { + fprintf(stderr, "sd_bus_release_name() failed: %s\en", strerror(\-r)); + return EXIT_FAILURE; } - check(sd_bus_release_name(bus, "org\&.freedesktop\&.systemd\&.VtableExample")); free(object\&.name); return 0; @@ -688,29 +688,21 @@ One of the required parameters is or invalid\&. A reserved D\-Bus interface was passed as the \fIinterface\fR parameter\&. -.sp -Added in version 246\&. .RE .PP \fB\-ENOPKG\fR .RS 4 The bus cannot be resolved\&. -.sp -Added in version 246\&. .RE .PP \fB\-ECHILD\fR .RS 4 The bus was created in a different process, library or module instance\&. -.sp -Added in version 246\&. .RE .PP \fB\-ENOMEM\fR .RS 4 Memory allocation failed\&. -.sp -Added in version 246\&. .RE .PP \fB\-EPROTOTYPE\fR @@ -719,8 +711,6 @@ Added in version 246\&. and \fBsd_bus_add_fallback_vtable()\fR have been both called for the same bus object path, which is not allowed\&. -.sp -Added in version 246\&. .RE .PP \fB\-EEXIST\fR @@ -729,8 +719,6 @@ This vtable has already been registered for this \fIinterface\fR and \fIpath\fR\&. -.sp -Added in version 246\&. .RE .SH "NOTES" .PP @@ -754,13 +742,10 @@ from an early phase of the program when no other threads have been started\&. \fBsd_bus_add_object_vtable()\fR, \fBsd_bus_add_fallback_vtable()\fR, and \fBsd_bus_add_filter()\fR -were added in version 246\&. +were added in version 221\&. .SH "SEE ALSO" .PP -\fBsd-bus\fR(3), -\fBbusctl\fR(1), -\fBsd_bus_emit_properties_changed\fR(3), -\fBsd_bus_emit_object_added\fR(3) +\fBsd-bus\fR(3), \fBbusctl\fR(1), \fBsd_bus_emit_properties_changed\fR(3), \fBsd_bus_emit_object_added\fR(3) .SH "NOTES" .IP " 1." 4 D-Bus annotations |