forked from github/server
add skeleton for expat suport
This commit is contained in:
parent
b868a54f0b
commit
6207211ba9
5 changed files with 37 additions and 2 deletions
|
@ -50,6 +50,7 @@ else()
|
|||
find_package (SQLite3 REQUIRED QUIET)
|
||||
endif()
|
||||
|
||||
find_package(EXPAT)
|
||||
find_package (LibXml2 REQUIRED)
|
||||
find_package (ToLua REQUIRED)
|
||||
if (TOLUA_FOUND)
|
||||
|
|
|
@ -139,6 +139,11 @@ set (ERESSEA_SRC
|
|||
${UTIL_SRC}
|
||||
)
|
||||
|
||||
IF(EXPAT_FOUND)
|
||||
set (ERESSEA_SRC ${ERESSEA_SRC} exparse.c)
|
||||
ENDIF(EXPAT_FOUND)
|
||||
|
||||
|
||||
set(SERVER_SRC
|
||||
main.c
|
||||
console.c
|
||||
|
@ -309,6 +314,14 @@ target_link_libraries(eressea ${CURSES_LIBRARIES})
|
|||
add_definitions(-DUSE_CURSES)
|
||||
endif(CURSES_FOUND)
|
||||
|
||||
if (EXPAT_FOUND)
|
||||
include_directories (${EXPAT_INCLUDE_DIRS})
|
||||
target_link_libraries(eressea ${EXPAT_LIBRARIES})
|
||||
target_link_libraries(convert ${EXPAT_LIBRARIES})
|
||||
target_link_libraries(test_eressea ${EXPAT_LIBRARIES})
|
||||
add_definitions(-DUSE_EXPAT)
|
||||
endif (EXPAT_FOUND)
|
||||
|
||||
if (LIBXML2_FOUND)
|
||||
include_directories (${LIBXML2_INCLUDE_DIR})
|
||||
target_link_libraries(eressea ${LIBXML2_LIBRARIES})
|
||||
|
|
7
src/exparse.c
Normal file
7
src/exparse.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "exparse.h"
|
||||
|
||||
#include <expat.h>
|
||||
|
||||
int exparse_readfile(const char * filename) {
|
||||
return 1;
|
||||
}
|
3
src/exparse.h
Normal file
3
src/exparse.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
int exparse_readfile(const char * filename);
|
|
@ -46,6 +46,9 @@ without prior permission by the authors of Eressea.
|
|||
#include "move.h"
|
||||
#include "prefix.h"
|
||||
#include "skill.h"
|
||||
#ifdef USE_EXPAT
|
||||
#include "exparse.h"
|
||||
#endif
|
||||
|
||||
/* external libraries */
|
||||
#include <cJSON.h>
|
||||
|
@ -969,8 +972,16 @@ static int include_json(const char *uri) {
|
|||
static int include_xml(const char *uri) {
|
||||
char name[PATH_MAX];
|
||||
const char *filename = uri_to_file(uri, name, sizeof(name));
|
||||
int err = read_xml(filename);
|
||||
if (err < 0) {
|
||||
int err;
|
||||
#ifdef USE_EXPAT
|
||||
err = exparse_readfile(filename);
|
||||
if (err != 0) {
|
||||
err = read_xml(filename);
|
||||
}
|
||||
#else
|
||||
err = read_xml(filename);
|
||||
#endif
|
||||
if (err != 0) {
|
||||
log_error("could not parse XML from %s", uri);
|
||||
}
|
||||
return err;
|
||||
|
|
Loading…
Reference in a new issue