diff options
Diffstat (limited to 'sys/osb/chrupk.c')
-rw-r--r-- | sys/osb/chrupk.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/osb/chrupk.c b/sys/osb/chrupk.c new file mode 100644 index 00000000..f909c8d9 --- /dev/null +++ b/sys/osb/chrupk.c @@ -0,0 +1,32 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* CHRUPK -- Unpack a byte string into XCHAR. This routine does not + * know about EOS terminators. The input and output arrays may be the same. + * Note that while XCHAR is signed, the signedness of the C char is unspecified, + * hence we pack the chars into unsigned bytes and restore the sign explicitly. + */ +CHRUPK (a, a_off, b, b_off, nchars) +XCHAR *a, *b; +XINT *a_off, *b_off, *nchars; +{ + register unsigned char *ip; + register XCHAR *op; + register int n, ch; + + /* Set pointers to last char plus one so that we can unpack the array + * in the reverse direction. + */ + n = *nchars; + ip = &((unsigned char *)a)[*a_off-1+n]; + op = &b[*b_off-1+n]; + + /* Unpack string from right to left. + */ + while (--n >= 0) + *--op = ((ch = *--ip) <= 127) ? ch : ch - 256; +} |