/[zanavi_public1]/navit/navit/maptool/cfuconf.h
ZANavi

Contents of /navit/navit/maptool/cfuconf.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Mon Feb 4 17:41:59 2013 UTC (6 years, 7 months ago) by zoff99
File MIME type: text/plain
File size: 4248 byte(s)
new map version, lots of fixes and experimental new features
1 /* Creation date: 2005-07-08 22:24:03
2 * Authors: Don
3 * Change log:
4 */
5
6 /* Copyright (c) 2005 Don Owens
7 All rights reserved.
8
9 This code is released under the BSD license:
10
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions
13 are met:
14
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17
18 * Redistributions in binary form must reproduce the above
19 copyright notice, this list of conditions and the following
20 disclaimer in the documentation and/or other materials provided
21 with the distribution.
22
23 * Neither the name of the author nor the names of its
24 contributors may be used to endorse or promote products derived
25 from this software without specific prior written permission.
26
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
38 OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41 #ifndef _CFU_CONF_H_
42 #define _CFU_CONF_H_
43
44 #include <cfu.h>
45 #include <cfuhash.h>
46 #include <cfulist.h>
47 #include <cfustring.h>
48
49 #include <stdio.h>
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 struct cfuconf;
56 typedef struct cfuconf cfuconf_t;
57
58 /* Apache-style conf files contain directives and containers.
59 Directives are simple one line specifications with or without
60 arguments, e.g.,
61
62 Doit
63 Expires On
64 LoadModule my_mod modules/my_mod.so
65
66 Containers have a type and a name associated with them and they
67 in turn contain directives and/or containers, e.g.,
68
69 <MyContainer test1>
70 Expires Off
71 <DB devdb>
72 DBHost db.example.com
73 DBUser test_user
74 </DB>
75 </MyContainer>
76
77 Values may be quoted, e.g.
78
79 DBUser "test user"
80
81 But must be specified on a single line. To escape quotes
82 within a quoted string, use the '\' character.
83
84 */
85
86
87 /* Parse the apache-like conf file specified by file_path,
88 * returning a pointer to a cfuconf_t structure in conf. Returns
89 * zero on success, less than zero on error. If an error occurs
90 * and error is not NULL, it will be set to an error message
91 * (which must be free()'d by the caller).
92 */
93 extern int cfuconf_parse_file(char *file_path, cfuconf_t **conf, char **error);
94
95 /* Same as cfuconf_parse_file(), except assume the contents of the
96 * file are already in buffer.
97 */
98 extern int cfuconf_parse_buffer(char *buffer, cfuconf_t **conf, char **error);
99
100 /* Free all resources used by the cfuconf_t structure */
101 extern void cfuconf_destroy(cfuconf_t *conf);
102
103 /* Get a hash of containers at the top level of conf */
104 extern cfuhash_table_t * cfuconf_get_containers(cfuconf_t *conf);
105
106 /* Get a hash of directives at the to level */
107 extern cfuhash_table_t * cfuconf_get_directives(cfuconf_t *conf);
108
109 /* Get the value of the given directive, assuming there is only one argument */
110 extern int cfuconf_get_directive_one_arg(cfuconf_t *conf, char *directive, char **rvalue);
111
112 /* Get the value of the given directive, assuming there are two arguments */
113 extern int cfuconf_get_directive_two_args(cfuconf_t *conf, char *directive, char **rvalue,
114 char **rvalue2);
115
116 /* Get the value of the given directives, with n arguments */
117 extern int cfuconf_get_directive_n_args(cfuconf_t *conf, char *directive, size_t n, ...);
118
119 /* Print out a representation of the parsed configuration */
120 extern void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level);
121
122 #ifdef __cplusplus
123 }
124 #endif
125
126 #endif

   
Visit the ZANavi Wiki