00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef DBUS_MARSHAL_H
00025 #define DBUS_MARSHAL_H
00026
00027 #include <config.h>
00028 #include <dbus/dbus-protocol.h>
00029 #include <dbus/dbus-types.h>
00030 #include <dbus/dbus-arch-deps.h>
00031 #include <dbus/dbus-string.h>
00032
00033 #ifndef PACKAGE
00034 #error "config.h not included here"
00035 #endif
00036
00037 #ifdef WORDS_BIGENDIAN
00038 #define DBUS_COMPILER_BYTE_ORDER DBUS_BIG_ENDIAN
00039 #else
00040 #define DBUS_COMPILER_BYTE_ORDER DBUS_LITTLE_ENDIAN
00041 #endif
00042
00043 #define DBUS_UINT32_SWAP_LE_BE_CONSTANT(val) ((dbus_uint32_t) ( \
00044 (((dbus_uint32_t) (val) & (dbus_uint32_t) 0x000000ffU) << 24) | \
00045 (((dbus_uint32_t) (val) & (dbus_uint32_t) 0x0000ff00U) << 8) | \
00046 (((dbus_uint32_t) (val) & (dbus_uint32_t) 0x00ff0000U) >> 8) | \
00047 (((dbus_uint32_t) (val) & (dbus_uint32_t) 0xff000000U) >> 24)))
00048
00049 #ifdef DBUS_HAVE_INT64
00050
00051 #define DBUS_UINT64_SWAP_LE_BE_CONSTANT(val) ((dbus_uint64_t) ( \
00052 (((dbus_uint64_t) (val) & \
00053 (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00000000000000ff)) << 56) | \
00054 (((dbus_uint64_t) (val) & \
00055 (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x000000000000ff00)) << 40) | \
00056 (((dbus_uint64_t) (val) & \
00057 (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x0000000000ff0000)) << 24) | \
00058 (((dbus_uint64_t) (val) & \
00059 (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00000000ff000000)) << 8) | \
00060 (((dbus_uint64_t) (val) & \
00061 (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x000000ff00000000)) >> 8) | \
00062 (((dbus_uint64_t) (val) & \
00063 (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x0000ff0000000000)) >> 24) | \
00064 (((dbus_uint64_t) (val) & \
00065 (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00ff000000000000)) >> 40) | \
00066 (((dbus_uint64_t) (val) & \
00067 (dbus_uint64_t) DBUS_UINT64_CONSTANT (0xff00000000000000)) >> 56)))
00068 #endif
00069
00070 #define DBUS_UINT32_SWAP_LE_BE(val) (DBUS_UINT32_SWAP_LE_BE_CONSTANT (val))
00071 #define DBUS_INT32_SWAP_LE_BE(val) ((dbus_int32_t)DBUS_UINT32_SWAP_LE_BE_CONSTANT (val))
00072
00073 #ifdef DBUS_HAVE_INT64
00074 #define DBUS_UINT64_SWAP_LE_BE(val) (DBUS_UINT64_SWAP_LE_BE_CONSTANT (val))
00075 #define DBUS_INT64_SWAP_LE_BE(val) ((dbus_int64_t)DBUS_UINT64_SWAP_LE_BE_CONSTANT (val))
00076 #endif
00077
00078 #ifdef WORDS_BIGENDIAN
00079 #define DBUS_INT32_TO_BE(val) ((dbus_int32_t) (val))
00080 #define DBUS_UINT32_TO_BE(val) ((dbus_uint32_t) (val))
00081 #define DBUS_INT32_TO_LE(val) (DBUS_INT32_SWAP_LE_BE (val))
00082 #define DBUS_UINT32_TO_LE(val) (DBUS_UINT32_SWAP_LE_BE (val))
00083 # ifdef DBUS_HAVE_INT64
00084 #define DBUS_INT64_TO_BE(val) ((dbus_int64_t) (val))
00085 #define DBUS_UINT64_TO_BE(val) ((dbus_uint64_t) (val))
00086 #define DBUS_INT64_TO_LE(val) (DBUS_INT64_SWAP_LE_BE (val))
00087 #define DBUS_UINT64_TO_LE(val) (DBUS_UINT64_SWAP_LE_BE (val))
00088 # endif
00089 #else
00090 #define DBUS_INT32_TO_LE(val) ((dbus_int32_t) (val))
00091 #define DBUS_UINT32_TO_LE(val) ((dbus_uint32_t) (val))
00092 #define DBUS_INT32_TO_BE(val) ((dbus_int32_t) DBUS_UINT32_SWAP_LE_BE (val))
00093 #define DBUS_UINT32_TO_BE(val) (DBUS_UINT32_SWAP_LE_BE (val))
00094 # ifdef DBUS_HAVE_INT64
00095 #define DBUS_INT64_TO_LE(val) ((dbus_int64_t) (val))
00096 #define DBUS_UINT64_TO_LE(val) ((dbus_uint64_t) (val))
00097 #define DBUS_INT64_TO_BE(val) ((dbus_int64_t) DBUS_UINT64_SWAP_LE_BE (val))
00098 #define DBUS_UINT64_TO_BE(val) (DBUS_UINT64_SWAP_LE_BE (val))
00099 # endif
00100 #endif
00101
00102
00103 #define DBUS_INT32_FROM_LE(val) (DBUS_INT32_TO_LE (val))
00104 #define DBUS_UINT32_FROM_LE(val) (DBUS_UINT32_TO_LE (val))
00105 #define DBUS_INT32_FROM_BE(val) (DBUS_INT32_TO_BE (val))
00106 #define DBUS_UINT32_FROM_BE(val) (DBUS_UINT32_TO_BE (val))
00107 #ifdef DBUS_HAVE_INT64
00108 #define DBUS_INT64_FROM_LE(val) (DBUS_INT64_TO_LE (val))
00109 #define DBUS_UINT64_FROM_LE(val) (DBUS_UINT64_TO_LE (val))
00110 #define DBUS_INT64_FROM_BE(val) (DBUS_INT64_TO_BE (val))
00111 #define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val))
00112 #endif
00113
00114 void _dbus_pack_int32 (dbus_int32_t value,
00115 int byte_order,
00116 unsigned char *data);
00117 dbus_int32_t _dbus_unpack_int32 (int byte_order,
00118 const unsigned char *data);
00119 void _dbus_pack_uint32 (dbus_uint32_t value,
00120 int byte_order,
00121 unsigned char *data);
00122 dbus_uint32_t _dbus_unpack_uint32 (int byte_order,
00123 const unsigned char *data);
00124 #ifdef DBUS_HAVE_INT64
00125 void _dbus_pack_int64 (dbus_int64_t value,
00126 int byte_order,
00127 unsigned char *data);
00128 dbus_int64_t _dbus_unpack_int64 (int byte_order,
00129 const unsigned char *data);
00130 void _dbus_pack_uint64 (dbus_uint64_t value,
00131 int byte_order,
00132 unsigned char *data);
00133 dbus_uint64_t _dbus_unpack_uint64 (int byte_order,
00134 const unsigned char *data);
00135 #endif
00136
00137 void _dbus_marshal_set_int32 (DBusString *str,
00138 int byte_order,
00139 int offset,
00140 dbus_int32_t value);
00141 void _dbus_marshal_set_uint32 (DBusString *str,
00142 int byte_order,
00143 int offset,
00144 dbus_uint32_t value);
00145 #ifdef DBUS_HAVE_INT64
00146 void _dbus_marshal_set_int64 (DBusString *str,
00147 int byte_order,
00148 int offset,
00149 dbus_int64_t value);
00150 void _dbus_marshal_set_uint64 (DBusString *str,
00151 int byte_order,
00152 int offset,
00153 dbus_uint64_t value);
00154 #endif
00155 dbus_bool_t _dbus_marshal_set_string (DBusString *str,
00156 int byte_order,
00157 int offset,
00158 const DBusString *value,
00159 int len);
00160
00161 dbus_bool_t _dbus_marshal_int32 (DBusString *str,
00162 int byte_order,
00163 dbus_int32_t value);
00164 dbus_bool_t _dbus_marshal_uint32 (DBusString *str,
00165 int byte_order,
00166 dbus_uint32_t value);
00167 #ifdef DBUS_HAVE_INT64
00168 dbus_bool_t _dbus_marshal_int64 (DBusString *str,
00169 int byte_order,
00170 dbus_int64_t value);
00171 dbus_bool_t _dbus_marshal_uint64 (DBusString *str,
00172 int byte_order,
00173 dbus_uint64_t value);
00174 #endif
00175 dbus_bool_t _dbus_marshal_double (DBusString *str,
00176 int byte_order,
00177 double value);
00178 dbus_bool_t _dbus_marshal_string (DBusString *str,
00179 int byte_order,
00180 const char *value);
00181 dbus_bool_t _dbus_marshal_byte_array (DBusString *str,
00182 int byte_order,
00183 const unsigned char *value,
00184 int len);
00185 dbus_bool_t _dbus_marshal_int32_array (DBusString *str,
00186 int byte_order,
00187 const dbus_int32_t *value,
00188 int len);
00189 dbus_bool_t _dbus_marshal_uint32_array (DBusString *str,
00190 int byte_order,
00191 const dbus_uint32_t *value,
00192 int len);
00193 #ifdef DBUS_HAVE_INT64
00194 dbus_bool_t _dbus_marshal_int64_array (DBusString *str,
00195 int byte_order,
00196 const dbus_int64_t *value,
00197 int len);
00198 dbus_bool_t _dbus_marshal_uint64_array (DBusString *str,
00199 int byte_order,
00200 const dbus_uint64_t *value,
00201 int len);
00202 #endif
00203 dbus_bool_t _dbus_marshal_double_array (DBusString *str,
00204 int byte_order,
00205 const double *value,
00206 int len);
00207 dbus_bool_t _dbus_marshal_string_array (DBusString *str,
00208 int byte_order,
00209 const char **value,
00210 int len);
00211 double _dbus_demarshal_double (const DBusString *str,
00212 int byte_order,
00213 int pos,
00214 int *new_pos);
00215 dbus_int32_t _dbus_demarshal_int32 (const DBusString *str,
00216 int byte_order,
00217 int pos,
00218 int *new_pos);
00219 dbus_uint32_t _dbus_demarshal_uint32 (const DBusString *str,
00220 int byte_order,
00221 int pos,
00222 int *new_pos);
00223 #ifdef DBUS_HAVE_INT64
00224 dbus_int64_t _dbus_demarshal_int64 (const DBusString *str,
00225 int byte_order,
00226 int pos,
00227 int *new_pos);
00228 dbus_uint64_t _dbus_demarshal_uint64 (const DBusString *str,
00229 int byte_order,
00230 int pos,
00231 int *new_pos);
00232 #endif
00233 char * _dbus_demarshal_string (const DBusString *str,
00234 int byte_order,
00235 int pos,
00236 int *new_pos);
00237 dbus_bool_t _dbus_demarshal_byte_array (const DBusString *str,
00238 int byte_order,
00239 int pos,
00240 int *new_pos,
00241 unsigned char **array,
00242 int *array_len);
00243 dbus_bool_t _dbus_demarshal_int32_array (const DBusString *str,
00244 int byte_order,
00245 int pos,
00246 int *new_pos,
00247 dbus_int32_t **array,
00248 int *array_len);
00249 dbus_bool_t _dbus_demarshal_uint32_array (const DBusString *str,
00250 int byte_order,
00251 int pos,
00252 int *new_pos,
00253 dbus_uint32_t **array,
00254 int *array_len);
00255 #ifdef DBUS_HAVE_INT64
00256 dbus_bool_t _dbus_demarshal_int64_array (const DBusString *str,
00257 int byte_order,
00258 int pos,
00259 int *new_pos,
00260 dbus_int64_t **array,
00261 int *array_len);
00262 dbus_bool_t _dbus_demarshal_uint64_array (const DBusString *str,
00263 int byte_order,
00264 int pos,
00265 int *new_pos,
00266 dbus_uint64_t **array,
00267 int *array_len);
00268 #endif
00269 dbus_bool_t _dbus_demarshal_double_array (const DBusString *str,
00270 int byte_order,
00271 int pos,
00272 int *new_pos,
00273 double **array,
00274 int *array_len);
00275 dbus_bool_t _dbus_demarshal_string_array (const DBusString *str,
00276 int byte_order,
00277 int pos,
00278 int *new_pos,
00279 char ***array,
00280 int *array_len);
00281
00282
00283
00284
00285 dbus_bool_t _dbus_marshal_get_arg_end_pos (const DBusString *str,
00286 int byte_order,
00287 int type,
00288 int pos,
00289 int *end_pos);
00290 dbus_bool_t _dbus_marshal_validate_type (const DBusString *str,
00291 int pos,
00292 int *type,
00293 int *end_pos);
00294 dbus_bool_t _dbus_marshal_validate_arg (const DBusString *str,
00295 int depth,
00296 int byte_order,
00297 int type,
00298 int array_type_pos,
00299 int pos,
00300 int *end_pos);
00301
00302
00303 #endif