Commit 9c3d566e authored by Havoc Pennington's avatar Havoc Pennington

2005-01-15 Havoc Pennington <hp@redhat.com>

	* Land the new message args API and type system.

	This patch is huge, but the public API change is not
	really large. The set of D-BUS types has changed somewhat,
	and the arg "getters" are more geared toward language bindings;
	they don't make a copy, etc.

	There are also some known issues. See these emails for details
	on this huge patch:
	http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
        http://lists.freedesktop.org/archives/dbus/2005-January/001922.html

	* dbus/dbus-marshal-*: all the new stuff

	* dbus/dbus-message.c: basically rewritten

	* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
	freed blocks to be all non-nul bytes so using freed memory is less
	likely to work right

	* dbus/dbus-internals.c (_dbus_test_oom_handling): add
	DBUS_FAIL_MALLOC=N environment variable, so you can do
	DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
	DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
	thorough.

	* qt/message.cpp: port to the new message args API
	(operator<<): use str.utf8() rather than str.unicode()
	(pretty sure this is right from the Qt docs?)

	* glib/dbus-gvalue.c: port to the new message args API

	* bus/dispatch.c, bus/driver.c: port to the new message args API

	* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
	"locked" flag to TRUE and align_offset to 0; I guess we never
	looked at these anyhow, but seems cleaner.

	* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
	move allocation padding macro to this header; use it to implement
	(_DBUS_STRING_STATIC): ability to declare a static string.

	* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
	change to return TRUE if the interface is not set.

	* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
	to dbus-marshal-validate.[hc]

	* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
	dbus-internals.c

	* dbus/Makefile.am: cut over from dbus-marshal.[hc]
	to dbus-marshal-*.[hc]

	* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
	function here from dbus-marshal.c
parent 6ec04e91
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-12 Joe Shaw <joeshaw@novell.com>
* NEWS: Update for 0.23.
......
......@@ -127,6 +127,17 @@ dbus_realloc to fail if the number of bytes to be allocated is greater
than the specified number. This only works if D-BUS has been compiled with
--enable-tests.
DBUS_TEST_MALLOC_FAILURES=n
Many of the D-BUS tests will run over and over, once for each malloc
involved in the test. Each run will fail a different malloc, plus some
number of mallocs following that malloc (because a fair number of bugs
only happen if two or more mallocs fail in a row, e.g. error recovery
that itself involves malloc). This env variable sets the number of
mallocs to fail.
Here's why you care: If set to 0, then the malloc checking is skipped,
which makes the test suite a heck of a lot faster. Just run with this
env variable unset before you commit.
Tests
===
......
......@@ -93,6 +93,7 @@ typedef struct
unsigned int timeout_added : 1;
} BusPendingActivation;
#if 0
static BusServiceDirectory *
bus_service_directory_ref (BusServiceDirectory *dir)
{
......@@ -102,6 +103,7 @@ bus_service_directory_ref (BusServiceDirectory *dir)
return dir;
}
#endif
static void
bus_service_directory_unref (BusServiceDirectory *dir)
......@@ -909,15 +911,19 @@ bus_activation_service_created (BusActivation *activation,
/* Only send activation replies to regular activation requests. */
if (!entry->auto_activation)
{
dbus_uint32_t result;
message = dbus_message_new_method_return (entry->activation_message);
if (!message)
{
BUS_SET_OOM (error);
goto error;
}
result = DBUS_ACTIVATION_REPLY_ACTIVATED;
if (!dbus_message_append_args (message,
DBUS_TYPE_UINT32, DBUS_ACTIVATION_REPLY_ACTIVATED,
DBUS_TYPE_UINT32, &result,
DBUS_TYPE_INVALID))
{
dbus_message_unref (message);
......@@ -1328,6 +1334,8 @@ bus_activation_activate_service (BusActivation *activation,
_dbus_string_init_const (&service_str, service_name);
if (bus_registry_lookup (bus_context_get_registry (activation->context), &service_str) != NULL)
{
dbus_uint32_t result;
_dbus_verbose ("Service \"%s\" is already active\n", service_name);
message = dbus_message_new_method_return (activation_message);
......@@ -1339,8 +1347,10 @@ bus_activation_activate_service (BusActivation *activation,
return FALSE;
}
result = DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE;
if (!dbus_message_append_args (message,
DBUS_TYPE_UINT32, DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE,
DBUS_TYPE_UINT32, &result,
DBUS_TYPE_INVALID))
{
_dbus_verbose ("No memory to set args of reply to activate message\n");
......
......@@ -1398,6 +1398,7 @@ bus_pending_reply_send_no_reply (BusConnections *connections,
DBusMessage *message;
DBusMessageIter iter;
dbus_bool_t retval;
const char *errmsg;
retval = FALSE;
......@@ -1414,9 +1415,10 @@ bus_pending_reply_send_no_reply (BusConnections *connections,
if (!dbus_message_set_error_name (message,
DBUS_ERROR_NO_REPLY))
goto out;
errmsg = "Message did not receive a reply (timeout by message bus)";
dbus_message_append_iter_init (message, &iter);
if (!dbus_message_iter_append_string (&iter, "Message did not receive a reply (timeout by message bus)"))
if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errmsg))
goto out;
if (!bus_transaction_send_from_driver (transaction, pending->will_get_reply,
......
This diff is collapsed.
This diff is collapsed.
......@@ -156,13 +156,18 @@ bus_registry_ensure (BusRegistry *registry,
service->registry = registry;
service->refcount = 1;
_dbus_verbose ("copying string %p '%s' to service->name\n",
service_name, _dbus_string_get_const_data (service_name));
if (!_dbus_string_copy_data (service_name, &service->name))
{
_dbus_mem_pool_dealloc (registry->service_pool, service);
BUS_SET_OOM (error);
return NULL;
}
_dbus_verbose ("copied string %p '%s' to '%s'\n",
service_name, _dbus_string_get_const_data (service_name),
service->name);
if (!bus_driver_send_service_owner_changed (service->name,
NULL,
......
......@@ -23,6 +23,7 @@
#include "signals.h"
#include "services.h"
#include "utils.h"
#include <dbus/dbus-marshal-validate.h>
struct BusMatchRule
{
......@@ -656,7 +657,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed;
}
if (!_dbus_string_validate_service (&tmp_str, 0, len))
if (!_dbus_validate_service (&tmp_str, 0, len))
{
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Sender service name '%s' is invalid\n", value);
......@@ -678,7 +679,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed;
}
if (!_dbus_string_validate_interface (&tmp_str, 0, len))
if (!_dbus_validate_interface (&tmp_str, 0, len))
{
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Interface name '%s' is invalid\n", value);
......@@ -700,7 +701,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed;
}
if (!_dbus_string_validate_member (&tmp_str, 0, len))
if (!_dbus_validate_member (&tmp_str, 0, len))
{
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Member name '%s' is invalid\n", value);
......@@ -722,7 +723,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed;
}
if (!_dbus_string_validate_path (&tmp_str, 0, len))
if (!_dbus_validate_path (&tmp_str, 0, len))
{
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Path '%s' is invalid\n", value);
......@@ -744,7 +745,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed;
}
if (!_dbus_string_validate_service (&tmp_str, 0, len))
if (!_dbus_validate_service (&tmp_str, 0, len))
{
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Destination service name '%s' is invalid\n", value);
......
......@@ -12,3 +12,5 @@ dbus-test
dbus-arch-deps.h
.dbus-keyrings
dbus-glib-error-enum.h
*.gcno
*.gcda
......@@ -54,6 +54,12 @@ DBUS_LIB_SOURCES= \
dbus-errors.c \
dbus-keyring.c \
dbus-keyring.h \
dbus-marshal-header.c \
dbus-marshal-header.h \
dbus-marshal-recursive.c \
dbus-marshal-recursive.h \
dbus-marshal-validate.c \
dbus-marshal-validate.h \
dbus-message.c \
dbus-message-internal.h \
dbus-object-tree.c \
......@@ -98,13 +104,11 @@ DBUS_SHARED_SOURCES= \
dbus-internals.h \
dbus-list.c \
dbus-list.h \
dbus-marshal.c \
dbus-marshal.h \
dbus-marshal-basic.c \
dbus-marshal-basic.h \
dbus-memory.c \
dbus-mempool.c \
dbus-mempool.h \
dbus-message-builder.c \
dbus-message-builder.h \
dbus-spawn.c \
dbus-spawn.h \
dbus-string.c \
......
......@@ -29,7 +29,6 @@
#include "dbus-string.h"
#include "dbus-hash.h"
#include "dbus-internals.h"
#include "dbus-marshal.h"
#include "dbus-userdb.h"
/**
......
......@@ -479,8 +479,13 @@ dbus_bus_register (DBusConnection *connection,
DBUS_TYPE_INVALID))
goto out;
bd->base_service = name;
bd->base_service = _dbus_strdup (name);
if (bd->base_service == NULL)
{
_DBUS_SET_OOM (error);
goto out;
}
retval = TRUE;
out:
......@@ -578,7 +583,7 @@ dbus_bus_get_unix_user (DBusConnection *connection,
}
if (!dbus_message_append_args (message,
DBUS_TYPE_STRING, service,
DBUS_TYPE_STRING, &service,
DBUS_TYPE_INVALID))
{
dbus_message_unref (message);
......@@ -659,8 +664,8 @@ dbus_bus_acquire_service (DBusConnection *connection,
}
if (!dbus_message_append_args (message,
DBUS_TYPE_STRING, service_name,
DBUS_TYPE_UINT32, flags,
DBUS_TYPE_STRING, &service_name,
DBUS_TYPE_UINT32, &flags,
DBUS_TYPE_INVALID))
{
dbus_message_unref (message);
......@@ -731,7 +736,7 @@ dbus_bus_service_exists (DBusConnection *connection,
}
if (!dbus_message_append_args (message,
DBUS_TYPE_STRING, service_name,
DBUS_TYPE_STRING, &service_name,
DBUS_TYPE_INVALID))
{
dbus_message_unref (message);
......@@ -791,8 +796,8 @@ dbus_bus_activate_service (DBusConnection *connection,
DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
"ActivateService");
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, service_name,
DBUS_TYPE_UINT32, flags, DBUS_TYPE_INVALID))
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &service_name,
DBUS_TYPE_UINT32, &flags, DBUS_TYPE_INVALID))
{
dbus_message_unref (msg);
_DBUS_SET_OOM (error);
......@@ -895,7 +900,7 @@ dbus_bus_add_match (DBusConnection *connection,
return;
}
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, rule,
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &rule,
DBUS_TYPE_INVALID))
{
dbus_message_unref (msg);
......@@ -933,7 +938,7 @@ dbus_bus_remove_match (DBusConnection *connection,
DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
"RemoveMatch");
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, rule,
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &rule,
DBUS_TYPE_INVALID))
{
dbus_message_unref (msg);
......
......@@ -38,7 +38,6 @@
#include "dbus-string.h"
#include "dbus-pending-call.h"
#include "dbus-object-tree.h"
#include "dbus-marshal.h"
#if 0
#define CONNECTION_LOCK(connection) do { \
......@@ -1562,15 +1561,6 @@ _dbus_connection_send_preallocated_unlocked (DBusConnection *connection,
connection->n_outgoing += 1;
sig = dbus_message_get_signature (message);
#ifndef DBUS_DISABLE_ASSERT
{
DBusString foo;
_dbus_verbose (" validating signature '%s'\n", sig);
_dbus_string_init_const (&foo, sig);
_dbus_assert (_dbus_string_validate_signature (&foo, 0,
_dbus_string_get_length (&foo)));
}
#endif
_dbus_verbose ("Message %p (%d %s %s '%s') added to outgoing queue %p, %d pending to send\n",
message,
......
......@@ -354,42 +354,6 @@ _dbus_string_array_contains (const char **array,
return FALSE;
}
/**
* Returns a string describing the given type.
*
* @param type the type to describe
* @returns a constant string describing the type
*/
const char *
_dbus_type_to_string (int type)
{
switch (type)
{
case DBUS_TYPE_INVALID:
return "invalid";
case DBUS_TYPE_NIL:
return "nil";
case DBUS_TYPE_BOOLEAN:
return "boolean";
case DBUS_TYPE_INT32:
return "int32";
case DBUS_TYPE_UINT32:
return "uint32";
case DBUS_TYPE_DOUBLE:
return "double";
case DBUS_TYPE_STRING:
return "string";
case DBUS_TYPE_CUSTOM:
return "custom";
case DBUS_TYPE_ARRAY:
return "array";
case DBUS_TYPE_DICT:
return "dict";
default:
return "unknown";
}
}
/**
* Returns a string describing the given name.
*
......@@ -525,6 +489,9 @@ _dbus_test_oom_handling (const char *description,
void *data)
{
int approx_mallocs;
const char *setting;
int max_failures_to_try;
int i;
/* Run once to see about how many mallocs are involved */
......@@ -540,21 +507,30 @@ _dbus_test_oom_handling (const char *description,
_dbus_verbose ("\n=================\n%s: about %d mallocs total\n=================\n",
description, approx_mallocs);
_dbus_set_fail_alloc_failures (1);
if (!run_failing_each_malloc (approx_mallocs, description, func, data))
return FALSE;
_dbus_set_fail_alloc_failures (2);
if (!run_failing_each_malloc (approx_mallocs, description, func, data))
return FALSE;
_dbus_set_fail_alloc_failures (3);
if (!run_failing_each_malloc (approx_mallocs, description, func, data))
return FALSE;
setting = _dbus_getenv ("DBUS_TEST_MALLOC_FAILURES");
if (setting != NULL)
{
DBusString str;
long v;
_dbus_string_init_const (&str, setting);
v = 4;
if (!_dbus_string_parse_int (&str, 0, &v, NULL))
_dbus_warn ("couldn't parse '%s' as integer\n", setting);
max_failures_to_try = v;
}
else
{
max_failures_to_try = 4;
}
_dbus_set_fail_alloc_failures (4);
if (!run_failing_each_malloc (approx_mallocs, description, func, data))
return FALSE;
i = setting ? max_failures_to_try - 1 : 1;
while (i < max_failures_to_try)
{
_dbus_set_fail_alloc_failures (i);
if (!run_failing_each_malloc (approx_mallocs, description, func, data))
return FALSE;
++i;
}
_dbus_verbose ("\n=================\n%s: all iterations passed\n=================\n",
description);
......
......@@ -170,6 +170,7 @@ extern const char _dbus_return_if_fail_warning_format[];
#define _DBUS_ALIGN_ADDRESS(this, boundary) \
((void*)_DBUS_ALIGN_VALUE(this, boundary))
char* _dbus_strdup (const char *str);
void* _dbus_memdup (const void *mem,
size_t n_bytes);
......@@ -207,13 +208,12 @@ dbus_bool_t _dbus_set_fd_nonblocking (int fd,
DBusError *error);
void _dbus_verbose_bytes (const unsigned char *data,
int len);
int len,
int offset);
void _dbus_verbose_bytes_of_string (const DBusString *str,
int start,
int len);
const char* _dbus_type_to_string (int type);
const char* _dbus_header_field_to_string (int header_field);
extern const char _dbus_no_memory_message[];
......
......@@ -30,7 +30,7 @@
#define MAINLOOP_SPEW 0
#ifdef MAINLOOP_SPEW
#if MAINLOOP_SPEW
#ifdef DBUS_ENABLE_VERBOSE_MODE
static const char*
watch_flags_to_string (int flags)
......
This diff is collapsed.
......@@ -35,120 +35,6 @@
#error "config.h not included here"
#endif
/****************************************************** Remove later */
#undef DBUS_TYPE_INVALID
#undef DBUS_TYPE_NIL
#undef DBUS_TYPE_CUSTOM
#undef DBUS_TYPE_BYTE
#undef DBUS_TYPE_INT32
#undef DBUS_TYPE_UINT32
#undef DBUS_TYPE_INT64
#undef DBUS_TYPE_UINT64
#undef DBUS_TYPE_DOUBLE
#undef DBUS_TYPE_STRING
#undef DBUS_TYPE_OBJECT_PATH
#undef DBUS_TYPE_ARRAY
#undef DBUS_TYPE_DICT
#undef DBUS_TYPE_VARIANT
#undef DBUS_TYPE_STRUCT
#undef DBUS_NUMBER_OF_TYPES
/* Never a legitimate type */
#define DBUS_TYPE_INVALID ((int) '\0')
#define DBUS_TYPE_INVALID_AS_STRING "\0"
/* Primitive types */
#define DBUS_TYPE_BYTE ((int) 'y')
#define DBUS_TYPE_BYTE_AS_STRING "y"
#define DBUS_TYPE_BOOLEAN ((int) 'b')
#define DBUS_TYPE_BOOLEAN_AS_STRING "b"
#define DBUS_TYPE_INT32 ((int) 'i')
#define DBUS_TYPE_INT32_AS_STRING "i"
#define DBUS_TYPE_UINT32 ((int) 'u')
#define DBUS_TYPE_UINT32_AS_STRING "u"
#define DBUS_TYPE_INT64 ((int) 'x')
#define DBUS_TYPE_INT64_AS_STRING "x"
#define DBUS_TYPE_UINT64 ((int) 't')
#define DBUS_TYPE_UINT64_AS_STRING "t"
#define DBUS_TYPE_DOUBLE ((int) 'd')
#define DBUS_TYPE_DOUBLE_AS_STRING "d"
#define DBUS_TYPE_STRING ((int) 's')
#define DBUS_TYPE_STRING_AS_STRING "s"
#define DBUS_TYPE_OBJECT_PATH ((int) 'o')
#define DBUS_TYPE_OBJECT_PATH_AS_STRING "o"
#define DBUS_TYPE_SIGNATURE ((int) 'g')
#define DBUS_TYPE_SIGNATURE_AS_STRING "g"
/* Compound types */
#define DBUS_TYPE_ARRAY ((int) 'a')
#define DBUS_TYPE_ARRAY_AS_STRING "a"
#define DBUS_TYPE_VARIANT ((int) 'v')
#define DBUS_TYPE_VARIANT_AS_STRING "v"
/* STRUCT is sort of special since its code can't appear in a type string,
* instead DBUS_STRUCT_BEGIN_CHAR has to appear
*/
#define DBUS_TYPE_STRUCT ((int) 'r')
#define DBUS_TYPE_STRUCT_AS_STRING "r"
/* Does not count INVALID */
#define DBUS_NUMBER_OF_TYPES (13)
/* characters other than typecodes that appear in type signatures */
#define DBUS_STRUCT_BEGIN_CHAR ((int) '(')
#define DBUS_STRUCT_BEGIN_CHAR_AS_STRING "("
#define DBUS_STRUCT_END_CHAR ((int) ')')
#define DBUS_STRUCT_END_CHAR_AS_STRING ")"
#define DBUS_MAXIMUM_SIGNATURE_LENGTH 255
#define DBUS_MAXIMUM_ARRAY_LENGTH (67108864)
#define DBUS_MAXIMUM_ARRAY_LENGTH_BITS 26
#define DBUS_MAXIMUM_MESSAGE_LENGTH (DBUS_MAXIMUM_ARRAY_LENGTH * 2)
#define DBUS_MAXIMUM_MESSAGE_LENGTH_BITS 27
static const char *
_hack_dbus_type_to_string (int type)
{
switch (type)
{
case DBUS_TYPE_INVALID:
return "invalid";
case DBUS_TYPE_BOOLEAN:
return "boolean";
case DBUS_TYPE_INT32:
return "int32";
case DBUS_TYPE_UINT32:
return "uint32";
case DBUS_TYPE_DOUBLE:
return "double";
case DBUS_TYPE_STRING:
return "string";
case DBUS_TYPE_OBJECT_PATH:
return "object_path";
case DBUS_TYPE_SIGNATURE:
return "signature";
case DBUS_TYPE_STRUCT:
return "struct";
case DBUS_TYPE_ARRAY:
return "array";
case DBUS_TYPE_VARIANT:
return "variant";
case DBUS_STRUCT_BEGIN_CHAR:
return "begin_struct";
case DBUS_STRUCT_END_CHAR:
return "end_struct";
default:
return "unknown";
}
}
#define _dbus_type_to_string(t) _hack_dbus_type_to_string(t)
/****************************************************** Remove later */
#ifdef WORDS_BIGENDIAN
#define DBUS_COMPILER_BYTE_ORDER DBUS_BIG_ENDIAN
#else
......@@ -275,7 +161,7 @@ dbus_bool_t _dbus_marshal_write_basic (DBusString *str,
const void *value,
int byte_order,
int *pos_after);
dbus_bool_t _dbus_marshal_write_fixed_array (DBusString *str,
dbus_bool_t _dbus_marshal_write_fixed_multi (DBusString *str,
int insert_at,
int element_type,
const void *value,
......@@ -288,11 +174,11 @@ void _dbus_marshal_read_basic (const DBusString *str,
void *value,
int byte_order,
int *new_pos);
void _dbus_marshal_read_fixed_array (const DBusString *str,
void _dbus_marshal_read_fixed_multi (const DBusString *str,
int pos,
int element_type,
void *value,
int *n_elements,
int n_elements,
int byte_order,
int *new_pos);
void _dbus_marshal_skip_basic (const DBusString *str,
......@@ -316,7 +202,7 @@ int _dbus_type_get_alignment (int typecode);
dbus_bool_t _dbus_type_is_basic (int typecode);
dbus_bool_t _dbus_type_is_container (int typecode);
dbus_bool_t _dbus_type_is_fixed (int typecode);
const char* _dbus_type_to_string (int typecode);
......
This diff is collapsed.
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-marshal-header.h Managing marshaling/demarshaling of message headers
*
* Copyright (C) 2005 Red Hat, Inc.
*
* Licensed under the Academic Free License version 2.1
*
* 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
*
*/
#ifndef DBUS_MARSHAL_HEADER_H
#define DBUS_MARSHAL_HEADER_H
#include <config.h>
#include <dbus/dbus-marshal-basic.h>
#include <dbus/dbus-marshal-validate.h>
#ifndef PACKAGE
#error "config.h not included here"
#endif
typedef struct DBusHeader DBusHeader;
typedef struct DBusHeaderField DBusHeaderField;
#define _DBUS_HEADER_FIELD_VALUE_UNKNOWN -1
#define _DBUS_HEADER_FIELD_VALUE_NONEXISTENT -2
/**
* Cached information about a header field in the message
*/
struct DBusHeaderField
{
int value_pos; /**< Position of field value, or -1/-2 */
};
struct DBusHeader
{
DBusString data; /**< Header network data, stored
* separately from body so we can
* independently realloc it.
*/
DBusHeaderField fields[DBUS_HEADER_FIELD_LAST + 1]; /**< Track the location
* of each field in header
*/
dbus_uint32_t padding : 3; /**< bytes of alignment in header */
dbus_uint32_t byte_order : 8; /**< byte order of header */
};
dbus_bool_t _dbus_header_init (DBusHeader *header,
int byte_order);
void _dbus_header_free (DBusHeader *header);
void _dbus_header_reinit (DBusHeader *header,
int byte_order);
dbus_bool_t _dbus_header_create (DBusHeader *header,
int type,
const char *destination,
const char *path,
const char *interface,
const char *member,
const char *error_name);
dbus_bool_t _dbus_header_copy (const DBusHeader *header,
DBusHeader *dest);
int _dbus_header_get_message_type (DBusHeader *header);
void _dbus_header_set_serial (DBusHeader *header,
dbus_uint32_t serial);