home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 1B
/
DATAFILE_PDCD1B.iso
/
_pocketbk
/
pocketbook
/
opl
/
pbm2pic_tg
/
pbm2pic_tg~
/
conv
/
swap.c
< prev
Wrap
C/C++ Source or Header
|
1993-12-16
|
650b
|
42 lines
#include <stdio.h>
int needmotorolaorder = 1;
static int whatwehave = -1;
void
initorder()
{
int x = 0;
((char *)&x)[3] = 1;
if(x == 1)
whatwehave = 1;
else
whatwehave = 0;
}
unsigned long
LongSwap(x)
unsigned long x;
{
if(whatwehave == -1)
initorder();
if(whatwehave == needmotorolaorder)
return;
x = (x>>16 & 0x0000ffff) | (x<<16 & 0xffff0000);
x = (x>> 8 & 0x00ff00ff) | (x<< 8 & 0xff00ff00);
return(x);
}
unsigned short
ShortSwap(x)
unsigned short x;
{
if(whatwehave == -1)
initorder();
if(whatwehave == needmotorolaorder)
return;
x = (x>> 8 & 0x00ff) | (x<< 8 & 0xff00);
return(x);
}