return;
_dbus_verbose ("Swapping message into compiler byte order\n");
-
+
get_const_signature (message, &type_str, &type_pos);
-
+
_dbus_marshal_byteswap (type_str, type_pos,
byte_order,
DBUS_COMPILER_BYTE_ORDER,
* Sets the serial number of a message.
* This can only be done once on a message.
*
- * DBusConnection will automatically set the serial to an appropriate value
- * when the message is sent; this function is only needed when encapsulating
+ * DBusConnection will automatically set the serial to an appropriate value
+ * when the message is sent; this function is only needed when encapsulating
* messages in another protocol, or otherwise bypassing DBusConnection.
*
* @param message the message
* @param serial the serial
*/
-void
+void
dbus_message_set_serial (DBusMessage *message,
dbus_uint32_t serial)
{
* reference to a message in the outgoing queue and change it
* underneath us. Messages are locked when they enter the outgoing
* queue (dbus_connection_send_message()), and the library complains
- * if the message is modified while locked. This function may also
+ * if the message is modified while locked. This function may also
* called externally, for applications wrapping D-Bus in another protocol.
*
* @param message the message to lock.
_dbus_assert (_dbus_atomic_get (&message->refcount) == 0);
_dbus_assert (message->counters == NULL);
-
+
_DBUS_UNLOCK (message_cache);
return message;
_dbus_assert (_dbus_atomic_get (&message->refcount) == 0);
_DBUS_UNLOCK (message_cache);
-
+
if (!was_cached)
dbus_message_finalize (message);
}
const char *s;
_dbus_type_reader_read_basic (&array,
(void *) &s);
-
+
str_array[j] = _dbus_strdup (s);
if (str_array[j] == NULL)
{
_DBUS_SET_OOM (error);
goto out;
}
-
+
++j;
-
+
if (!_dbus_type_reader_next (&array))
_dbus_assert (j == n_elements);
}
*
* The D-Bus specification goes into some more detail about header fields and
* message types.
- *
+ *
* @{
*/
dbus_message_set_reply_serial (DBusMessage *message,
dbus_uint32_t reply_serial)
{
- int type = DBUS_TYPE_UINT32;
+ DBusBasicValue value;
+ int type;
_dbus_return_val_if_fail (message != NULL, FALSE);
_dbus_return_val_if_fail (!message->locked, FALSE);
if (_dbus_message_is_gvariant (message))
{
- dbus_uint64_t reply_serial_uint64 = reply_serial;
type = DBUS_TYPE_UINT64;
- return _dbus_header_set_field_basic (&message->header,
- DBUS_HEADER_FIELD_REPLY_SERIAL,
- type,
- &reply_serial_uint64);
+ value.u64 = reply_serial;
+ }
+ else
+ {
+ type = DBUS_TYPE_UINT64;
+ value.u32 = reply_serial;
}
return _dbus_header_set_field_basic (&message->header,
DBUS_HEADER_FIELD_REPLY_SERIAL,
type,
- &reply_serial);
+ &value);
}
/**
*
* Destination, path, interface, and method name can't contain
* any invalid characters (see the D-Bus specification).
- *
+ *
* @param destination name that the message should be sent to or #NULL
* @param path object path the message should be sent to
* @param iface interface to invoke method on, or #NULL
*
* Path, interface, and signal name must all be valid (the D-Bus
* specification defines the syntax of these fields).
- *
+ *
* @param path the path to the object emitting the signal
* @param iface the interface the signal is emitted from
* @param name name of the signal
*
* @todo add _DBUS_GNUC_PRINTF to this (requires moving _DBUS_GNUC_PRINTF to
* public header, see DBUS_DEPRECATED for an example)
- *
+ *
* @param reply_to the original message
* @param error_name the error name
* @param error_format the error message format as with printf
char buf[2];
element_type = va_arg (var_args, int);
-
+
buf[0] = element_type;
buf[1] = '\0';
if (!dbus_message_iter_open_container (&iter,
value = va_arg (var_args, const DBusBasicValue**);
n_elements = va_arg (var_args, int);
-
+
if (!dbus_message_iter_append_fixed_array (&array,
element_type,
value,
const char **value;
int n_elements;
int i;
-
+
value_p = va_arg (var_args, const char***);
n_elements = va_arg (var_args, int);
value = *value_p;
-
+
i = 0;
while (i < n_elements)
{
*
* If more arguments than requested are present, the requested
* arguments are returned and the extra arguments are ignored.
- *
+ *
* @todo support DBUS_TYPE_STRUCT and DBUS_TYPE_VARIANT and complex arrays
*
* @param message the message
* message, we need to get in the right byte order
*/
ensure_byte_order (message);
-
+
real->message = message;
real->changed_stamp = message->changed_stamp;
real->iter_type = iter_type;
* Some types of argument can only be read with #DBusMessageIter
* however.
*
- * The easiest way to iterate is like this:
+ * The easiest way to iterate is like this:
* @code
* dbus_message_iter_init (message, &iter);
* while ((current_type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID)
*
* #DBusMessageIter contains no allocated memory; it need not be
* freed, and can be copied by assignment or memcpy().
- *
+ *
* @param message the message
* @param iter pointer to an iterator to initialize
* @returns #FALSE if the message has no arguments
* the variant's value.
*
* The returned string must be freed with dbus_free().
- *
+ *
* @param iter the message iterator
* @returns the contained signature, or NULL if out of memory
*/
* The value argument should be the address of a location to store the
* returned array. So for int32 it should be a "const dbus_int32_t**"
* The returned value is by reference and should not be freed.
- *
+ *
* This function should only be used if dbus_type_is_fixed() returns
* #TRUE for the element type.
*
* If an array's elements are not fixed in size, you have to recurse
* into the array with dbus_message_iter_recurse() and read the
* elements one by one.
- *
+ *
* Because the array is not copied, this function runs in constant
* time and is fast; it's much preferred over walking the entire array
* with an iterator. (However, you can always use
* dbus_message_iter_recurse(), even for fixed-length types;
* dbus_message_iter_get_fixed_array() is just an optimization.)
- *
+ *
* @param iter the iterator
* @param value location to store the block
* @param n_elements number of elements in the block
contained_signature != NULL) ||
(type == DBUS_TYPE_ARRAY &&
contained_signature != NULL), FALSE);
-
+
/* this would fail if the contained_signature is a dict entry, since
* dict entries are invalid signatures standalone (they must be in
* an array)
type,
NULL, 0,
&real_sub->u.writer);
- }
+ }
}
* required to reply.
*
* On the protocol level this toggles #DBUS_HEADER_FLAG_NO_REPLY_EXPECTED
- *
+ *
* @param message the message
* @param no_reply #TRUE if no reply is desired
*/
* The flag is set to #TRUE by default, i.e. auto starting is the default.
*
* On the protocol level this toggles #DBUS_HEADER_FLAG_NO_AUTO_START
- *
+ *
* @param message the message
* @param auto_start #TRUE if auto-starting is desired
*/
*
* The returned string becomes invalid if the message is
* modified, since it points into the wire-marshaled message data.
- *
+ *
* @param message the message
* @returns the path (should not be freed) or #NULL
*/
{
const char *msg_path;
msg_path = dbus_message_get_path (message);
-
+
if (msg_path == NULL)
{
if (path == NULL)
if (path == NULL)
return FALSE;
-
+
if (strcmp (msg_path, path) == 0)
return TRUE;
* and the path "/" becomes { NULL }.
*
* See also dbus_message_get_path().
- *
+ *
* @todo this could be optimized by using the len from the message
* instead of calling strlen() again
*
*
* The interface name must contain only valid characters as defined
* in the D-Bus specification.
- *
+ *
* @param message the message
* @param iface the interface or #NULL to unset
* @returns #FALSE if not enough memory
{
const char *msg_interface;
msg_interface = dbus_message_get_interface (message);
-
+
if (msg_interface == NULL)
{
if (iface == NULL)
if (iface == NULL)
return FALSE;
-
+
if (strcmp (msg_interface, iface) == 0)
return TRUE;
*
* The returned string becomes invalid if the message is
* modified, since it points into the wire-marshaled message data.
- *
+ *
* @param message the message
* @returns the member name (should not be freed) or #NULL
*/
{
const char *msg_member;
msg_member = dbus_message_get_member (message);
-
+
if (msg_member == NULL)
{
if (member == NULL)
if (member == NULL)
return FALSE;
-
+
if (strcmp (msg_member, member) == 0)
return TRUE;
*
* The returned string becomes invalid if the message is
* modified, since it points into the wire-marshaled message data.
- *
+ *
* @param message the message
* @returns the error name (should not be freed) or #NULL
*/
*
* The destination name must contain only valid characters as defined
* in the D-Bus specification.
- *
+ *
* @param message the message
* @param destination the destination name or #NULL to unset
* @returns #FALSE if not enough memory
* Note, the returned sender is always the unique bus name.
* Connections may own multiple other bus names, but those
* are not found in the sender field.
- *
+ *
* The returned string becomes invalid if the message is
* modified, since it points into the wire-marshaled message data.
*
loader = dbus_new0 (DBusMessageLoader, 1);
if (loader == NULL)
return NULL;
-
+
loader->refcount = 1;
loader->corrupted = FALSE;
dbus_uint32_t n_unix_fds = 0;
mode = DBUS_VALIDATION_MODE_DATA_IS_UNTRUSTED;
-
+
oom = FALSE;
#if 0
loader->corrupted = TRUE;
loader->corruption_reason = validity;
-
+
goto failed;
}
}
/* does nothing if the message isn't in the list */
_dbus_list_remove_last (&loader->messages, message);
-
+
if (oom)
_dbus_assert (!loader->corrupted);
else
_dbus_return_val_if_fail (msg != NULL, FALSE);
_dbus_return_val_if_fail (marshalled_data_p != NULL, FALSE);
_dbus_return_val_if_fail (len_p != NULL, FALSE);
-
+
if (!_dbus_string_init (&tmp))
return FALSE;
* @param buf data to be marshalled
* @param len the length of @p buf
* @returns -1 if there was no valid data to be demarshalled, 0 if there wasn't enough data to determine how much should be demarshalled. Otherwise returns the number of bytes to be demarshalled
- *
+ *
*/
-int
-dbus_message_demarshal_bytes_needed(const char *buf,
+int
+dbus_message_demarshal_bytes_needed(const char *buf,
int len)
{
DBusString str;
if (len > DBUS_MAXIMUM_MESSAGE_LENGTH)
len = DBUS_MAXIMUM_MESSAGE_LENGTH;
_dbus_string_init_const_len (&str, buf, len);
-
+
validity = DBUS_VALID;
have_message
= _dbus_header_have_message_untrusted(DBUS_MAXIMUM_MESSAGE_LENGTH,