diff --git a/configure.ac b/configure.ac index 12014472..ecb6000e 100644 --- a/configure.ac +++ b/configure.ac @@ -110,7 +110,7 @@ FORK_FUNC_REQUIRE([COMMON], [GNU libunistring], [LIBUNISTRING], [unistring], FORK_MODULES_CHECK([FORKED], [ZLIB], [zlib], [deflate], [zlib.h]) FORK_MODULES_CHECK([FORKED], [CONFUSE], [libconfuse], [cfg_init], [confuse.h]) FORK_MODULES_CHECK([FORKED], [MINIXML], [mxml], [mxmlNewElement], [mxml.h], - [AC_CHECK_FUNCS([mxmlGetOpaque])]) + [AC_CHECK_FUNCS([mxmlGetOpaque] [mxmlGetText] [mxmlGetType] [mxmlGetFirstChild])]) dnl SQLite3 requires extra checks FORK_MODULES_CHECK([COMMON], [SQLITE3], [sqlite3 >= 3.5.0], diff --git a/src/Makefile.am b/src/Makefile.am index 1906b50f..a9eb2e4b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -118,7 +118,7 @@ forked_daapd_SOURCES = main.c \ $(MPD_SRC) \ listener.c listener.h \ commands.c commands.h \ - ffmpeg-compat.h \ + ffmpeg-compat.h mxml-compat.h \ $(GPERF_SRC) \ $(ANTLR_SRC) diff --git a/src/inputs/pipe.c b/src/inputs/pipe.c index 8707fdf4..f180fe11 100644 --- a/src/inputs/pipe.c +++ b/src/inputs/pipe.c @@ -47,6 +47,7 @@ #include #include +#include "input.h" #include "misc.h" #include "logger.h" #include "db.h" @@ -54,7 +55,7 @@ #include "listener.h" #include "player.h" #include "worker.h" -#include "input.h" +#include "mxml-compat.h" // Maximum number of pipes to watch for data #define PIPE_MAX_WATCH 4 diff --git a/src/lastfm.c b/src/lastfm.c index 1d81cd39..cc8fc077 100644 --- a/src/lastfm.c +++ b/src/lastfm.c @@ -35,6 +35,8 @@ #include #include +#include "mxml-compat.h" + #include "db.h" #include "lastfm.h" #include "logger.h" @@ -215,24 +217,6 @@ param_sign(struct keyval *kv) return ret; } -/* For compability with mxml 2.6 */ -#ifndef HAVE_MXMLGETOPAQUE -const char * /* O - Opaque string or NULL */ -mxmlGetOpaque(mxml_node_t *node) /* I - Node to get */ -{ - if (!node) - return (NULL); - - if (node->type == MXML_OPAQUE) - return (node->value.opaque); - else if (node->type == MXML_ELEMENT && - node->child && - node->child->type == MXML_OPAQUE) - return (node->child->value.opaque); - else - return (NULL); -} -#endif /* --------------------------------- MAIN --------------------------------- */ diff --git a/src/mxml-compat.h b/src/mxml-compat.h new file mode 100644 index 00000000..e9e4e9e9 --- /dev/null +++ b/src/mxml-compat.h @@ -0,0 +1,58 @@ +#ifndef __MXML_COMPAT_H__ +#define __MXML_COMPAT_H__ + +/* For compability with mxml 2.6 */ +#ifndef HAVE_MXMLGETTEXT +static const char * /* O - Text string or NULL */ +mxmlGetText(mxml_node_t *node, /* I - Node to get */ + int *whitespace) /* O - 1 if string is preceded by whitespace, 0 otherwise */ +{ + if (node->type == MXML_TEXT) + return (node->value.text.string); + else if (node->type == MXML_ELEMENT && + node->child && + node->child->type == MXML_TEXT) + return (node->child->value.text.string); + else + return (NULL); +} +#endif + +#ifndef HAVE_MXMLGETOPAQUE +const char * /* O - Opaque string or NULL */ +mxmlGetOpaque(mxml_node_t *node) /* I - Node to get */ +{ + if (!node) + return (NULL); + + if (node->type == MXML_OPAQUE) + return (node->value.opaque); + else if (node->type == MXML_ELEMENT && + node->child && + node->child->type == MXML_OPAQUE) + return (node->child->value.opaque); + else + return (NULL); +} +#endif + +#ifndef HAVE_MXMLGETFIRSTCHILD +static mxml_node_t * /* O - First child or NULL */ +mxmlGetFirstChild(mxml_node_t *node) /* I - Node to get */ +{ + if (!node || node->type != MXML_ELEMENT) + return (NULL); + + return (node->child); +} +#endif + +#ifndef HAVE_MXMLGETTYPE +static mxml_type_t /* O - Type of node */ +mxmlGetType(mxml_node_t *node) /* I - Node to get */ +{ + return (node->type); +} +#endif + +#endif /* !__MXML_COMPAT_H__ */