-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparseconf.c
735 lines (608 loc) · 18.2 KB
/
parseconf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
93
94
95
96
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
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
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
/* parseconf.c
* Copyright (C) 2007 Tillmann Werner <[email protected]>
*
* This file is free software; as a special exception the author gives
* unlimited permission to copy and/or distribute it, with or without
* modifications, as long as this notice is preserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* The config file parser is based on lcfg from Paul Baecher.
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "parseconf.h"
#include "readconf.h"
#include "logging.h"
struct lcfg_scanner * lcfg_scanner_new(struct lcfg *, int fd);
enum lcfg_status lcfg_scanner_init(struct lcfg_scanner *);
enum lcfg_status lcfg_scanner_next_token(struct lcfg_scanner *, struct lcfg_token *);
int lcfg_scanner_has_next(struct lcfg_scanner *);
void lcfg_scanner_delete(struct lcfg_scanner *);
struct lcfg_parser * lcfg_parser_new(struct lcfg *, const char *);
enum lcfg_status lcfg_parser_run(struct lcfg_parser *);
enum lcfg_status lcfg_parser_accept(struct lcfg_parser *, lcfg_visitor_function, void *);
void lcfg_parser_delete(struct lcfg_parser *);
int lcfg_string_set(struct lcfg_string *s, const char *cstr) {
lcfg_string_trunc(s, 0);
return lcfg_string_cat_cstr(s, cstr);
}
/* make sure new_size bytes fit into the string */
inline static void lcfg_string_grow(struct lcfg_string *s, unsigned int new_size) {
/* always allocate one byte more than needed
* to make _cstr() working in any case without realloc. */
while( (new_size + 1) > s->capacity ) {
s->capacity *= 2;
s->str = realloc(s->str, s->capacity);
}
}
struct lcfg_string *lcfg_string_new() {
struct lcfg_string *s = malloc(sizeof(struct lcfg_string));
s->capacity = 8;
s->size = 0;
s->str = malloc(s->capacity);
return s;
}
struct lcfg_string *lcfg_string_new_copy(struct lcfg_string *s) {
struct lcfg_string *s_new = malloc(sizeof(struct lcfg_string));
s_new->capacity = s->capacity;
s_new->size = s->size;
s_new->str = malloc(s_new->capacity);
memcpy(s_new->str, s->str, s_new->size);
return s_new;
}
int lcfg_string_cat_uint(struct lcfg_string *s, unsigned int i) {
unsigned int size_needed = 1;
unsigned int ii = i;
char c;
while( ii > 10 ) {
size_needed++;
ii /= 10;
}
lcfg_string_grow(s, s->size + size_needed);
ii = size_needed - 1;
do {
c = '0' + i % 10;
s->str[s->size + ii--] = c;
i /= 10;
} while( i != 0 );
s->size += size_needed;
return s->size;
}
int lcfg_string_find(struct lcfg_string *s, char c) {
int i;
for( i = 0; i < s->size; i++ ) if( s->str[i] == c ) return i;
return -1;
}
int lcfg_string_rfind(struct lcfg_string *s, char c) {
int i;
for( i = s->size - 1; i >= 0; i-- ) if( s->str[i] == c ) return i;
return -1;
}
void lcfg_string_trunc(struct lcfg_string *s, unsigned int max_size) {
if( max_size < s->size ) s->size = max_size;
}
int lcfg_string_cat_cstr(struct lcfg_string *s, const char *cstr) {
size_t len = strlen(cstr);
lcfg_string_grow(s, s->size + len);
memcpy(s->str + s->size, cstr, len);
s->size += len;
return s->size;
}
int lcfg_string_cat_char(struct lcfg_string *s, char c) {
lcfg_string_grow(s, s->size + 1);
s->str[s->size++] = c;
return s->size;
}
inline const char *lcfg_string_cstr(struct lcfg_string *s) {
s->str[s->size] = '\0';
return s->str;
}
inline unsigned int lcfg_string_len(struct lcfg_string *s) {
return s->size;
}
void lcfg_string_delete(struct lcfg_string *s) {
free(s->str);
free(s);
}
const char *lcfg_token_map[] = {
"null_token",
"T_IDENTIFIER",
"`='",
"T_STRING",
"`['",
"`]'",
"`,'",
"`{'",
"`}'"
};
struct lcfg_scanner {
struct lcfg *lcfg;
int fd;
char buffer[LCFG_BUFSIZ];
int offset;
int size;
int eof;
short line;
short col;
struct lcfg_token prepared_token;
int token_eof;
};
static enum lcfg_status lcfg_scanner_buffer_fill(struct lcfg_scanner *s) {
if( (s->size = read(s->fd, s->buffer, LCFG_BUFSIZ)) < 0 ) {
lcfg_error_set(s->lcfg, "read(): %m");
return lcfg_status_error;
} else if( s->size == 0 ) s->eof = !0;
else s->offset = 0;
return lcfg_status_ok;
}
static inline int lcfg_scanner_char_eof(struct lcfg_scanner *s) {
if( s->eof ) return !0;
if( s->size == 0 || s->offset == LCFG_BUFSIZ) lcfg_scanner_buffer_fill(s);
if( s->size < LCFG_BUFSIZ && s->offset == s->size ) s->eof = !0;
return s->eof;
}
static enum lcfg_status lcfg_scanner_char_read(struct lcfg_scanner *s, char *c) {
if( lcfg_scanner_char_eof(s) ) {
lcfg_error_set(s->lcfg, "%s", "cannot read beyond eof");
return lcfg_status_error;
}
*c = s->buffer[s->offset++];
return lcfg_status_ok;
}
static enum lcfg_status lcfg_scanner_char_peek(struct lcfg_scanner *s, char *c) {
if( lcfg_scanner_char_eof(s) ) {
lcfg_error_set(s->lcfg, "%s", "cannot peek beyond eof");
return lcfg_status_error;
}
*c = s->buffer[s->offset];
return lcfg_status_ok;
}
/* the beautiful lowlevel fsm */
static enum lcfg_status lcfg_scanner_token_read(struct lcfg_scanner *s) {
enum scanner_state {
start = 0,
comm_start,
in_oneline,
in_multiline,
multiline_end,
in_identifier,
in_str,
in_esc,
esc_hex_exp_first,
esc_hex_exp_second,
invalid
};
enum scanner_state state = start;
char c = '\0';
char hex[3];
s->prepared_token.type = lcfg_null_token;
while( !lcfg_scanner_char_eof(s) ) {
int consume = !0;
lcfg_scanner_char_peek(s, &c);
switch( state ) {
case start:
switch( c ) {
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '=':
s->prepared_token.type = lcfg_equals;
break;
case '[':
s->prepared_token.type = lcfg_sbracket_open;
break;
case ']':
s->prepared_token.type = lcfg_sbracket_close;
break;
case '{':
s->prepared_token.type = lcfg_brace_open;
break;
case '}':
s->prepared_token.type = lcfg_brace_close;
break;
case ',':
s->prepared_token.type = lcfg_comma;
break;
case '/':
state = comm_start;
break;
case '"':
state = in_str;
lcfg_string_trunc(s->prepared_token.string, 0);
break;
default:
if( isalpha(c) ) {
lcfg_string_trunc(s->prepared_token.string, 0);
lcfg_string_cat_char(s->prepared_token.string, c);
state = in_identifier;
} else {
lcfg_error_set(s->lcfg, "parse error: invalid input character `%c' (0x%02x) near line %d, col %d",
isprint(c) ? c : '.', c, s->line, s->col);
state = invalid;
}
}
break;
case comm_start:
if( c == '/' ) state = in_oneline;
else if( c == '*' ) state = in_multiline;
else {
lcfg_error_set(s->lcfg, "parse error: invalid input character `%c' (0x%02x) near line %d, col %d",
isprint(c) ? c : '.', c, s->line, s->col);
state = invalid;
}
break;
case in_oneline:
if( c == '\n' ) state = start;
break;
case in_multiline:
if( c == '*' ) state = multiline_end;
break;
case multiline_end:
if( c == '/' ) state = start;
else if( c != '*' ) state = in_multiline;
break;
case in_identifier:
if( isalnum(c) || c == '-' || c == '_' ) lcfg_string_cat_char(s->prepared_token.string, c);
else {
s->prepared_token.type = lcfg_identifier;
consume = 0;
state = start;
}
break;
case in_str:
if( c == '"' ) {
s->prepared_token.type = lcfg_string;
state = start;
} else if( c == '\\' ) {
state = in_esc;
} else {
lcfg_string_cat_char(s->prepared_token.string, c);
}
break;
case in_esc:
state = in_str;
switch( c ) {
case '"':
lcfg_string_cat_char(s->prepared_token.string, '"');
break;
case '\\':
lcfg_string_cat_char(s->prepared_token.string, '\\');
break;
case 'n':
lcfg_string_cat_char(s->prepared_token.string, '\n');
break;
case 't':
lcfg_string_cat_char(s->prepared_token.string, '\t');
break;
case 'r':
lcfg_string_cat_char(s->prepared_token.string, '\r');
break;
case '0':
lcfg_string_cat_char(s->prepared_token.string, '\0');
break;
case 'x':
state = esc_hex_exp_first;
break;
default:
lcfg_error_set(s->lcfg, "invalid string escape sequence `%c' near line %d, col %d", c, s->line, s->col);
state = invalid;
}
break;
case esc_hex_exp_first:
if( !isxdigit(c) ) {
lcfg_error_set(s->lcfg, "invalid hex escape sequence `%c' on line %d column %d", c, s->line, s->col);
state = invalid;
}
hex[0] = c;
state = esc_hex_exp_second;
break;
case esc_hex_exp_second:
if( !isxdigit(c) ) {
lcfg_error_set(s->lcfg, "invalid hex escape sequence `%c' on line %d column %d", c, s->line, s->col);
state = invalid;
}
hex[1] = c;
hex[2] = '\0';
lcfg_string_cat_char(s->prepared_token.string, strtoul(hex, NULL, 16));
state = in_str;
break;
case invalid:
break;
}
/* this is technically not optimal (token position identified by last char), but it will suffice for now */
s->prepared_token.line = s->line;
s->prepared_token.col = s->col;
if( consume ) {
lcfg_scanner_char_read(s, &c);
if( c == '\n' ) {
s->line++;
s->col = 1;
} else s->col++;
}
if( s->prepared_token.type != lcfg_null_token || state == invalid ) break;
}
if( state != start ) {
if( state != invalid ) lcfg_error_set(s->lcfg, "parse error: premature end of file near line %d, col %d", s->line, s->col);
return lcfg_status_error;
}
return lcfg_status_ok;
}
enum lcfg_status lcfg_scanner_init(struct lcfg_scanner *s) {
/* prepare the first token */
return lcfg_scanner_token_read(s);
}
int lcfg_scanner_has_next(struct lcfg_scanner *s) {
return s->prepared_token.type != lcfg_null_token;
}
enum lcfg_status lcfg_scanner_next_token(struct lcfg_scanner *s, struct lcfg_token *t) {
if( !lcfg_scanner_has_next(s) ) {
lcfg_error_set(s->lcfg, "%s", "cannot access tokenstream beyond eof");
return lcfg_status_error;
}
memcpy(t, &s->prepared_token, sizeof(struct lcfg_token));
t->string = lcfg_string_new_copy(s->prepared_token.string);
/* prepare the next token */
return lcfg_scanner_token_read(s);
}
struct lcfg_scanner *lcfg_scanner_new(struct lcfg *c, int fd) {
struct lcfg_scanner *s = malloc(sizeof(struct lcfg_scanner));
memset(s, 0, sizeof(struct lcfg_scanner));
s->lcfg = c;
s->fd = fd;
s->line = s->col = 1;
s->prepared_token.string = lcfg_string_new();
return s;
}
void lcfg_scanner_delete(struct lcfg_scanner *s) {
lcfg_string_delete(s->prepared_token.string);
free(s);
}
struct lcfg_parser_value_pair {
char *key;
struct lcfg_string *value;
};
struct lcfg_parser {
struct lcfg *lcfg;
char *filename;
struct lcfg_scanner *scanner;
struct lcfg_parser_value_pair *values;
unsigned int value_length;
unsigned int value_capacity;
};
static int lcfg_parser_add_value(struct lcfg_parser *p, const char *key, struct lcfg_string *value) {
if( p->value_length == p->value_capacity ) {
p->value_capacity *= 2;
p->values = realloc(p->values, sizeof(struct lcfg_parser_value_pair) * p->value_capacity);
}
p->values[p->value_length].key = strdup(key);
p->values[p->value_length].value = lcfg_string_new_copy(value);
return ++p->value_length;
}
struct lcfg_parser *lcfg_parser_new(struct lcfg *c, const char *filename) {
struct lcfg_parser *p = malloc(sizeof(struct lcfg_parser));
memset(p, 0, sizeof(struct lcfg_parser));
p->filename = strdup(filename);
p->lcfg = c;
p->value_length = 0;
p->value_capacity = 8;
p->values = malloc(sizeof(struct lcfg_parser_value_pair) * p->value_capacity);
return p;
}
/* this is a basic push down automata */
static enum lcfg_status lcfg_parser_parse(struct lcfg_parser *p) {
enum state { top_level = 0, exp_equals, exp_value, in_list, in_map, invalid };
/*const char *state_map[] = { "top_level", "exp_equals", "exp_value", "in_list", "in_map", "invalid" };*/
struct state_element {
enum state s;
int list_counter;
};
/* start of ugly preproc stuff */
#define STATE_STACK_PUSH(t) \
if( ssi + 1 == state_stack_size ) \
{ \
state_stack_size *= 2; \
state_stack = realloc(state_stack, state_stack_size * sizeof(struct state_element)); \
} \
state_stack[++ssi].s = t; \
state_stack[ssi].list_counter = 0
#define STATE_STACK_POP() ssi--
#define PATH_PUSH_STR(s) \
if( lcfg_string_len(current_path) != 0 ) \
{ \
lcfg_string_cat_char(current_path, '.'); \
} \
lcfg_string_cat_cstr(current_path, s);
#define PATH_PUSH_INT(i) \
if( lcfg_string_len(current_path) != 0 ) \
{ \
lcfg_string_cat_char(current_path, '.'); \
} \
lcfg_string_cat_uint(current_path, i);
#define PATH_POP() \
if( lcfg_string_rfind(current_path, '.') != -1 ) \
{ \
lcfg_string_trunc(current_path, lcfg_string_rfind(current_path, '.')); \
} \
else \
{ \
lcfg_string_trunc(current_path, 0); \
}
/* end of ugly preproc stuff */
if( lcfg_scanner_init(p->scanner) != lcfg_status_ok ) return lcfg_status_error;
int state_stack_size = 8;
int ssi = 0; /* ssi = state stack index */
struct state_element *state_stack = malloc(sizeof(struct state_element) * state_stack_size);
state_stack[ssi].s = top_level;
state_stack[ssi].list_counter = 0;
struct lcfg_token t;
struct lcfg_string *current_path = lcfg_string_new();
while( lcfg_scanner_has_next(p->scanner) && state_stack[ssi].s != invalid ) {
if( lcfg_scanner_next_token(p->scanner, &t) != lcfg_status_ok ) {
free(state_stack);
lcfg_string_delete(t.string);
lcfg_string_delete(current_path);
return lcfg_status_error;
}
switch( state_stack[ssi].s ) {
case top_level:
case in_map:
if( t.type == lcfg_identifier ) {
PATH_PUSH_STR(lcfg_string_cstr(t.string));
STATE_STACK_PUSH(exp_equals);
} else if( state_stack[ssi].s == in_map && t.type == lcfg_brace_close ) {
STATE_STACK_POP();
PATH_POP();
} else {
lcfg_error_set(p->lcfg, "invalid token (%s) near line %d column %d: expected identifier%s",
lcfg_token_map[t.type], t.line, t.col, state_stack[ssi].s == in_map ? " or `}'" : "");
state_stack[ssi].s = invalid;
}
break;
case exp_equals:
if( t.type == lcfg_equals ) state_stack[ssi].s = exp_value;
else {
lcfg_error_set(p->lcfg, "invalid token (%s) near line %d column %d: expected `='",
lcfg_token_map[t.type], t.line, t.col);
state_stack[ssi].s = invalid;
}
break;
case exp_value:
if( t.type == lcfg_string ) {
lcfg_parser_add_value(p, lcfg_string_cstr(current_path), t.string);
STATE_STACK_POP();
PATH_POP();
} else if( t.type == lcfg_sbracket_open ) state_stack[ssi].s = in_list;
else if( t.type == lcfg_brace_open ) state_stack[ssi].s = in_map;
else {
lcfg_error_set(p->lcfg, "invalid token (%s) near line %d column %d: expected string, `[' or `{'",
lcfg_token_map[t.type], t.line, t.col);
state_stack[ssi].s = invalid;
}
break;
case in_list:
if( t.type == lcfg_comma ); /* ignore comma */
else if( t.type == lcfg_string ) {
PATH_PUSH_INT(state_stack[ssi].list_counter);
lcfg_parser_add_value(p, lcfg_string_cstr(current_path), t.string);
PATH_POP();
state_stack[ssi].list_counter++;
} else if( t.type == lcfg_sbracket_open ) {
PATH_PUSH_INT(state_stack[ssi].list_counter);
state_stack[ssi].list_counter++;
STATE_STACK_PUSH(in_list);
} else if( t.type == lcfg_brace_open ) {
PATH_PUSH_INT(state_stack[ssi].list_counter);
state_stack[ssi].list_counter++;
STATE_STACK_PUSH(in_map);
} else if( t.type == lcfg_sbracket_close ) {
PATH_POP();
STATE_STACK_POP();
} else {
lcfg_error_set(p->lcfg, "invalid token (%s) near line %d column %d: expected string, `[', `{', `,' or `]'",
lcfg_token_map[t.type], t.line, t.col);
state_stack[ssi].s = invalid;
}
break;
case invalid: /* unreachable */
break;
}
lcfg_string_delete(t.string);
}
lcfg_string_delete(current_path);
if( state_stack[ssi].s == top_level && ssi == 0 ) {
free(state_stack);
return lcfg_status_ok;
} else {
free(state_stack);
return lcfg_status_error;
}
}
enum lcfg_status lcfg_parser_run(struct lcfg_parser *p) {
int fd = open(p->filename, 0);
enum lcfg_status status;
if( fd < 0 ) {
lcfg_error_set(p->lcfg, "open(): %m");
return lcfg_status_error;
}
p->scanner = lcfg_scanner_new(p->lcfg, fd);
status = lcfg_parser_parse(p);
close(fd);
return status;
}
enum lcfg_status lcfg_parser_accept(struct lcfg_parser *p, lcfg_visitor_function fn, void *user_data) {
int i;
for( i = 0; i < p->value_length; i++ ) {
if( fn(p->values[i].key, (void *)lcfg_string_cstr(p->values[i].value),
lcfg_string_len(p->values[i].value), user_data) != lcfg_status_ok ) {
lcfg_error_set(p->lcfg, "%s", "configuration value traversal aborted upon user request");
return lcfg_status_error;
}
}
return lcfg_status_ok;
}
void lcfg_parser_delete(struct lcfg_parser *p) {
if (p->scanner) lcfg_scanner_delete(p->scanner);
int i;
for( i = 0; i < p->value_length; i++ ) {
free(p->values[i].key);
lcfg_string_delete(p->values[i].value);
}
free(p->values);
free(p->filename);
free(p);
}
struct lcfg *lcfg_new(const char *filename) {
struct lcfg *c = malloc(sizeof(struct lcfg));
memset(c, 0, sizeof(struct lcfg));
c->parser = lcfg_parser_new(c, filename);
return c;
}
void lcfg_delete(struct lcfg *c) {
if (c->parser) lcfg_parser_delete(c->parser);
free(c);
}
const char *lcfg_error_get(struct lcfg *c) {
return c->error;
}
enum lcfg_status lcfg_parse(struct lcfg *c) {
return lcfg_parser_run(c->parser);
}
enum lcfg_status lcfg_accept(struct lcfg *c, lcfg_visitor_function fn, void *user_data) {
return lcfg_parser_accept(c->parser, fn, user_data);
}
void lcfg_error_set(struct lcfg *c, const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vsnprintf(c->error, sizeof(c->error), fmt, ap);
va_end(ap);
}
struct lcfg *parse_config_file(const char *filename) {
struct lcfg *c = NULL;
if (!filename) {
fprintf(stderr, " Error - No configuration file name given.\n");
return(NULL);
}
/* parse file */
c = lcfg_new(filename);
if (lcfg_parse(c) != lcfg_status_ok) {
fprintf(stderr, " Error - Unable to parse %s: %s\n", filename, lcfg_error_get(c));
lcfg_delete(c);
return(NULL);
}
return(c);
}