aboutsummaryrefslogtreecommitdiff
path: root/sys/osb/strpak.c
blob: 4f88123d11a9793f79b1ac729184ea5dd2404d66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
 */

#define	import_spp
#define import_knames
#include <iraf.h>

/* STRPAK -- Pack an SPP character string into a C string, i.e., a sequence
 * of characters stored one per byte, delimited by EOS='\0'.  The operation
 * may be performed in place.  This version assumes that the host character
 * set is ASCII and hence no lookup table reference to map character sets is
 * needed.  If this is not the case, code must be added to convert to the host
 * character set.
 *
 * 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.
 */
STRPAK (instr, outstr, maxch)
XCHAR	*instr;
PKCHAR	*outstr;
XINT	*maxch;
{
	register XCHAR	*ip = instr;
	register char	*op = (char *)outstr;
	register int	  n = *maxch;

	while ((*op++ = *ip++) != XEOS && --n >= 0)
	    ;
	*--op = EOS;
}