parsectx.h 1.6 KB

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