3
// byteorder-related functions for VoxBo
4
// Copyright (c) 1998-2001 by The VoxBo Development Team
6
// This file is part of VoxBo
8
// VoxBo is free software: you can redistribute it and/or modify it
9
// under the terms of the GNU General Public License as published by
10
// the Free Software Foundation, either version 3 of the License, or
11
// (at your option) any later version.
13
// VoxBo is distributed in the hope that it will be useful, but
14
// WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
// General Public License for more details.
18
// You should have received a copy of the GNU General Public License
19
// along with VoxBo. If not, see <http://www.gnu.org/licenses/>.
21
// For general information on VoxBo, including the latest complete
22
// source code and binary distributions, manual, and associated files,
23
// see the VoxBo home page at: http://www.voxbo.org/
25
// original version written by Dan Kimberg
30
#include <netinet/in.h>
33
swapn(unsigned char *uc,int dsize,int len)
36
swap((uint16 *)uc,len);
38
swap((uint32 *)uc,len);
40
swap((double *)uc,len);
44
swap(uint16 *sh,int len)
46
unsigned char *foo,tmp;
47
for (int i=0; i<len; i++) {
48
foo = (unsigned char *)(sh + i);
56
swap(int16 *sh,int len)
58
unsigned char *foo,tmp;
59
for (int i=0; i<len; i++) {
60
foo = (unsigned char *)(sh + i);
68
swap(uint32 *lng,int len)
70
unsigned char *foo,tmp;
71
for (int i=0; i<len; i++) {
72
foo = (unsigned char *)(lng + i);
83
swap(int32 *lng,int len)
85
unsigned char *foo,tmp;
86
for (int i=0; i<len; i++) {
87
foo = (unsigned char *)(lng + i);
98
swap(float *flt,int len)
100
unsigned char *foo,tmp;
101
for (int i=0; i<len; i++) {
102
foo = (unsigned char *)(flt + i);
113
swap(double *dbl,int len)
115
unsigned char *foo,tmp;
116
for (int i=0; i<len; i++) {
117
foo = (unsigned char *)(dbl + i);
139
return ENDIAN_LITTLE;