Blame


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