1*7cc98087Sdrochner /* $NetBSD: wordexp.h,v 1.2 2008/04/01 19:23:28 drochner Exp $ */ 22f8bbc11Sseb 32f8bbc11Sseb /*- 42f8bbc11Sseb * Copyright (c) 2002 Tim J. Robbins. 52f8bbc11Sseb * All rights reserved. 62f8bbc11Sseb * 72f8bbc11Sseb * Redistribution and use in source and binary forms, with or without 82f8bbc11Sseb * modification, are permitted provided that the following conditions 92f8bbc11Sseb * are met: 102f8bbc11Sseb * 1. Redistributions of source code must retain the above copyright 112f8bbc11Sseb * notice, this list of conditions and the following disclaimer. 122f8bbc11Sseb * 2. Redistributions in binary form must reproduce the above copyright 132f8bbc11Sseb * notice, this list of conditions and the following disclaimer in the 142f8bbc11Sseb * documentation and/or other materials provided with the distribution. 152f8bbc11Sseb * 162f8bbc11Sseb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 172f8bbc11Sseb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 182f8bbc11Sseb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 192f8bbc11Sseb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 202f8bbc11Sseb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 212f8bbc11Sseb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 222f8bbc11Sseb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 232f8bbc11Sseb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 242f8bbc11Sseb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 252f8bbc11Sseb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 262f8bbc11Sseb * SUCH DAMAGE. 272f8bbc11Sseb * 282f8bbc11Sseb * $FreeBSD: /repoman/r/ncvs/src/include/wordexp.h,v 1.4 2003/01/03 12:03:38 tjr Exp $ 292f8bbc11Sseb */ 302f8bbc11Sseb 312f8bbc11Sseb #ifndef _WORDEXP_H_ 322f8bbc11Sseb #define _WORDEXP_H_ 332f8bbc11Sseb 342f8bbc11Sseb #include <sys/cdefs.h> 352f8bbc11Sseb #include <sys/featuretest.h> 362f8bbc11Sseb #include <machine/ansi.h> 372f8bbc11Sseb 382f8bbc11Sseb #ifdef _BSD_SIZE_T_ 392f8bbc11Sseb typedef _BSD_SIZE_T_ size_t; 402f8bbc11Sseb #undef _BSD_SIZE_T_ 412f8bbc11Sseb #endif 422f8bbc11Sseb 432f8bbc11Sseb 442f8bbc11Sseb typedef struct { 452f8bbc11Sseb size_t we_wordc; /* count of words matched */ 462f8bbc11Sseb char **we_wordv; /* pointer to list of words */ 472f8bbc11Sseb size_t we_offs; /* slots to reserve in we_wordv */ 482f8bbc11Sseb /* following are internals */ 492f8bbc11Sseb char *we_strings; /* storage for wordv strings */ 502f8bbc11Sseb size_t we_nbytes; /* size of we_strings */ 512f8bbc11Sseb } wordexp_t; 522f8bbc11Sseb 532f8bbc11Sseb /* 542f8bbc11Sseb * Flags for wordexp(). 552f8bbc11Sseb */ 562f8bbc11Sseb #define WRDE_APPEND 0x1 /* append to previously generated */ 572f8bbc11Sseb #define WRDE_DOOFFS 0x2 /* we_offs member is valid */ 582f8bbc11Sseb #define WRDE_NOCMD 0x4 /* disallow command substitution */ 592f8bbc11Sseb #define WRDE_REUSE 0x8 /* reuse wordexp_t */ 602f8bbc11Sseb #define WRDE_SHOWERR 0x10 /* don't redirect stderr to /dev/null */ 612f8bbc11Sseb #define WRDE_UNDEF 0x20 /* disallow undefined shell vars */ 622f8bbc11Sseb 632f8bbc11Sseb /* 642f8bbc11Sseb * Return values from wordexp(). 652f8bbc11Sseb */ 662f8bbc11Sseb #define WRDE_BADCHAR 1 /* unquoted special character */ 672f8bbc11Sseb #define WRDE_BADVAL 2 /* undefined variable */ 682f8bbc11Sseb #define WRDE_CMDSUB 3 /* command substitution not allowed */ 692f8bbc11Sseb #define WRDE_NOSPACE 4 /* no memory for result */ 70*7cc98087Sdrochner #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 712f8bbc11Sseb #define WRDE_NOSYS 5 /* obsolete, reserved */ 722f8bbc11Sseb #endif 732f8bbc11Sseb #define WRDE_SYNTAX 6 /* shell syntax error */ 742f8bbc11Sseb #define WRDE_ERRNO 7 /* other errors see errno */ 752f8bbc11Sseb 762f8bbc11Sseb __BEGIN_DECLS 772f8bbc11Sseb int wordexp(const char * __restrict, wordexp_t * __restrict, int); 782f8bbc11Sseb void wordfree(wordexp_t *); 792f8bbc11Sseb __END_DECLS 802f8bbc11Sseb 812f8bbc11Sseb #endif /* !_WORDEXP_H_ */ 82