1 /* Copyright (C) 1991,1992,1996-1999,2001,2003,2012
2    Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18 
19 #ifndef	_WORDEXP_H
20 #define	_WORDEXP_H	1
21 
22 #include <features.h>
23 #define __need_size_t
24 #include <stddef.h>
25 
26 __BEGIN_DECLS
27 
28 /* Bits set in the FLAGS argument to `wordexp'.  */
29 enum
30   {
31     WRDE_DOOFFS = (1 << 0),	/* Insert PWORDEXP->we_offs NULLs.  */
32     WRDE_APPEND = (1 << 1),	/* Append to results of a previous call.  */
33     WRDE_NOCMD = (1 << 2),	/* Don't do command substitution.  */
34     WRDE_REUSE = (1 << 3),	/* Reuse storage in PWORDEXP.  */
35     WRDE_SHOWERR = (1 << 4),	/* Don't redirect stderr to /dev/null.  */
36     WRDE_UNDEF = (1 << 5),	/* Error for expanding undefined variables.  */
37     __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD |
38 		    WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF)
39   };
40 
41 /* Structure describing a word-expansion run.  */
42 typedef struct
43   {
44     size_t we_wordc;		/* Count of words matched.  */
45     char **we_wordv;		/* List of expanded words.  */
46     size_t we_offs;		/* Slots to reserve in `we_wordv'.  */
47   } wordexp_t;
48 
49 /* Possible nonzero return values from `wordexp'.  */
50 enum
51   {
52 #ifdef __USE_XOPEN
53     WRDE_NOSYS = -1,		/* Never used since we support `wordexp'.  */
54 #endif
55     WRDE_NOSPACE = 1,		/* Ran out of memory.  */
56     WRDE_BADCHAR,		/* A metachar appears in the wrong place.  */
57     WRDE_BADVAL,		/* Undefined var reference with WRDE_UNDEF.  */
58     WRDE_CMDSUB,		/* Command substitution with WRDE_NOCMD.  */
59     WRDE_SYNTAX			/* Shell syntax error.  */
60   };
61 
62 /* Do word expansion of WORDS into PWORDEXP.  */
63 extern int wordexp (const char *__restrict __words,
64 		    wordexp_t *__restrict __pwordexp, int __flags);
65 
66 /* Free the storage allocated by a `wordexp' call.  */
67 extern void wordfree (wordexp_t *__wordexp) __THROW;
68 
69 __END_DECLS
70 
71 #endif /* wordexp.h  */
72