parsectx.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* ----------------------------------------------------------------------------
  2. libconfig - A library for processing structured configuration files
  3. Copyright (C) 2005-2010 Mark A Lindner
  4. This file is part of libconfig.
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, see
  15. <http://www.gnu.org/licenses/>.
  16. ----------------------------------------------------------------------------
  17. */
  18. #ifndef __libconfig_parsectx_h
  19. #define __libconfig_parsectx_h
  20. #include "libconfig.h"
  21. #include "strbuf.h"
  22. struct parse_context
  23. {
  24. config_t *config;
  25. config_setting_t *parent;
  26. config_setting_t *setting;
  27. char *name;
  28. strbuf_t string;
  29. };
  30. #define parsectx_init(C) \
  31. memset((C), 0, sizeof(struct parse_context))
  32. #define parsectx_cleanup(C) \
  33. free((void *)(strbuf_release(&((C)->string))))
  34. #define parsectx_append_string(C, S) \
  35. strbuf_append(&((C)->string), (S))
  36. #define parsectx_take_string(C) \
  37. strbuf_release(&((C)->string))
  38. #endif /* __libconfig_parsectx_h */