Skip to content

Commit

Permalink
Add custom xml parser. Use as fallback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Jan 2, 2013
1 parent 49709b9 commit 276b588
Show file tree
Hide file tree
Showing 17 changed files with 623 additions and 58 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ OBJ = retroarch.o \
fifo_buffer.o \
compat/compat.o \
audio/null.o \
cheats.o \
gfx/null.o \
conf/config_file.o \
input/null.o \
Expand Down Expand Up @@ -238,10 +239,11 @@ ifeq ($(HAVE_CG), 1)
endif
endif

ifeq ($(HAVE_XML), 1)
OBJ += cheats.o
LIBS += $(XML_LIBS)
DEFINES += $(XML_CFLAGS)
ifeq ($(HAVE_LIBXML2), 1)
LIBS += $(LIBXML2_LIBS)
DEFINES += $(LIBXML2_CFLAGS)
else
OBJ += compat/rxml/rxml.o
endif

ifeq ($(HAVE_DYLIB), 1)
Expand Down Expand Up @@ -380,6 +382,7 @@ clean:
rm -f gfx/py_state/*.o
rm -f gfx/scaler/*.o
rm -f compat/*.o
rm -f compat/rxml/*.o
rm -f record/*.o
rm -f input/*.o
rm -f tools/*.o
Expand Down
15 changes: 9 additions & 6 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ OBJ = retroarch.o \
patch.o \
compat/compat.o \
screenshot.o \
cheats.o \
audio/utils.o \
audio/null.o \
input/null.o \
Expand Down Expand Up @@ -60,7 +61,7 @@ DYNAMIC = 1
ifeq ($(SLIM),)
HAVE_SDL = 1
HAVE_SDL_IMAGE = 1
HAVE_XML = 1
HAVE_LIBXML2 = 1
HAVE_FREETYPE = 1
HAVE_RSOUND = 1
HAVE_FBO = 1
Expand Down Expand Up @@ -103,8 +104,8 @@ ifeq ($(HAVE_THREADS), 1)
endif

ifeq ($(HAVE_OPENGL), 1)
OBJ += gfx/gl.o gfx/math/matrix.o gfx/fonts/gl_font.o gfx/fonts/gl_raster_font.o gfx/gfx_context.o gfx/context/wgl_ctx.o
DEFINES += -DHAVE_OPENGL -DHAVE_OVERLAY
OBJ += gfx/gl.o gfx/math/matrix.o gfx/fonts/gl_font.o gfx/fonts/gl_raster_font.o gfx/gfx_context.o gfx/context/wgl_ctx.o gfx/shader_glsl.o
DEFINES += -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_GLSL
LIBS += -lopengl32 -lgdi32
endif

Expand Down Expand Up @@ -145,10 +146,11 @@ ifeq ($(HAVE_RSOUND), 1)
LIBS += -lrsound
endif

ifeq ($(HAVE_XML), 1)
OBJ += gfx/shader_glsl.o cheats.o
DEFINES += -Ilibxml2 -DHAVE_XML -DHAVE_GLSL
ifeq ($(HAVE_LIBXML2), 1)
DEFINES += -Ilibxml2 -DHAVE_LIBXML2 -DHAVE_GLSL
LIBS += -lxml2 -liconv
else
OBJ += compat/rxml/rxml.o
endif

ifeq ($(HAVE_DYLIB), 1)
Expand Down Expand Up @@ -258,6 +260,7 @@ clean:
rm -f audio/*.o
rm -f audio/xaudio-c/*.o
rm -f compat/*.o
rm -f compat/rxml/*.o
rm -f conf/*.o
rm -f gfx/scaler/*.o
rm -f gfx/*.o
Expand Down
7 changes: 7 additions & 0 deletions cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@
#include <stddef.h>
#include <string.h>

#ifdef HAVE_LIBXML2
#include <libxml/parser.h>
#include <libxml/tree.h>
#else
#define RXML_LIBXML2_COMPAT
#include "compat/rxml/rxml.h"
#endif

struct cheat
{
Expand Down Expand Up @@ -252,11 +257,13 @@ cheat_manager_t *cheat_manager_new(const char *path)
goto error;
}

#ifdef HAVE_LIBXML2
if (ctx->valid == 0)
{
RARCH_ERR("Cannot validate XML file: %s\n", path);
goto error;
}
#endif

head = xmlDocGetRootElement(doc);
for (cur = head; cur; cur = cur->next)
Expand Down
20 changes: 20 additions & 0 deletions compat/rxml/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
TARGET := rxml

SOURCES := $(wildcard *.c)
OBJS := $(SOURCES:.c=.o)

CFLAGS += -Wall -pedantic -std=gnu99 -O3 -g

all: $(TARGET)

%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)

$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)

clean:
rm -f $(TARGET) $(OBJS)

.PHONY: clean

Loading

0 comments on commit 276b588

Please sign in to comment.