blob: 2b6a619cf715f8044d7c09035d6c885f962aa959 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#define import_spp
#define import_knames
#include <iraf.h>
/* I64TO32 - Convert big endian 64bit integer array into 32bit.
*/
int
I64TO32 (void *a, void *b, XINT *nelems)
{
char *ip = (char *)a,
*op = (char *)b;
XINT i;
/*
* in |--------|
* out |----|
*/
if ( op <= ip ) {
for ( i=0 ; i < *nelems ; i++ ) {
ip += 4;
*op = *ip;
op++; ip++;
*op = *ip;
op++; ip++;
*op = *ip;
op++; ip++;
*op = *ip;
op++; ip++;
}
}
else {
char *ipe = (char *)a + *nelems * 8 - 1;
char *ope = (char *)b + *nelems * 4 - 1;
/*
* in |--------|
* out |----|
*/
if ( ipe <= ope ) {
for ( i=0 ; i < *nelems ; i++ ) {
*ope = *ipe;
ope--; ipe--;
*ope = *ipe;
ope--; ipe--;
*ope = *ipe;
ope--; ipe--;
*ope = *ipe;
ope--; ipe--;
ipe -= 4;
}
}
/*
* in |--------|
* out |----|
*/
else {
for ( i=0 ; i < *nelems ; i++ ) {
/* --------> */
ip += 4;
if ( op < ip ) {
*op = *ip;
op++; ip++;
*op = *ip;
op++; ip++;
*op = *ip;
op++; ip++;
*op = *ip;
op++; ip++;
}
else {
op += 4;
ip += 4;
}
/* <-------- */
if ( ipe < ope ) {
*ope = *ipe;
ope--; ipe--;
*ope = *ipe;
ope--; ipe--;
*ope = *ipe;
ope--; ipe--;
*ope = *ipe;
ope--; ipe--;
}
else {
ope -= 4;
ipe -= 4;
}
ipe -= 4;
}
}
}
return 0;
}
|