From e8216945a97bc2a2b04bc286e67ab5bba313b83e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 7 Jul 2015 20:35:45 +0200 Subject: man: update and extend the various sd_bus_message_append_*() man pages Some calls changed their signature since the man pages were written. Also extend on a number of details. --- man/sd_bus_message_append.xml | 64 +++++++++++-------- man/sd_bus_message_append_array.xml | 123 +++++++++++++++++++++--------------- man/sd_bus_message_append_basic.xml | 51 ++++++++++----- 3 files changed, 144 insertions(+), 94 deletions(-) (limited to 'man') diff --git a/man/sd_bus_message_append.xml b/man/sd_bus_message_append.xml index 7a4bfa4bc4..0ee849dca7 100644 --- a/man/sd_bus_message_append.xml +++ b/man/sd_bus_message_append.xml @@ -46,7 +46,8 @@ sd_bus_message_append - Attach parts of message based on a format string + Attach fields to a D-Bus message based on a type + string @@ -65,17 +66,20 @@ Description - The sd_bus_message_append function appends - a sequence of items to message m. The - format string types describes the types of - arguments that follow. + The sd_bus_message_append() function + appends a sequence of fields to the D-Bus message object + m. The type string + types describes the types of the field + arguments that follow. For each type specified in the type string + one or more arguments need to be specified, in the same order as + declared in the type string. - The format string is composed of the elements shown in the + The type string is composed of the elements shown in the table below. It contains zero or more single "complete types". Each complete type may be one of the basic types or a fully - described container type. A container type may be a structure, a - variant type code, an array with its element type, or a dictionary - with its entry type. The format string is + described container type. A container type may be a structure with + the contained types, a variant, an array with its element type, or + a dictionary entry with the contained types. The type string is NUL-terminated. In case of a basic type, one argument of the corresponding @@ -88,27 +92,32 @@ rules as if they were not nested. A variant is denoted by v. Corresponding - arguments must include a format string denoting a complete type, + arguments must begin with a type string denoting a complete type, and following that, arguments corresponding to the specified type. An array is denoted by a followed by a - complete type. Corresponding arguments must include the size of - the array, and then repeated this number of times, arguments - corresponding to the nested type. + complete type. Corresponding arguments must begin with the number of + entries in the array, followed by the entries themselves, + matching the element type of the array. A dictionary is an array of dictionary entries, denoted by a followed by a pair of complete types between { and }. The first of those - types must be a basic type. Corresponding arguments must include - the size of the dictionary, and then repeated this number of - times, arguments corresponding to each of the two nested - types. + types must be a basic type. Corresponding arguments must begin + with the number of dictionary entries, followed by a pair of + values for each entry matching the element type of + the dictionary entries. + + For further details on the D-Bus type system, please consult + the D-Bus + Specification. - Item format specifiers + Item type specifiers - + @@ -120,6 +129,7 @@ SD_BUS_TYPE_ARRAY array determined by array type and size + int, followed by array contents @@ -127,6 +137,7 @@ SD_BUS_TYPE_VARIANT variant determined by the type argument + signature string, followed by variant contents @@ -134,6 +145,7 @@ SD_BUS_TYPE_STRUCT_BEGIN array start determined by the nested types + structure contents ) @@ -146,6 +158,7 @@ SD_BUS_TYPE_DICT_ENTRY_BEGIN dictionary entry start determined by the nested types + dictionary contents } @@ -155,10 +168,11 @@
+
- Types string grammar + Types String Grammar types ::= complete_type* complete_type ::= basic_type | variant | structure | array | dictionary @@ -194,7 +208,7 @@ uint32_t t = 7; double d = 8.0; sd_bus_message_append(m, "ynqiuxtd", y, n, q, i, u, x, t, d); - Append a structure composed of string and a D-Bus path: + Append a structure composed of a string and a D-Bus path: sd_bus_message_append(m, "(so)", "a string", "/a/path"); @@ -242,12 +256,8 @@ sd_bus_message_append(m, "ynqiuxtd", y, n, q, i, u, x, t, d); systemd1, sd-bus3, - sd_bus_new3, - sd_bus_ref3, - sd_bus_unref3, - ssh1, - systemd-machined.service8, - machinectl1 + sd_bus_message_append_basic3, + sd_bus_message_append_array3 diff --git a/man/sd_bus_message_append_array.xml b/man/sd_bus_message_append_array.xml index c2adc6f43d..034466bf9c 100644 --- a/man/sd_bus_message_append_array.xml +++ b/man/sd_bus_message_append_array.xml @@ -49,7 +49,8 @@ sd_bus_message_append_array_iovec sd_bus_message_append_array_space - Attach an array of items to a message + Appaned an array of fields to a D-Bus + message @@ -69,6 +70,8 @@ sd_bus_message *m char type int memfd + uint64_t offset + uint64_t size @@ -83,7 +86,7 @@ int sd_bus_message_append_array_space char type size_t size - char void **ptr + void **ptr @@ -91,18 +94,19 @@ Description - The sd_bus_message_append_array functionc - appends items to message m as the single - array. A container will be opened, items appended, and the - container closed. Parameter type determines - how pointer p is interpreted. + The sd_bus_message_append_array() + function appends an array to a D-Bus message + m. A container will be opened, the array + contents appended, and the container closed. The parameter + type determines how the pointer + p is interpreted. type must be one of the "trivial" types y, n, q, i, u, x, t, d (but not - b), as defined by the - Basic Types - section of the D-Bus specification, and listed in + b), as defined by the Basic + Types section of the D-Bus specification, and listed in sd_bus_message_append_basic3. Pointer p must point to an array of size size bytes containing items of the @@ -110,50 +114,68 @@ multiple of the size of the type type. As a special case, p may be NULL, if size is 0. - - - The memory pointed at by p is copied - into the memory area containing the message and may be changed - after this call. - - The - sd_bus_message_append_array_memfd function appends - items to message m, similarly to - sd_bus_message_append_array. Contents of the - memory file descriptor memfd are used as - the contents of the array. Their size must be a multiple of the - size of the type type. - - The descriptor specified with memfd - will be sealed and cannot be modified after this call. - - The - sd_bus_message_append_array_iovec function appends - items to message m, similarly to - sd_bus_message_append_array. Contents of the - iovec iov are used as the contents of the - array. The total size of iov payload (the - sum of iov_len fields) must be a multiple - of the size of the type type. - - The iov argument must point to - n struct iovec - structures. Each structure may have the - iov_base field set, in which case the - memory pointed to will be copied into the message, or unset, in - which case a block of zeros of length + The memory pointed to by p is copied into + the memory area containing the message and stays in possession of + the caller. The caller may hence freely change the data after this + call without affecting the message the array was appended + to. + + The sd_bus_message_append_array_memfd() + function appends an array of a trivial type to message + m, similar to + sd_bus_message_append_array(). The contents + of the memory file descriptor memfd + starting at the specified offset and and of the specified size is + used as the contents of the array. The offset and size must be a + multiple of the size of the type + type. However, as a special exception, if + the offset is specified as zero and the size specified as + UINT64_MAX the full memory file descriptor contents is used. The + memory file descriptor is sealed by this call if it hasn't been + sealed yet, and cannot be modified a after this call. See + memfd_create2 + for details about memory file descriptors. Appending arrays with + memory file descriptors enables efficient zero-copy data transfer, + as the memory file descriptor may be passed as-is to the + destination, without copying the memory in it to the destination + process. Not all protocol transports support passing memory file + descriptors between participants, in which case this call will + automatically fall back to copying. Also, as memory file + descriptor passing is inefficient for smaller amounts of data + copying might still be enforced even where memory file descriptor + passing is supported. + + The sd_bus_message_append_array_iovec() + function appends an array of a trivial type to the message + m, similar to + sd_bus_message_append_array(). Contents of + the IO vector array iov are used as the + contents of the array. The total size of + iov payload (the sum of + iov_len fields) must be a multiple of + the size of the type type. The + iov argument must point to + n IO vector structures. Each structure may + have the iov_base field set, in which + case the memory pointed to will be copied into the message, or + unset (set to zero), in which case a block of zeros of length iov_len bytes will be inserted. The memory pointed at by iov may be changed after this call. - The - sd_bus_message_append_array_space function appends - space for an array of items to message m. - It behaves the same as - sd_bus_message_append_array, but instead - of copying items to the message, it returns a pointer to the - destination area to the caller in pointer p. - + The sd_bus_message_append_array_space() + function appends space for an array of a trivial type to message + m. It behaves the same as + sd_bus_message_append_array(), but instead of + copying items to the message, it returns a pointer to the + destination area to the caller in pointer + p. The caller should subsequently write the + array contents to this memory. Modifications of the memory + pointed to should only occur until the next operation on the bus + message is invoked, most imporantly the memory should not be + altered anymore when another field has been added to the message + or the message has been sealed. @@ -183,6 +205,7 @@ sd-bus3, sd_bus_message_append3, sd_bus_message_append_basic3, + memfd_create2, The D-Bus specification diff --git a/man/sd_bus_message_append_basic.xml b/man/sd_bus_message_append_basic.xml index 91eaf87530..276953af69 100644 --- a/man/sd_bus_message_append_basic.xml +++ b/man/sd_bus_message_append_basic.xml @@ -45,7 +45,7 @@ sd_bus_message_append_basic - Attach a single part to a message + Attach a single field to a message @@ -56,7 +56,7 @@ int sd_bus_message_append_basic sd_bus_message *m char type - char void *p + const void *p @@ -64,31 +64,33 @@ Description - sd_bus_message_append_basic appends a - single item to the message m. Parameter - type determines how pointer + sd_bus_message_append_basic() appends a + single field to the message m. The + parameter type determines how the pointer p is interpreted. - type must be one of the basic types - as defined by the - - Basic Types - section of the D-Bus specification, and listed in the table below. + type must be one of the basic types as + defined by the Basic + Types section of the D-Bus specification, and listed in + the table below. - Item format specifiers + Item type specifiers - + + Specifier Constant Description Size + Expected C Type @@ -97,6 +99,7 @@ SD_BUS_TYPE_BYTEunsigned integer1 byte + uint8_t @@ -104,6 +107,7 @@ SD_BUS_TYPE_BOOLEAN boolean 4 bytes + int @@ -111,6 +115,7 @@ SD_BUS_TYPE_INT16 signed integer 2 bytes + int16_t @@ -118,6 +123,7 @@ SD_BUS_TYPE_UINT16 unsigned integer 2 bytes + uint16_t @@ -125,6 +131,7 @@ SD_BUS_TYPE_INT32 signed integer 4 bytes + int32_t @@ -132,6 +139,7 @@ SD_BUS_TYPE_UINT32 unsigned integer 4 bytes + uint32_t @@ -139,6 +147,7 @@ SD_BUS_TYPE_INT64 signed integer 8 bytes + int64_t @@ -146,6 +155,7 @@ SD_BUS_TYPE_UINT64 unsigned integer 8 bytes + uint64_t @@ -153,6 +163,7 @@ SD_BUS_TYPE_DOUBLE floating-point 8 bytes + double @@ -160,6 +171,7 @@ SD_BUS_TYPE_STRING Unicode string variable + char[] @@ -167,6 +179,7 @@ SD_BUS_TYPE_OBJECT_PATH object path variable + char[] @@ -174,6 +187,7 @@ SD_BUS_TYPE_SIGNATURE signature variable + char[] @@ -181,16 +195,19 @@ SD_BUS_TYPE_UNIX_FD UNIX file descriptor 4 bytes + int
- The value of the parameter is copied into the memory area - containing the message and may be changed after this call. If - type is h (UNIX file - descriptor), it is always "consumed" by this call, and either - successfully appended to the message or closed. + The value of the parameter is copied into a memory area held + by the message object, stays in the possession of the caller and + may hence be freely changed after this call without affecting the + bus message it has been added to. If type + is h (UNIX file descriptor), the descriptor is + duplicated by this call and the passed descriptor stays in + possession of the caller. For types s, o, and g, the parameter p is -- cgit v1.2.3