Overview
Comment: | Added an "ADDR" var type (since it was already documented) Removed brain-dead (void *) to type casts in lc_handle_...() |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e07808cac62ec432c68d1765ca4698ac |
User & Date: | rkeene on 2006-12-17 03:04:26 |
Other Links: | manifest | tags |
Context
2006-12-17
| ||
03:35 | Added working addr and ipv4 conversion functions check-in: 525f68fcf8 user: rkeene tags: trunk | |
03:04 | Added an "ADDR" var type (since it was already documented) Removed brain-dead (void *) to type casts in lc_handle_...() check-in: e07808cac6 user: rkeene tags: trunk | |
02:49 | Exposed lc_handle_type() function to public (needs documentation) Updated lc_register_callback documentation check-in: c3d71a3b91 user: rkeene tags: trunk | |
Changes
Modified libconfig.c from [bc792aa0c5] to [a6cd32cb12].
︙ | ︙ | |||
56 57 58 59 60 61 62 | return(0); } static int lc_process_var_cidr(void *data, const char *value, const char **endptr) { return(-1); } | > > > > | > > > > | | < | < < < | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | return(0); } static int lc_process_var_cidr(void *data, const char *value, const char **endptr) { return(-1); } static int lc_process_var_addr4(uint32_t *data, const char *value, const char **endptr) { return(-1); } static int lc_process_var_addr6(void *data, const char *value, const char **endptr) { return(-1); } static int lc_process_var_hostname4(uint32_t *data, const char *value, const char **endptr) { return(-1); } static int lc_process_var_hostname6(void *data, const char *value, const char **endptr) { return(-1); } static int lc_process_var_ip6(void *data, const char *value, const char **endptr) { return(-1); } static int lc_process_var_ip4(uint32_t *data, const char *value, const char **endptr) { const char *dotptr = NULL; int tmpval = -1, retval = 0; dotptr = value; while (1) { tmpval = atoi(dotptr); if (tmpval < 0) { break; |
︙ | ︙ | |||
97 98 99 100 101 102 103 | } if (*dotptr != '.') { break; } dotptr++; } | | | < < < | | < < < | | < < < | | < < < | | | < < < < | < < < | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | } if (*dotptr != '.') { break; } dotptr++; } *data = retval; *endptr = (char *) dotptr; return(0); } static int lc_process_var_longlong(long long *data, const char *value, const char **endptr) { *data = strtoll(value, (char **) endptr, 10); return(0); } static int lc_process_var_long(long *data, const char *value, const char **endptr) { *data = strtoll(value, (char **) endptr, 10); return(0); } static int lc_process_var_int(int *data, const char *value, const char **endptr) { *data = strtoll(value, (char **) endptr, 10); return(0); } static int lc_process_var_short(short *data, const char *value, const char **endptr) { *data = strtoll(value, (char **) endptr, 10); return(0); } static int lc_process_var_bool_byexistance(int *data, const char *value, const char **endptr) { *data = 1; *endptr = NULL; return(0); } static int lc_process_var_bool(int *data, const char *value, const char **endptr) { char *trueval[] = {"enable", "true", "yes", "on", "y", "1"}; char *falseval[] = {"disable", "false", "no", "off", "n", "0"}; size_t chkvallen, vallen; int i; *data = -1; vallen = strlen(value); for (i = 0; i < (sizeof(trueval) / sizeof(*trueval)); i++) { chkvallen = strlen(trueval[i]); /* |
︙ | ︙ | |||
186 187 188 189 190 191 192 | continue; } if (value[chkvallen] == '\0' || value[chkvallen] == ',' || \ value[chkvallen] == ' ') { /* Declare a winner and set the next token. */ *endptr = value + chkvallen; | | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | continue; } if (value[chkvallen] == '\0' || value[chkvallen] == ',' || \ value[chkvallen] == ' ') { /* Declare a winner and set the next token. */ *endptr = value + chkvallen; *data = 1; return(0); } } for (i = 0; i < (sizeof(falseval) / sizeof(*falseval)); i++) { chkvallen = strlen(falseval[i]); |
︙ | ︙ | |||
212 213 214 215 216 217 218 | continue; } if (value[chkvallen] == '\0' || value[chkvallen] == ',' || \ value[chkvallen] == ' ') { /* Declare a winner and set the next token. */ *endptr = value + chkvallen; | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | continue; } if (value[chkvallen] == '\0' || value[chkvallen] == ',' || \ value[chkvallen] == ' ') { /* Declare a winner and set the next token. */ *endptr = value + chkvallen; *data = 0; return(0); } } lc_errno = LC_ERR_BADFORMAT; return(-1); } |
︙ | ︙ | |||
251 252 253 254 255 256 257 | break; } } return(retval); } | | < < < | | < < < | | < < < | | < < < | | < < < | | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | break; } } return(retval); } static int lc_process_var_sizelonglong(long long *data, const char *value, const char **endptr) { *data = lc_process_size(value, endptr); return(0); } static int lc_process_var_sizelong(long *data, const char *value, const char **endptr) { *data = lc_process_size(value, endptr); return(0); } static int lc_process_var_sizeint(int *data, const char *value, const char **endptr) { *data = lc_process_size(value, endptr); return(0); } static int lc_process_var_sizeshort(short *data, const char *value, const char **endptr) { *data = lc_process_size(value, endptr); return(0); } static int lc_process_var_sizesizet(size_t *data, const char *value, const char **endptr) { *data = lc_process_size(value, endptr); return(0); } int lc_handle_type(lc_var_type_t type, const char *value, void *data) { const char *next; int is_list; |
︙ | ︙ | |||
350 351 352 353 354 355 356 357 358 359 360 361 362 363 | case LC_VAR_IP: case LC_VAR_IP4: return(lc_process_var_ip4(data, value, &next)); break; case LC_VAR_IP6: return(lc_process_var_ip6(data, value, &next)); break; case LC_VAR_HOSTNAME4: return(lc_process_var_hostname4(data, value, &next)); break; case LC_VAR_HOSTNAME6: return(lc_process_var_hostname6(data, value, &next)); break; case LC_VAR_CIDR: | > > > > > > | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | case LC_VAR_IP: case LC_VAR_IP4: return(lc_process_var_ip4(data, value, &next)); break; case LC_VAR_IP6: return(lc_process_var_ip6(data, value, &next)); break; case LC_VAR_ADDR: case LC_VAR_ADDR4: return(lc_process_var_addr4(data, value, &next)); case LC_VAR_ADDR6: return(lc_process_var_addr6(data, value, &next)); case LC_VAR_HOSTNAME: case LC_VAR_HOSTNAME4: return(lc_process_var_hostname4(data, value, &next)); break; case LC_VAR_HOSTNAME6: return(lc_process_var_hostname6(data, value, &next)); break; case LC_VAR_CIDR: |
︙ | ︙ |
Modified libconfig.h.in from [14f8a60094] to [1c13a21f8a].
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | LC_VAR_SECTIONEND, LC_VAR_BOOL_BY_EXISTANCE, LC_VAR_SIZE_SIZE_T, LC_VAR_CIDR, LC_VAR_IP, LC_VAR_IP4, LC_VAR_IP6, LC_VAR_HOSTNAME4, LC_VAR_HOSTNAME6, LC_VAR_LIST = 0x80 } lc_var_type_t; __BLANK_LINE__ | > > > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | LC_VAR_SECTIONEND, LC_VAR_BOOL_BY_EXISTANCE, LC_VAR_SIZE_SIZE_T, LC_VAR_CIDR, LC_VAR_IP, LC_VAR_IP4, LC_VAR_IP6, LC_VAR_ADDR, LC_VAR_ADDR4, LC_VAR_ADDR6, LC_VAR_HOSTNAME, LC_VAR_HOSTNAME4, LC_VAR_HOSTNAME6, LC_VAR_LIST = 0x80 } lc_var_type_t; __BLANK_LINE__ |
︙ | ︙ |