wordexp.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Copyright (C) 1991, 92, 1996-1999, 2001, 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _WORDEXP_H
  16. #define _WORDEXP_H 1
  17. #include <features.h>
  18. #define __need_size_t
  19. #include <stddef.h>
  20. __BEGIN_DECLS
  21. /* Bits set in the FLAGS argument to `wordexp'. */
  22. enum
  23. {
  24. WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs. */
  25. WRDE_APPEND = (1 << 1), /* Append to results of a previous call. */
  26. WRDE_NOCMD = (1 << 2), /* Don't do command substitution. */
  27. WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */
  28. WRDE_SHOWERR = (1 << 4), /* Don't redirect stderr to /dev/null. */
  29. WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */
  30. __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD |
  31. WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF)
  32. };
  33. /* Structure describing a word-expansion run. */
  34. typedef struct
  35. {
  36. size_t we_wordc; /* Count of words matched. */
  37. char **we_wordv; /* List of expanded words. */
  38. size_t we_offs; /* Slots to reserve in `we_wordv'. */
  39. } wordexp_t;
  40. /* Possible nonzero return values from `wordexp'. */
  41. enum
  42. {
  43. #ifdef __USE_XOPEN
  44. WRDE_NOSYS = -1, /* Never used since we support `wordexp'. */
  45. #endif
  46. WRDE_NOSPACE = 1, /* Ran out of memory. */
  47. WRDE_BADCHAR, /* A metachar appears in the wrong place. */
  48. WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */
  49. WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */
  50. WRDE_SYNTAX /* Shell syntax error. */
  51. };
  52. /* Do word expansion of WORDS into PWORDEXP. */
  53. extern int wordexp (__const char *__restrict __words,
  54. wordexp_t *__restrict __pwordexp, int __flags);
  55. /* Free the storage allocated by a `wordexp' call. */
  56. extern void wordfree (wordexp_t *__wordexp) __THROW;
  57. libc_hidden_proto(wordfree)
  58. __END_DECLS
  59. #endif /* wordexp.h */