Revision 0940b7ec som/ChunkBuffer/config.c
som/ChunkBuffer/config.c | ||
---|---|---|
12 | 12 |
#warning Fix config_parse |
13 | 13 |
struct tag *config_parse(const char *cfg) |
14 | 14 |
{ |
15 |
/* Fake Implementation */ |
|
16 | 15 |
struct tag *res; |
17 | 16 |
int i = 0; |
17 |
const char *p = cfg; |
|
18 | 18 |
|
19 | 19 |
res = malloc(sizeof(struct tag) * MAX_TAGS); |
20 | 20 |
if (res == NULL) { |
21 | 21 |
return res; |
22 | 22 |
} |
23 |
strcpy(res[i].name, "size"); |
|
24 |
strcpy(res[i++].value, "32"); |
|
23 |
while (p && *p != 0) { |
|
24 |
char *p1 = strchr(p, '='); |
|
25 |
if (p1) { |
|
26 |
if (i % MAX_TAGS == 0) { |
|
27 |
res = realloc(res, sizeof(struct tag) * (i + MAX_TAGS)); |
|
28 |
} |
|
29 |
memcpy(res[i].name, p, p1 - p); |
|
30 |
res[i].name[p1 - p + 1] = 0; |
|
31 |
p = strchr(p1, ','); |
|
32 |
if (p == NULL) { |
|
33 |
strcpy(res[i++].value, p1 + 1); |
|
34 |
} else { |
|
35 |
memcpy(res[i].value, p1 + 1, p - p1 - 1); |
|
36 |
res[i++].value[p - p1] = 0; |
|
37 |
p++; |
|
38 |
} |
|
39 |
} else { |
|
40 |
p = NULL; |
|
41 |
} |
|
42 |
} |
|
25 | 43 |
res[i++].name[0] = 0; |
26 | 44 |
|
27 | 45 |
res = realloc(res, sizeof(struct tag) * i); |
Also available in: Unified diff