1 /* Copyright (C) 2002, 2010 by  Red Hat, Incorporated. All rights reserved.
2  *
3  * Permission to use, copy, modify, and distribute this software
4  * is freely granted, provided that this notice is preserved.
5  */
6 
7 #ifndef _WORDEXP_H_
8 #define _WORDEXP_H_
9 
10 #include <sys/types.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 struct _wordexp_t
17 {
18   size_t we_wordc;	/* Count of words matched by words. */
19   char **we_wordv;	/* Pointer to list of expanded words. */
20   size_t we_offs;	/* Slots to reserve at the beginning of we_wordv. */
21 };
22 
23 typedef struct _wordexp_t wordexp_t;
24 
25 #define	WRDE_DOOFFS	0x0001	/* Use we_offs. */
26 #define	WRDE_APPEND	0x0002	/* Append to output from previous call. */
27 #define	WRDE_NOCMD	0x0004	/* Don't perform command substitution. */
28 #define	WRDE_REUSE	0x0008	/* pwordexp points to a wordexp_t struct returned from
29                                    a previous successful call to wordexp. */
30 #define	WRDE_SHOWERR	0x0010	/* Print error messages to stderr. */
31 #define	WRDE_UNDEF	0x0020	/* Report attempt to expand undefined shell variable. */
32 
33 enum {
34   WRDE_SUCCESS,
35   WRDE_NOSPACE,
36   WRDE_BADCHAR,
37   WRDE_BADVAL,
38   WRDE_CMDSUB,
39   WRDE_SYNTAX,
40   WRDE_NOSYS
41 };
42 
43 /* Note: This implementation of wordexp requires a version of bash
44    that supports the --wordexp and --protected arguments to be present
45    on the system.  It does not support the WRDE_UNDEF flag. */
46 int wordexp(const char *__restrict, wordexp_t *__restrict, int);
47 void wordfree(wordexp_t *);
48 
49 #ifdef __cplusplus
50 }
51 #endif
52 
53 #endif /* _WORDEXP_H_  */
54