summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan@13f79535-47bb-0310-9956-ffa450edef68>2019-05-11 20:24:17 +0000
committerivan <ivan@13f79535-47bb-0310-9956-ffa450edef68>2019-05-11 20:24:17 +0000
commit02ba2ba252bc69739742bc910884ccbdcf4d42f7 (patch)
tree118903a35e9d3a3ad43131dcd5651904ff016bbb
parent3f78f4fda6933425931f0478b8a19f7f3380e9f8 (diff)
downloadlibapr-02ba2ba252bc69739742bc910884ccbdcf4d42f7.tar.gz
On 'xmllite' branch: Add placeholder for XmlLite support.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/xmllite@1859122 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CMakeLists.txt44
-rw-r--r--include/apr.hwc1
-rw-r--r--xml/apr_xml_xmllite.c88
3 files changed, 121 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b424814e3..68b9ca26a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,16 +24,28 @@ FIND_PACKAGE(Expat)
FIND_PACKAGE(LibXml2)
FIND_PACKAGE(OpenSSL)
-IF(NOT EXPAT_FOUND AND NOT LIBXML2_FOUND)
- MESSAGE(FATAL_ERROR "Either Expat or LibXml2 is required, but neither was found")
+IF(NOT APU_USE_EXPAT AND NOT APU_USE_LIBXML2 AND NOT APU_USE_XMLLITE)
+ IF(EXPAT_FOUND)
+ OPTION(APU_USE_EXPAT "Use Expat" ON)
+ OPTION(APU_USE_LIBXML2 "Use LibXml2" OFF)
+ OPTION(APU_USE_XMLLITE "Use XmlLite" OFF)
+ ELSEIF(LIBXML2_FOUND)
+ OPTION(APU_USE_EXPAT "Use Expat" OFF)
+ OPTION(APU_USE_LIBXML2 "Use LibXml2" ON)
+ OPTION(APU_USE_XMLLITE "Use XmlLite" OFF)
+ ELSE()
+ OPTION(APU_USE_EXPAT "Use Expat" OFF)
+ OPTION(APU_USE_LIBXML2 "Use LibXml2" OFF)
+ OPTION(APU_USE_XMLLITE "Use XmlLite" ON)
+ ENDIF()
ENDIF()
-IF(EXPAT_FOUND)
- OPTION(APU_USE_EXPAT "Use Expat" ON)
- OPTION(APU_USE_LIBXML2 "Use LibXml2" OFF)
-ELSE()
- OPTION(APU_USE_EXPAT "Use Expat" OFF)
- OPTION(APU_USE_LIBXML2 "Use LibXml2" ON)
+IF(APU_USE_EXPAT AND NOT EXPAT_FOUND)
+ MESSAGE(FATAL_ERROR "Expat not found")
+ENDIF()
+
+IF(APU_USE_LIBXML2 AND NOT LIBXML2_FOUND)
+ MESSAGE(FATAL_ERROR "LibXml2 not found")
ENDIF()
OPTION(APR_INSTALL_PRIVATE_H "Install selected private .h files (for httpd)" OFF)
@@ -50,8 +62,8 @@ SET(LIBXML2_ICONV_INCLUDE_DIR ""
SET(LIBXML2_ICONV_LIBRARIES ""
CACHE STRING "iconv libraries to link with for libxml2")
-IF(NOT APU_USE_EXPAT AND NOT APU_USE_LIBXML2)
- MESSAGE(FATAL_ERROR "Either Expat or LibXml2 must be selected")
+IF(NOT APU_USE_EXPAT AND NOT APU_USE_LIBXML2 AND NOT APU_USE_XMLLITE)
+ MESSAGE(FATAL_ERROR "Either Expat or LibXml2 or XmlLite must be selected")
ENDIF()
IF(APU_USE_EXPAT AND APU_USE_LIBXML2)
MESSAGE(FATAL_ERROR "Only one of Expat and LibXml2 can be selected")
@@ -69,6 +81,7 @@ SET(apr_have_ipv6_10 0)
SET(apu_have_crypto_10 0)
SET(apu_use_libxml2_10 0)
SET(apu_use_expat_10 0)
+SET(apu_use_xmllite_10 0)
IF(APR_HAVE_IPV6)
SET(apr_have_ipv6_10 1)
@@ -80,8 +93,10 @@ ENDIF()
IF(APU_USE_EXPAT)
SET(apu_use_expat_10 1)
-ELSE()
+ELSEIF(APU_USE_LIBXML2)
SET(apu_use_libxml2_10 1)
+ELSE(APU_USE_XMLLITE)
+ SET(apu_use_xmllite_10 1)
ENDIF()
IF("${MIN_WINDOWS_VER}" STREQUAL "")
@@ -120,9 +135,12 @@ ADD_CUSTOM_TARGET(
IF(APU_USE_EXPAT)
SET(XMLLIB_INCLUDE_DIR ${EXPAT_INCLUDE_DIRS})
SET(XMLLIB_LIBRARIES ${EXPAT_LIBRARIES})
-ELSE()
+ELSEIF(APU_USE_LIBXML2)
SET(XMLLIB_INCLUDE_DIR "${LIBXML2_INCLUDE_DIR};${LIBXML2_ICONV_INCLUDE_DIR}")
SET(XMLLIB_LIBRARIES "${LIBXML2_LIBRARIES};${LIBXML2_ICONV_LIBRARIES}")
+ELSEIF(APU_USE_XMLLITE)
+ SET(XMLLIB_INCLUDE_DIR "")
+ SET(XMLLIB_LIBRARIES "xmllite.lib")
ENDIF()
# Generated .h files are stored in PROJECT_BINARY_DIR, not the
@@ -353,6 +371,7 @@ SET(APR_SOURCES
xml/apr_xml.c
xml/apr_xml_expat.c
xml/apr_xml_libxml2.c
+ xml/apr_xml_xmllite.c
)
SET(APR_TEST_SOURCES
@@ -633,6 +652,7 @@ MESSAGE(STATUS " IPv6 ............................ : ${APR_HAVE_IPV6}")
MESSAGE(STATUS " DBD ODBC driver ................. : ${APU_HAVE_ODBC}")
MESSAGE(STATUS " Use Expat ....................... : ${APU_USE_EXPAT}")
MESSAGE(STATUS " Use LibXml2 ..................... : ${APU_USE_LIBXML2}")
+MESSAGE(STATUS " Use XmlLite ..................... : ${APU_USE_XMLLITE}")
MESSAGE(STATUS " Minimum Windows version ......... : ${MIN_WINDOWS_VER}")
MESSAGE(STATUS " Library files for XML ........... : ${XMLLIB_LIBRARIES}")
MESSAGE(STATUS " Build test suite ................ : ${APR_BUILD_TESTAPR}")
diff --git a/include/apr.hwc b/include/apr.hwc
index 6f242a0ed..1ced0d11f 100644
--- a/include/apr.hwc
+++ b/include/apr.hwc
@@ -686,6 +686,7 @@ typedef int apr_wait_t;
#define APU_USE_EXPAT @apu_use_expat_10@
#define APU_USE_LIBXML2 @apu_use_libxml2_10@
+#define APU_USE_XMLLITE @apu_use_xmllite_10@
/** @} */
diff --git a/xml/apr_xml_xmllite.c b/xml/apr_xml_xmllite.c
new file mode 100644
index 000000000..73d8b1fe4
--- /dev/null
+++ b/xml/apr_xml_xmllite.c
@@ -0,0 +1,88 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+
+#if APU_USE_XMLLITE
+#include "apr_xml.h"
+
+typedef void * XML_Parser;
+typedef int XML_Error;
+
+#include "apr_xml_internal.h"
+
+#define CINTERFACE
+#define COBJMACROS
+#define interface struct
+typedef void * LPMSG;
+
+#include <xmllite.h>
+
+static apr_status_t cleanup_parser(void *ctx)
+{
+ apr_xml_parser *parser = ctx;
+
+ return APR_SUCCESS;
+}
+
+static apr_status_t xmllite_parse(apr_xml_parser* parser, const char* data,
+ apr_size_t sz, int final)
+{
+ return APR_SUCCESS;
+}
+
+static XMLParserImpl xml_parser_xmllite = {
+ xmllite_parse,
+ cleanup_parser
+};
+
+static const char APR_KW_DAV[] = { 0x44, 0x41, 0x56, 0x3A, '\0' };
+
+XMLParserImpl* apr_xml_get_parser_impl(void)
+{
+ return &xml_parser_xmllite;
+}
+
+
+apr_xml_parser* apr_xml_parser_create_internal(apr_pool_t *pool,
+ void *start_func,
+ void *end_func,
+ void *cdata_func)
+{
+ apr_xml_parser *parser = apr_pcalloc(pool, sizeof(*parser));
+ IXmlReader *xml_reader;
+ HRESULT hr;
+
+ parser->impl = apr_xml_get_parser_impl();
+ parser->p = pool;
+ parser->doc = apr_pcalloc(pool, sizeof(*parser->doc));
+ parser->doc->namespaces = apr_array_make(pool, 5, sizeof(const char *));
+
+ /* ### is there a way to avoid hard-coding this? */
+ apr_xml_insert_uri(parser->doc->namespaces, APR_KW_DAV);
+ apr_pool_cleanup_register(pool, parser, cleanup_parser,
+ apr_pool_cleanup_null);
+
+ hr = CreateXmlReader(&IID_IXmlReader, &xml_reader, NULL);
+ if (FAILED(hr)) {
+ return NULL;
+ }
+
+ IXmlReader_Release(xml_reader);
+
+ return parser;
+}
+#endif