index.html
Main Page
|
modules.html
Modules
|
namespaces.html
Namespace List
|
hierarchy.html
Class Hierarchy
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
namespacemembers.html
Namespace Members
|
functions.html
Data Fields
|
pages.html
Related Pages
dir_000004.html
dbus
dbus-message.c
00001
/* -*- mode: C; c-file-style: "gnu" -*- */
00002
/* dbus-message.c  DBusMessage object
00003
*
00004
* Copyright (C) 2002, 2003, 2004, 2005  Red Hat Inc.
00005
* Copyright (C) 2002, 2003  CodeFactory AB
00006
*
00007
* Licensed under the Academic Free License version 2.1
00008
*
00009
* This program is free software; you can redistribute it and/or modify
00010
* it under the terms of the GNU General Public License as published by
00011
* the Free Software Foundation; either version 2 of the License, or
00012
* (at your option) any later version.
00013
*
00014
* This program is distributed in the hope that it will be useful,
00015
* but WITHOUT ANY WARRANTY; without even the implied warranty of
00016
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017
* GNU General Public License for more details.
00018
*
00019
* You should have received a copy of the GNU General Public License
00020
* along with this program; if not, write to the Free Software
00021
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022
*
00023
*/
00024
00025
#include "dbus-internals.h"
00026
#include "dbus-marshal-recursive.h"
00027
#include "dbus-marshal-validate.h"
00028
#include "dbus-marshal-byteswap.h"
00029
#include "dbus-marshal-header.h"
00030
#include "dbus-signature.h"
00031
#include "dbus-message-private.h"
00032
#include "dbus-object-tree.h"
00033
#include "dbus-memory.h"
00034
#include "dbus-list.h"
00035
#include "dbus-threads-internal.h"
00036
#include <string.h>
00037
00048
/* Not thread locked, but strictly const/read-only so should be OK
00049
*/
00051
group__DBusMarshal.html#ga50
_DBUS_STRING_DEFINE_STATIC
(_dbus_empty_signature_str,
""
);
00052
00053
/* these have wacky values to help trap uninitialized iterators;
00054
* but has to fit in 3 bits
00055
*/
00056
enum
{
00057   DBUS_MESSAGE_ITER_TYPE_READER = 3,
00058   DBUS_MESSAGE_ITER_TYPE_WRITER = 7
00059 };
00060
group__DBusMessageInternals.html#ga0
00062
typedef
struct
structDBusMessageRealIter.html
DBusMessageRealIter
DBusMessageRealIter;
00063
structDBusMessageRealIter.html
00069
struct
DBusMessageRealIter
00070 {
structDBusMessageRealIter.html#o0
00071
structDBusMessage.html
DBusMessage
*
structDBusMessageRealIter.html#o0
message
;
structDBusMessageRealIter.html#o1
00072
group__DBusTypes.html#ga3
dbus_uint32_t
structDBusMessageRealIter.html#o1
changed_stamp
:
group__DBusMessageInternals.html#ga33
CHANGED_STAMP_BITS
;
structDBusMessageRealIter.html#o2
00073
group__DBusTypes.html#ga3
dbus_uint32_t
structDBusMessageRealIter.html#o2
iter_type
: 3;
structDBusMessageRealIter.html#o3
00074
group__DBusTypes.html#ga3
dbus_uint32_t
structDBusMessageRealIter.html#o3
sig_refcount
: 8;
00075
union
00076
{
structDBusMessageRealIter.html#o4
00077
structDBusTypeWriter.html
DBusTypeWriter
structDBusMessageRealIter.html#o4
writer
;
structDBusMessageRealIter.html#o5
00078
structDBusTypeReader.html
DBusTypeReader
structDBusMessageRealIter.html#o5
reader
;
00079   }
structDBusMessageRealIter.html#o6
u
;
00080 };
00081
00082
static
void
00083 get_const_signature (
structDBusHeader.html
DBusHeader
*header,
00084
const
structDBusString.html
DBusString
**type_str_p,
00085
int
*type_pos_p)
00086 {
00087
if
(
group__DBusMarshal.html#ga78
_dbus_header_get_field_raw
(header,
00088                                   DBUS_HEADER_FIELD_SIGNATURE,
00089                                   type_str_p,
00090                                   type_pos_p))
00091     {
00092       *type_pos_p += 1;
/* skip the signature length which is 1 byte */
00093     }
00094
else
00095     {
00096       *type_str_p = &_dbus_empty_signature_str;
00097       *type_pos_p = 0;
00098     }
00099 }
00100
00106
static
void
00107 _dbus_message_byteswap (
structDBusMessage.html
DBusMessage
*message)
00108 {
00109
const
structDBusString.html
DBusString
*type_str;
00110
int
type_pos;
00111
00112
if
(message->
structDBusMessage.html#o3
byte_order
== DBUS_COMPILER_BYTE_ORDER)
00113
return
;
00114
00115   _dbus_verbose (
"Swapping message into compiler byte order\n"
);
00116
00117   get_const_signature (&message->
structDBusMessage.html#o1
header
, &type_str, &type_pos);
00118
00119
group__DBusMarshal.html#ga49
_dbus_marshal_byteswap
(type_str, type_pos,
00120                           message->
structDBusMessage.html#o3
byte_order
,
00121                           DBUS_COMPILER_BYTE_ORDER,
00122                           &message->
structDBusMessage.html#o2
body
, 0);
00123
00124   message->
structDBusMessage.html#o3
byte_order
= DBUS_COMPILER_BYTE_ORDER;
00125
00126
group__DBusMarshal.html#ga82
_dbus_header_byteswap
(&message->
structDBusMessage.html#o1
header
, DBUS_COMPILER_BYTE_ORDER);
00127 }
00128
group__DBusMessageInternals.html#ga34
00129
#define ensure_byte_order(message)                      \
00130
if (message->byte_order != DBUS_COMPILER_BYTE_ORDER)   \
00131
_dbus_message_byteswap (message)
00132
00143
void
group__DBusMessageInternals.html#ga6
00144
group__DBusMessageInternals.html#ga6
_dbus_message_get_network_data
(
structDBusMessage.html
DBusMessage
*message,
00145
const
structDBusString.html
DBusString
**header,
00146
const
structDBusString.html
DBusString
**body)
00147 {
00148
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message->
structDBusMessage.html#o4
locked
);
00149
00150   *header = &message->
structDBusMessage.html#o1
header
.
structDBusHeader.html#o0
data
;
00151   *body = &message->
structDBusMessage.html#o2
body
;
00152 }
00153
00161
void
group__DBusMessageInternals.html#ga7
00162
group__DBusMessageInternals.html#ga7
_dbus_message_set_serial
(
structDBusMessage.html
DBusMessage
*message,
00163
group__DBusTypes.html#ga3
dbus_uint32_t
serial)
00164 {
00165
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message !=
group__DBusMacros.html#ga4
NULL
);
00166
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!message->
structDBusMessage.html#o4
locked
);
00167
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusMessage.html#ga3
dbus_message_get_serial
(message) == 0);
00168
00169
group__DBusMarshal.html#ga63
_dbus_header_set_serial
(&message->header, serial);
00170 }
00171
00184
void
group__DBusMessageInternals.html#ga8
00185
group__DBusMessageInternals.html#ga8
_dbus_message_add_size_counter_link
(
structDBusMessage.html
DBusMessage
*message,
00186
structDBusList.html
DBusList
*link)
00187 {
00188
/* right now we don't recompute the delta when message
00189
* size changes, and that's OK for current purposes
00190
* I think, but could be important to change later.
00191
* Do recompute it whenever there are no outstanding counters,
00192
* since it's basically free.
00193
*/
00194
if
(message->
structDBusMessage.html#o6
size_counters
==
group__DBusMacros.html#ga4
NULL
)
00195     {
00196       message->
structDBusMessage.html#o7
size_counter_delta
=
00197         _dbus_string_get_length (&message->
structDBusMessage.html#o1
header
.
structDBusHeader.html#o0
data
) +
00198         _dbus_string_get_length (&message->
structDBusMessage.html#o2
body
);
00199
00200
#if 0
00201
_dbus_verbose (
"message has size %ld\n"
,
00202                      message->
structDBusMessage.html#o7
size_counter_delta
);
00203
#endif
00204
}
00205
00206
group__DBusList.html#ga4
_dbus_list_append_link
(&message->
structDBusMessage.html#o6
size_counters
, link);
00207
00208
group__DBusResources.html#ga3
_dbus_counter_adjust
(link->
structDBusList.html#o2
data
, message->
structDBusMessage.html#o7
size_counter_delta
);
00209 }
00210
00220
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessageInternals.html#ga9
00221
group__DBusMessageInternals.html#ga9
_dbus_message_add_size_counter
(
structDBusMessage.html
DBusMessage
*message,
00222
structDBusCounter.html
DBusCounter
*counter)
00223 {
00224
structDBusList.html
DBusList
*link;
00225
00226   link =
group__DBusList.html#ga0
_dbus_list_alloc_link
(counter);
00227
if
(link ==
group__DBusMacros.html#ga4
NULL
)
00228
return
group__DBusMacros.html#ga3
FALSE
;
00229
00230
group__DBusResources.html#ga1
_dbus_counter_ref
(counter);
00231
group__DBusMessageInternals.html#ga8
_dbus_message_add_size_counter_link
(message, link);
00232
00233
return
group__DBusMacros.html#ga2
TRUE
;
00234 }
00235
00244
void
group__DBusMessageInternals.html#ga10
00245
group__DBusMessageInternals.html#ga10
_dbus_message_remove_size_counter
(
structDBusMessage.html
DBusMessage
*message,
00246
structDBusCounter.html
DBusCounter
*counter,
00247
structDBusList.html
DBusList
**link_return)
00248 {
00249
structDBusList.html
DBusList
*link;
00250
00251   link =
group__DBusList.html#ga9
_dbus_list_find_last
(&message->
structDBusMessage.html#o6
size_counters
,
00252                                counter);
00253
group__DBusInternalsUtils.html#ga130
_dbus_assert
(link !=
group__DBusMacros.html#ga4
NULL
);
00254
00255
group__DBusList.html#ga10
_dbus_list_unlink
(&message->
structDBusMessage.html#o6
size_counters
,
00256                      link);
00257
if
(link_return)
00258     *link_return = link;
00259
else
00260
group__DBusList.html#ga1
_dbus_list_free_link
(link);
00261
00262
group__DBusResources.html#ga3
_dbus_counter_adjust
(counter, - message->
structDBusMessage.html#o7
size_counter_delta
);
00263
00264
group__DBusResources.html#ga2
_dbus_counter_unref
(counter);
00265 }
00266
00276
void
group__DBusMessageInternals.html#ga11
00277
group__DBusMessageInternals.html#ga11
_dbus_message_lock
(
structDBusMessage.html
DBusMessage
*message)
00278 {
00279
if
(!message->
structDBusMessage.html#o4
locked
)
00280     {
00281
group__DBusMarshal.html#ga74
_dbus_header_update_lengths
(&message->
structDBusMessage.html#o1
header
,
00282                                    _dbus_string_get_length (&message->
structDBusMessage.html#o2
body
));
00283
00284
/* must have a signature if you have a body */
00285
group__DBusInternalsUtils.html#ga130
_dbus_assert
(_dbus_string_get_length (&message->
structDBusMessage.html#o2
body
) == 0 ||
00286
group__DBusMessage.html#ga67
dbus_message_get_signature
(message) !=
group__DBusMacros.html#ga4
NULL
);
00287
00288       message->
structDBusMessage.html#o4
locked
=
group__DBusMacros.html#ga2
TRUE
;
00289     }
00290 }
00291
00292
static
group__DBusTypes.html#ga2
dbus_bool_t
00293 set_or_delete_string_field (
structDBusMessage.html
DBusMessage
*message,
00294
int
field,
00295
int
typecode,
00296
const
char
*value)
00297 {
00298
if
(value ==
group__DBusMacros.html#ga4
NULL
)
00299
return
group__DBusMarshal.html#ga79
_dbus_header_delete_field
(&message->
structDBusMessage.html#o1
header
, field);
00300
else
00301
return
group__DBusMarshal.html#ga76
_dbus_header_set_field_basic
(&message->
structDBusMessage.html#o1
header
,
00302                                          field,
00303                                          typecode,
00304                                          &value);
00305 }
00306
00307
#if 0
00308
/* Probably we don't need to use this */
00332
static
group__DBusTypes.html#ga2
dbus_bool_t
00333 _dbus_message_set_signature (
structDBusMessage.html
DBusMessage
*message,
00334
const
char
*signature)
00335 {
00336   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
00337   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o4
locked
,
group__DBusMacros.html#ga3
FALSE
);
00338   _dbus_return_val_if_fail (signature ==
group__DBusMacros.html#ga4
NULL
||
00339                             _dbus_check_is_valid_signature (signature));
00340
/* can't delete the signature if you have a message body */
00341   _dbus_return_val_if_fail (_dbus_string_get_length (&message->
structDBusMessage.html#o2
body
) == 0 ||
00342                             signature !=
group__DBusMacros.html#ga4
NULL
);
00343
00344
return
set_or_delete_string_field (message,
00345                                      DBUS_HEADER_FIELD_SIGNATURE,
00346                                      DBUS_TYPE_SIGNATURE,
00347                                      signature);
00348 }
00349
#endif
00350
00383
group__DBusTypes.html#ga3
dbus_uint32_t
group__DBusMessage.html#ga3
00384
group__DBusMessage.html#ga3
dbus_message_get_serial
(
structDBusMessage.html
DBusMessage
*message)
00385 {
00386   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
, 0);
00387
00388
return
group__DBusMarshal.html#ga64
_dbus_header_get_serial
(&message->
structDBusMessage.html#o1
header
);
00389 }
00390
00399
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga4
00400
group__DBusMessage.html#ga4
dbus_message_set_reply_serial
(
structDBusMessage.html
DBusMessage
*message,
00401
group__DBusTypes.html#ga3
dbus_uint32_t
reply_serial)
00402 {
00403   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
00404   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o4
locked
,
group__DBusMacros.html#ga3
FALSE
);
00405
00406
return
group__DBusMarshal.html#ga76
_dbus_header_set_field_basic
(&message->
structDBusMessage.html#o1
header
,
00407                                        DBUS_HEADER_FIELD_REPLY_SERIAL,
00408                                        DBUS_TYPE_UINT32,
00409                                        &reply_serial);
00410 }
00411
00418
group__DBusTypes.html#ga3
dbus_uint32_t
group__DBusMessage.html#ga5
00419
group__DBusMessage.html#ga5
dbus_message_get_reply_serial
(
structDBusMessage.html
DBusMessage
*message)
00420 {
00421
group__DBusTypes.html#ga3
dbus_uint32_t
v_UINT32;
00422
00423   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
, 0);
00424
00425
if
(
group__DBusMarshal.html#ga77
_dbus_header_get_field_basic
(&message->
structDBusMessage.html#o1
header
,
00426                                     DBUS_HEADER_FIELD_REPLY_SERIAL,
00427                                     DBUS_TYPE_UINT32,
00428                                     &v_UINT32))
00429
return
v_UINT32;
00430
else
00431
return
0;
00432 }
00433
00434
static
void
00435 free_size_counter (
void
*element,
00436
void
*data)
00437 {
00438
structDBusCounter.html
DBusCounter
*counter = element;
00439
structDBusMessage.html
DBusMessage
*message = data;
00440
00441
group__DBusResources.html#ga3
_dbus_counter_adjust
(counter, - message->
structDBusMessage.html#o7
size_counter_delta
);
00442
00443
group__DBusResources.html#ga2
_dbus_counter_unref
(counter);
00444 }
00445
00446
static
void
00447 dbus_message_finalize (
structDBusMessage.html
DBusMessage
*message)
00448 {
00449
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message->
structDBusMessage.html#o0
refcount
.
structDBusAtomic.html#o0
value
== 0);
00450
00451
/* This calls application callbacks! */
00452
group__DBusDataSlot.html#ga7
_dbus_data_slot_list_free
(&message->
structDBusMessage.html#o9
slot_list
);
00453
00454
group__DBusList.html#ga22
_dbus_list_foreach
(&message->
structDBusMessage.html#o6
size_counters
,
00455                       free_size_counter, message);
00456
group__DBusList.html#ga12
_dbus_list_clear
(&message->
structDBusMessage.html#o6
size_counters
);
00457
00458
group__DBusMarshal.html#ga67
_dbus_header_free
(&message->
structDBusMessage.html#o1
header
);
00459
group__DBusString.html#ga9
_dbus_string_free
(&message->
structDBusMessage.html#o2
body
);
00460
00461
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message->
structDBusMessage.html#o0
refcount
.
structDBusAtomic.html#o0
value
== 0);
00462
00463
group__DBusMemory.html#ga3
dbus_free
(message);
00464 }
00465
00466
/* Message Cache
00467
*
00468
* We cache some DBusMessage to reduce the overhead of allocating
00469
* them.  In my profiling this consistently made about an 8%
00470
* difference.  It avoids the malloc for the message, the malloc for
00471
* the slot list, the malloc for the header string and body string,
00472
* and the associated free() calls. It does introduce another global
00473
* lock which could be a performance issue in certain cases.
00474
*
00475
* For the echo client/server the round trip time goes from around
00476
* .000077 to .000069 with the message cache on my laptop. The sysprof
00477
* change is as follows (numbers are cumulative percentage):
00478
*
00479
*  with message cache implemented as array as it is now (0.000069 per):
00480
*    new_empty_header           1.46
00481
*      mutex_lock               0.56    # i.e. _DBUS_LOCK(message_cache)
00482
*      mutex_unlock             0.25
00483
*      self                     0.41
00484
*    unref                      2.24
00485
*      self                     0.68
00486
*      list_clear               0.43
00487
*      mutex_lock               0.33    # i.e. _DBUS_LOCK(message_cache)
00488
*      mutex_unlock             0.25
00489
*
00490
*  with message cache implemented as list (0.000070 per roundtrip):
00491
*    new_empty_header           2.72
00492
*      list_pop_first           1.88
00493
*    unref                      3.3
00494
*      list_prepend             1.63
00495
*
00496
* without cache (0.000077 per roundtrip):
00497
*    new_empty_header           6.7
00498
*      string_init_preallocated 3.43
00499
*        dbus_malloc            2.43
00500
*      dbus_malloc0             2.59
00501
*
00502
*    unref                      4.02
00503
*      string_free              1.82
00504
*        dbus_free              1.63
00505
*      dbus_free                0.71
00506
*
00507
* If you implement the message_cache with a list, the primary reason
00508
* it's slower is that you add another thread lock (on the DBusList
00509
* mempool).
00510
*/
00511
group__DBusMessage.html#ga76
00513
#define MAX_MESSAGE_SIZE_TO_CACHE _DBUS_ONE_MEGABYTE
00514
group__DBusMessage.html#ga77
00516
#define MAX_MESSAGE_CACHE_SIZE    5
00517
00518
group__DBusInternalsUtils.html#ga146
_DBUS_DEFINE_GLOBAL_LOCK
(message_cache);
00519
static
structDBusMessage.html
DBusMessage
*message_cache[
group__DBusMessage.html#ga77
MAX_MESSAGE_CACHE_SIZE
];
00520
static
int
message_cache_count = 0;
00521
static
group__DBusTypes.html#ga2
dbus_bool_t
message_cache_shutdown_registered =
group__DBusMacros.html#ga3
FALSE
;
00522
00523
static
void
00524 dbus_message_cache_shutdown (
void
*data)
00525 {
00526
int
i;
00527
00528
group__DBusInternalsUtils.html#ga148
_DBUS_LOCK
(message_cache);
00529
00530   i = 0;
00531
while
(i <
group__DBusMessage.html#ga77
MAX_MESSAGE_CACHE_SIZE
)
00532     {
00533
if
(message_cache[i])
00534         dbus_message_finalize (message_cache[i]);
00535
00536       ++i;
00537     }
00538
00539   message_cache_count = 0;
00540   message_cache_shutdown_registered =
group__DBusMacros.html#ga3
FALSE
;
00541
00542
group__DBusInternalsUtils.html#ga149
_DBUS_UNLOCK
(message_cache);
00543 }
00544
00552
static
structDBusMessage.html
DBusMessage
*
00553 dbus_message_get_cached (
void
)
00554 {
00555
structDBusMessage.html
DBusMessage
*message;
00556
int
i;
00557
00558   message =
group__DBusMacros.html#ga4
NULL
;
00559
00560
group__DBusInternalsUtils.html#ga148
_DBUS_LOCK
(message_cache);
00561
00562
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message_cache_count >= 0);
00563
00564
if
(message_cache_count == 0)
00565     {
00566
group__DBusInternalsUtils.html#ga149
_DBUS_UNLOCK
(message_cache);
00567
return
group__DBusMacros.html#ga4
NULL
;
00568     }
00569
00570
/* This is not necessarily true unless count > 0, and
00571
* message_cache is uninitialized until the shutdown is
00572
* registered
00573
*/
00574
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message_cache_shutdown_registered);
00575
00576   i = 0;
00577
while
(i <
group__DBusMessage.html#ga77
MAX_MESSAGE_CACHE_SIZE
)
00578     {
00579
if
(message_cache[i])
00580         {
00581           message = message_cache[i];
00582           message_cache[i] =
group__DBusMacros.html#ga4
NULL
;
00583           message_cache_count -= 1;
00584
break
;
00585         }
00586       ++i;
00587     }
00588
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message_cache_count >= 0);
00589
group__DBusInternalsUtils.html#ga130
_dbus_assert
(i <
group__DBusMessage.html#ga77
MAX_MESSAGE_CACHE_SIZE
);
00590
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message !=
group__DBusMacros.html#ga4
NULL
);
00591
00592
group__DBusInternalsUtils.html#ga149
_DBUS_UNLOCK
(message_cache);
00593
00594
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message->
structDBusMessage.html#o0
refcount
.
structDBusAtomic.html#o0
value
== 0);
00595
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message->
structDBusMessage.html#o6
size_counters
==
group__DBusMacros.html#ga4
NULL
);
00596
00597
return
message;
00598 }
00599
00605
static
void
00606 dbus_message_cache_or_finalize (
structDBusMessage.html
DBusMessage
*message)
00607 {
00608
group__DBusTypes.html#ga2
dbus_bool_t
was_cached;
00609
int
i;
00610
00611
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message->
structDBusMessage.html#o0
refcount
.
structDBusAtomic.html#o0
value
== 0);
00612
00613
/* This calls application code and has to be done first thing
00614
* without holding the lock
00615
*/
00616
group__DBusDataSlot.html#ga6
_dbus_data_slot_list_clear
(&message->
structDBusMessage.html#o9
slot_list
);
00617
00618
group__DBusList.html#ga22
_dbus_list_foreach
(&message->
structDBusMessage.html#o6
size_counters
,
00619                       free_size_counter, message);
00620
group__DBusList.html#ga12
_dbus_list_clear
(&message->
structDBusMessage.html#o6
size_counters
);
00621
00622   was_cached =
group__DBusMacros.html#ga3
FALSE
;
00623
00624
group__DBusInternalsUtils.html#ga148
_DBUS_LOCK
(message_cache);
00625
00626
if
(!message_cache_shutdown_registered)
00627     {
00628
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message_cache_count == 0);
00629
00630
if
(!
group__DBusMemoryInternals.html#ga3
_dbus_register_shutdown_func
(dbus_message_cache_shutdown,
group__DBusMacros.html#ga4
NULL
))
00631
goto
out;
00632
00633       i = 0;
00634
while
(i <
group__DBusMessage.html#ga77
MAX_MESSAGE_CACHE_SIZE
)
00635         {
00636           message_cache[i] =
group__DBusMacros.html#ga4
NULL
;
00637           ++i;
00638         }
00639
00640       message_cache_shutdown_registered =
group__DBusMacros.html#ga2
TRUE
;
00641     }
00642
00643
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message_cache_count >= 0);
00644
00645
if
((_dbus_string_get_length (&message->
structDBusMessage.html#o1
header
.
structDBusHeader.html#o0
data
) +
00646        _dbus_string_get_length (&message->
structDBusMessage.html#o2
body
)) >
00647
group__DBusMessage.html#ga76
MAX_MESSAGE_SIZE_TO_CACHE
)
00648
goto
out;
00649
00650
if
(message_cache_count >=
group__DBusMessage.html#ga77
MAX_MESSAGE_CACHE_SIZE
)
00651
goto
out;
00652
00653
/* Find empty slot */
00654   i = 0;
00655
while
(message_cache[i] !=
group__DBusMacros.html#ga4
NULL
)
00656     ++i;
00657
00658
group__DBusInternalsUtils.html#ga130
_dbus_assert
(i <
group__DBusMessage.html#ga77
MAX_MESSAGE_CACHE_SIZE
);
00659
00660
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message_cache[i] ==
group__DBusMacros.html#ga4
NULL
);
00661   message_cache[i] = message;
00662   message_cache_count += 1;
00663   was_cached =
group__DBusMacros.html#ga2
TRUE
;
00664
#ifndef DBUS_DISABLE_CHECKS
00665
message->
structDBusMessage.html#o5
in_cache
=
group__DBusMacros.html#ga2
TRUE
;
00666
#endif
00667
00668  out:
00669
group__DBusInternalsUtils.html#ga149
_DBUS_UNLOCK
(message_cache);
00670
00671
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message->
structDBusMessage.html#o0
refcount
.
structDBusAtomic.html#o0
value
== 0);
00672
00673
if
(!was_cached)
00674     dbus_message_finalize (message);
00675 }
00676
00677
static
structDBusMessage.html
DBusMessage
*
00678 dbus_message_new_empty_header (
void
)
00679 {
00680
structDBusMessage.html
DBusMessage
*message;
00681
group__DBusTypes.html#ga2
dbus_bool_t
from_cache;
00682
00683   message = dbus_message_get_cached ();
00684
00685
if
(message !=
group__DBusMacros.html#ga4
NULL
)
00686     {
00687       from_cache =
group__DBusMacros.html#ga2
TRUE
;
00688     }
00689
else
00690     {
00691       from_cache =
group__DBusMacros.html#ga3
FALSE
;
00692       message =
group__DBusMemory.html#ga6
dbus_new
(
structDBusMessage.html
DBusMessage
, 1);
00693
if
(message ==
group__DBusMacros.html#ga4
NULL
)
00694
return
group__DBusMacros.html#ga4
NULL
;
00695
#ifndef DBUS_DISABLE_CHECKS
00696
message->
structDBusMessage.html#o10
generation
=
group__DBusMemoryInternals.html#ga0
_dbus_current_generation
;
00697
#endif
00698
}
00699
00700   message->
structDBusMessage.html#o0
refcount
.
structDBusAtomic.html#o0
value
= 1;
00701   message->
structDBusMessage.html#o3
byte_order
= DBUS_COMPILER_BYTE_ORDER;
00702   message->
structDBusMessage.html#o4
locked
=
group__DBusMacros.html#ga3
FALSE
;
00703
#ifndef DBUS_DISABLE_CHECKS
00704
message->
structDBusMessage.html#o5
in_cache
=
group__DBusMacros.html#ga3
FALSE
;
00705
#endif
00706
message->
structDBusMessage.html#o6
size_counters
=
group__DBusMacros.html#ga4
NULL
;
00707   message->
structDBusMessage.html#o7
size_counter_delta
= 0;
00708   message->
structDBusMessage.html#o8
changed_stamp
= 0;
00709
00710
if
(!from_cache)
00711
group__DBusDataSlot.html#ga3
_dbus_data_slot_list_init
(&message->
structDBusMessage.html#o9
slot_list
);
00712
00713
if
(from_cache)
00714     {
00715
group__DBusMarshal.html#ga65
_dbus_header_reinit
(&message->
structDBusMessage.html#o1
header
, message->
structDBusMessage.html#o3
byte_order
);
00716
group__DBusString.html#ga21
_dbus_string_set_length
(&message->
structDBusMessage.html#o2
body
, 0);
00717     }
00718
else
00719     {
00720
if
(!
group__DBusMarshal.html#ga66
_dbus_header_init
(&message->
structDBusMessage.html#o1
header
, message->
structDBusMessage.html#o3
byte_order
))
00721         {
00722
group__DBusMemory.html#ga3
dbus_free
(message);
00723
return
group__DBusMacros.html#ga4
NULL
;
00724         }
00725
00726
if
(!
group__DBusString.html#ga5
_dbus_string_init_preallocated
(&message->
structDBusMessage.html#o2
body
, 32))
00727         {
00728
group__DBusMarshal.html#ga67
_dbus_header_free
(&message->
structDBusMessage.html#o1
header
);
00729
group__DBusMemory.html#ga3
dbus_free
(message);
00730
return
group__DBusMacros.html#ga4
NULL
;
00731         }
00732     }
00733
00734
return
message;
00735 }
00736
00745
structDBusMessage.html
DBusMessage
*
group__DBusMessage.html#ga12
00746
group__DBusMessage.html#ga12
dbus_message_new
(
int
message_type)
00747 {
00748
structDBusMessage.html
DBusMessage
*message;
00749
00750   _dbus_return_val_if_fail (message_type != DBUS_MESSAGE_TYPE_INVALID,
group__DBusMacros.html#ga4
NULL
);
00751
00752   message = dbus_message_new_empty_header ();
00753
if
(message ==
group__DBusMacros.html#ga4
NULL
)
00754
return
group__DBusMacros.html#ga4
NULL
;
00755
00756
if
(!
group__DBusMarshal.html#ga69
_dbus_header_create
(&message->
structDBusMessage.html#o1
header
,
00757                             message_type,
00758
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
))
00759     {
00760
group__DBusMessage.html#ga20
dbus_message_unref
(message);
00761
return
group__DBusMacros.html#ga4
NULL
;
00762     }
00763
00764
return
message;
00765 }
00766
00784
structDBusMessage.html
DBusMessage
*
group__DBusMessage.html#ga13
00785
group__DBusMessage.html#ga13
dbus_message_new_method_call
(
const
char
*destination,
00786
const
char
*path,
00787
const
char
*interface,
00788
const
char
*method)
00789 {
00790
structDBusMessage.html
DBusMessage
*message;
00791
00792   _dbus_return_val_if_fail (path !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00793   _dbus_return_val_if_fail (method !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00794   _dbus_return_val_if_fail (destination ==
group__DBusMacros.html#ga4
NULL
||
00795                             _dbus_check_is_valid_bus_name (destination),
group__DBusMacros.html#ga4
NULL
);
00796   _dbus_return_val_if_fail (_dbus_check_is_valid_path (path),
group__DBusMacros.html#ga4
NULL
);
00797   _dbus_return_val_if_fail (interface ==
group__DBusMacros.html#ga4
NULL
||
00798                             _dbus_check_is_valid_interface (interface),
group__DBusMacros.html#ga4
NULL
);
00799   _dbus_return_val_if_fail (_dbus_check_is_valid_member (method),
group__DBusMacros.html#ga4
NULL
);
00800
00801   message = dbus_message_new_empty_header ();
00802
if
(message ==
group__DBusMacros.html#ga4
NULL
)
00803
return
group__DBusMacros.html#ga4
NULL
;
00804
00805
if
(!
group__DBusMarshal.html#ga69
_dbus_header_create
(&message->
structDBusMessage.html#o1
header
,
00806                             DBUS_MESSAGE_TYPE_METHOD_CALL,
00807                             destination, path, interface, method,
group__DBusMacros.html#ga4
NULL
))
00808     {
00809
group__DBusMessage.html#ga20
dbus_message_unref
(message);
00810
return
group__DBusMacros.html#ga4
NULL
;
00811     }
00812
00813
return
message;
00814 }
00815
00825
structDBusMessage.html
DBusMessage
*
group__DBusMessage.html#ga14
00826
group__DBusMessage.html#ga14
dbus_message_new_method_return
(
structDBusMessage.html
DBusMessage
*method_call)
00827 {
00828
structDBusMessage.html
DBusMessage
*message;
00829
const
char
*sender;
00830
00831   _dbus_return_val_if_fail (method_call !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00832
00833   sender =
group__DBusMessage.html#ga66
dbus_message_get_sender
(method_call);
00834
00835
/* sender is allowed to be null here in peer-to-peer case */
00836
00837   message = dbus_message_new_empty_header ();
00838
if
(message ==
group__DBusMacros.html#ga4
NULL
)
00839
return
group__DBusMacros.html#ga4
NULL
;
00840
00841
if
(!
group__DBusMarshal.html#ga69
_dbus_header_create
(&message->
structDBusMessage.html#o1
header
,
00842                             DBUS_MESSAGE_TYPE_METHOD_RETURN,
00843                             sender,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
))
00844     {
00845
group__DBusMessage.html#ga20
dbus_message_unref
(message);
00846
return
group__DBusMacros.html#ga4
NULL
;
00847     }
00848
00849
group__DBusMessage.html#ga47
dbus_message_set_no_reply
(message,
group__DBusMacros.html#ga2
TRUE
);
00850
00851
if
(!
group__DBusMessage.html#ga4
dbus_message_set_reply_serial
(message,
00852
group__DBusMessage.html#ga3
dbus_message_get_serial
(method_call)))
00853     {
00854
group__DBusMessage.html#ga20
dbus_message_unref
(message);
00855
return
group__DBusMacros.html#ga4
NULL
;
00856     }
00857
00858
return
message;
00859 }
00860
00873
structDBusMessage.html
DBusMessage
*
group__DBusMessage.html#ga15
00874
group__DBusMessage.html#ga15
dbus_message_new_signal
(
const
char
*path,
00875
const
char
*interface,
00876
const
char
*name)
00877 {
00878
structDBusMessage.html
DBusMessage
*message;
00879
00880   _dbus_return_val_if_fail (path !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00881   _dbus_return_val_if_fail (interface !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00882   _dbus_return_val_if_fail (name !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00883   _dbus_return_val_if_fail (_dbus_check_is_valid_path (path),
group__DBusMacros.html#ga4
NULL
);
00884   _dbus_return_val_if_fail (_dbus_check_is_valid_interface (interface),
group__DBusMacros.html#ga4
NULL
);
00885   _dbus_return_val_if_fail (_dbus_check_is_valid_member (name),
group__DBusMacros.html#ga4
NULL
);
00886
00887   message = dbus_message_new_empty_header ();
00888
if
(message ==
group__DBusMacros.html#ga4
NULL
)
00889
return
group__DBusMacros.html#ga4
NULL
;
00890
00891
if
(!
group__DBusMarshal.html#ga69
_dbus_header_create
(&message->
structDBusMessage.html#o1
header
,
00892                             DBUS_MESSAGE_TYPE_SIGNAL,
00893
group__DBusMacros.html#ga4
NULL
, path, interface, name,
group__DBusMacros.html#ga4
NULL
))
00894     {
00895
group__DBusMessage.html#ga20
dbus_message_unref
(message);
00896
return
group__DBusMacros.html#ga4
NULL
;
00897     }
00898
00899
group__DBusMessage.html#ga47
dbus_message_set_no_reply
(message,
group__DBusMacros.html#ga2
TRUE
);
00900
00901
return
message;
00902 }
00903
00913
structDBusMessage.html
DBusMessage
*
group__DBusMessage.html#ga16
00914
group__DBusMessage.html#ga16
dbus_message_new_error
(
structDBusMessage.html
DBusMessage
*reply_to,
00915
const
char
*error_name,
00916
const
char
*error_message)
00917 {
00918
structDBusMessage.html
DBusMessage
*message;
00919
const
char
*sender;
00920
structDBusMessageIter.html
DBusMessageIter
iter;
00921
00922   _dbus_return_val_if_fail (reply_to !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00923   _dbus_return_val_if_fail (error_name !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00924   _dbus_return_val_if_fail (_dbus_check_is_valid_error_name (error_name),
group__DBusMacros.html#ga4
NULL
);
00925
00926   sender =
group__DBusMessage.html#ga66
dbus_message_get_sender
(reply_to);
00927
00928
/* sender may be NULL for non-message-bus case or
00929
* when the message bus is dealing with an unregistered
00930
* connection.
00931
*/
00932   message = dbus_message_new_empty_header ();
00933
if
(message ==
group__DBusMacros.html#ga4
NULL
)
00934
return
group__DBusMacros.html#ga4
NULL
;
00935
00936
if
(!
group__DBusMarshal.html#ga69
_dbus_header_create
(&message->
structDBusMessage.html#o1
header
,
00937                             DBUS_MESSAGE_TYPE_ERROR,
00938                             sender,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
, error_name))
00939     {
00940
group__DBusMessage.html#ga20
dbus_message_unref
(message);
00941
return
group__DBusMacros.html#ga4
NULL
;
00942     }
00943
00944
group__DBusMessage.html#ga47
dbus_message_set_no_reply
(message,
group__DBusMacros.html#ga2
TRUE
);
00945
00946
if
(!
group__DBusMessage.html#ga4
dbus_message_set_reply_serial
(message,
00947
group__DBusMessage.html#ga3
dbus_message_get_serial
(reply_to)))
00948     {
00949
group__DBusMessage.html#ga20
dbus_message_unref
(message);
00950
return
group__DBusMacros.html#ga4
NULL
;
00951     }
00952
00953
if
(error_message !=
group__DBusMacros.html#ga4
NULL
)
00954     {
00955
group__DBusMessage.html#ga39
dbus_message_iter_init_append
(message, &iter);
00956
if
(!
group__DBusMessage.html#ga43
dbus_message_iter_append_basic
(&iter,
00957                                            DBUS_TYPE_STRING,
00958                                            &error_message))
00959         {
00960
group__DBusMessage.html#ga20
dbus_message_unref
(message);
00961
return
group__DBusMacros.html#ga4
NULL
;
00962         }
00963     }
00964
00965
return
message;
00966 }
00967
00978
structDBusMessage.html
DBusMessage
*
group__DBusMessage.html#ga17
00979
group__DBusMessage.html#ga17
dbus_message_new_error_printf
(
structDBusMessage.html
DBusMessage
*reply_to,
00980
const
char
*error_name,
00981
const
char
*error_format,
00982                                ...)
00983 {
00984   va_list args;
00985
structDBusString.html
DBusString
str;
00986
structDBusMessage.html
DBusMessage
*message;
00987
00988   _dbus_return_val_if_fail (reply_to !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00989   _dbus_return_val_if_fail (error_name !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00990   _dbus_return_val_if_fail (_dbus_check_is_valid_error_name (error_name),
group__DBusMacros.html#ga4
NULL
);
00991
00992
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&str))
00993
return
group__DBusMacros.html#ga4
NULL
;
00994
00995   va_start (args, error_format);
00996
00997
if
(
group__DBusString.html#ga32
_dbus_string_append_printf_valist
(&str, error_format, args))
00998     message =
group__DBusMessage.html#ga16
dbus_message_new_error
(reply_to, error_name,
00999                                       _dbus_string_get_const_data (&str));
01000
else
01001     message =
group__DBusMacros.html#ga4
NULL
;
01002
01003
group__DBusString.html#ga9
_dbus_string_free
(&str);
01004
01005   va_end (args);
01006
01007
return
message;
01008 }
01009
01010
01021
structDBusMessage.html
DBusMessage
*
group__DBusMessage.html#ga18
01022
group__DBusMessage.html#ga18
dbus_message_copy
(
const
structDBusMessage.html
DBusMessage
*message)
01023 {
01024
structDBusMessage.html
DBusMessage
*retval;
01025
01026   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
01027
01028   retval =
group__DBusMemory.html#ga7
dbus_new0
(
structDBusMessage.html
DBusMessage
, 1);
01029
if
(retval ==
group__DBusMacros.html#ga4
NULL
)
01030
return
group__DBusMacros.html#ga4
NULL
;
01031
01032   retval->
structDBusMessage.html#o0
refcount
.
structDBusAtomic.html#o0
value
= 1;
01033   retval->
structDBusMessage.html#o3
byte_order
= message->
structDBusMessage.html#o3
byte_order
;
01034   retval->
structDBusMessage.html#o4
locked
=
group__DBusMacros.html#ga3
FALSE
;
01035
#ifndef DBUS_DISABLE_CHECKS
01036
retval->
structDBusMessage.html#o10
generation
= message->
structDBusMessage.html#o10
generation
;
01037
#endif
01038
01039
if
(!
group__DBusMarshal.html#ga68
_dbus_header_copy
(&message->
structDBusMessage.html#o1
header
, &retval->
structDBusMessage.html#o1
header
))
01040     {
01041
group__DBusMemory.html#ga3
dbus_free
(retval);
01042
return
group__DBusMacros.html#ga4
NULL
;
01043     }
01044
01045
if
(!
group__DBusString.html#ga5
_dbus_string_init_preallocated
(&retval->
structDBusMessage.html#o2
body
,
01046                                        _dbus_string_get_length (&message->
structDBusMessage.html#o2
body
)))
01047     {
01048
group__DBusMarshal.html#ga67
_dbus_header_free
(&retval->
structDBusMessage.html#o1
header
);
01049
group__DBusMemory.html#ga3
dbus_free
(retval);
01050
return
group__DBusMacros.html#ga4
NULL
;
01051     }
01052
01053
if
(!
group__DBusString.html#ga40
_dbus_string_copy
(&message->
structDBusMessage.html#o2
body
, 0,
01054                           &retval->
structDBusMessage.html#o2
body
, 0))
01055
goto
failed_copy;
01056
01057
return
retval;
01058
01059  failed_copy:
01060
group__DBusMarshal.html#ga67
_dbus_header_free
(&retval->
structDBusMessage.html#o1
header
);
01061
group__DBusString.html#ga9
_dbus_string_free
(&retval->
structDBusMessage.html#o2
body
);
01062
group__DBusMemory.html#ga3
dbus_free
(retval);
01063
01064
return
group__DBusMacros.html#ga4
NULL
;
01065 }
01066
01067
01075
structDBusMessage.html
DBusMessage
*
group__DBusMessage.html#ga19
01076
group__DBusMessage.html#ga19
dbus_message_ref
(
structDBusMessage.html
DBusMessage
*message)
01077 {
01078
group__DBusTypes.html#ga4
dbus_int32_t
old_refcount;
01079
01080   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
01081   _dbus_return_val_if_fail (message->
structDBusMessage.html#o10
generation
==
group__DBusMemoryInternals.html#ga0
_dbus_current_generation
,
group__DBusMacros.html#ga4
NULL
);
01082   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o5
in_cache
,
group__DBusMacros.html#ga4
NULL
);
01083
01084   old_refcount =
group__DBusInternalsUtils.html#ga80
_dbus_atomic_inc
(&message->
structDBusMessage.html#o0
refcount
);
01085
group__DBusInternalsUtils.html#ga130
_dbus_assert
(old_refcount >= 1);
01086
01087
return
message;
01088 }
01089
01096
void
group__DBusMessage.html#ga20
01097
group__DBusMessage.html#ga20
dbus_message_unref
(
structDBusMessage.html
DBusMessage
*message)
01098 {
01099
group__DBusTypes.html#ga4
dbus_int32_t
old_refcount;
01100
01101   _dbus_return_if_fail (message !=
group__DBusMacros.html#ga4
NULL
);
01102   _dbus_return_if_fail (message->
structDBusMessage.html#o10
generation
==
group__DBusMemoryInternals.html#ga0
_dbus_current_generation
);
01103   _dbus_return_if_fail (!message->
structDBusMessage.html#o5
in_cache
);
01104
01105   old_refcount =
group__DBusInternalsUtils.html#ga81
_dbus_atomic_dec
(&message->
structDBusMessage.html#o0
refcount
);
01106
01107
group__DBusInternalsUtils.html#ga130
_dbus_assert
(old_refcount >= 0);
01108
01109
if
(old_refcount == 1)
01110     {
01111
/* Calls application callbacks! */
01112       dbus_message_cache_or_finalize (message);
01113     }
01114 }
01115
01128
int
group__DBusMessage.html#ga21
01129
group__DBusMessage.html#ga21
dbus_message_get_type
(
structDBusMessage.html
DBusMessage
*message)
01130 {
01131   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
, DBUS_MESSAGE_TYPE_INVALID);
01132
01133
return
group__DBusMarshal.html#ga62
_dbus_header_get_message_type
(&message->
structDBusMessage.html#o1
header
);
01134 }
01135
01188
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga22
01189
group__DBusMessage.html#ga22
dbus_message_append_args
(
structDBusMessage.html
DBusMessage
*message,
01190
int
first_arg_type,
01191                           ...)
01192 {
01193
group__DBusTypes.html#ga2
dbus_bool_t
retval;
01194   va_list var_args;
01195
01196   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
01197
01198   va_start (var_args, first_arg_type);
01199   retval =
group__DBusMessage.html#ga23
dbus_message_append_args_valist
(message,
01200                                             first_arg_type,
01201                                             var_args);
01202   va_end (var_args);
01203
01204
return
retval;
01205 }
01206
01221
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga23
01222
group__DBusMessage.html#ga23
dbus_message_append_args_valist
(
structDBusMessage.html
DBusMessage
*message,
01223
int
first_arg_type,
01224                                  va_list      var_args)
01225 {
01226
int
type;
01227
structDBusMessageIter.html
DBusMessageIter
iter;
01228
01229   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
01230
01231   type = first_arg_type;
01232
01233
group__DBusMessage.html#ga39
dbus_message_iter_init_append
(message, &iter);
01234
01235
while
(type != DBUS_TYPE_INVALID)
01236     {
01237
if
(
group__DBusSignature.html#ga9
dbus_type_is_basic
(type))
01238         {
01239
const
unionDBusBasicValue.html
DBusBasicValue
*value;
01240           value = va_arg (var_args,
const
unionDBusBasicValue.html
DBusBasicValue
*);
01241
01242
if
(!
group__DBusMessage.html#ga43
dbus_message_iter_append_basic
(&iter,
01243                                                type,
01244                                                value))
01245
goto
failed;
01246         }
01247
else
if
(type == DBUS_TYPE_ARRAY)
01248         {
01249
int
element_type;
01250
structDBusMessageIter.html
DBusMessageIter
array;
01251
char
buf[2];
01252
01253           element_type = va_arg (var_args,
int
);
01254
01255           buf[0] = element_type;
01256           buf[1] =
'\0'
;
01257
if
(!
group__DBusMessage.html#ga45
dbus_message_iter_open_container
(&iter,
01258                                                  DBUS_TYPE_ARRAY,
01259                                                  buf,
01260                                                  &array))
01261
goto
failed;
01262
01263
if
(
group__DBusSignature.html#ga10
dbus_type_is_fixed
(element_type))
01264             {
01265
const
unionDBusBasicValue.html
DBusBasicValue
**value;
01266
int
n_elements;
01267
01268               value = va_arg (var_args,
const
unionDBusBasicValue.html
DBusBasicValue
**);
01269               n_elements = va_arg (var_args,
int
);
01270
01271
if
(!
group__DBusMessage.html#ga44
dbus_message_iter_append_fixed_array
(&array,
01272                                                          element_type,
01273                                                          value,
01274                                                          n_elements))
01275
goto
failed;
01276             }
01277
else
if
(element_type == DBUS_TYPE_STRING ||
01278                    element_type == DBUS_TYPE_SIGNATURE ||
01279                    element_type == DBUS_TYPE_OBJECT_PATH)
01280             {
01281
const
char
***value_p;
01282
const
char
**value;
01283
int
n_elements;
01284
int
i;
01285
01286               value_p = va_arg (var_args,
const
char
***);
01287               n_elements = va_arg (var_args,
int
);
01288
01289               value = *value_p;
01290
01291               i = 0;
01292
while
(i < n_elements)
01293                 {
01294
if
(!
group__DBusMessage.html#ga43
dbus_message_iter_append_basic
(&array,
01295                                                        element_type,
01296                                                        &value[i]))
01297
goto
failed;
01298                   ++i;
01299                 }
01300             }
01301
else
01302             {
01303
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"arrays of %s can't be appended with %s for now\n"
,
01304
group__DBusMarshal.html#ga42
_dbus_type_to_string
(element_type),
01305                           _DBUS_FUNCTION_NAME);
01306
goto
failed;
01307             }
01308
01309
if
(!
group__DBusMessage.html#ga46
dbus_message_iter_close_container
(&iter, &array))
01310
goto
failed;
01311         }
01312
#ifndef DBUS_DISABLE_CHECKS
01313
else
01314         {
01315
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"type %s isn't supported yet in %s\n"
,
01316
group__DBusMarshal.html#ga42
_dbus_type_to_string
(type), _DBUS_FUNCTION_NAME);
01317
goto
failed;
01318         }
01319
#endif
01320
01321       type = va_arg (var_args,
int
);
01322     }
01323
01324
return
group__DBusMacros.html#ga2
TRUE
;
01325
01326  failed:
01327
return
group__DBusMacros.html#ga3
FALSE
;
01328 }
01329
01362
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga24
01363
group__DBusMessage.html#ga24
dbus_message_get_args
(
structDBusMessage.html
DBusMessage
*message,
01364
structDBusError.html
DBusError
*error,
01365
int
first_arg_type,
01366                        ...)
01367 {
01368
group__DBusTypes.html#ga2
dbus_bool_t
retval;
01369   va_list var_args;
01370
01371   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
01372   _dbus_return_val_if_error_is_set (error,
group__DBusMacros.html#ga3
FALSE
);
01373
01374   va_start (var_args, first_arg_type);
01375   retval =
group__DBusMessage.html#ga25
dbus_message_get_args_valist
(message, error, first_arg_type, var_args);
01376   va_end (var_args);
01377
01378
return
retval;
01379 }
01380
01392
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga25
01393
group__DBusMessage.html#ga25
dbus_message_get_args_valist
(
structDBusMessage.html
DBusMessage
*message,
01394
structDBusError.html
DBusError
*error,
01395
int
first_arg_type,
01396                               va_list          var_args)
01397 {
01398
structDBusMessageIter.html
DBusMessageIter
iter;
01399
01400   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
01401   _dbus_return_val_if_error_is_set (error,
group__DBusMacros.html#ga3
FALSE
);
01402
01403
group__DBusMessage.html#ga27
dbus_message_iter_init
(message, &iter);
01404
return
group__DBusMessageInternals.html#ga2
_dbus_message_iter_get_args_valist
(&iter, error, first_arg_type, var_args);
01405 }
01406
01407
static
void
01408 _dbus_message_iter_init_common (
structDBusMessage.html
DBusMessage
*message,
01409                                 DBusMessageRealIter *real,
01410
int
iter_type)
01411 {
01412
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
sizeof
(DBusMessageRealIter) <=
sizeof
(
structDBusMessageIter.html
DBusMessageIter
));
01413
01414
/* Since the iterator will read or write who-knows-what from the
01415
* message, we need to get in the right byte order
01416
*/
01417
group__DBusMessageInternals.html#ga34
ensure_byte_order
(message);
01418
01419   real->
structDBusMessageRealIter.html#o0
message
= message;
01420   real->
structDBusMessageRealIter.html#o1
changed_stamp
= message->
structDBusMessage.html#o8
changed_stamp
;
01421   real->
structDBusMessageRealIter.html#o2
iter_type
= iter_type;
01422   real->
structDBusMessageRealIter.html#o3
sig_refcount
= 0;
01423 }
01424
01433
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga27
01434
group__DBusMessage.html#ga27
dbus_message_iter_init
(
structDBusMessage.html
DBusMessage
*message,
01435
structDBusMessageIter.html
DBusMessageIter
*iter)
01436 {
01437   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01438
const
structDBusString.html
DBusString
*type_str;
01439
int
type_pos;
01440
01441   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
01442   _dbus_return_val_if_fail (iter !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
01443
01444   get_const_signature (&message->
structDBusMessage.html#o1
header
, &type_str, &type_pos);
01445
01446   _dbus_message_iter_init_common (message, real,
01447                                   DBUS_MESSAGE_ITER_TYPE_READER);
01448
01449
group__DBusMarshal.html#ga104
_dbus_type_reader_init
(&real->
structDBusMessageRealIter.html#o6
u
.reader,
01450                           message->
structDBusMessage.html#o3
byte_order
,
01451                           type_str, type_pos,
01452                           &message->
structDBusMessage.html#o2
body
,
01453                           0);
01454
01455
return
group__DBusMarshal.html#ga109
_dbus_type_reader_get_current_type
(&real->
structDBusMessageRealIter.html#o6
u
.reader) != DBUS_TYPE_INVALID;
01456 }
01457
01458
#ifndef DBUS_DISABLE_CHECKS
01459
static
group__DBusTypes.html#ga2
dbus_bool_t
01460 _dbus_message_iter_check (DBusMessageRealIter *iter)
01461 {
01462
if
(iter ==
group__DBusMacros.html#ga4
NULL
)
01463     {
01464
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"dbus message iterator is NULL\n"
);
01465
return
group__DBusMacros.html#ga3
FALSE
;
01466     }
01467
01468
if
(iter->
structDBusMessageRealIter.html#o2
iter_type
== DBUS_MESSAGE_ITER_TYPE_READER)
01469     {
01470
if
(iter->
structDBusMessageRealIter.html#o6
u
.reader.byte_order != iter->
structDBusMessageRealIter.html#o0
message
->
structDBusMessage.html#o3
byte_order
)
01471         {
01472
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"dbus message changed byte order since iterator was created\n"
);
01473
return
group__DBusMacros.html#ga3
FALSE
;
01474         }
01475
/* because we swap the message into compiler order when you init an iter */
01476
group__DBusInternalsUtils.html#ga130
_dbus_assert
(iter->
structDBusMessageRealIter.html#o6
u
.reader.byte_order == DBUS_COMPILER_BYTE_ORDER);
01477     }
01478
else
if
(iter->
structDBusMessageRealIter.html#o2
iter_type
== DBUS_MESSAGE_ITER_TYPE_WRITER)
01479     {
01480
if
(iter->
structDBusMessageRealIter.html#o6
u
.writer.byte_order != iter->
structDBusMessageRealIter.html#o0
message
->
structDBusMessage.html#o3
byte_order
)
01481         {
01482
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"dbus message changed byte order since append iterator was created\n"
);
01483
return
group__DBusMacros.html#ga3
FALSE
;
01484         }
01485
/* because we swap the message into compiler order when you init an iter */
01486
group__DBusInternalsUtils.html#ga130
_dbus_assert
(iter->
structDBusMessageRealIter.html#o6
u
.writer.byte_order == DBUS_COMPILER_BYTE_ORDER);
01487     }
01488
else
01489     {
01490
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"dbus message iterator looks uninitialized or corrupted\n"
);
01491
return
group__DBusMacros.html#ga3
FALSE
;
01492     }
01493
01494
if
(iter->
structDBusMessageRealIter.html#o1
changed_stamp
!= iter->
structDBusMessageRealIter.html#o0
message
->
structDBusMessage.html#o8
changed_stamp
)
01495     {
01496
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"dbus message iterator invalid because the message has been modified (or perhaps the iterator is just uninitialized)\n"
);
01497
return
group__DBusMacros.html#ga3
FALSE
;
01498     }
01499
01500
return
group__DBusMacros.html#ga2
TRUE
;
01501 }
01502
#endif
/* DBUS_DISABLE_CHECKS */
01503
01511
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga29
01512
group__DBusMessage.html#ga29
dbus_message_iter_has_next
(
structDBusMessageIter.html
DBusMessageIter
*iter)
01513 {
01514   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01515
01516   _dbus_return_val_if_fail (_dbus_message_iter_check (real),
group__DBusMacros.html#ga3
FALSE
);
01517   _dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_READER,
group__DBusMacros.html#ga3
FALSE
);
01518
01519
return
group__DBusMarshal.html#ga118
_dbus_type_reader_has_next
(&real->u.reader);
01520 }
01521
01530
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga30
01531
group__DBusMessage.html#ga30
dbus_message_iter_next
(
structDBusMessageIter.html
DBusMessageIter
*iter)
01532 {
01533   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01534
01535   _dbus_return_val_if_fail (_dbus_message_iter_check (real),
group__DBusMacros.html#ga3
FALSE
);
01536   _dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_READER,
group__DBusMacros.html#ga3
FALSE
);
01537
01538
return
group__DBusMarshal.html#ga117
_dbus_type_reader_next
(&real->u.reader);
01539 }
01540
01555
int
group__DBusMessage.html#ga31
01556
group__DBusMessage.html#ga31
dbus_message_iter_get_arg_type
(
structDBusMessageIter.html
DBusMessageIter
*iter)
01557 {
01558   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01559
01560   _dbus_return_val_if_fail (_dbus_message_iter_check (real), DBUS_TYPE_INVALID);
01561   _dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_READER,
group__DBusMacros.html#ga3
FALSE
);
01562
01563
return
group__DBusMarshal.html#ga109
_dbus_type_reader_get_current_type
(&real->u.reader);
01564 }
01565
01574
int
group__DBusMessage.html#ga32
01575
group__DBusMessage.html#ga32
dbus_message_iter_get_element_type
(
structDBusMessageIter.html
DBusMessageIter
*iter)
01576 {
01577   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01578
01579   _dbus_return_val_if_fail (_dbus_message_iter_check (real), DBUS_TYPE_INVALID);
01580   _dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_READER, DBUS_TYPE_INVALID);
01581   _dbus_return_val_if_fail (
group__DBusMessage.html#ga31
dbus_message_iter_get_arg_type
(iter) == DBUS_TYPE_ARRAY, DBUS_TYPE_INVALID);
01582
01583
return
group__DBusMarshal.html#ga110
_dbus_type_reader_get_element_type
(&real->u.reader);
01584 }
01585
01601
void
group__DBusMessage.html#ga33
01602
group__DBusMessage.html#ga33
dbus_message_iter_recurse
(
structDBusMessageIter.html
DBusMessageIter
*iter,
01603
structDBusMessageIter.html
DBusMessageIter
*sub)
01604 {
01605   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01606   DBusMessageRealIter *real_sub = (DBusMessageRealIter *)sub;
01607
01608   _dbus_return_if_fail (_dbus_message_iter_check (real));
01609   _dbus_return_if_fail (sub !=
group__DBusMacros.html#ga4
NULL
);
01610
01611   *real_sub = *real;
01612
group__DBusMarshal.html#ga116
_dbus_type_reader_recurse
(&real->u.reader, &real_sub->
structDBusMessageRealIter.html#o6
u
.reader);
01613 }
01614
01624
char
*
group__DBusMessage.html#ga34
01625
group__DBusMessage.html#ga34
dbus_message_iter_get_signature
(
structDBusMessageIter.html
DBusMessageIter
*iter)
01626 {
01627
const
structDBusString.html
DBusString
*sig;
01628
structDBusString.html
DBusString
retstr;
01629
char
*ret;
01630
int
start, len;
01631   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01632
01633   _dbus_return_val_if_fail (_dbus_message_iter_check (real),
group__DBusMacros.html#ga4
NULL
);
01634
01635
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&retstr))
01636
return
group__DBusMacros.html#ga4
NULL
;
01637
01638
group__DBusMarshal.html#ga119
_dbus_type_reader_get_signature
(&real->u.reader, &sig,
01639                                    &start, &len);
01640
if
(!
group__DBusString.html#ga34
_dbus_string_append_len
(&retstr,
01641                                 _dbus_string_get_const_data (sig) + start,
01642                                 len))
01643
return
group__DBusMacros.html#ga4
NULL
;
01644
if
(!
group__DBusString.html#ga16
_dbus_string_steal_data
(&retstr, &ret))
01645
return
group__DBusMacros.html#ga4
NULL
;
01646
group__DBusString.html#ga9
_dbus_string_free
(&retstr);
01647
return
ret;
01648 }
01649
01685
void
group__DBusMessage.html#ga35
01686
group__DBusMessage.html#ga35
dbus_message_iter_get_basic
(
structDBusMessageIter.html
DBusMessageIter
*iter,
01687
void
*value)
01688 {
01689   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01690
01691   _dbus_return_if_fail (_dbus_message_iter_check (real));
01692   _dbus_return_if_fail (value !=
group__DBusMacros.html#ga4
NULL
);
01693
01694
group__DBusMarshal.html#ga113
_dbus_type_reader_read_basic
(&real->u.reader,
01695                                 value);
01696 }
01697
01704
int
group__DBusMessage.html#ga36
01705
group__DBusMessage.html#ga36
dbus_message_iter_get_array_len
(
structDBusMessageIter.html
DBusMessageIter
*iter)
01706 {
01707   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01708
01709   _dbus_return_val_if_fail (_dbus_message_iter_check (real), 0);
01710
01711
return
group__DBusMarshal.html#ga114
_dbus_type_reader_get_array_length
(&real->u.reader);
01712 }
01713
01731
void
group__DBusMessage.html#ga37
01732
group__DBusMessage.html#ga37
dbus_message_iter_get_fixed_array
(
structDBusMessageIter.html
DBusMessageIter
*iter,
01733
void
*value,
01734
int
*n_elements)
01735 {
01736   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01737
01738   _dbus_return_if_fail (_dbus_message_iter_check (real));
01739   _dbus_return_if_fail (value !=
group__DBusMacros.html#ga4
NULL
);
01740   _dbus_return_if_fail (
group__DBusSignature.html#ga10
dbus_type_is_fixed
(
group__DBusMarshal.html#ga109
_dbus_type_reader_get_current_type
(&real->u.reader)));
01741
01742
group__DBusMarshal.html#ga115
_dbus_type_reader_read_fixed_multi
(&real->u.reader,
01743                                       value, n_elements);
01744 }
01745
01759
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga38
01760
group__DBusMessageInternals.html#ga2
_dbus_message_iter_get_args_valist
(
structDBusMessageIter.html
DBusMessageIter
*iter,
01761
structDBusError.html
DBusError
*error,
01762
int
first_arg_type,
01763                                     va_list          var_args)
01764 {
01765   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01766
int
spec_type, msg_type, i;
01767
group__DBusTypes.html#ga2
dbus_bool_t
retval;
01768
01769
group__DBusInternalsUtils.html#ga130
_dbus_assert
(_dbus_message_iter_check (real));
01770
01771   retval =
group__DBusMacros.html#ga3
FALSE
;
01772
01773   spec_type = first_arg_type;
01774   i = 0;
01775
01776
while
(spec_type != DBUS_TYPE_INVALID)
01777     {
01778       msg_type =
group__DBusMessage.html#ga31
dbus_message_iter_get_arg_type
(iter);
01779
01780
if
(msg_type != spec_type)
01781         {
01782
group__DBusErrors.html#ga6
dbus_set_error
(error, DBUS_ERROR_INVALID_ARGS,
01783
"Argument %d is specified to be of type \"%s\", but "
01784
"is actually of type \"%s\"\n"
, i,
01785
group__DBusMarshal.html#ga42
_dbus_type_to_string
(spec_type),
01786
group__DBusMarshal.html#ga42
_dbus_type_to_string
(msg_type));
01787
01788
goto
out;
01789         }
01790
01791
if
(
group__DBusSignature.html#ga9
dbus_type_is_basic
(spec_type))
01792         {
01793
unionDBusBasicValue.html
DBusBasicValue
*ptr;
01794
01795           ptr = va_arg (var_args,
unionDBusBasicValue.html
DBusBasicValue
*);
01796
01797
group__DBusInternalsUtils.html#ga130
_dbus_assert
(ptr !=
group__DBusMacros.html#ga4
NULL
);
01798
01799
group__DBusMarshal.html#ga113
_dbus_type_reader_read_basic
(&real->u.reader,
01800                                         ptr);
01801         }
01802
else
if
(spec_type == DBUS_TYPE_ARRAY)
01803         {
01804
int
element_type;
01805
int
spec_element_type;
01806
const
unionDBusBasicValue.html
DBusBasicValue
**ptr;
01807
int
*n_elements_p;
01808
structDBusTypeReader.html
DBusTypeReader
array;
01809
01810           spec_element_type = va_arg (var_args,
int
);
01811           element_type =
group__DBusMarshal.html#ga110
_dbus_type_reader_get_element_type
(&real->u.reader);
01812
01813
if
(spec_element_type != element_type)
01814             {
01815
group__DBusErrors.html#ga6
dbus_set_error
(error, DBUS_ERROR_INVALID_ARGS,
01816
"Argument %d is specified to be an array of \"%s\", but "
01817
"is actually an array of \"%s\"\n"
,
01818                               i,
01819
group__DBusMarshal.html#ga42
_dbus_type_to_string
(spec_element_type),
01820
group__DBusMarshal.html#ga42
_dbus_type_to_string
(element_type));
01821
01822
goto
out;
01823             }
01824
01825
if
(
group__DBusSignature.html#ga10
dbus_type_is_fixed
(spec_element_type))
01826             {
01827               ptr = va_arg (var_args,
const
unionDBusBasicValue.html
DBusBasicValue
**);
01828               n_elements_p = va_arg (var_args,
int
*);
01829
01830
group__DBusInternalsUtils.html#ga130
_dbus_assert
(ptr !=
group__DBusMacros.html#ga4
NULL
);
01831
group__DBusInternalsUtils.html#ga130
_dbus_assert
(n_elements_p !=
group__DBusMacros.html#ga4
NULL
);
01832
01833
group__DBusMarshal.html#ga116
_dbus_type_reader_recurse
(&real->u.reader, &array);
01834
01835
group__DBusMarshal.html#ga115
_dbus_type_reader_read_fixed_multi
(&array,
01836                                                   ptr, n_elements_p);
01837             }
01838
else
if
(spec_element_type == DBUS_TYPE_STRING ||
01839                    spec_element_type == DBUS_TYPE_SIGNATURE ||
01840                    spec_element_type == DBUS_TYPE_OBJECT_PATH)
01841             {
01842
char
***str_array_p;
01843
int
n_elements;
01844
char
**str_array;
01845
01846               str_array_p = va_arg (var_args,
char
***);
01847               n_elements_p = va_arg (var_args,
int
*);
01848
01849
group__DBusInternalsUtils.html#ga130
_dbus_assert
(str_array_p !=
group__DBusMacros.html#ga4
NULL
);
01850
group__DBusInternalsUtils.html#ga130
_dbus_assert
(n_elements_p !=
group__DBusMacros.html#ga4
NULL
);
01851
01852
/* Count elements in the array */
01853
group__DBusMarshal.html#ga116
_dbus_type_reader_recurse
(&real->u.reader, &array);
01854
01855               n_elements = 0;
01856
while
(
group__DBusMarshal.html#ga109
_dbus_type_reader_get_current_type
(&array) != DBUS_TYPE_INVALID)
01857                 {
01858                   ++n_elements;
01859
group__DBusMarshal.html#ga117
_dbus_type_reader_next
(&array);
01860                 }
01861
01862               str_array =
group__DBusMemory.html#ga7
dbus_new0
(
char
*, n_elements + 1);
01863
if
(str_array ==
group__DBusMacros.html#ga4
NULL
)
01864                 {
01865                   _DBUS_SET_OOM (error);
01866
goto
out;
01867                 }
01868
01869
/* Now go through and dup each string */
01870
group__DBusMarshal.html#ga116
_dbus_type_reader_recurse
(&real->u.reader, &array);
01871
01872               i = 0;
01873
while
(i < n_elements)
01874                 {
01875
const
char
*s;
01876
group__DBusMarshal.html#ga113
_dbus_type_reader_read_basic
(&array,
01877                                                 &s);
01878
01879                   str_array[i] =
group__DBusInternalsUtils.html#ga8
_dbus_strdup
(s);
01880
if
(str_array[i] ==
group__DBusMacros.html#ga4
NULL
)
01881                     {
01882
group__DBusMemory.html#ga4
dbus_free_string_array
(str_array);
01883                       _DBUS_SET_OOM (error);
01884
goto
out;
01885                     }
01886
01887                   ++i;
01888
01889
if
(!
group__DBusMarshal.html#ga117
_dbus_type_reader_next
(&array))
01890
group__DBusInternalsUtils.html#ga130
_dbus_assert
(i == n_elements);
01891                 }
01892
01893
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusMarshal.html#ga109
_dbus_type_reader_get_current_type
(&array) == DBUS_TYPE_INVALID);
01894
group__DBusInternalsUtils.html#ga130
_dbus_assert
(i == n_elements);
01895
group__DBusInternalsUtils.html#ga130
_dbus_assert
(str_array[i] ==
group__DBusMacros.html#ga4
NULL
);
01896
01897               *str_array_p = str_array;
01898               *n_elements_p = n_elements;
01899             }
01900
#ifndef DBUS_DISABLE_CHECKS
01901
else
01902             {
01903
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"you can't read arrays of container types (struct, variant, array) with %s for now\n"
,
01904                           _DBUS_FUNCTION_NAME);
01905
goto
out;
01906             }
01907
#endif
01908
}
01909
#ifndef DBUS_DISABLE_CHECKS
01910
else
01911         {
01912
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"you can only read arrays and basic types with %s for now\n"
,
01913                       _DBUS_FUNCTION_NAME);
01914
goto
out;
01915         }
01916
#endif
01917
01918       spec_type = va_arg (var_args,
int
);
01919
if
(!
group__DBusMarshal.html#ga117
_dbus_type_reader_next
(&real->u.reader) && spec_type != DBUS_TYPE_INVALID)
01920         {
01921
group__DBusErrors.html#ga6
dbus_set_error
(error, DBUS_ERROR_INVALID_ARGS,
01922
"Message has only %d arguments, but more were expected"
, i);
01923
goto
out;
01924         }
01925
01926       i++;
01927     }
01928
01929   retval =
group__DBusMacros.html#ga2
TRUE
;
01930
01931  out:
01932
01933
return
retval;
01934 }
01935
01947
void
group__DBusMessage.html#ga39
01948
group__DBusMessage.html#ga39
dbus_message_iter_init_append
(
structDBusMessage.html
DBusMessage
*message,
01949
structDBusMessageIter.html
DBusMessageIter
*iter)
01950 {
01951   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
01952
01953   _dbus_return_if_fail (message !=
group__DBusMacros.html#ga4
NULL
);
01954   _dbus_return_if_fail (iter !=
group__DBusMacros.html#ga4
NULL
);
01955
01956   _dbus_message_iter_init_common (message, real,
01957                                   DBUS_MESSAGE_ITER_TYPE_WRITER);
01958
01959
/* We create the signature string and point iterators at it "on demand"
01960
* when a value is actually appended. That means that init() never fails
01961
* due to OOM.
01962
*/
01963
group__DBusMarshal.html#ga129
_dbus_type_writer_init_types_delayed
(&real->
structDBusMessageRealIter.html#o6
u
.writer,
01964                                         message->
structDBusMessage.html#o3
byte_order
,
01965                                         &message->
structDBusMessage.html#o2
body
,
01966                                         _dbus_string_get_length (&message->
structDBusMessage.html#o2
body
));
01967 }
01968
01977
static
group__DBusTypes.html#ga2
dbus_bool_t
01978 _dbus_message_iter_open_signature (DBusMessageRealIter *real)
01979 {
01980
structDBusString.html
DBusString
*str;
01981
const
structDBusString.html
DBusString
*current_sig;
01982
int
current_sig_pos;
01983
01984
group__DBusInternalsUtils.html#ga130
_dbus_assert
(real->
structDBusMessageRealIter.html#o2
iter_type
== DBUS_MESSAGE_ITER_TYPE_WRITER);
01985
01986
if
(real->
structDBusMessageRealIter.html#o6
u
.writer.type_str !=
group__DBusMacros.html#ga4
NULL
)
01987     {
01988
group__DBusInternalsUtils.html#ga130
_dbus_assert
(real->
structDBusMessageRealIter.html#o3
sig_refcount
> 0);
01989       real->
structDBusMessageRealIter.html#o3
sig_refcount
+= 1;
01990
return
group__DBusMacros.html#ga2
TRUE
;
01991     }
01992
01993   str =
group__DBusMemory.html#ga6
dbus_new
(
structDBusString.html
DBusString
, 1);
01994
if
(str ==
group__DBusMacros.html#ga4
NULL
)
01995
return
group__DBusMacros.html#ga3
FALSE
;
01996
01997
if
(!
group__DBusMarshal.html#ga78
_dbus_header_get_field_raw
(&real->
structDBusMessageRealIter.html#o0
message
->
structDBusMessage.html#o1
header
,
01998                                    DBUS_HEADER_FIELD_SIGNATURE,
01999                                    &current_sig, &current_sig_pos))
02000     current_sig =
group__DBusMacros.html#ga4
NULL
;
02001
02002
if
(current_sig)
02003     {
02004
int
current_len;
02005
02006       current_len = _dbus_string_get_byte (current_sig, current_sig_pos);
02007       current_sig_pos += 1;
/* move on to sig data */
02008
02009
if
(!
group__DBusString.html#ga5
_dbus_string_init_preallocated
(str, current_len + 4))
02010         {
02011
group__DBusMemory.html#ga3
dbus_free
(str);
02012
return
group__DBusMacros.html#ga3
FALSE
;
02013         }
02014
02015
if
(!
group__DBusString.html#ga42
_dbus_string_copy_len
(current_sig, current_sig_pos, current_len,
02016                                   str, 0))
02017         {
02018
group__DBusString.html#ga9
_dbus_string_free
(str);
02019
group__DBusMemory.html#ga3
dbus_free
(str);
02020
return
group__DBusMacros.html#ga3
FALSE
;
02021         }
02022     }
02023
else
02024     {
02025
if
(!
group__DBusString.html#ga5
_dbus_string_init_preallocated
(str, 4))
02026         {
02027
group__DBusMemory.html#ga3
dbus_free
(str);
02028
return
group__DBusMacros.html#ga3
FALSE
;
02029         }
02030     }
02031
02032   real->
structDBusMessageRealIter.html#o3
sig_refcount
= 1;
02033
02034
group__DBusMarshal.html#ga130
_dbus_type_writer_add_types
(&real->
structDBusMessageRealIter.html#o6
u
.writer,
02035                                str, _dbus_string_get_length (str));
02036
return
group__DBusMacros.html#ga2
TRUE
;
02037 }
02038
02048
static
group__DBusTypes.html#ga2
dbus_bool_t
02049 _dbus_message_iter_close_signature (DBusMessageRealIter *real)
02050 {
02051
structDBusString.html
DBusString
*str;
02052
const
char
*v_STRING;
02053
group__DBusTypes.html#ga2
dbus_bool_t
retval;
02054
02055
group__DBusInternalsUtils.html#ga130
_dbus_assert
(real->
structDBusMessageRealIter.html#o2
iter_type
== DBUS_MESSAGE_ITER_TYPE_WRITER);
02056
group__DBusInternalsUtils.html#ga130
_dbus_assert
(real->
structDBusMessageRealIter.html#o6
u
.writer.type_str !=
group__DBusMacros.html#ga4
NULL
);
02057
group__DBusInternalsUtils.html#ga130
_dbus_assert
(real->
structDBusMessageRealIter.html#o3
sig_refcount
> 0);
02058
02059   real->
structDBusMessageRealIter.html#o3
sig_refcount
-= 1;
02060
02061
if
(real->
structDBusMessageRealIter.html#o3
sig_refcount
> 0)
02062
return
group__DBusMacros.html#ga2
TRUE
;
02063
group__DBusInternalsUtils.html#ga130
_dbus_assert
(real->
structDBusMessageRealIter.html#o3
sig_refcount
== 0);
02064
02065   retval =
group__DBusMacros.html#ga2
TRUE
;
02066
02067   str = real->
structDBusMessageRealIter.html#o6
u
.writer.type_str;
02068
02069   v_STRING = _dbus_string_get_const_data (str);
02070
if
(!
group__DBusMarshal.html#ga76
_dbus_header_set_field_basic
(&real->
structDBusMessageRealIter.html#o0
message
->
structDBusMessage.html#o1
header
,
02071                                      DBUS_HEADER_FIELD_SIGNATURE,
02072                                      DBUS_TYPE_SIGNATURE,
02073                                      &v_STRING))
02074     retval =
group__DBusMacros.html#ga3
FALSE
;
02075
02076
group__DBusMarshal.html#ga131
_dbus_type_writer_remove_types
(&real->
structDBusMessageRealIter.html#o6
u
.writer);
02077
group__DBusString.html#ga9
_dbus_string_free
(str);
02078
group__DBusMemory.html#ga3
dbus_free
(str);
02079
02080
return
retval;
02081 }
02082
02083
#ifndef DBUS_DISABLE_CHECKS
02084
static
group__DBusTypes.html#ga2
dbus_bool_t
02085 _dbus_message_iter_append_check (DBusMessageRealIter *iter)
02086 {
02087
if
(!_dbus_message_iter_check (iter))
02088
return
group__DBusMacros.html#ga3
FALSE
;
02089
02090
if
(iter->message->locked)
02091     {
02092
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"dbus append iterator can't be used: message is locked (has already been sent)\n"
);
02093
return
group__DBusMacros.html#ga3
FALSE
;
02094     }
02095
02096
return
group__DBusMacros.html#ga2
TRUE
;
02097 }
02098
#endif
/* DBUS_DISABLE_CHECKS */
02099
02115
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga43
02116
group__DBusMessage.html#ga43
dbus_message_iter_append_basic
(
structDBusMessageIter.html
DBusMessageIter
*iter,
02117
int
type,
02118
const
void
*value)
02119 {
02120   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
02121
group__DBusTypes.html#ga2
dbus_bool_t
ret;
02122
02123   _dbus_return_val_if_fail (_dbus_message_iter_append_check (real),
group__DBusMacros.html#ga3
FALSE
);
02124   _dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
group__DBusMacros.html#ga3
FALSE
);
02125   _dbus_return_val_if_fail (
group__DBusSignature.html#ga9
dbus_type_is_basic
(type),
group__DBusMacros.html#ga3
FALSE
);
02126   _dbus_return_val_if_fail (value !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02127
02128
if
(!_dbus_message_iter_open_signature (real))
02129
return
group__DBusMacros.html#ga3
FALSE
;
02130
02131   ret =
group__DBusMarshal.html#ga144
_dbus_type_writer_write_basic
(&real->u.writer, type, value);
02132
02133
if
(!_dbus_message_iter_close_signature (real))
02134     ret =
group__DBusMacros.html#ga3
FALSE
;
02135
02136
return
ret;
02137 }
02138
02174
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga44
02175
group__DBusMessage.html#ga44
dbus_message_iter_append_fixed_array
(
structDBusMessageIter.html
DBusMessageIter
*iter,
02176
int
element_type,
02177
const
void
*value,
02178
int
n_elements)
02179 {
02180   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
02181
group__DBusTypes.html#ga2
dbus_bool_t
ret;
02182
02183   _dbus_return_val_if_fail (_dbus_message_iter_append_check (real),
group__DBusMacros.html#ga3
FALSE
);
02184   _dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
group__DBusMacros.html#ga3
FALSE
);
02185   _dbus_return_val_if_fail (
group__DBusSignature.html#ga10
dbus_type_is_fixed
(element_type),
group__DBusMacros.html#ga3
FALSE
);
02186   _dbus_return_val_if_fail (real->u.writer.container_type == DBUS_TYPE_ARRAY,
group__DBusMacros.html#ga3
FALSE
);
02187   _dbus_return_val_if_fail (value !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02188   _dbus_return_val_if_fail (n_elements >= 0,
group__DBusMacros.html#ga3
FALSE
);
02189   _dbus_return_val_if_fail (n_elements <=
02190                             DBUS_MAXIMUM_ARRAY_LENGTH /
group__DBusMarshal.html#ga40
_dbus_type_get_alignment
(element_type),
02191
group__DBusMacros.html#ga3
FALSE
);
02192
02193   ret =
group__DBusMarshal.html#ga145
_dbus_type_writer_write_fixed_multi
(&real->u.writer, element_type, value, n_elements);
02194
02195
return
ret;
02196 }
02197
02219
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga45
02220
group__DBusMessage.html#ga45
dbus_message_iter_open_container
(
structDBusMessageIter.html
DBusMessageIter
*iter,
02221
int
type,
02222
const
char
*contained_signature,
02223
structDBusMessageIter.html
DBusMessageIter
*sub)
02224 {
02225   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
02226   DBusMessageRealIter *real_sub = (DBusMessageRealIter *)sub;
02227
structDBusString.html
DBusString
contained_str;
02228
02229   _dbus_return_val_if_fail (_dbus_message_iter_append_check (real),
group__DBusMacros.html#ga3
FALSE
);
02230   _dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
group__DBusMacros.html#ga3
FALSE
);
02231   _dbus_return_val_if_fail (
group__DBusSignature.html#ga8
dbus_type_is_container
(type),
group__DBusMacros.html#ga3
FALSE
);
02232   _dbus_return_val_if_fail (sub !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02233   _dbus_return_val_if_fail ((type == DBUS_TYPE_STRUCT &&
02234                              contained_signature ==
group__DBusMacros.html#ga4
NULL
) ||
02235                             (type == DBUS_TYPE_DICT_ENTRY &&
02236                              contained_signature ==
group__DBusMacros.html#ga4
NULL
) ||
02237                             contained_signature !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02238
02239
#if 0
02240
/* FIXME this would fail if the contained_signature is a dict entry,
02241
* since dict entries are invalid signatures standalone (they must be in
02242
* an array)
02243
*/
02244   _dbus_return_val_if_fail (contained_signature ==
group__DBusMacros.html#ga4
NULL
||
02245                             _dbus_check_is_valid_signature (contained_signature));
02246
#endif
02247
02248
if
(!_dbus_message_iter_open_signature (real))
02249
return
group__DBusMacros.html#ga3
FALSE
;
02250
02251   *real_sub = *real;
02252
02253
if
(contained_signature !=
group__DBusMacros.html#ga4
NULL
)
02254     {
02255
group__DBusString.html#ga7
_dbus_string_init_const
(&contained_str, contained_signature);
02256
02257
return
group__DBusMarshal.html#ga140
_dbus_type_writer_recurse
(&real->u.writer,
02258                                         type,
02259                                         &contained_str, 0,
02260                                         &real_sub->
structDBusMessageRealIter.html#o6
u
.writer);
02261     }
02262
else
02263     {
02264
return
group__DBusMarshal.html#ga140
_dbus_type_writer_recurse
(&real->u.writer,
02265                                         type,
02266
group__DBusMacros.html#ga4
NULL
, 0,
02267                                         &real_sub->
structDBusMessageRealIter.html#o6
u
.writer);
02268     }
02269 }
02270
02271
02285
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga46
02286
group__DBusMessage.html#ga46
dbus_message_iter_close_container
(
structDBusMessageIter.html
DBusMessageIter
*iter,
02287
structDBusMessageIter.html
DBusMessageIter
*sub)
02288 {
02289   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
02290   DBusMessageRealIter *real_sub = (DBusMessageRealIter *)sub;
02291
group__DBusTypes.html#ga2
dbus_bool_t
ret;
02292
02293   _dbus_return_val_if_fail (_dbus_message_iter_append_check (real),
group__DBusMacros.html#ga3
FALSE
);
02294   _dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
group__DBusMacros.html#ga3
FALSE
);
02295   _dbus_return_val_if_fail (_dbus_message_iter_append_check (real_sub),
group__DBusMacros.html#ga3
FALSE
);
02296   _dbus_return_val_if_fail (real_sub->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER,
group__DBusMacros.html#ga3
FALSE
);
02297
02298   ret =
group__DBusMarshal.html#ga143
_dbus_type_writer_unrecurse
(&real->u.writer,
02299                                      &real_sub->u.writer);
02300
02301
if
(!_dbus_message_iter_close_signature (real))
02302     ret =
group__DBusMacros.html#ga3
FALSE
;
02303
02304
return
ret;
02305 }
02306
02318
void
group__DBusMessage.html#ga47
02319
group__DBusMessage.html#ga47
dbus_message_set_no_reply
(
structDBusMessage.html
DBusMessage
*message,
02320
group__DBusTypes.html#ga2
dbus_bool_t
no_reply)
02321 {
02322   _dbus_return_if_fail (message !=
group__DBusMacros.html#ga4
NULL
);
02323   _dbus_return_if_fail (!message->
structDBusMessage.html#o4
locked
);
02324
02325
group__DBusMarshal.html#ga80
_dbus_header_toggle_flag
(&message->
structDBusMessage.html#o1
header
,
02326                             DBUS_HEADER_FLAG_NO_REPLY_EXPECTED,
02327                             no_reply);
02328 }
02329
02337
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga48
02338
group__DBusMessage.html#ga48
dbus_message_get_no_reply
(
structDBusMessage.html
DBusMessage
*message)
02339 {
02340   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02341
02342
return
group__DBusMarshal.html#ga81
_dbus_header_get_flag
(&message->
structDBusMessage.html#o1
header
,
02343                                 DBUS_HEADER_FLAG_NO_REPLY_EXPECTED);
02344 }
02345
02356
void
group__DBusMessage.html#ga49
02357
group__DBusMessage.html#ga49
dbus_message_set_auto_start
(
structDBusMessage.html
DBusMessage
*message,
02358
group__DBusTypes.html#ga2
dbus_bool_t
auto_start)
02359 {
02360   _dbus_return_if_fail (message !=
group__DBusMacros.html#ga4
NULL
);
02361   _dbus_return_if_fail (!message->
structDBusMessage.html#o4
locked
);
02362
02363
group__DBusMarshal.html#ga80
_dbus_header_toggle_flag
(&message->
structDBusMessage.html#o1
header
,
02364                             DBUS_HEADER_FLAG_NO_AUTO_START,
02365                             !auto_start);
02366 }
02367
02375
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga50
02376
group__DBusMessage.html#ga50
dbus_message_get_auto_start
(
structDBusMessage.html
DBusMessage
*message)
02377 {
02378   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02379
02380
return
!
group__DBusMarshal.html#ga81
_dbus_header_get_flag
(&message->
structDBusMessage.html#o1
header
,
02381                                  DBUS_HEADER_FLAG_NO_AUTO_START);
02382 }
02383
02384
02394
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga51
02395
group__DBusMessage.html#ga51
dbus_message_set_path
(
structDBusMessage.html
DBusMessage
*message,
02396
const
char
*object_path)
02397 {
02398   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02399   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o4
locked
,
group__DBusMacros.html#ga3
FALSE
);
02400   _dbus_return_val_if_fail (object_path ==
group__DBusMacros.html#ga4
NULL
||
02401                             _dbus_check_is_valid_path (object_path),
02402
group__DBusMacros.html#ga3
FALSE
);
02403
02404
return
set_or_delete_string_field (message,
02405                                      DBUS_HEADER_FIELD_PATH,
02406                                      DBUS_TYPE_OBJECT_PATH,
02407                                      object_path);
02408 }
02409
02418
const
char
*
group__DBusMessage.html#ga52
02419
group__DBusMessage.html#ga52
dbus_message_get_path
(
structDBusMessage.html
DBusMessage
*message)
02420 {
02421
const
char
*v;
02422
02423   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
02424
02425   v =
group__DBusMacros.html#ga4
NULL
;
/* in case field doesn't exist */
02426
group__DBusMarshal.html#ga77
_dbus_header_get_field_basic
(&message->
structDBusMessage.html#o1
header
,
02427                                 DBUS_HEADER_FIELD_PATH,
02428                                 DBUS_TYPE_OBJECT_PATH,
02429                                 &v);
02430
return
v;
02431 }
02432
02439
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga53
02440
group__DBusMessage.html#ga53
dbus_message_has_path
(
structDBusMessage.html
DBusMessage
*message,
02441
const
char
*path)
02442 {
02443
const
char
*msg_path;
02444   msg_path =
group__DBusMessage.html#ga52
dbus_message_get_path
(message);
02445
02446
if
(msg_path ==
group__DBusMacros.html#ga4
NULL
)
02447     {
02448
if
(path ==
group__DBusMacros.html#ga4
NULL
)
02449
return
group__DBusMacros.html#ga2
TRUE
;
02450
else
02451
return
group__DBusMacros.html#ga3
FALSE
;
02452     }
02453
02454
if
(path ==
group__DBusMacros.html#ga4
NULL
)
02455
return
group__DBusMacros.html#ga3
FALSE
;
02456
02457
if
(strcmp (msg_path, path) == 0)
02458
return
group__DBusMacros.html#ga2
TRUE
;
02459
02460
return
group__DBusMacros.html#ga3
FALSE
;
02461 }
02462
02481
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga54
02482
group__DBusMessage.html#ga54
dbus_message_get_path_decomposed
(
structDBusMessage.html
DBusMessage
*message,
02483
char
***path)
02484 {
02485
const
char
*v;
02486
02487   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02488   _dbus_return_val_if_fail (path !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02489
02490   *path =
group__DBusMacros.html#ga4
NULL
;
02491
02492   v =
group__DBusMessage.html#ga52
dbus_message_get_path
(message);
02493
if
(v !=
group__DBusMacros.html#ga4
NULL
)
02494     {
02495
if
(!
group__DBusObjectTree.html#ga25
_dbus_decompose_path
(v, strlen (v),
02496                                  path,
group__DBusMacros.html#ga4
NULL
))
02497
return
group__DBusMacros.html#ga3
FALSE
;
02498     }
02499
return
group__DBusMacros.html#ga2
TRUE
;
02500 }
02501
02512
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga55
02513
group__DBusMessage.html#ga55
dbus_message_set_interface
(
structDBusMessage.html
DBusMessage
*message,
02514
const
char
*interface)
02515 {
02516   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02517   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o4
locked
,
group__DBusMacros.html#ga3
FALSE
);
02518   _dbus_return_val_if_fail (interface ==
group__DBusMacros.html#ga4
NULL
||
02519                             _dbus_check_is_valid_interface (interface),
02520
group__DBusMacros.html#ga3
FALSE
);
02521
02522
return
set_or_delete_string_field (message,
02523                                      DBUS_HEADER_FIELD_INTERFACE,
02524                                      DBUS_TYPE_STRING,
02525                                      interface);
02526 }
02527
02538
const
char
*
group__DBusMessage.html#ga56
02539
group__DBusMessage.html#ga56
dbus_message_get_interface
(
structDBusMessage.html
DBusMessage
*message)
02540 {
02541
const
char
*v;
02542
02543   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
02544
02545   v =
group__DBusMacros.html#ga4
NULL
;
/* in case field doesn't exist */
02546
group__DBusMarshal.html#ga77
_dbus_header_get_field_basic
(&message->
structDBusMessage.html#o1
header
,
02547                                 DBUS_HEADER_FIELD_INTERFACE,
02548                                 DBUS_TYPE_STRING,
02549                                 &v);
02550
return
v;
02551 }
02552
02559
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga57
02560
group__DBusMessage.html#ga57
dbus_message_has_interface
(
structDBusMessage.html
DBusMessage
*message,
02561
const
char
*interface)
02562 {
02563
const
char
*msg_interface;
02564   msg_interface =
group__DBusMessage.html#ga56
dbus_message_get_interface
(message);
02565
02566
if
(msg_interface ==
group__DBusMacros.html#ga4
NULL
)
02567     {
02568
if
(interface ==
group__DBusMacros.html#ga4
NULL
)
02569
return
group__DBusMacros.html#ga2
TRUE
;
02570
else
02571
return
group__DBusMacros.html#ga3
FALSE
;
02572     }
02573
02574
if
(interface ==
group__DBusMacros.html#ga4
NULL
)
02575
return
group__DBusMacros.html#ga3
FALSE
;
02576
02577
if
(strcmp (msg_interface, interface) == 0)
02578
return
group__DBusMacros.html#ga2
TRUE
;
02579
02580
return
group__DBusMacros.html#ga3
FALSE
;
02581
02582 }
02583
02594
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga58
02595
group__DBusMessage.html#ga58
dbus_message_set_member
(
structDBusMessage.html
DBusMessage
*message,
02596
const
char
*member)
02597 {
02598   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02599   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o4
locked
,
group__DBusMacros.html#ga3
FALSE
);
02600   _dbus_return_val_if_fail (member ==
group__DBusMacros.html#ga4
NULL
||
02601                             _dbus_check_is_valid_member (member),
02602
group__DBusMacros.html#ga3
FALSE
);
02603
02604
return
set_or_delete_string_field (message,
02605                                      DBUS_HEADER_FIELD_MEMBER,
02606                                      DBUS_TYPE_STRING,
02607                                      member);
02608 }
02609
02618
const
char
*
group__DBusMessage.html#ga59
02619
group__DBusMessage.html#ga59
dbus_message_get_member
(
structDBusMessage.html
DBusMessage
*message)
02620 {
02621
const
char
*v;
02622
02623   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
02624
02625   v =
group__DBusMacros.html#ga4
NULL
;
/* in case field doesn't exist */
02626
group__DBusMarshal.html#ga77
_dbus_header_get_field_basic
(&message->
structDBusMessage.html#o1
header
,
02627                                 DBUS_HEADER_FIELD_MEMBER,
02628                                 DBUS_TYPE_STRING,
02629                                 &v);
02630
return
v;
02631 }
02632
02639
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga60
02640
group__DBusMessage.html#ga60
dbus_message_has_member
(
structDBusMessage.html
DBusMessage
*message,
02641
const
char
*member)
02642 {
02643
const
char
*msg_member;
02644   msg_member =
group__DBusMessage.html#ga59
dbus_message_get_member
(message);
02645
02646
if
(msg_member ==
group__DBusMacros.html#ga4
NULL
)
02647     {
02648
if
(member ==
group__DBusMacros.html#ga4
NULL
)
02649
return
group__DBusMacros.html#ga2
TRUE
;
02650
else
02651
return
group__DBusMacros.html#ga3
FALSE
;
02652     }
02653
02654
if
(member ==
group__DBusMacros.html#ga4
NULL
)
02655
return
group__DBusMacros.html#ga3
FALSE
;
02656
02657
if
(strcmp (msg_member, member) == 0)
02658
return
group__DBusMacros.html#ga2
TRUE
;
02659
02660
return
group__DBusMacros.html#ga3
FALSE
;
02661
02662 }
02663
02672
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga61
02673
group__DBusMessage.html#ga61
dbus_message_set_error_name
(
structDBusMessage.html
DBusMessage
*message,
02674
const
char
*error_name)
02675 {
02676   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02677   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o4
locked
,
group__DBusMacros.html#ga3
FALSE
);
02678   _dbus_return_val_if_fail (error_name ==
group__DBusMacros.html#ga4
NULL
||
02679                             _dbus_check_is_valid_error_name (error_name),
02680
group__DBusMacros.html#ga3
FALSE
);
02681
02682
return
set_or_delete_string_field (message,
02683                                      DBUS_HEADER_FIELD_ERROR_NAME,
02684                                      DBUS_TYPE_STRING,
02685                                      error_name);
02686 }
02687
02695
const
char
*
group__DBusMessage.html#ga62
02696
group__DBusMessage.html#ga62
dbus_message_get_error_name
(
structDBusMessage.html
DBusMessage
*message)
02697 {
02698
const
char
*v;
02699
02700   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
02701
02702   v =
group__DBusMacros.html#ga4
NULL
;
/* in case field doesn't exist */
02703
group__DBusMarshal.html#ga77
_dbus_header_get_field_basic
(&message->
structDBusMessage.html#o1
header
,
02704                                 DBUS_HEADER_FIELD_ERROR_NAME,
02705                                 DBUS_TYPE_STRING,
02706                                 &v);
02707
return
v;
02708 }
02709
02720
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga63
02721
group__DBusMessage.html#ga63
dbus_message_set_destination
(
structDBusMessage.html
DBusMessage
*message,
02722
const
char
*destination)
02723 {
02724   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02725   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o4
locked
,
group__DBusMacros.html#ga3
FALSE
);
02726   _dbus_return_val_if_fail (destination ==
group__DBusMacros.html#ga4
NULL
||
02727                             _dbus_check_is_valid_bus_name (destination),
02728
group__DBusMacros.html#ga3
FALSE
);
02729
02730
return
set_or_delete_string_field (message,
02731                                      DBUS_HEADER_FIELD_DESTINATION,
02732                                      DBUS_TYPE_STRING,
02733                                      destination);
02734 }
02735
02742
const
char
*
group__DBusMessage.html#ga64
02743
group__DBusMessage.html#ga64
dbus_message_get_destination
(
structDBusMessage.html
DBusMessage
*message)
02744 {
02745
const
char
*v;
02746
02747   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
02748
02749   v =
group__DBusMacros.html#ga4
NULL
;
/* in case field doesn't exist */
02750
group__DBusMarshal.html#ga77
_dbus_header_get_field_basic
(&message->
structDBusMessage.html#o1
header
,
02751                                 DBUS_HEADER_FIELD_DESTINATION,
02752                                 DBUS_TYPE_STRING,
02753                                 &v);
02754
return
v;
02755 }
02756
02764
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga65
02765
group__DBusMessage.html#ga65
dbus_message_set_sender
(
structDBusMessage.html
DBusMessage
*message,
02766
const
char
*sender)
02767 {
02768   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02769   _dbus_return_val_if_fail (!message->
structDBusMessage.html#o4
locked
,
group__DBusMacros.html#ga3
FALSE
);
02770   _dbus_return_val_if_fail (sender ==
group__DBusMacros.html#ga4
NULL
||
02771                             _dbus_check_is_valid_bus_name (sender),
02772
group__DBusMacros.html#ga3
FALSE
);
02773
02774
return
set_or_delete_string_field (message,
02775                                      DBUS_HEADER_FIELD_SENDER,
02776                                      DBUS_TYPE_STRING,
02777                                      sender);
02778 }
02779
02788
const
char
*
group__DBusMessage.html#ga66
02789
group__DBusMessage.html#ga66
dbus_message_get_sender
(
structDBusMessage.html
DBusMessage
*message)
02790 {
02791
const
char
*v;
02792
02793   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
02794
02795   v =
group__DBusMacros.html#ga4
NULL
;
/* in case field doesn't exist */
02796
group__DBusMarshal.html#ga77
_dbus_header_get_field_basic
(&message->
structDBusMessage.html#o1
header
,
02797                                 DBUS_HEADER_FIELD_SENDER,
02798                                 DBUS_TYPE_STRING,
02799                                 &v);
02800
return
v;
02801 }
02802
02818
const
char
*
group__DBusMessage.html#ga67
02819
group__DBusMessage.html#ga67
dbus_message_get_signature
(
structDBusMessage.html
DBusMessage
*message)
02820 {
02821
const
structDBusString.html
DBusString
*type_str;
02822
int
type_pos;
02823
02824   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
02825
02826   get_const_signature (&message->
structDBusMessage.html#o1
header
, &type_str, &type_pos);
02827
02828
return
_dbus_string_get_const_data_len (type_str, type_pos, 0);
02829 }
02830
02831
static
group__DBusTypes.html#ga2
dbus_bool_t
02832 _dbus_message_has_type_interface_member (
structDBusMessage.html
DBusMessage
*message,
02833
int
type,
02834
const
char
*interface,
02835
const
char
*member)
02836 {
02837
const
char
*n;
02838
02839
group__DBusInternalsUtils.html#ga130
_dbus_assert
(message !=
group__DBusMacros.html#ga4
NULL
);
02840
group__DBusInternalsUtils.html#ga130
_dbus_assert
(interface !=
group__DBusMacros.html#ga4
NULL
);
02841
group__DBusInternalsUtils.html#ga130
_dbus_assert
(member !=
group__DBusMacros.html#ga4
NULL
);
02842
02843
if
(
group__DBusMessage.html#ga21
dbus_message_get_type
(message) != type)
02844
return
group__DBusMacros.html#ga3
FALSE
;
02845
02846
/* Optimize by checking the short member name first
02847
* instead of the longer interface name
02848
*/
02849
02850   n =
group__DBusMessage.html#ga59
dbus_message_get_member
(message);
02851
02852
if
(n && strcmp (n, member) == 0)
02853     {
02854       n =
group__DBusMessage.html#ga56
dbus_message_get_interface
(message);
02855
02856
if
(n ==
group__DBusMacros.html#ga4
NULL
|| strcmp (n, interface) == 0)
02857
return
group__DBusMacros.html#ga2
TRUE
;
02858     }
02859
02860
return
group__DBusMacros.html#ga3
FALSE
;
02861 }
02862
02877
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga69
02878
group__DBusMessage.html#ga69
dbus_message_is_method_call
(
structDBusMessage.html
DBusMessage
*message,
02879
const
char
*interface,
02880
const
char
*method)
02881 {
02882   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02883   _dbus_return_val_if_fail (interface !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02884   _dbus_return_val_if_fail (method !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02885
/* don't check that interface/method are valid since it would be
02886
* expensive, and not catch many common errors
02887
*/
02888
02889
return
_dbus_message_has_type_interface_member (message,
02890                                                   DBUS_MESSAGE_TYPE_METHOD_CALL,
02891                                                   interface, method);
02892 }
02893
02907
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga70
02908
group__DBusMessage.html#ga70
dbus_message_is_signal
(
structDBusMessage.html
DBusMessage
*message,
02909
const
char
*interface,
02910
const
char
*signal_name)
02911 {
02912   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02913   _dbus_return_val_if_fail (interface !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02914   _dbus_return_val_if_fail (signal_name !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02915
/* don't check that interface/name are valid since it would be
02916
* expensive, and not catch many common errors
02917
*/
02918
02919
return
_dbus_message_has_type_interface_member (message,
02920                                                   DBUS_MESSAGE_TYPE_SIGNAL,
02921                                                   interface, signal_name);
02922 }
02923
02934
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga71
02935
group__DBusMessage.html#ga71
dbus_message_is_error
(
structDBusMessage.html
DBusMessage
*message,
02936
const
char
*error_name)
02937 {
02938
const
char
*n;
02939
02940   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02941   _dbus_return_val_if_fail (error_name !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02942
/* don't check that error_name is valid since it would be expensive,
02943
* and not catch many common errors
02944
*/
02945
02946
if
(
group__DBusMessage.html#ga21
dbus_message_get_type
(message) != DBUS_MESSAGE_TYPE_ERROR)
02947
return
group__DBusMacros.html#ga3
FALSE
;
02948
02949   n =
group__DBusMessage.html#ga62
dbus_message_get_error_name
(message);
02950
02951
if
(n && strcmp (n, error_name) == 0)
02952
return
group__DBusMacros.html#ga2
TRUE
;
02953
else
02954
return
group__DBusMacros.html#ga3
FALSE
;
02955 }
02956
02967
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga72
02968
group__DBusMessage.html#ga72
dbus_message_has_destination
(
structDBusMessage.html
DBusMessage
*message,
02969
const
char
*name)
02970 {
02971
const
char
*s;
02972
02973   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02974   _dbus_return_val_if_fail (name !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
02975
/* don't check that name is valid since it would be expensive, and
02976
* not catch many common errors
02977
*/
02978
02979   s =
group__DBusMessage.html#ga64
dbus_message_get_destination
(message);
02980
02981
if
(s && strcmp (s, name) == 0)
02982
return
group__DBusMacros.html#ga2
TRUE
;
02983
else
02984
return
group__DBusMacros.html#ga3
FALSE
;
02985 }
02986
03002
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga73
03003
group__DBusMessage.html#ga73
dbus_message_has_sender
(
structDBusMessage.html
DBusMessage
*message,
03004
const
char
*name)
03005 {
03006
const
char
*s;
03007
03008   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
03009   _dbus_return_val_if_fail (name !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
03010
/* don't check that name is valid since it would be expensive, and
03011
* not catch many common errors
03012
*/
03013
03014   s =
group__DBusMessage.html#ga66
dbus_message_get_sender
(message);
03015
03016
if
(s && strcmp (s, name) == 0)
03017
return
group__DBusMacros.html#ga2
TRUE
;
03018
else
03019
return
group__DBusMacros.html#ga3
FALSE
;
03020 }
03021
03031
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga74
03032
group__DBusMessage.html#ga74
dbus_message_has_signature
(
structDBusMessage.html
DBusMessage
*message,
03033
const
char
*signature)
03034 {
03035
const
char
*s;
03036
03037   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
03038   _dbus_return_val_if_fail (signature !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
03039
/* don't check that signature is valid since it would be expensive,
03040
* and not catch many common errors
03041
*/
03042
03043   s =
group__DBusMessage.html#ga67
dbus_message_get_signature
(message);
03044
03045
if
(s && strcmp (s, signature) == 0)
03046
return
group__DBusMacros.html#ga2
TRUE
;
03047
else
03048
return
group__DBusMacros.html#ga3
FALSE
;
03049 }
03050
03073
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessage.html#ga75
03074
group__DBusMessage.html#ga75
dbus_set_error_from_message
(
structDBusError.html
DBusError
*error,
03075
structDBusMessage.html
DBusMessage
*message)
03076 {
03077
const
char
*str;
03078
03079   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
03080   _dbus_return_val_if_error_is_set (error,
group__DBusMacros.html#ga3
FALSE
);
03081
03082
if
(
group__DBusMessage.html#ga21
dbus_message_get_type
(message) != DBUS_MESSAGE_TYPE_ERROR)
03083
return
group__DBusMacros.html#ga3
FALSE
;
03084
03085   str =
group__DBusMacros.html#ga4
NULL
;
03086
group__DBusMessage.html#ga24
dbus_message_get_args
(message,
group__DBusMacros.html#ga4
NULL
,
03087                          DBUS_TYPE_STRING, &str,
03088                          DBUS_TYPE_INVALID);
03089
03090
group__DBusErrors.html#ga6
dbus_set_error
(error,
group__DBusMessage.html#ga62
dbus_message_get_error_name
(message),
03091                   str ?
"%s"
:
group__DBusMacros.html#ga4
NULL
, str);
03092
03093
return
group__DBusMacros.html#ga2
TRUE
;
03094 }
03095
group__DBusMessageInternals.html#ga35
03114
#define INITIAL_LOADER_DATA_LEN 32
03115
03122
structDBusMessageLoader.html
DBusMessageLoader
*
group__DBusMessageInternals.html#ga13
03123
group__DBusMessageInternals.html#ga13
_dbus_message_loader_new
(
void
)
03124 {
03125
structDBusMessageLoader.html
DBusMessageLoader
*loader;
03126
03127   loader =
group__DBusMemory.html#ga7
dbus_new0
(
structDBusMessageLoader.html
DBusMessageLoader
, 1);
03128
if
(loader ==
group__DBusMacros.html#ga4
NULL
)
03129
return
group__DBusMacros.html#ga4
NULL
;
03130
03131   loader->
structDBusMessageLoader.html#o0
refcount
= 1;
03132
03133   loader->
structDBusMessageLoader.html#o5
corrupted
=
group__DBusMacros.html#ga3
FALSE
;
03134   loader->
structDBusMessageLoader.html#o6
corruption_reason
= DBUS_VALID;
03135
03136
/* this can be configured by the app, but defaults to the protocol max */
03137   loader->
structDBusMessageLoader.html#o3
max_message_size
= DBUS_MAXIMUM_MESSAGE_LENGTH;
03138
03139
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&loader->
structDBusMessageLoader.html#o1
data
))
03140     {
03141
group__DBusMemory.html#ga3
dbus_free
(loader);
03142
return
group__DBusMacros.html#ga4
NULL
;
03143     }
03144
03145
/* preallocate the buffer for speed, ignore failure */
03146
group__DBusString.html#ga21
_dbus_string_set_length
(&loader->
structDBusMessageLoader.html#o1
data
,
group__DBusMessageInternals.html#ga35
INITIAL_LOADER_DATA_LEN
);
03147
group__DBusString.html#ga21
_dbus_string_set_length
(&loader->
structDBusMessageLoader.html#o1
data
, 0);
03148
03149
return
loader;
03150 }
03151
03158
structDBusMessageLoader.html
DBusMessageLoader
*
group__DBusMessageInternals.html#ga14
03159
group__DBusMessageInternals.html#ga14
_dbus_message_loader_ref
(
structDBusMessageLoader.html
DBusMessageLoader
*loader)
03160 {
03161   loader->
structDBusMessageLoader.html#o0
refcount
+= 1;
03162
03163
return
loader;
03164 }
03165
03172
void
group__DBusMessageInternals.html#ga15
03173
group__DBusMessageInternals.html#ga15
_dbus_message_loader_unref
(
structDBusMessageLoader.html
DBusMessageLoader
*loader)
03174 {
03175   loader->
structDBusMessageLoader.html#o0
refcount
-= 1;
03176
if
(loader->
structDBusMessageLoader.html#o0
refcount
== 0)
03177     {
03178
group__DBusList.html#ga22
_dbus_list_foreach
(&loader->
structDBusMessageLoader.html#o2
messages
,
03179                           (
group__DBusInternalsUtils.html#ga161
DBusForeachFunction
)
group__DBusMessage.html#ga20
dbus_message_unref
,
03180
group__DBusMacros.html#ga4
NULL
);
03181
group__DBusList.html#ga12
_dbus_list_clear
(&loader->
structDBusMessageLoader.html#o2
messages
);
03182
group__DBusString.html#ga9
_dbus_string_free
(&loader->
structDBusMessageLoader.html#o1
data
);
03183
group__DBusMemory.html#ga3
dbus_free
(loader);
03184     }
03185 }
03186
03205
void
group__DBusMessageInternals.html#ga16
03206
group__DBusMessageInternals.html#ga16
_dbus_message_loader_get_buffer
(
structDBusMessageLoader.html
DBusMessageLoader
*loader,
03207
structDBusString.html
DBusString
**buffer)
03208 {
03209
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!loader->
structDBusMessageLoader.html#o4
buffer_outstanding
);
03210
03211   *buffer = &loader->
structDBusMessageLoader.html#o1
data
;
03212
03213   loader->
structDBusMessageLoader.html#o4
buffer_outstanding
=
group__DBusMacros.html#ga2
TRUE
;
03214 }
03215
03226
void
group__DBusMessageInternals.html#ga17
03227
group__DBusMessageInternals.html#ga17
_dbus_message_loader_return_buffer
(
structDBusMessageLoader.html
DBusMessageLoader
*loader,
03228
structDBusString.html
DBusString
*buffer,
03229
int
bytes_read)
03230 {
03231
group__DBusInternalsUtils.html#ga130
_dbus_assert
(loader->
structDBusMessageLoader.html#o4
buffer_outstanding
);
03232
group__DBusInternalsUtils.html#ga130
_dbus_assert
(buffer == &loader->
structDBusMessageLoader.html#o1
data
);
03233
03234   loader->
structDBusMessageLoader.html#o4
buffer_outstanding
=
group__DBusMacros.html#ga3
FALSE
;
03235 }
03236
03237
/*
03238
* FIXME when we move the header out of the buffer, that memmoves all
03239
* buffered messages. Kind of crappy.
03240
*
03241
* Also we copy the header and body, which is kind of crappy.  To
03242
* avoid this, we have to allow header and body to be in a single
03243
* memory block, which is good for messages we read and bad for
03244
* messages we are creating. But we could move_len() the buffer into
03245
* this single memory block, and move_len() will just swap the buffers
03246
* if you're moving the entire buffer replacing the dest string.
03247
*
03248
* We could also have the message loader tell the transport how many
03249
* bytes to read; so it would first ask for some arbitrary number like
03250
* 256, then if the message was incomplete it would use the
03251
* header/body len to ask for exactly the size of the message (or
03252
* blocks the size of a typical kernel buffer for the socket). That
03253
* way we don't get trailing bytes in the buffer that have to be
03254
* memmoved. Though I suppose we also don't have a chance of reading a
03255
* bunch of small messages at once, so the optimization may be stupid.
03256
*
03257
* Another approach would be to keep a "start" index into
03258
* loader->data and only delete it occasionally, instead of after
03259
* each message is loaded.
03260
*
03261
* load_message() returns FALSE if not enough memory OR the loader was corrupted
03262
*/
03263
static
group__DBusTypes.html#ga2
dbus_bool_t
03264 load_message (
structDBusMessageLoader.html
DBusMessageLoader
*loader,
03265
structDBusMessage.html
DBusMessage
*message,
03266
int
byte_order,
03267
int
fields_array_len,
03268
int
header_len,
03269
int
body_len)
03270 {
03271
group__DBusTypes.html#ga2
dbus_bool_t
oom;
03272   DBusValidity validity;
03273
const
structDBusString.html
DBusString
*type_str;
03274
int
type_pos;
03275   DBusValidationMode mode;
03276
03277   mode = DBUS_VALIDATION_MODE_DATA_IS_UNTRUSTED;
03278
03279   oom =
group__DBusMacros.html#ga3
FALSE
;
03280
03281
#if 0
03282
group__DBusMarshal.html#ga44
_dbus_verbose_bytes_of_string
(&loader->
structDBusMessageLoader.html#o1
data
, 0, header_len
/* + body_len */
);
03283
#endif
03284
03285
/* 1. VALIDATE AND COPY OVER HEADER */
03286
group__DBusInternalsUtils.html#ga130
_dbus_assert
(_dbus_string_get_length (&message->
structDBusMessage.html#o1
header
.
structDBusHeader.html#o0
data
) == 0);
03287
group__DBusInternalsUtils.html#ga130
_dbus_assert
((header_len + body_len) <= _dbus_string_get_length (&loader->
structDBusMessageLoader.html#o1
data
));
03288
03289
if
(!
group__DBusMarshal.html#ga73
_dbus_header_load
(&message->
structDBusMessage.html#o1
header
,
03290                           mode,
03291                           &validity,
03292                           byte_order,
03293                           fields_array_len,
03294                           header_len,
03295                           body_len,
03296                           &loader->
structDBusMessageLoader.html#o1
data
, 0,
03297                           _dbus_string_get_length (&loader->
structDBusMessageLoader.html#o1
data
)))
03298     {
03299       _dbus_verbose (
"Failed to load header for new message code %d\n"
, validity);
03300
03301
/* assert here so we can catch any code that still uses DBUS_VALID to indicate
03302
oom errors.  They should use DBUS_VALIDITY_UNKNOWN_OOM_ERROR instead */
03303
group__DBusInternalsUtils.html#ga130
_dbus_assert
(validity != DBUS_VALID);
03304
03305
if
(validity == DBUS_VALIDITY_UNKNOWN_OOM_ERROR)
03306         oom =
group__DBusMacros.html#ga2
TRUE
;
03307
else
03308         {
03309           loader->
structDBusMessageLoader.html#o5
corrupted
=
group__DBusMacros.html#ga2
TRUE
;
03310           loader->
structDBusMessageLoader.html#o6
corruption_reason
= validity;
03311         }
03312
goto
failed;
03313     }
03314
03315
group__DBusInternalsUtils.html#ga130
_dbus_assert
(validity == DBUS_VALID);
03316
03317   message->
structDBusMessage.html#o3
byte_order
= byte_order;
03318
03319
/* 2. VALIDATE BODY */
03320
if
(mode != DBUS_VALIDATION_MODE_WE_TRUST_THIS_DATA_ABSOLUTELY)
03321     {
03322       get_const_signature (&message->
structDBusMessage.html#o1
header
, &type_str, &type_pos);
03323
03324
/* Because the bytes_remaining arg is NULL, this validates that the
03325
* body is the right length
03326
*/
03327       validity =
group__DBusMarshal.html#ga154
_dbus_validate_body_with_reason
(type_str,
03328                                                   type_pos,
03329                                                   byte_order,
03330
group__DBusMacros.html#ga4
NULL
,
03331                                                   &loader->
structDBusMessageLoader.html#o1
data
,
03332                                                   header_len,
03333                                                   body_len);
03334
if
(validity != DBUS_VALID)
03335         {
03336           _dbus_verbose (
"Failed to validate message body code %d\n"
, validity);
03337
03338           loader->
structDBusMessageLoader.html#o5
corrupted
=
group__DBusMacros.html#ga2
TRUE
;
03339           loader->
structDBusMessageLoader.html#o6
corruption_reason
= validity;
03340
03341
goto
failed;
03342         }
03343     }
03344
03345
/* 3. COPY OVER BODY AND QUEUE MESSAGE */
03346
03347
if
(!
group__DBusList.html#ga2
_dbus_list_append
(&loader->
structDBusMessageLoader.html#o2
messages
, message))
03348     {
03349       _dbus_verbose (
"Failed to append new message to loader queue\n"
);
03350       oom =
group__DBusMacros.html#ga2
TRUE
;
03351
goto
failed;
03352     }
03353
03354
group__DBusInternalsUtils.html#ga130
_dbus_assert
(_dbus_string_get_length (&message->
structDBusMessage.html#o2
body
) == 0);
03355
group__DBusInternalsUtils.html#ga130
_dbus_assert
(_dbus_string_get_length (&loader->
structDBusMessageLoader.html#o1
data
) >=
03356                 (header_len + body_len));
03357
03358
if
(!
group__DBusString.html#ga42
_dbus_string_copy_len
(&loader->
structDBusMessageLoader.html#o1
data
, header_len, body_len, &message->
structDBusMessage.html#o2
body
, 0))
03359     {
03360       _dbus_verbose (
"Failed to move body into new message\n"
);
03361       oom =
group__DBusMacros.html#ga2
TRUE
;
03362
goto
failed;
03363     }
03364
03365
group__DBusString.html#ga37
_dbus_string_delete
(&loader->
structDBusMessageLoader.html#o1
data
, 0, header_len + body_len);
03366
03367
group__DBusInternalsUtils.html#ga130
_dbus_assert
(_dbus_string_get_length (&message->
structDBusMessage.html#o1
header
.
structDBusHeader.html#o0
data
) == header_len);
03368
group__DBusInternalsUtils.html#ga130
_dbus_assert
(_dbus_string_get_length (&message->
structDBusMessage.html#o2
body
) == body_len);
03369
03370   _dbus_verbose (
"Loaded message %p\n"
, message);
03371
03372
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!oom);
03373
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!loader->
structDBusMessageLoader.html#o5
corrupted
);
03374
group__DBusInternalsUtils.html#ga130
_dbus_assert
(loader->
structDBusMessageLoader.html#o2
messages
!=
group__DBusMacros.html#ga4
NULL
);
03375
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusList.html#ga9
_dbus_list_find_last
(&loader->
structDBusMessageLoader.html#o2
messages
, message) !=
group__DBusMacros.html#ga4
NULL
);
03376
03377
return
group__DBusMacros.html#ga2
TRUE
;
03378
03379  failed:
03380
03381
/* Clean up */
03382
03383
/* does nothing if the message isn't in the list */
03384
group__DBusList.html#ga8
_dbus_list_remove_last
(&loader->
structDBusMessageLoader.html#o2
messages
, message);
03385
03386
if
(oom)
03387
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!loader->
structDBusMessageLoader.html#o5
corrupted
);
03388
else
03389
group__DBusInternalsUtils.html#ga130
_dbus_assert
(loader->
structDBusMessageLoader.html#o5
corrupted
);
03390
03391
group__DBusMarshal.html#ga44
_dbus_verbose_bytes_of_string
(&loader->
structDBusMessageLoader.html#o1
data
, 0, _dbus_string_get_length (&loader->
structDBusMessageLoader.html#o1
data
));
03392
03393
return
group__DBusMacros.html#ga3
FALSE
;
03394 }
03395
03410
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessageInternals.html#ga19
03411
group__DBusMessageInternals.html#ga19
_dbus_message_loader_queue_messages
(
structDBusMessageLoader.html
DBusMessageLoader
*loader)
03412 {
03413
while
(!loader->
structDBusMessageLoader.html#o5
corrupted
&&
03414          _dbus_string_get_length (&loader->
structDBusMessageLoader.html#o1
data
) >= DBUS_MINIMUM_HEADER_SIZE)
03415     {
03416       DBusValidity validity;
03417
int
byte_order, fields_array_len, header_len, body_len;
03418
03419
if
(
group__DBusMarshal.html#ga70
_dbus_header_have_message_untrusted
(loader->
structDBusMessageLoader.html#o3
max_message_size
,
03420                                                &validity,
03421                                                &byte_order,
03422                                                &fields_array_len,
03423                                                &header_len,
03424                                                &body_len,
03425                                                &loader->
structDBusMessageLoader.html#o1
data
, 0,
03426                                                _dbus_string_get_length (&loader->
structDBusMessageLoader.html#o1
data
)))
03427         {
03428
structDBusMessage.html
DBusMessage
*message;
03429
03430
group__DBusInternalsUtils.html#ga130
_dbus_assert
(validity == DBUS_VALID);
03431
03432           message = dbus_message_new_empty_header ();
03433
if
(message ==
group__DBusMacros.html#ga4
NULL
)
03434
return
group__DBusMacros.html#ga3
FALSE
;
03435
03436
if
(!load_message (loader, message,
03437                              byte_order, fields_array_len,
03438                              header_len, body_len))
03439             {
03440
group__DBusMessage.html#ga20
dbus_message_unref
(message);
03441
/* load_message() returns false if corrupted or OOM; if
03442
* corrupted then return TRUE for not OOM
03443
*/
03444
return
loader->corrupted;
03445             }
03446
03447
group__DBusInternalsUtils.html#ga130
_dbus_assert
(loader->messages !=
group__DBusMacros.html#ga4
NULL
);
03448
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusList.html#ga9
_dbus_list_find_last
(&loader->messages, message) !=
group__DBusMacros.html#ga4
NULL
);
03449         }
03450
else
03451         {
03452           _dbus_verbose (
"Initial peek at header says we don't have a whole message yet, or data broken with invalid code %d\n"
,
03453                          validity);
03454
if
(validity != DBUS_VALID)
03455             {
03456               loader->
structDBusMessageLoader.html#o5
corrupted
=
group__DBusMacros.html#ga2
TRUE
;
03457               loader->
structDBusMessageLoader.html#o6
corruption_reason
= validity;
03458             }
03459
return
group__DBusMacros.html#ga2
TRUE
;
03460         }
03461     }
03462
03463
return
group__DBusMacros.html#ga2
TRUE
;
03464 }
03465
03473
structDBusMessage.html
DBusMessage
*
group__DBusMessageInternals.html#ga20
03474
group__DBusMessageInternals.html#ga20
_dbus_message_loader_peek_message
(
structDBusMessageLoader.html
DBusMessageLoader
*loader)
03475 {
03476
if
(loader->
structDBusMessageLoader.html#o2
messages
)
03477
return
loader->
structDBusMessageLoader.html#o2
messages
->
structDBusList.html#o2
data
;
03478
else
03479
return
group__DBusMacros.html#ga4
NULL
;
03480 }
03481
03490
structDBusMessage.html
DBusMessage
*
group__DBusMessageInternals.html#ga21
03491
group__DBusMessageInternals.html#ga21
_dbus_message_loader_pop_message
(
structDBusMessageLoader.html
DBusMessageLoader
*loader)
03492 {
03493
return
group__DBusList.html#ga18
_dbus_list_pop_first
(&loader->
structDBusMessageLoader.html#o2
messages
);
03494 }
03495
03504
structDBusList.html
DBusList
*
group__DBusMessageInternals.html#ga22
03505
group__DBusMessageInternals.html#ga22
_dbus_message_loader_pop_message_link
(
structDBusMessageLoader.html
DBusMessageLoader
*loader)
03506 {
03507
return
group__DBusList.html#ga17
_dbus_list_pop_first_link
(&loader->
structDBusMessageLoader.html#o2
messages
);
03508 }
03509
03516
void
group__DBusMessageInternals.html#ga23
03517
group__DBusMessageInternals.html#ga23
_dbus_message_loader_putback_message_link
(
structDBusMessageLoader.html
DBusMessageLoader
*loader,
03518
structDBusList.html
DBusList
*link)
03519 {
03520
group__DBusList.html#ga5
_dbus_list_prepend_link
(&loader->
structDBusMessageLoader.html#o2
messages
, link);
03521 }
03522
03532
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessageInternals.html#ga24
03533
group__DBusMessageInternals.html#ga24
_dbus_message_loader_get_is_corrupted
(
structDBusMessageLoader.html
DBusMessageLoader
*loader)
03534 {
03535
group__DBusInternalsUtils.html#ga130
_dbus_assert
((loader->
structDBusMessageLoader.html#o5
corrupted
&& loader->
structDBusMessageLoader.html#o6
corruption_reason
!= DBUS_VALID) ||
03536                 (!loader->
structDBusMessageLoader.html#o5
corrupted
&& loader->
structDBusMessageLoader.html#o6
corruption_reason
== DBUS_VALID));
03537
return
loader->
structDBusMessageLoader.html#o5
corrupted
;
03538 }
03539
03546
void
group__DBusMessageInternals.html#ga25
03547
group__DBusMessageInternals.html#ga25
_dbus_message_loader_set_max_message_size
(
structDBusMessageLoader.html
DBusMessageLoader
*loader,
03548
long
size)
03549 {
03550
if
(size > DBUS_MAXIMUM_MESSAGE_LENGTH)
03551     {
03552       _dbus_verbose (
"clamping requested max message size %ld to %d\n"
,
03553                      size, DBUS_MAXIMUM_MESSAGE_LENGTH);
03554       size = DBUS_MAXIMUM_MESSAGE_LENGTH;
03555     }
03556   loader->
structDBusMessageLoader.html#o3
max_message_size
= size;
03557 }
03558
03565
long
group__DBusMessageInternals.html#ga26
03566
group__DBusMessageInternals.html#ga26
_dbus_message_loader_get_max_message_size
(
structDBusMessageLoader.html
DBusMessageLoader
*loader)
03567 {
03568
return
loader->
structDBusMessageLoader.html#o3
max_message_size
;
03569 }
03570
03571
static
structDBusDataSlotAllocator.html
DBusDataSlotAllocator
slot_allocator;
03572
group__DBusInternalsUtils.html#ga146
_DBUS_DEFINE_GLOBAL_LOCK
(message_slots);
03573
03588
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessageInternals.html#ga27
03589
group__DBusMessageInternals.html#ga27
dbus_message_allocate_data_slot
(
group__DBusTypes.html#ga4
dbus_int32_t
*slot_p)
03590 {
03591
return
group__DBusDataSlot.html#ga1
_dbus_data_slot_allocator_alloc
(&slot_allocator,
03592
group__DBusInternalsUtils.html#ga145
_DBUS_LOCK_NAME
(message_slots),
03593                                           slot_p);
03594 }
03595
03607
void
group__DBusMessageInternals.html#ga28
03608
group__DBusMessageInternals.html#ga28
dbus_message_free_data_slot
(
group__DBusTypes.html#ga4
dbus_int32_t
*slot_p)
03609 {
03610   _dbus_return_if_fail (*slot_p >= 0);
03611
03612
group__DBusDataSlot.html#ga2
_dbus_data_slot_allocator_free
(&slot_allocator, slot_p);
03613 }
03614
03628
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusMessageInternals.html#ga29
03629
group__DBusMessageInternals.html#ga29
dbus_message_set_data
(
structDBusMessage.html
DBusMessage
*message,
03630
group__DBusTypes.html#ga4
dbus_int32_t
slot,
03631
void
*data,
03632
group__DBusMemory.html#ga8
DBusFreeFunction
free_data_func)
03633 {
03634
group__DBusMemory.html#ga8
DBusFreeFunction
old_free_func;
03635
void
*old_data;
03636
group__DBusTypes.html#ga2
dbus_bool_t
retval;
03637
03638   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga3
FALSE
);
03639   _dbus_return_val_if_fail (slot >= 0,
group__DBusMacros.html#ga3
FALSE
);
03640
03641   retval =
group__DBusDataSlot.html#ga4
_dbus_data_slot_list_set
(&slot_allocator,
03642                                      &message->
structDBusMessage.html#o9
slot_list
,
03643                                      slot, data, free_data_func,
03644                                      &old_free_func, &old_data);
03645
03646
if
(retval)
03647     {
03648
/* Do the actual free outside the message lock */
03649
if
(old_free_func)
03650         (* old_free_func) (old_data);
03651     }
03652
03653
return
retval;
03654 }
03655
03664
void
*
group__DBusMessageInternals.html#ga30
03665
group__DBusMessageInternals.html#ga30
dbus_message_get_data
(
structDBusMessage.html
DBusMessage
*message,
03666
group__DBusTypes.html#ga4
dbus_int32_t
slot)
03667 {
03668
void
*res;
03669
03670   _dbus_return_val_if_fail (message !=
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
03671
03672   res =
group__DBusDataSlot.html#ga5
_dbus_data_slot_list_get
(&slot_allocator,
03673                                   &message->
structDBusMessage.html#o9
slot_list
,
03674                                   slot);
03675
03676
return
res;
03677 }
03678
03692
int
group__DBusMessageInternals.html#ga31
03693
group__DBusMessageInternals.html#ga31
dbus_message_type_from_string
(
const
char
*type_str)
03694 {
03695
if
(strcmp (type_str,
"method_call"
) == 0)
03696
return
DBUS_MESSAGE_TYPE_METHOD_CALL;
03697
if
(strcmp (type_str,
"method_return"
) == 0)
03698
return
DBUS_MESSAGE_TYPE_METHOD_RETURN;
03699
else
if
(strcmp (type_str,
"signal"
) == 0)
03700
return
DBUS_MESSAGE_TYPE_SIGNAL;
03701
else
if
(strcmp (type_str,
"error"
) == 0)
03702
return
DBUS_MESSAGE_TYPE_ERROR;
03703
else
03704
return
DBUS_MESSAGE_TYPE_INVALID;
03705 }
03706
03720
const
char
*
group__DBusMessageInternals.html#ga32
03721
group__DBusMessageInternals.html#ga32
dbus_message_type_to_string
(
int
type)
03722 {
03723
switch
(type)
03724     {
03725
case
DBUS_MESSAGE_TYPE_METHOD_CALL:
03726
return
"method_call"
;
03727
case
DBUS_MESSAGE_TYPE_METHOD_RETURN:
03728
return
"method_return"
;
03729
case
DBUS_MESSAGE_TYPE_SIGNAL:
03730
return
"signal"
;
03731
case
DBUS_MESSAGE_TYPE_ERROR:
03732
return
"error"
;
03733
default
:
03734
return
"invalid"
;
03735     }
03736 }
03737
03740
/* tests in dbus-message-util.c */
Generated on Tue Sep 13 01:28:07 2005 for D-BUS by
http://www.doxygen.org/index.html
doxygen
1.4.4
