public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: fabbione@sourceware.org
To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com
Subject: Cluster Project branch, master, updated. cluster-2.99.04-38-gcb69044
Date: Fri, 20 Jun 2008 05:32:00 -0000	[thread overview]
Message-ID: <20080620053239.18804.qmail@sourceware.org> (raw)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=cb690444146f443739976b8795407545666addb1

The branch, master has been updated
       via  cb690444146f443739976b8795407545666addb1 (commit)
      from  ccdb6bd23d58be30082e0a4f5686fdbfc4ac92b0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cb690444146f443739976b8795407545666addb1
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Fri Jun 20 07:31:36 2008 +0200

    [CCS] Shrink more common code for internal xml queries
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

-----------------------------------------------------------------------

Summary of changes:
 ccs/daemon/misc.c |  139 +++++++++++++++++++----------------------------------
 1 files changed, 49 insertions(+), 90 deletions(-)

diff --git a/ccs/daemon/misc.c b/ccs/daemon/misc.c
index 1c738d9..167536f 100644
--- a/ccs/daemon/misc.c
+++ b/ccs/daemon/misc.c
@@ -32,12 +32,43 @@ open_doc_t *master_doc = NULL;
 
 LOGSYS_DECLARE_SUBSYS ("CCS", LOG_INFO);
 
+/**
+ * do_simple_xml_query
+ * @ctx: xml context
+ * @query: "/cluster/@name"
+ *
+ * it only handles this kind of query
+ */
+static char *do_simple_xml_query(xmlXPathContextPtr ctx, char *query) {
+  xmlXPathObjectPtr  obj = NULL;
+  xmlNodePtr        node = NULL;
+
+  obj = xmlXPathEvalExpression((xmlChar *)query, ctx);
+  if(!obj || !obj->nodesetval || (obj->nodesetval->nodeNr != 1))
+    log_printf(LOG_DEBUG, "Error processing query: %s.\n", query);
+  else {
+    node = obj->nodesetval->nodeTab[0];
+    if(node->type != XML_ATTRIBUTE_NODE)
+      log_printf(LOG_DEBUG, "Object returned is not of attribute type.\n");
+    else {
+      if(!node->children->content || !strlen((char *)node->children->content))
+	log_printf(LOG_DEBUG, "No content found.\n");
+      else
+	return strdup((char *)node->children->content);
+    }
+  }
+
+  if(obj)
+    xmlXPathFreeObject(obj);
+
+  return NULL;
+}
+
 int get_doc_version(xmlDocPtr ldoc){
   int i;
   int error = 0;
-  xmlXPathObjectPtr  obj = NULL;
   xmlXPathContextPtr ctx = NULL;
-  xmlNodePtr        node = NULL;
+  char *res = NULL;
 
   CCSENTER("get_doc_version");
 
@@ -48,43 +79,28 @@ int get_doc_version(xmlDocPtr ldoc){
     goto fail;
   }
 
-  obj = xmlXPathEvalExpression((xmlChar *)"/cluster/@config_version", ctx);
-  if(!obj || !obj->nodesetval || (obj->nodesetval->nodeNr != 1)){
-    log_printf(LOG_ERR, "Error while retrieving config_version.\n");
-    error = -ENODATA;
-    goto fail;
-  }
-
-  node = obj->nodesetval->nodeTab[0];
-  if(node->type != XML_ATTRIBUTE_NODE){
-    log_printf(LOG_ERR, "Object returned is not of attribute type.\n");
-    error = -ENODATA;
-    goto fail;
-  }
-
-  if(!node->children->content || !strlen((char *)node->children->content)){
-    log_printf(LOG_DEBUG, "No content found.\n");
-    error = -ENODATA;
-    goto fail;
-  }
-  
-  for(i=0; i < strlen((char *)node->children->content); i++){
-    if(!isdigit(node->children->content[i])){
-      log_printf(LOG_ERR, "config_version is not a valid integer.\n");
-      error = -EINVAL;
-      goto fail;
+  res =  do_simple_xml_query(ctx, "/cluster/@config_version");
+  if(res) {
+    for(i=0; i < strlen(res); i++){
+      if(!isdigit(res[i])){
+        log_printf(LOG_ERR, "config_version is not a valid integer.\n");
+        error = -EINVAL;
+        goto fail;
+      }
     }
-  }
-  error = atoi((char *)node->children->content);
+    error = atoi(res);
+  } else
+    error = -EINVAL;
 
 fail:
 
+  if(res)
+	free(res);
+
   if(ctx){
     xmlXPathFreeContext(ctx);
   }
-  if(obj){
-    xmlXPathFreeObject(obj);
-  }
+
   CCSEXIT("get_doc_version");
   return error;
 }
@@ -101,9 +117,7 @@ fail:
 char *get_cluster_name(xmlDocPtr ldoc){
   int error = 0;
   char *rtn = NULL;
-  xmlXPathObjectPtr  obj = NULL;
   xmlXPathContextPtr ctx = NULL;
-  xmlNodePtr        node = NULL;
 
   CCSENTER("get_cluster_name");
 
@@ -114,73 +128,18 @@ char *get_cluster_name(xmlDocPtr ldoc){
     goto fail;
   }
 
-  obj = xmlXPathEvalExpression((xmlChar *)"/cluster/@name", ctx);
-  if(!obj || !obj->nodesetval || (obj->nodesetval->nodeNr != 1)){
-    log_printf(LOG_ERR, "Error while retrieving config_version.\n");
-    error = -ENODATA;
-    goto fail;
-  }
-
-  node = obj->nodesetval->nodeTab[0];
-  if(node->type != XML_ATTRIBUTE_NODE){
-    log_printf(LOG_ERR, "Object returned is not of attribute type.\n");
-    error = -ENODATA;
-    goto fail;
-  }
-
-  if(!node->children->content || !strlen((char *)node->children->content)){
-    log_printf(LOG_DEBUG, "No content found.\n");
-    error = -ENODATA;
-    goto fail;
-  }
-
-  rtn = strdup((char *)node->children->content);
+  rtn = do_simple_xml_query(ctx, "/cluster/@name");
 
 fail:
 
   if(ctx){
     xmlXPathFreeContext(ctx);
   }
-  if(obj){
-    xmlXPathFreeObject(obj);
-  }
   CCSEXIT("get_cluster_name");
   return rtn;
 }
 
 /**
- * do_simple_xml_query
- * @ctx: xml context
- * @query: "/cluster/@name"
- *
- * it only handles this kind of query
- */
-static char *do_simple_xml_query(xmlXPathContextPtr ctx, char *query) {
-  xmlXPathObjectPtr  obj = NULL;
-  xmlNodePtr        node = NULL;
-
-  obj = xmlXPathEvalExpression((xmlChar *)query, ctx);
-  if(!obj || !obj->nodesetval || (obj->nodesetval->nodeNr != 1))
-    log_printf(LOG_DEBUG, "Error processing query: %s.\n", query);
-  else {
-    node = obj->nodesetval->nodeTab[0];
-    if(node->type != XML_ATTRIBUTE_NODE)
-      log_printf(LOG_DEBUG, "Object returned is not of attribute type.\n");
-    else {
-      if(!node->children->content || !strlen((char *)node->children->content))
-	log_printf(LOG_DEBUG, "No content found.\n");
-      else
-	return strdup((char *)node->children->content);
-    }
-  }
-
-  if(obj)
-    xmlXPathFreeObject(obj);
-
-  return NULL;
-}
-
-/**
  * set_ccs_logging
  * @ldoc:
  *


hooks/post-receive
--
Cluster Project


                 reply	other threads:[~2008-06-20  5:32 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=20080620053239.18804.qmail@sourceware.org \
    --to=fabbione@sourceware.org \
    --cc=cluster-cvs@sources.redhat.com \
    --cc=cluster-devel@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).