blob: a2c080305570d7962021e23da0231080559d8dc4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/
#define import_spp
#define import_knames
#include <iraf.h>
/* BSWAP2 - Move bytes from array "a" to array "b", swapping successive
* pairs of bytes. The two arrays may be the same but may not be offset
* and overlapping.
*/
BSWAP2 (a, aoff, b, boff, nbytes)
XCHAR *a; /* input array */
XINT *aoff; /* first byte in input array */
XCHAR *b; /* output array */
XINT *boff; /* first byte in output array */
XINT *nbytes; /* number of bytes to swap */
{
register char *ip, *op, *otop;
register unsigned temp;
ip = (char *)a + *aoff - 1;
op = (char *)b + *boff - 1;
otop = op + (*nbytes & ~1);
/* Swap successive pairs of bytes.
*/
while (op < otop) {
temp = *ip++;
*op++ = *ip++;
*op++ = temp;
}
/* If there is an odd byte left, move it to the output array.
*/
if (*nbytes & 1)
*op = *ip;
}
|