1*9f981eecSandvar /* $NetBSD: vis.h,v 1.26 2022/05/20 21:31:24 andvar Exp $ */ 24d2cbfceScgd 361f28255Scgd /*- 4b7b7322cSperry * Copyright (c) 1990, 1993 5b7b7322cSperry * The Regents of the University of California. All rights reserved. 661f28255Scgd * 761f28255Scgd * Redistribution and use in source and binary forms, with or without 861f28255Scgd * modification, are permitted provided that the following conditions 961f28255Scgd * are met: 1061f28255Scgd * 1. Redistributions of source code must retain the above copyright 1161f28255Scgd * notice, this list of conditions and the following disclaimer. 1261f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright 1361f28255Scgd * notice, this list of conditions and the following disclaimer in the 1461f28255Scgd * documentation and/or other materials provided with the distribution. 15039cc956Sagc * 3. Neither the name of the University nor the names of its contributors 1661f28255Scgd * may be used to endorse or promote products derived from this software 1761f28255Scgd * without specific prior written permission. 1861f28255Scgd * 1961f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2061f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2161f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2261f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2361f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2461f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2561f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2661f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2761f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2861f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2961f28255Scgd * SUCH DAMAGE. 3061f28255Scgd * 31b7b7322cSperry * @(#)vis.h 8.1 (Berkeley) 6/2/93 3261f28255Scgd */ 3361f28255Scgd 3461f28255Scgd #ifndef _VIS_H_ 3561f28255Scgd #define _VIS_H_ 3661f28255Scgd 3732d2556bSlukem #include <sys/types.h> 3832d2556bSlukem 3961f28255Scgd /* 4061f28255Scgd * to select alternate encoding format 4161f28255Scgd */ 42d37bfd64Schristos #define VIS_OCTAL 0x0001 /* use octal \ddd format */ 43*9f981eecSandvar #define VIS_CSTYLE 0x0002 /* use \[nrft0..] where appropriate */ 4461f28255Scgd 4561f28255Scgd /* 4661f28255Scgd * to alter set of characters encoded (default is to encode all 4761f28255Scgd * non-graphic except space, tab, and newline). 4861f28255Scgd */ 49d37bfd64Schristos #define VIS_SP 0x0004 /* also encode space */ 50d37bfd64Schristos #define VIS_TAB 0x0008 /* also encode tab */ 51d37bfd64Schristos #define VIS_NL 0x0010 /* also encode newline */ 5261f28255Scgd #define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) 53d37bfd64Schristos #define VIS_SAFE 0x0020 /* only encode "unsafe" characters */ 54f81dba20Schristos #define VIS_DQ 0x8000 /* also encode double quotes */ 5561f28255Scgd 5661f28255Scgd /* 5761f28255Scgd * other 5861f28255Scgd */ 59d37bfd64Schristos #define VIS_NOSLASH 0x0040 /* inhibit printing '\' */ 60d37bfd64Schristos #define VIS_HTTP1808 0x0080 /* http-style escape % hex hex */ 61d37bfd64Schristos #define VIS_HTTPSTYLE 0x0080 /* http-style escape % hex hex */ 62d37bfd64Schristos #define VIS_MIMESTYLE 0x0100 /* mime-style escape = HEX HEX */ 63d37bfd64Schristos #define VIS_HTTP1866 0x0200 /* http-style &#num; or &string; */ 64d37bfd64Schristos #define VIS_NOESCAPE 0x0400 /* don't decode `\' */ 65d37bfd64Schristos #define _VIS_END 0x0800 /* for unvis */ 66d37bfd64Schristos #define VIS_GLOB 0x1000 /* encode glob(3) magic characters */ 67e36fdb7eSchristos #define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */ 68e36fdb7eSchristos #define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL) 69a7328ae6Schristos #define VIS_NOLOCALE 0x4000 /* encode using the C locale */ 7061f28255Scgd 7161f28255Scgd /* 7261f28255Scgd * unvis return codes 7361f28255Scgd */ 7461f28255Scgd #define UNVIS_VALID 1 /* character valid */ 7561f28255Scgd #define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */ 7661f28255Scgd #define UNVIS_NOCHAR 3 /* valid sequence, no character produced */ 7761f28255Scgd #define UNVIS_SYNBAD -1 /* unrecognized escape sequence */ 7861f28255Scgd #define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */ 7961f28255Scgd 8061f28255Scgd /* 8161f28255Scgd * unvis flags 8261f28255Scgd */ 832d8f83e7Schristos #define UNVIS_END _VIS_END /* no more characters */ 8461f28255Scgd 8561f28255Scgd #include <sys/cdefs.h> 8661f28255Scgd 8761f28255Scgd __BEGIN_DECLS 8819b7469aSperry char *vis(char *, int, int, int); 892d8f83e7Schristos char *nvis(char *, size_t, int, int, int); 902d8f83e7Schristos 9119b7469aSperry char *svis(char *, int, int, int, const char *); 922d8f83e7Schristos char *snvis(char *, size_t, int, int, int, const char *); 932d8f83e7Schristos 9419b7469aSperry int strvis(char *, const char *, int); 953df8d6b9Schristos int stravis(char **, const char *, int); 962d8f83e7Schristos int strnvis(char *, size_t, const char *, int); 972d8f83e7Schristos 9819b7469aSperry int strsvis(char *, const char *, int, const char *); 992d8f83e7Schristos int strsnvis(char *, size_t, const char *, int, const char *); 1002d8f83e7Schristos 10119b7469aSperry int strvisx(char *, const char *, size_t, int); 1022d8f83e7Schristos int strnvisx(char *, size_t, const char *, size_t, int); 10388d1b254Schristos int strenvisx(char *, size_t, const char *, size_t, int, int *); 1042d8f83e7Schristos 10519b7469aSperry int strsvisx(char *, const char *, size_t, int, const char *); 1062d8f83e7Schristos int strsnvisx(char *, size_t, const char *, size_t, int, const char *); 10788d1b254Schristos int strsenvisx(char *, size_t, const char *, size_t , int, const char *, 10888d1b254Schristos int *); 1092d8f83e7Schristos 11019b7469aSperry int strunvis(char *, const char *); 1112d8f83e7Schristos int strnunvis(char *, size_t, const char *); 1122d8f83e7Schristos 11319b7469aSperry int strunvisx(char *, const char *, int); 1142d8f83e7Schristos int strnunvisx(char *, size_t, const char *, int); 1152d8f83e7Schristos 11666412e72Schristos #ifndef __LIBC12_SOURCE__ 1172d8f83e7Schristos int unvis(char *, int, int *, int) __RENAME(__unvis50); 11821e1e24dSfvdl #endif 11961f28255Scgd __END_DECLS 12061f28255Scgd 12161f28255Scgd #endif /* !_VIS_H_ */ 122