vis.h revision 113908
1113908Sdes/*	$OpenBSD: vis.h,v 1.5 2002/02/16 21:27:17 millert Exp $	*/
2113908Sdes/*	$NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $	*/
3113908Sdes
4113908Sdes/*-
5113908Sdes * Copyright (c) 1990 The Regents of the University of California.
6113908Sdes * All rights reserved.
7113908Sdes *
8113908Sdes * Redistribution and use in source and binary forms, with or without
9113908Sdes * modification, are permitted provided that the following conditions
10113908Sdes * are met:
11113908Sdes * 1. Redistributions of source code must retain the above copyright
12113908Sdes *    notice, this list of conditions and the following disclaimer.
13113908Sdes * 2. Redistributions in binary form must reproduce the above copyright
14113908Sdes *    notice, this list of conditions and the following disclaimer in the
15113908Sdes *    documentation and/or other materials provided with the distribution.
16113908Sdes * 3. All advertising materials mentioning features or use of this software
17113908Sdes *    must display the following acknowledgement:
18113908Sdes *	This product includes software developed by the University of
19113908Sdes *	California, Berkeley and its contributors.
20113908Sdes * 4. Neither the name of the University nor the names of its contributors
21113908Sdes *    may be used to endorse or promote products derived from this software
22113908Sdes *    without specific prior written permission.
23113908Sdes *
24113908Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25113908Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26113908Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27113908Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28113908Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29113908Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30113908Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31113908Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32113908Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33113908Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34113908Sdes * SUCH DAMAGE.
35113908Sdes *
36113908Sdes *	@(#)vis.h	5.9 (Berkeley) 4/3/91
37113908Sdes */
38113908Sdes#include "config.h"
39113908Sdes#if !defined(HAVE_STRNVIS)
40113908Sdes
41113908Sdes#ifndef _VIS_H_
42113908Sdes#define	_VIS_H_
43113908Sdes
44113908Sdes#include <sys/types.h>
45113908Sdes#include <limits.h>
46113908Sdes
47113908Sdes/*
48113908Sdes * to select alternate encoding format
49113908Sdes */
50113908Sdes#define	VIS_OCTAL	0x01	/* use octal \ddd format */
51113908Sdes#define	VIS_CSTYLE	0x02	/* use \[nrft0..] where appropriate */
52113908Sdes
53113908Sdes/*
54113908Sdes * to alter set of characters encoded (default is to encode all
55113908Sdes * non-graphic except space, tab, and newline).
56113908Sdes */
57113908Sdes#define	VIS_SP		0x04	/* also encode space */
58113908Sdes#define	VIS_TAB		0x08	/* also encode tab */
59113908Sdes#define	VIS_NL		0x10	/* also encode newline */
60113908Sdes#define	VIS_WHITE	(VIS_SP | VIS_TAB | VIS_NL)
61113908Sdes#define	VIS_SAFE	0x20	/* only encode "unsafe" characters */
62113908Sdes
63113908Sdes/*
64113908Sdes * other
65113908Sdes */
66113908Sdes#define	VIS_NOSLASH	0x40	/* inhibit printing '\' */
67113908Sdes
68113908Sdes/*
69113908Sdes * unvis return codes
70113908Sdes */
71113908Sdes#define	UNVIS_VALID	 1	/* character valid */
72113908Sdes#define	UNVIS_VALIDPUSH	 2	/* character valid, push back passed char */
73113908Sdes#define	UNVIS_NOCHAR	 3	/* valid sequence, no character produced */
74113908Sdes#define	UNVIS_SYNBAD	-1	/* unrecognized escape sequence */
75113908Sdes#define	UNVIS_ERROR	-2	/* decoder in unknown state (unrecoverable) */
76113908Sdes
77113908Sdes/*
78113908Sdes * unvis flags
79113908Sdes */
80113908Sdes#define	UNVIS_END	1	/* no more characters */
81113908Sdes
82113908Sdeschar	*vis(char *, int, int, int);
83113908Sdesint	strvis(char *, const char *, int);
84113908Sdesint	strnvis(char *, const char *, size_t, int);
85113908Sdesint	strvisx(char *, const char *, size_t, int);
86113908Sdesint	strunvis(char *, const char *);
87113908Sdesint	unvis(char *, char, int *, int);
88113908Sdes
89113908Sdes#endif /* !_VIS_H_ */
90113908Sdes
91113908Sdes#endif /* !HAVE_STRNVIS */
92