Changeset 5706
Remove unused cruft from config handling
Comitted by:
mjagdis
Date:
Jun 04 2010 * 23:10 (about 1 year ago)
Affected files:
callweaver/trunk/corelib/config.c (unified diff)
| r5680 | r5706 | |
|---|---|---|
| 94 | 94 | |
| 95 | 95 | #define MAX_INCLUDE_LEVEL 10 |
| 96 | 96 | |
| 97 | struct cw_comment { | |
| 98 | struct cw_comment *next; | |
| 99 | char cmt[0]; | |
| 100 | }; | |
| 101 | ||
| 102 | 97 | struct cw_category { |
| 103 | 98 | char name[80]; |
| 104 | 99 | int ignored; /* do not let user of the config see this category */ |
| --- | --- | |
| 119 | 114 | struct cw_variable *cw_variable_new(const char *name, const char *value) |
| 120 | 115 | { |
| 121 | 116 | struct cw_variable *variable; |
| 117 | int name_len, value_len, length; | |
| 122 | 118 | |
| 123 | int length = strlen(name) + strlen(value) + 2 + sizeof(struct cw_variable); | |
| 124 | variable = malloc(length); | |
| 125 | if (variable) { | |
| 119 | name_len = strlen(name) + 1; | |
| 120 | value_len = strlen(value) + 1; | |
| 121 | length = sizeof(struct cw_variable) + name_len + value_len; | |
| 122 | ||
| 123 | if ((variable = malloc(length))) { | |
| 126 | 124 | memset(variable, 0, length); |
| 127 | variable->name = variable->stuff; | |
| 128 | variable->value = variable->stuff + strlen(name) + 1; | |
| 129 | strcpy(variable->name,name); | |
| 130 | strcpy(variable->value,value); | |
| 125 | variable->value = variable->name + name_len; | |
| 126 | memcpy(variable->name, name, name_len); | |
| 127 | memcpy(variable->value, value, value_len); | |
| 131 | 128 | } |
| 132 | 129 | |
| 133 | 130 | return variable; |
| --- | --- | |
| 193 | 190 | { |
| 194 | 191 | struct cw_variable *new = cw_variable_new(old->name, old->value); |
| 195 | 192 | |
| 196 | if (new) { | |
| 193 | if (new) | |
| 197 | 194 | new->lineno = old->lineno; |
| 198 | new->object = old->object; | |
| 199 | new->blanklines = old->blanklines; | |
| 200 | /* TODO: clone comments? */ | |
| 201 | } | |
| 202 | 195 | |
| 203 | 196 | return new; |
| 204 | 197 | } |
| --- | --- | |
| 390 | 383 | char *cur = buf; |
| 391 | 384 | struct cw_variable *v; |
| 392 | 385 | char cmd[512], exec_file[512]; |
| 393 | int object, do_exec, do_include; | |
| 386 | int do_exec, do_include; | |
| 394 | 387 | |
| 395 | 388 | /* Actually parse the entry */ |
| 396 | 389 | if (cur[0] == '[') { |
| --- | --- | |
| 524 | 517 | *c = 0; |
| 525 | 518 | c++; |
| 526 | 519 | /* Ignore > in => */ |
| 527 | if (*c== '>') { | |
| 528 | object = 1; | |
| 520 | if (*c== '>') | |
| 529 | 521 | c++; |
| 530 | } else | |
| 531 | object = 0; | |
| 532 | 522 | v = cw_variable_new(cw_strip(cur), cw_strip(c)); |
| 533 | 523 | if (v) { |
| 534 | 524 | v->lineno = lineno; |
| 535 | v->object = object; | |
| 536 | 525 | /* Put and reset comments */ |
| 537 | v->blanklines = 0; | |
| 538 | 526 | cw_variable_append(*cat, v); |
| 539 | 527 | } else { |
| 540 | 528 | cw_log(CW_LOG_WARNING, "Out of memory, line %d\n", lineno); |
callweaver/trunk/include/callweaver/config.h (unified diff)
| r5590 | r5706 | |
|---|---|---|
| 39 | 39 | struct cw_category; |
| 40 | 40 | |
| 41 | 41 | struct cw_variable { |
| 42 | char *name; | |
| 43 | 42 | char *value; |
| 44 | 43 | int lineno; |
| 45 | int object; /*!< 0 for variable, 1 for object */ | |
| 46 | int blanklines; /*!< Number of blanklines following entry */ | |
| 47 | struct cw_comment *precomments; | |
| 48 | struct cw_comment *sameline; | |
| 49 | 44 | struct cw_variable *next; |
| 50 | char stuff[0]; | |
| 45 | char name[0]; | |
| 51 | 46 | }; |
| 52 | 47 | |
| 53 | 48 | typedef struct cw_config *config_load_func(const char *database, const char *table, const char *configfile, struct cw_config *config); |
![Home changeset 5706 [home]](/images/logo.png?1180520111)

RSS Feeds