blob: ff544b7dd0d46a8faaf43faa73f574ad98d93017 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/
#define import_spp
#define import_knames
#include <iraf.h>
/* BSWAP8 - Move bytes from array "a" to array "b", swapping the eight bytes
* in each successive 8 byte group, i.e., 12345678 becomes 87654321.
* The input and output arrays may be the same but may not partially overlap.
*/
BSWAP8 (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, *tp;
register int n;
static char temp[8];
tp = temp;
ip = (char *)a + *aoff - 1;
op = (char *)b + *boff - 1;
/* Swap successive eight byte groups.
*/
for (n = *nbytes >> 3; --n >= 0; ) {
*tp++ = *ip++;
*tp++ = *ip++;
*tp++ = *ip++;
*tp++ = *ip++;
*tp++ = *ip++;
*tp++ = *ip++;
*tp++ = *ip++;
*tp++ = *ip++;
*op++ = *--tp;
*op++ = *--tp;
*op++ = *--tp;
*op++ = *--tp;
*op++ = *--tp;
*op++ = *--tp;
*op++ = *--tp;
*op++ = *--tp;
}
/* If there are any odd bytes left, move them to the output array.
* Do not bother to swap as it is unclear how to swap a partial
* group, and really incorrect if the data is not modulus 8.
*/
for (n = *nbytes & 03; --n >= 0; )
*op++ = *ip++;
}
|