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
00156 dbus_bool_t _dbus_marshal_set_string (DBusString *str,
00157 int byte_order,
00158 int offset,
00159 const DBusString *value,
00160 int len);
00161 void _dbus_marshal_set_object_path (DBusString *str,
00162 int byte_order,
00163 int offset,
00164 const char **path,
00165 int path_len);
00166
00167 dbus_bool_t _dbus_marshal_int32 (DBusString *str,
00168 int byte_order,
00169 dbus_int32_t value);
00170 dbus_bool_t _dbus_marshal_uint32 (DBusString *str,
00171 int byte_order,
00172 dbus_uint32_t value);
00173 #ifdef DBUS_HAVE_INT64
00174 dbus_bool_t _dbus_marshal_int64 (DBusString *str,
00175 int byte_order,
00176 dbus_int64_t value);
00177 dbus_bool_t _dbus_marshal_uint64 (DBusString *str,
00178 int byte_order,
00179 dbus_uint64_t value);
00180 #endif
00181 dbus_bool_t _dbus_marshal_double (DBusString *str,
00182 int byte_order,
00183 double value);
00184 dbus_bool_t _dbus_marshal_string (DBusString *str,
00185 int byte_order,
00186 const char *value);
00187 dbus_bool_t _dbus_marshal_string_len (DBusString *str,
00188 int byte_order,
00189 const char *value,
00190 int len);
00191 dbus_bool_t _dbus_marshal_basic_type (DBusString *str,
00192 char type,
00193 void *value,
00194 int byte_order);
00195 dbus_bool_t _dbus_marshal_byte_array (DBusString *str,
00196 int byte_order,
00197 const unsigned char *value,
00198 int len);
00199 dbus_bool_t _dbus_marshal_int32_array (DBusString *str,
00200 int byte_order,
00201 const dbus_int32_t *value,
00202 int len);
00203 dbus_bool_t _dbus_marshal_uint32_array (DBusString *str,
00204 int byte_order,
00205 const dbus_uint32_t *value,
00206 int len);
00207 #ifdef DBUS_HAVE_INT64
00208 dbus_bool_t _dbus_marshal_int64_array (DBusString *str,
00209 int byte_order,
00210 const dbus_int64_t *value,
00211 int len);
00212 dbus_bool_t _dbus_marshal_uint64_array (DBusString *str,
00213 int byte_order,
00214 const dbus_uint64_t *value,
00215 int len);
00216 #endif
00217 dbus_bool_t _dbus_marshal_double_array (DBusString *str,
00218 int byte_order,
00219 const double *value,
00220 int len);
00221 dbus_bool_t _dbus_marshal_basic_type_array (DBusString *str,
00222 char element_type,
00223 const void *value,
00224 int len,
00225 int byte_order);
00226
00227 dbus_bool_t _dbus_marshal_string_array (DBusString *str,
00228 int byte_order,
00229 const char **value,
00230 int len);
00231 dbus_bool_t _dbus_marshal_object_path (DBusString *str,
00232 int byte_order,
00233 const char **path,
00234 int path_len);
00235
00236 double _dbus_demarshal_double (const DBusString *str,
00237 int byte_order,
00238 int pos,
00239 int *new_pos);
00240 dbus_int32_t _dbus_demarshal_int32 (const DBusString *str,
00241 int byte_order,
00242 int pos,
00243 int *new_pos);
00244 dbus_uint32_t _dbus_demarshal_uint32 (const DBusString *str,
00245 int byte_order,
00246 int pos,
00247 int *new_pos);
00248 #ifdef DBUS_HAVE_INT64
00249 dbus_int64_t _dbus_demarshal_int64 (const DBusString *str,
00250 int byte_order,
00251 int pos,
00252 int *new_pos);
00253 dbus_uint64_t _dbus_demarshal_uint64 (const DBusString *str,
00254 int byte_order,
00255 int pos,
00256 int *new_pos);
00257 #endif
00258 void _dbus_demarshal_basic_type (const DBusString *str,
00259 int type,
00260 void *value,
00261 int byte_order,
00262 int *pos);
00263 char * _dbus_demarshal_string (const DBusString *str,
00264 int byte_order,
00265 int pos,
00266 int *new_pos);
00267 dbus_bool_t _dbus_demarshal_byte_array (const DBusString *str,
00268 int byte_order,
00269 int pos,
00270 int *new_pos,
00271 unsigned char **array,
00272 int *array_len);
00273 dbus_bool_t _dbus_demarshal_int32_array (const DBusString *str,
00274 int byte_order,
00275 int pos,
00276 int *new_pos,
00277 dbus_int32_t **array,
00278 int *array_len);
00279 dbus_bool_t _dbus_demarshal_uint32_array (const DBusString *str,
00280 int byte_order,
00281 int pos,
00282 int *new_pos,
00283 dbus_uint32_t **array,
00284 int *array_len);
00285 #ifdef DBUS_HAVE_INT64
00286 dbus_bool_t _dbus_demarshal_int64_array (const DBusString *str,
00287 int byte_order,
00288 int pos,
00289 int *new_pos,
00290 dbus_int64_t **array,
00291 int *array_len);
00292 dbus_bool_t _dbus_demarshal_uint64_array (const DBusString *str,
00293 int byte_order,
00294 int pos,
00295 int *new_pos,
00296 dbus_uint64_t **array,
00297 int *array_len);
00298 #endif
00299 dbus_bool_t _dbus_demarshal_double_array (const DBusString *str,
00300 int byte_order,
00301 int pos,
00302 int *new_pos,
00303 double **array,
00304 int *array_len);
00305 dbus_bool_t _dbus_demarshal_basic_type_array (const DBusString *str,
00306 int type,
00307 void **array,
00308 int *array_len,
00309 int byte_order,
00310 int *pos);
00311
00312 dbus_bool_t _dbus_demarshal_string_array (const DBusString *str,
00313 int byte_order,
00314 int pos,
00315 int *new_pos,
00316 char ***array,
00317 int *array_len);
00318 dbus_bool_t _dbus_decompose_path (const char* data,
00319 int len,
00320 char ***path,
00321 int *path_len);
00322 dbus_bool_t _dbus_demarshal_object_path (const DBusString *str,
00323 int byte_order,
00324 int pos,
00325 int *new_pos,
00326 char ***path,
00327 int *path_len);
00328
00329 dbus_bool_t _dbus_marshal_get_arg_end_pos (const DBusString *str,
00330 int byte_order,
00331 int type,
00332 int pos,
00333 int *end_pos);
00334 dbus_bool_t _dbus_marshal_validate_type (const DBusString *str,
00335 int pos,
00336 int *type,
00337 int *end_pos);
00338 dbus_bool_t _dbus_marshal_validate_arg (const DBusString *str,
00339 int depth,
00340 int byte_order,
00341 int type,
00342 int array_type_pos,
00343 int pos,
00344 int *end_pos);
00345
00346 dbus_bool_t _dbus_type_is_valid (int typecode);
00347
00348 #endif