00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef INI_CONFIG_H
00024 #define INI_CONFIG_H
00025
00026 #include <limits.h>
00027 #include <stdio.h>
00028 #include "collection.h"
00029
00125 #define INI_DEFAULT_SECTION "default"
00126
00150 #define COL_CLASS_INI_BASE 20000
00151
00162 #define COL_CLASS_INI_CONFIG COL_CLASS_INI_BASE + 0
00163
00167 #define COL_CLASS_INI_SECTION COL_CLASS_INI_BASE + 1
00168
00173 #define COL_CLASS_INI_PERROR COL_CLASS_INI_BASE + 2
00174
00182 #define COL_CLASS_INI_PESET COL_CLASS_INI_BASE + 3
00183
00187 #define COL_CLASS_INI_GERROR COL_CLASS_INI_BASE + 4
00188
00192 #define COL_CLASS_INI_VERROR COL_CLASS_INI_BASE + 5
00193
00197 #define COL_CLASS_INI_LINES COL_CLASS_INI_BASE + 6
00198
00212 #define INI_STOP_ON_ANY 0
00213
00214 #define INI_STOP_ON_NONE 1
00215
00216 #define INI_STOP_ON_ERROR 2
00217
00228 #define ERR_LONGDATA 1
00229
00230 #define ERR_NOCLOSESEC 2
00231
00232 #define ERR_NOSECTION 3
00233
00234 #define ERR_SECTIONLONG 4
00235
00236 #define ERR_NOEQUAL 5
00237
00238 #define ERR_NOKEY 6
00239
00240 #define ERR_LONGKEY 7
00241
00243 #define ERR_MAXPARSE ERR_LONGKEY
00244
00256 #define ERR_MAXGRAMMAR 0
00257
00268 #define ERR_MAXVALID 0
00269
00270
00287 struct parse_error {
00288 unsigned line;
00289 int error;
00290 };
00291
00292
00308 const char *parsing_error_str(int parsing_error);
00309
00321 const char *grammar_error_str(int parsing_error);
00322
00335 const char *validation_error_str(int parsing_error);
00336
00361 int config_from_file(const char *application,
00362 const char *config_filename,
00363 struct collection_item **ini_config,
00364 int error_level,
00365 struct collection_item **error_list);
00366
00392 int config_from_fd(const char *application,
00393 int fd,
00394 const char *config_source,
00395 struct collection_item **ini_config,
00396 int error_level,
00397 struct collection_item **error_list);
00398
00399
00407 int config_from_file_with_lines(
00408 const char *application,
00409 const char *config_filename,
00410 struct collection_item **ini_config,
00411 int error_level,
00412 struct collection_item **error_list,
00413 struct collection_item **lines);
00414
00422 int config_from_fd_with_lines(
00423 const char *application,
00424 int fd,
00425 const char *config_source,
00426 struct collection_item **ini_config,
00427 int error_level,
00428 struct collection_item **error_list,
00429 struct collection_item **lines);
00430
00431
00459 int config_for_app(const char *application,
00460 const char *config_file,
00461 const char *config_dir,
00462 struct collection_item **ini_config,
00463 int error_level,
00464 struct collection_item **error_set);
00465
00472 void free_ini_config(struct collection_item *ini_config);
00473
00480 void free_ini_config_errors(struct collection_item *error_set);
00481
00490 void free_ini_config_lines(struct collection_item *lines);
00491
00492
00493
00501 void print_file_parsing_errors(FILE *file,
00502 struct collection_item *error_list);
00503
00514 void print_grammar_errors(FILE *file,
00515 struct collection_item *error_list);
00516
00527 void print_validation_errors(FILE *file,
00528 struct collection_item *error_list);
00529
00530
00531
00532
00543 void print_config_parsing_errors(FILE *file,
00544 struct collection_item *error_set);
00545
00566 char **get_section_list(struct collection_item *ini_config,
00567 int *size,
00568 int *error);
00569
00579 void free_section_list(char **section_list);
00580
00601 char **get_attribute_list(struct collection_item *ini_config,
00602 const char *section,
00603 int *size,
00604 int *error);
00605
00615 void free_attribute_list(char **attr_list);
00616
00640 int get_config_item(const char *section,
00641 const char *name,
00642 struct collection_item *ini_config,
00643 struct collection_item **item);
00644
00685 int get_int_config_value(struct collection_item *item,
00686 int strict,
00687 int def,
00688 int *error);
00689
00730 long get_long_config_value(struct collection_item *item,
00731 int strict,
00732 long def,
00733 int *error);
00734
00775 unsigned get_unsigned_config_value(struct collection_item *item,
00776 int strict,
00777 unsigned def,
00778 int *error);
00779
00820 unsigned long get_ulong_config_value(struct collection_item *item,
00821 int strict,
00822 unsigned long def,
00823 int *error);
00824
00863 double get_double_config_value(struct collection_item *item,
00864 int strict,
00865 double def,
00866 int *error);
00867
00901 unsigned char get_bool_config_value(struct collection_item *item,
00902 unsigned char def,
00903 int *error);
00904
00928 char *get_string_config_value(struct collection_item *item,
00929 int *error);
00952 const char *get_const_string_config_value(struct collection_item *item,
00953 int *error);
00954
01004 char *get_bin_config_value(struct collection_item *item,
01005 int *length,
01006 int *error);
01007
01016 void free_bin_config_value(char *bin);
01017
01072 char **get_string_config_array(struct collection_item *item,
01073 const char *sep,
01074 int *size,
01075 int *error);
01076
01131 char **get_raw_string_config_array(struct collection_item *item,
01132 const char *sep,
01133 int *size,
01134 int *error);
01135
01178 long *get_long_config_array(struct collection_item *item,
01179 int *size,
01180 int *error);
01181
01223 double *get_double_config_array(struct collection_item *item,
01224 int *size,
01225 int *error);
01226
01236 void free_string_config_array(char **str_config);
01237
01246 void free_long_config_array(long *array);
01255 void free_double_config_array(double *array);
01256
01257
01262 #endif