envz.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Routines for dealing with '\0' separated environment vectors
  2. Copyright (C) 1995-2020 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, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _ENVZ_H
  16. #define _ENVZ_H 1
  17. #include <features.h>
  18. #include <errno.h>
  19. /* Envz's are argz's too, and should be created etc., using the same
  20. routines. */
  21. #include <argz.h>
  22. __BEGIN_DECLS
  23. /* Returns a pointer to the entry in ENVZ for NAME, or 0 if there is none. */
  24. extern char *envz_entry (const char *__restrict __envz, size_t __envz_len,
  25. const char *__restrict __name)
  26. __THROW __attribute_pure__;
  27. /* Returns a pointer to the value portion of the entry in ENVZ for NAME, or 0
  28. if there is none. */
  29. extern char *envz_get (const char *__restrict __envz, size_t __envz_len,
  30. const char *__restrict __name)
  31. __THROW __attribute_pure__;
  32. /* Adds an entry for NAME with value VALUE to ENVZ & ENVZ_LEN. If an entry
  33. with the same name already exists in ENVZ, it is removed. If VALUE is
  34. NULL, then the new entry will a special null one, for which envz_get will
  35. return NULL, although envz_entry will still return an entry; this is handy
  36. because when merging with another envz, the null entry can override an
  37. entry in the other one. Null entries can be removed with envz_strip (). */
  38. extern error_t envz_add (char **__restrict __envz,
  39. size_t *__restrict __envz_len,
  40. const char *__restrict __name,
  41. const char *__restrict __value) __THROW;
  42. /* Adds each entry in ENVZ2 to ENVZ & ENVZ_LEN, as if with envz_add(). If
  43. OVERRIDE is true, then values in ENVZ2 will supersede those with the same
  44. name in ENV, otherwise not. */
  45. extern error_t envz_merge (char **__restrict __envz,
  46. size_t *__restrict __envz_len,
  47. const char *__restrict __envz2,
  48. size_t __envz2_len, int __override) __THROW;
  49. /* Remove the entry for NAME from ENVZ & ENVZ_LEN, if any. */
  50. extern void envz_remove (char **__restrict __envz,
  51. size_t *__restrict __envz_len,
  52. const char *__restrict __name) __THROW;
  53. /* Remove null entries. */
  54. extern void envz_strip (char **__restrict __envz,
  55. size_t *__restrict __envz_len) __THROW;
  56. __END_DECLS
  57. #endif /* envz.h */