parsectx.h 1.6 KB

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