Blame


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