in flood_config.c [146:191]
apr_status_t retrieve_xml_elem_with_childmatch(struct apr_xml_elem **elem,
struct apr_xml_elem *top_elem,
char *path,
const char *child_name,
const char *child_val)
{
char *pc, *last; /* path component, apr_strtok state */
const char *lc; /* last path component */
struct apr_xml_elem *node, *tmpnode;
apr_status_t stat;
char *delim = XML_ELEM_DELIM;
/* start the search from the given top element */
node = top_elem;
/* break the path into the components, find the first match */
for (pc = apr_strtok(path, delim, &last);
pc;
pc = apr_strtok(NULL, delim, &last)) {
if ((stat = retrieve_xml_elem_child(&tmpnode, node, pc)) != APR_SUCCESS)
return stat; /* it'll return here if it wasn't found */
node = tmpnode; /* keep walking down the path */
}
/* save the name of this node */
lc = node->name;
/* search each sibling for a child node called "name" with value 'name' */
for (tmpnode = node; tmpnode; tmpnode = tmpnode->next) {
if ((strncasecmp(tmpnode->name, lc, FLOOD_STRLEN_MAX) == 0) &&
tmpnode->first_child &&
tmpnode->first_child->name &&
(strncasecmp(
tmpnode->first_child->name,
child_name, FLOOD_STRLEN_MAX) == 0) &&
(strncmp(
tmpnode->first_child->first_cdata.first->text, /* XXX: only checks first cdata. */
child_val, FLOOD_STRLEN_MAX) == 0))
{
/* we found the node */
*elem = tmpnode;
return APR_SUCCESS;
}
}
return APR_EGENERAL;
}