libini_config  0.3.0.1
 All Functions Enumerations Enumerator Groups Pages
ini_configobj.h
1 /*
2  INI LIBRARY
3 
4  Header file for the ini configuration interface.
5  THIS IS THE PREFERRED INTERFACE TO USE.
6 
7  Copyright (C) Dmitri Pal <dpal@redhat.com> 2010 - 2012
8 
9  INI Library is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  INI Library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with INI Library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 
24 #ifndef INI_CONFIGOBJ_H
25 #define INI_CONFIGOBJ_H
26 
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <unistd.h>
30 #include <limits.h>
31 #include <stdio.h>
32 #include "simplebuffer.h"
33 #include "ini_valueobj.h"
34 
141 enum ERR_LEVEL {
145 };
146 
159 enum ERR_PARSE {
179 };
180 
194 #define INI_META_NONE 0
195 
196 #define INI_META_STATS 1
197 
215 #define INI_ACCESS_CHECK_MODE 0x00000001
216 
223 #define INI_ACCESS_CHECK_UID 0x00000002
224 
231 #define INI_ACCESS_CHECK_GID 0x00000004
232 
255 #define INI_MV1S_OVERWRITE 0x0000
256 
257 #define INI_MV1S_ERROR 0x0001
258 
259 #define INI_MV1S_PRESERVE 0x0002
260 
261 #define INI_MV1S_ALLOW 0x0003
262 
263 #define INI_MV1S_DETECT 0x0004
264 
282 #define INI_MV2S_OVERWRITE 0x0000
283 
284 #define INI_MV2S_ERROR 0x0010
285 
286 #define INI_MV2S_PRESERVE 0x0020
287 
288 #define INI_MV2S_ALLOW 0x0030
289 
290 #define INI_MV2S_DETECT 0x0040
291 
308 #define INI_MS_MERGE 0x0000
309 
310 #define INI_MS_ERROR 0x0100
311 
312 #define INI_MS_OVERWRITE 0x0200
313 
314 #define INI_MS_PRESERVE 0x0300
315 
316 #define INI_MS_DETECT 0x0400
317 
335 #define INI_PARSE_NOWRAP 0x0001
336 
337 #define INI_PARSE_NOSPACE 0x0002
338 
339 #define INI_PARSE_NOTAB 0x0004
340 
364 enum INI_GET {
368 };
369 
380 #define INI_DEFAULT_SECTION "default"
381 
388 struct ini_cfgobj;
389 struct ini_cfgfile;
390 
394 struct ini_parse_error;
395 
396 
430 int ini_config_create(struct ini_cfgobj **ini_config);
431 
440 void ini_config_destroy(struct ini_cfgobj *ini_config);
441 
451 void ini_config_clean_state(struct ini_cfgobj *ini_config);
452 
478 int ini_config_file_open(const char *filename,
479  uint32_t metadata_flags,
480  struct ini_cfgfile **file_ctx);
481 
491 void ini_config_file_close(struct ini_cfgfile *file_ctx);
492 
493 
508 int ini_config_file_reopen(struct ini_cfgfile *file_ctx_in,
509  struct ini_cfgfile **file_ctx_out);
510 
511 
520 void ini_config_file_destroy(struct ini_cfgfile *file_ctx);
521 
533 unsigned ini_config_error_count(struct ini_cfgobj *ini_config);
534 
551 int ini_config_get_errors(struct ini_cfgobj *ini_config,
552  char ***errors);
553 
563 void ini_config_free_errors(char **errors);
564 
576 void ini_config_print_errors(FILE *file, char **error_list);
577 
588 const char *ini_config_get_filename(struct ini_cfgfile *file_ctx);
589 
601 const struct stat *ini_config_get_stat(struct ini_cfgfile *file_ctx);
602 
603 
604 
613 void ini_config_file_print(struct ini_cfgfile *file_ctx);
614 
639 int ini_config_access_check(struct ini_cfgfile *file_ctx,
640  uint32_t flags,
641  uid_t uid,
642  gid_t gid,
643  mode_t mode,
644  mode_t mask);
645 
677 int ini_config_changed(struct ini_cfgfile *file_ctx1,
678  struct ini_cfgfile *file_ctx2,
679  int *changed);
680 
700 int ini_config_parse(struct ini_cfgfile *file_ctx,
701  int error_level,
702  uint32_t collision_flags,
703  uint32_t parse_flags,
704  struct ini_cfgobj *ini_config);
705 
719 int ini_config_copy(struct ini_cfgobj *ini_config,
720  struct ini_cfgobj **ini_new);
721 
747 int ini_config_merge(struct ini_cfgobj *first,
748  struct ini_cfgobj *second,
749  uint32_t collision_flags,
750  struct ini_cfgobj **result);
751 
765 int ini_config_set_wrap(struct ini_cfgobj *ini_config,
766  uint32_t boundary);
767 
782 int ini_config_serialize(struct ini_cfgobj *ini_config,
783  struct simplebuffer *sbobj);
784 
785 
786 /* TODO: Functions that add, modify or delete sections and values in
787  * the configuration object.
788  */
789 
826 char **ini_get_section_list(struct ini_cfgobj *ini_config,
827  int *size,
828  int *error);
829 
839 void ini_free_section_list(char **section_list);
840 
861 char **ini_get_attribute_list(struct ini_cfgobj *ini_config,
862  const char *section,
863  int *size,
864  int *error);
865 
875 void ini_free_attribute_list(char **attr_list);
876 
918 int ini_get_config_valueobj(const char *section,
919  const char *name,
920  struct ini_cfgobj *ini_config,
921  int mode,
922  struct value_obj **vo);
923 
924 
925 
966 int ini_get_int_config_value(struct value_obj *vo,
967  int strict,
968  int def,
969  int *error);
970 
1012 unsigned ini_get_unsigned_config_value(struct value_obj *vo,
1013  int strict,
1014  unsigned def,
1015  int *error);
1016 
1058 long ini_get_long_config_value(struct value_obj *vo,
1059  int strict,
1060  long def,
1061  int *error);
1062 
1104 unsigned long ini_get_ulong_config_value(struct value_obj *vo,
1105  int strict,
1106  unsigned long def,
1107  int *error);
1108 
1109 
1150 int32_t ini_get_int32_config_value(struct value_obj *vo,
1151  int strict,
1152  int32_t def,
1153  int *error);
1154 
1195 uint32_t ini_get_uint32_config_value(struct value_obj *vo,
1196  int strict,
1197  uint32_t def,
1198  int *error);
1199 
1240 int64_t ini_get_int64_config_value(struct value_obj *vo,
1241  int strict,
1242  int64_t def,
1243  int *error);
1244 
1285 uint64_t ini_get_uint64_config_value(struct value_obj *vo,
1286  int strict,
1287  uint64_t def,
1288  int *error);
1289 
1328 double ini_get_double_config_value(struct value_obj *vo,
1329  int strict,
1330  double def,
1331  int *error);
1332 
1366 unsigned char ini_get_bool_config_value(struct value_obj *vo,
1367  unsigned char def,
1368  int *error);
1369 
1394 char *ini_get_string_config_value(struct value_obj *vo,
1395  int *error);
1418 const char *ini_get_const_string_config_value(struct value_obj *vo,
1419  int *error);
1420 
1470 char *ini_get_bin_config_value(struct value_obj *vo,
1471  int *length,
1472  int *error);
1473 
1482 void ini_free_bin_config_value(char *bin);
1483 
1538 char **ini_get_string_config_array(struct value_obj *vo,
1539  const char *sep,
1540  int *size,
1541  int *error);
1542 
1597 char **ini_get_raw_string_config_array(struct value_obj *vo,
1598  const char *sep,
1599  int *size,
1600  int *error);
1601 
1644 long *ini_get_long_config_array(struct value_obj *vo,
1645  int *size,
1646  int *error);
1647 
1689 double *ini_get_double_config_array(struct value_obj *vo,
1690  int *size,
1691  int *error);
1692 
1702 void ini_free_string_config_array(char **str_config);
1703 
1712 void ini_free_long_config_array(long *array);
1721 void ini_free_double_config_array(double *array);
1722 
1727 #endif