public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Lon Hohberger <lon@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: STABLE3 - config: Make 'cn' output conditional
Date: Thu, 10 Sep 2009 17:49:00 -0000	[thread overview]
Message-ID: <20090910174921.940081201EF@lists.fedorahosted.org> (raw)

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;
 }


                 reply	other threads:[~2009-09-10 17:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090910174921.940081201EF@lists.fedorahosted.org \
    --to=lon@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).