48 while(atts[i] != NULL)
85 int done, len, end, i, j, attr;
86 char buf[1024], *next;
95 fprintf(stderr,
"config_load: couldn't open %s for reading: %s\n", file, strerror(errno));
100 p = XML_ParserCreate(NULL);
103 fprintf(stderr,
"config_load: couldn't allocate XML parser\n");
113 XML_SetUserData(p, (
void *) &bd);
120 len = fread(buf, 1, 1024, f);
123 fprintf(stderr,
"config_load: read error: %s\n", strerror(errno));
132 if(!XML_Parse(p, buf, len, done))
134 fprintf(stderr,
"config_load: parse error at line %llu: %s\n", (
unsigned long long) XML_GetCurrentLineNumber(p), XML_ErrorString(XML_GetErrorCode(p)));
153 elem->
values = calloc(1,
sizeof(
char *));
162 for(i = 1; i < bd.
nad->
ecur && rv == 0; i++)
165 if(end <= bd.nad->elems[i].
depth)
177 for(j = 1; j < len; j++)
180 next = next + path[j]->
lname;
217 elem->
attrs = realloc((
void *) elem->
attrs,
sizeof(
char **) * (elem->
nvalues + 1));
321 return j_attr((
const char **) elem->
attrs[num], attr);
340 #ifdef CONFIGEXPAND_GUARDED
341 static char guard[] =
"deadbeaf";
345 char *s = strndup(value, l);
347 char *var_start, *var_end;
349 while (var_start = strstr(s,
"${")) {
351 var_end = strstr(var_start + 2,
"}");
354 char *tail = var_end + 1;
355 char *var = var_start + 2;
363 int len = (var_start - s) + strlen(tail) + strlen(var_value) + 1;
365 #ifdef CONFIGEXPAND_GUARDED
366 len +=
sizeof(guard);
368 char *expanded_str = calloc(len, 1);
370 #ifdef CONFIGEXPAND_GUARDED
371 char *p_guard = expanded_str + len -
sizeof(guard);
372 strncpy(p_guard, guard,
sizeof(guard));
375 char *p = expanded_str;
376 strncpy(expanded_str, s, var_start - s);
379 strcpy(p, var_value);
380 p += strlen(var_value);
387 fprintf(stderr,
"config_expand: Have no '%s' defined\n", var);
393 fprintf(stderr,
"config_expand: } missmatch\n");