tree.c | tree.c | |||
---|---|---|---|---|
skipping to change at line 93 | skipping to change at line 93 | |||
static struct ldap_attr_node * | static struct ldap_attr_node * | |||
get_attr(xmlNodePtr curr_node, struct ldap_attr_node **attrs, | get_attr(xmlNodePtr curr_node, struct ldap_attr_node **attrs, | |||
struct idinfo *ids) | struct idinfo *ids) | |||
{ | { | |||
struct ldap_attr_node *n; | struct ldap_attr_node *n; | |||
struct idval *v; | struct idval *v; | |||
char *name, *normalized; | char *name, *normalized; | |||
name = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); | name = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); | |||
if (!name) { | ||||
return NULL; | ||||
} | ||||
normalized = normalize_name((const char *)name); | normalized = normalize_name((const char *)name); | |||
n = find_attr_byname(*attrs, normalized); | n = find_attr_byname(*attrs, normalized); | |||
if (n) { | if (n) { | |||
free(normalized); | free(normalized); | |||
return n; | return n; | |||
} | } | |||
n = zalloc(sizeof(*n)); | n = zalloc(sizeof(*n)); | |||
skipping to change at line 148 | skipping to change at line 152 | |||
static xmlNodePtr | static xmlNodePtr | |||
find_ref(xmlNodePtr curr_node) | find_ref(xmlNodePtr curr_node) | |||
{ | { | |||
xmlNodePtr n; | xmlNodePtr n; | |||
char *name; | char *name; | |||
char *tmp_name; | char *tmp_name; | |||
dbg_printf("Trying to parse ref tag\n"); | dbg_printf("Trying to parse ref tag\n"); | |||
name = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); | name = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); | |||
if (!name) { | ||||
fprintf(stderr, "Unable to determine xml name prop\n"); | ||||
exit(1); | ||||
} | ||||
n = xmlDocGetRootElement(curr_node->doc); | n = xmlDocGetRootElement(curr_node->doc); | |||
if (!n) { | ||||
fprintf(stderr, "Unable to determine xml root element\n"); | ||||
exit(1); | ||||
} | ||||
n = n->xmlChildrenNode; | n = n->xmlChildrenNode; | |||
for (; n; n = n->next) { | for (; n; n = n->next) { | |||
if (n->type != XML_ELEMENT_NODE) | if (n->type != XML_ELEMENT_NODE) | |||
continue; | continue; | |||
if (strcasecmp((char *)n->name, "define")) | if (strcasecmp((char *)n->name, "define")) | |||
continue; | continue; | |||
tmp_name = (char *)xmlGetProp(n, (xmlChar *)"name"); | tmp_name = (char *)xmlGetProp(n, (xmlChar *)"name"); | |||
if (!tmp_name) | if (!tmp_name) | |||
continue; | continue; | |||
skipping to change at line 184 | skipping to change at line 196 | |||
} | } | |||
static int | static int | |||
find_optional_attributes(xmlNodePtr curr_node, int in_block, | find_optional_attributes(xmlNodePtr curr_node, int in_block, | |||
struct ldap_object_node *curr_obj, | struct ldap_object_node *curr_obj, | |||
struct ldap_attr_node **attrs, | struct ldap_attr_node **attrs, | |||
struct idinfo *ids) | struct idinfo *ids) | |||
{ | { | |||
xmlNodePtr node; | xmlNodePtr node; | |||
struct ldap_attr_node *attr; | struct ldap_attr_node *attr; | |||
struct ldap_attr_meta_node *n; | struct ldap_attr_meta_node *n = NULL; | |||
if (!curr_node || (curr_node->type == XML_ELEMENT_NODE && | if (!curr_node || (curr_node->type == XML_ELEMENT_NODE && | |||
(curr_node->name && !strcasecmp((char *)curr_node->name, "elemen t")))) { | (curr_node->name && !strcasecmp((char *)curr_node->name, "elemen t")))) { | |||
return 0; | return 0; | |||
} | } | |||
dbg_printf("lookin for optionals\n"); | dbg_printf("lookin for optionals\n"); | |||
for (node = curr_node; node; node = node->next) { | for (node = curr_node; node; node = node->next) { | |||
if (node->type != XML_ELEMENT_NODE) | if (node->type != XML_ELEMENT_NODE) | |||
continue; | continue; | |||
if (!node->name) | ||||
continue; | ||||
if (strcmp((char *)node->name, "attribute")) | ||||
continue; | ||||
if (!strcasecmp((char *)node->name, "ref")) { | if (!strcasecmp((char *)node->name, "ref")) { | |||
find_optional_attributes( | find_optional_attributes( | |||
find_ref(node), 1, curr_obj, attrs, ids); | find_ref(node), 1, curr_obj, attrs, ids); | |||
} | } | |||
if (!strcasecmp((char *)node->name, "choice")) { | if (!strcasecmp((char *)node->name, "choice")) { | |||
find_optional_attributes(node->xmlChildrenNode, 1, | find_optional_attributes(node->xmlChildrenNode, 1, | |||
curr_obj, | curr_obj, | |||
attrs, ids); | attrs, ids); | |||
continue; | continue; | |||
} | } | |||
skipping to change at line 219 | skipping to change at line 238 | |||
attrs, ids); | attrs, ids); | |||
continue; | continue; | |||
} | } | |||
if (!strcasecmp((char *)node->name, "optional")) { | if (!strcasecmp((char *)node->name, "optional")) { | |||
find_optional_attributes(node->xmlChildrenNode, 1, | find_optional_attributes(node->xmlChildrenNode, 1, | |||
curr_obj, | curr_obj, | |||
attrs, ids); | attrs, ids); | |||
continue; | continue; | |||
} | } | |||
if (!node->name || strcmp((char *)node->name, | ||||
"attribute")) { | ||||
continue; | ||||
} | ||||
if (!in_block) | if (!in_block) | |||
continue; | continue; | |||
attr = get_attr(node, attrs, ids); | attr = get_attr(node, attrs, ids); | |||
n = zalloc(sizeof(*n)); | if (!n) { | |||
n = zalloc(sizeof(*n)); | ||||
assert(n); | ||||
} | ||||
dbg_printf("opt attr '%s'\n", attr->idval->name); | dbg_printf("opt attr '%s'\n", attr->idval->name); | |||
if (find_meta_attr(curr_obj->required_attrs, | if (find_meta_attr(curr_obj->required_attrs, | |||
attr)) { | attr)) { | |||
dbg_printf("skipping dup attr\n"); | dbg_printf("skipping dup attr\n"); | |||
continue; | continue; | |||
} | } | |||
if (find_meta_attr(curr_obj->optional_attrs, | if (find_meta_attr(curr_obj->optional_attrs, | |||
attr)) { | attr)) { | |||
dbg_printf("skipping dup attr on optional list\n"); | dbg_printf("skipping dup attr on optional list\n"); | |||
continue; | continue; | |||
} | } | |||
n->node = attr; | n->node = attr; | |||
n->next = curr_obj->optional_attrs; | n->next = curr_obj->optional_attrs; | |||
curr_obj->optional_attrs = n; | curr_obj->optional_attrs = n; | |||
n=NULL; | ||||
} | ||||
if (n) { | ||||
free(n); | ||||
n=NULL; | ||||
} | } | |||
return 0; | return 0; | |||
} | } | |||
static int | static int | |||
find_required_attributes(xmlNodePtr curr_node, | find_required_attributes(xmlNodePtr curr_node, | |||
struct ldap_object_node *curr_obj, | struct ldap_object_node *curr_obj, | |||
struct ldap_attr_node **attrs, | struct ldap_attr_node **attrs, | |||
struct idinfo *ids) | struct idinfo *ids) | |||
{ | { | |||
xmlNodePtr node; | xmlNodePtr node; | |||
struct ldap_attr_node *attr; | struct ldap_attr_node *attr; | |||
struct ldap_attr_meta_node *n; | struct ldap_attr_meta_node *n = NULL; | |||
dbg_printf("lookin for required\n"); | dbg_printf("lookin for required\n"); | |||
for (node = curr_node; node; node = node->next) { | for (node = curr_node; node; node = node->next) { | |||
if (node->type != XML_ELEMENT_NODE) | if (node->type != XML_ELEMENT_NODE) | |||
continue; | continue; | |||
if (xmlStrcmp(node->name, (xmlChar *)"attribute")) | if (xmlStrcmp(node->name, (xmlChar *)"attribute")) | |||
continue; | continue; | |||
attr = get_attr(node, attrs, ids); | attr = get_attr(node, attrs, ids); | |||
n = zalloc(sizeof(*n)); | if (!n) { | |||
n = zalloc(sizeof(*n)); | ||||
assert(n); | ||||
} | ||||
dbg_printf("req attr '%s'\n", attr->idval->name); | dbg_printf("req attr '%s'\n", attr->idval->name); | |||
if (find_meta_attr(curr_obj->required_attrs, | if (find_meta_attr(curr_obj->required_attrs, | |||
attr)) { | attr)) { | |||
dbg_printf("skipping dup attr\n"); | dbg_printf("skipping dup attr\n"); | |||
continue; | continue; | |||
} | } | |||
if (find_meta_attr(curr_obj->optional_attrs, | if (find_meta_attr(curr_obj->optional_attrs, | |||
attr)) { | attr)) { | |||
dbg_printf("skipping dup attr on optional list\n"); | dbg_printf("skipping dup attr on optional list\n"); | |||
continue; | continue; | |||
} | } | |||
n->node = attr; | n->node = attr; | |||
n->next = curr_obj->required_attrs; | n->next = curr_obj->required_attrs; | |||
curr_obj->required_attrs = n; | curr_obj->required_attrs = n; | |||
n=NULL; | ||||
} | ||||
if (n) { | ||||
free(n); | ||||
n=NULL; | ||||
} | } | |||
return 0; | return 0; | |||
} | } | |||
static struct ldap_object_node * | static struct ldap_object_node * | |||
parse_element_tag(xmlNodePtr curr_node, | parse_element_tag(xmlNodePtr curr_node, | |||
struct ldap_object_node **objs, | struct ldap_object_node **objs, | |||
struct ldap_attr_node **attrs, | struct ldap_attr_node **attrs, | |||
struct idinfo *ids) | struct idinfo *ids) | |||
{ | { | |||
struct ldap_object_node *obj; | struct ldap_object_node *obj; | |||
char *n, *normalized; | char *n, *normalized; | |||
struct idval *v; | struct idval *v; | |||
int need_cn = 1; | int need_cn = 1; | |||
dbg_printf("Trying to parse element tag\n"); | dbg_printf("Trying to parse element tag\n"); | |||
n = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); | n = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); | |||
if (!n) { | ||||
printf("Unable to parse element tag\n"); | ||||
exit(1); | ||||
} | ||||
normalized = normalize_name(n); | normalized = normalize_name(n); | |||
v = id_find(ids, normalized, OBJ, 0); | v = id_find(ids, normalized, OBJ, 0); | |||
if (!v) { | if (!v) { | |||
v = zalloc(sizeof(*v)); | v = zalloc(sizeof(*v)); | |||
v->name = normalized; | v->name = normalized; | |||
v->rawname = n; | v->rawname = n; | |||
v->type = OBJ; | v->type = OBJ; | |||
id_insert(ids, v); | id_insert(ids, v); | |||
} | } | |||
End of changes. 12 change blocks. | ||||
9 lines changed or deleted | 45 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |