summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-string.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-28 03:06:56 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-28 03:06:56 +0000
commit3ed9db546e1143bc9aa2d83a6f423fdd81227352 (patch)
tree6ba7a785ddeff02224072cc51faf108482dfb0c7 /dbus/dbus-string.c
parent4506b6594b4a86557fad7850f56b5fdabd3108de (diff)
2005-01-27 Havoc Pennington <hp@redhat.com>
* dbus/dbus-arch-deps.h.in: add 16/32-bit types * configure.in: find the right type for 16 and 32 bit ints as well as 64 * dbus/dbus-protocol.h (DBUS_TYPE_INT16, DBUS_TYPE_UINT16): add the 16-bit types so people don't have to stuff them in 32-bit or byte arrays.
Diffstat (limited to 'dbus/dbus-string.c')
-rw-r--r--dbus/dbus-string.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index 154193ce..f64d4746 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -974,6 +974,9 @@ _dbus_string_append (DBusString *str,
return append (real, buffer, buffer_len);
}
+/** assign 2 bytes from one string to another */
+#define ASSIGN_2_OCTETS(p, octets) \
+ *((dbus_uint16_t*)(p)) = *((dbus_uint16_t*)(octets));
/** assign 4 bytes from one string to another */
#define ASSIGN_4_OCTETS(p, octets) \
@@ -1052,6 +1055,30 @@ _dbus_string_append_8_aligned (DBusString *str,
#endif /* DBUS_BUILD_TESTS */
/**
+ * Inserts 2 bytes aligned on a 2 byte boundary
+ * with any alignment padding initialized to 0.
+ *
+ * @param str the DBusString
+ * @param insert_at where to insert
+ * @param octets 2 bytes to insert
+ * @returns #FALSE if not enough memory.
+ */
+dbus_bool_t
+_dbus_string_insert_2_aligned (DBusString *str,
+ int insert_at,
+ const unsigned char octets[4])
+{
+ DBUS_STRING_PREAMBLE (str);
+
+ if (!align_insert_point_then_open_gap (str, &insert_at, 2, 2))
+ return FALSE;
+
+ ASSIGN_2_OCTETS (real->str + insert_at, octets);
+
+ return TRUE;
+}
+
+/**
* Inserts 4 bytes aligned on a 4 byte boundary
* with any alignment padding initialized to 0.
*
@@ -1109,7 +1136,7 @@ _dbus_string_insert_8_aligned (DBusString *str,
*
* @param str the DBusString
* @param insert_at location to be aligned
- * @param alignment alignment boundary (1, 4, or 8)
+ * @param alignment alignment boundary (1, 2, 4, or 8)
* @returns #FALSE if not enough memory.
*/
dbus_bool_t