2 * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
9 #include <MessengerPrivate.h>
13 swap_data(type_code type
, void *_data
, size_t length
, swap_action action
)
15 // is there anything to do?
17 if (action
== B_SWAP_HOST_TO_LENDIAN
|| action
== B_SWAP_LENDIAN_TO_HOST
)
20 if (action
== B_SWAP_HOST_TO_BENDIAN
|| action
== B_SWAP_BENDIAN_TO_HOST
)
30 // ToDo: these are not safe. If the length is smaller than the size of
31 // the type to be converted, too much data may be read. R5 behaves in the
38 uint16
*data
= (uint16
*)_data
;
39 uint16
*end
= (uint16
*)((addr_t
)_data
+ length
);
42 *data
= __swap_int16(*data
);
61 uint32
*data
= (uint32
*)_data
;
62 uint32
*end
= (uint32
*)((addr_t
)_data
+ length
);
65 *data
= __swap_int32(*data
);
82 uint64
*data
= (uint64
*)_data
;
83 uint64
*end
= (uint64
*)((addr_t
)_data
+ length
);
86 *data
= __swap_int64(*data
);
93 case B_MESSENGER_TYPE
:
95 BMessenger
*messenger
= (BMessenger
*)_data
;
96 BMessenger
*end
= (BMessenger
*)((addr_t
)_data
+ length
);
98 while (messenger
< end
) {
99 BMessenger::Private
messengerPrivate(messenger
);
100 // ToDo: if the additional fields change, this function has to be updated!
101 messengerPrivate
.SetTo(
102 __swap_int32(messengerPrivate
.Team()),
103 __swap_int32(messengerPrivate
.Port()),
104 __swap_int32(messengerPrivate
.Token()));
111 // not swappable or recognized type!
120 is_type_swapped(type_code type
)
122 // Returns true when the type is in the host's native format
123 // Looks like a pretty strange function to me :)
128 case B_COLOR_8_BIT_TYPE
:
131 case B_GRAYSCALE_8_BIT_TYPE
:
137 case B_MESSENGER_TYPE
:
139 case B_MONOCHROME_1_BIT_TYPE
:
146 case B_RGB_32_BIT_TYPE
:
147 case B_RGB_COLOR_TYPE
: