wordexp.h revision 1.2 1 1.2 drochner /* $NetBSD: wordexp.h,v 1.2 2008/04/01 19:23:28 drochner Exp $ */
2 1.1 seb
3 1.1 seb /*-
4 1.1 seb * Copyright (c) 2002 Tim J. Robbins.
5 1.1 seb * All rights reserved.
6 1.1 seb *
7 1.1 seb * Redistribution and use in source and binary forms, with or without
8 1.1 seb * modification, are permitted provided that the following conditions
9 1.1 seb * are met:
10 1.1 seb * 1. Redistributions of source code must retain the above copyright
11 1.1 seb * notice, this list of conditions and the following disclaimer.
12 1.1 seb * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 seb * notice, this list of conditions and the following disclaimer in the
14 1.1 seb * documentation and/or other materials provided with the distribution.
15 1.1 seb *
16 1.1 seb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.1 seb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.1 seb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1 seb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.1 seb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 seb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1 seb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 seb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1 seb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 seb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 seb * SUCH DAMAGE.
27 1.1 seb *
28 1.1 seb * $FreeBSD: /repoman/r/ncvs/src/include/wordexp.h,v 1.4 2003/01/03 12:03:38 tjr Exp $
29 1.1 seb */
30 1.1 seb
31 1.1 seb #ifndef _WORDEXP_H_
32 1.1 seb #define _WORDEXP_H_
33 1.1 seb
34 1.1 seb #include <sys/cdefs.h>
35 1.1 seb #include <sys/featuretest.h>
36 1.1 seb #include <machine/ansi.h>
37 1.1 seb
38 1.1 seb #ifdef _BSD_SIZE_T_
39 1.1 seb typedef _BSD_SIZE_T_ size_t;
40 1.1 seb #undef _BSD_SIZE_T_
41 1.1 seb #endif
42 1.1 seb
43 1.1 seb
44 1.1 seb typedef struct {
45 1.1 seb size_t we_wordc; /* count of words matched */
46 1.1 seb char **we_wordv; /* pointer to list of words */
47 1.1 seb size_t we_offs; /* slots to reserve in we_wordv */
48 1.1 seb /* following are internals */
49 1.1 seb char *we_strings; /* storage for wordv strings */
50 1.1 seb size_t we_nbytes; /* size of we_strings */
51 1.1 seb } wordexp_t;
52 1.1 seb
53 1.1 seb /*
54 1.1 seb * Flags for wordexp().
55 1.1 seb */
56 1.1 seb #define WRDE_APPEND 0x1 /* append to previously generated */
57 1.1 seb #define WRDE_DOOFFS 0x2 /* we_offs member is valid */
58 1.1 seb #define WRDE_NOCMD 0x4 /* disallow command substitution */
59 1.1 seb #define WRDE_REUSE 0x8 /* reuse wordexp_t */
60 1.1 seb #define WRDE_SHOWERR 0x10 /* don't redirect stderr to /dev/null */
61 1.1 seb #define WRDE_UNDEF 0x20 /* disallow undefined shell vars */
62 1.1 seb
63 1.1 seb /*
64 1.1 seb * Return values from wordexp().
65 1.1 seb */
66 1.1 seb #define WRDE_BADCHAR 1 /* unquoted special character */
67 1.1 seb #define WRDE_BADVAL 2 /* undefined variable */
68 1.1 seb #define WRDE_CMDSUB 3 /* command substitution not allowed */
69 1.1 seb #define WRDE_NOSPACE 4 /* no memory for result */
70 1.2 drochner #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
71 1.1 seb #define WRDE_NOSYS 5 /* obsolete, reserved */
72 1.1 seb #endif
73 1.1 seb #define WRDE_SYNTAX 6 /* shell syntax error */
74 1.1 seb #define WRDE_ERRNO 7 /* other errors see errno */
75 1.1 seb
76 1.1 seb __BEGIN_DECLS
77 1.1 seb int wordexp(const char * __restrict, wordexp_t * __restrict, int);
78 1.1 seb void wordfree(wordexp_t *);
79 1.1 seb __END_DECLS
80 1.1 seb
81 1.1 seb #endif /* !_WORDEXP_H_ */
82