xref: /illumos-gate/usr/src/head/wordexp.h (revision 3ba944265c4ae1fcf23ef758537c2e4f4feec16e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24  *
25  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 /*
30  * Copyright 1985, 1992 by Mortice Kern Systems Inc.  All rights reserved.
31  */
32 
33 #ifndef	_WORDEXP_H
34 #define	_WORDEXP_H
35 
36 #include <sys/feature_tests.h>
37 #include <sys/types.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 typedef	struct	wordexp_t {
44 	size_t	we_wordc;		/* Count of paths matched by pattern */
45 	char	**we_wordv;		/* List of matched pathnames */
46 	size_t	we_offs;		/* # of slots reserved in we_pathv */
47 	/* following are internal to the implementation */
48 	char	**we_wordp;		/* we_pathv + we_offs */
49 	int	we_wordn;		/* # of elements allocated */
50 } wordexp_t;
51 
52 /*
53  * wordexp flags.
54  */
55 #define	WRDE_APPEND	0x0001		/* append to existing wordexp_t */
56 #define	WRDE_DOOFFS	0x0002		/* use we_offs */
57 #define	WRDE_NOCMD	0x0004		/* don't allow $() */
58 #define	WRDE_REUSE	0x0008
59 #define	WRDE_SHOWERR	0x0010		/* don't 2>/dev/null */
60 #define	WRDE_UNDEF	0x0020		/* set -u */
61 
62 /*
63  * wordexp errors.
64  */
65 #define	WRDE_ERRNO	(2)		/* error in "errno" */
66 #define	WRDE_BADCHAR	(3)		/* shell syntax character */
67 #define	WRDE_BADVAL	(4)		/* undefined variable expanded */
68 #define	WRDE_CMDSUB	(5)		/* prohibited $() */
69 #define	WRDE_NOSPACE	(6)		/* no memory */
70 #define	WRDE_SYNTAX	(7)		/* bad syntax */
71 #define	WRDE_NOSYS	(8)		/* function not supported (XPG4) */
72 
73 extern int wordexp(const char *_RESTRICT_KYWD, wordexp_t *_RESTRICT_KYWD, int);
74 extern void wordfree(wordexp_t *);
75 
76 #ifdef	__cplusplus
77 }
78 #endif
79 
80 #endif	/* _WORDEXP_H */
81