envz.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Routines for dealing with '\0' separated environment vectors
  2. Copyright (C) 1995, 96, 98, 99, 2000 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _ENVZ_H
  17. #define _ENVZ_H 1
  18. #include <features.h>
  19. #include <errno.h>
  20. /* Envz's are argz's too, and should be created etc., using the same
  21. routines. */
  22. #include <argz.h>
  23. __BEGIN_DECLS
  24. /* Returns a pointer to the entry in ENVZ for NAME, or 0 if there is none. */
  25. extern char *envz_entry (__const char *__restrict __envz, size_t __envz_len,
  26. __const char *__restrict __name)
  27. __THROW __attribute_pure__;
  28. /* Returns a pointer to the value portion of the entry in ENVZ for NAME, or 0
  29. if there is none. */
  30. extern char *envz_get (__const char *__restrict __envz, size_t __envz_len,
  31. __const char *__restrict __name)
  32. __THROW __attribute_pure__;
  33. /* Adds an entry for NAME with value VALUE to ENVZ & ENVZ_LEN. If an entry
  34. with the same name already exists in ENVZ, it is removed. If VALUE is
  35. NULL, then the new entry will a special null one, for which envz_get will
  36. return NULL, although envz_entry will still return an entry; this is handy
  37. because when merging with another envz, the null entry can override an
  38. entry in the other one. Null entries can be removed with envz_strip (). */
  39. extern error_t envz_add (char **__restrict __envz,
  40. size_t *__restrict __envz_len,
  41. __const char *__restrict __name,
  42. __const char *__restrict __value) __THROW;
  43. /* Adds each entry in ENVZ2 to ENVZ & ENVZ_LEN, as if with envz_add(). If
  44. OVERRIDE is true, then values in ENVZ2 will supersede those with the same
  45. name in ENV, otherwise not. */
  46. extern error_t envz_merge (char **__restrict __envz,
  47. size_t *__restrict __envz_len,
  48. __const char *__restrict __envz2,
  49. size_t __envz2_len, int __override) __THROW;
  50. /* Remove the entry for NAME from ENVZ & ENVZ_LEN, if any. */
  51. extern void envz_remove (char **__restrict __envz,
  52. size_t *__restrict __envz_len,
  53. __const char *__restrict __name) __THROW;
  54. /* Remove null entries. */
  55. extern void envz_strip (char **__restrict __envz,
  56. size_t *__restrict __envz_len) __THROW;
  57. __END_DECLS
  58. #endif /* envz.h */