Fix multiple query code

Signed-off-by: Lon Hohberger <lon@users.sourceforge.net>
This commit is contained in:
Lon Hohberger 2010-01-08 18:17:03 -05:00
parent 2643994886
commit 42af98aa99

View File

@ -238,11 +238,55 @@ top:
}
if (ptr[0] != '@') {
if (node->val) {
strncpy(value, node->val, valuesz);
return 0;
strncpy(buf, ptr, sizeof(buf));
id = NULL;
bracket = strchr(buf, '[');
if (bracket) {
*bracket = 0;
++bracket;
id = bracket;
bracket = strchr(bracket, ']');
if (!bracket)
return 1;
*bracket = 0;
if (id[0] == '@') {
++id;
if (!strlen(id)) {
return 1;
}
} else {
req_index = atoi(id);
if (req_index <= 0)
return 1;
id = NULL;
}
}
found = 0;
curr_index = 0;
for (n = node; n; n = n->next) {
if (strcasecmp(n->id, buf))
continue;
++curr_index;
if (req_index && (curr_index != req_index)) {
continue;
} else if (id && strcasecmp(n->val, id)) {
continue;
}
if (node->val) {
strncpy(value, node->val, valuesz);
return 0;
}
return 1;
}
return 1;
}
++ptr;