Blame


1 0d6fb46a 2022-01-09 op /* $OpenBSD: vis.h,v 1.15 2015/07/20 01:52:27 millert Exp $ */
2 0d6fb46a 2022-01-09 op /* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */
3 0d6fb46a 2022-01-09 op
4 0d6fb46a 2022-01-09 op /*-
5 0d6fb46a 2022-01-09 op * Copyright (c) 1990 The Regents of the University of California.
6 0d6fb46a 2022-01-09 op * All rights reserved.
7 0d6fb46a 2022-01-09 op *
8 0d6fb46a 2022-01-09 op * Redistribution and use in source and binary forms, with or without
9 0d6fb46a 2022-01-09 op * modification, are permitted provided that the following conditions
10 0d6fb46a 2022-01-09 op * are met:
11 0d6fb46a 2022-01-09 op * 1. Redistributions of source code must retain the above copyright
12 0d6fb46a 2022-01-09 op * notice, this list of conditions and the following disclaimer.
13 0d6fb46a 2022-01-09 op * 2. Redistributions in binary form must reproduce the above copyright
14 0d6fb46a 2022-01-09 op * notice, this list of conditions and the following disclaimer in the
15 0d6fb46a 2022-01-09 op * documentation and/or other materials provided with the distribution.
16 0d6fb46a 2022-01-09 op * 3. Neither the name of the University nor the names of its contributors
17 0d6fb46a 2022-01-09 op * may be used to endorse or promote products derived from this software
18 0d6fb46a 2022-01-09 op * without specific prior written permission.
19 0d6fb46a 2022-01-09 op *
20 0d6fb46a 2022-01-09 op * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 0d6fb46a 2022-01-09 op * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 0d6fb46a 2022-01-09 op * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 0d6fb46a 2022-01-09 op * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 0d6fb46a 2022-01-09 op * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 0d6fb46a 2022-01-09 op * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 0d6fb46a 2022-01-09 op * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 0d6fb46a 2022-01-09 op * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 0d6fb46a 2022-01-09 op * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 0d6fb46a 2022-01-09 op * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 0d6fb46a 2022-01-09 op * SUCH DAMAGE.
31 0d6fb46a 2022-01-09 op *
32 0d6fb46a 2022-01-09 op * @(#)vis.h 5.9 (Berkeley) 4/3/91
33 0d6fb46a 2022-01-09 op */
34 0d6fb46a 2022-01-09 op
35 0d6fb46a 2022-01-09 op #ifndef _VIS_H_
36 0d6fb46a 2022-01-09 op #define _VIS_H_
37 0d6fb46a 2022-01-09 op
38 0d6fb46a 2022-01-09 op /*
39 0d6fb46a 2022-01-09 op * to select alternate encoding format
40 0d6fb46a 2022-01-09 op */
41 0d6fb46a 2022-01-09 op #define VIS_OCTAL 0x01 /* use octal \ddd format */
42 0d6fb46a 2022-01-09 op #define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */
43 0d6fb46a 2022-01-09 op
44 0d6fb46a 2022-01-09 op /*
45 0d6fb46a 2022-01-09 op * to alter set of characters encoded (default is to encode all
46 0d6fb46a 2022-01-09 op * non-graphic except space, tab, and newline).
47 0d6fb46a 2022-01-09 op */
48 0d6fb46a 2022-01-09 op #define VIS_SP 0x04 /* also encode space */
49 0d6fb46a 2022-01-09 op #define VIS_TAB 0x08 /* also encode tab */
50 0d6fb46a 2022-01-09 op #define VIS_NL 0x10 /* also encode newline */
51 0d6fb46a 2022-01-09 op #define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
52 0d6fb46a 2022-01-09 op #define VIS_SAFE 0x20 /* only encode "unsafe" characters */
53 0d6fb46a 2022-01-09 op #define VIS_DQ 0x200 /* backslash-escape double quotes */
54 0d6fb46a 2022-01-09 op #define VIS_ALL 0x400 /* encode all characters */
55 0d6fb46a 2022-01-09 op
56 0d6fb46a 2022-01-09 op /*
57 0d6fb46a 2022-01-09 op * other
58 0d6fb46a 2022-01-09 op */
59 0d6fb46a 2022-01-09 op #define VIS_NOSLASH 0x40 /* inhibit printing '\' */
60 0d6fb46a 2022-01-09 op #define VIS_GLOB 0x100 /* encode glob(3) magics and '#' */
61 0d6fb46a 2022-01-09 op
62 0d6fb46a 2022-01-09 op /*
63 0d6fb46a 2022-01-09 op * unvis return codes
64 0d6fb46a 2022-01-09 op */
65 0d6fb46a 2022-01-09 op #define UNVIS_VALID 1 /* character valid */
66 0d6fb46a 2022-01-09 op #define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
67 0d6fb46a 2022-01-09 op #define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
68 0d6fb46a 2022-01-09 op #define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
69 0d6fb46a 2022-01-09 op #define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
70 0d6fb46a 2022-01-09 op
71 0d6fb46a 2022-01-09 op /*
72 0d6fb46a 2022-01-09 op * unvis flags
73 0d6fb46a 2022-01-09 op */
74 0d6fb46a 2022-01-09 op #define UNVIS_END 1 /* no more characters */
75 0d6fb46a 2022-01-09 op
76 0d6fb46a 2022-01-09 op #include <sys/cdefs.h>
77 0d6fb46a 2022-01-09 op
78 0d6fb46a 2022-01-09 op char *vis(char *, int, int, int);
79 0d6fb46a 2022-01-09 op int strvis(char *, const char *, int);
80 0d6fb46a 2022-01-09 op int stravis(char **, const char *, int);
81 0d6fb46a 2022-01-09 op int strnvis(char *, const char *, size_t, int)
82 0d6fb46a 2022-01-09 op __attribute__ ((__bounded__(__string__,1,3)));
83 0d6fb46a 2022-01-09 op int strvisx(char *, const char *, size_t, int)
84 0d6fb46a 2022-01-09 op __attribute__ ((__bounded__(__string__,1,3)));
85 0d6fb46a 2022-01-09 op int strunvis(char *, const char *);
86 0d6fb46a 2022-01-09 op int unvis(char *, char, int *, int);
87 0d6fb46a 2022-01-09 op ssize_t strnunvis(char *, const char *, size_t)
88 0d6fb46a 2022-01-09 op __attribute__ ((__bounded__(__string__,1,3)));
89 0d6fb46a 2022-01-09 op
90 0d6fb46a 2022-01-09 op #endif /* !_VIS_H_ */