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
|
return(0);
}
static int lc_process_var_cidr(void *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_hostname4(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(void *data, const char *value, const char **endptr) {
uint32_t *dataval, retval = 0;
const char *dotptr = NULL;
int tmpval = -1;
// int dotcount
dataval = data;
dotptr = value;
while (1) {
tmpval = atoi(dotptr);
if (tmpval < 0) {
break;
|
>
>
>
>
|
>
>
>
>
|
|
<
|
<
<
<
|
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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
}
if (*dotptr != '.') {
break;
}
dotptr++;
}
*dataval = retval;
*endptr = (char *) dotptr;
return(0);
}
static int lc_process_var_longlong(void *data, const char *value, const char **endptr) {
long long *dataval;
dataval = data;
*dataval = strtoll(value, (char **) endptr, 10);
return(0);
}
static int lc_process_var_long(void *data, const char *value, const char **endptr) {
long *dataval;
dataval = data;
*dataval = strtoll(value, (char **) endptr, 10);
return(0);
}
static int lc_process_var_int(void *data, const char *value, const char **endptr) {
int *dataval;
dataval = data;
*dataval = strtoll(value, (char **) endptr, 10);
return(0);
}
static int lc_process_var_short(void *data, const char *value, const char **endptr) {
short *dataval;
dataval = data;
*dataval = strtoll(value, (char **) endptr, 10);
return(0);
}
static int lc_process_var_bool_byexistance(void *data, const char *value, const char **endptr) {
int *dataval;
dataval = data;
*dataval = 1;
*endptr = NULL;
return(0);
}
static int lc_process_var_bool(void *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 *dataval;
int i;
dataval = data;
*dataval = -1;
vallen = strlen(value);
for (i = 0; i < (sizeof(trueval) / sizeof(*trueval)); i++) {
chkvallen = strlen(trueval[i]);
/*
|
|
|
<
<
<
|
|
<
<
<
|
|
<
<
<
|
|
<
<
<
|
|
|
<
<
<
<
|
<
<
<
|
|
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
193
194
195
196
197
198
199
200
|
continue;
}
if (value[chkvallen] == '\0' || value[chkvallen] == ',' || \
value[chkvallen] == ' ') {
/* Declare a winner and set the next token. */
*endptr = value + chkvallen;
*dataval = 1;
return(0);
}
}
for (i = 0; i < (sizeof(falseval) / sizeof(*falseval)); i++) {
chkvallen = strlen(falseval[i]);
|
|
|
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]);
|
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
break;
}
}
return(retval);
}
static int lc_process_var_sizelonglong(void *data, const char *value, const char **endptr) {
long long *dataval;
dataval = data;
*dataval = lc_process_size(value, endptr);
return(0);
}
static int lc_process_var_sizelong(void *data, const char *value, const char **endptr) {
long *dataval;
dataval = data;
*dataval = lc_process_size(value, endptr);
return(0);
}
static int lc_process_var_sizeint(void *data, const char *value, const char **endptr) {
int *dataval;
dataval = data;
*dataval = lc_process_size(value, endptr);
return(0);
}
static int lc_process_var_sizeshort(void *data, const char *value, const char **endptr) {
short *dataval;
dataval = data;
*dataval = lc_process_size(value, endptr);
return(0);
}
static int lc_process_var_sizesizet(void *data, const char *value, const char **endptr) {
size_t *dataval;
dataval = data;
*dataval = 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;
|
|
<
<
<
|
|
<
<
<
|
|
<
<
<
|
|
<
<
<
|
|
<
<
<
|
|
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:
|