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-marshal-byteswap-util.c
00001
/* -*- mode: C; c-file-style: "gnu" -*- */
00002
/* dbus-marshal-byteswap-util.c  Would be in dbus-marshal-byteswap.c but tests/bus only
00003
*
00004
* Copyright (C) 2005 Red Hat, Inc.
00005
*
00006
* Licensed under the Academic Free License version 2.1
00007
*
00008
* This program is free software; you can redistribute it and/or modify
00009
* it under the terms of the GNU General Public License as published by
00010
* the Free Software Foundation; either version 2 of the License, or
00011
* (at your option) any later version.
00012
*
00013
* This program is distributed in the hope that it will be useful,
00014
* but WITHOUT ANY WARRANTY; without even the implied warranty of
00015
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016
* GNU General Public License for more details.
00017
*
00018
* You should have received a copy of the GNU General Public License
00019
* along with this program; if not, write to the Free Software
00020
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021
*
00022
*/
00023
00024
#include <config.h>
00025
00026
#ifdef DBUS_BUILD_TESTS
00027
#include "dbus-marshal-byteswap.h"
00028
#include "dbus-test.h"
00029
#include <stdio.h>
00030
00031
static
void
00032 do_byteswap_test (
int
byte_order)
00033 {
00034
int
sequence;
00035
structDBusString.html
DBusString
signature;
00036
structDBusString.html
DBusString
body;
00037
int
opposite_order;
00038
00039
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&signature) || !
group__DBusString.html#ga6
_dbus_string_init
(&body))
00040
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"oom"
);
00041
00042   opposite_order = byte_order == DBUS_LITTLE_ENDIAN ? DBUS_BIG_ENDIAN : DBUS_LITTLE_ENDIAN;
00043
00044   sequence = 0;
00045
while
(dbus_internal_do_not_use_generate_bodies (sequence,
00046                                                    byte_order,
00047                                                    &signature, &body))
00048     {
00049
structDBusString.html
DBusString
copy;
00050
structDBusTypeReader.html
DBusTypeReader
body_reader;
00051
structDBusTypeReader.html
DBusTypeReader
copy_reader;
00052
00053
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&copy))
00054
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"oom"
);
00055
00056
if
(!
group__DBusString.html#ga40
_dbus_string_copy
(&body, 0, &copy, 0))
00057
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"oom"
);
00058
00059
group__DBusMarshal.html#ga49
_dbus_marshal_byteswap
(&signature, 0,
00060                               byte_order,
00061                               opposite_order,
00062                               &copy, 0);
00063
00064
group__DBusMarshal.html#ga104
_dbus_type_reader_init
(&body_reader, byte_order, &signature, 0,
00065                               &body, 0);
00066
group__DBusMarshal.html#ga104
_dbus_type_reader_init
(&copy_reader, opposite_order, &signature, 0,
00067                               &copy, 0);
00068
00069
if
(!_dbus_type_reader_equal_values (&body_reader, &copy_reader))
00070         {
00071
group__DBusMarshal.html#ga44
_dbus_verbose_bytes_of_string
(&signature, 0,
00072                                          _dbus_string_get_length (&signature));
00073
group__DBusMarshal.html#ga44
_dbus_verbose_bytes_of_string
(&body, 0,
00074                                          _dbus_string_get_length (&body));
00075
group__DBusMarshal.html#ga44
_dbus_verbose_bytes_of_string
(&copy, 0,
00076                                          _dbus_string_get_length (&copy));
00077
00078
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"Byte-swapped data did not have same values as original data\n"
);
00079
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"test failed"
);
00080         }
00081
00082
group__DBusString.html#ga9
_dbus_string_free
(&copy);
00083
00084
group__DBusString.html#ga21
_dbus_string_set_length
(&signature, 0);
00085
group__DBusString.html#ga21
_dbus_string_set_length
(&body, 0);
00086       ++sequence;
00087     }
00088
00089
group__DBusString.html#ga9
_dbus_string_free
(&signature);
00090
group__DBusString.html#ga9
_dbus_string_free
(&body);
00091
00092   printf (
"  %d blocks swapped from order '%c' to '%c'\n"
,
00093           sequence, byte_order, opposite_order);
00094 }
00095
00096
group__DBusTypes.html#ga2
dbus_bool_t
00097 _dbus_marshal_byteswap_test (
void
)
00098 {
00099   do_byteswap_test (DBUS_LITTLE_ENDIAN);
00100   do_byteswap_test (DBUS_BIG_ENDIAN);
00101
00102
return
group__DBusMacros.html#ga2
TRUE
;
00103 }
00104
00105
#endif
/* DBUS_BUILD_TESTS */
Generated on Tue Sep 13 01:28:07 2005 for D-BUS by
http://www.doxygen.org/index.html
doxygen
1.4.4
