Blame


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