diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/osb/i64to32.c | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/osb/i64to32.c')
-rw-r--r-- | sys/osb/i64to32.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/sys/osb/i64to32.c b/sys/osb/i64to32.c new file mode 100644 index 00000000..2b6a619c --- /dev/null +++ b/sys/osb/i64to32.c @@ -0,0 +1,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; +} |