Function

Qmimessage_tlv_read_fixed_size_string

since: 1.12

Declaration [src]

gboolean
qmi_message_tlv_read_fixed_size_string (
  QmiMessage* self,
  gsize tlv_offset,
  gsize* offset,
  guint16 string_length,
  gchar* out,
  GError** error
)

Description [src]

Reads a string from the TLV.

The string written in out will need to be NUL-terminated by the caller.

offset needs to point to a valid gsize specifying the index to start reading from within the TLV value (0 for the first item). If the variable is successfully read, offset will be updated to point past the read item.

Since 1.24.6 the read string is guaranteed to be valid UTF-8.

The fixed sized field may be suffixed with e.g. 0xFF if the contents are shorter than string_length. Since 1.26, this method will return the valid UTF-8 characters in the start of the string, instead of returning an error when doing the full UTF-8 string validation.

Available since: 1.12

Parameters

self

Type: QmiMessage

A QmiMessage.

The data is owned by the caller of the function.
tlv_offset

Type: gsize

Offset that was returned by qmi_message_tlv_read_init().

offset

Type: gsize*

Address of a the offset within the TLV value.

The argument will be modified by the function.
string_length

Type: guint16

Amount of bytes to read.

out

Type: gchar*

Buffer preallocated by the client, with at least string_length bytes.

The argument will be set by the function.
The value is a NUL terminated UTF-8 string.
error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will be left initialized to NULL by the function if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: gboolean

TRUE if the variable is successfully read, otherwise FALSE is returned and error is set.