1248302Sbrooks/*	$NetBSD: vis.h,v 1.21 2013/02/20 17:01:15 christos Exp $	*/
2244401Sbrooks/*	$FreeBSD: releng/10.3/contrib/libc-vis/vis.h 248302 2013-03-14 23:51:47Z brooks $	*/
3241236Sbrooks
4241236Sbrooks/*-
5241236Sbrooks * Copyright (c) 1990, 1993
6241236Sbrooks *	The Regents of the University of California.  All rights reserved.
7241236Sbrooks *
8241236Sbrooks * Redistribution and use in source and binary forms, with or without
9241236Sbrooks * modification, are permitted provided that the following conditions
10241236Sbrooks * are met:
11241236Sbrooks * 1. Redistributions of source code must retain the above copyright
12241236Sbrooks *    notice, this list of conditions and the following disclaimer.
13241236Sbrooks * 2. Redistributions in binary form must reproduce the above copyright
14241236Sbrooks *    notice, this list of conditions and the following disclaimer in the
15241236Sbrooks *    documentation and/or other materials provided with the distribution.
16241236Sbrooks * 3. Neither the name of the University nor the names of its contributors
17241236Sbrooks *    may be used to endorse or promote products derived from this software
18241236Sbrooks *    without specific prior written permission.
19241236Sbrooks *
20241236Sbrooks * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21241236Sbrooks * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22241236Sbrooks * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23241236Sbrooks * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24241236Sbrooks * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25241236Sbrooks * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26241236Sbrooks * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27241236Sbrooks * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28241236Sbrooks * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29241236Sbrooks * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30241236Sbrooks * SUCH DAMAGE.
31241236Sbrooks *
32241236Sbrooks *	@(#)vis.h	8.1 (Berkeley) 6/2/93
33241236Sbrooks */
34241236Sbrooks
35241236Sbrooks#ifndef _VIS_H_
36241236Sbrooks#define	_VIS_H_
37241236Sbrooks
38241236Sbrooks#include <sys/types.h>
39241236Sbrooks
40241236Sbrooks/*
41241236Sbrooks * to select alternate encoding format
42241236Sbrooks */
43244230Sbrooks#define	VIS_OCTAL	0x0001	/* use octal \ddd format */
44244230Sbrooks#define	VIS_CSTYLE	0x0002	/* use \[nrft0..] where appropiate */
45241236Sbrooks
46241236Sbrooks/*
47241236Sbrooks * to alter set of characters encoded (default is to encode all
48241236Sbrooks * non-graphic except space, tab, and newline).
49241236Sbrooks */
50244230Sbrooks#define	VIS_SP		0x0004	/* also encode space */
51244230Sbrooks#define	VIS_TAB		0x0008	/* also encode tab */
52244230Sbrooks#define	VIS_NL		0x0010	/* also encode newline */
53241236Sbrooks#define	VIS_WHITE	(VIS_SP | VIS_TAB | VIS_NL)
54244230Sbrooks#define	VIS_SAFE	0x0020	/* only encode "unsafe" characters */
55241236Sbrooks
56241236Sbrooks/*
57241236Sbrooks * other
58241236Sbrooks */
59244230Sbrooks#define	VIS_NOSLASH	0x0040	/* inhibit printing '\' */
60244230Sbrooks#define	VIS_HTTP1808	0x0080	/* http-style escape % hex hex */
61244230Sbrooks#define	VIS_HTTPSTYLE	0x0080	/* http-style escape % hex hex */
62244401Sbrooks#define	VIS_GLOB	0x0100	/* encode glob(3) magic characters */
63244401Sbrooks#define	VIS_MIMESTYLE	0x0200	/* mime-style escape = HEX HEX */
64244401Sbrooks#define	VIS_HTTP1866	0x0400	/* http-style &#num; or &string; */
65244401Sbrooks#define	VIS_NOESCAPE	0x0800	/* don't decode `\' */
66244401Sbrooks#define	_VIS_END	0x1000	/* for unvis */
67241236Sbrooks
68241236Sbrooks/*
69241236Sbrooks * unvis return codes
70241236Sbrooks */
71241236Sbrooks#define	UNVIS_VALID	 1	/* character valid */
72241236Sbrooks#define	UNVIS_VALIDPUSH	 2	/* character valid, push back passed char */
73241236Sbrooks#define	UNVIS_NOCHAR	 3	/* valid sequence, no character produced */
74241236Sbrooks#define	UNVIS_SYNBAD	-1	/* unrecognized escape sequence */
75241236Sbrooks#define	UNVIS_ERROR	-2	/* decoder in unknown state (unrecoverable) */
76241236Sbrooks
77241236Sbrooks/*
78241236Sbrooks * unvis flags
79241236Sbrooks */
80241236Sbrooks#define	UNVIS_END	_VIS_END	/* no more characters */
81241236Sbrooks
82241236Sbrooks#include <sys/cdefs.h>
83241236Sbrooks
84241236Sbrooks__BEGIN_DECLS
85241236Sbrookschar	*vis(char *, int, int, int);
86241236Sbrookschar	*nvis(char *, size_t, int, int, int);
87241236Sbrooks
88241236Sbrookschar	*svis(char *, int, int, int, const char *);
89241236Sbrookschar	*snvis(char *, size_t, int, int, int, const char *);
90241236Sbrooks
91241236Sbrooksint	strvis(char *, const char *, int);
92241236Sbrooksint	strnvis(char *, size_t, const char *, int);
93241236Sbrooks
94241236Sbrooksint	strsvis(char *, const char *, int, const char *);
95241236Sbrooksint	strsnvis(char *, size_t, const char *, int, const char *);
96241236Sbrooks
97241236Sbrooksint	strvisx(char *, const char *, size_t, int);
98241236Sbrooksint	strnvisx(char *, size_t, const char *, size_t, int);
99248302Sbrooksint 	strenvisx(char *, size_t, const char *, size_t, int, int *);
100241236Sbrooks
101241236Sbrooksint	strsvisx(char *, const char *, size_t, int, const char *);
102241236Sbrooksint	strsnvisx(char *, size_t, const char *, size_t, int, const char *);
103248302Sbrooksint	strsenvisx(char *, size_t, const char *, size_t , int, const char *,
104248302Sbrooks    int *);
105241236Sbrooks
106241236Sbrooksint	strunvis(char *, const char *);
107241236Sbrooksint	strnunvis(char *, size_t, const char *);
108241236Sbrooks
109241236Sbrooksint	strunvisx(char *, const char *, int);
110241236Sbrooksint	strnunvisx(char *, size_t, const char *, int);
111241236Sbrooks
112241236Sbrooks#ifndef __LIBC12_SOURCE__
113244401Sbrooksint	unvis(char *, int, int *, int);
114241236Sbrooks#endif
115241236Sbrooks__END_DECLS
116241236Sbrooks
117241236Sbrooks#endif /* !_VIS_H_ */
118