xref: /netbsd-src/crypto/external/bsd/heimdal/dist/lib/roken/vis.hin (revision ca1c9b0c534faa5fd4c7d36fd3c199a2a3d7b0e4)
1*ca1c9b0cSelric/*	NetBSD: vis.h,v 1.16 2005/09/13 01:44:32 christos Exp	*/
2*ca1c9b0cSelric
3*ca1c9b0cSelric/*-
4*ca1c9b0cSelric * Copyright (c) 1990, 1993
5*ca1c9b0cSelric *	The Regents of the University of California.  All rights reserved.
6*ca1c9b0cSelric *
7*ca1c9b0cSelric * Redistribution and use in source and binary forms, with or without
8*ca1c9b0cSelric * modification, are permitted provided that the following conditions
9*ca1c9b0cSelric * are met:
10*ca1c9b0cSelric * 1. Redistributions of source code must retain the above copyright
11*ca1c9b0cSelric *    notice, this list of conditions and the following disclaimer.
12*ca1c9b0cSelric * 2. Redistributions in binary form must reproduce the above copyright
13*ca1c9b0cSelric *    notice, this list of conditions and the following disclaimer in the
14*ca1c9b0cSelric *    documentation and/or other materials provided with the distribution.
15*ca1c9b0cSelric * 3. Neither the name of the University nor the names of its contributors
16*ca1c9b0cSelric *    may be used to endorse or promote products derived from this software
17*ca1c9b0cSelric *    without specific prior written permission.
18*ca1c9b0cSelric *
19*ca1c9b0cSelric * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20*ca1c9b0cSelric * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21*ca1c9b0cSelric * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22*ca1c9b0cSelric * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23*ca1c9b0cSelric * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24*ca1c9b0cSelric * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25*ca1c9b0cSelric * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26*ca1c9b0cSelric * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27*ca1c9b0cSelric * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28*ca1c9b0cSelric * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29*ca1c9b0cSelric * SUCH DAMAGE.
30*ca1c9b0cSelric *
31*ca1c9b0cSelric *	@(#)vis.h	8.1 (Berkeley) 6/2/93
32*ca1c9b0cSelric */
33*ca1c9b0cSelric
34*ca1c9b0cSelric#ifndef _VIS_H_
35*ca1c9b0cSelric#define	_VIS_H_
36*ca1c9b0cSelric
37*ca1c9b0cSelric#ifndef ROKEN_LIB_FUNCTION
38*ca1c9b0cSelric#ifdef _WIN32
39*ca1c9b0cSelric#define ROKEN_LIB_FUNCTION
40*ca1c9b0cSelric#define ROKEN_LIB_CALL     __cdecl
41*ca1c9b0cSelric#else
42*ca1c9b0cSelric#define ROKEN_LIB_FUNCTION
43*ca1c9b0cSelric#define ROKEN_LIB_CALL
44*ca1c9b0cSelric#endif
45*ca1c9b0cSelric#endif
46*ca1c9b0cSelric
47*ca1c9b0cSelric#include <sys/types.h>
48*ca1c9b0cSelric
49*ca1c9b0cSelric#include <roken.h>
50*ca1c9b0cSelric
51*ca1c9b0cSelric/*
52*ca1c9b0cSelric * to select alternate encoding format
53*ca1c9b0cSelric */
54*ca1c9b0cSelric#define	VIS_OCTAL	0x01	/* use octal \ddd format */
55*ca1c9b0cSelric#define	VIS_CSTYLE	0x02	/* use \[nrft0..] where appropiate */
56*ca1c9b0cSelric
57*ca1c9b0cSelric/*
58*ca1c9b0cSelric * to alter set of characters encoded (default is to encode all
59*ca1c9b0cSelric * non-graphic except space, tab, and newline).
60*ca1c9b0cSelric */
61*ca1c9b0cSelric#define	VIS_SP		0x04	/* also encode space */
62*ca1c9b0cSelric#define	VIS_TAB		0x08	/* also encode tab */
63*ca1c9b0cSelric#define	VIS_NL		0x10	/* also encode newline */
64*ca1c9b0cSelric#define	VIS_WHITE	(VIS_SP | VIS_TAB | VIS_NL)
65*ca1c9b0cSelric#define	VIS_SAFE	0x20	/* only encode "unsafe" characters */
66*ca1c9b0cSelric
67*ca1c9b0cSelric/*
68*ca1c9b0cSelric * other
69*ca1c9b0cSelric */
70*ca1c9b0cSelric#define	VIS_NOSLASH	0x40	/* inhibit printing '\' */
71*ca1c9b0cSelric#define	VIS_HTTPSTYLE	0x80	/* http-style escape % HEX HEX */
72*ca1c9b0cSelric
73*ca1c9b0cSelric/*
74*ca1c9b0cSelric * unvis return codes
75*ca1c9b0cSelric */
76*ca1c9b0cSelric#define	UNVIS_VALID	 1	/* character valid */
77*ca1c9b0cSelric#define	UNVIS_VALIDPUSH	 2	/* character valid, push back passed char */
78*ca1c9b0cSelric#define	UNVIS_NOCHAR	 3	/* valid sequence, no character produced */
79*ca1c9b0cSelric#define	UNVIS_SYNBAD	-1	/* unrecognized escape sequence */
80*ca1c9b0cSelric#define	UNVIS_ERROR	-2	/* decoder in unknown state (unrecoverable) */
81*ca1c9b0cSelric
82*ca1c9b0cSelric/*
83*ca1c9b0cSelric * unvis flags
84*ca1c9b0cSelric */
85*ca1c9b0cSelric#define	UNVIS_END	1	/* no more characters */
86*ca1c9b0cSelric
87*ca1c9b0cSelricROKEN_CPP_START
88*ca1c9b0cSelric
89*ca1c9b0cSelricROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
90*ca1c9b0cSelric	rk_vis(char *, int, int, int);
91*ca1c9b0cSelricROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
92*ca1c9b0cSelric	rk_svis(char *, int, int, int, const char *);
93*ca1c9b0cSelricROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
94*ca1c9b0cSelric	rk_strvis(char *, const char *, int);
95*ca1c9b0cSelricROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
96*ca1c9b0cSelric	rk_strsvis(char *, const char *, int, const char *);
97*ca1c9b0cSelricROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
98*ca1c9b0cSelric	rk_strvisx(char *, const char *, size_t, int);
99*ca1c9b0cSelricROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
100*ca1c9b0cSelric	rk_strsvisx(char *, const char *, size_t, int, const char *);
101*ca1c9b0cSelricROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
102*ca1c9b0cSelric	rk_strunvis(char *, const char *);
103*ca1c9b0cSelricROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
104*ca1c9b0cSelric	rk_strunvisx(char *, const char *, int);
105*ca1c9b0cSelricROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
106*ca1c9b0cSelric	rk_unvis(char *, int, int *, int);
107*ca1c9b0cSelric
108*ca1c9b0cSelricROKEN_CPP_END
109*ca1c9b0cSelric
110*ca1c9b0cSelric#ifndef HAVE_VIS
111*ca1c9b0cSelric#undef vis
112*ca1c9b0cSelric#define vis(a,b,c,d) rk_vis(a,b,c,d)
113*ca1c9b0cSelric#endif
114*ca1c9b0cSelric
115*ca1c9b0cSelric#ifndef HAVE_SVIS
116*ca1c9b0cSelric#undef svis
117*ca1c9b0cSelric#define svis(a,b,c,d,e) rk_svis(a,b,c,d,e)
118*ca1c9b0cSelric#endif
119*ca1c9b0cSelric
120*ca1c9b0cSelric#ifndef HAVE_STRVIS
121*ca1c9b0cSelric#undef strvis
122*ca1c9b0cSelric#define strvis(a,b,c) rk_strvis(a,b,c)
123*ca1c9b0cSelric#endif
124*ca1c9b0cSelric
125*ca1c9b0cSelric#ifndef HAVE_STRSVIS
126*ca1c9b0cSelric#undef strsvis
127*ca1c9b0cSelric#define strsvis(a,b,c,d) rk_strsvis(a,b,c,d)
128*ca1c9b0cSelric#endif
129*ca1c9b0cSelric
130*ca1c9b0cSelric#ifndef HAVE_STRVISX
131*ca1c9b0cSelric#undef strvisx
132*ca1c9b0cSelric#define strvisx(a,b,c,d) rk_strvisx(a,b,c,d)
133*ca1c9b0cSelric#endif
134*ca1c9b0cSelric
135*ca1c9b0cSelric#ifndef HAVE_STRSVISX
136*ca1c9b0cSelric#undef strsvisx
137*ca1c9b0cSelric#define strsvisx(a,b,c,d,e) rk_strsvisx(a,b,c,d,e)
138*ca1c9b0cSelric#endif
139*ca1c9b0cSelric
140*ca1c9b0cSelric#ifndef HAVE_STRUNVIS
141*ca1c9b0cSelric#undef strunvis
142*ca1c9b0cSelric#define strunvis(a,b) rk_strunvis(a,b)
143*ca1c9b0cSelric#endif
144*ca1c9b0cSelric
145*ca1c9b0cSelric
146*ca1c9b0cSelric#ifndef HAVE_UNVIS
147*ca1c9b0cSelric#undef unvis
148*ca1c9b0cSelric#define unvis(a,b,c,d) rk_unvis(a,b,c,d)
149*ca1c9b0cSelric#endif
150*ca1c9b0cSelric
151*ca1c9b0cSelric#endif /* !_VIS_H_ */
152