Re: [xml] c14n



The attached patch "special cases" DAV: namespace in c14n's
relative namespaces check and replaces "#ifdef DEBUG_C14N/#endif"
with structured error messages as you described bellow. Please
take a look and let me know if I can check it in or need to
do something.

Aleksey

Aleksey Sanin wrote:
Sounds good. I'll do it this week (I hope).

Aleksey

Daniel Veillard wrote:

On Tue, Mar 15, 2005 at 10:13:32AM -0800, Aleksey Sanin wrote:

Currently, all c14n errors are ifdef'd with DEBUG_C14N. Should
we just turn them on by default?



Depends:
   1/ do they use the existing structured error reporting framework ?
      I think so but double checking quickly would be good


Yes. Errors are printed out using
   xmlGenericError(xmlGenericErrorContext, ...)
calls.



  Hum, it's not the structured API. The structured one provides more
informations, more generically, see include/libxml/xmlerror.h,
there is a XML_FROM_C14N error domain, and an error range for C14N
(starting at XML_C14N_CREATE_CTXT 1950 to 2000) for error numbers.
Best is to define in c14n.c a couple of intermediate calls which sets
the context up and call __xmlRaiseError or __xmlSimpleError, see for
example xmlTreeErrMemory() and xmlTreeErr() at the beginning of the tree.c module. Not really fun to do, defining new enums for errors
and calling the intermediate functions but it makes a huge difference
when the library is embedded in a more complex framework.


   2/ is there any drawback for example speed wise ?


I don't think so. It is only error case which should not happen during
"normal" run. I'll make sure that only errors will be undefed.



The main drawback can be the code size inflation, but using intermediate simpler calls at the beginning of the modules avoid most of the code size increase (don't get me started on ELF symbols lookup at runtime ...)


   3/ would that be a problem for upper layer like xmldsig ?


Not to xmldsig. It should be no difference for normal run.



  okay, though the structured error handling might be useful for your
users too ;-)


In general people appreciate receiving error messages when stuff fails.


Yes, I know :)



 especially if they can automate the processing of said errors :-)

Daniel

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
Index: c14n.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/c14n.c,v
retrieving revision 1.22
diff -u -w -r1.22 c14n.c
--- c14n.c      25 May 2004 17:39:48 -0000      1.22
+++ c14n.c      20 Mar 2005 02:25:10 -0000
@@ -127,7 +127,7 @@
  * xmlC14NErrMemory:
  * @extra:  extra informations
  *
- * Handle a redefinition of attribute error
+ * Handle a redefinition of memory error
  */
 static void
 xmlC14NErrMemory(const char *extra)
@@ -139,6 +139,83 @@
 }
 
 /**
+ * xmlC14NErrParam:
+ * @extra:  extra informations
+ *
+ * Handle a redefinition of param error
+ */
+static void
+xmlC14NErrParam(const char *extra)
+{
+    __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N,
+                   XML_ERR_INTERNAL_ERROR, XML_ERR_ERROR, NULL, 0, extra,
+                   NULL, NULL, 0, 0,
+                   "Invalid parameter : %s\n", extra);
+}
+
+/**
+ * xmlC14NErrInternal:
+ * @extra:  extra informations
+ *
+ * Handle a redefinition of internal error
+ */
+static void
+xmlC14NErrInternal(const char *extra)
+{
+    __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N,
+                   XML_ERR_INTERNAL_ERROR, XML_ERR_ERROR, NULL, 0, extra,
+                   NULL, NULL, 0, 0,
+                   "Internal error : %s\n", extra);
+}
+
+/**
+ * xmlC14NErrInvalidNode:
+ * @extra:  extra informations
+ *
+ * Handle a redefinition of invalid node error
+ */
+static void
+xmlC14NErrInvalidNode(const char *node_type, const char *extra)
+{
+    __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N,
+                   XML_C14N_INVALID_NODE, XML_ERR_ERROR, NULL, 0, extra,
+                   NULL, NULL, 0, 0,
+                   "Node %s is invalid here : %s\n", node_type, extra);
+}
+
+/**
+ * xmlC14NErrUnknownNode:
+ * @extra:  extra informations
+ *
+ * Handle a redefinition of unknown node error
+ */
+static void
+xmlC14NErrUnknownNode(int node_type, const char *extra)
+{
+    __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N,
+                   XML_C14N_UNKNOW_NODE, XML_ERR_ERROR, NULL, 0, extra,
+                   NULL, NULL, 0, 0,
+                   "Unknown node type %d found : %s\n", node_type, extra);
+}
+
+/**
+ * xmlC14NErrRelativeNamespace:
+ * @extra:  extra informations
+ *
+ * Handle a redefinition of relative namespace error
+ */
+static void
+xmlC14NErrRelativeNamespace(const char *ns_uri)
+{
+    __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_C14N,
+                   XML_C14N_RELATIVE_NAMESPACE, XML_ERR_ERROR, NULL, 0, NULL,
+                   NULL, NULL, 0, 0,
+                   "Relative namespace UR is invalid here : %s\n", ns_uri);
+}
+
+
+
+/**
  * xmlC14NErr:
  * @ctxt:  a C14N evaluation context
  * @node:  the context node
@@ -200,7 +277,7 @@
 
     ret = (xmlC14NVisibleNsStackPtr) xmlMalloc(sizeof(xmlC14NVisibleNsStack));
     if (ret == NULL) {
-        xmlC14NErrMemory("creating stack");
+        xmlC14NErrMemory("creating namespaces stack");
        return(NULL);
     }
     memset(ret, 0 , (size_t) sizeof(xmlC14NVisibleNsStack));
@@ -210,10 +287,7 @@
 static void
 xmlC14NVisibleNsStackDestroy(xmlC14NVisibleNsStackPtr cur) {
     if(cur == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-            "xmlC14NVisibleNsStackDestroy: cur is null.\n");
-#endif
+        xmlC14NErrParam("destroying namespaces stack");
        return;
     }
     if(cur->nsTab != NULL) {
@@ -234,10 +308,7 @@
     if((cur == NULL) || 
        ((cur->nsTab == NULL) && (cur->nodeTab != NULL)) ||
        ((cur->nsTab != NULL) && (cur->nodeTab == NULL))) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-            "xmlC14NVisibleNsStackAdd: cur is null.\n");
-#endif
+        xmlC14NErrParam("adding namespace to stack");
        return;
     }
 
@@ -281,10 +352,7 @@
 static void
 xmlC14NVisibleNsStackSave(xmlC14NVisibleNsStackPtr cur, xmlC14NVisibleNsStackPtr state) {
     if((cur == NULL) || (state == NULL)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-            "xmlC14NVisibleNsStackSave: cur or state is null.\n");
-#endif
+        xmlC14NErrParam("saving namespaces stack");
        return;
     }
     
@@ -296,10 +364,7 @@
 static void
 xmlC14NVisibleNsStackRestore(xmlC14NVisibleNsStackPtr cur, xmlC14NVisibleNsStackPtr state) {
     if((cur == NULL) || (state == NULL)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-            "xmlC14NVisibleNsStackRestore: cur or state is null.\n");
-#endif
+        xmlC14NErrParam("restoring namespaces stack");
        return;
     }
     cur->nsCurEnd = state->nsCurEnd;
@@ -310,10 +375,7 @@
 static void 
 xmlC14NVisibleNsStackShift(xmlC14NVisibleNsStackPtr cur) {
     if(cur == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-            "xmlC14NVisibleNsStackRestore: cur is null.\n");
-#endif
+        xmlC14NErrParam("shifting namespaces stack");
        return;
     }
     cur->nsPrevStart = cur->nsPrevEnd;
@@ -349,10 +411,7 @@
     int has_empty_ns;
         
     if(cur == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-            "xmlC14NVisibleNsStackFind: cur is null.\n");
-#endif
+        xmlC14NErrParam("searching namespaces stack (c14n)");
         return (0);
     }
 
@@ -385,10 +444,7 @@
     int has_empty_ns;
         
     if(cur == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-            "xmlExcC14NVisibleNsStackFind: cur is null.\n");
-#endif
+        xmlC14NErrParam("searching namespaces stack (exc c14n)");
         return (0);
     }
 
@@ -479,10 +535,7 @@
 {
 
     if ((ns == NULL) || (ctx == NULL)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NPrintNamespace: namespace or context pointer is null\n");
-#endif
+        xmlC14NErrParam("writing namespaces");
         return 0;
     }
 
@@ -549,10 +602,7 @@
     int has_empty_ns = 0;
     
     if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NProcessNamespacesAxis: Null context or node pointer or type != 
XML_ELEMENT_NODE.\n");
-#endif
+        xmlC14NErrParam("processing namespaces axis (c14n)");
         return (-1);
     }
 
@@ -561,10 +611,7 @@
      */
     list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare);
     if (list == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NProcessNamespacesAxis: list creation failed\n");
-#endif
+        xmlC14NErrInternal("creating namespaces list (c14n)");
         return (-1);
     }
 
@@ -662,18 +709,12 @@
     int has_empty_ns_in_inclusive_list = 0;
         
     if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlExcC14NProcessNamespacesAxis: Null context or node pointer or type != 
XML_ELEMENT_NODE.\n");
-#endif
+        xmlC14NErrParam("processing namespaces axis (exc c14n)");
         return (-1);
     }
 
     if(!ctx->exclusive) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlExcC14NProcessNamespacesAxis: called for non-exclusive canonization or rendered 
stack is NULL.\n");
-#endif
+        xmlC14NErrParam("processing namespaces axis (exc c14n)");
         return (-1);
 
     }
@@ -683,10 +724,7 @@
      */
     list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NNsCompare);
     if (list == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlExcC14NProcessNamespacesAxis: list creation failed\n");
-#endif
+        xmlC14NErrInternal("creating namespaces list (exc c14n)");
         return (-1);
     }
 
@@ -874,10 +912,7 @@
     xmlChar *buffer;
 
     if ((attr == NULL) || (ctx == NULL)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NPrintAttrs: attr == NULL or ctx == NULL\n");
-#endif
+        xmlC14NErrParam("writing attributes");
         return (0);
     }
 
@@ -899,10 +934,7 @@
             xmlOutputBufferWriteString(ctx->buf, (const char *) buffer);
             xmlFree(buffer);
         } else {
-#ifdef DEBUG_C14N
-            xmlGenericError(xmlGenericErrorContext,
-                            "xmlC14NPrintAttrs: xmlC11NNormalizeAttr failed\n");
-#endif
+            xmlC14NErrInternal("normalizing attributes axis");
             return (0);
         }
     }
@@ -948,10 +980,7 @@
     xmlListPtr list;
 
     if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NProcessAttrsAxis: Null context or node pointer or type != 
XML_ELEMENT_NODE.\n");
-#endif
+        xmlC14NErrParam("processing attributes axis");
         return (-1);
     }
 
@@ -960,10 +989,7 @@
      */
     list = xmlListCreate(NULL, (xmlListDataCompare) xmlC14NAttrsCompare);
     if (list == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NProcessAttrsAxis: list creation failed\n");
-#endif
+        xmlC14NErrInternal("creating attributes list");
         return (-1);
     }
 
@@ -1032,10 +1058,7 @@
     xmlNsPtr ns;
 
     if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NCheckForRelativeNamespaces: Null context or node pointer or type != 
XML_ELEMENT_NODE.\n");
-#endif
+        xmlC14NErrParam("checking for relative namespaces");
         return (-1);
     }
 
@@ -1046,20 +1069,18 @@
 
             uri = xmlParseURI((const char *) ns->href);
             if (uri == NULL) {
-#ifdef DEBUG_C14N
-                xmlGenericError(xmlGenericErrorContext,
-                                "xmlC14NCheckForRelativeNamespaces: unable to parse uri=\"%s\".\n",
-                                ns->href);
-#endif
+                xmlC14NErrInternal("parsing namespace uri");
                 return (-1);
             }
             if (xmlStrlen((const xmlChar *) uri->scheme) == 0) {
+                xmlC14NErrRelativeNamespace(uri->scheme);
                 xmlFreeURI(uri);
                 return (-1);
             }
-            if ((!xmlStrEqual
-                 ((const xmlChar *) uri->scheme, BAD_CAST "urn"))
+            if ((xmlStrcasecmp((const xmlChar *) uri->scheme, BAD_CAST "urn") != 0)
+                && (xmlStrcasecmp((const xmlChar *) uri->scheme, BAD_CAST "dav") !=0)
                 && (xmlStrlen((const xmlChar *) uri->server) == 0)) {
+                xmlC14NErrRelativeNamespace(uri->scheme);
                 xmlFreeURI(uri);
                 return (-1);
             }
@@ -1099,10 +1120,7 @@
     int parent_is_doc = 0;
 
     if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NProcessElementNode: Null context or node pointer or type != 
XML_ELEMENT_NODE.\n");
-#endif
+        xmlC14NErrParam("processing element node");
         return (-1);
     }
 
@@ -1112,10 +1130,7 @@
      * failure on documents containing relative namespace URIs.
      */
     if (xmlC14NCheckForRelativeNamespaces(ctx, cur) < 0) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NProcessElementNode: xmlC14NCheckForRelativeNamespaces failed.\n");
-#endif
+        xmlC14NErrInternal("checking for relative namespaces");
         return (-1);
     }
 
@@ -1148,10 +1163,7 @@
         ret = xmlExcC14NProcessNamespacesAxis(ctx, cur, visible);
     }
     if (ret < 0) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-            "xmlC14NProcessElementNode: xmlC14NProcessNamespacesAxis failed.\n");
-#endif
+        xmlC14NErrInternal("processing namespaces axis");
         return (-1);
     }
     /* todo: shouldn't this go to "visible only"? */
@@ -1162,10 +1174,7 @@
     if(visible) {
        ret = xmlC14NProcessAttrsAxis(ctx, cur);
        if (ret < 0) {
-#ifdef DEBUG_C14N
-           xmlGenericError(xmlGenericErrorContext,
-                "xmlC14NProcessElementNode: xmlC14NProcessAttrsAxis failed.\n");
-#endif
+        xmlC14NErrInternal("processing attributes axis");
            return (-1);
        }
     }
@@ -1176,10 +1185,7 @@
     if (cur->children != NULL) {
         ret = xmlC14NProcessNodeList(ctx, cur->children);
         if (ret < 0) {
-#ifdef DEBUG_C14N
-            xmlGenericError(xmlGenericErrorContext,
-                            "xmlC14NProcessElementNode: xmlC14NProcessNodeList failed.\n");
-#endif
+            xmlC14NErrInternal("processing childrens list");
             return (-1);
         }
     }
@@ -1222,10 +1228,7 @@
     int visible;
 
     if ((ctx == NULL) || (cur == NULL)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NProcessNode: Null context or node pointer.\n");
-#endif
+        xmlC14NErrParam("processing node");
         return (-1);
     }
 
@@ -1254,10 +1257,7 @@
                                                (const char *) buffer);
                     xmlFree(buffer);
                 } else {
-#ifdef DEBUG_C14N
-                    xmlGenericError(xmlGenericErrorContext,
-                                    "xmlC14NProcessNode: xmlC11NNormalizeText() failed\n");
-#endif
+                    xmlC14NErrInternal("normalizing text node");
                     return (-1);
                 }
             }
@@ -1296,10 +1296,7 @@
                                                    (const char *) buffer);
                         xmlFree(buffer);
                     } else {
-#ifdef DEBUG_C14N
-                        xmlGenericError(xmlGenericErrorContext,
-                                        "xmlC14NProcessNode: xmlC11NNormalizePI() failed\n");
-#endif
+                        xmlC14NErrInternal("normalizing pi node");
                         return (-1);
                     }
                 }
@@ -1344,10 +1341,7 @@
                                                    (const char *) buffer);
                         xmlFree(buffer);
                     } else {
-#ifdef DEBUG_C14N
-                        xmlGenericError(xmlGenericErrorContext,
-                                        "xmlC14NProcessNode: xmlC11NNormalizeComment() failed\n");
-#endif
+                        xmlC14NErrInternal("normalizing comment node");
                         return (-1);
                     }
                 }
@@ -1375,20 +1369,16 @@
             break;
 
         case XML_ATTRIBUTE_NODE:
-           xmlC14NErr(ctx, cur, XML_C14N_INVALID_NODE,
-               "xmlC14NProcessNode: XML_ATTRIBUTE_NODE is illegal here\n");
+            xmlC14NErrInvalidNode("XML_ATTRIBUTE_NODE", "processing node");
             return (-1);
         case XML_NAMESPACE_DECL:
-           xmlC14NErr(ctx, cur, XML_C14N_INVALID_NODE,
-               "xmlC14NProcessNode: XML_NAMESPACE_DECL is illegal here\n");
+            xmlC14NErrInvalidNode("XML_NAMESPACE_DECL", "processing node");
             return (-1);
         case XML_ENTITY_REF_NODE:
-           xmlC14NErr(ctx, cur, XML_C14N_INVALID_NODE,
-               "xmlC14NProcessNode: XML_ENTITY_REF_NODE is illegal here\n");
+            xmlC14NErrInvalidNode("XML_ENTITY_REF_NODE", "processing node");
             return (-1);
         case XML_ENTITY_NODE:
-           xmlC14NErr(ctx, cur, XML_C14N_INVALID_NODE,
-               "xmlC14NProcessNode: XML_ENTITY_NODE is illegal here\n");
+            xmlC14NErrInvalidNode("XML_ENTITY_NODE", "processing node");
             return (-1);
 
         case XML_DOCUMENT_TYPE_NODE:
@@ -1406,11 +1396,7 @@
              */
             break;
         default:
-#ifdef DEBUG_C14N
-            xmlGenericError(xmlGenericErrorContext,
-                            "xmlC14NProcessNode: unknown node type = %d\n",
-                            cur->type);
-#endif
+            xmlC14NErrUnknownNode(cur->type, "processing node");
             return (-1);
     }
 
@@ -1432,10 +1418,7 @@
     int ret;
 
     if (ctx == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NProcessNodeList: Null context pointer.\n");
-#endif
+        xmlC14NErrParam("processing node list");
         return (-1);
     }
 
@@ -1457,10 +1440,7 @@
 xmlC14NFreeCtx(xmlC14NCtxPtr ctx)
 {
     if (ctx == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NFreeCtx: ctx == NULL\n");
-#endif
+        xmlC14NErrParam("freeing context");
         return;
     }
 
@@ -1499,10 +1479,7 @@
     xmlC14NCtxPtr ctx = NULL;
 
     if ((doc == NULL) || (buf == NULL)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NNewCtx: pointer to document or output buffer is NULL\n");
-#endif
+        xmlC14NErrParam("creating new context");
         return (NULL);
     }
 
@@ -1597,10 +1574,7 @@
     int ret;
 
     if ((buf == NULL) || (doc == NULL)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NExecute: null return buffer or doc pointer\n");
-#endif
+        xmlC14NErrParam("executing c14n");
         return (-1);
     }
 
@@ -1635,10 +1609,7 @@
     if (doc->children != NULL) {
         ret = xmlC14NProcessNodeList(ctx, doc->children);
         if (ret < 0) {
-#ifdef DEBUG_C14N
-            xmlGenericError(xmlGenericErrorContext,
-                            "xmlC14NExecute: process childrens' list failed.\n");
-#endif
+            xmlC14NErrInternal("processing docs children list");
             xmlC14NFreeCtx(ctx);
             return (-1);
         }
@@ -1649,10 +1620,7 @@
      */
     ret = xmlOutputBufferFlush(buf);
     if (ret < 0) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NExecute: buffer flush failed.\n");
-#endif
+        xmlC14NErrInternal("flushing output buffer");
         xmlC14NFreeCtx(ctx);
         return (-1);
     }
@@ -1731,10 +1699,7 @@
     xmlOutputBufferPtr buf;
 
     if (doc_txt_ptr == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NDocDumpMemory:  null return buffer pointer\n");
-#endif
+        xmlC14NErrParam("dumping doc to memory");
         return (-1);
     }
 
@@ -1745,10 +1710,7 @@
      */
     buf = xmlAllocOutputBuffer(NULL);
     if (buf == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NDocDumpMemory: failed to allocate output buffer.\n");
-#endif
+        xmlC14NErrMemory("creating output buffer");
         return (-1);
     }
 
@@ -1758,10 +1720,7 @@
     ret = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes,
                            with_comments, buf);
     if (ret < 0) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NDocDumpMemory: xmlC14NDocSaveTo failed.\n");
-#endif
+        xmlC14NErrInternal("saving doc to output buffer");
         (void) xmlOutputBufferClose(buf);
         return (-1);
     }
@@ -1773,10 +1732,7 @@
     (void) xmlOutputBufferClose(buf);
 
     if ((*doc_txt_ptr == NULL) && (ret > 0)) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NDocDumpMemory: failed to allocate memory for document text 
representation\n");
-#endif
+        xmlC14NErrMemory("coping canonicanized document");
         return (-1);
     }
     return (ret);
@@ -1815,10 +1771,7 @@
     int ret;
 
     if (filename == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NDocSave:  filename is NULL\n");
-#endif
+        xmlC14NErrParam("saving doc");
         return (-1);
     }
 #ifdef HAVE_ZLIB_H
@@ -1831,11 +1784,7 @@
      */
     buf = xmlOutputBufferCreateFilename(filename, NULL, compression);
     if (buf == NULL) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NDocSave:  unable to create buffer for file=\"%s\" with compressin=%d\n",
-                        filename, compression);
-#endif
+        xmlC14NErrInternal("creating temporary filename");
         return (-1);
     }
 
@@ -1845,10 +1794,7 @@
     ret = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes,
                            with_comments, buf);
     if (ret < 0) {
-#ifdef DEBUG_C14N
-        xmlGenericError(xmlGenericErrorContext,
-                        "xmlC14NDocSave: xmlC14NDocSaveTo failed.\n");
-#endif
+        xmlC14NErrInternal("cannicanize document to buffer");
         (void) xmlOutputBufferClose(buf);
         return (-1);
     }
Index: include/libxml/xmlerror.h
===================================================================
RCS file: /cvs/gnome/gnome-xml/include/libxml/xmlerror.h,v
retrieving revision 1.69
diff -u -w -r1.69 xmlerror.h
--- include/libxml/xmlerror.h   15 Feb 2005 14:39:48 -0000      1.69
+++ include/libxml/xmlerror.h   20 Mar 2005 02:25:11 -0000
@@ -663,6 +663,8 @@
     XML_C14N_REQUIRES_UTF8, /* 1951 */
     XML_C14N_CREATE_STACK, /* 1952 */
     XML_C14N_INVALID_NODE, /* 1953 */
+    XML_C14N_UNKNOW_NODE, /* 1954 */
+    XML_C14N_RELATIVE_NAMESPACE, /* 1955 */
     XML_FTP_PASV_ANSWER = 2000,
     XML_FTP_EPSV_ANSWER, /* 2001 */
     XML_FTP_ACCNT, /* 2002 */


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