Debian Codegraph @

ini/ini_config_priv.h

raw symbols SCIP
1 /*
2 INI LIBRARY
3
4 Header for the internal structures used by INI interface.
5
6 Copyright (C) Dmitri Pal <[email protected]> 2010
7
8 INI Library is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 INI Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with INI Library. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef INI_CONFIG_PRIV_H
23 #define INI_CONFIG_PRIV_H
24
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <unistd.h>
28 #include "collection.h"
29 #include "simplebuffer.h"
30 #include "ini_comment.h"
31
32 /* Configuration object */
33 struct ini_cfgobj {
34 /* For now just a collection */
35 struct collection_item *cfg;
36 /* Boundary */
37 uint32_t boundary;
38 /* Last comment */
39 struct ini_comment *last_comment;
40 /* Last search state */
41 char *section;
42 char *name;
43 int section_len;
44 int name_len;
45 struct collection_iterator *iterator;
46 /* Collection of errors detected during parsing */
47 struct collection_item *error_list;
48 /* Count of error lines */
49 unsigned count;
50
51 /*... */
52 /* Statistics? Timestamps? When created? Modified? - TBD */
53 /*... */
54 };
55
56
57 /* Configuration file object */
58 struct ini_cfgfile {
59 /***********************************/
60 /* Externally controlled variables */
61 /***********************************/
62 /* File name for the configuration file */
63 char *filename;
64 /* File stream */
65 FILE *file;
66 /* What meta data to collect */
67 uint32_t metadata_flags;
68 /**********************/
69 /* Internal variables */
70 /**********************/
71 /* File stats */
72 struct stat file_stats;
73 /* Were stats read ? */
74 int stats_read;
75 /* Internal buffer */
76 struct simplebuffer *file_data;
77 /* BOM indicator */
78 enum index_utf_t bom;
79 };
80
81 /* Parsing error */
82 struct ini_parse_error {
83 unsigned line;
84 int error;
85 };
86
87 /* Internal cleanup callback */
88 void ini_cleanup_cb(const char *property,
89 int property_len,
90 int type,
91 void *data,
92 int length,
93 void *custom_data);
94
95 /* Get parsing error */
96 const char *ini_get_error_str(int parsing_error, int family);
97
98 /* Check if collision flags are valid */
99 int valid_collision_flags(uint32_t collision_flags);
100
101 /* Empty section */
102 int empty_section(struct collection_item *sec);
103
104 /* Internal access check function */
105 int access_check_int(struct stat *file_stats,
106 uint32_t flags,
107 uid_t uid,
108 gid_t gid,
109 mode_t mode,
110 mode_t mask);
111
112 /**
113 * @brief Serialize configuration object
114 *
115 * Serialize configuration object into provided buffer.
116 * Use buffer object functions to manipulate or save
117 * the buffer to a file/stream.
118 *
119 * @param[in] ini_config Configuration object.
120 * @param[out] sbobj Serialized configuration.
121 *
122 * @return 0 - Success.
123 * @return EINVAL - Invalid parameter.
124 * @return ENOMEM - No memory.
125 */
126 int ini_config_serialize(struct ini_cfgobj *ini_config,
127 struct simplebuffer *sbobj);
128
129 /* Serialize value */
130 int value_serialize(struct value_obj *vo,
131 const char *key,
132 struct simplebuffer *sbobj);
133
134 /* Serialize comment */
135 int ini_comment_serialize(struct ini_comment *ic,
136 struct simplebuffer *sbobj);
137
138 struct ini_errmsg;
139
140 struct ini_errobj {
141 size_t count;
142 struct ini_errmsg *first_msg;
143 struct ini_errmsg *last_msg;
144 struct ini_errmsg *cur_msg;
145 };
146
147 struct ini_errmsg {
148 char *str;
149 struct ini_errmsg *next;
150 };
151
152 #endif