27#ifndef DBUS_MARSHAL_BASIC_H 
   28#define DBUS_MARSHAL_BASIC_H 
   34#include <dbus/dbus-protocol.h> 
   35#include <dbus/dbus-types.h> 
   36#include <dbus/dbus-arch-deps.h> 
   37#include <dbus/dbus-string.h> 
   40#define DBUS_COMPILER_BYTE_ORDER DBUS_BIG_ENDIAN 
   42#define DBUS_COMPILER_BYTE_ORDER DBUS_LITTLE_ENDIAN 
   46#define DBUS_UINT16_SWAP_LE_BE_CONSTANT(val) bswap_16(val) 
   47#define DBUS_UINT32_SWAP_LE_BE_CONSTANT(val) bswap_32(val) 
   50#define DBUS_UINT16_SWAP_LE_BE_CONSTANT(val)    ((dbus_uint16_t) (      \ 
   51    (dbus_uint16_t) ((dbus_uint16_t) (val) >> 8) |                      \ 
   52    (dbus_uint16_t) ((dbus_uint16_t) (val) << 8))) 
   54#define DBUS_UINT32_SWAP_LE_BE_CONSTANT(val)    ((dbus_uint32_t) (      \ 
   55    (((dbus_uint32_t) (val) & (dbus_uint32_t) 0x000000ffU) << 24) |     \ 
   56    (((dbus_uint32_t) (val) & (dbus_uint32_t) 0x0000ff00U) <<  8) |     \ 
   57    (((dbus_uint32_t) (val) & (dbus_uint32_t) 0x00ff0000U) >>  8) |     \ 
   58    (((dbus_uint32_t) (val) & (dbus_uint32_t) 0xff000000U) >> 24))) 
   63#define DBUS_UINT64_SWAP_LE_BE_CONSTANT(val) bswap_64(val) 
   66#define DBUS_UINT64_SWAP_LE_BE_CONSTANT(val)    ((dbus_uint64_t) (              \ 
   67      (((dbus_uint64_t) (val) &                                                 \ 
   68        (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00000000000000ff)) << 56) |    \ 
   69      (((dbus_uint64_t) (val) &                                                 \ 
   70        (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x000000000000ff00)) << 40) |    \ 
   71      (((dbus_uint64_t) (val) &                                                 \ 
   72        (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x0000000000ff0000)) << 24) |    \ 
   73      (((dbus_uint64_t) (val) &                                                 \ 
   74        (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00000000ff000000)) <<  8) |    \ 
   75      (((dbus_uint64_t) (val) &                                                 \ 
   76        (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x000000ff00000000)) >>  8) |    \ 
   77      (((dbus_uint64_t) (val) &                                                 \ 
   78        (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x0000ff0000000000)) >> 24) |    \ 
   79      (((dbus_uint64_t) (val) &                                                 \ 
   80        (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00ff000000000000)) >> 40) |    \ 
   81      (((dbus_uint64_t) (val) &                                                 \ 
   82        (dbus_uint64_t) DBUS_UINT64_CONSTANT (0xff00000000000000)) >> 56))) 
   86#define DBUS_UINT16_SWAP_LE_BE(val) (DBUS_UINT16_SWAP_LE_BE_CONSTANT (val)) 
   87#define DBUS_INT16_SWAP_LE_BE(val)  ((dbus_int16_t)DBUS_UINT16_SWAP_LE_BE_CONSTANT (val)) 
   89#define DBUS_UINT32_SWAP_LE_BE(val) (DBUS_UINT32_SWAP_LE_BE_CONSTANT (val)) 
   90#define DBUS_INT32_SWAP_LE_BE(val)  ((dbus_int32_t)DBUS_UINT32_SWAP_LE_BE_CONSTANT (val)) 
   92#define DBUS_UINT64_SWAP_LE_BE(val) (DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) 
   93#define DBUS_INT64_SWAP_LE_BE(val)  ((dbus_int64_t)DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) 
   97#  define DBUS_INT16_TO_BE(val) ((dbus_int16_t) (val)) 
   98#  define DBUS_UINT16_TO_BE(val)        ((dbus_uint16_t) (val)) 
   99#  define DBUS_INT16_TO_LE(val) (DBUS_INT16_SWAP_LE_BE (val)) 
  100#  define DBUS_UINT16_TO_LE(val)        (DBUS_UINT16_SWAP_LE_BE (val)) 
  101#  define DBUS_INT32_TO_BE(val) ((dbus_int32_t) (val)) 
  102#  define DBUS_UINT32_TO_BE(val)        ((dbus_uint32_t) (val)) 
  103#  define DBUS_INT32_TO_LE(val) (DBUS_INT32_SWAP_LE_BE (val)) 
  104#  define DBUS_UINT32_TO_LE(val)        (DBUS_UINT32_SWAP_LE_BE (val)) 
  105#  define DBUS_INT64_TO_BE(val) ((dbus_int64_t) (val)) 
  106#  define DBUS_UINT64_TO_BE(val)        ((dbus_uint64_t) (val)) 
  107#  define DBUS_INT64_TO_LE(val) (DBUS_INT64_SWAP_LE_BE (val)) 
  108#  define DBUS_UINT64_TO_LE(val)        (DBUS_UINT64_SWAP_LE_BE (val)) 
  112#  define DBUS_INT16_TO_LE(val) ((dbus_int16_t) (val)) 
  113#  define DBUS_UINT16_TO_LE(val)        ((dbus_uint16_t) (val)) 
  114#  define DBUS_INT16_TO_BE(val) ((dbus_int16_t) DBUS_UINT16_SWAP_LE_BE (val)) 
  115#  define DBUS_UINT16_TO_BE(val)        (DBUS_UINT16_SWAP_LE_BE (val)) 
  116#  define DBUS_INT32_TO_LE(val) ((dbus_int32_t) (val)) 
  117#  define DBUS_UINT32_TO_LE(val)        ((dbus_uint32_t) (val)) 
  118#  define DBUS_INT32_TO_BE(val) ((dbus_int32_t) DBUS_UINT32_SWAP_LE_BE (val)) 
  119#  define DBUS_UINT32_TO_BE(val)        (DBUS_UINT32_SWAP_LE_BE (val)) 
  120#  define DBUS_INT64_TO_LE(val) ((dbus_int64_t) (val)) 
  121#  define DBUS_UINT64_TO_LE(val)        ((dbus_uint64_t) (val)) 
  122#  define DBUS_INT64_TO_BE(val) ((dbus_int64_t) DBUS_UINT64_SWAP_LE_BE (val)) 
  123#  define DBUS_UINT64_TO_BE(val)        (DBUS_UINT64_SWAP_LE_BE (val)) 
  127#define DBUS_INT16_FROM_LE(val)  (DBUS_INT16_TO_LE (val)) 
  128#define DBUS_UINT16_FROM_LE(val) (DBUS_UINT16_TO_LE (val)) 
  129#define DBUS_INT16_FROM_BE(val)  (DBUS_INT16_TO_BE (val)) 
  130#define DBUS_UINT16_FROM_BE(val) (DBUS_UINT16_TO_BE (val)) 
  131#define DBUS_INT32_FROM_LE(val)  (DBUS_INT32_TO_LE (val)) 
  132#define DBUS_UINT32_FROM_LE(val) (DBUS_UINT32_TO_LE (val)) 
  133#define DBUS_INT32_FROM_BE(val)  (DBUS_INT32_TO_BE (val)) 
  134#define DBUS_UINT32_FROM_BE(val) (DBUS_UINT32_TO_BE (val)) 
  135#define DBUS_INT64_FROM_LE(val)  (DBUS_INT64_TO_LE (val)) 
  136#define DBUS_UINT64_FROM_LE(val) (DBUS_UINT64_TO_LE (val)) 
  137#define DBUS_INT64_FROM_BE(val)  (DBUS_INT64_TO_BE (val)) 
  138#define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val)) 
  140#ifdef DBUS_DISABLE_ASSERT 
  141#define _dbus_unpack_uint16(byte_order, data)           \ 
  142   (((byte_order) == DBUS_LITTLE_ENDIAN) ?              \ 
  143     DBUS_UINT16_FROM_LE (*(dbus_uint16_t*)(data)) :    \ 
  144     DBUS_UINT16_FROM_BE (*(dbus_uint16_t*)(data))) 
  146#define _dbus_unpack_uint32(byte_order, data)           \ 
  147   (((byte_order) == DBUS_LITTLE_ENDIAN) ?              \ 
  148     DBUS_UINT32_FROM_LE (*(dbus_uint32_t*)(data)) :    \ 
  149     DBUS_UINT32_FROM_BE (*(dbus_uint32_t*)(data))) 
  152#ifndef _dbus_unpack_uint16 
  155                                   const unsigned char *data);
 
  160                                   unsigned char       *data);
 
  161#ifndef _dbus_unpack_uint32 
  164                                   const unsigned char *data);
 
  193void          _dbus_marshal_read_fixed_multi  (
const DBusString *str,
 
DBUS_PRIVATE_EXPORT dbus_uint16_t _dbus_unpack_uint16(int byte_order, const unsigned char *data)
Unpacks a 16 bit unsigned integer from a data pointer.
int _dbus_type_get_alignment(int typecode)
Gets the alignment requirement for the given type; will be 1, 2, 4, or 8.
void _dbus_pack_uint32(dbus_uint32_t value, int byte_order, unsigned char *data)
Packs a 32 bit unsigned integer into a data pointer.
DBUS_PRIVATE_EXPORT void _dbus_marshal_set_uint32(DBusString *str, int pos, dbus_uint32_t value, int byte_order)
Sets the 4 bytes at the given offset to a marshaled unsigned integer, replacing anything found there ...
DBUS_PRIVATE_EXPORT dbus_uint32_t _dbus_unpack_uint32(int byte_order, const unsigned char *data)
Unpacks a 32 bit unsigned integer from a data pointer.
dbus_bool_t _dbus_marshal_write_basic(DBusString *str, int insert_at, int type, const void *value, int byte_order, int *pos_after)
Marshals a basic-typed value.
DBUS_PRIVATE_EXPORT int _dbus_first_type_in_signature(const DBusString *str, int pos)
Get the first type in the signature.
int _dbus_first_type_in_signature_c_str(const char *str, int pos)
Similar to _dbus_first_type_in_signature, but operates on a C string buffer.
DBUS_PRIVATE_EXPORT dbus_uint32_t _dbus_marshal_read_uint32(const DBusString *str, int pos, int byte_order, int *new_pos)
Convenience function to demarshal a 32 bit unsigned integer.
dbus_bool_t _dbus_marshal_set_basic(DBusString *str, int pos, int type, const void *value, int byte_order, int *old_end_pos, int *new_end_pos)
Sets an existing basic type value to a new value.
void _dbus_marshal_skip_array(const DBusString *str, int element_type, int byte_order, int *pos)
Skips an array, returning the next position.
dbus_bool_t _dbus_marshal_write_fixed_multi(DBusString *str, int insert_at, int element_type, const void *value, int n_elements, int byte_order, int *pos_after)
Marshals a block of values of fixed-length type all at once, as an optimization.
DBUS_PRIVATE_EXPORT const char * _dbus_type_to_string(int typecode)
Returns a string describing the given type.
void _dbus_marshal_read_basic(const DBusString *str, int pos, int type, void *value, int byte_order, int *new_pos)
Demarshals a basic-typed value.
void _dbus_swap_array(unsigned char *data, int n_elements, int alignment)
Swaps the elements of an array to the opposite byte order.
void _dbus_marshal_skip_basic(const DBusString *str, int type, int byte_order, int *pos)
Skips over a basic-typed value, reporting the following position.
unsigned short dbus_uint16_t
A 16-bit unsigned integer on all platforms.
unsigned int dbus_uint32_t
A 32-bit unsigned integer on all platforms.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.