summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-marshal.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2004-06-07 19:27:51 +0000
committerHavoc Pennington <hp@redhat.com>2004-06-07 19:27:51 +0000
commitf7beca572b341c4cabf2f97a9f0d6d763e6acb40 (patch)
tree9e82c7e0ceedf9a97fa3e68175bd3170afc83900 /dbus/dbus-marshal.c
parent41a369c333a2b60deaed307c22c88395f4d12cf6 (diff)
2004-06-07 Havoc Pennington <hp@redhat.com>
* dbus/dbus-message-builder.c (_dbus_message_data_load): append random signature when using REQUIRED_FIELDS (this hack won't work in the long term) * dbus/dbus-message.c: change the signature to be a header field, instead of message->signature special-case string. Incremental step forward. Then we can fix up code to send the signature in the message, then fix up code to validate said signature, then fix up code to not put the typecodes inline, etc. (load_one_message): don't make up the signature after the fact (decode_header_data): require signature field for the known message types * dbus/dbus-marshal.c (_dbus_marshal_string_len): new * dbus/dbus-protocol.h: add DBUS_HEADER_FIELD_SIGNATURE
Diffstat (limited to 'dbus/dbus-marshal.c')
-rw-r--r--dbus/dbus-marshal.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c
index 01bb6a17..267fa0f6 100644
--- a/dbus/dbus-marshal.c
+++ b/dbus/dbus-marshal.c
@@ -2,7 +2,7 @@
/* dbus-marshal.c Marshalling routines
*
* Copyright (C) 2002 CodeFactory AB
- * Copyright (C) 2003 Red Hat, Inc.
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
*
* Licensed under the Academic Free License version 2.0
*
@@ -608,6 +608,46 @@ _dbus_marshal_string (DBusString *str,
}
/**
+ * Marshals a UTF-8 string
+ *
+ * @todo: If the string append fails we need to restore
+ * the old length. (also for other marshallers)
+ *
+ * @param str the string to append the marshalled value to
+ * @param byte_order the byte order to use
+ * @param value the string
+ * @param len length of string to marshal in bytes
+ * @returns #TRUE on success
+ */
+dbus_bool_t
+_dbus_marshal_string_len (DBusString *str,
+ int byte_order,
+ const char *value,
+ int len)
+{
+ int old_string_len;
+
+ old_string_len = _dbus_string_get_length (str);
+
+ if (!_dbus_marshal_uint32 (str, byte_order, len))
+ {
+ /* Restore the previous length */
+ _dbus_string_set_length (str, old_string_len);
+
+ return FALSE;
+ }
+
+ if (!_dbus_string_append_len (str, value, len))
+ return FALSE;
+
+ /* add a nul byte */
+ if (!_dbus_string_lengthen (str, 1))
+ return FALSE;
+
+ return TRUE;
+}
+
+/**
* Marshals a byte array
*
* @param str the string to append the marshalled value to