mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-01 03:18:07 +02:00
2003-08-01 Havoc Pennington <hp@pobox.com>
* dbus/dbus-protocol.h (DBUS_MESSAGE_TYPE_*): introduce a message type enum to distinguish kinds of message (DBUS_HEADER_FLAG_NO_REPLY_EXPECTED): flag for a message that need not be replied to 2003-08-01 Havoc Pennington <hp@pobox.com> * dbus/dbus-marshal.c: adapt to DBusObjectID changes (unpack_8_octets): fix no-64-bit-int bug * dbus/dbus-object-registry.c (validate_id): validate the connection ID bits, not just the instance ID. * dbus/dbus-connection.c (_dbus_connection_init_id): initialize the connection-global 33 bits of the object ID * dbus/dbus-object-registry.c (info_from_entry): fill in object ID in the new way * dbus/dbus-objectid.h: rather than high/low bits, specifically define server/client/instance bits.
This commit is contained in:
parent
8b7fe6f99d
commit
fe195a911d
11 changed files with 339 additions and 147 deletions
29
ChangeLog
29
ChangeLog
|
|
@ -1,3 +1,32 @@
|
|||
2003-08-01 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* dbus/dbus-protocol.h (DBUS_MESSAGE_TYPE_*): introduce
|
||||
a message type enum to distinguish kinds of message
|
||||
(DBUS_HEADER_FLAG_NO_REPLY_EXPECTED): flag for a message
|
||||
that need not be replied to
|
||||
|
||||
2003-08-01 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* dbus/dbus-marshal.c: adapt to DBusObjectID changes
|
||||
(unpack_8_octets): fix no-64-bit-int bug
|
||||
|
||||
* dbus/dbus-object-registry.c (validate_id): validate the
|
||||
connection ID bits, not just the instance ID.
|
||||
|
||||
* dbus/dbus-connection.c (_dbus_connection_init_id): initialize
|
||||
the connection-global 33 bits of the object ID
|
||||
|
||||
* dbus/dbus-object-registry.c (info_from_entry): fill in
|
||||
object ID in the new way
|
||||
|
||||
* dbus/dbus-objectid.h: rather than high/low bits, specifically
|
||||
define server/client/instance bits.
|
||||
|
||||
2003-07-30 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* dbus/dbus-connection.c (dbus_connection_register_object): fix
|
||||
build
|
||||
|
||||
2003-07-13 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* dbus/dbus-object.h (struct DBusObjectVTable): add padding
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
#include "dbus-sha.h"
|
||||
#include "dbus-userdb.h"
|
||||
|
||||
/* See doc/dbus-sasl-profile.txt */
|
||||
|
||||
/**
|
||||
* @defgroup DBusAuth Authentication
|
||||
* @ingroup DBusInternals
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ void _dbus_message_handler_remove_connection (DBusMessageHandl
|
|||
DBusHandlerResult _dbus_message_handler_handle_message (DBusMessageHandler *handler,
|
||||
DBusConnection *connection,
|
||||
DBusMessage *message);
|
||||
dbus_uint32_t _dbus_connection_get_id (DBusConnection *connection);
|
||||
void _dbus_connection_init_id (DBusConnection *connection,
|
||||
DBusObjectID *id);
|
||||
|
||||
DBUS_END_DECLS;
|
||||
|
||||
|
|
|
|||
|
|
@ -910,19 +910,22 @@ _dbus_connection_handle_watch (DBusWatch *watch,
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the ID to be used in the high bits of an object ID for an object
|
||||
* Get the server ID to be used in the object ID for an object
|
||||
* registered with this connection.
|
||||
*
|
||||
* @todo implement this function
|
||||
*
|
||||
* @param connection the connection.
|
||||
* @returns the connection portion of the object ID
|
||||
* @returns the portion of the object ID
|
||||
*/
|
||||
dbus_uint32_t
|
||||
_dbus_connection_get_id (DBusConnection *connection)
|
||||
void
|
||||
_dbus_connection_init_id (DBusConnection *connection,
|
||||
DBusObjectID *object_id)
|
||||
{
|
||||
/* FIXME */
|
||||
return 1492;
|
||||
dbus_object_id_set_server_bits (object_id, 15);
|
||||
dbus_object_id_set_client_bits (object_id, 31);
|
||||
dbus_object_id_set_is_server_bit (object_id, FALSE);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
@ -2793,9 +2796,9 @@ dbus_connection_register_object (DBusConnection *connection,
|
|||
{
|
||||
_dbus_return_val_if_fail (connection != NULL, FALSE);
|
||||
_dbus_return_val_if_fail (vtable != NULL, FALSE);
|
||||
_dbus_return_val_if_fail (vtable->dbus_internal_pad1 == NULL);
|
||||
_dbus_return_val_if_fail (vtable->dbus_internal_pad2 == NULL);
|
||||
_dbus_return_val_if_fail (vtable->dbus_internal_pad3 == NULL);
|
||||
_dbus_return_val_if_fail (vtable->dbus_internal_pad1 == NULL, FALSE);
|
||||
_dbus_return_val_if_fail (vtable->dbus_internal_pad2 == NULL, FALSE);
|
||||
_dbus_return_val_if_fail (vtable->dbus_internal_pad3 == NULL, FALSE);
|
||||
|
||||
CONNECTION_LOCK (connection);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,19 +80,7 @@ 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
|
||||
DBusObjectID object_id;
|
||||
} DBusOctets8;
|
||||
|
||||
static DBusOctets8
|
||||
|
|
@ -111,7 +99,8 @@ unpack_8_octets (int byte_order,
|
|||
r.u = DBUS_UINT64_FROM_BE (*(dbus_uint64_t*)data);
|
||||
#else
|
||||
r.d = *(double*)data;
|
||||
swap_bytes (&r, sizeof (r));
|
||||
if (byte_order != DBUS_COMPILER_BYTE_ORDER)
|
||||
swap_bytes ((unsigned char*) &r, sizeof (r));
|
||||
#endif
|
||||
|
||||
return r;
|
||||
|
|
@ -453,14 +442,8 @@ _dbus_marshal_set_object_id (DBusString *str,
|
|||
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));
|
||||
|
||||
r.object_id = *value;
|
||||
|
||||
set_8_octets (str, byte_order, offset, r);
|
||||
}
|
||||
|
|
@ -724,7 +707,7 @@ marshal_8_octets_array (DBusString *str,
|
|||
#ifdef DBUS_HAVE_INT64
|
||||
*((dbus_uint64_t*)d) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)d));
|
||||
#else
|
||||
swap_bytes (d, 8);
|
||||
swap_bytes ((unsigned char*) d, 8);
|
||||
#endif
|
||||
d += 8;
|
||||
}
|
||||
|
|
@ -900,14 +883,8 @@ _dbus_marshal_object_id (DBusString *str,
|
|||
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));
|
||||
|
||||
r.object_id = *value;
|
||||
|
||||
return marshal_8_octets (str, byte_order, r);
|
||||
}
|
||||
|
|
@ -1242,7 +1219,7 @@ demarshal_8_octets_array (const DBusString *str,
|
|||
#ifdef DBUS_HAVE_INT64
|
||||
retval[i].u = DBUS_UINT64_SWAP_LE_BE (retval[i].u);
|
||||
#else
|
||||
swap_bytes (&retval[i], 8);
|
||||
swap_bytes ((unsigned char *) &retval[i], 8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -1481,14 +1458,7 @@ _dbus_demarshal_object_id (const DBusString *str,
|
|||
|
||||
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);
|
||||
*value = r.object_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2312,8 +2282,9 @@ _dbus_marshal_test (void)
|
|||
#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);
|
||||
dbus_object_id_set_server_bits (&obj_id, 0xfffe);
|
||||
dbus_object_id_set_client_bits (&obj_id, 0xaacc);
|
||||
dbus_object_id_set_instance_bits (&obj_id, 0x70f00f0f);
|
||||
|
||||
if (!_dbus_marshal_object_id (&str, DBUS_BIG_ENDIAN, &obj_id))
|
||||
_dbus_assert_not_reached ("could not marshal object ID value");
|
||||
|
|
|
|||
|
|
@ -5855,10 +5855,12 @@ _dbus_message_test (const char *test_data_dir)
|
|||
_DBUS_N_ELEMENTS (our_uint32_array),
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, our_int32_array,
|
||||
_DBUS_N_ELEMENTS (our_int32_array),
|
||||
#ifdef DBUS_HAVE_INT64
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, our_uint64_array,
|
||||
_DBUS_N_ELEMENTS (our_uint64_array),
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, our_int64_array,
|
||||
_DBUS_N_ELEMENTS (our_int64_array),
|
||||
#endif
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, our_string_array,
|
||||
_DBUS_N_ELEMENTS (our_string_array),
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, our_double_array,
|
||||
|
|
|
|||
|
|
@ -177,12 +177,27 @@ validate_id (DBusObjectRegistry *registry,
|
|||
{
|
||||
int idx;
|
||||
int times_used;
|
||||
dbus_uint32_t low_bits;
|
||||
dbus_uint32_t instance_bits;
|
||||
|
||||
instance_bits = dbus_object_id_get_instance_bits (object_id);
|
||||
|
||||
low_bits = dbus_object_id_get_low_bits (object_id);
|
||||
|
||||
idx = ID_TO_INDEX (low_bits);
|
||||
times_used = ID_TO_TIMES_USED (low_bits);
|
||||
/* Verify that connection ID bits are the same */
|
||||
#ifdef DBUS_BUILD_TESTS
|
||||
if (registry->connection)
|
||||
#endif
|
||||
{
|
||||
DBusObjectID tmp_id;
|
||||
|
||||
_dbus_connection_init_id (registry->connection,
|
||||
&tmp_id);
|
||||
dbus_object_id_set_instance_bits (&tmp_id, instance_bits);
|
||||
|
||||
if (!dbus_object_id_equal (&tmp_id, object_id))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
idx = ID_TO_INDEX (instance_bits);
|
||||
times_used = ID_TO_TIMES_USED (instance_bits);
|
||||
|
||||
if (idx >= registry->n_entries_allocated)
|
||||
return NULL;
|
||||
|
|
@ -206,15 +221,23 @@ info_from_entry (DBusObjectRegistry *registry,
|
|||
#ifdef DBUS_BUILD_TESTS
|
||||
if (registry->connection)
|
||||
#endif
|
||||
dbus_object_id_set_high_bits (&info->object_id,
|
||||
_dbus_connection_get_id (registry->connection));
|
||||
_dbus_connection_init_id (registry->connection,
|
||||
&info->object_id);
|
||||
#ifdef DBUS_BUILD_TESTS
|
||||
else
|
||||
dbus_object_id_set_high_bits (&info->object_id, 1);
|
||||
{
|
||||
dbus_object_id_set_server_bits (&info->object_id, 1);
|
||||
dbus_object_id_set_client_bits (&info->object_id, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&info->object_id) != 0);
|
||||
_dbus_assert (dbus_object_id_get_client_bits (&info->object_id) != 0);
|
||||
|
||||
dbus_object_id_set_low_bits (&info->object_id,
|
||||
ENTRY_TO_ID (entry));
|
||||
dbus_object_id_set_instance_bits (&info->object_id,
|
||||
ENTRY_TO_ID (entry));
|
||||
|
||||
_dbus_assert (dbus_object_id_get_instance_bits (&info->object_id) != 0);
|
||||
}
|
||||
|
||||
static DBusInterfaceEntry*
|
||||
|
|
|
|||
|
|
@ -25,12 +25,34 @@
|
|||
#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)))
|
||||
#define VALUE(objid) ((objid)->dbus_do_not_use_dummy1)
|
||||
#define SERVER_MASK DBUS_UINT64_CONSTANT (0xffff000000000000)
|
||||
#define CLIENT_MASK DBUS_UINT64_CONSTANT (0x0000ffff00000000)
|
||||
#define IS_SERVER_MASK DBUS_UINT64_CONSTANT (0x0000000080000000)
|
||||
#define INSTANCE_MASK DBUS_UINT64_CONSTANT (0x000000007fffffff)
|
||||
#define SERVER_BITS(objid) ((dbus_uint16_t) (VALUE (obj_id) >> 48))
|
||||
#define CLIENT_BITS(objid) ((dbus_uint16_t) ((VALUE (obj_id) & CLIENT_MASK) >> 32))
|
||||
#define IS_SERVER_BIT(objid) ((VALUE (obj_id) & IS_SERVER_MASK) != 0)
|
||||
#define INSTANCE_BITS(objid) ((dbus_uint32_t) (VALUE (obj_id) & INSTANCE_MASK))
|
||||
#else
|
||||
#define HIGH_BITS(objid) ((objid)->dbus_do_not_use_dummy1)
|
||||
#define LOW_BITS(objid) ((objid)->dbus_do_not_use_dummy2)
|
||||
/* We care about the exact packing since in dbus-marshal.c we
|
||||
* just use the DBusObjectID struct as-is.
|
||||
*/
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define HIGH_VALUE(objid) ((objid)->dbus_do_not_use_dummy2)
|
||||
#define LOW_VALUE(objid) ((objid)->dbus_do_not_use_dummy3)
|
||||
#else
|
||||
#define HIGH_VALUE(objid) ((objid)->dbus_do_not_use_dummy3)
|
||||
#define LOW_VALUE(objid) ((objid)->dbus_do_not_use_dummy2)
|
||||
#endif
|
||||
#define SERVER_MASK (0xffff0000)
|
||||
#define CLIENT_MASK (0x0000ffff)
|
||||
#define IS_SERVER_MASK (0x80000000)
|
||||
#define INSTANCE_MASK (0x7fffffff)
|
||||
#define SERVER_BITS(objid) ((HIGH_VALUE (objid) & SERVER_MASK) >> 16)
|
||||
#define CLIENT_BITS(objid) (HIGH_VALUE (objid) & CLIENT_MASK)
|
||||
#define IS_SERVER_BIT(objid) ((LOW_VALUE (objid) & IS_SERVER_MASK) != 0)
|
||||
#define INSTANCE_BITS(objid) (LOW_VALUE (objid) & INSTANCE_MASK)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
@ -41,6 +63,20 @@
|
|||
* Value type representing an object ID, i.e. an object in the remote
|
||||
* application that can be communicated with.
|
||||
*
|
||||
* An object ID has three parts. 16 bits are provided by the server
|
||||
* side of a connection, and used for the high 16 bits of all object
|
||||
* IDs created by the client. 16 bits are provided by the client side
|
||||
* and used as the next 16 bits of all object IDs created by the
|
||||
* client. The next single bit is 1 if the object ID represents an
|
||||
* object on the server side of the connection and 0 otherwise. Then
|
||||
* 31 bits are provided by the side creating an object instance and
|
||||
* differ for each instance created (each app should make a best
|
||||
* effort to avoid recycling the instance values).
|
||||
*
|
||||
* 0 is an invalid value for the server bits, the client bits,
|
||||
* and the object instance bits. An object ID is the null ID
|
||||
* if all 64 bits are 0.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
|
@ -58,8 +94,7 @@ dbus_object_id_equal (const DBusObjectID *a,
|
|||
#ifdef DBUS_HAVE_INT64
|
||||
return VALUE (a) == VALUE (b);
|
||||
#else
|
||||
return HIGH_BITS (a) == HIGH_BITS (b) &&
|
||||
LOW_BITS (a) == LOW_BITS (b);
|
||||
return LOW_VALUE (a) == LOW_VALUE (b) && HIGH_VALUE (a) == HIGH_VALUE (b);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -85,95 +120,168 @@ dbus_object_id_compare (const DBusObjectID *a,
|
|||
else
|
||||
return 0;
|
||||
#else
|
||||
if (HIGH_BITS (a) > HIGH_BITS (b))
|
||||
if (HIGH_VALUE (a) > HIGH_VALUE (b))
|
||||
return 1;
|
||||
else if (HIGH_BITS (a) < HIGH_BITS (b))
|
||||
else if (HIGH_VALUE (a) < HIGH_VALUE (b))
|
||||
return -1;
|
||||
else if (LOW_BITS (a) > LOW_BITS (b))
|
||||
else if (LOW_VALUE (a) > LOW_VALUE (b))
|
||||
return 1;
|
||||
else if (LOW_BITS (a) < LOW_BITS (b))
|
||||
else if (LOW_VALUE (a) < LOW_VALUE (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.
|
||||
* returns the 16 bits that were provided by the server
|
||||
* side of the connection.
|
||||
*
|
||||
* @param obj_id the object ID
|
||||
* @returns the high bits of the ID
|
||||
* @returns the server bits of the ID
|
||||
*
|
||||
*/
|
||||
dbus_uint32_t
|
||||
dbus_object_id_get_high_bits (const DBusObjectID *obj_id)
|
||||
dbus_uint16_t
|
||||
dbus_object_id_get_server_bits (const DBusObjectID *obj_id)
|
||||
{
|
||||
return HIGH_BITS (obj_id);
|
||||
return SERVER_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.
|
||||
* returns the 16 bits that were provided by the client
|
||||
* side of the connection.
|
||||
*
|
||||
* @param obj_id the object ID
|
||||
* @returns the low bits of the ID
|
||||
* @returns the client bits of the ID
|
||||
*
|
||||
*/
|
||||
dbus_uint32_t
|
||||
dbus_object_id_get_low_bits (const DBusObjectID *obj_id)
|
||||
dbus_uint16_t
|
||||
dbus_object_id_get_client_bits (const DBusObjectID *obj_id)
|
||||
{
|
||||
return LOW_BITS (obj_id);
|
||||
return CLIENT_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.
|
||||
* returns the bit flagging whether the object ID comes
|
||||
* from the client or the server side of the connection.
|
||||
*
|
||||
* There is no secure guarantee that the bit is accurate;
|
||||
* object ID values are simply conventional, to make
|
||||
* collisions relatively unlikely.
|
||||
*
|
||||
* @param obj_id the object ID
|
||||
* @param value the new value of the high bits
|
||||
* @returns the server-side bit of the ID
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
dbus_object_id_get_is_server_bit (const DBusObjectID *obj_id)
|
||||
{
|
||||
return IS_SERVER_BIT (obj_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* An object ID contains 64 bits of data. This function
|
||||
* returns the 31 bits that identify the object instance.
|
||||
*
|
||||
* @param obj_id the object ID
|
||||
* @returns the instance bits of the ID
|
||||
*
|
||||
*/
|
||||
dbus_uint32_t
|
||||
dbus_object_id_get_instance_bits (const DBusObjectID *obj_id)
|
||||
{
|
||||
return INSTANCE_BITS (obj_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* An object ID contains 64 bits of data. This function sets the 16
|
||||
* bits provided by the server side of a connection.
|
||||
*
|
||||
* @param obj_id the object ID
|
||||
* @param value the new value of the server bits
|
||||
*
|
||||
*/
|
||||
void
|
||||
dbus_object_id_set_high_bits (DBusObjectID *obj_id,
|
||||
dbus_uint32_t value)
|
||||
dbus_object_id_set_server_bits (DBusObjectID *obj_id,
|
||||
dbus_uint16_t value)
|
||||
{
|
||||
#ifdef DBUS_HAVE_INT64
|
||||
VALUE (obj_id) = (((dbus_uint64_t) value) << 32) | LOW_BITS (obj_id);
|
||||
VALUE (obj_id) &= ~ SERVER_MASK;
|
||||
VALUE (obj_id) |= ((dbus_uint64_t) value) << 48;
|
||||
#else
|
||||
HIGH_BITS (obj_id) = value;
|
||||
HIGH_VALUE (obj_id) &= ~ SERVER_MASK;
|
||||
HIGH_VALUE (obj_id) |= ((dbus_uint32_t) value) << 16;
|
||||
#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.
|
||||
* An object ID contains 64 bits of data. This function sets the 16
|
||||
* bits provided by the client side of a connection.
|
||||
*
|
||||
* @param obj_id the object ID
|
||||
* @param value the new value of the low bits
|
||||
* @param value the new value of the client bits
|
||||
*
|
||||
*/
|
||||
void
|
||||
dbus_object_id_set_low_bits (DBusObjectID *obj_id,
|
||||
dbus_uint32_t value)
|
||||
dbus_object_id_set_client_bits (DBusObjectID *obj_id,
|
||||
dbus_uint16_t value)
|
||||
{
|
||||
#ifdef DBUS_HAVE_INT64
|
||||
VALUE (obj_id) = ((dbus_uint64_t) value) |
|
||||
(((dbus_uint64_t) HIGH_BITS (obj_id)) << 32);
|
||||
VALUE (obj_id) &= ~ CLIENT_MASK;
|
||||
VALUE (obj_id) |= ((dbus_uint64_t) value) << 32;
|
||||
#else
|
||||
LOW_BITS (obj_id) = value;
|
||||
HIGH_VALUE (obj_id) &= ~ CLIENT_MASK;
|
||||
HIGH_VALUE (obj_id) |= (dbus_uint32_t) value;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* An object ID contains 64 bits of data. This function sets the
|
||||
* single bit that flags an instance as server-side or client-side.
|
||||
*
|
||||
* @param obj_id the object ID
|
||||
* @param value the new value of the server-side bit
|
||||
*
|
||||
*/
|
||||
void
|
||||
dbus_object_id_set_is_server_bit (DBusObjectID *obj_id,
|
||||
dbus_bool_t value)
|
||||
{
|
||||
#ifdef DBUS_HAVE_INT64
|
||||
if (value)
|
||||
VALUE (obj_id) |= IS_SERVER_MASK;
|
||||
else
|
||||
VALUE (obj_id) &= ~ IS_SERVER_MASK;
|
||||
#else
|
||||
if (value)
|
||||
LOW_VALUE (obj_id) |= IS_SERVER_MASK;
|
||||
else
|
||||
LOW_VALUE (obj_id) &= ~ IS_SERVER_MASK;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* An object ID contains 64 bits of data. This function sets the 31
|
||||
* bits identifying the object instance.
|
||||
*
|
||||
* @param obj_id the object ID
|
||||
* @param value the new value of the instance bits
|
||||
*
|
||||
*/
|
||||
void
|
||||
dbus_object_id_set_instance_bits (DBusObjectID *obj_id,
|
||||
dbus_uint32_t value)
|
||||
{
|
||||
#ifdef DBUS_HAVE_INT64
|
||||
VALUE (obj_id) &= ~ INSTANCE_MASK;
|
||||
VALUE (obj_id) |= (dbus_uint64_t) value;
|
||||
#else
|
||||
LOW_VALUE (obj_id) &= ~ INSTANCE_MASK;
|
||||
LOW_VALUE (obj_id) |= (dbus_uint32_t) value;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +309,7 @@ dbus_object_id_is_null (const DBusObjectID *obj_id)
|
|||
#ifdef DBUS_HAVE_INT64
|
||||
return VALUE (obj_id) == 0;
|
||||
#else
|
||||
return HIGH_BITS (obj_id) == 0 && LOW_BITS (obj_id) == 0;
|
||||
return HIGH_VALUE (obj_id) == 0 && LOW_VALUE (obj_id) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -263,28 +371,49 @@ _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);
|
||||
/* Check basic get/set */
|
||||
|
||||
dbus_object_id_set_server_bits (&tmp, 340);
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&tmp) == 340);
|
||||
|
||||
dbus_object_id_set_client_bits (&tmp, 1492);
|
||||
_dbus_assert (dbus_object_id_get_client_bits (&tmp) == 1492);
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&tmp) == 340);
|
||||
|
||||
dbus_object_id_set_is_server_bit (&tmp, TRUE);
|
||||
_dbus_assert (dbus_object_id_get_client_bits (&tmp) == 1492);
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&tmp) == 340);
|
||||
_dbus_assert (dbus_object_id_get_is_server_bit (&tmp) == TRUE);
|
||||
|
||||
dbus_object_id_set_instance_bits (&tmp, 2001);
|
||||
_dbus_assert (dbus_object_id_get_client_bits (&tmp) == 1492);
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&tmp) == 340);
|
||||
_dbus_assert (dbus_object_id_get_is_server_bit (&tmp) == TRUE);
|
||||
_dbus_assert (dbus_object_id_get_instance_bits (&tmp) == 2001);
|
||||
|
||||
/* check equality check */
|
||||
tmp2 = tmp;
|
||||
_dbus_assert (dbus_object_id_equal (&tmp, &tmp2));
|
||||
|
||||
|
||||
/* check get/set as integer */
|
||||
#ifdef DBUS_HAVE_INT64
|
||||
_dbus_assert (dbus_object_id_get_as_integer (&tmp) ==
|
||||
((DBUS_UINT64_CONSTANT (340) << 32) |
|
||||
DBUS_UINT64_CONSTANT (1492)));
|
||||
((DBUS_UINT64_CONSTANT (340) << 48) |
|
||||
(DBUS_UINT64_CONSTANT (1492) << 32) |
|
||||
(DBUS_UINT64_CONSTANT (1) << 31) |
|
||||
(DBUS_UINT64_CONSTANT (2001))));
|
||||
|
||||
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_assert (dbus_object_id_get_server_bits (&tmp) ==
|
||||
0xffff);
|
||||
_dbus_assert (dbus_object_id_get_client_bits (&tmp) ==
|
||||
0xffff);
|
||||
_dbus_assert (dbus_object_id_get_is_server_bit (&tmp) ==
|
||||
TRUE);
|
||||
_dbus_assert (dbus_object_id_get_instance_bits (&tmp) ==
|
||||
0x7fffffff);
|
||||
|
||||
dbus_object_id_set_as_integer (&tmp, 1);
|
||||
dbus_object_id_set_as_integer (&tmp2, 2);
|
||||
|
|
@ -295,24 +424,45 @@ _dbus_object_id_test (void)
|
|||
_dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
|
||||
#endif
|
||||
|
||||
/* Check comparison */
|
||||
tmp2 = tmp;
|
||||
|
||||
dbus_object_id_set_high_bits (&tmp, 1);
|
||||
dbus_object_id_set_high_bits (&tmp2, 2);
|
||||
dbus_object_id_set_server_bits (&tmp, 1);
|
||||
dbus_object_id_set_server_bits (&tmp2, 2);
|
||||
_dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == -1);
|
||||
dbus_object_id_set_high_bits (&tmp2, 0);
|
||||
dbus_object_id_set_server_bits (&tmp2, 0);
|
||||
_dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 1);
|
||||
dbus_object_id_set_high_bits (&tmp2, 1);
|
||||
dbus_object_id_set_server_bits (&tmp2, 1);
|
||||
_dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
|
||||
|
||||
dbus_object_id_set_low_bits (&tmp, 1);
|
||||
dbus_object_id_set_client_bits (&tmp, 1);
|
||||
|
||||
dbus_object_id_set_low_bits (&tmp2, 2);
|
||||
dbus_object_id_set_client_bits (&tmp2, 2);
|
||||
_dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == -1);
|
||||
dbus_object_id_set_low_bits (&tmp2, 0);
|
||||
dbus_object_id_set_client_bits (&tmp2, 0);
|
||||
_dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 1);
|
||||
dbus_object_id_set_low_bits (&tmp2, 1);
|
||||
dbus_object_id_set_client_bits (&tmp2, 1);
|
||||
_dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
|
||||
|
||||
/* Check get/set again with high-limit numbers */
|
||||
|
||||
dbus_object_id_set_server_bits (&tmp, 0xf0f0);
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&tmp) == 0xf0f0);
|
||||
|
||||
dbus_object_id_set_client_bits (&tmp, 0xf00f);
|
||||
_dbus_assert (dbus_object_id_get_client_bits (&tmp) == 0xf00f);
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&tmp) == 0xf0f0);
|
||||
|
||||
dbus_object_id_set_is_server_bit (&tmp, TRUE);
|
||||
_dbus_assert (dbus_object_id_get_client_bits (&tmp) == 0xf00f);
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&tmp) == 0xf0f0);
|
||||
_dbus_assert (dbus_object_id_get_is_server_bit (&tmp) == TRUE);
|
||||
|
||||
dbus_object_id_set_instance_bits (&tmp, 0x7fffffff);
|
||||
_dbus_assert (dbus_object_id_get_client_bits (&tmp) == 0xf00f);
|
||||
_dbus_assert (dbus_object_id_get_server_bits (&tmp) == 0xf0f0);
|
||||
_dbus_assert (dbus_object_id_get_is_server_bit (&tmp) == TRUE);
|
||||
_dbus_assert (dbus_object_id_get_instance_bits (&tmp) == 0x7fffffff);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,23 +39,31 @@ 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;
|
||||
dbus_uint32_t dbus_do_not_use_dummy3;
|
||||
#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);
|
||||
void dbus_object_id_set_null (DBusObjectID *obj_id);
|
||||
dbus_bool_t dbus_object_id_is_null (const DBusObjectID *obj_id);
|
||||
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_uint16_t dbus_object_id_get_server_bits (const DBusObjectID *obj_id);
|
||||
dbus_uint16_t dbus_object_id_get_client_bits (const DBusObjectID *obj_id);
|
||||
dbus_uint32_t dbus_object_id_get_connection_bits (const DBusObjectID *obj_id);
|
||||
dbus_bool_t dbus_object_id_get_is_server_bit (const DBusObjectID *obj_id);
|
||||
dbus_uint32_t dbus_object_id_get_instance_bits (const DBusObjectID *obj_id);
|
||||
void dbus_object_id_set_server_bits (DBusObjectID *obj_id,
|
||||
dbus_uint16_t value);
|
||||
void dbus_object_id_set_client_bits (DBusObjectID *obj_id,
|
||||
dbus_uint16_t value);
|
||||
void dbus_object_id_set_is_server_bit (DBusObjectID *obj_id,
|
||||
dbus_bool_t value);
|
||||
void dbus_object_id_set_instance_bits (DBusObjectID *obj_id,
|
||||
dbus_uint32_t value);
|
||||
void dbus_object_id_set_null (DBusObjectID *obj_id);
|
||||
dbus_bool_t dbus_object_id_is_null (const DBusObjectID *obj_id);
|
||||
|
||||
#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,
|
||||
|
|
|
|||
|
|
@ -60,8 +60,15 @@ extern "C" {
|
|||
/* Max length in bytes of a service or message name */
|
||||
#define DBUS_MAXIMUM_NAME_LENGTH 256
|
||||
|
||||
/* Types of message */
|
||||
#define DBUS_MESSAGE_TYPE_METHOD_CALL 1
|
||||
#define DBUS_MESSAGE_TYPE_METHOD_RETURN 2
|
||||
#define DBUS_MESSAGE_TYPE_ERROR 3
|
||||
#define DBUS_MESSAGE_TYPE_SIGNAL 4
|
||||
|
||||
/* Header flags */
|
||||
#define DBUS_HEADER_FLAG_ERROR 0x1
|
||||
#define DBUS_HEADER_FLAG_ERROR 0x1
|
||||
#define DBUS_HEADER_FLAG_NO_REPLY_EXPECTED 0x2
|
||||
|
||||
/* Header fields */
|
||||
#define DBUS_HEADER_FIELD_NAME "name"
|
||||
|
|
|
|||
|
|
@ -964,7 +964,7 @@ _dbus_string_append_8_aligned (DBusString *str,
|
|||
p = (dbus_uint64_t*) (real->str + (real->len - 8));
|
||||
*p = *((dbus_uint64_t*)octets);
|
||||
#else
|
||||
char *p;
|
||||
unsigned char *p;
|
||||
DBUS_STRING_PREAMBLE (str);
|
||||
|
||||
if (!align_length_then_lengthen (str, 8, 8))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue