Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   sd_bus_message_appendv    ( 3 )

прикрепляйте поля к сообщению D-Bus на основе строки типа (Attach fields to a D-Bus message based on a type string)

  Name  |  Synopsis  |    Description    |  Types string grammar  |  Examples  |  Return value  |  Note  |  See also  |

Описание (Description)

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 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 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 type is expected.

A structure is denoted by a sequence of complete types between "(" and ")". This sequence cannot be empty — it must contain at least one type. Arguments corresponding to this nested sequence follow the same rules as if they were not nested.

A variant is denoted by "v". Corresponding 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 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 begin with the number of dictionary entries, followed by a pair of values for each entry matching the element type of the dictionary entries.

sd_bus_message_appendv() is equivalent to sd_bus_message_append(), except that it is called with a "va_list" instead of a variable number of arguments. This function does not call the va_end() macro. Because it invokes the va_arg() macro, the value of ap is undefined after the call.

For further details on the D-Bus type system, please consult the D-Bus Specification[1].

Table 1. Item type specifiers ┌──────────┬──────────────────────────────┬────────────────┬──────────────┬─────────────┐ │Specifier Constant Description Size Expected C │ │ │ │ │ │ Type │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"y" │ SD_BUS_TYPE_BYTE │ unsigned │ 1 byte │ uint8_t │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"b" │ SD_BUS_TYPE_BOOLEAN │ boolean │ 4 bytes │ int │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"n" │ SD_BUS_TYPE_INT16 │ signed │ 2 bytes │ int16_t │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"q" │ SD_BUS_TYPE_UINT16 │ unsigned │ 2 bytes │ uint16_t │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"i" │ SD_BUS_TYPE_INT32 │ signed │ 4 bytes │ int32_t │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"u" │ SD_BUS_TYPE_UINT32 │ unsigned │ 4 bytes │ uint32_t │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"x" │ SD_BUS_TYPE_INT64 │ signed │ 8 bytes │ int64_t │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"t" │ SD_BUS_TYPE_UINT64 │ unsigned │ 8 bytes │ uint64_t │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"d" │ SD_BUS_TYPE_DOUBLE │ floating-point │ 8 bytes │ double │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"s" │ SD_BUS_TYPE_STRING │ Unicode string │ variable │ char[] │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"o" │ SD_BUS_TYPE_OBJECT_PATH │ object path │ variable │ char[] │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"g" │ SD_BUS_TYPE_SIGNATURE │ signature │ variable │ char[] │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"h" │ SD_BUS_TYPE_UNIX_FD │ UNIX file │ 4 bytes │ int │ │ │ │ descriptor │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"a" │ SD_BUS_TYPE_ARRAY │ array │ determined │ int, │ │ │ │ │ by array │ followed by │ │ │ │ │ type and │ array │ │ │ │ │ size │ contents │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"v" │ SD_BUS_TYPE_VARIANT │ variant │ determined │ signature │ │ │ │ │ by the type │ string, │ │ │ │ │ argument │ followed by │ │ │ │ │ │ variant │ │ │ │ │ │ contents │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"(" │ SD_BUS_TYPE_STRUCT_BEGIN │ array start │ determined │ structure │ ├──────────┼──────────────────────────────┼────────────────┤ by the │ contents │ │")" │ SD_BUS_TYPE_STRUCT_END │ array end │ nested types │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼─────────────┤ │"{" │ SD_BUS_TYPE_DICT_ENTRY_BEGIN │ dictionary │ │ │ │ │ │ entry start │ determined │ dictionary │ ├──────────┼──────────────────────────────┼────────────────┤ by the │ contents │ │"}" │ SD_BUS_TYPE_DICT_ENTRY_END │ dictionary │ nested types │ │ │ │ │ entry end │ │ │ └──────────┴──────────────────────────────┴────────────────┴──────────────┴─────────────┘

For types "s" and "g" (unicode string or signature), the pointer may be NULL, which is equivalent to an empty string. For "h" (UNIX file descriptor), the descriptor is duplicated by this call and the passed descriptor stays in possession of the caller. See sd_bus_message_append_basic(3) for the precise interpretation of those and other types.