remove libxml2 from dependencies

remove the converter, that isn't a way we're going.
This commit is contained in:
Enno Rehling 2018-05-18 21:14:14 +02:00
parent 6b0f75339f
commit ce37fd1bb7
16 changed files with 4 additions and 1674 deletions

View File

@ -50,8 +50,7 @@ else()
find_package (SQLite3 REQUIRED QUIET)
endif()
find_package(EXPAT)
find_package (LibXml2 REQUIRED)
find_package(EXPAT REQUIRED)
find_package (ToLua REQUIRED)
if (TOLUA_FOUND)
if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2")
@ -71,6 +70,7 @@ add_subdirectory (process)
add_subdirectory (src eressea)
install(DIRECTORY etc DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.txt")
install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.po")
install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml")
install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.json")
install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua")

View File

@ -111,6 +111,7 @@ set (ERESSEA_SRC
report.c
steal.c
economy.c
exparse.c
give.c
items.c
laws.c
@ -127,7 +128,6 @@ set (ERESSEA_SRC
travelthru.c
monsters.c
wormhole.c
xmlreader.c
${SPELLS_SRC}
${RACES_SRC}
${ITEMS_SRC}
@ -139,11 +139,6 @@ 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
@ -187,15 +182,6 @@ target_link_libraries(eressea
${INIPARSER_LIBRARIES}
)
add_executable(convert convert.c)
target_link_libraries(convert
game
${LUA_MATH_LIBRARY}
${STORAGE_LIBRARIES}
${CLIBS_LIBRARIES}
${INIPARSER_LIBRARIES}
)
set(TESTS_SRC
test_eressea.c
tests.c
@ -235,7 +221,6 @@ set(TESTS_SRC
volcano.test.c
vortex.test.c
wormhole.test.c
# xmlreader.test.c
spells/flyingship.test.c
spells/magicresistance.test.c
triggers/shock.test.c
@ -285,18 +270,15 @@ endif(HAVE_STRDUP)
if (HAVE_LIBBSD)
target_link_libraries(test_eressea bsd)
target_link_libraries(eressea bsd)
target_link_libraries(convert bsd)
endif (HAVE_LIBBSD)
if (SQLITE3_FOUND)
include_directories (${SQLITE3_INCLUDE_DIR})
target_link_libraries(eressea ${SQLITE3_LIBRARIES})
target_link_libraries(convert ${SQLITE3_LIBRARIES})
target_link_libraries(test_eressea ${SQLITE3_LIBRARIES})
add_definitions(-DUSE_SQLITE)
elseif (DB_FOUND)
include_directories (${DB_INCLUDE_DIR})
target_link_libraries(convert ${DB_LIBRARIES})
target_link_libraries(eressea ${DB_LIBRARIES})
target_link_libraries(test_eressea ${DB_LIBRARIES})
add_definitions(-DUSE_DB)
@ -317,14 +299,5 @@ 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})
target_link_libraries(convert ${LIBXML2_LIBRARIES})
target_link_libraries(test_eressea ${LIBXML2_LIBRARIES})
endif (LIBXML2_FOUND)

View File

@ -59,7 +59,6 @@
#include <util/nrmessage.h>
#include <util/rand.h>
#include <util/rng.h>
#include <util/xml.h>
#include <selist.h>
#include <storage.h>
@ -833,33 +832,12 @@ static int tolua_get_spells(lua_State * L)
return tolua_selist_push(L, "spell_list", "spell", spells);
}
static int init_data(const char *filename)
{
int l;
l = read_xml(filename);
reset_locales();
if (l) {
return l;
}
if (turn <= 0) {
turn = first_turn();
}
return 0;
}
static int tolua_equip_newunits(lua_State * L) {
unit *u = (unit *)tolua_tousertype(L, 1, 0);
equip_newunits(u);
return 0;
}
static int tolua_read_xml(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, "config.xml");
lua_pushinteger(L, init_data(filename));
return 1;
}
static int tolua_report_unit(lua_State * L)
{
char buffer[512];
@ -1029,7 +1007,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile)
tolua_function(L, TOLUA_CAST "set_key", tolua_setkey);
tolua_function(L, TOLUA_CAST "translate", &tolua_translate);
tolua_function(L, TOLUA_CAST "spells", tolua_get_spells);
tolua_function(L, TOLUA_CAST "read_xml", tolua_read_xml);
tolua_function(L, TOLUA_CAST "equip_newunits", tolua_equip_newunits);
} tolua_endmodule(L);
return 1;

View File

@ -1,37 +0,0 @@
#include <platform.h>
#include "xmlreader.h"
#include <util/xml.h>
#include <kernel/race.h>
#include <kernel/rules.h>
#include <races/races.h>
#include <storage.h>
#include <string.h>
static int usage(void) {
return -1;
}
int main(int argc, char **argv) {
const char *mode;
register_races();
register_xmlreader();
if (argc < 2) return usage();
mode = argv[1];
if (strcmp(mode, "rules")==0) {
const char *xmlfile;
if (argc < 4) return usage();
xmlfile = argv[2];
read_xml(xmlfile);
write_rules("rules.dat");
return 0;
}
if (strcmp(mode, "po")==0) {
return 0;
}
return usage();
}

View File

@ -33,7 +33,6 @@
#include "spells.h"
#include "vortex.h"
#include "wormhole.h"
#include "xmlreader.h"
#include <errno.h>
#include <stdlib.h>
@ -80,7 +79,6 @@ void game_init(void)
register_weapons();
register_xerewards();
register_xmlreader();
register_attributes();
register_gmcmd();

View File

@ -55,7 +55,6 @@
#include "listbox.h"
#include "wormhole.h"
#include "teleport.h"
#include "xmlreader.h"
#include <storage.h>
#include <lua.h>

View File

@ -39,7 +39,6 @@ without prior permission by the authors of Eressea.
#include "util/path.h"
#include "util/pofile.h"
#include "util/strings.h"
#include "util/xml.h"
/* game modules */
#include "direction.h"
@ -47,9 +46,7 @@ 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>
@ -1017,14 +1014,7 @@ static int include_xml(const char *uri) {
char name[PATH_MAX];
const char *filename = uri_to_file(uri, name, sizeof(name));
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);
}
@ -1058,7 +1048,7 @@ static int include_po(const char *uri) {
if (lang) {
int err = pofile_read(filename, add_po_string, lang);
if (err < 0) {
log_error("could not parse XML from %s", uri);
log_error("could not parse translations from %s", uri);
}
return err;
}

View File

@ -60,7 +60,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/log.h>
#include <util/parser.h>
#include <util/resolve.h>
#include <util/xml.h>
/* from libc */
#include <assert.h>

View File

@ -66,16 +66,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/strings.h>
#include <util/translation.h>
#include <util/umlaut.h>
#include <util/xml.h>
#include "donations.h"
#include "guard.h"
#include "prefix.h"
/* libxml includes */
#include <libxml/tree.h>
#include <libxml/xpath.h>
/* external libraries */
#include <iniparser.h>
#include <critbit.h>
@ -559,7 +554,6 @@ void kernel_done(void)
/* calling this function releases memory assigned to static variables, etc.
* calling it is optional, e.g. a release server will most likely not do it.
*/
xml_done();
attrib_done();
item_done();
message_done();

View File

@ -42,7 +42,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/log.h>
#include <util/strings.h>
#include <util/umlaut.h>
#include <util/xml.h>
#include <storage.h>
#include <selist.h>

View File

@ -26,7 +26,6 @@
#include "randenc.h"
#include "monsters.h"
#include "teleport.h"
#include "xmlreader.h"
/* triggers includes */
#include <triggers/changefaction.h>

View File

@ -28,7 +28,6 @@ log.test.c
umlaut.test.c
unicode.test.c
variant.test.c
# xml.test.c
)
SET(_FILES
@ -59,7 +58,6 @@ translation.c
umlaut.c
unicode.c
variant.c
xml.c
)
FOREACH(_FILE ${_FILES})

View File

@ -1,131 +0,0 @@
/*
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
+-------------------+ Stefan Reich <reich@halbling.de>
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
#include <platform.h>
#include "xml.h"
/* util includes */
#include "log.h"
#include "assert.h"
#include <libxml/catalog.h>
#include <libxml/xmlstring.h>
/* libc includes */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int xml_ivalue(xmlNodePtr node, const char *name, int dflt)
{
int i = dflt;
xmlChar *propValue = xmlGetProp(node, BAD_CAST name);
if (propValue != NULL) {
i = atoi((const char *)propValue);
xmlFree(propValue);
}
return i;
}
bool xml_bvalue(xmlNodePtr node, const char *name, bool dflt)
{
bool result = dflt;
xmlChar *propValue = xmlGetProp(node, BAD_CAST name);
if (propValue != NULL) {
if (strcmp((const char *)propValue, "no") == 0)
result = false;
else if (strcmp((const char *)propValue, "yes") == 0)
result = true;
else if (strcmp((const char *)propValue, "false") == 0)
result = false;
else if (strcmp((const char *)propValue, "true") == 0)
result = true;
else if (strcmp((const char *)propValue, "1") == 0) {
log_warning("bool value is '1': %s::%s\n", node->name, name);
result = true;
}
else if (strcmp((const char *)propValue, "0") == 0) {
log_warning("bool value is '0': %s::%s\n", node->name, name);
result = false;
}
xmlFree(propValue);
}
return result;
}
double xml_fvalue(xmlNodePtr node, const char *name, double dflt)
{
double result = dflt;
xmlChar *propValue = xmlGetProp(node, BAD_CAST name);
if (propValue != NULL) {
result = atof((const char *)propValue);
xmlFree(propValue);
}
return result;
}
/* new xml functions */
/* libxml includes */
#include <libxml/tree.h>
#include <libxml/parser.h>
typedef struct xml_reader {
struct xml_reader *next;
xml_callback callback;
} xml_reader;
static xml_reader *xmlReaders;
void xml_done(void) {
xml_reader ** xrp = &xmlReaders;
while (*xrp) {
xml_reader *xr = *xrp;
*xrp = xr->next;
free(xr);
}
}
void xml_register_callback(xml_callback callback)
{
xml_reader *reader = (xml_reader *)malloc(sizeof(xml_reader));
xml_reader **insert = &xmlReaders;
assert_alloc(reader);
reader->callback = callback;
reader->next = NULL;
while (*insert)
insert = &(*insert)->next;
*insert = reader;
}
int read_xml(const char *filename)
{
xml_reader *reader = xmlReaders;
xmlDocPtr doc;
int results = 0;
doc = xmlReadFile(filename, NULL, XML_PARSE_NONET | XML_PARSE_PEDANTIC | XML_PARSE_COMPACT);
if (doc == NULL) {
log_error("could not open '%s'\n", filename);
return -1;
}
while (reader != NULL) {
int i = reader->callback(doc);
if (i < 0) {
return i;
}
results += i;
reader = reader->next;
}
xmlFreeDoc(doc);
return (results > 0) ? 0 : -1;
}

View File

@ -1,39 +0,0 @@
/*
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
+-------------------+ Stefan Reich <reich@halbling.de>
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
#ifndef H_UTIL_XML
#define H_UTIL_XML
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* new xml functions: */
#include <libxml/tree.h>
typedef int (*xml_callback) (xmlDocPtr);
void xml_register_callback(xml_callback callback);
double xml_fvalue(xmlNodePtr node, const char *name, double dflt);
int xml_ivalue(xmlNodePtr node, const char *name, int dflt);
bool xml_bvalue(xmlNodePtr node, const char *name, bool dflt);
void xml_done(void);
int read_xml(const char *filename);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
/*
+-------------------+
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
| (c) 1998 - 2007 | Katja Zedel <katze@felidae.kn-bremen.de>
| | Henning Peters <faroul@beyond.kn-bremen.de>
+-------------------+
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
#ifndef H_KRNL_XMLREADER_H
#define H_KRNL_XMLREADER_H
struct spell;
#ifdef __cplusplus
extern "C" {
#endif
extern void register_xmlreader(void);
/* game-specific callbacks */
extern void(*set_spelldata_cb) (struct spell * sp);
#ifdef __cplusplus
}
#endif
#endif