Back to index

glibc  2.9
wordexp.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991, 92, 1996-1999, 2001, 2003 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef       _WORDEXP_H
00020 #define       _WORDEXP_H    1
00021 
00022 #include <features.h>
00023 #define __need_size_t
00024 #include <stddef.h>
00025 
00026 __BEGIN_DECLS
00027 
00028 /* Bits set in the FLAGS argument to `wordexp'.  */
00029 enum
00030   {
00031     WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs.  */
00032     WRDE_APPEND = (1 << 1), /* Append to results of a previous call.  */
00033     WRDE_NOCMD = (1 << 2),  /* Don't do command substitution.  */
00034     WRDE_REUSE = (1 << 3),  /* Reuse storage in PWORDEXP.  */
00035     WRDE_SHOWERR = (1 << 4),       /* Don't redirect stderr to /dev/null.  */
00036     WRDE_UNDEF = (1 << 5),  /* Error for expanding undefined variables.  */
00037     __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD |
00038                   WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF)
00039   };
00040 
00041 /* Structure describing a word-expansion run.  */
00042 typedef struct
00043   {
00044     size_t we_wordc;        /* Count of words matched.  */
00045     char **we_wordv;        /* List of expanded words.  */
00046     size_t we_offs;         /* Slots to reserve in `we_wordv'.  */
00047   } wordexp_t;
00048 
00049 /* Possible nonzero return values from `wordexp'.  */
00050 enum
00051   {
00052 #ifdef __USE_XOPEN
00053     WRDE_NOSYS = -1,        /* Never used since we support `wordexp'.  */
00054 #endif
00055     WRDE_NOSPACE = 1,              /* Ran out of memory.  */
00056     WRDE_BADCHAR,           /* A metachar appears in the wrong place.  */
00057     WRDE_BADVAL,            /* Undefined var reference with WRDE_UNDEF.  */
00058     WRDE_CMDSUB,            /* Command substitution with WRDE_NOCMD.  */
00059     WRDE_SYNTAX                    /* Shell syntax error.  */
00060   };
00061 
00062 /* Do word expansion of WORDS into PWORDEXP.  */
00063 extern int wordexp (__const char *__restrict __words,
00064                   wordexp_t *__restrict __pwordexp, int __flags);
00065 
00066 /* Free the storage allocated by a `wordexp' call.  */
00067 extern void wordfree (wordexp_t *__wordexp) __THROW;
00068 
00069 __END_DECLS
00070 
00071 #endif /* wordexp.h  */