Send Linux-ha-cvs mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: lib by andrew from 
      ([email protected])
   2. Linux-HA CVS: include by andrew from 
      ([email protected])
   3. Linux-HA CVS: lib by andrew from 
      ([email protected])


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

Message: 1
Date: Tue,  4 Apr 2006 07:07:37 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/cib


Modified Files:
        cib_client.c 


Log Message:
New CIB error code

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/cib/cib_client.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -3 -r1.53 -r1.54
--- cib_client.c        31 Mar 2006 11:50:24 -0000      1.53
+++ cib_client.c        4 Apr 2006 13:07:36 -0000       1.54
@@ -802,6 +802,8 @@
                        break;
                case cib_old_data:
                        error_msg = "Update was older than existing 
configuration";
+               case cib_dtd_validation:
+                       error_msg = "Update does conform to the DTD in 
"HA_LIBDIR"/heartbeat/crm.dtd";
                        break;
        }
                        
@@ -920,7 +922,9 @@
 get_cib_copy(cib_t *cib)
 {
        crm_data_t *xml_cib;
+#if CRM_DEPRECATED_SINCE_2_0_4
        crm_data_t *xml_cib_copy;
+#endif
        int options = cib_scope_local|cib_sync_call;
        if(cib->cmds->query(cib, NULL, &xml_cib, options) != cib_ok) {
                crm_err("Couldnt retrieve the CIB");




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

Message: 2
Date: Tue,  4 Apr 2006 07:07:37 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: include by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : include

Dir     : linux-ha/include/crm


Modified Files:
        cib.h 


Log Message:
New CIB error code

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/crm/cib.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -3 -r1.38 -r1.39
--- cib.h       3 Feb 2006 08:29:22 -0000       1.38
+++ cib.h       4 Apr 2006 13:07:36 -0000       1.39
@@ -1,4 +1,4 @@
-/* $Id: cib.h,v 1.38 2006/02/03 08:29:22 andrew Exp $ */
+/* $Id: cib.h,v 1.39 2006/04/04 13:07:36 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -111,7 +111,8 @@
        cib_diff_failed         = -43,
        cib_diff_resync         = -44,
        cib_old_data            = -45,
-       cib_id_check            = -46
+       cib_id_check            = -46,
+       cib_dtd_validation      = -47   
 };
 
 enum cib_update_op {




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

Message: 3
Date: Tue,  4 Apr 2006 07:08:52 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/common


Modified Files:
        msg.c xml.c 


Log Message:
Dont fake xmlGetNodePath(), just use get_element_name() directly
Implement xml dtd validation

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/msg.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- msg.c       16 Sep 2005 16:55:23 -0000      1.6
+++ msg.c       4 Apr 2006 13:08:52 -0000       1.7
@@ -1,4 +1,4 @@
-/* $Id: msg.c,v 1.6 2005/09/16 16:55:23 andrew Exp $ */
+/* $Id: msg.c,v 1.7 2006/04/04 13:08:52 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -110,7 +110,7 @@
                crm_debug_3(
                       "XML is valid and node with message type (%s) found.",
                       type);
-       crm_debug_3("Returning node (%s)", xmlGetNodePath(action));
+       crm_debug_3("Returning node (%s)", crm_element_name(action));
 */
        
        return action;
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/xml.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -3 -r1.66 -r1.67
--- xml.c       3 Apr 2006 15:16:48 -0000       1.66
+++ xml.c       4 Apr 2006 13:08:52 -0000       1.67
@@ -1,4 +1,4 @@
-/* $Id: xml.c,v 1.66 2006/04/03 15:16:48 andrew Exp $ */
+/* $Id: xml.c,v 1.67 2006/04/04 13:08:52 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -82,7 +82,7 @@
        
        xml_child_iter_filter(
                root, a_child, search_path,
-/*             crm_debug_5("returning node (%s).", xmlGetNodePath(a_child)); */
+/*             crm_debug_5("returning node (%s).", crm_element_name(a_child)); 
*/
                crm_log_xml(LOG_DEBUG_5, "found:", a_child);
                crm_log_xml(LOG_DEBUG_6, "in:",    root);
                crm_validate_data(a_child);
@@ -90,9 +90,9 @@
                );
 
        if(must_find) {
-               crm_warn("Could not find %s in %s.", search_path, 
xmlGetNodePath(root));
+               crm_warn("Could not find %s in %s.", search_path, 
crm_element_name(root));
        } else if(root != NULL) {
-               crm_debug_3("Could not find %s in %s.", search_path, 
xmlGetNodePath(root));
+               crm_debug_3("Could not find %s in %s.", search_path, 
crm_element_name(root));
        } else {
                crm_debug_3("Could not find %s in <NULL>.", search_path);
        }
@@ -135,7 +135,7 @@
 
        if (is_found) {
                crm_debug_5("returning node (%s).",
-                          xmlGetNodePath(lastMatch));
+                          crm_element_name(lastMatch));
 
                crm_log_xml_debug_5(lastMatch, "found\t%s");
                crm_log_xml_debug_5(root, "in \t%s");
@@ -149,7 +149,7 @@
                   search_path, len);
 
        crm_debug_2("Closest point was node (%s) starting from %s.",
-                   xmlGetNodePath(lastMatch), crm_element_name(root));
+                   crm_element_name(lastMatch), crm_element_name(root));
 
        return NULL;
     
@@ -176,7 +176,7 @@
 
        if(attr_name == NULL || strlen(attr_name) == 0) {
                crm_err("Can not find attribute with no name in %s",
-                      xmlGetNodePath(parent));
+                      crm_element_name(parent));
                return NULL;
        }
        
@@ -194,7 +194,7 @@
        attr_value = crm_element_value(attr_parent, attr_name);
        if((attr_value == NULL || strlen(attr_value) == 0) && error) {
                crm_err("No value present for %s at %s",
-                       attr_name, xmlGetNodePath(attr_parent));
+                       attr_name, crm_element_name(attr_parent));
                return NULL;
        }
        
@@ -210,12 +210,12 @@
                parent, a_child, node_name,
                if(id == NULL || safe_str_eq(id, ID(a_child))) {
                        crm_debug_4("returning node (%s).", 
-                                 xmlGetNodePath(a_child));
+                                 crm_element_name(a_child));
                        return a_child;
                }
                );
        crm_debug_3("node <%s id=%s> not found in %s.",
-                   node_name, id, xmlGetNodePath(parent));
+                   node_name, id, crm_element_name(parent));
        return NULL;
 }
 
@@ -2442,3 +2442,52 @@
        free_xml(sorted);
        return digest;
 }
+
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+gboolean
+validate_with_dtd(crm_data_t *xml_blob, const char *dtd_file) 
+{
+       char *buffer = NULL;
+       gboolean valid = TRUE;
+
+       xmlDocPtr doc = NULL;
+       xmlDtdPtr dtd = NULL;
+       xmlValidCtxtPtr cvp = NULL;
+       
+       CRM_CHECK(xml_blob != NULL, return FALSE);
+       CRM_CHECK(dtd_file != NULL, return FALSE);
+
+       buffer = dump_xml_formatted(xml_blob);
+       CRM_CHECK(buffer != NULL, return FALSE);
+
+       doc = xmlParseMemory(buffer, strlen(buffer));
+       CRM_CHECK(doc != NULL, crm_free(buffer); return TRUE);
+       
+       dtd = xmlParseDTD(NULL, (const xmlChar *)dtd_file);
+       CRM_CHECK(dtd != NULL, crm_free(buffer); return TRUE);
+
+       cvp = xmlNewValidCtxt();
+       CRM_CHECK(cvp != NULL, crm_free(buffer); return TRUE);
+       
+       cvp->userData = (void *) LOG_ERR;
+       cvp->error    = (xmlValidityErrorFunc) cl_log;
+       cvp->warning  = (xmlValidityWarningFunc) cl_log;
+       
+       if (!xmlValidateDtd(cvp, doc, dtd)) {
+               crm_err("CIB does not validate against %s\n", dtd_file);
+               valid = FALSE;
+               crm_log_xml_debug(xml_blob, "invalid");
+       }
+
+       xmlFreeValidCtxt(cvp);
+       xmlFreeDtd(dtd);
+       xmlFreeDoc(doc);
+       
+       crm_free(buffer);
+       
+       return TRUE;
+/*     return valid; */
+}




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

_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 29, Issue 16
********************************************

Reply via email to