1323124Sdes/*	$OpenBSD: vis.h,v 1.15 2015/07/20 01:52:27 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.
16124208Sdes * 3. Neither the name of the University nor the names of its contributors
17113908Sdes *    may be used to endorse or promote products derived from this software
18113908Sdes *    without specific prior written permission.
19113908Sdes *
20113908Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21113908Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22113908Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23113908Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24113908Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25113908Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26113908Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27113908Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28113908Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29113908Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30113908Sdes * SUCH DAMAGE.
31113908Sdes *
32113908Sdes *	@(#)vis.h	5.9 (Berkeley) 4/3/91
33113908Sdes */
34124208Sdes
35157016Sdes/* OPENBSD ORIGINAL: include/vis.h */
36157016Sdes
37124208Sdes#include "includes.h"
38248619Sdes#if !defined(HAVE_STRNVIS) || defined(BROKEN_STRNVIS)
39113908Sdes
40113908Sdes#ifndef _VIS_H_
41113908Sdes#define	_VIS_H_
42113908Sdes
43113908Sdes#include <sys/types.h>
44113908Sdes#include <limits.h>
45113908Sdes
46113908Sdes/*
47113908Sdes * to select alternate encoding format
48113908Sdes */
49113908Sdes#define	VIS_OCTAL	0x01	/* use octal \ddd format */
50113908Sdes#define	VIS_CSTYLE	0x02	/* use \[nrft0..] where appropriate */
51113908Sdes
52113908Sdes/*
53113908Sdes * to alter set of characters encoded (default is to encode all
54113908Sdes * non-graphic except space, tab, and newline).
55113908Sdes */
56113908Sdes#define	VIS_SP		0x04	/* also encode space */
57113908Sdes#define	VIS_TAB		0x08	/* also encode tab */
58113908Sdes#define	VIS_NL		0x10	/* also encode newline */
59113908Sdes#define	VIS_WHITE	(VIS_SP | VIS_TAB | VIS_NL)
60113908Sdes#define	VIS_SAFE	0x20	/* only encode "unsafe" characters */
61323124Sdes#define	VIS_DQ		0x200	/* backslash-escape double quotes */
62323124Sdes#define	VIS_ALL		0x400	/* encode all characters */
63113908Sdes
64113908Sdes/*
65113908Sdes * other
66113908Sdes */
67113908Sdes#define	VIS_NOSLASH	0x40	/* inhibit printing '\' */
68157016Sdes#define	VIS_GLOB	0x100	/* encode glob(3) magics and '#' */
69113908Sdes
70113908Sdes/*
71113908Sdes * unvis return codes
72113908Sdes */
73113908Sdes#define	UNVIS_VALID	 1	/* character valid */
74113908Sdes#define	UNVIS_VALIDPUSH	 2	/* character valid, push back passed char */
75113908Sdes#define	UNVIS_NOCHAR	 3	/* valid sequence, no character produced */
76113908Sdes#define	UNVIS_SYNBAD	-1	/* unrecognized escape sequence */
77113908Sdes#define	UNVIS_ERROR	-2	/* decoder in unknown state (unrecoverable) */
78113908Sdes
79113908Sdes/*
80113908Sdes * unvis flags
81113908Sdes */
82113908Sdes#define	UNVIS_END	1	/* no more characters */
83113908Sdes
84113908Sdeschar	*vis(char *, int, int, int);
85113908Sdesint	strvis(char *, const char *, int);
86323124Sdesint	stravis(char **, const char *, int);
87157016Sdesint	strnvis(char *, const char *, size_t, int)
88157016Sdes		__attribute__ ((__bounded__(__string__,1,3)));
89157016Sdesint	strvisx(char *, const char *, size_t, int)
90157016Sdes		__attribute__ ((__bounded__(__string__,1,3)));
91113908Sdesint	strunvis(char *, const char *);
92113908Sdesint	unvis(char *, char, int *, int);
93157016Sdesssize_t strnunvis(char *, const char *, size_t)
94157016Sdes		__attribute__ ((__bounded__(__string__,1,3)));
95113908Sdes
96113908Sdes#endif /* !_VIS_H_ */
97113908Sdes
98248619Sdes#endif /* !HAVE_STRNVIS || BROKEN_STRNVIS */
99