Do not use deprecated libxml API (libxml 2.12.x) 31/307831/2 accepted/tizen/unified/20240315.032946
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 13 Mar 2024 10:49:21 +0000 (19:49 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 13 Mar 2024 10:50:10 +0000 (19:50 +0900)
Change-Id: I44597e996ea86e1fe3ecdef161c18308d11bd74c

oma-parser/CMakeLists.txt
oma-parser/oma-parser-interface.c

index 0d1672cdf669b719253e4f78d9ad40ee08be9be2..4bb91e15c0abfdcb58f7f7d6192414546d682844 100644 (file)
@@ -1,5 +1,14 @@
 FILE(GLOB OMA_SRCS *.c)
 
+pkg_check_modules(LIBXML libxml-2.0 REQUIRED)
+if(PKG_CONFIG_FOUND AND ${LIBXML_VERSION} VERSION_GREATER 2.11.0)
+    message(STATUS "libxml2.0 version is greater than 2.11.0. ${LIBXML_VERSION}")
+else()
+    message(STATUS "libxml2.0 version ${LIBXML_VERSION}")
+       ADD_DEFINITIONS("-D_USE_USER_PARSE_FILE")
+endif()
+
+
 ADD_DEFINITIONS("-DDEBUG_USING_DLOG")
 
 ADD_LIBRARY(${LIB_OMA_PARSER} OBJECT ${OMA_SRCS})
index c7cb53bdf7f0dd9623d16c4d03398d83b87cf421..eb4e1fd249827989de35110d4b1b2e5f479d511e 100644 (file)
@@ -69,6 +69,7 @@ int op_parse_dd_file(const char *dd_file_path, void **dd_info, int *error_code)
                goto ERR;
        }
 
+#ifdef _USE_USER_PARSE_FILE
        if (xmlSAXUserParseFile(sHandlerPtr, app_data, dd_file_path) < 0) {
                OP_LOGD("Error : return value less than zero");
                *error_code = app_data->parseError;
@@ -81,6 +82,23 @@ int op_parse_dd_file(const char *dd_file_path, void **dd_info, int *error_code)
                b_ret = OP_FALSE;
                goto ERR;
        }
+#else
+       xmlParserCtxtPtr ctxt = xmlNewSAXParserCtxt(sHandlerPtr, app_data);
+       if (ctxt == NULL) {
+               OP_LOGE("xmlNewSAXParserCtxt() is failed.");
+               b_ret = OP_FALSE;
+               goto ERR;
+       }
+
+       xmlDocPtr doc = xmlCtxtReadFile(ctxt, dd_file_path, NULL, XML_PARSE_COMPACT | XML_PARSE_BIG_LINES);
+       if (OP_RESULT_OK != app_data->parseError) {
+               *error_code = app_data->parseError;
+               b_ret = OP_FALSE;
+               xmlFreeDoc(doc);
+               goto ERR;
+       }
+       xmlFreeDoc(doc);
+#endif
 
        if (OP_FALSE == (b_ret = op_check_mandatory_tags(app_data))) {
                OP_LOGE("Parse error happened. Mandatory Element Missing");