aboutsummaryrefslogtreecommitdiff
path: root/sys/osb/chrupk.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/osb/chrupk.c
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/osb/chrupk.c')
-rw-r--r--sys/osb/chrupk.c32
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;
+}