scanctx.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_scanctx_h
  19. #define __libconfig_scanctx_h
  20. #include "libconfig.h"
  21. #include "strbuf.h"
  22. #include <stdio.h>
  23. #include <sys/types.h>
  24. #define MAX_INCLUDE_DEPTH 10
  25. struct scan_context
  26. {
  27. config_t *config;
  28. const char *top_filename;
  29. const char *files[MAX_INCLUDE_DEPTH];
  30. void *buffers[MAX_INCLUDE_DEPTH];
  31. FILE *streams[MAX_INCLUDE_DEPTH];
  32. int depth;
  33. strbuf_t string;
  34. const char **filenames;
  35. unsigned int num_filenames;
  36. };
  37. extern void scanctx_init(struct scan_context *ctx, const char *top_filename);
  38. extern const char **scanctx_cleanup(struct scan_context *ctx,
  39. unsigned int *num_filenames);
  40. extern FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer,
  41. const char **error);
  42. extern void *scanctx_pop_include(struct scan_context *ctx);
  43. #define scanctx_append_string(C, S) \
  44. strbuf_append(&((C)->string), (S))
  45. extern char *scanctx_take_string(struct scan_context *ctx);
  46. extern const char *scanctx_current_filename(struct scan_context *ctx);
  47. #endif /* __libconfig_scanctx_h */