From b96c1df391be5375939bad2c8aedeafcf82ee12c Mon Sep 17 00:00:00 2001 From: edwin Date: Sat, 5 Jul 2008 00:31:20 +0000 Subject: [PATCH] textproc/wbxml2: update to latest from official SVN Add missing dependency on textproc/libxml2. Fix package version in libwbxml2.pc. Update to latest from official SVN to fix build python bindings from SynCE Project. PR: ports/124602 Submitted by: Alexander Logvinov Approved by: maintainer timeout --- textproc/wbxml2/Makefile | 4 +- textproc/wbxml2/files/patch-configure.in | 16 ++ textproc/wbxml2/files/patch-libwbxml2.pc.in | 8 + textproc/wbxml2/files/patch-src_wbxml.h | 9 + textproc/wbxml2/files/patch-src_wbxml_encoder.c | 277 ++++++++++++++++++++++ textproc/wbxml2/files/patch-src_wbxml_encoder.h | 10 + textproc/wbxml2/files/patch-src_wbxml_parser.c | 300 ++++++++++++++++++++++++ textproc/wbxml2/files/patch-src_wbxml_tables.h | 13 + textproc/wbxml2/files/patch-src_wbxml_tree.c | 253 ++++++++++++++++++++ textproc/wbxml2/files/patch-src_wbxml_tree.h | 10 + 10 files changed, 898 insertions(+), 2 deletions(-) create mode 100644 textproc/wbxml2/files/patch-configure.in create mode 100644 textproc/wbxml2/files/patch-libwbxml2.pc.in create mode 100644 textproc/wbxml2/files/patch-src_wbxml.h create mode 100644 textproc/wbxml2/files/patch-src_wbxml_encoder.c create mode 100644 textproc/wbxml2/files/patch-src_wbxml_encoder.h create mode 100644 textproc/wbxml2/files/patch-src_wbxml_parser.c create mode 100644 textproc/wbxml2/files/patch-src_wbxml_tables.h create mode 100644 textproc/wbxml2/files/patch-src_wbxml_tree.c create mode 100644 textproc/wbxml2/files/patch-src_wbxml_tree.h diff --git a/textproc/wbxml2/Makefile b/textproc/wbxml2/Makefile index d15c1adf03e2..d5a10409196c 100644 --- a/textproc/wbxml2/Makefile +++ b/textproc/wbxml2/Makefile @@ -7,7 +7,7 @@ PORTNAME= wbxml2 PORTVERSION= 0.9.2 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= textproc devel MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} \ http://czauner.onlineloop.com/pub/FreeBSD/distfiles/ @@ -22,7 +22,7 @@ LIB_DEPENDS= expat.6:${PORTSDIR}/textproc/expat2 USE_AUTOTOOLS= aclocal:19 autoconf:261 autoheader:261 automake:19 libtool:15 AUTOMAKE_ARGS= -acf USE_LDCONFIG= yes -USE_GNOME= pkgconfig +USE_GNOME= pkgconfig libxml2 CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \ LDFLAGS="-L${LOCALBASE}/lib" diff --git a/textproc/wbxml2/files/patch-configure.in b/textproc/wbxml2/files/patch-configure.in new file mode 100644 index 000000000000..38fe3191981b --- /dev/null +++ b/textproc/wbxml2/files/patch-configure.in @@ -0,0 +1,16 @@ +--- configure.in.orig 2008-06-15 05:56:12.000000000 +1000 ++++ configure.in 2008-06-15 05:56:24.000000000 +1000 +@@ -1,11 +1,11 @@ + dnl Process this file with autoconf to produce a configure script. + AC_INIT(doxygen.h) +-AM_INIT_AUTOMAKE(wbxml2, 0.9.0) ++AM_INIT_AUTOMAKE(wbxml2, 0.9.2) + AM_CONFIG_HEADER(config.h) + + + dnl Define common variables +-VERSION="0.9.0" ++VERSION="0.9.2" + AC_SUBST(VERSION) + RELEASE="1" + AC_SUBST(RELEASE) diff --git a/textproc/wbxml2/files/patch-libwbxml2.pc.in b/textproc/wbxml2/files/patch-libwbxml2.pc.in new file mode 100644 index 000000000000..9d6654fe783f --- /dev/null +++ b/textproc/wbxml2/files/patch-libwbxml2.pc.in @@ -0,0 +1,8 @@ +--- libwbxml2.pc.in.orig 2006-07-11 21:47:44.000000000 +1000 ++++ libwbxml2.pc.in 2008-06-15 06:58:26.000000000 +1000 +@@ -8,4 +8,4 @@ + Version: @VERSION@ + Requires: libxml-2.0 >= 2.6 + Libs: -L${libdir} -lwbxml2 +-Cflags: -I${includedir} ++Cflags: -I${includedir} -DHAVE_EXPAT -D_REENTRANT -DWBXML_ENCODER_USE_STRTBL -DWBXML_SUPPORT_WML -DWBXML_SUPPORT_WTA -DWBXML_SUPPORT_SI -DWBXML_SUPPORT_SL -DWBXML_SUPPORT_CO -DWBXML_SUPPORT_PROV -DWBXML_SUPPORT_EMN -DWBXML_SUPPORT_DRMREL -DWBXML_SUPPORT_OTA_SETTINGS -DWBXML_SUPPORT_SYNCML -DWBXML_SUPPORT_WV -DWBXML_SUPPORT_AIRSYNC diff --git a/textproc/wbxml2/files/patch-src_wbxml.h b/textproc/wbxml2/files/patch-src_wbxml.h new file mode 100644 index 000000000000..235e8f292294 --- /dev/null +++ b/textproc/wbxml2/files/patch-src_wbxml.h @@ -0,0 +1,9 @@ +--- src/wbxml.h.orig 2006-07-11 21:47:44.000000000 +1000 ++++ src/wbxml.h 2008-06-15 06:58:54.000000000 +1000 +@@ -285,6 +285,7 @@ + WBXMLVersion wbxml_version; /**< WBXML Version */ + WB_BOOL keep_ignorable_ws; /**< Keep Ignorable Whitespaces (Default: FALSE) */ + WB_BOOL use_strtbl; /**< Generate String Table (Default: TRUE) */ ++ WB_BOOL produce_anonymous; /**< Produce an anonymous document (Default: FALSE) */ + } WBXMLGenWBXMLParams; + diff --git a/textproc/wbxml2/files/patch-src_wbxml_encoder.c b/textproc/wbxml2/files/patch-src_wbxml_encoder.c new file mode 100644 index 000000000000..60294f2e09fa --- /dev/null +++ b/textproc/wbxml2/files/patch-src_wbxml_encoder.c @@ -0,0 +1,277 @@ +--- src/wbxml_encoder.c.orig 2006-07-11 21:47:45.000000000 +1000 ++++ src/wbxml_encoder.c 2008-06-15 08:45:31.000000000 +1000 +@@ -136,6 +136,7 @@ + const WBXMLTagEntry *current_tag; /**< Current Tag (See The Warning For This Field !) */ + const WBXMLTreeNode *current_text_parent; /**< Text parent of current Node (See The Warning For This Field !) */ + const WBXMLAttrEntry *current_attr; /**< Current Attribute */ ++ WBXMLTreeNode *current_node; + WB_UTINY tagCodePage; /**< Current Tag Code Page */ + WB_UTINY attrCodePage; /**< Current Attribute Code Page */ + WB_BOOL ignore_empty_text; /**< Do we ignore empty text nodes (ie: ignorable whitespaces)? */ +@@ -153,6 +154,7 @@ + WB_BOOL use_strtbl; /**< Do we use String Table when generating WBXML output ? (default: YES) */ + #endif /* WBXML_ENCODER_USE_STRTBL */ + WB_BOOL xml_encode_header; /**< Do we generate XML Header ? */ ++ WB_BOOL produce_anonymous; + WBXMLVersion wbxml_version; /**< WBXML Version to use (when generating WBXML output) */ + WBXMLCharsetMIBEnum output_charset; /**< Output charset encoding */ + WB_BOOL flow_mode; /**< Is Flow Mode encoding activated ? */ +@@ -269,6 +271,7 @@ + static WBXMLError wbxml_encode_entity(WBXMLEncoder *encoder, WB_ULONG value); + #endif /* 0 */ + static WBXMLError wbxml_encode_opaque(WBXMLEncoder *encoder, WBXMLBuffer *buff); ++static WBXMLError wbxml_encode_opaque_data(WBXMLEncoder *encoder, WB_UTINY *data, WB_ULONG data_len); + #if defined( WBXML_ENCODER_USE_STRTBL ) + static WBXMLError wbxml_encode_tableref(WBXMLEncoder *encoder, WB_ULONG offset); + #endif /* WBXML_ENCODER_USE_STRTBL */ +@@ -292,7 +295,9 @@ + #if defined( WBXML_SUPPORT_DRMREL ) + static WBXMLError wbxml_encode_drmrel_content(WBXMLEncoder *encoder, WB_UTINY *buffer); + #endif /* WBXML_SUPPORT_DRMREL */ +- ++#if defined( WBXML_SUPPORT_OTA_SETTINGS ) ++static WBXMLError wbxml_encode_ota_nokia_icon(WBXMLEncoder *encoder, WB_UTINY *buffer); ++#endif + #if defined( WBXML_ENCODER_USE_STRTBL ) + /* WBXML String Table Functions */ + static WBXMLStringTableElement *wbxml_strtbl_element_create(WBXMLBuffer *string, WB_BOOL is_stat); +@@ -383,6 +388,7 @@ + encoder->current_tag = NULL; + encoder->current_text_parent = NULL; + encoder->current_attr = NULL; ++ encoder->current_node = NULL; + + encoder->tagCodePage = 0; + encoder->attrCodePage = 0; +@@ -400,6 +406,7 @@ + encoder->cdata = NULL; + + encoder->xml_encode_header = TRUE; ++ encoder->produce_anonymous = FALSE; + + /* Default Version: WBXML 1.3 */ + encoder->wbxml_version = WBXML_VERSION_13; +@@ -450,6 +457,7 @@ + + encoder->current_tag = NULL; + encoder->current_attr = NULL; ++ encoder->current_node = NULL; + + encoder->tagCodePage = 0; + encoder->attrCodePage = 0; +@@ -507,7 +515,13 @@ + encoder->use_strtbl = use_strtbl; + #endif /* WBXML_ENCODER_USE_STRTBL */ + } +- ++WBXML_DECLARE(void) wbxml_encoder_set_produce_anonymous(WBXMLEncoder *encoder, WB_BOOL set_anonymous) ++{ ++ if (encoder == NULL) ++ return; ++ ++ encoder->produce_anonymous = set_anonymous; ++} + + WBXML_DECLARE(void) wbxml_encoder_set_wbxml_version(WBXMLEncoder *encoder, WBXMLVersion version) + { +@@ -637,6 +651,9 @@ + + WBXML_DECLARE(WBXMLError) wbxml_encoder_encode_node(WBXMLEncoder *encoder, WBXMLTreeNode *node) + { ++ if (encoder->flow_mode == FALSE) { ++ WBXML_WARNING((WBXML_ENCODER, "You should NOT call wbxml_encoder_encode_node() if you are not in Flow Mode encoding ! (use wbxml_encoder_set_flow_mode(encoder, TRUE))")); ++ } + return wbxml_encoder_encode_node_with_elt_end(encoder, node, TRUE); + } + +@@ -649,10 +666,6 @@ + if ((encoder == NULL) || (node == NULL)) + return WBXML_ERROR_BAD_PARAMETER; + +- if (encoder->flow_mode == FALSE) { +- WBXML_WARNING((WBXML_ENCODER, "You should NOT call wbxml_encoder_encode_node() if you are not in Flow Mode encoding ! (use wbxml_encoder_set_flow_mode(encoder, TRUE))")); +- } +- + /* Check that language table has been set */ + if (encoder->lang == NULL) + return WBXML_ERROR_BAD_PARAMETER; +@@ -965,6 +978,7 @@ + static WBXMLError parse_node(WBXMLEncoder *encoder, WBXMLTreeNode *node, WB_BOOL enc_end) + { + WBXMLError ret = WBXML_OK; ++ encoder->current_node = node; + + /* Parse this node */ + switch (node->type) { +@@ -1078,6 +1092,7 @@ + + /* Reset Current Tag */ + encoder->current_tag = NULL; ++ encoder->current_node = NULL; + + /* Parse next node */ + if (node->next != NULL) +@@ -1464,7 +1479,7 @@ + + /* Encode Public ID */ + /* If WBXML Public Id is '0x01' (unknown), or we forced it, add the XML Public ID in the String Table */ +- if (encoder->textual_publicid || (public_id == WBXML_PUBLIC_ID_UNKNOWN)) ++ if ((encoder->textual_publicid || (public_id == WBXML_PUBLIC_ID_UNKNOWN)) && !encoder->produce_anonymous) + { + if (encoder->lang->publicID->xmlPublicID != NULL) + { +@@ -1500,7 +1515,7 @@ + else { + #endif /* WBXML_ENCODER_USE_STRTBL */ + /* Length of String Table is length of XML Public ID */ +- strstbl_len = wbxml_buffer_len(pid); ++ strstbl_len = wbxml_buffer_len(pid) + 1; + + /* There is only the XML Public ID in String Table */ + public_id_index = 0; +@@ -1548,7 +1563,8 @@ + /* The append includes terminating NULL char */ + if (!wbxml_buffer_append(header, pid)) + return WBXML_ERROR_ENCODER_APPEND_DATA; +- ++ if (!wbxml_buffer_append_char(header, WBXML_STR_END)) ++ return WBXML_ERROR_ENCODER_APPEND_DATA; + /* Clean up */ + wbxml_buffer_destroy(pid); + } +@@ -1870,7 +1886,7 @@ + * Encoder Language Specific Attribute Values + */ + +- if (ctx == WBXML_VALUE_ELEMENT_CTX_ATTR) { ++ if ((ctx == WBXML_VALUE_ELEMENT_CTX_ATTR) && (encoder->current_attr != NULL)) { + switch (encoder->lang->langID) { + #if defined( WBXML_SUPPORT_SI ) + case WBXML_LANG_SI10: +@@ -1892,7 +1908,16 @@ + } + break; + #endif /* WBXML_SUPPORT_EMN */ +- ++#if defined( WBXML_SUPPORT_OTA_SETTINGS ) ++ case WBXML_LANG_OTA_SETTINGS: ++ if ((encoder->current_attr->wbxmlCodePage == 0x00) && ++ (encoder->current_attr->wbxmlToken == 0x11)) ++ { ++ if ((ret = wbxml_encode_ota_nokia_icon(encoder, buffer)) != WBXML_NOT_ENCODED) ++ return ret; ++ } ++ break; ++#endif /* WBXML_SUPPORT_OTA_SETTINGS */ + default: + break; + } +@@ -1936,7 +1961,8 @@ + #if defined( WBXML_SUPPORT_SYNCML ) + /* If this is a SyncML document ? */ + if ((encoder->lang->langID == WBXML_LANG_SYNCML_SYNCML10) || +- (encoder->lang->langID == WBXML_LANG_SYNCML_SYNCML11)) ++ (encoder->lang->langID == WBXML_LANG_SYNCML_SYNCML11) || ++ (encoder->lang->langID == WBXML_LANG_SYNCML_SYNCML12)) + { + /** @todo We must check too if we are in a */ + +@@ -2219,6 +2245,11 @@ + * @param list The Value Element list + * @return WBXML_OK if encoding is OK, an error code otherwise + */ ++static WBXMLError wbxml_encode_opaque(WBXMLEncoder *encoder, WBXMLBuffer *buff) ++{ ++ return wbxml_encode_opaque_data(encoder, wbxml_buffer_get_cstr(buff), wbxml_buffer_len(buff)); ++} ++ + static WBXMLError wbxml_encode_value_element_list(WBXMLEncoder *encoder, WBXMLList *list) + { + WBXMLValueElement *elt = NULL; +@@ -2438,18 +2469,18 @@ + * @note opaque = OPAQUE length *byte + * length = mb_u_int32 + */ +-static WBXMLError wbxml_encode_opaque(WBXMLEncoder *encoder, WBXMLBuffer *buff) ++static WBXMLError wbxml_encode_opaque_data(WBXMLEncoder *encoder, WB_UTINY *data, WB_ULONG data_len) + { + /* Add WBXML_OPAQUE */ + if (!wbxml_buffer_append_char(encoder->output, WBXML_OPAQUE)) + return WBXML_ERROR_ENCODER_APPEND_DATA; + + /* Add Length */ +- if (!wbxml_buffer_append_mb_uint_32(encoder->output, wbxml_buffer_len(buff))) ++ if (!wbxml_buffer_append_mb_uint_32(encoder->output, data_len)) + return WBXML_ERROR_ENCODER_APPEND_DATA; + + /* Add Buffer */ +- if (!wbxml_buffer_append(encoder->output, buff)) ++ if (!wbxml_buffer_append_data(encoder->output, data, data_len)) + return WBXML_ERROR_ENCODER_APPEND_DATA; + + return WBXML_OK; +@@ -3146,8 +3177,54 @@ + } + + #endif /* WBXML_SUPPORT_DRMREL */ ++#if defined( WBXML_SUPPORT_OTA_SETTINGS ) ++static WBXMLError wbxml_encode_ota_nokia_icon(WBXMLEncoder *encoder, WB_UTINY *buffer) ++{ ++ WBXMLError ret = WBXML_NOT_ENCODED; ++ ++ /* Is a VALUE attribute ? */ ++ if ((encoder->current_tag != NULL) && ++ (encoder->current_attr->wbxmlCodePage == 0x00) && ++ (encoder->current_attr->wbxmlToken == 0x11) && ++ (encoder->current_node && encoder->current_node->attrs)) ++ { ++ WBXMLList *attrs = encoder->current_node->attrs; ++ WB_ULONG index = 0; ++ WB_ULONG nb_attrs = wbxml_list_len(attrs); ++ WB_BOOL found = FALSE; ++ ++ /* Search for a NAME="ICON" attribute */ ++ while (!found && (index < nb_attrs)) { ++ WBXMLAttribute *attr = (WBXMLAttribute*)wbxml_list_get(attrs, index); ++ ++ if ((WBXML_STRCMP("NAME", wbxml_attribute_get_xml_name(attr)) == 0) && ++ (WBXML_STRCMP("ICON", wbxml_attribute_get_xml_value(attr)) == 0)) ++ { ++ WB_UTINY *data = NULL; ++ WB_LONG data_len = 0; + ++ /* Decode Base64 */ ++ if ((data_len = wbxml_base64_decode(buffer, &data)) < 0) ++ return WBXML_NOT_ENCODED; ++ ++ /* Encode opaque */ ++ if ((ret = wbxml_encode_opaque_data(encoder, data, data_len)) != WBXML_OK) ++ return ret; ++ ++ /* Free Data */ ++ wbxml_free(data); ++ ++ found = TRUE; ++ } ++ ++ index++; ++ } ++ } ++ ++ return ret; ++} + ++#endif /* WBXML_SUPPORT_OTA_SETTINGS */ + #if defined( WBXML_ENCODER_USE_STRTBL ) + + /**************************** +@@ -4019,7 +4096,8 @@ + #if defined( WBXML_SUPPORT_SYNCML ) + /* Change text in from "application/vnd.syncml-devinf+wbxml" to "application/vnd.syncml-devinf+xml" */ + if (((encoder->lang->langID == WBXML_LANG_SYNCML_SYNCML10) || +- (encoder->lang->langID == WBXML_LANG_SYNCML_SYNCML11)) && ++ (encoder->lang->langID == WBXML_LANG_SYNCML_SYNCML11) || ++ (encoder->lang->langID == WBXML_LANG_SYNCML_SYNCML12)) && + (encoder->current_tag != NULL) && + (encoder->current_tag->wbxmlCodePage == 0x01 ) && + (encoder->current_tag->wbxmlToken == 0x13 ) && diff --git a/textproc/wbxml2/files/patch-src_wbxml_encoder.h b/textproc/wbxml2/files/patch-src_wbxml_encoder.h new file mode 100644 index 000000000000..f68e41c0b6e4 --- /dev/null +++ b/textproc/wbxml2/files/patch-src_wbxml_encoder.h @@ -0,0 +1,10 @@ +--- src/wbxml_encoder.h.orig 2008-06-15 07:38:14.000000000 +1000 ++++ src/wbxml_encoder.h 2008-06-15 07:39:40.000000000 +1000 +@@ -116,6 +116,7 @@ + * @note This function has no effect if WBXML_ENCODER_USE_STRTBL compilation flag is not set + */ + WBXML_DECLARE(void) wbxml_encoder_set_use_strtbl(WBXMLEncoder *encoder, WB_BOOL use_strtbl); ++WBXML_DECLARE(void) wbxml_encoder_set_produce_anonymous(WBXMLEncoder *encoder, WB_BOOL set_anonymous); + + /** + * @brief Set the WBXML Version of the output document, when generating WBXML [Default: 'WBXML_VERSION_TOKEN_13' (1.3)] diff --git a/textproc/wbxml2/files/patch-src_wbxml_parser.c b/textproc/wbxml2/files/patch-src_wbxml_parser.c new file mode 100644 index 000000000000..59775aa0d514 --- /dev/null +++ b/textproc/wbxml2/files/patch-src_wbxml_parser.c @@ -0,0 +1,300 @@ +--- src/wbxml_parser.c.orig 2006-07-11 21:47:45.000000000 +1000 ++++ src/wbxml_parser.c 2008-06-15 06:59:21.000000000 +1000 +@@ -153,11 +153,14 @@ + static WBXMLError parse_mb_uint32(WBXMLParser *parser, WB_ULONG *result); + + /* Language Specific Decoding Functions */ ++static WBXMLError decode_base64_value(WBXMLBuffer **data); ++ + #if defined( WBXML_SUPPORT_SI ) || defined( WBXML_SUPPORT_EMN ) + static WBXMLError decode_datetime(WBXMLBuffer *buff); + #endif /* WBXML_SUPPORT_SI || WBXML_SUPPORT_EMN */ + + static WBXMLError decode_opaque_content(WBXMLParser *parser, WBXMLBuffer **data); ++static WBXMLError decode_opaque_attr_value(WBXMLParser *parser, WBXMLBuffer **data); + + #if defined( WBXML_SUPPORT_WV ) + static WBXMLError decode_wv_content(WBXMLParser *parser, WBXMLBuffer **data); +@@ -165,10 +168,6 @@ + static WBXMLError decode_wv_datetime(WBXMLBuffer **data); + #endif /* WBXML_SUPPORT_WV */ + +-#if defined( WBXML_SUPPORT_DRMREL ) +-static WBXMLError decode_drmrel_keyvalue(WBXMLBuffer **data); +-#endif /* WBXML_SUPPORT_DRMREL */ +- + /* Macro for error handling */ + #define CHECK_ERROR if (ret != WBXML_OK) return ret; + +@@ -277,7 +276,7 @@ + parser->charset = WBXML_PARSER_DEFAULT_CHARSET; + + WBXML_WARNING((WBXML_PARSER, +- "No charset information found, using default : %s", ++ "No charset information found, using default : %x", + WBXML_PARSER_DEFAULT_CHARSET)); + } + } +@@ -659,12 +658,14 @@ + * Do NOT keep 'WBXML_VERSION_UNKNOWN' (0xffffffff) because only one byte will change. + * (for example, if the version is 0x02, then parser->version will be 0xffffff02) + */ +- parser->version = WBXML_VERSION_10; ++ WB_UTINY version = WBXML_VERSION_10; + +- if ((ret = parse_uint8(parser, (WB_UTINY*) &parser->version)) != WBXML_OK) ++ if ((ret = parse_uint8(parser, &version)) != WBXML_OK) + return ret; ++ ++ parser->version = version; + +- WBXML_DEBUG((WBXML_PARSER, "(%d) Parsed version: '0x%X'", parser->pos - 1, (WB_TINY) parser->version)); ++ WBXML_DEBUG((WBXML_PARSER, "(%d) Parsed version: 1.%d", parser->pos - 1, parser->version)); + + return WBXML_OK; + } +@@ -938,6 +939,8 @@ + if ((ret = parse_stag(parser, &tag, &element)) != WBXML_OK ) { + return ret; + } ++ ++ WBXML_DEBUG((WBXML_PARSER, "<%s>", wbxml_tag_get_xml_name(element))); + + /* Set Current Tag */ + if (element->type == WBXML_VALUE_TOKEN) { +@@ -990,11 +993,11 @@ + attrs, + is_empty); + } +- ++ + /* Free Attributes */ + free_attrs_table(attrs); + +- ++ + /* Parse *content */ + if (!is_empty) { + /* There can be NO content */ +@@ -1023,7 +1026,7 @@ + content = NULL; + } + +- WBXML_DEBUG((WBXML_PARSER, "(%d) End of Element", parser->pos)); ++ WBXML_DEBUG((WBXML_PARSER, "(%d) End of Element", parser->pos - 1)); + + /* Skip END */ + parser->pos++; +@@ -1037,7 +1040,9 @@ + element, + is_empty); + } +- ++ ++ WBXML_DEBUG((WBXML_PARSER, "", wbxml_tag_get_xml_name(element))); ++ + /* Free Tag */ + wbxml_tag_destroy(element); + +@@ -1078,7 +1083,7 @@ + WBXML_DEBUG((WBXML_PARSER, "(%d) Parsing switchPage", parser->pos)); + + if ((WB_UTINY) parser->version < (WB_UTINY) WBXML_VERSION_12) +- WBXML_WARNING((WBXML_PARSER, "No Switch Page mecanism possible in WBXML < %s", WBXML_VERSION_TEXT_12)); ++ WBXML_WARNING((WBXML_PARSER, "No Switch Page mecanism possible in WBXML < %s (current: %d)", WBXML_VERSION_TEXT_12, (WB_UTINY) parser->version)); + + /* Skip SWITCH_PAGE token */ + parser->pos++; +@@ -1946,7 +1951,10 @@ + WBXML_ERROR((WBXML_PARSER, "An Attribute value can't be 'opaque' in WBXML version < %s", WBXML_VERSION_TEXT_12)); + } + +- return parse_opaque(parser, result); ++ if ((ret = parse_opaque(parser, result)) != WBXML_OK) ++ return ret; ++ ++ return decode_opaque_attr_value(parser, result); + } + + +@@ -2209,6 +2217,40 @@ + * Language Specific Decoding Functions + */ + ++/** ++ * @brief Decode a BASE64 value ++ * @param data [in/out]The value to decode ++ * @return WBXML_OK if OK, another error code otherwise ++ */ ++static WBXMLError decode_base64_value(WBXMLBuffer **data) ++{ ++ WB_UTINY *result = NULL; ++ WBXMLError ret = WBXML_OK; ++ ++ if ((data == NULL) || (*data == NULL)) { ++ return WBXML_ERROR_INTERNAL; ++ } ++ ++ if ((result = wbxml_base64_encode((const WB_UTINY *) wbxml_buffer_get_cstr(*data), ++ wbxml_buffer_len(*data))) == NULL) ++ { ++ return WBXML_ERROR_B64_ENC; ++ } ++ ++ /* Reset buffer */ ++ wbxml_buffer_delete(*data, 0, wbxml_buffer_len(*data)); ++ ++ /* Set data */ ++ if (!wbxml_buffer_append_cstr(*data, result)) { ++ ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; ++ } ++ ++ wbxml_free(result); ++ ++ return ret; ++} ++ ++ + #if ( defined( WBXML_SUPPORT_SI ) || defined( WBXML_SUPPORT_EMN ) ) + + /************************************** +@@ -2297,8 +2339,6 @@ + * @param parser The WBXML Parser + * @param data The Opaque data buffer + * @return WBXML_OK if OK, another error code otherwise +- * @note Used for: +- * - WV 1.1 / 1.2 + */ + static WBXMLError decode_opaque_content(WBXMLParser *parser, + WBXMLBuffer **data) +@@ -2318,13 +2358,14 @@ + #if defined( WBXML_SUPPORT_DRMREL ) + + case WBXML_LANG_DRMREL10: ++ /* ds:KeyValue */ + if ((parser->current_tag->wbxmlCodePage == 0x00) && + (parser->current_tag->wbxmlToken == 0x0C)) + { + WBXMLError ret = WBXML_OK; + +- /* Decode */ +- if ((ret = decode_drmrel_keyvalue(data)) != WBXML_OK) ++ /* Decode base64 value */ ++ if ((ret = decode_base64_value(data)) != WBXML_OK) + return ret; + + return WBXML_OK; +@@ -2332,7 +2373,62 @@ + break; + + #endif /* WBXML_SUPPORT_DRMREL */ +- ++ ++#if defined( WBXML_SUPPORT_SYNCML ) ++ ++ case WBXML_LANG_SYNCML_SYNCML10: ++ case WBXML_LANG_SYNCML_SYNCML11: ++ case WBXML_LANG_SYNCML_SYNCML12: ++ /* NextNonce */ ++ if ((parser->current_tag->wbxmlCodePage == 0x01) && ++ (parser->current_tag->wbxmlToken == 0x10)) ++ { ++ WBXMLError ret = WBXML_OK; ++ ++ /* Decode base64 value */ ++ if ((ret = decode_base64_value(data)) != WBXML_OK) ++ return ret; ++ ++ return WBXML_OK; ++ } ++ break; ++ ++#endif /* WBXML_SUPPORT_SYNCML */ ++ ++ default: ++ /* NOP */ ++ break; ++ } /* switch */ ++ ++ return WBXML_OK; ++} ++ ++ ++/** ++ * @brief Decode an Opaque Attribute Value buffer ++ * @param parser The WBXML Parser ++ * @param data The Opaque data buffer ++ * @return WBXML_OK if OK, another error code otherwise ++ */ ++static WBXMLError decode_opaque_attr_value(WBXMLParser *parser, WBXMLBuffer **data) ++{ ++ switch (parser->langTable->langID) ++ { ++#if defined( WBXML_SUPPORT_OTA_SETTINGS ) ++ ++ case WBXML_LANG_OTA_SETTINGS: ++ { ++ WBXMLError ret = WBXML_OK; ++ ++ /* Decode base64 value */ ++ if ((ret = decode_base64_value(data)) != WBXML_OK) ++ return ret; ++ ++ return WBXML_OK; ++ } ++ ++#endif /* WBXML_SUPPORT_OTA_SETTINGS */ ++ + default: + /* NOP */ + break; +@@ -2705,49 +2801,3 @@ + } + + #endif /* WBXML_SUPPORT_WV */ +- +- +-#if defined( WBXML_SUPPORT_DRMREL ) +- +-/************************************** +- * DRMREL 1.0 +- */ +- +-/** +- * @brief Decode a DRMREL 'KeyValue' +- * @param data The KeyValue to decode +- * @return WBXML_OK if OK, another error code otherwise +- * @note Used for: +- * - DRMREL 1.0 +- * @note [OMA-Download-DRMREL-v1_0-20020913-C.PDF] - 7.1: +- * "The content of the element MUST be in binary format using the ‘opaque’ token." +- */ +-static WBXMLError decode_drmrel_keyvalue(WBXMLBuffer **data) +-{ +- WB_UTINY *result = NULL; +- WBXMLError ret = WBXML_OK; +- +- if ((data == NULL) || (*data == NULL)) { +- return WBXML_ERROR_INTERNAL; +- } +- +- if ((result = wbxml_base64_encode((const WB_UTINY *) wbxml_buffer_get_cstr(*data), +- wbxml_buffer_len(*data))) == NULL) +- { +- return WBXML_ERROR_B64_ENC; +- } +- +- /* Reset buffer */ +- wbxml_buffer_delete(*data, 0, wbxml_buffer_len(*data)); +- +- /* Set data */ +- if (!wbxml_buffer_append_cstr(*data, result)) { +- ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; +- } +- +- wbxml_free(result); +- +- return ret; +-} +- +-#endif /* WBXML_SUPPORT_DRMREL */ diff --git a/textproc/wbxml2/files/patch-src_wbxml_tables.h b/textproc/wbxml2/files/patch-src_wbxml_tables.h new file mode 100644 index 000000000000..d84a50b19dc0 --- /dev/null +++ b/textproc/wbxml2/files/patch-src_wbxml_tables.h @@ -0,0 +1,13 @@ +--- src/wbxml_tables.h.orig 2008-06-15 07:35:57.000000000 +1000 ++++ src/wbxml_tables.h 2008-06-15 07:36:37.000000000 +1000 +@@ -108,8 +108,8 @@ + + /* SyncML 1.2 */ + #define WBXML_PUBLIC_ID_SYNCML_SYNCML12 0x1201 +-#define WBXML_PUBLIC_ID_SYNCML_DEVINF12 0x1202 +-#define WBXML_PUBLIC_ID_SYNCML_METINF12 0x1203 ++#define WBXML_PUBLIC_ID_SYNCML_METINF12 0x1202 ++#define WBXML_PUBLIC_ID_SYNCML_DEVINF12 0x1203 + + #define XML_PUBLIC_ID_SYNCML_SYNCML12 "-//SYNCML//DTD SyncML 1.2//EN" + #define XML_PUBLIC_ID_SYNCML_DEVINF12 "-//SYNCML//DTD DevInf 1.2//EN" diff --git a/textproc/wbxml2/files/patch-src_wbxml_tree.c b/textproc/wbxml2/files/patch-src_wbxml_tree.c new file mode 100644 index 000000000000..d5b1de6783bb --- /dev/null +++ b/textproc/wbxml2/files/patch-src_wbxml_tree.c @@ -0,0 +1,253 @@ +--- src/wbxml_tree.c.orig 2006-07-11 21:47:45.000000000 +1000 ++++ src/wbxml_tree.c 2008-06-15 06:59:31.000000000 +1000 +@@ -137,6 +137,7 @@ + + /* Use String Table */ + wbxml_encoder_set_use_strtbl(wbxml_encoder, TRUE); ++ wbxml_encoder_set_produce_anonymous(wbxml_encoder, FALSE); + } + else { + /* WBXML Version */ +@@ -153,6 +156,7 @@ + + /* String Table */ + wbxml_encoder_set_use_strtbl(wbxml_encoder, params->use_strtbl); ++ wbxml_encoder_set_produce_anonymous(wbxml_encoder, params->produce_anonymous); + + /** @todo Add parameter to call : wbxml_encoder_set_output_charset() */ + } +@@ -256,7 +262,8 @@ + + #else /* HAVE_EXPAT */ + +-#if defined( HAVE_LIBXML ) ++//#if defined( HAVE_LIBXML ) ++#if 0 + + /** @todo Use LibXML2 SAX interface ! */ + return WBXML_ERROR_NO_XMLPARSER; +@@ -333,7 +340,8 @@ + } + + +-#if defined( HAVE_LIBXML ) ++// #if defined( HAVE_LIBXML ) ++#if 0 + + WBXML_DECLARE(WBXMLError) wbxml_tree_from_libxml_doc(xmlDocPtr libxml_doc, + WBXMLTree **tree) +@@ -617,6 +625,40 @@ + } + + ++WBXML_DECLARE(WBXMLError) wbxml_tree_node_extract(WBXMLTreeNode *node) ++{ ++ if (node == NULL) ++ return WBXML_ERROR_BAD_PARAMETER; ++ ++ /* Parent link */ ++ if (node->parent != NULL) { ++ if (node->parent->children == node) { ++ /* Update parent children */ ++ node->parent->children = node->next; ++ } ++ ++ /* No more parent */ ++ node->parent = NULL; ++ } ++ ++ /* Next link */ ++ if (node->next != NULL) { ++ /* Link next node to previous node */ ++ node->next->prev = node->prev; ++ node->next = NULL; ++ } ++ ++ /* Previous link */ ++ if (node->prev != NULL) { ++ /* Link previous node to next node */ ++ node->prev->next = node->next; ++ node->prev = NULL; ++ } ++ ++ return WBXML_OK; ++} ++ ++ + WBXML_DECLARE(WBXMLError) wbxml_tree_node_add_attr(WBXMLTreeNode *node, + WBXMLAttribute *attr) + { +@@ -938,34 +982,17 @@ + } + + +-/** @todo Rewrite this function (use wbxml_tree_node_* functions) */ + WBXML_DECLARE(WB_BOOL) wbxml_tree_add_node(WBXMLTree *tree, WBXMLTreeNode *parent, WBXMLTreeNode *node) + { + WBXMLTreeNode *tmp = NULL; + + if ((tree == NULL) || (node == NULL)) + return FALSE; +- +- /* Set parent to new node */ +- node->parent = parent; +- ++ + /* Check if this is the Root Element */ + if (parent != NULL) { +- /* This is not the Root Element... search for previous sibbling element */ +- if (parent->children != NULL) { +- /* Add this Node to end of Sibbling Node list of Parent */ +- tmp = parent->children; +- +- while (tmp->next != NULL) +- tmp = tmp->next; +- +- node->prev = tmp; +- tmp->next = node; +- } +- else { +- /* No previous sibbling element */ +- parent->children = node; +- } ++ if (!wbxml_tree_node_add_child(parent, node)) ++ return FALSE; + } + else { + /* We do NOT allow replacement of an existing Tree Node */ +@@ -974,53 +1001,28 @@ + + /* This is the Root Element */ + tree->root = node; ++ node->parent = NULL; + } + + return TRUE; + } + + +-/** @todo Rewrite this function (use wbxml_tree_node_* functions) */ + WBXML_DECLARE(WBXMLError) wbxml_tree_extract_node(WBXMLTree *tree, + WBXMLTreeNode *node) + { + if ((tree == NULL) || (node == NULL)) + return WBXML_ERROR_BAD_PARAMETER; +- +- /* Parent link */ +- if (node->parent != NULL) { +- if (node->parent->children == node) { +- /* Update parent children */ +- node->parent->children = node->next; +- } +- +- /* No more parent */ +- node->parent = NULL; +- } +- else { ++ ++ if (node == tree->root) { + /* Root removed ! */ + tree->root = node->next; + } + +- /* Next link */ +- if (node->next != NULL) { +- /* Link next node to previous node */ +- node->next->prev = node->prev; +- node->next = NULL; +- } +- +- /* Previous link */ +- if (node->prev != NULL) { +- /* Link previous node to next node */ +- node->prev->next = node->next; +- node->prev = NULL; +- } +- +- return WBXML_OK; ++ return wbxml_tree_node_extract(node); + } + + +-/** @todo Rewrite this function (use wbxml_tree_node_* functions) */ + WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_elt(WBXMLTree *tree, + WBXMLTreeNode *parent, + WBXMLTag *tag) +@@ -1048,7 +1050,6 @@ + } + + +-/** @todo Rewrite this function (use wbxml_tree_node_* functions) */ + WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_elt_with_attrs(WBXMLTree *tree, + WBXMLTreeNode *parent, + WBXMLTag *tag, +@@ -1075,36 +1076,15 @@ + } + + +-/** @todo Rewrite this function (use wbxml_tree_node_* functions) */ + WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_xml_elt(WBXMLTree *tree, + WBXMLTreeNode *parent, + WB_UTINY *name) + { +- const WBXMLTagEntry *tag_entry = NULL; + WBXMLTreeNode *node = NULL; +- WBXMLTag *tag = NULL; + +- /* Search for XML Tag Name in Table */ +- if ((tag_entry = wbxml_tables_get_tag_from_xml(tree->lang, (const WB_UTINY *) name)) != NULL) { +- /* Found : token tag */ +- tag = wbxml_tag_create_token(tag_entry); +- } +- else { +- /* Not found : literal tag */ +- tag = wbxml_tag_create_literal(name); +- } +- +- if (tag == NULL) +- return NULL; +- +- /* Create a new Node */ +- if ((node = wbxml_tree_node_create(WBXML_TREE_ELEMENT_NODE)) == NULL) { +- wbxml_tag_destroy(tag); ++ /* Create element node */ ++ if ((node = wbxml_tree_node_create_xml_elt(tree->lang, (const WB_UTINY *) name)) == NULL) + return NULL; +- } +- +- /* Set Node Tag */ +- node->name = tag; + + /* Add this Node to Tree */ + if (!wbxml_tree_add_node(tree, parent, node)) { +@@ -1116,7 +1096,6 @@ + } + + +-/** @todo Rewrite this function (use wbxml_tree_node_* functions) */ + WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_xml_elt_with_attrs(WBXMLTree *tree, + WBXMLTreeNode *parent, + WB_UTINY *name, +@@ -1143,7 +1122,6 @@ + } + + +-/** @todo Rewrite this function (use wbxml_tree_node_* functions) */ + WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_add_text(WBXMLTree *tree, + WBXMLTreeNode *parent, + const WB_UTINY *text, +@@ -1152,13 +1130,7 @@ + WBXMLTreeNode *node = NULL; + + /* Create a new Node */ +- if ((node = wbxml_tree_node_create(WBXML_TREE_TEXT_NODE)) == NULL) { +- return NULL; +- } +- +- /* Set Content */ +- if ((node->content = wbxml_buffer_create(text, len, len)) == NULL) { +- wbxml_tree_node_destroy(node); ++ if ((node = wbxml_tree_node_create_text(text, len)) == NULL) { + return NULL; + } + diff --git a/textproc/wbxml2/files/patch-src_wbxml_tree.h b/textproc/wbxml2/files/patch-src_wbxml_tree.h new file mode 100644 index 000000000000..c8e826114eba --- /dev/null +++ b/textproc/wbxml2/files/patch-src_wbxml_tree.h @@ -0,0 +1,10 @@ +--- src/wbxml_tree.h.orig 2008-06-15 08:10:30.000000000 +1000 ++++ src/wbxml_tree.h 2008-06-15 08:11:09.000000000 +1000 +@@ -308,6 +308,7 @@ + WBXML_DECLARE(WB_BOOL) wbxml_tree_node_add_child(WBXMLTreeNode *parent, + WBXMLTreeNode *node); + ++WBXML_DECLARE(WBXMLError) wbxml_tree_node_extract(WBXMLTreeNode *node); + /** + * @brief Add a WBXML Attribute to a Tree Node structure + * @param node The Tree Node to modify -- cgit