summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--dbus/Makefile.am2
-rw-r--r--dbus/dbus-marshal.c157
-rw-r--r--dbus/dbus-marshal.h28
-rw-r--r--dbus/dbus-objectid.c292
-rw-r--r--dbus/dbus-objectid.h61
-rw-r--r--dbus/dbus-protocol.h5
-rw-r--r--dbus/dbus-test.c6
-rw-r--r--dbus/dbus-test.h1
-rw-r--r--dbus/dbus-types.h8
-rw-r--r--dbus/dbus.h1
11 files changed, 532 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index e6840083..527ad1fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2003-07-06 Havoc Pennington <hp@pobox.com>
+
+ * dbus/dbus-marshal.c (_dbus_marshal_set_object_id): new function
+ (_dbus_marshal_object_id): new
+ (_dbus_demarshal_object_id): new
+ (_dbus_marshal_get_arg_end_pos): support object ID type, and
+ consolidate identical switch cases. Don't conditionalize handling
+ of DBUS_TYPE_UINT64, need to handle the type always.
+ (_dbus_marshal_validate_arg): consolidate identical cases, and
+ handle DBUS_TYPE_OBJECT_ID
+
+ * dbus/dbus-objectid.c: new file with DBusObjectID data type.
+
+ * dbus/dbus-protocol.h: add DBUS_TYPE_OBJECT_ID
+
2003-06-29 Havoc Pennington <hp@pobox.com>
* mono/Test.cs (class Test): fire up a main loop and run it
diff --git a/dbus/Makefile.am b/dbus/Makefile.am
index eac68c6a..3c3c14e7 100644
--- a/dbus/Makefile.am
+++ b/dbus/Makefile.am
@@ -17,6 +17,7 @@ dbusinclude_HEADERS= \
dbus-memory.h \
dbus-message.h \
dbus-message-handler.h \
+ dbus-objectid.h \
dbus-protocol.h \
dbus-server.h \
dbus-threads.h \
@@ -42,6 +43,7 @@ DBUS_LIB_SOURCES= \
dbus-message.c \
dbus-message-handler.c \
dbus-message-internal.h \
+ dbus-objectid.c \
dbus-resources.c \
dbus-resources.h \
dbus-server.c \
diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c
index 5d7290e3..2399a282 100644
--- a/dbus/dbus-marshal.c
+++ b/dbus/dbus-marshal.c
@@ -80,6 +80,19 @@ typedef union
dbus_uint64_t u;
#endif
double d;
+#ifdef WORDS_BIGENDIAN
+ struct
+ {
+ dbus_uint32_t high;
+ dbus_uint32_t low;
+ } bits;
+#else
+ struct
+ {
+ dbus_uint32_t low;
+ dbus_uint32_t high;
+ } bits;
+#endif
} DBusOctets8;
static DBusOctets8
@@ -423,6 +436,35 @@ _dbus_marshal_set_string (DBusString *str,
return TRUE;
}
+/**
+ * Sets the existing marshaled object ID at the given offset to a new
+ * value. The given offset must point to an existing object ID or this
+ * function doesn't make sense.
+ *
+ * @param str the string to write the marshalled string to
+ * @param offset the byte offset where string should be written
+ * @param byte_order the byte order to use
+ * @param value the new value
+ */
+void
+_dbus_marshal_set_object_id (DBusString *str,
+ int byte_order,
+ int offset,
+ const DBusObjectID *value)
+{
+ DBusOctets8 r;
+#ifdef DBUS_HAVE_INT64
+ r.u = dbus_object_id_get_as_integer (value);
+#else
+ r.bits.low = dbus_object_id_get_low_bits (value);
+ r.bits.high = dbus_object_id_get_high_bits (value);
+#endif
+ _dbus_assert (r.bits.low == dbus_object_id_get_low_bits (value));
+ _dbus_assert (r.bits.high == dbus_object_id_get_high_bits (value));
+
+ set_8_octets (str, byte_order, offset, r);
+}
+
static dbus_bool_t
marshal_4_octets (DBusString *str,
int byte_order,
@@ -844,6 +886,32 @@ _dbus_marshal_string_array (DBusString *str,
return FALSE;
}
+/**
+ * Marshals an object ID value.
+ *
+ * @param str the string to append the marshalled value to
+ * @param byte_order the byte order to use
+ * @param value the value
+ * @returns #TRUE on success
+ */
+dbus_bool_t
+_dbus_marshal_object_id (DBusString *str,
+ int byte_order,
+ const DBusObjectID *value)
+{
+ DBusOctets8 r;
+#ifdef DBUS_HAVE_INT64
+ r.u = dbus_object_id_get_as_integer (value);
+#else
+ r.bits.low = dbus_object_id_get_low_bits (value);
+ r.bits.high = dbus_object_id_get_high_bits (value);
+#endif
+ _dbus_assert (r.bits.low == dbus_object_id_get_low_bits (value));
+ _dbus_assert (r.bits.high == dbus_object_id_get_high_bits (value));
+
+ return marshal_8_octets (str, byte_order, r);
+}
+
static dbus_uint32_t
demarshal_4_octets (const DBusString *str,
int byte_order,
@@ -1393,6 +1461,36 @@ _dbus_demarshal_string_array (const DBusString *str,
return FALSE;
}
+/**
+ * Demarshals an object ID.
+ *
+ * @param str the string containing the data
+ * @param byte_order the byte order
+ * @param pos the position in the string
+ * @param new_pos the new position of the string
+ * @param value address to store new object ID
+ */
+void
+_dbus_demarshal_object_id (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ DBusObjectID *value)
+{
+ DBusOctets8 r;
+
+ r = demarshal_8_octets (str, byte_order, pos, new_pos);
+
+#ifdef DBUS_HAVE_INT64
+ dbus_object_id_set_as_integer (value, r.u);
+#else
+ dbus_object_id_set_low_bits (value, r.bits.low);
+ dbus_object_id_set_high_bits (value, r.bits.high);
+#endif
+ _dbus_assert (dbus_object_id_get_low_bits (value) == r.bits.low);
+ _dbus_assert (dbus_object_id_get_high_bits (value) == r.bits.high);
+}
+
/**
* Returns the position right after the end of an argument. PERFORMS
* NO VALIDATION WHATSOEVER. The message must have been previously
@@ -1435,30 +1533,16 @@ _dbus_marshal_get_arg_end_pos (const DBusString *str,
break;
case DBUS_TYPE_INT32:
- *end_pos = _DBUS_ALIGN_VALUE (pos, sizeof (dbus_int32_t)) + sizeof (dbus_int32_t);
-
- break;
-
case DBUS_TYPE_UINT32:
- *end_pos = _DBUS_ALIGN_VALUE (pos, sizeof (dbus_uint32_t)) + sizeof (dbus_uint32_t);
-
+ *end_pos = _DBUS_ALIGN_VALUE (pos, 4) + 4;
break;
-#ifdef DBUS_HAVE_INT64
case DBUS_TYPE_INT64:
- *end_pos = _DBUS_ALIGN_VALUE (pos, sizeof (dbus_int64_t)) + sizeof (dbus_int64_t);
-
- break;
-
case DBUS_TYPE_UINT64:
- *end_pos = _DBUS_ALIGN_VALUE (pos, sizeof (dbus_uint64_t)) + sizeof (dbus_uint64_t);
-
- break;
-#endif /* DBUS_HAVE_INT64 */
-
+ case DBUS_TYPE_OBJECT_ID:
case DBUS_TYPE_DOUBLE:
- *end_pos = _DBUS_ALIGN_VALUE (pos, sizeof (double)) + sizeof (double);
-
+
+ *end_pos = _DBUS_ALIGN_VALUE (pos, 8) + 8;
break;
case DBUS_TYPE_STRING:
@@ -1717,6 +1801,7 @@ validate_array_data (const DBusString *str,
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
+ case DBUS_TYPE_OBJECT_ID:
/* Call validate arg one time to check alignment padding
* at start of array
*/
@@ -1842,22 +1927,9 @@ _dbus_marshal_validate_arg (const DBusString *str,
break;
case DBUS_TYPE_INT64:
- case DBUS_TYPE_UINT64:
- {
- int align_8 = _DBUS_ALIGN_VALUE (pos, 8);
-
- if (!_dbus_string_validate_nul (str, pos,
- align_8 - pos))
- {
- _dbus_verbose ("int64/uint64 alignment padding not initialized to nul\n");
- return FALSE;
- }
-
- *end_pos = align_8 + 8;
- }
- break;
-
+ case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
+ case DBUS_TYPE_OBJECT_ID:
{
int align_8 = _DBUS_ALIGN_VALUE (pos, 8);
@@ -1866,7 +1938,7 @@ _dbus_marshal_validate_arg (const DBusString *str,
if (!_dbus_string_validate_nul (str, pos,
align_8 - pos))
{
- _dbus_verbose ("double alignment padding not initialized to nul\n");
+ _dbus_verbose ("double/int64/uint64/objid alignment padding not initialized to nul\n");
return FALSE;
}
@@ -2177,6 +2249,7 @@ _dbus_marshal_test (void)
#endif
char *s;
DBusString t;
+ DBusObjectID obj_id, obj_id2;
if (!_dbus_string_init (&str))
_dbus_assert_not_reached ("failed to init string");
@@ -2237,6 +2310,22 @@ _dbus_marshal_test (void)
if (!(_dbus_demarshal_uint64 (&str, DBUS_LITTLE_ENDIAN, pos, &pos) == DBUS_UINT64_CONSTANT (0x123456789abc7)))
_dbus_assert_not_reached ("demarshal failed");
#endif /* DBUS_HAVE_INT64 */
+
+ /* Marshal object IDs */
+ dbus_object_id_set_high_bits (&obj_id, 0xfffe);
+ dbus_object_id_set_low_bits (&obj_id, 0xaacc);
+
+ if (!_dbus_marshal_object_id (&str, DBUS_BIG_ENDIAN, &obj_id))
+ _dbus_assert_not_reached ("could not marshal object ID value");
+ _dbus_demarshal_object_id (&str, DBUS_BIG_ENDIAN, pos, &pos, &obj_id2);
+ if (!dbus_object_id_equal (&obj_id, &obj_id2))
+ _dbus_assert_not_reached ("demarshal failed");
+
+ if (!_dbus_marshal_object_id (&str, DBUS_LITTLE_ENDIAN, &obj_id))
+ _dbus_assert_not_reached ("could not marshal object ID value");
+ _dbus_demarshal_object_id (&str, DBUS_LITTLE_ENDIAN, pos, &pos, &obj_id2);
+ if (!dbus_object_id_equal (&obj_id, &obj_id2))
+ _dbus_assert_not_reached ("demarshal failed");
/* Marshal strings */
tmp1 = "This is the dbus test string";
diff --git a/dbus/dbus-marshal.h b/dbus/dbus-marshal.h
index 1eff8995..af18876a 100644
--- a/dbus/dbus-marshal.h
+++ b/dbus/dbus-marshal.h
@@ -29,6 +29,7 @@
#include <dbus/dbus-types.h>
#include <dbus/dbus-arch-deps.h>
#include <dbus/dbus-string.h>
+#include <dbus/dbus-objectid.h>
#ifndef PACKAGE
#error "config.h not included here"
@@ -152,11 +153,16 @@ void _dbus_marshal_set_uint64 (DBusString *str,
int offset,
dbus_uint64_t value);
#endif /* DBUS_HAVE_INT64 */
-dbus_bool_t _dbus_marshal_set_string (DBusString *str,
- int byte_order,
- int offset,
- const DBusString *value,
- int len);
+
+dbus_bool_t _dbus_marshal_set_string (DBusString *str,
+ int byte_order,
+ int offset,
+ const DBusString *value,
+ int len);
+void _dbus_marshal_set_object_id (DBusString *str,
+ int byte_order,
+ int offset,
+ const DBusObjectID *value);
dbus_bool_t _dbus_marshal_int32 (DBusString *str,
int byte_order,
@@ -208,6 +214,10 @@ dbus_bool_t _dbus_marshal_string_array (DBusString *str,
int byte_order,
const char **value,
int len);
+dbus_bool_t _dbus_marshal_object_id (DBusString *str,
+ int byte_order,
+ const DBusObjectID *value);
+
double _dbus_demarshal_double (const DBusString *str,
int byte_order,
int pos,
@@ -278,9 +288,11 @@ dbus_bool_t _dbus_demarshal_string_array (const DBusString *str,
int *new_pos,
char ***array,
int *array_len);
-
-
-
+void _dbus_demarshal_object_id (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ DBusObjectID *value);
dbus_bool_t _dbus_marshal_get_arg_end_pos (const DBusString *str,
int byte_order,
diff --git a/dbus/dbus-objectid.c b/dbus/dbus-objectid.c
new file mode 100644
index 00000000..1fb83e44
--- /dev/null
+++ b/dbus/dbus-objectid.c
@@ -0,0 +1,292 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-objectid.c DBusObjectID type
+ *
+ * Copyright (C) 2003 Red Hat Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "dbus-objectid.h"
+#include "dbus-internals.h"
+
+#ifdef DBUS_HAVE_INT64
+#define VALUE(objid) ((objid)->dbus_do_not_use_dummy1)
+#define HIGH_BITS(objid) ((dbus_uint32_t) (VALUE (obj_id) >> 32))
+#define LOW_BITS(objid) ((dbus_uint32_t) (VALUE (obj_id) & DBUS_UINT64_CONSTANT (0x00000000ffffffff)))
+#else
+#define HIGH_BITS(objid) ((objid)->dbus_do_not_use_dummy1)
+#define LOW_BITS(objid) ((objid)->dbus_do_not_use_dummy2)
+#endif
+
+/**
+ * @defgroup DBusObjectID object IDs
+ * @ingroup DBusObjectID
+ * @brief object ID datatype
+ *
+ * Value type representing an object ID, i.e. an object in the remote
+ * application that can be communicated with.
+ *
+ * @{
+ */
+
+/**
+ * Checks whether two object IDs have the same value.
+ *
+ * @param a the first object ID
+ * @param b the second object ID
+ * @returns #TRUE if they are equal
+ */
+dbus_bool_t
+dbus_object_id_equal (const DBusObjectID *a,
+ const DBusObjectID *b)
+{
+#ifdef DBUS_HAVE_INT64
+ return VALUE (a) == VALUE (b);
+#else
+ return HIGH_BITS (a) == HIGH_BITS (b) &&
+ LOW_BITS (a) == LOW_BITS (b);
+#endif
+}
+
+/**
+ * Compares two object IDs, appropriate for
+ * qsort(). Higher/lower IDs have no significance,
+ * but the comparison can be used for data structures
+ * that require ordering.
+ *
+ * @param a the first object ID
+ * @param b the second object ID
+ * @returns -1, 0, 1 as with strcmp()
+ */
+int
+dbus_object_id_compare (const DBusObjectID *a,
+ const DBusObjectID *b)
+{
+#ifdef DBUS_HAVE_INT64
+ if (VALUE (a) > VALUE (b))
+ return 1;
+ else if (VALUE (a) < VALUE (b))
+ return -1;
+ else
+ return 0;
+#else
+ if (HIGH_BITS (a) > HIGH_BITS (b))
+ return 1;
+ else if (HIGH_BITS (a) < HIGH_BITS (b))
+ return -1;
+ else if (LOW_BITS (a) > LOW_BITS (b))
+ return 1;
+ else if (LOW_BITS (a) < LOW_BITS (b))
+ return -1;
+ else
+ return 0;
+#endif
+}
+
+/**
+ * An object ID contains 64 bits of data. This function
+ * returns half of those bits. If you are willing to limit
+ * portability to compilers with a 64-bit type (this includes
+ * C99 compilers and almost all other compilers) consider
+ * dbus_object_id_get_as_integer() instead.
+ *
+ * @param obj_id the object ID
+ * @returns the high bits of the ID
+ *
+ */
+dbus_uint32_t
+dbus_object_id_get_high_bits (const DBusObjectID *obj_id)
+{
+ return HIGH_BITS (obj_id);
+}
+
+/**
+ * An object ID contains 64 bits of data. This function
+ * returns half of those bits. If you are willing to limit
+ * portability to compilers with a 64-bit type (this includes
+ * C99 compilers and almost all other compilers) consider
+ * dbus_object_id_get_as_integer() instead.
+ *
+ * @param obj_id the object ID
+ * @returns the low bits of the ID
+ *
+ */
+dbus_uint32_t
+dbus_object_id_get_low_bits (const DBusObjectID *obj_id)
+{
+ return LOW_BITS (obj_id);
+}
+
+/**
+ * An object ID contains 64 bits of data. This function
+ * sets half of those bits. If you are willing to limit
+ * portability to compilers with a 64-bit type (this includes
+ * C99 compilers and almost all other compilers) consider
+ * dbus_object_id_set_as_integer() instead.
+ *
+ * @param obj_id the object ID
+ * @param value the new value of the high bits
+ *
+ */
+void
+dbus_object_id_set_high_bits (DBusObjectID *obj_id,
+ dbus_uint32_t value)
+{
+#ifdef DBUS_HAVE_INT64
+ VALUE (obj_id) = (((dbus_uint64_t) value) << 32) | LOW_BITS (obj_id);
+#else
+ HIGH_BITS (obj_id) = value;
+#endif
+}
+
+/**
+ * An object ID contains 64 bits of data. This function
+ * sets half of those bits. If you are willing to limit
+ * portability to compilers with a 64-bit type (this includes
+ * C99 compilers and almost all other compilers) consider
+ * dbus_object_id_set_as_integer() instead.
+ *
+ * @param obj_id the object ID
+ * @param value the new value of the low bits
+ *
+ */
+void
+dbus_object_id_set_low_bits (DBusObjectID *obj_id,
+ dbus_uint32_t value)
+{
+#ifdef DBUS_HAVE_INT64
+ VALUE (obj_id) = ((dbus_uint64_t) value) |
+ (((dbus_uint64_t) HIGH_BITS (obj_id)) << 32);
+#else
+ LOW_BITS (obj_id) = value;
+#endif
+}
+
+#ifdef DBUS_HAVE_INT64
+/**
+ * An object ID contains 64 bits of data. This function
+ * returns all of them as a 64-bit integer.
+ *
+ * Use this function only if you are willing to limit portability to
+ * compilers with a 64-bit type (this includes C99 compilers and
+ * almost all other compilers).
+ *
+ * This function only exists if DBUS_HAVE_INT64 is defined.
+ *
+ * @param obj_id the object ID
+ * @returns the object ID as a 64-bit integer.
+ */
+dbus_uint64_t
+dbus_object_id_get_as_integer (const DBusObjectID *obj_id)
+{
+ return VALUE (obj_id);
+}
+
+/**
+ * An object ID contains 64 bits of data. This function sets all of
+ * them as a 64-bit integer.
+ *
+ * Use this function only if you are willing to limit portability to
+ * compilers with a 64-bit type (this includes C99 compilers and
+ * almost all other compilers).
+ *
+ * This function only exists if #DBUS_HAVE_INT64 is defined.
+ *
+ * @param obj_id the object ID
+ * @param value the new value of the object ID
+ */
+void
+dbus_object_id_set_as_integer (DBusObjectID *obj_id,
+ dbus_uint64_t value)
+{
+ VALUE (obj_id) = value;
+}
+#endif /* DBUS_HAVE_INT64 */
+
+/** @} */
+
+#ifdef DBUS_BUILD_TESTS
+#include "dbus-test.h"
+#include <stdio.h>
+
+/**
+ * Test for object ID routines.
+ *
+ * @returns #TRUE on success
+ */
+dbus_bool_t
+_dbus_object_id_test (void)
+{
+ DBusObjectID tmp;
+ DBusObjectID tmp2;
+
+ dbus_object_id_set_high_bits (&tmp, 340);
+ _dbus_assert (dbus_object_id_get_high_bits (&tmp) == 340);
+
+ dbus_object_id_set_low_bits (&tmp, 1492);
+ _dbus_assert (dbus_object_id_get_low_bits (&tmp) == 1492);
+ _dbus_assert (dbus_object_id_get_high_bits (&tmp) == 340);
+
+ tmp2 = tmp;
+ _dbus_assert (dbus_object_id_equal (&tmp, &tmp2));
+
+#ifdef DBUS_HAVE_INT64
+ _dbus_assert (dbus_object_id_get_as_integer (&tmp) ==
+ ((DBUS_UINT64_CONSTANT (340) << 32) |
+ DBUS_UINT64_CONSTANT (1492)));
+
+ dbus_object_id_set_as_integer (&tmp, _DBUS_UINT64_MAX);
+ _dbus_assert (dbus_object_id_get_as_integer (&tmp) ==
+ _DBUS_UINT64_MAX);
+ _dbus_assert (dbus_object_id_get_high_bits (&tmp) ==
+ _DBUS_UINT_MAX);
+ _dbus_assert (dbus_object_id_get_low_bits (&tmp) ==
+ _DBUS_UINT_MAX);
+
+ dbus_object_id_set_as_integer (&tmp, 1);
+ dbus_object_id_set_as_integer (&tmp2, 2);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == -1);
+ dbus_object_id_set_as_integer (&tmp2, 0);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 1);
+ dbus_object_id_set_as_integer (&tmp2, 1);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
+#endif
+
+ tmp2 = tmp;
+
+ dbus_object_id_set_high_bits (&tmp, 1);
+ dbus_object_id_set_high_bits (&tmp2, 2);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == -1);
+ dbus_object_id_set_high_bits (&tmp2, 0);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 1);
+ dbus_object_id_set_high_bits (&tmp2, 1);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
+
+ dbus_object_id_set_low_bits (&tmp, 1);
+
+ dbus_object_id_set_low_bits (&tmp2, 2);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == -1);
+ dbus_object_id_set_low_bits (&tmp2, 0);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 1);
+ dbus_object_id_set_low_bits (&tmp2, 1);
+ _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
+
+ return TRUE;
+}
+
+#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-objectid.h b/dbus/dbus-objectid.h
new file mode 100644
index 00000000..57346910
--- /dev/null
+++ b/dbus/dbus-objectid.h
@@ -0,0 +1,61 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-objectid.h DBusObjectID type
+ *
+ * Copyright (C) 2003 Red Hat Inc.
+ *
+ * Licensed under the Academic Free License version 1.2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
+#error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef DBUS_OBJECTID_H
+#define DBUS_OBJECTID_H
+
+#include <dbus/dbus-arch-deps.h>
+#include <dbus/dbus-types.h>
+
+typedef struct DBusObjectID DBusObjectID;
+
+struct DBusObjectID
+{
+#ifdef DBUS_HAVE_INT64
+ dbus_uint64_t dbus_do_not_use_dummy1;
+#else
+ dbus_uint32_t dbus_do_not_use_dummy1;
+ dbus_uint32_t dbus_do_not_use_dummy2;
+#endif
+};
+
+dbus_bool_t dbus_object_id_equal (const DBusObjectID *a,
+ const DBusObjectID *b);
+int dbus_object_id_compare (const DBusObjectID *a,
+ const DBusObjectID *b);
+dbus_uint32_t dbus_object_id_get_high_bits (const DBusObjectID *obj_id);
+dbus_uint32_t dbus_object_id_get_low_bits (const DBusObjectID *obj_id);
+void dbus_object_id_set_high_bits (DBusObjectID *obj_id,
+ dbus_uint32_t value);
+void dbus_object_id_set_low_bits (DBusObjectID *obj_id,
+ dbus_uint32_t value);
+#ifdef DBUS_HAVE_INT64
+dbus_uint64_t dbus_object_id_get_as_integer (const DBusObjectID *obj_id);
+void dbus_object_id_set_as_integer (DBusObjectID *obj_id,
+ dbus_uint64_t value);
+#endif
+
+#endif /* DBUS_OBJECTID_H */
diff --git a/dbus/dbus-protocol.h b/dbus/dbus-protocol.h
index fbdcb6dd..82bb6e3c 100644
--- a/dbus/dbus-protocol.h
+++ b/dbus/dbus-protocol.h
@@ -53,8 +53,9 @@ extern "C" {
#define DBUS_TYPE_NAMED 10
#define DBUS_TYPE_ARRAY 11
#define DBUS_TYPE_DICT 12
-
-#define DBUS_TYPE_LAST DBUS_TYPE_DICT
+#define DBUS_TYPE_OBJECT_ID 13
+
+#define DBUS_TYPE_LAST DBUS_TYPE_OBJECT_ID
/* Max length in bytes of a service or message name */
#define DBUS_MAXIMUM_NAME_LENGTH 256
diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c
index 2fbab5a4..3d5d14bb 100644
--- a/dbus/dbus-test.c
+++ b/dbus/dbus-test.c
@@ -99,6 +99,12 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)
die ("address parsing");
check_memleaks ();
+
+ printf ("%s: running object ID tests\n", "dbus-test");
+ if (!_dbus_object_id_test ())
+ die ("object ID");
+
+ check_memleaks ();
printf ("%s: running marshalling tests\n", "dbus-test");
if (!_dbus_marshal_test ())
diff --git a/dbus/dbus-test.h b/dbus/dbus-test.h
index 22a43f79..512cb9a6 100644
--- a/dbus/dbus-test.h
+++ b/dbus/dbus-test.h
@@ -53,6 +53,7 @@ dbus_bool_t _dbus_sysdeps_test (void);
dbus_bool_t _dbus_spawn_test (const char *test_data_dir);
dbus_bool_t _dbus_userdb_test (const char *test_data_dir);
dbus_bool_t _dbus_memory_test (void);
+dbus_bool_t _dbus_object_id_test (void);
void dbus_internal_do_not_use_run_tests (const char *test_data_dir);
diff --git a/dbus/dbus-types.h b/dbus/dbus-types.h
index 854b6526..99cb45f5 100644
--- a/dbus/dbus-types.h
+++ b/dbus/dbus-types.h
@@ -83,6 +83,10 @@ typedef dbus_uint32_t dbus_unichar_t;
*
* A 64-bit unsigned integer on all platforms that support it.
* If supported, #DBUS_HAVE_INT64 will be defined.
+ *
+ * C99 requires a 64-bit type and most likely all interesting
+ * compilers support one. GLib for example flat-out requires
+ * a 64-bit type.
*/
/**
@@ -90,6 +94,10 @@ typedef dbus_uint32_t dbus_unichar_t;
*
* A 64-bit signed integer on all platforms that support it.
* If supported, #DBUS_HAVE_INT64 will be defined.
+ *
+ * C99 requires a 64-bit type and most likely all interesting
+ * compilers support one. GLib for example flat-out requires
+ * a 64-bit type.
*/
/**
diff --git a/dbus/dbus.h b/dbus/dbus.h
index 0dd072ac..38db4f5b 100644
--- a/dbus/dbus.h
+++ b/dbus/dbus.h
@@ -38,6 +38,7 @@
#include <dbus/dbus-macros.h>
#include <dbus/dbus-message.h>
#include <dbus/dbus-message-handler.h>
+#include <dbus/dbus-objectid.h>
#include <dbus/dbus-protocol.h>
#include <dbus/dbus-server.h>
#include <dbus/dbus-threads.h>