1 /* 2 INI LIBRARY 3 4 Header for the internal structures used by INI interface. 5 6 Copyright (C) Dmitri Pal <dpal@redhat.com> 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 struct ini_errmsg; 113 114 struct ini_errobj { 115 size_t count; 116 struct ini_errmsg *first_msg; 117 struct ini_errmsg *last_msg; 118 struct ini_errmsg *cur_msg; 119 }; 120 121 struct ini_errmsg { 122 char *str; 123 struct ini_errmsg *next; 124 }; 125 126 #endif 127