14#ifdef LIBXML_C14N_ENABLED
15#ifdef LIBXML_OUTPUT_ENABLED
37 XMLC14N_BEFORE_DOCUMENT_ELEMENT = 0,
38 XMLC14N_INSIDE_DOCUMENT_ELEMENT = 1,
39 XMLC14N_AFTER_DOCUMENT_ELEMENT = 2
42typedef struct _xmlC14NVisibleNsStack {
49} xmlC14NVisibleNsStack, *xmlC14NVisibleNsStackPtr;
51typedef struct _xmlC14NCtx {
54 xmlC14NIsVisibleCallback is_visible_callback;
62 xmlC14NVisibleNsStackPtr ns_rendered;
68 xmlChar **inclusive_ns_prefixes;
72} xmlC14NCtx, *xmlC14NCtxPtr;
74static xmlC14NVisibleNsStackPtr xmlC14NVisibleNsStackCreate (
void);
75static void xmlC14NVisibleNsStackDestroy (xmlC14NVisibleNsStackPtr
cur);
76static void xmlC14NVisibleNsStackAdd (xmlC14NVisibleNsStackPtr
cur,
79static void xmlC14NVisibleNsStackSave (xmlC14NVisibleNsStackPtr
cur,
80 xmlC14NVisibleNsStackPtr
state);
81static void xmlC14NVisibleNsStackRestore (xmlC14NVisibleNsStackPtr
cur,
82 xmlC14NVisibleNsStackPtr
state);
83static void xmlC14NVisibleNsStackShift (xmlC14NVisibleNsStackPtr
cur);
84static int xmlC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr
cur,
86static int xmlExcC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr
cur,
90static int xmlC14NIsNodeInNodeset (
void *user_data,
99 XMLC14N_NORMALIZE_ATTR = 0,
100 XMLC14N_NORMALIZE_COMMENT = 1,
101 XMLC14N_NORMALIZE_PI = 2,
102 XMLC14N_NORMALIZE_TEXT = 3
103} xmlC14NNormalizationMode;
106 xmlC14NNormalizationMode
mode);
108#define xmlC11NNormalizeAttr( a ) \
109 xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_ATTR)
110#define xmlC11NNormalizeComment( a ) \
111 xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_COMMENT)
112#define xmlC11NNormalizePI( a ) \
113 xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_PI)
114#define xmlC11NNormalizeText( a ) \
115 xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_TEXT)
117#define xmlC14NIsVisible( ctx, node, parent ) \
118 (((ctx)->is_visible_callback != NULL) ? \
119 (ctx)->is_visible_callback((ctx)->user_data, \
120 (xmlNodePtr)(node), (xmlNodePtr)(parent)) : 1)
122#define xmlC14NIsExclusive( ctx ) \
123 ( (ctx)->mode == XML_C14N_EXCLUSIVE_1_0 )
138xmlC14NErrMemory(
const char *
extra)
143 "Memory allocation failed : %s\n",
extra);
153xmlC14NErrParam(
const char *
extra)
158 "Invalid parameter : %s\n",
extra);
168xmlC14NErrInternal(
const char *
extra)
173 "Internal error : %s\n",
extra);
183xmlC14NErrInvalidNode(
const char *node_type,
const char *
extra)
188 "Node %s is invalid here : %s\n", node_type,
extra);
198xmlC14NErrUnknownNode(
int node_type,
const char *
extra)
203 "Unknown node type %d found : %s\n", node_type,
extra);
213xmlC14NErrRelativeNamespace(
const char *ns_uri)
218 "Relative namespace UR is invalid here : %s\n", ns_uri);
250#define XML_NAMESPACES_DEFAULT 16
254 xmlNodeSetPtr nodes = (xmlNodeSetPtr) user_data;
257 return(xmlXPathNodeSetContains(nodes,
node));
274 return(xmlXPathNodeSetContains(nodes, (
xmlNodePtr)&
ns));
280static xmlC14NVisibleNsStackPtr
281xmlC14NVisibleNsStackCreate(
void) {
282 xmlC14NVisibleNsStackPtr
ret;
284 ret = (xmlC14NVisibleNsStackPtr)
xmlMalloc(
sizeof(xmlC14NVisibleNsStack));
286 xmlC14NErrMemory(
"creating namespaces stack");
289 memset(
ret, 0 , (
size_t)
sizeof(xmlC14NVisibleNsStack));
294xmlC14NVisibleNsStackDestroy(xmlC14NVisibleNsStackPtr
cur) {
296 xmlC14NErrParam(
"destroying namespaces stack");
307 memset(
cur, 0,
sizeof(xmlC14NVisibleNsStack));
317 xmlC14NErrParam(
"adding namespace to stack");
325 xmlC14NErrMemory(
"adding node to stack");
330 cur->nsMax = XML_NAMESPACES_DEFAULT;
331 }
else if(
cur->nsMax ==
cur->nsCurEnd) {
335 tmpSize = 2 *
cur->nsMax;
338 xmlC14NErrMemory(
"adding node to stack");
345 xmlC14NErrMemory(
"adding node to stack");
350 cur->nsMax = tmpSize;
359xmlC14NVisibleNsStackSave(xmlC14NVisibleNsStackPtr
cur, xmlC14NVisibleNsStackPtr
state) {
361 xmlC14NErrParam(
"saving namespaces stack");
366 state->nsPrevStart =
cur->nsPrevStart;
371xmlC14NVisibleNsStackRestore(xmlC14NVisibleNsStackPtr
cur, xmlC14NVisibleNsStackPtr
state) {
373 xmlC14NErrParam(
"restoring namespaces stack");
377 cur->nsPrevStart =
state->nsPrevStart;
382xmlC14NVisibleNsStackShift(xmlC14NVisibleNsStackPtr
cur) {
384 xmlC14NErrParam(
"shifting namespaces stack");
387 cur->nsPrevStart =
cur->nsPrevEnd;
388 cur->nsPrevEnd =
cur->nsCurEnd;
393 if (str1 == str2)
return(1);
394 if (str1 ==
NULL)
return((*str2) ==
'\0');
395 if (str2 ==
NULL)
return((*str1) ==
'\0');
397 if (*str1++ != *str2)
return(0);
412xmlC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr
cur,
xmlNsPtr ns)
420 xmlC14NErrParam(
"searching namespaces stack (c14n)");
430 has_empty_ns = (xmlC14NStrEqual(prefix,
NULL) && xmlC14NStrEqual(href,
NULL));
433 int start = (has_empty_ns) ? 0 :
cur->nsPrevStart;
438 return(xmlC14NStrEqual(href, (ns1 !=
NULL) ? ns1->
href :
NULL));
442 return(has_empty_ns);
446xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr
cur,
xmlNsPtr ns, xmlC14NCtxPtr
ctx) {
453 xmlC14NErrParam(
"searching namespaces stack (exc c14n)");
463 has_empty_ns = (xmlC14NStrEqual(prefix,
NULL) && xmlC14NStrEqual(href,
NULL));
471 if(xmlC14NStrEqual(href, (ns1 !=
NULL) ? ns1->
href :
NULL)) {
472 return(xmlC14NIsVisible(
ctx, ns1,
cur->nodeTab[
i]));
479 return(has_empty_ns);
515xmlC14NNsCompare(
const void *
data1,
const void *
data2)
544 xmlC14NErrParam(
"writing namespaces");
549 xmlOutputBufferWriteString(
ctx->buf,
" xmlns:");
550 xmlOutputBufferWriteString(
ctx->buf, (
const char *)
ns->
prefix);
551 xmlOutputBufferWriteString(
ctx->buf,
"=");
553 xmlOutputBufferWriteString(
ctx->buf,
" xmlns=");
558 xmlOutputBufferWriteString(
ctx->buf,
"\"\"");
564xmlC14NPrintNamespacesWalker(
const void *
ns,
void *
ctx) {
565 return xmlC14NPrintNamespaces((
const xmlNsPtr)
ns, (xmlC14NCtxPtr)
ctx);
613 int already_rendered;
614 int has_empty_ns = 0;
617 xmlC14NErrParam(
"processing namespaces axis (c14n)");
626 xmlC14NErrInternal(
"creating namespaces list (c14n)");
635 if((tmp ==
ns) && !xmlC14NIsXmlNs(
ns) && xmlC14NIsVisible(
ctx,
ns,
cur)) {
636 already_rendered = xmlC14NVisibleNsStackFind(
ctx->ns_rendered,
ns);
638 xmlC14NVisibleNsStackAdd(
ctx->ns_rendered,
ns,
cur);
640 if(!already_rendered) {
659 if(visible && !has_empty_ns) {
660 static xmlNs ns_default;
662 memset(&ns_default, 0,
sizeof(ns_default));
663 if(!xmlC14NVisibleNsStackFind(
ctx->ns_rendered, &ns_default)) {
664 xmlC14NPrintNamespaces(&ns_default,
ctx);
713xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr
ctx,
xmlNodePtr cur,
int visible)
718 int already_rendered;
719 int has_empty_ns = 0;
720 int has_visibly_utilized_empty_ns = 0;
721 int has_empty_ns_in_inclusive_list = 0;
724 xmlC14NErrParam(
"processing namespaces axis (exc c14n)");
728 if(!xmlC14NIsExclusive(
ctx)) {
729 xmlC14NErrParam(
"processing namespaces axis (exc c14n)");
739 xmlC14NErrInternal(
"creating namespaces list (exc c14n)");
748 if(
ctx->inclusive_ns_prefixes !=
NULL) {
752 for (
i = 0;
ctx->inclusive_ns_prefixes[
i] !=
NULL; ++
i) {
753 prefix =
ctx->inclusive_ns_prefixes[
i];
760 has_empty_ns_in_inclusive_list = 1;
765 already_rendered = xmlC14NVisibleNsStackFind(
ctx->ns_rendered,
ns);
767 xmlC14NVisibleNsStackAdd(
ctx->ns_rendered,
ns,
cur);
769 if(!already_rendered) {
784 has_visibly_utilized_empty_ns = 1;
786 if((
ns !=
NULL) && !xmlC14NIsXmlNs(
ns)) {
787 if(visible && xmlC14NIsVisible(
ctx,
ns,
cur)) {
788 if(!xmlExcC14NVisibleNsStackFind(
ctx->ns_rendered,
ns,
ctx)) {
793 xmlC14NVisibleNsStackAdd(
ctx->ns_rendered,
ns,
cur);
809 already_rendered = xmlExcC14NVisibleNsStackFind(
ctx->ns_rendered,
attr->ns,
ctx);
810 xmlC14NVisibleNsStackAdd(
ctx->ns_rendered,
attr->ns,
cur);
811 if(!already_rendered && visible) {
818 has_visibly_utilized_empty_ns = 1;
825 if(visible && has_visibly_utilized_empty_ns &&
826 !has_empty_ns && !has_empty_ns_in_inclusive_list) {
827 static xmlNs ns_default;
829 memset(&ns_default, 0,
sizeof(ns_default));
831 already_rendered = xmlExcC14NVisibleNsStackFind(
ctx->ns_rendered, &ns_default,
ctx);
832 if(!already_rendered) {
833 xmlC14NPrintNamespaces(&ns_default,
ctx);
835 }
else if(visible && !has_empty_ns && has_empty_ns_in_inclusive_list) {
836 static xmlNs ns_default;
838 memset(&ns_default, 0,
sizeof(ns_default));
839 if(!xmlC14NVisibleNsStackFind(
ctx->ns_rendered, &ns_default)) {
840 xmlC14NPrintNamespaces(&ns_default,
ctx);
874 (xmlC14NIsXmlNs(
attr->ns) != 0));
888xmlC14NAttrsCompare(
const void *
data1,
const void *
data2)
903 if (attr1->
ns == attr2->
ns) {
942xmlC14NPrintAttrs(
const void *
data,
void *
user)
945 xmlC14NCtxPtr
ctx = (xmlC14NCtxPtr)
user;
950 xmlC14NErrParam(
"writing attributes");
954 xmlOutputBufferWriteString(
ctx->buf,
" ");
956 xmlOutputBufferWriteString(
ctx->buf,
957 (
const char *)
attr->ns->prefix);
958 xmlOutputBufferWriteString(
ctx->buf,
":");
960 xmlOutputBufferWriteString(
ctx->buf, (
const char *)
attr->
name);
961 xmlOutputBufferWriteString(
ctx->buf,
"=\"");
969 xmlOutputBufferWriteString(
ctx->buf, (
const char *)
buffer);
972 xmlC14NErrInternal(
"normalizing attributes axis");
976 xmlOutputBufferWriteString(
ctx->buf,
"\"");
1011xmlC14NFixupBaseAttr(xmlC14NCtxPtr
ctx,
xmlAttrPtr xml_base_attr)
1021 xmlC14NErrParam(
"processing xml:base attribute");
1028 xmlC14NErrInternal(
"processing xml:base attribute - can't get attr value");
1039 if(tmp_str ==
NULL) {
1042 xmlC14NErrInternal(
"processing xml:base attribute - can't get attr value");
1049 if(tmp_str_len > 1 && tmp_str[tmp_str_len - 2] ==
'.') {
1051 if(tmp_str2 ==
NULL) {
1055 xmlC14NErrInternal(
"processing xml:base attribute - can't modify uri");
1064 if(tmp_str2 ==
NULL) {
1068 xmlC14NErrInternal(
"processing xml:base attribute - can't construct uri");
1093 xmlC14NErrInternal(
"processing xml:base attribute - can't construct attribute");
1136xmlC14NProcessAttrsAxis(xmlC14NCtxPtr
ctx,
xmlNodePtr cur,
int parent_visible)
1148 xmlC14NErrParam(
"processing attributes axis");
1157 xmlC14NErrInternal(
"creating attributes list");
1189 if (parent_visible && (
cur->parent !=
NULL) &&
1190 (!xmlC14NIsVisible(
ctx,
cur->parent,
cur->parent->parent)))
1199 while (tmp !=
NULL) {
1202 if (xmlC14NIsXmlAttr(
attr) != 0) {
1215 case XML_C14N_EXCLUSIVE_1_0:
1269 if ((!parent_visible) || (xmlC14NIsXmlAttr(
attr) == 0)) {
1279 xml_lang_attr =
attr;
1283 xml_space_attr =
attr;
1289 xml_base_attr =
attr;
1294 if((!matched) && xmlC14NIsVisible(
ctx,
attr,
cur)) {
1304 if ((parent_visible)) {
1307 if(xml_lang_attr ==
NULL) {
1310 if(xml_lang_attr !=
NULL) {
1313 if(xml_space_attr ==
NULL) {
1316 if(xml_space_attr !=
NULL) {
1321 if(xml_base_attr ==
NULL) {
1325 if(xml_base_attr !=
NULL) {
1326 xml_base_attr = xmlC14NFixupBaseAttr(
ctx, xml_base_attr);
1327 if(xml_base_attr !=
NULL) {
1331 xml_base_attr->
next = attrs_to_delete;
1332 attrs_to_delete = xml_base_attr;
1369 xmlC14NErrParam(
"checking for relative namespaces");
1380 xmlC14NErrInternal(
"parsing namespace uri");
1384 xmlC14NErrRelativeNamespace(
uri->scheme);
1422 xmlC14NVisibleNsStack
state;
1423 int parent_is_doc = 0;
1426 xmlC14NErrParam(
"processing element node");
1435 if (xmlC14NCheckForRelativeNamespaces(
ctx,
cur) < 0) {
1436 xmlC14NErrInternal(
"checking for relative namespaces");
1445 xmlC14NVisibleNsStackSave(
ctx->ns_rendered, &
state);
1448 if (
ctx->parent_is_doc) {
1450 parent_is_doc =
ctx->parent_is_doc;
1451 ctx->parent_is_doc = 0;
1452 ctx->pos = XMLC14N_INSIDE_DOCUMENT_ELEMENT;
1454 xmlOutputBufferWriteString(
ctx->buf,
"<");
1457 xmlOutputBufferWriteString(
ctx->buf,
1458 (
const char *)
cur->ns->prefix);
1459 xmlOutputBufferWriteString(
ctx->buf,
":");
1461 xmlOutputBufferWriteString(
ctx->buf, (
const char *)
cur->name);
1464 if (!xmlC14NIsExclusive(
ctx)) {
1465 ret = xmlC14NProcessNamespacesAxis(
ctx,
cur, visible);
1467 ret = xmlExcC14NProcessNamespacesAxis(
ctx,
cur, visible);
1470 xmlC14NErrInternal(
"processing namespaces axis");
1475 xmlC14NVisibleNsStackShift(
ctx->ns_rendered);
1478 ret = xmlC14NProcessAttrsAxis(
ctx,
cur, visible);
1480 xmlC14NErrInternal(
"processing attributes axis");
1485 xmlOutputBufferWriteString(
ctx->buf,
">");
1488 ret = xmlC14NProcessNodeList(
ctx,
cur->children);
1490 xmlC14NErrInternal(
"processing childrens list");
1495 xmlOutputBufferWriteString(
ctx->buf,
"</");
1497 xmlOutputBufferWriteString(
ctx->buf,
1498 (
const char *)
cur->ns->prefix);
1499 xmlOutputBufferWriteString(
ctx->buf,
":");
1501 xmlOutputBufferWriteString(
ctx->buf, (
const char *)
cur->name);
1502 xmlOutputBufferWriteString(
ctx->buf,
">");
1503 if (parent_is_doc) {
1505 ctx->parent_is_doc = parent_is_doc;
1506 ctx->pos = XMLC14N_AFTER_DOCUMENT_ELEMENT;
1513 xmlC14NVisibleNsStackRestore(
ctx->ns_rendered, &
state);
1533 xmlC14NErrParam(
"processing node");
1537 visible = xmlC14NIsVisible(
ctx,
cur,
cur->parent);
1538 switch (
cur->type) {
1540 ret = xmlC14NProcessElementNode(
ctx,
cur, visible);
1553 if ((visible) && (
cur->content !=
NULL)) {
1556 buffer = xmlC11NNormalizeText(
cur->content);
1558 xmlOutputBufferWriteString(
ctx->buf,
1562 xmlC14NErrInternal(
"normalizing text node");
1581 if (
ctx->pos == XMLC14N_AFTER_DOCUMENT_ELEMENT) {
1582 xmlOutputBufferWriteString(
ctx->buf,
"\x0A<?");
1584 xmlOutputBufferWriteString(
ctx->buf,
"<?");
1587 xmlOutputBufferWriteString(
ctx->buf,
1588 (
const char *)
cur->name);
1589 if ((
cur->content !=
NULL) && (*(
cur->content) !=
'\0')) {
1592 xmlOutputBufferWriteString(
ctx->buf,
" ");
1595 buffer = xmlC11NNormalizePI(
cur->content);
1597 xmlOutputBufferWriteString(
ctx->buf,
1601 xmlC14NErrInternal(
"normalizing pi node");
1606 if (
ctx->pos == XMLC14N_BEFORE_DOCUMENT_ELEMENT) {
1607 xmlOutputBufferWriteString(
ctx->buf,
"?>\x0A");
1609 xmlOutputBufferWriteString(
ctx->buf,
"?>");
1629 if (visible &&
ctx->with_comments) {
1630 if (
ctx->pos == XMLC14N_AFTER_DOCUMENT_ELEMENT) {
1631 xmlOutputBufferWriteString(
ctx->buf,
"\x0A<!--");
1633 xmlOutputBufferWriteString(
ctx->buf,
"<!--");
1640 buffer = xmlC11NNormalizeComment(
cur->content);
1642 xmlOutputBufferWriteString(
ctx->buf,
1646 xmlC14NErrInternal(
"normalizing comment node");
1651 if (
ctx->pos == XMLC14N_BEFORE_DOCUMENT_ELEMENT) {
1652 xmlOutputBufferWriteString(
ctx->buf,
"-->\x0A");
1654 xmlOutputBufferWriteString(
ctx->buf,
"-->");
1660#ifdef LIBXML_HTML_ENABLED
1664 ctx->pos = XMLC14N_BEFORE_DOCUMENT_ELEMENT;
1665 ctx->parent_is_doc = 1;
1666 ret = xmlC14NProcessNodeList(
ctx,
cur->children);
1671 xmlC14NErrInvalidNode(
"XML_ATTRIBUTE_NODE",
"processing node");
1674 xmlC14NErrInvalidNode(
"XML_NAMESPACE_DECL",
"processing node");
1677 xmlC14NErrInvalidNode(
"XML_ENTITY_REF_NODE",
"processing node");
1680 xmlC14NErrInvalidNode(
"XML_ENTITY_NODE",
"processing node");
1689#ifdef LIBXML_XINCLUDE_ENABLED
1698 xmlC14NErrUnknownNode(
cur->type,
"processing node");
1720 xmlC14NErrParam(
"processing node list");
1739xmlC14NFreeCtx(xmlC14NCtxPtr
ctx)
1742 xmlC14NErrParam(
"freeing context");
1746 if (
ctx->ns_rendered !=
NULL) {
1747 xmlC14NVisibleNsStackDestroy(
ctx->ns_rendered);
1775 xmlC14NIsVisibleCallback is_visible_callback,
void* user_data,
1776 xmlC14NMode
mode,
xmlChar ** inclusive_ns_prefixes,
1782 xmlC14NErrParam(
"creating new context");
1791"xmlC14NNewCtx: output buffer encoder != NULL but C14N requires UTF8 output\n");
1800 xmlC14NErrMemory(
"creating context");
1809 ctx->with_comments = with_comments;
1810 ctx->is_visible_callback = is_visible_callback;
1811 ctx->user_data = user_data;
1813 ctx->parent_is_doc = 1;
1814 ctx->pos = XMLC14N_BEFORE_DOCUMENT_ELEMENT;
1815 ctx->ns_rendered = xmlC14NVisibleNsStackCreate();
1817 if(
ctx->ns_rendered ==
NULL) {
1819 "xmlC14NNewCtx: xmlC14NVisibleNsStackCreate failed\n");
1820 xmlC14NFreeCtx(
ctx);
1829 if(xmlC14NIsExclusive(
ctx)) {
1830 ctx->inclusive_ns_prefixes = inclusive_ns_prefixes;
1859xmlC14NExecute(
xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
1860 void* user_data,
int mode,
xmlChar **inclusive_ns_prefixes,
1864 xmlC14NMode c14n_mode = XML_C14N_1_0;
1868 xmlC14NErrParam(
"executing c14n");
1876 case XML_C14N_EXCLUSIVE_1_0:
1878 c14n_mode = (xmlC14NMode)
mode;
1881 xmlC14NErrParam(
"invalid mode for executing c14n");
1890"xmlC14NExecute: output buffer encoder != NULL but C14N requires UTF8 output\n");
1894 ctx = xmlC14NNewCtx(doc, is_visible_callback, user_data,
1895 c14n_mode, inclusive_ns_prefixes,
1896 with_comments,
buf);
1899 "xmlC14NExecute: unable to create C14N context\n");
1916 xmlC14NErrInternal(
"processing docs children list");
1917 xmlC14NFreeCtx(
ctx);
1925 ret = xmlOutputBufferFlush(
buf);
1927 xmlC14NErrInternal(
"flushing output buffer");
1928 xmlC14NFreeCtx(
ctx);
1935 xmlC14NFreeCtx(
ctx);
1961xmlC14NDocSaveTo(
xmlDocPtr doc, xmlNodeSetPtr nodes,
1964 return(xmlC14NExecute(doc,
1965 xmlC14NIsNodeInNodeset,
1968 inclusive_ns_prefixes,
1996xmlC14NDocDumpMemory(
xmlDocPtr doc, xmlNodeSetPtr nodes,
1998 int with_comments,
xmlChar ** doc_txt_ptr)
2003 if (doc_txt_ptr ==
NULL) {
2004 xmlC14NErrParam(
"dumping doc to memory");
2008 *doc_txt_ptr =
NULL;
2013 buf = xmlAllocOutputBuffer(
NULL);
2015 xmlC14NErrMemory(
"creating output buffer");
2022 ret = xmlC14NDocSaveTo(doc, nodes,
mode, inclusive_ns_prefixes,
2023 with_comments,
buf);
2025 xmlC14NErrInternal(
"saving doc to output buffer");
2026 (
void) xmlOutputBufferClose(
buf);
2034 (
void) xmlOutputBufferClose(
buf);
2036 if ((*doc_txt_ptr ==
NULL) && (
ret >= 0)) {
2037 xmlC14NErrMemory(
"copying canonicalized document");
2067xmlC14NDocSave(
xmlDocPtr doc, xmlNodeSetPtr nodes,
2075 xmlC14NErrParam(
"saving doc");
2078#ifdef LIBXML_ZLIB_ENABLED
2088 xmlC14NErrInternal(
"creating temporary filename");
2095 ret = xmlC14NDocSaveTo(doc, nodes,
mode, inclusive_ns_prefixes,
2096 with_comments,
buf);
2098 xmlC14NErrInternal(
"canonize document to buffer");
2099 (
void) xmlOutputBufferClose(
buf);
2106 ret = xmlOutputBufferClose(
buf);
2115#define growBufferReentrant() { \
2117 buffer = (xmlChar *) \
2118 xmlRealloc(buffer, buffer_size * sizeof(xmlChar)); \
2119 if (buffer == NULL) { \
2120 xmlC14NErrMemory("growing buffer"); \
2139 xmlC14NNormalizationMode
mode)
2155 xmlC14NErrMemory(
"allocating buffer");
2160 while (*
cur !=
'\0') {
2168 if ((*
cur ==
'<') && ((
mode == XMLC14N_NORMALIZE_ATTR) ||
2169 (
mode == XMLC14N_NORMALIZE_TEXT))) {
2174 }
else if ((*
cur ==
'>') && (
mode == XMLC14N_NORMALIZE_TEXT)) {
2179 }
else if ((*
cur ==
'&') && ((
mode == XMLC14N_NORMALIZE_ATTR) ||
2180 (
mode == XMLC14N_NORMALIZE_TEXT))) {
2186 }
else if ((*
cur ==
'"') && (
mode == XMLC14N_NORMALIZE_ATTR)) {
2193 }
else if ((*
cur ==
'\x09') && (
mode == XMLC14N_NORMALIZE_ATTR)) {
2199 }
else if ((*
cur ==
'\x0A') && (
mode == XMLC14N_NORMALIZE_ATTR)) {
2205 }
else if ((*
cur ==
'\x0D') && ((
mode == XMLC14N_NORMALIZE_ATTR) ||
2206 (
mode == XMLC14N_NORMALIZE_TEXT) ||
2207 (
mode == XMLC14N_NORMALIZE_COMMENT) ||
2208 (
mode == XMLC14N_NORMALIZE_PI))) {
void user(int argc, const char *argv[])
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string)
#define growBufferReentrant()
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
XMLPUBVAR xmlMallocFunc xmlMalloc
XMLPUBVAR xmlFreeFunc xmlFree
XMLPUBVAR xmlReallocFunc xmlRealloc
XMLPUBFUN void XMLCALL xmlListWalk(xmlListPtr l, xmlListWalker walker, void *user)
XMLPUBFUN void *XMLCALL xmlListSearch(xmlListPtr l, void *data)
XMLPUBFUN int XMLCALL xmlListInsert(xmlListPtr l, void *data)
XMLPUBFUN void XMLCALL xmlListDelete(xmlListPtr l)
XMLPUBFUN xmlListPtr XMLCALL xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
xmlOutputBuffer * xmlOutputBufferPtr
XMLPUBFUN size_t XMLCALL xmlBufUse(const xmlBufPtr buf)
XMLPUBFUN int XMLCALL xmlGetCompressMode(void)
#define XML_XML_NAMESPACE
XMLPUBFUN void XMLCALL xmlFreePropList(xmlAttrPtr cur)
XMLPUBFUN xmlAttrPtr XMLCALL xmlHasNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
XMLPUBFUN xmlAttrPtr XMLCALL xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value)
XMLPUBFUN xmlChar *XMLCALL xmlBufContent(const xmlBuf *buf)
XMLPUBFUN xmlChar *XMLCALL xmlNodeListGetString(xmlDocPtr doc, const xmlNode *list, int inLine)
struct _xmlNode * children
struct _xmlNode * children
struct _xmlAttr * properties
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
@ XML_C14N_RELATIVE_NAMESPACE
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
XMLPUBFUN xmlChar *XMLCALL xmlStrcat(xmlChar *cur, const xmlChar *add)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
XMLPUBFUN int XMLCALL xmlStrcmp(const xmlChar *str1, const xmlChar *str2)
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)