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

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



   sd_bus_message_read    ( 3 )

прочитать последовательность значений из сообщения (Read a sequence of values from a message)

  Name  |  Synopsis  |    Description    |  Return value  |  Note  |  Examples  |  See also  |

Описание (Description)

sd_bus_message_read() reads a sequence of fields from the D-Bus
       message object m and advances the read position in the message.
       The type string types describes the types of items expected in
       the message and the field arguments that follow. The type string
       may be NULL or empty, in which case nothing is read.

The type string is composed of the elements described in sd_bus_message_append(3), i.e. basic and container types. It must contain zero or more single "complete types". The type string is NUL-terminated.

For each type specified in the type string, one or more arguments need to be specified after the types parameter, in the same order. The arguments must be pointers to appropriate types (a pointer to int8_t for a "y" in the type string, a pointer to int32_t for an "i", a pointer to const char* for an "s", ...) which are set based on the values in the message. As an exception, in case of array and variant types, the first argument is an "input" argument that further specifies how the message should be read. See the table below for a complete list of allowed arguments and their types. Note that, if the basic type is a pointer (e.g., const char * in the case of a string), the argument is a pointer to a pointer, and also the pointer value that is written is only borrowed and the contents must be copied if they are to be used after the end of the message's lifetime. If the type is "h" (UNIX file descriptor), the descriptor is not duplicated by this call and the returned descriptor remains in possession of the message object, and needs to be duplicated by the caller in order to keep an open reference to it after the message object is freed.

Each argument may also be NULL, in which case the value is read and ignored.

Table 1. Item type specifiers ┌──────────┬──────────────────────────────┬────────────────┬──────────────┬──────────────┐ │Specifier Constant Description Type of the Types of the │ │ │ │ │ first subsequent │ │ │ │ │ argument arguments, │ │ │ │ │ │ if any │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"y" │ SD_BUS_TYPE_BYTE │ 8bit │ uint8_t * │ │ │ │ │ unsigned │ │ │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"b" │ SD_BUS_TYPE_BOOLEAN │ boolean │ int * (NB: │ │ │ │ │ │ not bool *) │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"n" │ SD_BUS_TYPE_INT16 │ 16bit signed │ int16_t * │ │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"q" │ SD_BUS_TYPE_UINT16 │ 16bit │ uint16_t * │ │ │ │ │ unsigned │ │ │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"i" │ SD_BUS_TYPE_INT32 │ 32bit signed │ int32_t * │ │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"u" │ SD_BUS_TYPE_UINT32 │ 32bit │ uint32_t * │ │ │ │ │ unsigned │ │ │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"x" │ SD_BUS_TYPE_INT64 │ 64bit signed │ int64_t * │ │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"t" │ SD_BUS_TYPE_UINT64 │ 64bit │ uint64_t * │ │ │ │ │ unsigned │ │ │ │ │ │ integer │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"d" │ SD_BUS_TYPE_DOUBLE │ IEEE 754 │ double * │ │ │ │ │ double │ │ │ │ │ │ precision │ │ │ │ │ │ floating-point │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"s" │ SD_BUS_TYPE_STRING │ UTF-8 string │ const char │ │ │ │ │ │ ** │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"o" │ SD_BUS_TYPE_OBJECT_PATH │ D-Bus object │ const char │ │ │ │ │ path string │ ** │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"g" │ SD_BUS_TYPE_SIGNATURE │ D-Bus │ const char │ │ │ │ │ signature │ ** │ │ │ │ │ string │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"h" │ SD_BUS_TYPE_UNIX_FD │ UNIX file │ int * │ │ │ │ │ descriptor │ │ │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"a" │ SD_BUS_TYPE_ARRAY │ array │ int, which │ n sets of │ │ │ │ │ specifies │ arguments │ │ │ │ │ the expected │ appropriate │ │ │ │ │ length n of │ for the │ │ │ │ │ the array │ array │ │ │ │ │ │ element type │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┼──────────────┤ │"v" │ SD_BUS_TYPE_VARIANT │ variant │ signature │ arguments │ │ │ │ │ string │ appropriate │ │ │ │ │ │ for the │ │ │ │ │ │ types │ │ │ │ │ │ specified by │ │ │ │ │ │ the │ │ │ │ │ │ signature │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┴──────────────┤ │"(" │ SD_BUS_TYPE_STRUCT_BEGIN │ array start │ arguments appropriate │ ├──────────┼──────────────────────────────┼────────────────┤ for the structure │ │")" │ SD_BUS_TYPE_STRUCT_END │ array end │ elements │ ├──────────┼──────────────────────────────┼────────────────┼──────────────┬──────────────┤ │"{" │ SD_BUS_TYPE_DICT_ENTRY_BEGIN │ dictionary │ arguments │ arguments │ │ │ │ entry start │ appropriate │ appropriate │ ├──────────┼──────────────────────────────┼────────────────┤ for the │ for the │ │"}" │ SD_BUS_TYPE_DICT_ENTRY_END │ dictionary │ first type │ second type │ │ │ │ entry end │ in the pair │ in the pair │ └──────────┴──────────────────────────────┴────────────────┴──────────────┴──────────────┘

If objects of the specified types are not present at the current position in the message, an error is returned.

The sd_bus_message_readv() is equivalent to the sd_bus_message_read(), 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.

sd_bus_message_peek_type() determines the type of the next element in m to be read by sd_bus_message_read() or similar functions. On success, the type is stored in type, if it is not NULL. If the type is a container type, the type of its elements is stored in contents, if it is not NULL. If this function successfully determines the type of the next element in m, it returns a positive integer. If there are no more elements to be read, it returns zero.