aboutsummaryrefslogtreecommitdiff
path: root/sys/osb/strupk.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/osb/strupk.c')
-rw-r--r--sys/osb/strupk.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/sys/osb/strupk.c b/sys/osb/strupk.c
new file mode 100644
index 00000000..97bd1bc1
--- /dev/null
+++ b/sys/osb/strupk.c
@@ -0,0 +1,39 @@
+/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+ */
+
+#define import_spp
+#define import_knames
+#include <iraf.h>
+
+/* STRUPK -- Unpack a kernel (C style) string into an SPP string. The unpacking
+ * operation can be performed in place. A kernel string consists of a sequence
+ * of host characters stored one character per byte, delimited by EOS='\0'.
+ * We assume here that the host character set is ASCII. If this is not the
+ * case code must be added to convert from the host character set to ASCII in
+ * the unpacked string.
+ *
+ * N.B.: If sizeof(XCHAR)=1, XEOS=EOS, and the host character set is ASCII,
+ * and the operation is being performed in place, then this procedure should
+ * do nothing.
+ */
+STRUPK (instr, outstr, maxch)
+PKCHAR *instr;
+XCHAR *outstr;
+XINT *maxch;
+{
+ register char *ip = (char *)instr;
+ register XCHAR *op = outstr;
+ register int n;
+
+ /* Is is necessary to determine the length of the string in order to
+ * be able to unpack the string in place, i.e., from right to left.
+ */
+ for (n=0; *ip++; n++)
+ ;
+ n = (n < *maxch) ? n : *maxch;
+ op[n] = XEOS;
+
+ for (ip = (char *)instr; --n >= 0; )
+ op[n] = ip[n];
+ op[*maxch] = XEOS;
+}