diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/osb/i64to32.c | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
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; +} |