1*ea46e638SKyle Evans /* $NetBSD: vis.h,v 1.26 2022/05/20 21:31:24 andvar Exp $ */ 28ccca122SBrooks Davis 38ccca122SBrooks Davis /*- 48ccca122SBrooks Davis * Copyright (c) 1990, 1993 58ccca122SBrooks Davis * The Regents of the University of California. All rights reserved. 68ccca122SBrooks Davis * 78ccca122SBrooks Davis * Redistribution and use in source and binary forms, with or without 88ccca122SBrooks Davis * modification, are permitted provided that the following conditions 98ccca122SBrooks Davis * are met: 108ccca122SBrooks Davis * 1. Redistributions of source code must retain the above copyright 118ccca122SBrooks Davis * notice, this list of conditions and the following disclaimer. 128ccca122SBrooks Davis * 2. Redistributions in binary form must reproduce the above copyright 138ccca122SBrooks Davis * notice, this list of conditions and the following disclaimer in the 148ccca122SBrooks Davis * documentation and/or other materials provided with the distribution. 158ccca122SBrooks Davis * 3. Neither the name of the University nor the names of its contributors 168ccca122SBrooks Davis * may be used to endorse or promote products derived from this software 178ccca122SBrooks Davis * without specific prior written permission. 188ccca122SBrooks Davis * 198ccca122SBrooks Davis * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 208ccca122SBrooks Davis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 218ccca122SBrooks Davis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 228ccca122SBrooks Davis * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 238ccca122SBrooks Davis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 248ccca122SBrooks Davis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 258ccca122SBrooks Davis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 268ccca122SBrooks Davis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 278ccca122SBrooks Davis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 288ccca122SBrooks Davis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 298ccca122SBrooks Davis * SUCH DAMAGE. 308ccca122SBrooks Davis * 318ccca122SBrooks Davis * @(#)vis.h 8.1 (Berkeley) 6/2/93 328ccca122SBrooks Davis */ 338ccca122SBrooks Davis 348ccca122SBrooks Davis #ifndef _VIS_H_ 358ccca122SBrooks Davis #define _VIS_H_ 368ccca122SBrooks Davis 378ccca122SBrooks Davis #include <sys/types.h> 388ccca122SBrooks Davis 398ccca122SBrooks Davis /* 408ccca122SBrooks Davis * to select alternate encoding format 418ccca122SBrooks Davis */ 428ccca122SBrooks Davis #define VIS_OCTAL 0x0001 /* use octal \ddd format */ 43*ea46e638SKyle Evans #define VIS_CSTYLE 0x0002 /* use \[nrft0..] where appropriate */ 448ccca122SBrooks Davis 458ccca122SBrooks Davis /* 468ccca122SBrooks Davis * to alter set of characters encoded (default is to encode all 478ccca122SBrooks Davis * non-graphic except space, tab, and newline). 488ccca122SBrooks Davis */ 498ccca122SBrooks Davis #define VIS_SP 0x0004 /* also encode space */ 508ccca122SBrooks Davis #define VIS_TAB 0x0008 /* also encode tab */ 518ccca122SBrooks Davis #define VIS_NL 0x0010 /* also encode newline */ 528ccca122SBrooks Davis #define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) 538ccca122SBrooks Davis #define VIS_SAFE 0x0020 /* only encode "unsafe" characters */ 54ff88ef41SBrooks Davis #define VIS_DQ 0x8000 /* also encode double quotes */ 558ccca122SBrooks Davis 568ccca122SBrooks Davis /* 578ccca122SBrooks Davis * other 588ccca122SBrooks Davis */ 598ccca122SBrooks Davis #define VIS_NOSLASH 0x0040 /* inhibit printing '\' */ 608ccca122SBrooks Davis #define VIS_HTTP1808 0x0080 /* http-style escape % hex hex */ 618ccca122SBrooks Davis #define VIS_HTTPSTYLE 0x0080 /* http-style escape % hex hex */ 628ccca122SBrooks Davis #define VIS_GLOB 0x0100 /* encode glob(3) magic characters */ 638ccca122SBrooks Davis #define VIS_MIMESTYLE 0x0200 /* mime-style escape = HEX HEX */ 648ccca122SBrooks Davis #define VIS_HTTP1866 0x0400 /* http-style &#num; or &string; */ 658ccca122SBrooks Davis #define VIS_NOESCAPE 0x0800 /* don't decode `\' */ 668ccca122SBrooks Davis #define _VIS_END 0x1000 /* for unvis */ 678dfeba04SBrooks Davis #define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */ 688dfeba04SBrooks Davis #define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL) 698dfeba04SBrooks Davis #define VIS_NOLOCALE 0x4000 /* encode using the C locale */ 708ccca122SBrooks Davis 718ccca122SBrooks Davis /* 728ccca122SBrooks Davis * unvis return codes 738ccca122SBrooks Davis */ 748ccca122SBrooks Davis #define UNVIS_VALID 1 /* character valid */ 758ccca122SBrooks Davis #define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */ 768ccca122SBrooks Davis #define UNVIS_NOCHAR 3 /* valid sequence, no character produced */ 778ccca122SBrooks Davis #define UNVIS_SYNBAD -1 /* unrecognized escape sequence */ 788ccca122SBrooks Davis #define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */ 798ccca122SBrooks Davis 808ccca122SBrooks Davis /* 818ccca122SBrooks Davis * unvis flags 828ccca122SBrooks Davis */ 838ccca122SBrooks Davis #define UNVIS_END _VIS_END /* no more characters */ 848ccca122SBrooks Davis 858ccca122SBrooks Davis #include <sys/cdefs.h> 868ccca122SBrooks Davis 878ccca122SBrooks Davis __BEGIN_DECLS 888ccca122SBrooks Davis char *vis(char *, int, int, int); 898ccca122SBrooks Davis char *nvis(char *, size_t, int, int, int); 908ccca122SBrooks Davis 918ccca122SBrooks Davis char *svis(char *, int, int, int, const char *); 928ccca122SBrooks Davis char *snvis(char *, size_t, int, int, int, const char *); 938ccca122SBrooks Davis 948ccca122SBrooks Davis int strvis(char *, const char *, int); 958dfeba04SBrooks Davis int stravis(char **, const char *, int); 968ccca122SBrooks Davis int strnvis(char *, size_t, const char *, int); 978ccca122SBrooks Davis 988ccca122SBrooks Davis int strsvis(char *, const char *, int, const char *); 998ccca122SBrooks Davis int strsnvis(char *, size_t, const char *, int, const char *); 1008ccca122SBrooks Davis 1018ccca122SBrooks Davis int strvisx(char *, const char *, size_t, int); 1028ccca122SBrooks Davis int strnvisx(char *, size_t, const char *, size_t, int); 103778c12a6SBrooks Davis int strenvisx(char *, size_t, const char *, size_t, int, int *); 1048ccca122SBrooks Davis 1058ccca122SBrooks Davis int strsvisx(char *, const char *, size_t, int, const char *); 1068ccca122SBrooks Davis int strsnvisx(char *, size_t, const char *, size_t, int, const char *); 107778c12a6SBrooks Davis int strsenvisx(char *, size_t, const char *, size_t , int, const char *, 108778c12a6SBrooks Davis int *); 1098ccca122SBrooks Davis 1108ccca122SBrooks Davis int strunvis(char *, const char *); 1118ccca122SBrooks Davis int strnunvis(char *, size_t, const char *); 1128ccca122SBrooks Davis 1138ccca122SBrooks Davis int strunvisx(char *, const char *, int); 1148ccca122SBrooks Davis int strnunvisx(char *, size_t, const char *, int); 1158ccca122SBrooks Davis 1168ccca122SBrooks Davis #ifndef __LIBC12_SOURCE__ 1178ccca122SBrooks Davis int unvis(char *, int, int *, int); 1188ccca122SBrooks Davis #endif 1198ccca122SBrooks Davis __END_DECLS 1208ccca122SBrooks Davis 1218ccca122SBrooks Davis #endif /* !_VIS_H_ */ 122