wordexp.h revision 131331
11556Srgrimes/*-
21556Srgrimes * Copyright (c) 2002 Tim J. Robbins.
31556Srgrimes * All rights reserved.
41556Srgrimes *
51556Srgrimes * Redistribution and use in source and binary forms, with or without
61556Srgrimes * modification, are permitted provided that the following conditions
71556Srgrimes * are met:
81556Srgrimes * 1. Redistributions of source code must retain the above copyright
91556Srgrimes *    notice, this list of conditions and the following disclaimer.
101556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111556Srgrimes *    notice, this list of conditions and the following disclaimer in the
121556Srgrimes *    documentation and/or other materials provided with the distribution.
131556Srgrimes *
141556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
151556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171556Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
181556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
191556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
201556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
211556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
221556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
231556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
241556Srgrimes * SUCH DAMAGE.
251556Srgrimes *
261556Srgrimes * $FreeBSD: head/include/wordexp.h 131331 2004-06-30 13:55:08Z tjr $
271556Srgrimes */
281556Srgrimes
291556Srgrimes#ifndef _WORDEXP_H_
301556Srgrimes#define	_WORDEXP_H_
311556Srgrimes
321556Srgrimes#include <sys/cdefs.h>
331556Srgrimes#include <sys/_types.h>
3436150Scharnier
3536150Scharnier#if __XSI_VISIBLE && !defined(_SIZE_T_DECLARED)
3636150Scharniertypedef	__size_t	size_t;
371556Srgrimes#define	_SIZE_T_DECLARED
3899110Sobrien#endif
3999110Sobrien
401556Srgrimestypedef struct {
4117987Speter	__size_t	we_wordc;	/* count of words matched */
4217987Speter	char		**we_wordv;	/* pointer to list of words */
4317987Speter	__size_t	we_offs;	/* slots to reserve in we_wordv */
4420425Ssteve	char		*we_strings;	/* storage for wordv strings */
4517987Speter	__size_t	we_nbytes;	/* size of we_strings */
4617987Speter} wordexp_t;
47100661Stjr
4817987Speter/*
491556Srgrimes * Flags for wordexp().
501556Srgrimes */
511556Srgrimes#define	WRDE_APPEND	0x1		/* append to previously generated */
521556Srgrimes#define	WRDE_DOOFFS	0x2		/* we_offs member is valid */
531556Srgrimes#define	WRDE_NOCMD	0x4		/* disallow command substitution */
541556Srgrimes#define	WRDE_REUSE	0x8		/* reuse wordexp_t */
551556Srgrimes#define	WRDE_SHOWERR	0x10		/* don't redirect stderr to /dev/null */
561556Srgrimes#define	WRDE_UNDEF	0x20		/* disallow undefined shell vars */
571556Srgrimes
581556Srgrimes/*
591556Srgrimes * Return values from wordexp().
601556Srgrimes */
6120425Ssteve#define	WRDE_BADCHAR	1		/* unquoted special character */
6217987Speter#define	WRDE_BADVAL	2		/* undefined variable */
631556Srgrimes#define	WRDE_CMDSUB	3		/* command substitution not allowed */
6417987Speter#define	WRDE_NOSPACE	4		/* no memory for result */
6520425Ssteve#if __XSI_VISIBLE
661556Srgrimes#define	WRDE_NOSYS	5		/* obsolete, reserved */
6797092Stjr#endif
6897092Stjr#define	WRDE_SYNTAX	6		/* shell syntax error */
6997092Stjr
7090111Simp__BEGIN_DECLS
71176521Sstefanfint	wordexp(const char * __restrict, wordexp_t * __restrict, int);
72176521Sstefanfvoid	wordfree(wordexp_t *);
73176521Sstefanf__END_DECLS
741556Srgrimes
75117261Sdds#endif /* !_WORDEXP_H_ */
76117261Sdds