1108287Stjr/*-
2108287Stjr * Copyright (c) 2002 Tim J. Robbins.
3108287Stjr * All rights reserved.
4108287Stjr *
5108287Stjr * Redistribution and use in source and binary forms, with or without
6108287Stjr * modification, are permitted provided that the following conditions
7108287Stjr * are met:
8108287Stjr * 1. Redistributions of source code must retain the above copyright
9108287Stjr *    notice, this list of conditions and the following disclaimer.
10108287Stjr * 2. Redistributions in binary form must reproduce the above copyright
11108287Stjr *    notice, this list of conditions and the following disclaimer in the
12108287Stjr *    documentation and/or other materials provided with the distribution.
13108287Stjr *
14108287Stjr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15108287Stjr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16108287Stjr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17108287Stjr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18108287Stjr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19108287Stjr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20108287Stjr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21108287Stjr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22108287Stjr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23108287Stjr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24108287Stjr * SUCH DAMAGE.
25108287Stjr *
26108287Stjr * $FreeBSD$
27108287Stjr */
28108287Stjr
29108287Stjr#ifndef _WORDEXP_H_
30108287Stjr#define	_WORDEXP_H_
31108287Stjr
32108287Stjr#include <sys/cdefs.h>
33108287Stjr#include <sys/_types.h>
34108287Stjr
35108287Stjr#if __XSI_VISIBLE && !defined(_SIZE_T_DECLARED)
36108287Stjrtypedef	__size_t	size_t;
37108287Stjr#define	_SIZE_T_DECLARED
38108287Stjr#endif
39108287Stjr
40108287Stjrtypedef struct {
41108291Stjr	__size_t	we_wordc;	/* count of words matched */
42108291Stjr	char		**we_wordv;	/* pointer to list of words */
43108291Stjr	__size_t	we_offs;	/* slots to reserve in we_wordv */
44108291Stjr	char		*we_strings;	/* storage for wordv strings */
45108291Stjr	__size_t	we_nbytes;	/* size of we_strings */
46108287Stjr} wordexp_t;
47108287Stjr
48108287Stjr/*
49108287Stjr * Flags for wordexp().
50108287Stjr */
51108287Stjr#define	WRDE_APPEND	0x1		/* append to previously generated */
52131331Stjr#define	WRDE_DOOFFS	0x2		/* we_offs member is valid */
53108596Stjr#define	WRDE_NOCMD	0x4		/* disallow command substitution */
54108287Stjr#define	WRDE_REUSE	0x8		/* reuse wordexp_t */
55108287Stjr#define	WRDE_SHOWERR	0x10		/* don't redirect stderr to /dev/null */
56108287Stjr#define	WRDE_UNDEF	0x20		/* disallow undefined shell vars */
57108287Stjr
58108287Stjr/*
59108287Stjr * Return values from wordexp().
60108287Stjr */
61108287Stjr#define	WRDE_BADCHAR	1		/* unquoted special character */
62108287Stjr#define	WRDE_BADVAL	2		/* undefined variable */
63108287Stjr#define	WRDE_CMDSUB	3		/* command substitution not allowed */
64108287Stjr#define	WRDE_NOSPACE	4		/* no memory for result */
65108287Stjr#if __XSI_VISIBLE
66108287Stjr#define	WRDE_NOSYS	5		/* obsolete, reserved */
67108287Stjr#endif
68108287Stjr#define	WRDE_SYNTAX	6		/* shell syntax error */
69108287Stjr
70108287Stjr__BEGIN_DECLS
71108290Stjrint	wordexp(const char * __restrict, wordexp_t * __restrict, int);
72108287Stjrvoid	wordfree(wordexp_t *);
73108287Stjr__END_DECLS
74108287Stjr
75108287Stjr#endif /* !_WORDEXP_H_ */
76