156f56252STim J. Robbins /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3e58eb3c4SPedro F. Giffuni * 456f56252STim J. Robbins * Copyright (c) 2002 Tim J. Robbins. 556f56252STim J. Robbins * All rights reserved. 656f56252STim J. Robbins * 756f56252STim J. Robbins * Redistribution and use in source and binary forms, with or without 856f56252STim J. Robbins * modification, are permitted provided that the following conditions 956f56252STim J. Robbins * are met: 1056f56252STim J. Robbins * 1. Redistributions of source code must retain the above copyright 1156f56252STim J. Robbins * notice, this list of conditions and the following disclaimer. 1256f56252STim J. Robbins * 2. Redistributions in binary form must reproduce the above copyright 1356f56252STim J. Robbins * notice, this list of conditions and the following disclaimer in the 1456f56252STim J. Robbins * documentation and/or other materials provided with the distribution. 1556f56252STim J. Robbins * 1656f56252STim J. Robbins * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1756f56252STim J. Robbins * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1856f56252STim J. Robbins * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1956f56252STim J. Robbins * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2056f56252STim J. Robbins * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2156f56252STim J. Robbins * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2256f56252STim J. Robbins * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2356f56252STim J. Robbins * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2456f56252STim J. Robbins * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2556f56252STim J. Robbins * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2656f56252STim J. Robbins * SUCH DAMAGE. 2756f56252STim J. Robbins */ 2856f56252STim J. Robbins 2956f56252STim J. Robbins #ifndef _WORDEXP_H_ 3056f56252STim J. Robbins #define _WORDEXP_H_ 3156f56252STim J. Robbins 3256f56252STim J. Robbins #include <sys/cdefs.h> 3356f56252STim J. Robbins #include <sys/_types.h> 3456f56252STim J. Robbins 3556f56252STim J. Robbins #if __XSI_VISIBLE && !defined(_SIZE_T_DECLARED) 3656f56252STim J. Robbins typedef __size_t size_t; 3756f56252STim J. Robbins #define _SIZE_T_DECLARED 3856f56252STim J. Robbins #endif 3956f56252STim J. Robbins 4056f56252STim J. Robbins typedef struct { 41cd3edecbSTim J. Robbins __size_t we_wordc; /* count of words matched */ 4256f56252STim J. Robbins char **we_wordv; /* pointer to list of words */ 43cd3edecbSTim J. Robbins __size_t we_offs; /* slots to reserve in we_wordv */ 4456f56252STim J. Robbins char *we_strings; /* storage for wordv strings */ 45cd3edecbSTim J. Robbins __size_t we_nbytes; /* size of we_strings */ 4656f56252STim J. Robbins } wordexp_t; 4756f56252STim J. Robbins 4856f56252STim J. Robbins /* 4956f56252STim J. Robbins * Flags for wordexp(). 5056f56252STim J. Robbins */ 5156f56252STim J. Robbins #define WRDE_APPEND 0x1 /* append to previously generated */ 52b7114d4aSTim J. Robbins #define WRDE_DOOFFS 0x2 /* we_offs member is valid */ 537f872fe3STim J. Robbins #define WRDE_NOCMD 0x4 /* disallow command substitution */ 5456f56252STim J. Robbins #define WRDE_REUSE 0x8 /* reuse wordexp_t */ 5556f56252STim J. Robbins #define WRDE_SHOWERR 0x10 /* don't redirect stderr to /dev/null */ 5656f56252STim J. Robbins #define WRDE_UNDEF 0x20 /* disallow undefined shell vars */ 5756f56252STim J. Robbins 5856f56252STim J. Robbins /* 5956f56252STim J. Robbins * Return values from wordexp(). 6056f56252STim J. Robbins */ 6156f56252STim J. Robbins #define WRDE_BADCHAR 1 /* unquoted special character */ 6256f56252STim J. Robbins #define WRDE_BADVAL 2 /* undefined variable */ 6356f56252STim J. Robbins #define WRDE_CMDSUB 3 /* command substitution not allowed */ 6456f56252STim J. Robbins #define WRDE_NOSPACE 4 /* no memory for result */ 6556f56252STim J. Robbins #if __XSI_VISIBLE 6656f56252STim J. Robbins #define WRDE_NOSYS 5 /* obsolete, reserved */ 6756f56252STim J. Robbins #endif 6856f56252STim J. Robbins #define WRDE_SYNTAX 6 /* shell syntax error */ 6956f56252STim J. Robbins 7056f56252STim J. Robbins __BEGIN_DECLS 718eca3fa1STim J. Robbins int wordexp(const char * __restrict, wordexp_t * __restrict, int); 7256f56252STim J. Robbins void wordfree(wordexp_t *); 7356f56252STim J. Robbins __END_DECLS 7456f56252STim J. Robbins 7556f56252STim J. Robbins #endif /* !_WORDEXP_H_ */ 76