[libxml2] Fix a couple of ABI issues with C14N 1.1



commit 175beba061288d777dd3c022885c05500aa3c377
Author: Aleksey Sanin <aleksey aleksey com>
Date:   Thu Jul 9 22:54:00 2009 +0200

    Fix a couple of ABI issues with C14N 1.1
    
    * include/libxml/c14n.h c14n.c: fix API to not include enum xmlC14NMode
      in the arguments, and do a bit more check on input

 c14n.c                |   24 +++++++++++++++++++-----
 include/libxml/c14n.h |    6 +++---
 2 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/c14n.c b/c14n.c
index 53a19c1..5c6c456 100644
--- a/c14n.c
+++ b/c14n.c
@@ -1863,10 +1863,11 @@ xmlC14NNewCtx(xmlDocPtr doc,
  */
 int 		
 xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
-	 void* user_data, xmlC14NMode mode, xmlChar **inclusive_ns_prefixes,
+	 void* user_data, int mode, xmlChar **inclusive_ns_prefixes,
 	 int with_comments, xmlOutputBufferPtr buf) {
 
     xmlC14NCtxPtr ctx;
+    xmlC14NMode c14n_mode = XML_C14N_1_0;
     int ret;
 
     if ((buf == NULL) || (doc == NULL)) {
@@ -1874,6 +1875,19 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
         return (-1);
     }
 
+    /* for backward compatibility, we have to have "mode" as "int" 
+       and here we check that user gives valid value */
+    switch(mode) {
+    case XML_C14N_1_0:
+    case XML_C14N_EXCLUSIVE_1_0:
+    case XML_C14N_1_1: 
+         c14n_mode = (xmlC14NMode)mode;
+         break;
+    default:       
+        xmlC14NErrParam("invalid mode for executing c14n");
+        return (-1);
+    }
+
     /*
      *  Validate the encoding output buffer encoding
      */
@@ -1884,8 +1898,8 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
     }
 
     ctx = xmlC14NNewCtx(doc, is_visible_callback, user_data, 
-			            mode, inclusive_ns_prefixes,
-                        with_comments, buf);
+	            c14n_mode, inclusive_ns_prefixes,
+                    with_comments, buf);
     if (ctx == NULL) {
         xmlC14NErr(NULL, (xmlNodePtr) doc, XML_C14N_CREATE_CTXT,
 		   "xmlC14NExecute: unable to create C14N context\n");
@@ -1986,7 +2000,7 @@ xmlC14NDocSaveTo(xmlDocPtr doc, xmlNodeSetPtr nodes,
  */
 int
 xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
-                     xmlC14NMode mode, xmlChar ** inclusive_ns_prefixes,
+                     int mode, xmlChar ** inclusive_ns_prefixes,
                      int with_comments, xmlChar ** doc_txt_ptr)
 {
     int ret;
@@ -2057,7 +2071,7 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
  */
 int
 xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
-               xmlC14NMode mode, xmlChar ** inclusive_ns_prefixes,
+               int mode, xmlChar ** inclusive_ns_prefixes,
                int with_comments, const char *filename, int compression)
 {
     xmlOutputBufferPtr buf;
diff --git a/include/libxml/c14n.h b/include/libxml/c14n.h
index e99b144..3011af7 100644
--- a/include/libxml/c14n.h
+++ b/include/libxml/c14n.h
@@ -75,7 +75,7 @@ XMLPUBFUN int XMLCALL
 XMLPUBFUN int XMLCALL
 		xmlC14NDocDumpMemory	(xmlDocPtr doc,
 					 xmlNodeSetPtr nodes,
-					 xmlC14NMode mode,
+					 int mode, /* a xmlC14NMode */
 					 xmlChar **inclusive_ns_prefixes,
 					 int with_comments,
 					 xmlChar **doc_txt_ptr);
@@ -83,7 +83,7 @@ XMLPUBFUN int XMLCALL
 XMLPUBFUN int XMLCALL
 		xmlC14NDocSave		(xmlDocPtr doc,
 					 xmlNodeSetPtr nodes,
-					 xmlC14NMode mode,
+					 int mode, /* a xmlC14NMode */
 					 xmlChar **inclusive_ns_prefixes,
 					 int with_comments,
 					 const char* filename,
@@ -111,7 +111,7 @@ XMLPUBFUN int XMLCALL
 		xmlC14NExecute		(xmlDocPtr doc,
 					 xmlC14NIsVisibleCallback is_visible_callback,
 					 void* user_data,
-					 xmlC14NMode mode,
+					 int mode, /* a xmlC14NMode */
 					 xmlChar **inclusive_ns_prefixes,
 					 int with_comments,
 					 xmlOutputBufferPtr buf);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]