28 #include "dbus-internals.h"
29 #include "dbus-marshal-recursive.h"
30 #include "dbus-marshal-validate.h"
31 #include "dbus-marshal-byteswap.h"
32 #include "dbus-marshal-header.h"
33 #include "dbus-signature.h"
34 #include "dbus-message-private.h"
35 #include "dbus-object-tree.h"
36 #include "dbus-memory.h"
37 #include "dbus-list.h"
38 #include "dbus-threads-internal.h"
39 #ifdef HAVE_UNIX_FD_PASSING
40 #include "dbus-sysdeps.h"
41 #include "dbus-sysdeps-unix.h"
46 #define _DBUS_TYPE_IS_STRINGLIKE(type) \
47 (type == DBUS_TYPE_STRING || type == DBUS_TYPE_SIGNATURE || \
48 type == DBUS_TYPE_OBJECT_PATH)
50 static void dbus_message_finalize (
DBusMessage *message);
62 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
64 _dbus_enable_message_cache (
void)
66 static int enabled = -1;
81 _dbus_warn (
"DBUS_MESSAGE_CACHE should be 0 or 1 if set, not '%s'",
90 # define _dbus_enable_message_cache() (TRUE)
93 #ifndef _dbus_message_trace_ref
100 static int enabled = -1;
102 _dbus_trace_ref (
"DBusMessage", message, old_refcount, new_refcount, why,
103 "DBUS_MESSAGE_TRACE", &enabled);
116 DBUS_MESSAGE_ITER_TYPE_READER = 3,
117 DBUS_MESSAGE_ITER_TYPE_WRITER = 7
141 #if DBUS_SIZEOF_VOID_P > 8
147 #define CHECK_DBUS_1_10_BINARY_COMPATIBILITY 0
149 #define CHECK_DBUS_1_10_BINARY_COMPATIBILITY 1
188 *type_str_p = &_dbus_empty_signature_str;
207 if (byte_order == DBUS_COMPILER_BYTE_ORDER)
210 _dbus_verbose (
"Swapping message into compiler byte order\n");
212 get_const_signature (&message->
header, &type_str, &type_pos);
216 DBUS_COMPILER_BYTE_ORDER,
221 DBUS_COMPILER_BYTE_ORDER);
230 #define ensure_byte_order(message) _dbus_message_byteswap (message)
250 *body = &message->
body;
268 #ifdef HAVE_UNIX_FD_PASSING
269 *fds = message->unix_fds;
270 *n_fds = message->n_unix_fds;
304 _dbus_return_if_fail (message !=
NULL);
305 _dbus_return_if_fail (!message->
locked);
339 _dbus_string_get_length (&message->
header.
data) +
340 _dbus_string_get_length (&message->
body);
342 #ifdef HAVE_UNIX_FD_PASSING
343 message->unix_fd_counter_delta = message->n_unix_fds;
347 _dbus_verbose (
"message has size %ld\n",
356 #ifdef HAVE_UNIX_FD_PASSING
412 #ifdef HAVE_UNIX_FD_PASSING
436 _dbus_string_get_length (&message->
body));
508 #define MAX_MESSAGE_SIZE_TO_CACHE 10 * _DBUS_ONE_KILOBYTE
511 #define MAX_MESSAGE_CACHE_SIZE 5
515 static int message_cache_count = 0;
519 dbus_message_cache_shutdown (
void *data)
525 "before registering a shutdown function");
530 if (message_cache[i])
531 dbus_message_finalize (message_cache[i]);
536 message_cache_count = 0;
537 message_cache_shutdown_registered =
FALSE;
550 dbus_message_get_cached (
void)
566 if (message_cache_count == 0)
581 if (message_cache[i])
583 message = message_cache[i];
584 message_cache[i] =
NULL;
585 message_cache_count -= 1;
603 #ifdef HAVE_UNIX_FD_PASSING
605 close_unix_fds(
int *fds,
unsigned *n_fds)
615 for (i = 0; i < *n_fds; i++)
631 free_counter (
void *element,
638 #ifdef HAVE_UNIX_FD_PASSING
652 dbus_message_cache_or_finalize (
DBusMessage *message)
665 free_counter, message);
668 #ifdef HAVE_UNIX_FD_PASSING
669 close_unix_fds(message->unix_fds, &message->n_unix_fds);
679 "the first time we constructed a message");
682 if (!message_cache_shutdown_registered)
692 message_cache[i] =
NULL;
696 message_cache_shutdown_registered =
TRUE;
701 if (!_dbus_enable_message_cache ())
704 if ((_dbus_string_get_length (&message->
header.
data) +
705 _dbus_string_get_length (&message->
body)) >
714 while (message_cache[i] !=
NULL)
720 message_cache[i] = message;
721 message_cache_count += 1;
723 #ifndef DBUS_DISABLE_CHECKS
733 dbus_message_finalize (message);
757 _dbus_return_if_fail (iter !=
NULL);
768 #if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT)
783 "closed, or is uninitialized or corrupt");
789 if (iter->
iter_type == DBUS_MESSAGE_ITER_TYPE_READER)
799 else if (iter->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER)
817 _dbus_warn_check_failed (
"dbus message iterator invalid because the message has been modified (or perhaps the iterator is just uninitialized)");
844 int spec_type, msg_type, i, j;
852 spec_type = first_arg_type;
858 va_copy (copy_args, var_args);
864 if (msg_type != spec_type)
867 "Argument %d is specified to be of type \"%s\", but "
868 "is actually of type \"%s\"\n", i,
877 #ifdef HAVE_UNIX_FD_PASSING
881 pfd = va_arg (var_args,
int*);
889 "Message refers to file descriptor at index %i,"
890 "but has only %i descriptors attached.\n",
902 "Platform does not support file desciptor passing.\n");
910 ptr = va_arg (var_args,
void *);
920 int spec_element_type;
925 spec_element_type = va_arg (var_args,
int);
928 if (spec_element_type != element_type)
931 "Argument %d is specified to be an array of \"%s\", but "
932 "is actually an array of \"%s\"\n",
943 ptr = va_arg (var_args,
const void **);
944 n_elements_p = va_arg (var_args,
int*);
953 else if (_DBUS_TYPE_IS_STRINGLIKE (spec_element_type))
959 str_array_p = va_arg (var_args,
char***);
960 n_elements_p = va_arg (var_args,
int*);
975 str_array =
dbus_new0 (
char*, n_elements + 1);
976 if (str_array ==
NULL)
978 _DBUS_SET_OOM (error);
986 while (j < n_elements)
993 if (str_array[j] ==
NULL)
996 _DBUS_SET_OOM (error);
1010 *str_array_p = str_array;
1011 *n_elements_p = n_elements;
1013 #ifndef DBUS_DISABLE_CHECKS
1016 _dbus_warn (
"you can't read arrays of container types (struct, variant, array) with %s for now",
1017 _DBUS_FUNCTION_NAME);
1022 #ifndef DBUS_DISABLE_CHECKS
1025 _dbus_warn (
"you can only read arrays and basic types with %s for now",
1026 _DBUS_FUNCTION_NAME);
1034 spec_type = va_arg (var_args,
int);
1038 "Message has only %d arguments, but more were expected", i);
1052 spec_type = first_arg_type;
1059 #ifdef HAVE_UNIX_FD_PASSING
1062 pfd = va_arg (copy_args,
int *);
1074 va_arg (copy_args,
const void *);
1078 int spec_element_type;
1080 spec_element_type = va_arg (copy_args,
int);
1084 va_arg (copy_args,
const void **);
1085 va_arg (copy_args,
int *);
1087 else if (_DBUS_TYPE_IS_STRINGLIKE (spec_element_type))
1089 char ***str_array_p;
1091 str_array_p = va_arg (copy_args,
char ***);
1093 va_arg (copy_args,
int *);
1096 *str_array_p =
NULL;
1100 spec_type = va_arg (copy_args,
int);
1170 _dbus_return_val_if_fail (message !=
NULL, 0);
1189 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
1190 _dbus_return_val_if_fail (!message->
locked,
FALSE);
1191 _dbus_return_val_if_fail (reply_serial != 0,
FALSE);
1193 value.
u32 = reply_serial;
1212 _dbus_return_val_if_fail (message !=
NULL, 0);
1232 free_counter, message);
1238 #ifdef HAVE_UNIX_FD_PASSING
1239 close_unix_fds(message->unix_fds, &message->n_unix_fds);
1249 dbus_message_new_empty_header (
void)
1254 message = dbus_message_get_cached ();
1256 if (message !=
NULL)
1264 if (message ==
NULL)
1266 #ifndef DBUS_DISABLE_CHECKS
1270 #ifdef HAVE_UNIX_FD_PASSING
1271 message->unix_fds =
NULL;
1272 message->n_unix_fds_allocated = 0;
1278 _dbus_message_trace_ref (message, 0, 1,
"new_empty_header");
1281 #ifndef DBUS_DISABLE_CHECKS
1288 #ifdef HAVE_UNIX_FD_PASSING
1289 message->n_unix_fds = 0;
1290 message->n_unix_fds_allocated = 0;
1291 message->unix_fd_counter_delta = 0;
1340 message = dbus_message_new_empty_header ();
1341 if (message ==
NULL)
1345 DBUS_COMPILER_BYTE_ORDER,
1385 _dbus_return_val_if_fail (path !=
NULL,
NULL);
1386 _dbus_return_val_if_fail (method !=
NULL,
NULL);
1387 _dbus_return_val_if_fail (destination ==
NULL ||
1388 _dbus_check_is_valid_bus_name (destination),
NULL);
1389 _dbus_return_val_if_fail (_dbus_check_is_valid_path (path),
NULL);
1390 _dbus_return_val_if_fail (iface ==
NULL ||
1391 _dbus_check_is_valid_interface (iface),
NULL);
1392 _dbus_return_val_if_fail (_dbus_check_is_valid_member (method),
NULL);
1394 message = dbus_message_new_empty_header ();
1395 if (message ==
NULL)
1399 DBUS_COMPILER_BYTE_ORDER,
1401 destination, path, iface, method,
NULL))
1423 _dbus_return_val_if_fail (method_call !=
NULL,
NULL);
1429 message = dbus_message_new_empty_header ();
1430 if (message ==
NULL)
1434 DBUS_COMPILER_BYTE_ORDER,
1475 _dbus_return_val_if_fail (path !=
NULL,
NULL);
1476 _dbus_return_val_if_fail (iface !=
NULL,
NULL);
1477 _dbus_return_val_if_fail (name !=
NULL,
NULL);
1478 _dbus_return_val_if_fail (_dbus_check_is_valid_path (path),
NULL);
1479 _dbus_return_val_if_fail (_dbus_check_is_valid_interface (iface),
NULL);
1480 _dbus_return_val_if_fail (_dbus_check_is_valid_member (name),
NULL);
1482 message = dbus_message_new_empty_header ();
1483 if (message ==
NULL)
1487 DBUS_COMPILER_BYTE_ORDER,
1516 const char *error_name,
1517 const char *error_message)
1523 _dbus_return_val_if_fail (reply_to !=
NULL,
NULL);
1524 _dbus_return_val_if_fail (error_name !=
NULL,
NULL);
1525 _dbus_return_val_if_fail (_dbus_check_is_valid_error_name (error_name),
NULL);
1533 message = dbus_message_new_empty_header ();
1534 if (message ==
NULL)
1538 DBUS_COMPILER_BYTE_ORDER,
1555 if (error_message !=
NULL)
1588 const char *error_name,
1589 const char *error_format,
1596 _dbus_return_val_if_fail (reply_to !=
NULL,
NULL);
1597 _dbus_return_val_if_fail (error_name !=
NULL,
NULL);
1598 _dbus_return_val_if_fail (_dbus_check_is_valid_error_name (error_name),
NULL);
1603 va_start (args, error_format);
1607 _dbus_string_get_const_data (&str));
1636 _dbus_return_val_if_fail (message !=
NULL,
NULL);
1645 #ifndef DBUS_DISABLE_CHECKS
1656 _dbus_string_get_length (&message->
body)))
1667 #ifdef HAVE_UNIX_FD_PASSING
1668 retval->unix_fds =
dbus_new(
int, message->n_unix_fds);
1669 if (retval->unix_fds ==
NULL && message->n_unix_fds > 0)
1672 retval->n_unix_fds_allocated = message->n_unix_fds;
1674 for (retval->n_unix_fds = 0;
1675 retval->n_unix_fds < message->n_unix_fds;
1676 retval->n_unix_fds++)
1678 retval->unix_fds[retval->n_unix_fds] =
_dbus_dup(message->unix_fds[retval->n_unix_fds],
NULL);
1680 if (retval->unix_fds[retval->n_unix_fds] < 0)
1686 _dbus_message_trace_ref (retval, 0, 1,
"copy");
1693 #ifdef HAVE_UNIX_FD_PASSING
1694 close_unix_fds(retval->unix_fds, &retval->n_unix_fds);
1716 _dbus_return_val_if_fail (message !=
NULL,
NULL);
1722 _dbus_message_trace_ref (message, old_refcount, old_refcount + 1,
"ref");
1739 _dbus_return_if_fail (message !=
NULL);
1741 _dbus_return_if_fail (!message->
in_cache);
1747 _dbus_message_trace_ref (message, old_refcount, old_refcount - 1,
"unref");
1749 if (old_refcount == 1)
1752 dbus_message_cache_or_finalize (message);
1850 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
1852 va_start (var_args, first_arg_type);
1882 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
1884 type = first_arg_type;
1893 value = va_arg (var_args,
const void *);
1906 element_type = va_arg (var_args,
int);
1908 buf[0] = element_type;
1922 value = va_arg (var_args,
const void **);
1923 n_elements = va_arg (var_args,
int);
1933 else if (_DBUS_TYPE_IS_STRINGLIKE (element_type))
1935 const char ***value_p;
1940 value_p = va_arg (var_args,
const char***);
1941 n_elements = va_arg (var_args,
int);
1946 while (i < n_elements)
1959 _dbus_warn (
"arrays of %s can't be appended with %s for now",
1961 _DBUS_FUNCTION_NAME);
1969 #ifndef DBUS_DISABLE_CHECKS
1972 _dbus_warn (
"type %s isn't supported yet in %s",
1978 type = va_arg (var_args,
int);
2040 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
2041 _dbus_return_val_if_error_is_set (error,
FALSE);
2043 va_start (var_args, first_arg_type);
2068 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
2069 _dbus_return_val_if_error_is_set (error,
FALSE);
2076 _dbus_message_iter_init_common (
DBusMessage *message,
2084 #if CHECK_DBUS_1_10_BINARY_COMPATIBILITY
2095 #if DBUS_SIZEOF_VOID_P > 8
2096 _DBUS_STATIC_ASSERT (
sizeof (
DBusMessageIter) == 16 *
sizeof (
void *));
2099 4 *
sizeof (
void *) +
sizeof (
dbus_uint32_t) + 9 *
sizeof (
int));
2143 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
2144 _dbus_return_val_if_fail (iter !=
NULL,
FALSE);
2146 get_const_signature (&message->
header, &type_str, &type_pos);
2148 _dbus_message_iter_init_common (message, real,
2149 DBUS_MESSAGE_ITER_TYPE_READER);
2171 _dbus_return_val_if_fail (_dbus_message_iter_check (real),
FALSE);
2172 _dbus_return_val_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_READER,
FALSE);
2190 _dbus_return_val_if_fail (_dbus_message_iter_check (real),
FALSE);
2191 _dbus_return_val_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_READER,
FALSE);
2216 _dbus_return_val_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_READER,
FALSE);
2273 _dbus_return_if_fail (_dbus_message_iter_check (real));
2274 _dbus_return_if_fail (sub !=
NULL);
2300 _dbus_return_val_if_fail (_dbus_message_iter_check (real),
NULL);
2308 _dbus_string_get_const_data (sig) + start,
2374 _dbus_return_if_fail (_dbus_message_iter_check (real));
2375 _dbus_return_if_fail (value !=
NULL);
2379 #ifdef HAVE_UNIX_FD_PASSING
2387 *((
int*) value) = -1;
2393 *((
int*) value) = -1;
2421 _dbus_return_val_if_fail (_dbus_message_iter_check (real), 0);
2431 n_elements = total_len / alignment;
2462 _dbus_return_val_if_fail (_dbus_message_iter_check (real), 0);
2508 #ifndef DBUS_DISABLE_CHECKS
2511 _dbus_return_if_fail (_dbus_message_iter_check (real));
2512 _dbus_return_if_fail (value !=
NULL);
2538 _dbus_return_if_fail (message !=
NULL);
2539 _dbus_return_if_fail (iter !=
NULL);
2541 _dbus_message_iter_init_common (message, real,
2542 DBUS_MESSAGE_ITER_TYPE_WRITER);
2551 _dbus_string_get_length (&message->
body));
2567 int current_sig_pos;
2584 ¤t_sig, ¤t_sig_pos))
2591 current_len = _dbus_string_get_byte (current_sig, current_sig_pos);
2592 current_sig_pos += 1;
2623 str, _dbus_string_get_length (str));
2640 const char *v_STRING;
2657 v_STRING = _dbus_string_get_const_data (str);
2700 #if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT)
2704 if (!_dbus_message_iter_check (iter))
2717 #ifdef HAVE_UNIX_FD_PASSING
2727 if (m->n_unix_fds + n > m->n_unix_fds_allocated)
2733 k = (m->n_unix_fds + n) * 2;
2744 m->n_unix_fds_allocated = k;
2747 return m->unix_fds + m->n_unix_fds;
2778 _dbus_return_val_if_fail (_dbus_message_iter_append_check (real),
FALSE);
2779 _dbus_return_val_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
FALSE);
2781 _dbus_return_val_if_fail (value !=
NULL,
FALSE);
2783 #ifndef DBUS_DISABLE_CHECKS
2788 const char *
const *string_p;
2793 _dbus_return_val_if_fail (_dbus_check_is_valid_utf8 (*string_p),
FALSE);
2798 _dbus_return_val_if_fail (_dbus_check_is_valid_path (*string_p),
FALSE);
2806 _dbus_string_get_length (&str));
2816 _dbus_return_val_if_fail (*bool_p == 0 || *bool_p == 1,
FALSE);
2826 if (!_dbus_message_iter_open_signature (real))
2831 #ifdef HAVE_UNIX_FD_PASSING
2838 if (!(fds = expand_fd_array(real->
message, 1)))
2845 u = real->
message->n_unix_fds;
2853 real->
message->n_unix_fds += 1;
2880 if (!_dbus_message_iter_close_signature (real))
2930 _dbus_return_val_if_fail (_dbus_message_iter_append_check (real),
FALSE);
2931 _dbus_return_val_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
FALSE);
2934 _dbus_return_val_if_fail (value !=
NULL,
FALSE);
2935 _dbus_return_val_if_fail (n_elements >= 0,
FALSE);
2936 _dbus_return_val_if_fail (n_elements <=
2940 #ifndef DBUS_DISABLE_CHECKS
2946 for (i = 0; i < n_elements; i++)
2948 _dbus_return_val_if_fail ((*bools)[i] == 0 || (*bools)[i] == 1,
FALSE);
2988 const char *contained_signature,
2997 _dbus_return_val_if_fail (sub !=
NULL,
FALSE);
3000 _dbus_message_real_iter_zero (real_sub);
3002 _dbus_return_val_if_fail (_dbus_message_iter_append_check (real),
FALSE);
3003 _dbus_return_val_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
FALSE);
3006 contained_signature ==
NULL) ||
3008 contained_signature ==
NULL) ||
3010 contained_signature !=
NULL) ||
3018 if (contained_signature !=
NULL)
3023 _dbus_string_get_length (&contained_str));
3031 contained_signature_validity = DBUS_VALID_BUT_INCOMPLETE;
3035 contained_signature ==
NULL ||
3039 if (!_dbus_message_iter_open_signature (real))
3045 if (contained_signature !=
NULL)
3063 _dbus_message_iter_abandon_signature (real);
3096 _dbus_return_val_if_fail (_dbus_message_iter_append_check (real),
FALSE);
3097 _dbus_return_val_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
FALSE);
3098 _dbus_return_val_if_fail (_dbus_message_iter_append_check (real_sub),
FALSE);
3099 _dbus_return_val_if_fail (real_sub->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
FALSE);
3103 _dbus_message_real_iter_zero (real_sub);
3105 if (!_dbus_message_iter_close_signature (real))
3129 #ifndef DBUS_DISABLE_CHECKS
3130 _dbus_return_if_fail (_dbus_message_iter_append_check (real));
3131 _dbus_return_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER);
3132 _dbus_return_if_fail (_dbus_message_iter_append_check (real_sub));
3133 _dbus_return_if_fail (real_sub->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER);
3136 _dbus_message_iter_abandon_signature (real);
3137 _dbus_message_real_iter_zero (real_sub);
3194 if (_dbus_message_real_iter_is_zeroed (real) &&
3195 _dbus_message_real_iter_is_zeroed (real_sub))
3198 #ifndef DBUS_DISABLE_CHECKS
3203 _dbus_return_if_fail (_dbus_message_iter_append_check (real));
3204 _dbus_return_if_fail (real->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER);
3214 if (_dbus_message_real_iter_is_zeroed (real_sub))
3217 #ifndef DBUS_DISABLE_CHECKS
3218 _dbus_return_if_fail (_dbus_message_iter_append_check (real_sub));
3219 _dbus_return_if_fail (real_sub->
iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER);
3226 _dbus_message_iter_abandon_signature (real);
3227 _dbus_message_real_iter_zero (real_sub);
3250 _dbus_return_if_fail (message !=
NULL);
3251 _dbus_return_if_fail (!message->
locked);
3268 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3292 _dbus_return_if_fail (message !=
NULL);
3293 _dbus_return_if_fail (!message->
locked);
3310 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3331 const char *object_path)
3333 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3334 _dbus_return_val_if_fail (!message->
locked,
FALSE);
3335 _dbus_return_val_if_fail (object_path ==
NULL ||
3336 _dbus_check_is_valid_path (object_path),
3339 return set_or_delete_string_field (message,
3363 _dbus_return_val_if_fail (message !=
NULL,
NULL);
3386 const char *msg_path;
3389 if (msg_path ==
NULL)
3400 if (strcmp (msg_path, path) == 0)
3432 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3433 _dbus_return_val_if_fail (path !=
NULL,
FALSE);
3464 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3465 _dbus_return_val_if_fail (!message->
locked,
FALSE);
3466 _dbus_return_val_if_fail (iface ==
NULL ||
3467 _dbus_check_is_valid_interface (iface),
3470 return set_or_delete_string_field (message,
3494 _dbus_return_val_if_fail (message !=
NULL,
NULL);
3515 const char *msg_interface;
3518 if (msg_interface ==
NULL)
3529 if (strcmp (msg_interface, iface) == 0)
3552 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3553 _dbus_return_val_if_fail (!message->
locked,
FALSE);
3554 _dbus_return_val_if_fail (member ==
NULL ||
3555 _dbus_check_is_valid_member (member),
3558 return set_or_delete_string_field (message,
3580 _dbus_return_val_if_fail (message !=
NULL,
NULL);
3601 const char *msg_member;
3604 if (msg_member ==
NULL)
3615 if (strcmp (msg_member, member) == 0)
3635 const char *error_name)
3637 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3638 _dbus_return_val_if_fail (!message->
locked,
FALSE);
3639 _dbus_return_val_if_fail (error_name ==
NULL ||
3640 _dbus_check_is_valid_error_name (error_name),
3643 return set_or_delete_string_field (message,
3664 _dbus_return_val_if_fail (message !=
NULL,
NULL);
3689 const char *destination)
3691 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3692 _dbus_return_val_if_fail (!message->
locked,
FALSE);
3693 _dbus_return_val_if_fail (destination ==
NULL ||
3694 _dbus_check_is_valid_bus_name (destination),
3697 return set_or_delete_string_field (message,
3717 _dbus_return_val_if_fail (message !=
NULL,
NULL);
3745 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3746 _dbus_return_val_if_fail (!message->
locked,
FALSE);
3747 _dbus_return_val_if_fail (sender ==
NULL ||
3748 _dbus_check_is_valid_bus_name (sender),
3751 return set_or_delete_string_field (message,
3777 _dbus_return_val_if_fail (message !=
NULL,
NULL);
3811 _dbus_return_val_if_fail (message !=
NULL,
NULL);
3813 get_const_signature (&message->
header, &type_str, &type_pos);
3815 return _dbus_string_get_const_data_len (type_str, type_pos, 0);
3819 _dbus_message_has_type_interface_member (
DBusMessage *message,
3839 if (n && strcmp (n, member) == 0)
3843 if (n ==
NULL || strcmp (n, iface) == 0)
3869 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3870 _dbus_return_val_if_fail (iface !=
NULL,
FALSE);
3871 _dbus_return_val_if_fail (method !=
NULL,
FALSE);
3876 return _dbus_message_has_type_interface_member (message,
3895 const char *signal_name)
3897 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3898 _dbus_return_val_if_fail (iface !=
NULL,
FALSE);
3899 _dbus_return_val_if_fail (signal_name !=
NULL,
FALSE);
3904 return _dbus_message_has_type_interface_member (message,
3906 iface, signal_name);
3921 const char *error_name)
3925 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3926 _dbus_return_val_if_fail (error_name !=
NULL,
FALSE);
3936 if (n && strcmp (n, error_name) == 0)
3958 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3959 _dbus_return_val_if_fail (name !=
NULL,
FALSE);
3966 if (s && strcmp (s, name) == 0)
3993 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
3994 _dbus_return_val_if_fail (name !=
NULL,
FALSE);
4001 if (s && strcmp (s, name) == 0)
4018 const char *signature)
4022 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
4023 _dbus_return_val_if_fail (signature !=
NULL,
FALSE);
4030 if (s && strcmp (s, signature) == 0)
4064 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
4065 _dbus_return_val_if_error_is_set (error,
FALSE);
4076 str ?
"%s" :
NULL, str);
4090 #ifdef HAVE_UNIX_FD_PASSING
4093 return message->n_unix_fds > 0;
4111 const char *object_path)
4113 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
4114 _dbus_return_val_if_fail (!message->
locked,
FALSE);
4115 _dbus_return_val_if_fail (object_path ==
NULL ||
4116 _dbus_check_is_valid_path (object_path),
4119 return set_or_delete_string_field (message,
4140 _dbus_return_val_if_fail (message !=
NULL,
NULL);
4168 #define INITIAL_LOADER_DATA_LEN 32
4209 #ifdef HAVE_UNIX_FD_PASSING
4210 loader->unix_fds =
NULL;
4211 loader->n_unix_fds = loader->n_unix_fds_allocated = 0;
4212 loader->unix_fds_outstanding =
FALSE;
4244 #ifdef HAVE_UNIX_FD_PASSING
4245 close_unix_fds(loader->unix_fds, &loader->n_unix_fds);
4281 *buffer = &loader->
data;
4285 if (max_to_read !=
NULL)
4287 #ifdef HAVE_UNIX_FD_PASSING
4291 int fields_array_len;
4297 *may_read_fds =
TRUE;
4299 #ifdef HAVE_UNIX_FD_PASSING
4302 if (loader->n_unix_fds == 0)
4313 remain = _dbus_string_get_length (&loader->
data);
4327 *may_read_fds =
FALSE;
4351 needed = header_len + body_len;
4353 *max_to_read = needed - remain;
4354 *may_read_fds =
FALSE;
4360 needed = header_len + body_len;
4389 #ifdef HAVE_UNIX_FD_PASSING
4403 unsigned *max_n_fds)
4423 loader->unix_fds = a;
4427 *fds = loader->unix_fds + loader->n_unix_fds;
4428 *max_n_fds = loader->n_unix_fds_allocated - loader->n_unix_fds;
4430 loader->unix_fds_outstanding =
TRUE;
4450 _dbus_assert(loader->unix_fds + loader->n_unix_fds == fds);
4451 _dbus_assert(loader->n_unix_fds + n_fds <= loader->n_unix_fds_allocated);
4453 loader->n_unix_fds += n_fds;
4454 loader->unix_fds_outstanding =
FALSE;
4456 if (n_fds && loader->unix_fds_change)
4457 loader->unix_fds_change (loader->unix_fds_change_data);
4491 int fields_array_len,
4502 mode = DBUS_VALIDATION_MODE_DATA_IS_UNTRUSTED;
4512 _dbus_assert ((header_len + body_len) <= _dbus_string_get_length (&loader->
data));
4523 _dbus_verbose (
"Failed to load header for new message code %d\n", validity);
4542 if (mode != DBUS_VALIDATION_MODE_WE_TRUST_THIS_DATA_ABSOLUTELY)
4544 get_const_signature (&message->
header, &type_str, &type_pos);
4558 _dbus_verbose (
"Failed to validate message body code %d\n", validity);
4573 #ifdef HAVE_UNIX_FD_PASSING
4575 if (n_unix_fds > loader->n_unix_fds)
4577 _dbus_verbose(
"Message contains references to more unix fds than were sent %u != %u\n",
4578 n_unix_fds, loader->n_unix_fds);
4591 message->unix_fds =
_dbus_memdup(loader->unix_fds, n_unix_fds *
sizeof(message->unix_fds[0]));
4592 if (message->unix_fds ==
NULL)
4594 _dbus_verbose (
"Failed to allocate file descriptor array\n");
4599 message->n_unix_fds_allocated = message->n_unix_fds = n_unix_fds;
4600 loader->n_unix_fds -= n_unix_fds;
4601 memmove (loader->unix_fds, loader->unix_fds + n_unix_fds, loader->n_unix_fds * sizeof (loader->unix_fds[0]));
4603 if (loader->unix_fds_change)
4604 loader->unix_fds_change (loader->unix_fds_change_data);
4607 message->unix_fds =
NULL;
4613 _dbus_verbose (
"Hmm, message claims to come with file descriptors "
4614 "but that's not supported on our platform, disconnecting.\n");
4627 _dbus_verbose (
"Failed to append new message to loader queue\n");
4634 (header_len + body_len));
4638 _dbus_verbose (
"Failed to move body into new message\n");
4651 _dbus_verbose (
"Loaded message %p\n", message);
4698 int byte_order, fields_array_len, header_len, body_len;
4707 _dbus_string_get_length (&loader->
data)))
4713 message = dbus_message_new_empty_header ();
4714 if (message ==
NULL)
4717 if (!load_message (loader, message,
4718 byte_order, fields_array_len,
4719 header_len, body_len))
4733 _dbus_verbose (
"Initial peek at header says we don't have a whole message yet, or data broken with invalid code %d\n",
4848 _dbus_verbose (
"clamping requested max message size %ld to %d\n",
4879 _dbus_verbose (
"clamping requested max message unix_fds %ld to %d\n",
4906 #ifdef HAVE_UNIX_FD_PASSING
4907 return loader->n_unix_fds;
4923 void (* callback) (
void *),
4926 #ifdef HAVE_UNIX_FD_PASSING
4927 loader->unix_fds_change = callback;
4928 loader->unix_fds_change_data = data;
4970 _dbus_return_if_fail (*slot_p >= 0);
4998 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
4999 _dbus_return_val_if_fail (slot >= 0,
FALSE);
5003 slot, data, free_data_func,
5004 &old_free_func, &old_data);
5010 (* old_free_func) (old_data);
5030 _dbus_return_val_if_fail (message !=
NULL,
NULL);
5055 if (strcmp (type_str,
"method_call") == 0)
5057 if (strcmp (type_str,
"method_return") == 0)
5059 else if (strcmp (type_str,
"signal") == 0)
5061 else if (strcmp (type_str,
"error") == 0)
5086 return "method_call";
5088 return "method_return";
5112 char **marshalled_data_p,
5118 _dbus_return_val_if_fail (msg !=
NULL,
FALSE);
5119 _dbus_return_val_if_fail (marshalled_data_p !=
NULL,
FALSE);
5120 _dbus_return_val_if_fail (len_p !=
NULL,
FALSE);
5126 was_locked = msg->
locked;
5134 *len_p = _dbus_string_get_length (&tmp);
5139 *len_p = _dbus_string_get_length (&tmp);
5181 _dbus_return_val_if_fail (str !=
NULL,
NULL);
5219 _DBUS_SET_OOM (error);
5244 int byte_order, fields_array_len, header_len, body_len;
5258 &validity, &byte_order,
5268 _dbus_assert (have_message || (header_len + body_len) > len);
5269 (void) have_message;
5270 return header_len + body_len;
5303 _dbus_return_if_fail (message !=
NULL);
5304 _dbus_return_if_fail (!message->
locked);
5320 _dbus_return_val_if_fail (message !=
NULL,
FALSE);
5396 &variant_signature, 0, &self->data, 0);
5399 &contained_signature, 0, &variant_writer))
5415 &contained_signature, 1, &array_writer))
5419 &real_array_reader->
u.
reader))
5443 &real_inner_reader->
u.
reader))
5488 #ifndef DBUS_DISABLE_ASSERT
5494 #ifndef DBUS_DISABLE_ASSERT
5497 len = _dbus_string_get_byte (&self->data, 0);
5499 ret = _dbus_string_get_const_data_len (&self->data, 1, len);
5530 _dbus_assert (_dbus_message_iter_append_check (real_writer));
5535 &variant_signature, 0, &self->data, 0);
5538 if (!_dbus_message_iter_open_signature (real_writer))
5544 if (!_dbus_message_iter_close_signature (real_writer))
5554 return _dbus_string_get_length (&self->data);
dbus_bool_t dbus_type_is_fixed(int typecode)
Tells you whether values of this type can change length if you set them to some other value...
DBusValidity _dbus_validate_body_with_reason(const DBusString *expected_signature, int expected_signature_start, int byte_order, int *bytes_remaining, const DBusString *value_str, int value_pos, int len)
Verifies that the range of value_str from value_pos to value_end is a legitimate value of type expect...
int dbus_message_type_from_string(const char *type_str)
Utility function to convert a machine-readable (not translated) string into a D-Bus message type...
unsigned int dbus_uint32_t
A 32-bit unsigned integer on all platforms.
DBusMessage * dbus_message_ref(DBusMessage *message)
Increments the reference count of a DBusMessage.
void dbus_message_lock(DBusMessage *message)
Locks a message.
const char * message
public error message field
dbus_bool_t dbus_message_has_path(DBusMessage *message, const char *path)
Checks if the message has a particular object path.
dbus_uint32_t changed_stamp
Incremented when iterators are invalidated.
#define NULL
A null pointer, defined appropriately for C or C++.
dbus_bool_t dbus_message_is_method_call(DBusMessage *message, const char *iface, const char *method)
Checks whether the message is a method call with the given interface and member fields.
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
long _dbus_message_loader_get_max_message_size(DBusMessageLoader *loader)
Gets the maximum allowed message size in bytes.
void dbus_message_set_no_reply(DBusMessage *message, dbus_bool_t no_reply)
Sets a flag indicating that the message does not want a reply; if this flag is set, the other end of the connection may (but is not required to) optimize by not sending method return or error replies.
void _dbus_message_loader_putback_message_link(DBusMessageLoader *loader, DBusList *link)
Returns a popped message link, used to undo a pop.
dbus_bool_t _dbus_header_copy(const DBusHeader *header, DBusHeader *dest)
Initializes dest with a copy of the given header.
int dbus_message_iter_get_arg_type(DBusMessageIter *iter)
Returns the argument type of the argument that the message iterator points to.
dbus_uint32_t sig_refcount
depth of open_signature()
void _dbus_message_loader_return_buffer(DBusMessageLoader *loader, DBusString *buffer)
Returns a buffer obtained from _dbus_message_loader_get_buffer(), indicating to the loader how many b...
void _dbus_type_writer_remove_types(DBusTypeWriter *writer)
Removes type string from the writer.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
dbus_uint32_t dbus_message_get_serial(DBusMessage *message)
Returns the serial of a message or 0 if none has been specified.
DBusList * messages
Complete messages.
The type writer is an iterator for writing to a block of values.
void dbus_message_iter_recurse(DBusMessageIter *iter, DBusMessageIter *sub)
Recurses into a container value when reading values from a message, initializing a sub-iterator to us...
void _dbus_type_reader_recurse(DBusTypeReader *reader, DBusTypeReader *sub)
Initialize a new reader pointing to the first type and corresponding value that's a child of the curr...
DBusMessage * _dbus_message_loader_pop_message(DBusMessageLoader *loader)
Pops a loaded message (passing ownership of the message to the caller).
DBusList * _dbus_list_find_last(DBusList **list, void *data)
Finds a value in the list.
dbus_bool_t dbus_message_set_interface(DBusMessage *message, const char *iface)
Sets the interface this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or the interface...
#define DBUS_ERROR_NOT_SUPPORTED
Requested operation isn't supported (like ENOSYS on UNIX).
#define dbus_new(type, count)
Safe macro for using dbus_malloc().
void dbus_message_free_data_slot(dbus_int32_t *slot_p)
Deallocates a global ID for message data slots.
#define DBUS_HEADER_FIELD_SIGNATURE
Header field code for the type signature of a message.
dbus_bool_t _dbus_header_remove_unknown_fields(DBusHeader *header)
Remove every header field not known to this version of dbus.
const char * dbus_message_get_error_name(DBusMessage *message)
Gets the error name (DBUS_MESSAGE_TYPE_ERROR only) or NULL if none.
dbus_bool_t dbus_message_iter_close_container(DBusMessageIter *iter, DBusMessageIter *sub)
Closes a container-typed value appended to the message; may write out more information to the message...
dbus_bool_t dbus_message_is_error(DBusMessage *message, const char *error_name)
Checks whether the message is an error reply with the given error name.
void _dbus_list_remove_link(DBusList **list, DBusList *link)
Removes a link from the list.
#define DBUS_TYPE_STRUCT
STRUCT and DICT_ENTRY are sort of special since their codes can't appear in a type string...
#define DBUS_TYPE_DICT_ENTRY
Type code used to represent a dict entry; however, this type code does not appear in type signatures...
const char * _dbus_variant_get_signature(DBusVariant *self)
Return the signature of the item stored in self.
const char * dbus_message_get_sender(DBusMessage *message)
Gets the unique name of the connection which originated this message, or NULL if unknown or inapplica...
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_message_iter_get_args_valist(DBusMessageIter *iter, DBusError *error, int first_arg_type, va_list var_args)
Implementation of the varargs arg-getting functions.
#define DBUS_TYPE_STRING
Type code marking a UTF-8 encoded, nul-terminated Unicode string.
DBusString body
Body network data.
dbus_uint32_t _dbus_header_get_serial(DBusHeader *header)
See dbus_message_get_serial()
dbus_bool_t _dbus_header_get_flag(DBusHeader *header, dbus_uint32_t flag)
Gets a message flag bit, returning TRUE if the bit is set.
#define DBUS_HEADER_FLAG_NO_REPLY_EXPECTED
If set, this flag means that the sender of a message does not care about getting a reply...
void _dbus_list_append_link(DBusList **list, DBusList *link)
Appends a link to the list.
Internals of DBusCounter.
dbus_bool_t dbus_message_allocate_data_slot(dbus_int32_t *slot_p)
Allocates an integer ID to be used for storing application-specific data on any DBusMessage.
void * data
Data stored at this element.
#define MAX_MESSAGE_CACHE_SIZE
Avoid caching too many messages.
DBusMessage * dbus_message_new(int message_type)
Constructs a new message of the given message type.
#define DBUS_ERROR_INCONSISTENT_MESSAGE
The message meta data does not match the payload.
dbus_bool_t _dbus_header_init(DBusHeader *header)
Initializes a header, but doesn't prepare it for use; to make the header valid, you have to call _dbu...
void _dbus_warn_check_failed(const char *format,...)
Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...
const char * dbus_message_get_signature(DBusMessage *message)
Gets the type signature of the message, i.e.
void dbus_message_iter_init_append(DBusMessage *message, DBusMessageIter *iter)
Initializes a DBusMessageIter for appending arguments to the end of a message.
void dbus_error_free(DBusError *error)
Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...
void dbus_message_set_auto_start(DBusMessage *message, dbus_bool_t auto_start)
Sets a flag indicating that an owner for the destination name will be automatically started before th...
An opaque data structure containing the serialized form of any single D-Bus message item...
union DBusMessageRealIter::@6 u
the type writer or reader that does all the work
Layout of a DBusMessageIter on the stack in dbus 1.10.0.
dbus_bool_t dbus_message_get_allow_interactive_authorization(DBusMessage *message)
Returns whether the flag controlled by dbus_message_set_allow_interactive_authorization() has been se...
void _dbus_message_loader_unref(DBusMessageLoader *loader)
Decrements the reference count of the loader and finalizes the loader when the count reaches zero...
DBusCounter * _dbus_counter_ref(DBusCounter *counter)
Increments refcount of the counter.
dbus_bool_t dbus_message_has_interface(DBusMessage *message, const char *iface)
Checks if the message has an interface.
void _dbus_list_clear_full(DBusList **list, DBusFreeFunction function)
Free every link and every element in the list.
DBusValidity _dbus_message_loader_get_corruption_reason(DBusMessageLoader *loader)
Checks what kind of bad data confused the loader.
dbus_bool_t _dbus_type_writer_write_basic(DBusTypeWriter *writer, int type, const void *value)
Writes out a basic type.
#define DBUS_MESSAGE_TYPE_ERROR
Message type of an error reply message, see dbus_message_get_type()
dbus_bool_t _dbus_message_remove_unknown_fields(DBusMessage *message)
Remove every header field not known to this version of dbus.
DBusList * _dbus_list_alloc_link(void *data)
Allocates a linked list node.
#define DBUS_MAXIMUM_MESSAGE_UNIX_FDS
The maximum total number of unix fds in a message.
const char * dbus_message_get_path(DBusMessage *message)
Gets the object path this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitt...
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
#define DBUS_HEADER_FIELD_CONTAINER_INSTANCE
Header field code for the container instance that sent this message.
#define DBUS_MESSAGE_TYPE_METHOD_RETURN
Message type of a method return message, see dbus_message_get_type()
DBusMessage * dbus_message_new_signal(const char *path, const char *iface, const char *name)
Constructs a new message representing a signal emission.
dbus_bool_t _dbus_string_append_printf_valist(DBusString *str, const char *format, va_list args)
Appends a printf-style formatted string to the DBusString.
int _dbus_dup(int fd, DBusError *error)
Duplicates a file descriptor.
DBusTypeReader reader
reader
DBusValidationMode
This is used rather than a bool for high visibility.
dbus_bool_t dbus_message_iter_has_next(DBusMessageIter *iter)
Checks if an iterator has any more fields.
DBusMessage * message
Message used.
dbus_bool_t _dbus_string_copy(const DBusString *source, int start, DBusString *dest, int insert_at)
Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...
#define DBUS_HEADER_FIELD_INTERFACE
Header field code for the interface containing a member (method or signal).
#define DBUS_DICT_ENTRY_BEGIN_CHAR
Code marking the start of a dict entry type in a type signature.
DBusList * _dbus_list_pop_first_link(DBusList **list)
Removes the first link in the list and returns it.
dbus_bool_t dbus_message_has_member(DBusMessage *message, const char *member)
Checks if the message has an interface member.
DBusValidity
This is primarily used in unit testing, so we can verify that each invalid message is invalid for the...
DBusMessageIter struct; contains no public fields.
dbus_bool_t dbus_message_iter_init(DBusMessage *message, DBusMessageIter *iter)
Initializes a DBusMessageIter for reading the arguments of the message passed in. ...
dbus_bool_t _dbus_message_add_counter(DBusMessage *message, DBusCounter *counter)
Adds a counter to be incremented immediately with the size/unix fds of this message, and decremented by the size/unix fds of this message when this message if finalized.
const char * dbus_message_get_destination(DBusMessage *message)
Gets the destination of a message or NULL if there is none set.
void _dbus_message_add_counter_link(DBusMessage *message, DBusList *link)
Adds a counter to be incremented immediately with the size/unix fds of this message, and decremented by the size/unix fds of this message when this message if finalized.
#define DBUS_TYPE_ARRAY
Type code marking a D-Bus array type.
DBusString * type_str
where to write typecodes (or read type expectations)
void _dbus_type_reader_read_fixed_multi(const DBusTypeReader *reader, const void **value, int *n_elements)
Reads a block of fixed-length basic values, from the current point in an array to the end of the arra...
dbus_bool_t dbus_message_iter_append_fixed_array(DBusMessageIter *iter, int element_type, const void *value, int n_elements)
Appends a block of fixed-length values to an array.
dbus_bool_t dbus_message_set_error_name(DBusMessage *message, const char *error_name)
Sets the name of the error (DBUS_MESSAGE_TYPE_ERROR).
dbus_bool_t _dbus_header_load(DBusHeader *header, DBusValidationMode mode, DBusValidity *validity, int byte_order, int fields_array_len, int header_len, int body_len, const DBusString *str)
Creates a message header from potentially-untrusted data.
const char * dbus_message_get_member(DBusMessage *message)
Gets the interface member being invoked (DBUS_MESSAGE_TYPE_METHOD_CALL) or emitted (DBUS_MESSAGE_TYPE...
dbus_bool_t _dbus_list_remove_last(DBusList **list, void *data)
Removes a value from the list.
Internals of DBusMessage.
Internals of DBusMessageIter.
void _dbus_type_writer_init_values_only(DBusTypeWriter *writer, int byte_order, const DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
Like _dbus_type_writer_init(), except the type string passed in should correspond to an existing sign...
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
#define _DBUS_LOCK_NAME(name)
Expands to name of a global lock variable.
dbus_uint32_t changed_stamp
stamp to detect invalid iters
void _dbus_type_writer_init_types_delayed(DBusTypeWriter *writer, int byte_order, DBusString *value_str, int value_pos)
Initialize a write iterator, with the signature to be provided later.
dbus_bool_t _dbus_string_compact(DBusString *str, int max_waste)
Compacts the string to avoid wasted memory.
int _dbus_header_get_message_type(DBusHeader *header)
Gets the type of the message.
#define DBUS_HEADER_FIELD_ERROR_NAME
Header field code for an error name (found in DBUS_MESSAGE_TYPE_ERROR messages).
#define DBUS_MINIMUM_HEADER_SIZE
The smallest header size that can occur.
dbus_bool_t _dbus_type_writer_unrecurse(DBusTypeWriter *writer, DBusTypeWriter *sub)
Closes a container created by _dbus_type_writer_recurse() and writes any additional information to th...
dbus_bool_t dbus_type_is_basic(int typecode)
A "basic type" is a somewhat arbitrary concept, but the intent is to include those types that are ful...
const char * dbus_message_get_container_instance(DBusMessage *message)
Gets the container instance this message was sent from, or NULL if none.
void _dbus_message_loader_set_max_message_size(DBusMessageLoader *loader, long size)
Sets the maximum size message we allow.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
DBusHeader header
Header network data and associated cache.
dbus_bool_t dbus_message_set_sender(DBusMessage *message, const char *sender)
Sets the message sender.
dbus_bool_t dbus_message_is_signal(DBusMessage *message, const char *iface, const char *signal_name)
Checks whether the message is a signal with the given interface and member fields.
DBusString data
Buffered data.
void _dbus_type_reader_read_basic(const DBusTypeReader *reader, void *value)
Reads a basic-typed value, as with _dbus_marshal_read_basic().
unsigned int locked
Message being sent, no modifications allowed.
#define ensure_byte_order(message)
byte-swap the message if it doesn't match our byte order.
DBusMessageLoader * _dbus_message_loader_ref(DBusMessageLoader *loader)
Increments the reference count of the loader.
dbus_bool_t _dbus_header_get_field_basic(DBusHeader *header, int field, int type, void *value)
Gets the value of a field with basic type.
dbus_bool_t dbus_message_get_path_decomposed(DBusMessage *message, char ***path)
Gets the object path this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitt...
#define DBUS_TYPE_VARIANT_AS_STRING
DBUS_TYPE_VARIANT as a string literal instead of a int literal
can't determine validity due to OOM
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
void _dbus_string_delete(DBusString *str, int start, int len)
Deletes a segment of a DBusString with length len starting at start.
dbus_bool_t _dbus_string_init_preallocated(DBusString *str, int allocate_size)
Initializes a string that can be up to the given allocation size before it has to realloc...
void _dbus_counter_unref(DBusCounter *counter)
Decrements refcount of the counter and possibly finalizes the counter.
dbus_int32_t _dbus_atomic_inc(DBusAtomic *atomic)
Atomically increments an integer.
void _dbus_message_remove_counter(DBusMessage *message, DBusCounter *counter)
Removes a counter tracking the size/unix fds of this message, and decrements the counter by the size/...
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
dbus_bool_t _dbus_decompose_path(const char *data, int len, char ***path, int *path_len)
Decompose an object path.
void * _dbus_memdup(const void *mem, size_t n_bytes)
Duplicates a block of memory.
dbus_bool_t _dbus_data_slot_list_set(DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot, void *data, DBusFreeFunction free_data_func, DBusFreeFunction *old_free_func, void **old_data)
Stores a pointer in the data slot list, along with an optional function to be used for freeing the da...
dbus_bool_t dbus_message_set_path(DBusMessage *message, const char *object_path)
Sets the object path this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or the one a s...
void _dbus_list_foreach(DBusList **list, DBusForeachFunction function, void *data)
Calls the given function for each element in the list.
long max_message_size
Maximum size of a message.
void _dbus_counter_adjust_unix_fd(DBusCounter *counter, long delta)
Adjusts the value of the unix fd counter by the given delta which may be positive or negative...
dbus_bool_t _dbus_type_reader_next(DBusTypeReader *reader)
Skip to the next value on this "level".
DBusList * counters
0-N DBusCounter used to track message size/unix fds.
DBusMessageLoader * _dbus_message_loader_new(void)
Creates a new message loader.
dbus_bool_t dbus_message_set_container_instance(DBusMessage *message, const char *object_path)
Sets the container instance this message was sent from.
long size_counter_delta
Size we incremented the size counters by.
#define CHANGED_STAMP_BITS
How many bits are in the changed_stamp used to validate iterators.
void _dbus_header_byteswap(DBusHeader *header, int new_order)
Swaps the header into the given order if required.
dbus_bool_t _dbus_header_have_message_untrusted(int max_message_length, DBusValidity *validity, int *byte_order, int *fields_array_len, int *header_len, int *body_len, const DBusString *str, int start, int len)
Given data long enough to contain the length of the message body and the fields array, check whether the data is long enough to contain the entire message (assuming the claimed lengths are accurate).
#define DBUS_MESSAGE_TYPE_METHOD_CALL
Message type of a method call message, see dbus_message_get_type()
#define DBUS_HEADER_FIELD_UNIX_FDS
Header field code for the number of unix file descriptors associated with this message.
int _dbus_current_generation
_dbus_current_generation is used to track each time that dbus_shutdown() is called, so we can reinit things after it's been called.
dbus_bool_t dbus_message_get_args(DBusMessage *message, DBusError *error, int first_arg_type,...)
Gets arguments from a message given a variable argument list.
Object representing an exception.
unsigned int in_cache
Has been "freed" since it's in the cache (this is a debug feature)
int dbus_message_iter_get_element_count(DBusMessageIter *iter)
Returns the number of elements in the array-typed value pointed to by the iterator.
void * _dbus_list_pop_first(DBusList **list)
Removes the first value in the list and returns it.
#define DBUS_TYPE_SIGNATURE
Type code marking a D-Bus type signature.
void _dbus_message_loader_set_pending_fds_function(DBusMessageLoader *loader, void(*callback)(void *), void *data)
Register a function to be called whenever the number of pending file descriptors in the loader change...
dbus_bool_t dbus_message_append_args(DBusMessage *message, int first_arg_type,...)
Appends fields to a message given a variable argument list.
#define DBUS_MESSAGE_TYPE_SIGNAL
Message type of a signal message, see dbus_message_get_type()
void dbus_message_iter_init_closed(DBusMessageIter *iter)
Initialize iter as if with DBUS_MESSAGE_ITER_INIT_CLOSED.
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
dbus_uint32_t dbus_message_get_reply_serial(DBusMessage *message)
Returns the serial that the message is a reply to or 0 if none.
#define INITIAL_LOADER_DATA_LEN
The initial buffer size of the message loader.
dbus_bool_t dbus_message_has_signature(DBusMessage *message, const char *signature)
Checks whether the message has the given signature; see dbus_message_get_signature() for more details...
void _dbus_data_slot_list_clear(DBusDataSlotList *list)
Frees all data slots contained in the list, calling application-provided free functions if they exist...
dbus_bool_t _dbus_message_loader_get_is_corrupted(DBusMessageLoader *loader)
Checks whether the loader is confused due to bad data.
#define DBUS_TYPE_VARIANT
Type code marking a D-Bus variant type.
dbus_bool_t _dbus_variant_write(DBusVariant *self, DBusMessageIter *writer)
Copy the single D-Bus message item from self into writer.
#define DBUS_TYPE_UINT32
Type code marking a 32-bit unsigned integer.
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
void _dbus_header_reinit(DBusHeader *header)
Re-initializes a header that was previously initialized and never freed.
DBusMessage * dbus_message_new_method_call(const char *destination, const char *path, const char *iface, const char *method)
Constructs a new message to invoke a method on a remote object.
#define DBUS_HEADER_FIELD_DESTINATION
Header field code for the destination bus name of a message.
dbus_uint32_t byte_order
byte order of the block
dbus_bool_t _dbus_header_delete_field(DBusHeader *header, int field)
Deletes a field, if it exists.
dbus_bool_t dbus_message_has_destination(DBusMessage *message, const char *name)
Checks whether the message was sent to the given name.
#define DBUS_MESSAGE_TYPE_INVALID
This value is never a valid message type, see dbus_message_get_type()
#define DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION
If set on a method call, this flag means that the caller is prepared to wait for interactive authoriz...
dbus_bool_t dbus_message_get_auto_start(DBusMessage *message)
Returns TRUE if the message will cause an owner for destination name to be auto-started.
dbus_uint32_t byte_order
byte order to write values with
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as #_DBUS_STRING_I...
The type reader is an iterator for reading values from a block of values.
void * _dbus_data_slot_list_get(DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot)
Retrieves data previously set with _dbus_data_slot_list_set_data().
long _dbus_message_loader_get_max_message_unix_fds(DBusMessageLoader *loader)
Gets the maximum allowed number of unix fds per message.
#define TRUE
Expands to "1".
dbus_bool_t dbus_message_marshal(DBusMessage *msg, char **marshalled_data_p, int *len_p)
Turn a DBusMessage into the marshalled form as described in the D-Bus specification.
dbus_bool_t _dbus_header_set_field_basic(DBusHeader *header, int field, int type, const void *value)
Sets the value of a field with basic type.
void dbus_message_iter_abandon_container_if_open(DBusMessageIter *iter, DBusMessageIter *sub)
Abandons creation of a contained-typed value and frees resources created by dbus_message_iter_open_co...
void _dbus_data_slot_list_init(DBusDataSlotList *list)
Initializes a slot list.
DBusMessage * dbus_message_copy(const DBusMessage *message)
Creates a new message that is an exact replica of the message specified, except that its refcount is ...
int dbus_message_iter_get_element_type(DBusMessageIter *iter)
Returns the element type of the array that the message iterator points to.
void _dbus_message_get_network_data(DBusMessage *message, const DBusString **header, const DBusString **body)
Gets the data to be sent over the network for this message.
#define DBUS_HEADER_FIELD_MEMBER
Header field code for a member (method or signal).
long max_message_unix_fds
Maximum unix fds in a message.
unsigned int corrupted
We got broken data, and are no longer working.
dbus_bool_t dbus_message_get_args_valist(DBusMessage *message, DBusError *error, int first_arg_type, va_list var_args)
Like dbus_message_get_args but takes a va_list for use by language bindings.
#define DBUS_HEADER_FIELD_SENDER
Header field code for the sender of a message; usually initialized by the message bus...
void _dbus_type_writer_add_types(DBusTypeWriter *writer, DBusString *type_str, int type_pos)
Adds type string to the writer, if it had none.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
#define DBUS_TYPE_OBJECT_PATH
Type code marking a D-Bus object path.
dbus_bool_t dbus_set_error_from_message(DBusError *error, DBusMessage *message)
Sets a DBusError based on the contents of the given message.
DBusMessage * dbus_message_demarshal(const char *str, int len, DBusError *error)
Demarshal a D-Bus message from the format described in the D-Bus specification.
void dbus_message_iter_get_fixed_array(DBusMessageIter *iter, void *value, int *n_elements)
Reads a block of fixed-length values from the message iterator.
#define DBUS_TYPE_UNIX_FD
Type code marking a unix file descriptor.
dbus_bool_t _dbus_header_create(DBusHeader *header, int byte_order, int message_type, const char *destination, const char *path, const char *interface, const char *member, const char *error_name)
Fills in the primary fields of the header, so the header is ready for use.
const char * dbus_message_get_interface(DBusMessage *message)
Gets the interface this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitted...
dbus_bool_t _dbus_type_writer_write_reader(DBusTypeWriter *writer, DBusTypeReader *reader)
Iterate through all values in the given reader, writing a copy of each value to the writer...
An allocator that tracks a set of slot IDs.
#define DBUS_TYPE_INVALID
Type code that is never equal to a legitimate type code.
dbus_bool_t dbus_message_set_reply_serial(DBusMessage *message, dbus_uint32_t reply_serial)
Sets the reply serial of a message (the serial of the message this is a reply to).
DBusVariant * _dbus_variant_read(DBusMessageIter *reader)
Copy a single D-Bus message item from reader into a newly-allocated DBusVariant.
void _dbus_counter_notify(DBusCounter *counter)
Calls the notify function from _dbus_counter_set_notify(), if that function has been specified and th...
dbus_bool_t dbus_message_has_sender(DBusMessage *message, const char *name)
Checks whether the message has the given unique name as its sender.
DBusValidity _dbus_validate_signature_with_reason(const DBusString *type_str, int type_pos, int len)
Verifies that the range of type_str from type_pos to type_end is a valid signature.
dbus_bool_t dbus_message_iter_next(DBusMessageIter *iter)
Moves the iterator to the next field, if any.
_DBUS_STRING_DEFINE_STATIC(_dbus_empty_signature_str,"")
An static string representing an empty signature.
void dbus_message_iter_get_basic(DBusMessageIter *iter, void *value)
Reads a basic-typed value from the message iterator.
void * dbus_message_get_data(DBusMessage *message, dbus_int32_t slot)
Retrieves data previously set with dbus_message_set_data().
void _dbus_type_reader_init(DBusTypeReader *reader, int byte_order, const DBusString *type_str, int type_pos, const DBusString *value_str, int value_pos)
Initializes a type reader.
void _dbus_header_free(DBusHeader *header)
Frees a header.
DBusList * _dbus_message_loader_pop_message_link(DBusMessageLoader *loader)
Pops a loaded message inside a list link (passing ownership of the message and link to the caller)...
#define DBUS_MAXIMUM_ARRAY_LENGTH
Max length of a marshaled array in bytes (64M, 2^26) We use signed int for lengths so must be INT_MAX...
dbus_bool_t dbus_message_set_destination(DBusMessage *message, const char *destination)
Sets the message's destination.
void dbus_error_init(DBusError *error)
Initializes a DBusError structure.
dbus_int32_t _dbus_atomic_dec(DBusAtomic *atomic)
Atomically decrement an integer.
DBusAtomic refcount
Reference count.
dbus_bool_t dbus_message_get_no_reply(DBusMessage *message)
Returns TRUE if the message does not expect a reply.
void dbus_free_string_array(char **str_array)
Frees a NULL-terminated array of strings.
#define DBUS_TYPE_BOOLEAN
Type code marking a boolean.
dbus_bool_t _dbus_string_append_len(DBusString *str, const char *buffer, int len)
Appends block of bytes with the given length to a DBusString.
dbus_uint32_t iter_type
whether this is a reader or writer iter
#define _DBUS_UNLOCK(name)
Unlocks a global lock.
void _dbus_header_set_serial(DBusHeader *header, dbus_uint32_t serial)
Sets the serial number of a header.
int _dbus_type_reader_get_element_type(const DBusTypeReader *reader)
Gets the type of an element of the array the reader is currently pointing to.
char _dbus_header_get_byte_order(const DBusHeader *header)
Returns the header's byte order.
dbus_bool_t dbus_message_iter_open_container(DBusMessageIter *iter, int type, const char *contained_signature, DBusMessageIter *sub)
Appends a container-typed value to the message.
dbus_bool_t _dbus_type_reader_has_next(const DBusTypeReader *reader)
Check whether there's another value on this "level".
A simple value union that lets you access bytes as if they were various types; useful when dealing wi...
dbus_uint32_t container_type
what are we inside? (e.g.
int _dbus_type_reader_get_array_length(const DBusTypeReader *reader)
Returns the number of bytes in the array.
dbus_bool_t _dbus_header_get_field_raw(DBusHeader *header, int field, const DBusString **str, int *pos)
Gets the raw marshaled data for a field.
dbus_bool_t dbus_message_iter_append_basic(DBusMessageIter *iter, int type, const void *value)
Appends a basic-typed value to the message.
dbus_bool_t _dbus_close(int fd, DBusError *error)
Closes a file descriptor.
int dbus_message_iter_get_array_len(DBusMessageIter *iter)
Returns the number of bytes in the array as marshaled in the wire protocol.
int _dbus_type_reader_get_current_type(const DBusTypeReader *reader)
Gets the type of the value the reader is currently pointing to; or for a types-only reader gets the t...
#define FALSE
Expands to "0".
void dbus_message_set_allow_interactive_authorization(DBusMessage *message, dbus_bool_t allow)
Sets a flag indicating that the caller of the method is prepared to wait for interactive authorizatio...
#define DBUS_HEADER_FIELD_PATH
Header field code for the path - the path is the object emitting a signal or the object receiving a m...
int dbus_message_get_type(DBusMessage *message)
Gets the type of a message.
#define DBUS_HEADER_FIELD_REPLY_SERIAL
Header field code for a reply serial, used to match a DBUS_MESSAGE_TYPE_METHOD_RETURN message with th...
unsigned int buffer_outstanding
Someone is using the buffer to read.
int generation
_dbus_current_generation when message was created
void _dbus_list_prepend_link(DBusList **list, DBusList *link)
Prepends a link to the list.
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a string.
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_register_shutdown_func(DBusShutdownFunction function, void *data)
Register a cleanup function to be called exactly once the next time dbus_shutdown() is called...
const char * _dbus_type_to_string(int typecode)
Returns a string describing the given type.
DBusMessage * _dbus_message_loader_peek_message(DBusMessageLoader *loader)
Peeks at first loaded message, returns NULL if no messages have been queued.
dbus_bool_t _dbus_string_copy_len(const DBusString *source, int start, int len, DBusString *dest, int insert_at)
Like _dbus_string_copy(), but can copy a segment from the middle of the source string.
dbus_bool_t _dbus_string_steal_data(DBusString *str, char **data_return)
Like _dbus_string_get_data(), but removes the gotten data from the original string.
void _dbus_message_loader_get_buffer(DBusMessageLoader *loader, DBusString **buffer, int *max_to_read, dbus_bool_t *may_read_fds)
Gets the buffer to use for reading data from the network.
void _dbus_type_reader_get_signature(const DBusTypeReader *reader, const DBusString **str_p, int *start_p, int *len_p)
Gets the string and range of said string containing the signature of the current value.
dbus_bool_t dbus_message_append_args_valist(DBusMessage *message, int first_arg_type, va_list var_args)
Like dbus_message_append_args() but takes a va_list for use by language bindings. ...
int dbus_message_demarshal_bytes_needed(const char *buf, int len)
Returns the number of bytes required to be in the buffer to demarshal a D-Bus message.
dbus_int32_t _dbus_atomic_get(DBusAtomic *atomic)
Atomically get the value of an integer.
char * dbus_message_iter_get_signature(DBusMessageIter *iter)
Returns the current signature of a message iterator.
dbus_bool_t _dbus_type_writer_write_fixed_multi(DBusTypeWriter *writer, int element_type, const void *value, int n_elements)
Writes a block of fixed-length basic values, i.e.
void dbus_message_iter_abandon_container(DBusMessageIter *iter, DBusMessageIter *sub)
Abandons creation of a contained-typed value and frees resources created by dbus_message_iter_open_co...
DBUS_PRIVATE_EXPORT void _dbus_verbose_bytes_of_string(const DBusString *str, int start, int len)
Dump the given part of the string to verbose log.
dbus_bool_t _dbus_data_slot_allocator_alloc(DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p)
Allocates an integer ID to be used for storing data in a DBusDataSlotList.
dbus_bool_t dbus_message_contains_unix_fds(DBusMessage *message)
Checks whether a message contains unix fds.
#define DBUS_HEADER_FLAG_NO_AUTO_START
If set, this flag means that even if the message bus knows how to start an owner for the destination ...
dbus_bool_t _dbus_message_loader_queue_messages(DBusMessageLoader *loader)
Converts buffered data into messages, if we have enough data.
void * dbus_realloc(void *memory, size_t bytes)
Resizes a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
void _dbus_message_get_unix_fds(DBusMessage *message, const int **fds, unsigned *n_fds)
Gets the unix fds to be sent over the network for this message.
int refcount
Reference count.
int dbus_int32_t
A 32-bit signed integer on all platforms.
char * _dbus_strdup(const char *str)
Duplicates a string.
#define _DBUS_ZERO(object)
Sets all bits in an object to zero.
#define MAX_MESSAGE_SIZE_TO_CACHE
Avoid caching huge messages.
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
#define DBUS_ERROR_INVALID_ARGS
Invalid arguments passed to a method call.
void _dbus_data_slot_allocator_free(DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p)
Deallocates an ID previously allocated with _dbus_data_slot_allocator_alloc().
int _dbus_type_get_alignment(int typecode)
Gets the alignment requirement for the given type; will be 1, 2, 4, or 8.
DBusValidity corruption_reason
why we were corrupted
void _dbus_message_loader_set_max_message_unix_fds(DBusMessageLoader *loader, long n)
Sets the maximum unix fds per message we allow.
dbus_bool_t dbus_message_set_member(DBusMessage *message, const char *member)
Sets the interface member being invoked (DBUS_MESSAGE_TYPE_METHOD_CALL) or emitted (DBUS_MESSAGE_TYPE...
const char * dbus_message_type_to_string(int type)
Utility function to convert a D-Bus message type into a machine-readable string (not translated)...
void dbus_message_unref(DBusMessage *message)
Decrements the reference count of a DBusMessage, freeing the message if the count reaches 0...
void _dbus_string_init_const_len(DBusString *str, const char *value, int len)
Initializes a constant string with a length.
Implementation details of DBusMessageLoader.
#define _DBUS_LOCK(name)
Locks a global lock, initializing it first if necessary.
dbus_bool_t _dbus_type_writer_recurse(DBusTypeWriter *writer, int container_type, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
Opens a new container and writes out the initial information for that container.
dbus_uint32_t u32
as int32
DBusMessage * dbus_message_new_error_printf(DBusMessage *reply_to, const char *error_name, const char *error_format,...)
Creates a new message that is an error reply to another message, allowing you to use printf formattin...
dbus_bool_t dbus_message_set_data(DBusMessage *message, dbus_int32_t slot, void *data, DBusFreeFunction free_data_func)
Stores a pointer on a DBusMessage, along with an optional function to be used for freeing the data wh...
void dbus_message_set_serial(DBusMessage *message, dbus_uint32_t serial)
Sets the serial number of a message.
void _dbus_header_toggle_flag(DBusHeader *header, dbus_uint32_t flag, dbus_bool_t value)
Toggles a message flag bit, turning on the bit if value = TRUE and flipping it off if value = FALSE...
void _dbus_header_update_lengths(DBusHeader *header, int body_len)
Fills in the correct body length.
DBusMessage * dbus_message_new_method_return(DBusMessage *method_call)
Constructs a message that is a reply to a method call.
DBusTypeWriter writer
writer
void _dbus_data_slot_list_free(DBusDataSlotList *list)
Frees the data slot list and all data slots contained in it, calling application-provided free functi...
#define DBUS_MAXIMUM_MESSAGE_LENGTH
The maximum total message size including header and body; similar rationale to max array size...
DBusDataSlotList slot_list
Data stored by allocated integer ID.
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.
void _dbus_marshal_byteswap(const DBusString *signature, int signature_start, int old_byte_order, int new_byte_order, DBusString *value_str, int value_pos)
Byteswaps the marshaled data in the given value_str.
int _dbus_message_loader_get_pending_fds_count(DBusMessageLoader *loader)
Return how many file descriptors are pending in the loader.
dbus_bool_t dbus_type_is_container(int typecode)
A "container type" can contain basic types, or nested container types.
DBusMessage * dbus_message_new_error(DBusMessage *reply_to, const char *error_name, const char *error_message)
Creates a new message that is an error reply to another message.
void _dbus_counter_adjust_size(DBusCounter *counter, long delta)
Adjusts the value of the size counter by the given delta which may be positive or negative...