public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - config: Make 'cn' output conditional
@ 2009-09-10 17:49 Lon Hohberger
0 siblings, 0 replies; only message in thread
From: Lon Hohberger @ 2009-09-10 17:49 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a1de8e1e91180e5e025fffda48f8325ee4b43815
Commit: a1de8e1e91180e5e025fffda48f8325ee4b43815
Parent: b6edcdd24b9b438abe364cf128e05481e9ad644c
Author: Lon Hohberger <lhh@redhat.com>
AuthorDate: Thu Sep 10 13:46:41 2009 -0400
Committer: Lon Hohberger <lhh@redhat.com>
CommitterDate: Thu Sep 10 13:46:41 2009 -0400
config: Make 'cn' output conditional
The MUST ( cn ) output is now conditional on whether
the given object class may have children.
Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
config/tools/ldap/rng2ldif/rng2ldif.c | 4 +--
config/tools/ldap/rng2ldif/tree.c | 35 +++++++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/config/tools/ldap/rng2ldif/rng2ldif.c b/config/tools/ldap/rng2ldif/rng2ldif.c
index 33e795c..6b24dd2 100644
--- a/config/tools/ldap/rng2ldif/rng2ldif.c
+++ b/config/tools/ldap/rng2ldif/rng2ldif.c
@@ -218,9 +218,7 @@ main(int argc, char **argv)
return 1;
}
- if (find_objects(xmlDocGetRootElement(doc),
- &objs, &attrs, &info) < 0)
- return 1;
+ find_objects(xmlDocGetRootElement(doc), &objs, &attrs, &info);
reverse((struct faux_list **)&attrs);
reverse((struct faux_list **)&objs);
diff --git a/config/tools/ldap/rng2ldif/tree.c b/config/tools/ldap/rng2ldif/tree.c
index a2fae31..85a02ce 100644
--- a/config/tools/ldap/rng2ldif/tree.c
+++ b/config/tools/ldap/rng2ldif/tree.c
@@ -255,14 +255,13 @@ find_required_attributes(xmlNodePtr curr_node,
}
-static void
+static struct ldap_object_node *
parse_element_tag(xmlNodePtr curr_node,
struct ldap_object_node **objs,
struct ldap_attr_node **attrs,
struct idinfo *ids)
{
struct ldap_object_node *obj;
- struct ldap_attr_meta_node *attrm;
char *n, *normalized;
struct idval *v;
int need_cn = 1;
@@ -311,6 +310,8 @@ parse_element_tag(xmlNodePtr curr_node,
dbg_printf("Object class might %s need 'MUST ( cn )' for proper LDIF\n", obj->name);
obj->need_cn = 1;
}
+
+ return obj;
}
@@ -320,21 +321,43 @@ find_objects(xmlNodePtr curr_node,
struct ldap_attr_node **attrs,
struct idinfo *ids)
{
+ struct ldap_object_node *obj = NULL;
+ int ret = 0;
+
if (!curr_node)
+ /* no objects found */
return 0;
for (; curr_node; curr_node = curr_node->next) {
if (curr_node->type != XML_ELEMENT_NODE)
continue;
if (!strcasecmp((char *)curr_node->name, "element")) {
- parse_element_tag(curr_node, objs, attrs, ids);
+ obj = parse_element_tag(curr_node, objs, attrs, ids);
+ ret = 1;
} else {
dbg_printf("Descend on %s\n", curr_node->name);
}
- find_objects(curr_node->xmlChildrenNode,
- objs, attrs, ids);
+ if (find_objects(curr_node->xmlChildrenNode,
+ objs, attrs, ids)) {
+ ret = 1;
+ } else if (obj) {
+ /*
+ * We have an object, but when we
+ * looked for children, it did not
+ * have any. So, we can omit the
+ * requirement for 'cn' in the
+ * output LDIF here
+ */
+ if (obj->need_cn) {
+ dbg_printf("Object class %s does not have"
+ " any children; not outputting "
+ "'MUST ( cn )'\n", obj->name);
+ }
+ obj->need_cn = 0;
+ }
}
- return 0;
+ /* Child objects were found */
+ return ret;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-10 17:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-10 17:49 cluster: STABLE3 - config: Make 'cn' output conditional Lon Hohberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).