1 | /* ---------------------------------------------------------------------------- |
---|
2 | libconfig - A library for processing structured configuration files |
---|
3 | Copyright (C) 2005-2009 Mark A Lindner |
---|
4 | |
---|
5 | This file is part of libconfig. |
---|
6 | |
---|
7 | This library is free software; you can redistribute it and/or |
---|
8 | modify it under the terms of the GNU Lesser General Public License |
---|
9 | as published by the Free Software Foundation; either version 2.1 of |
---|
10 | the License, or (at your option) any later version. |
---|
11 | |
---|
12 | This library is distributed in the hope that it will be useful, but |
---|
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | Lesser General Public License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU Library General Public |
---|
18 | License along with this library; if not, see |
---|
19 | <http://www.gnu.org/licenses/>. |
---|
20 | ---------------------------------------------------------------------------- |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef __libconfig_scanctx_h |
---|
24 | #define __libconfig_scanctx_h |
---|
25 | |
---|
26 | #include "libconfig.h" |
---|
27 | #include "strbuf.h" |
---|
28 | |
---|
29 | #include <stdio.h> |
---|
30 | #include <sys/types.h> |
---|
31 | |
---|
32 | #define MAX_INCLUDE_DEPTH 10 |
---|
33 | |
---|
34 | struct scan_context |
---|
35 | { |
---|
36 | config_t *config; |
---|
37 | const char *top_filename; |
---|
38 | const char *files[MAX_INCLUDE_DEPTH]; |
---|
39 | void *buffers[MAX_INCLUDE_DEPTH]; |
---|
40 | FILE *streams[MAX_INCLUDE_DEPTH]; |
---|
41 | int depth; |
---|
42 | strbuf_t string; |
---|
43 | const char **filenames; |
---|
44 | unsigned int num_filenames; |
---|
45 | }; |
---|
46 | |
---|
47 | extern void scanctx_init(struct scan_context *ctx, const char *top_filename); |
---|
48 | extern const char **scanctx_cleanup(struct scan_context *ctx, |
---|
49 | unsigned int *num_filenames); |
---|
50 | |
---|
51 | extern FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer, |
---|
52 | const char **error); |
---|
53 | extern void *scanctx_pop_include(struct scan_context *ctx); |
---|
54 | |
---|
55 | #define scanctx_append_string(C, S) \ |
---|
56 | strbuf_append(&((C)->string), (S)) |
---|
57 | |
---|
58 | extern char *scanctx_take_string(struct scan_context *ctx); |
---|
59 | |
---|
60 | extern const char *scanctx_current_filename(struct scan_context *ctx); |
---|
61 | |
---|
62 | #endif /* __libconfig_scanctx_h */ |
---|