wordexp.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _WORDEXP_H
  15. #define _WORDEXP_H 1
  16. #include <features.h>
  17. #define __need_size_t
  18. #include <stddef.h>
  19. __BEGIN_DECLS
  20. /* Bits set in the FLAGS argument to `wordexp'. */
  21. enum
  22. {
  23. WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs. */
  24. WRDE_APPEND = (1 << 1), /* Append to results of a previous call. */
  25. WRDE_NOCMD = (1 << 2), /* Don't do command substitution. */
  26. WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */
  27. WRDE_SHOWERR = (1 << 4), /* Don't redirect stderr to /dev/null. */
  28. WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */
  29. __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD |
  30. WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF)
  31. };
  32. /* Structure describing a word-expansion run. */
  33. typedef struct
  34. {
  35. size_t we_wordc; /* Count of words matched. */
  36. char **we_wordv; /* List of expanded words. */
  37. size_t we_offs; /* Slots to reserve in `we_wordv'. */
  38. } wordexp_t;
  39. /* Possible nonzero return values from `wordexp'. */
  40. enum
  41. {
  42. #ifdef __USE_XOPEN
  43. WRDE_NOSYS = -1, /* Never used since we support `wordexp'. */
  44. #endif
  45. WRDE_NOSPACE = 1, /* Ran out of memory. */
  46. WRDE_BADCHAR, /* A metachar appears in the wrong place. */
  47. WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */
  48. WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */
  49. WRDE_SYNTAX /* Shell syntax error. */
  50. };
  51. /* Do word expansion of WORDS into PWORDEXP. */
  52. extern int wordexp (const char *__restrict __words,
  53. wordexp_t *__restrict __pwordexp, int __flags);
  54. /* Free the storage allocated by a `wordexp' call. */
  55. extern void wordfree (wordexp_t *__wordexp) __THROW;
  56. libc_hidden_proto(wordfree)
  57. __END_DECLS
  58. #endif /* wordexp.h */