summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac1
-rw-r--r--doc/man/en/Makefile.am2
-rw-r--r--doc/man/en/xine-config.11
-rw-r--r--doc/man/en/xine-list.1.in9
-rw-r--r--doc/man/en/xine.52
-rw-r--r--src/Makefile.am1
-rw-r--r--src/combined/ffmpeg/ff_video_decoder.c3
-rw-r--r--src/demuxers/demux_asf.c9
-rw-r--r--src/demuxers/demux_flac.c3
-rw-r--r--src/demuxers/demux_real.c3
-rw-r--r--src/demuxers/demux_tta.c2
-rw-r--r--src/input/input_dvb.c2
-rw-r--r--src/input/libdvdnav/dvd_reader.c2
-rw-r--r--src/libspucmml/xine_cmml_decoder.c8
-rw-r--r--src/libspuhdmv/Makefile.am9
-rw-r--r--src/xine-engine/alphablend.c4
-rw-r--r--src/xine-engine/scratch.c2
-rw-r--r--src/xine-engine/scratch.h5
-rw-r--r--src/xine-utils/monitor.c46
-rw-r--r--src/xine-utils/xmllexer.c139
-rw-r--r--src/xine-utils/xmllexer.h25
-rw-r--r--src/xine-utils/xmlparser.c45
-rw-r--r--src/xine-utils/xmlparser.h17
24 files changed, 220 insertions, 124 deletions
diff --git a/ChangeLog b/ChangeLog
index 0dccfbb78..f8ba8a1e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,10 @@ xine-lib (1.1.17) 2009-??-??
* Fixed int-to-float conversion in the JACK output plugin.
* Work around MOD files with reported length == 0.
* Reworked Matroska demuxer. Now reads files created by mkvmerge 2.7.0.
+ * Support BluRay/HDMV streams & subtitles.
+ * The XML parser & lexer code now has re-entrancy.
+ * Fixed a bug which prevented "dvb://" (no channel specified) working with
+ the default configuration.
xine-lib (1.1.16.3) 2009-04-03
* Security fixes:
diff --git a/configure.ac b/configure.ac
index 5e87d63e0..c9a8557df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2783,6 +2783,7 @@ src/libspudec/Makefile
src/libspucc/Makefile
src/libspucmml/Makefile
src/libspudvb/Makefile
+src/libspuhdmv/Makefile
src/libsputext/Makefile
src/libw32dll/Makefile
src/libw32dll/wine/Makefile
diff --git a/doc/man/en/Makefile.am b/doc/man/en/Makefile.am
index 9fe87cc11..c8d616c35 100644
--- a/doc/man/en/Makefile.am
+++ b/doc/man/en/Makefile.am
@@ -10,4 +10,4 @@ DISTCLEANFILES = $(DYNAMICMANS)
EXTRA_DIST = $(STATICMANS) xine-list.1.in
xine-list-@XINE_SERIES@.1: xine-list.1.in
- (echo '.ds xl xine\-list\-@XINE_SERIES@'; cat $<) >$@
+ $(SED) -e 's/@XL@/xine\-list\-@XINE_SERIES@/' $< >$@
diff --git a/doc/man/en/xine-config.1 b/doc/man/en/xine-config.1
index 207dc2dea..3fe828166 100644
--- a/doc/man/en/xine-config.1
+++ b/doc/man/en/xine-config.1
@@ -21,7 +21,6 @@ Finally, it's also used internally
by the .m4 macros for GNU autoconf that are included with \fIxine-lib\fP.
.
.SH OPTIONS
-.l
\fIxine\-config\fP accepts the following options:
.TP 8
.B \-\-version
diff --git a/doc/man/en/xine-list.1.in b/doc/man/en/xine-list.1.in
index e159852c8..558b44df0 100644
--- a/doc/man/en/xine-list.1.in
+++ b/doc/man/en/xine-list.1.in
@@ -1,18 +1,17 @@
.TH XINE 1 2001-08-28 "The xine project"
.SH NAME
-\*(xl - get supported filetype information from xine-lib
+@XL@ - get supported filetype information from xine-lib
.SH SYNOPSIS
-.B \*(xl
+.B @XL@
[\fPoptions...\fI]
.SH DESCRIPTION
.PP
-\fI\*(xl\fP is a tool that is used to list the MIME type and filename
+\fI@XL@\fP is a tool that is used to list the MIME type and filename
extension information known and supported by the installed \fIxine-lib\fP.
It is of use in filling in MIME information in front ends' desktop files.
.
.SH OPTIONS
-.l
-\fIxine\-list\fP accepts the following options:
+\fI@XL@\fP accepts the following options:
.TP 8
.B \-m
.B \-\-mime\-types
diff --git a/doc/man/en/xine.5 b/doc/man/en/xine.5
index eba55aef5..195fb1596 100644
--- a/doc/man/en/xine.5
+++ b/doc/man/en/xine.5
@@ -98,7 +98,7 @@ above are available with stock libxine.
provided\fP - from a shell, you can normally use \fB"$PWD/file"\fP or
\fB"$(pwd)/file"\fP or \fB"\`pwd\`/file"\fP if the file is in the current
directory. (Which one depends on your shell; all three work in bash. Also,
-certain characters need to be encoded.)
+normal URL encoding rules apply; `%', in particular, must be encoded as `%25'.)
As of xine-lib 1.1.3, the DVD title number may be 0 (select navigation) and
the chapter number may be 0 (full title).
diff --git a/src/Makefile.am b/src/Makefile.am
index 249bbc2b6..5d21a97eb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,6 +17,7 @@ SUBDIRS = \
libspucc \
libspucmml \
libspudvb \
+ libspuhdmv \
libsputext \
libdts \
libmad \
diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c
index 2742e3f2e..60f2c5d9c 100644
--- a/src/combined/ffmpeg/ff_video_decoder.c
+++ b/src/combined/ffmpeg/ff_video_decoder.c
@@ -1194,7 +1194,8 @@ static void ff_handle_buffer (ff_video_decoder_t *this, buf_element_t *buf) {
if (this->size == 0) {
/* take over pts when we are about to buffer a frame */
this->av_frame->reordered_opaque = ff_tag_pts(this, this->pts);
- this->context->reordered_opaque = ff_tag_pts(this, this->pts);
+ if (this->context) /* shouldn't be NULL */
+ this->context->reordered_opaque = ff_tag_pts(this, this->pts);
this->pts = 0;
}
#endif /* AVCODEC_HAS_REORDERED_OPAQUE */
diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c
index d79782026..6c9ea631c 100644
--- a/src/demuxers/demux_asf.c
+++ b/src/demuxers/demux_asf.c
@@ -1544,6 +1544,7 @@ static int demux_asf_parse_asx_references( demux_asf_t *this) {
int buf_used = 0;
int len;
xml_node_t *xml_tree, *asx_entry, *asx_ref;
+ xml_parser_t *xml_parser;
int result;
@@ -1566,9 +1567,13 @@ static int demux_asf_parse_asx_references( demux_asf_t *this) {
if(buf_used)
buf[buf_used] = '\0';
- xml_parser_init(buf, buf_used, XML_PARSER_CASE_INSENSITIVE);
- if((result = xml_parser_build_tree(&xml_tree)) != XML_PARSER_OK)
+ xml_parser = xml_parser_init_r(buf, buf_used, XML_PARSER_CASE_INSENSITIVE);
+ if((result = xml_parser_build_tree_r(xml_parser, &xml_tree)) != XML_PARSER_OK) {
+ xml_parser_finalize_r(xml_parser);
goto failure;
+ }
+
+ xml_parser_finalize_r(xml_parser);
if(!strcasecmp(xml_tree->name, "ASX")) {
/* Attributes: VERSION, PREVIEWMODE, BANNERBAR
diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c
index c14536040..c4132b767 100644
--- a/src/demuxers/demux_flac.c
+++ b/src/demuxers/demux_flac.c
@@ -33,6 +33,9 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
#define LOG_MODULE "demux_flac"
#define LOG_VERBOSE
diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c
index 8f1e4f539..774c74e2c 100644
--- a/src/demuxers/demux_real.c
+++ b/src/demuxers/demux_real.c
@@ -42,6 +42,9 @@
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
#define LOG_MODULE "demux_real"
#define LOG_VERBOSE
diff --git a/src/demuxers/demux_tta.c b/src/demuxers/demux_tta.c
index 24a983157..7853c8182 100644
--- a/src/demuxers/demux_tta.c
+++ b/src/demuxers/demux_tta.c
@@ -58,7 +58,7 @@ typedef struct {
uint32_t samplerate;
uint32_t data_length;
uint32_t crc32;
- } __attribute__((__packed__)) tta;
+ } XINE_PACKED tta;
uint8_t buffer[22]; /* This is the size of the header */
} header;
} demux_tta_t;
diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c
index 5060757e4..54c40087e 100644
--- a/src/input/input_dvb.c
+++ b/src/input/input_dvb.c
@@ -2875,6 +2875,8 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
if (lastchannel.num_value) {
if (xine_config_lookup_entry(this->class->xine, "media.dvb.last_channel", &lastchannel)){
this->channel = lastchannel.num_value -1;
+ if (this->channel < 0 || this->channel >= num_channels)
+ this->channel = 0; /* out of range? default */
}else{
xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: invalid channel specification, defaulting to channel 0\n"));
this->channel = 0;
diff --git a/src/input/libdvdnav/dvd_reader.c b/src/input/libdvdnav/dvd_reader.c
index eff1977fc..1e0d3016b 100644
--- a/src/input/libdvdnav/dvd_reader.c
+++ b/src/input/libdvdnav/dvd_reader.c
@@ -30,7 +30,9 @@
#include <string.h>
#include <unistd.h>
#include <limits.h>
+#ifdef HAVE_DIRENT_H
#include <dirent.h>
+#endif
#ifndef HAVE_GETTIMEOFDAY
# ifdef WIN32
diff --git a/src/libspucmml/xine_cmml_decoder.c b/src/libspucmml/xine_cmml_decoder.c
index c3da1b0fd..9cd446988 100644
--- a/src/libspucmml/xine_cmml_decoder.c
+++ b/src/libspucmml/xine_cmml_decoder.c
@@ -239,6 +239,7 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
spucmml_decoder_t *this = (spucmml_decoder_t *) this_gen;
+ xml_parser_t *xml_parser;
xml_node_t *packet_xml_root;
char * anchor_text = NULL;
@@ -248,12 +249,15 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
/* parse the CMML */
- xml_parser_init (str, strlen (str), XML_PARSER_CASE_INSENSITIVE);
- if (xml_parser_build_tree(&packet_xml_root) != XML_PARSER_OK) {
+ xml_parser = xml_parser_init_r (str, strlen (str), XML_PARSER_CASE_INSENSITIVE);
+ if (xml_parser_build_tree_r(xml_parser, &packet_xml_root) != XML_PARSER_OK) {
lprintf ("warning: invalid XML packet detected in CMML track\n");
+ xml_parser_finalize_r(xml_parser);
return;
}
+ xml_parser_finalize_r(xml_parser);
+
if (strcasecmp(packet_xml_root->name, "head") == 0) {
/* found a <head>...</head> packet: need to parse the title */
diff --git a/src/libspuhdmv/Makefile.am b/src/libspuhdmv/Makefile.am
new file mode 100644
index 000000000..15a029f8a
--- /dev/null
+++ b/src/libspuhdmv/Makefile.am
@@ -0,0 +1,9 @@
+include $(top_builddir)/misc/Makefile.plugins
+include $(top_srcdir)/misc/Makefile.common
+
+xineplug_LTLIBRARIES = xineplug_decode_spuhdmv.la
+
+xineplug_decode_spuhdmv_la_SOURCES = xine_hdmv_decoder.c
+xineplug_decode_spuhdmv_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL)
+xineplug_decode_spuhdmv_la_CFLAGS = $(VISIBILITY_FLAG)
+xineplug_decode_spuhdmv_la_LDFLAGS = $(xineplug_ldflags)
diff --git a/src/xine-engine/alphablend.c b/src/xine-engine/alphablend.c
index a9b015209..1dcd47eb7 100644
--- a/src/xine-engine/alphablend.c
+++ b/src/xine-engine/alphablend.c
@@ -1108,7 +1108,7 @@ static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
static uint8_t *(*blend_yuv_grow_extra_data(alphablend_t *extra_data, int osd_width))[ 3 ][ 2 ]
{
- struct __attribute__((packed)) header_s {
+ struct XINE_PACKED header_s {
int id;
int max_width;
uint8_t *data[ 3 ][ 2 ];
@@ -1550,7 +1550,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
static uint8_t *(*blend_yuy2_grow_extra_data(alphablend_t *extra_data, int osd_width))[ 3 ]
{
- struct __attribute__((packed)) header_s {
+ struct XINE_PACKED header_s {
int id;
int max_width;
uint8_t *data[ 3 ];
diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c
index 696e99ffb..980af2f71 100644
--- a/src/xine-engine/scratch.c
+++ b/src/xine-engine/scratch.c
@@ -37,7 +37,7 @@
#include "xineutils.h"
#include "scratch.h"
-static void __attribute__((__format__(__printf__, 2, 0)))
+static void XINE_FORMAT_PRINTF(2, 0)
scratch_printf (scratch_buffer_t *this, const char *format, va_list argp)
{
time_t t;
diff --git a/src/xine-engine/scratch.h b/src/xine-engine/scratch.h
index 1029276e3..c45af198f 100644
--- a/src/xine-engine/scratch.h
+++ b/src/xine-engine/scratch.h
@@ -32,10 +32,7 @@ typedef struct scratch_buffer_s scratch_buffer_t;
struct scratch_buffer_s {
- void
-#if __GNUC__ >= 3
- __attribute__((__format__(__printf__, 2, 0)))
-#endif
+ void XINE_FORMAT_PRINTF(2, 0)
(*scratch_printf) (scratch_buffer_t *this, const char *format, va_list ap);
char **(*get_content) (scratch_buffer_t *this);
diff --git a/src/xine-utils/monitor.c b/src/xine-utils/monitor.c
index 650c10f99..77280ffc6 100644
--- a/src/xine-utils/monitor.c
+++ b/src/xine-utils/monitor.c
@@ -32,41 +32,42 @@
#ifndef NDEBUG
-static long long int profiler_times[MAX_ID] ;
-static long long int profiler_start[MAX_ID] ;
-static long profiler_calls[MAX_ID] ;
-static const char *profiler_label[MAX_ID] ;
+typedef struct {
+ uint64_t p_times;
+ uint64_t p_start;
+ long p_calls;
+ const char *p_label;
+} xine_profiler_t;
+
+static xine_profiler_t profiler[MAX_ID];
void xine_profiler_init () {
- memset(profiler_times, 0, sizeof(profiler_times));
- memset(profiler_start, 0, sizeof(profiler_start));
- memset(profiler_calls, 0, sizeof(profiler_calls));
- memset(profiler_label, 0, sizeof(profiler_label));
+ memset(profiler, 0, sizeof(profiler));
}
int xine_profiler_allocate_slot (const char *label) {
int id;
- for (id = 0; id < MAX_ID && profiler_label[id] != NULL; id++)
+ for (id = 0; id < MAX_ID && profiler[id].p_label != NULL; id++)
;
if (id >= MAX_ID)
return -1;
- profiler_label[id] = label;
+ profiler[id].p_label = label;
return id;
}
#if defined(ARCH_X86_32)
-static __inline__ unsigned long long int rdtsc(void)
+static __inline__ uint64_t rdtsc(void)
{
unsigned long long int x;
__asm__ volatile ("rdtsc\n\t" : "=A" (x));
return x;
}
#elif defined(ARCH_X86_64)
-static __inline__ unsigned long long int rdtsc(void)
+static __inline__ uint64_t rdtsc(void)
{
unsigned long long int a, d;
__asm__ volatile ("rdtsc\n\t" : "=a" (a), "=d" (d));
@@ -78,7 +79,7 @@ void xine_profiler_start_count (int id) {
if ( id >= MAX_ID || id < 0 ) return;
#if defined(ARCH_X86) || defined(ARCH_X86_64)
- profiler_start[id] = rdtsc();
+ profiler[id].p_start = rdtsc();
#endif
}
@@ -86,18 +87,19 @@ void xine_profiler_stop_count (int id) {
if ( id >= MAX_ID || id < 0 ) return;
#if defined(ARCH_X86) || defined(ARCH_X86_64)
- profiler_times[id] += rdtsc() - profiler_start[id];
+ profiler[id].p_times += rdtsc() - profiler[id].p_start;
#endif
- profiler_calls[id]++;
+ profiler[id].p_calls++;
}
void xine_profiler_print_results (void) {
int i;
#if defined(ARCH_X86) || defined(ARCH_X86_64)
- static long long int cpu_speed; /* cpu cyles/usec */
+ static uint64_t cpu_speed; /* cpu cyles/usec */
+
if (!cpu_speed) {
- long long int tsc_start, tsc_end;
+ uint64_t tsc_start, tsc_end;
struct timeval tv_start, tv_end;
tsc_start = rdtsc();
@@ -119,13 +121,13 @@ void xine_profiler_print_results (void) {
"----------------------------------------------------------------------------\n",
"ID", "name", "cpu cycles", "calls", "cycles/call", "usec/call");
for (i=0; i<MAX_ID; i++) {
- if (profiler_label[i]) {
+ if (profiler[i].p_label) {
printf ("%2d: %-24.24s %12lld %9ld",
- i, profiler_label[i], profiler_times[i], profiler_calls[i]);
- if (profiler_calls[i]) {
- printf(" %12lld", profiler_times[i] / profiler_calls[i]);
+ i, profiler[i].p_label, profiler[i].p_times, profiler[i].p_calls);
+ if (profiler[i].p_calls) {
+ printf(" %12lld", profiler[i].p_times / profiler[i].p_calls);
#if defined(ARCH_X86) || defined(ARCH_X86_64)
- printf(" %9lld", profiler_times[i] / (cpu_speed * profiler_calls[i]));
+ printf(" %9lld", profiler[i].p_times / (cpu_speed * profiler[i].p_calls));
#endif
}
printf ("\n");
diff --git a/src/xine-utils/xmllexer.c b/src/xine-utils/xmllexer.c
index 08c56e88e..696c18011 100644
--- a/src/xine-utils/xmllexer.c
+++ b/src/xine-utils/xmllexer.c
@@ -50,16 +50,11 @@
#define DATA 1 /* data lex mode */
/* private global variables */
-static const char * lexbuf;
-static int lexbuf_size = 0;
-static int lexbuf_pos = 0;
-static int lex_mode = NORMAL;
-static int in_comment = 0;
-static char *lex_malloc = NULL;
+struct lexer * static_lexer;
enum utf { UTF32BE, UTF32LE, UTF16BE, UTF16LE };
-static void lex_convert (const char * buf, int size, enum utf utf)
+static void lex_convert (struct lexer * lexer, const char * buf, int size, enum utf utf)
{
char *utf8 = malloc (size * (utf >= UTF16BE ? 3 : 6) + 1);
char *bp = utf8;
@@ -91,42 +86,60 @@ static void lex_convert (const char * buf, int size, enum utf utf)
}
}
*bp = 0;
- lexbuf_size = bp - utf8;
- lexbuf = lex_malloc = realloc (utf8, lexbuf_size + 1);
+ lexer->lexbuf_size = bp - utf8;
+ lexer->lexbuf = lexer->lex_malloc = realloc (utf8, lexer->lexbuf_size + 1);
}
+/* for ABI compatibility */
void lexer_init(const char * buf, int size) {
+ if (static_lexer) {
+ lexer_finalize_r(static_lexer);
+ }
+ static_lexer = lexer_init_r(buf, size);
+}
+
+struct lexer *lexer_init_r(const char * buf, int size) {
static const char boms[] = { 0xFF, 0xFE, 0, 0, 0xFE, 0xFF },
bom_utf8[] = { 0xEF, 0xBB, 0xBF };
+ struct lexer * lexer = calloc (1, sizeof (*lexer));
- free (lex_malloc);
- lex_malloc = NULL;
-
- lexbuf = buf;
- lexbuf_size = size;
+ lexer->lexbuf = buf;
+ lexer->lexbuf_size = size;
if (size >= 4 && !memcmp (buf, boms + 2, 4))
- lex_convert (buf + 4, size - 4, UTF32BE);
+ lex_convert (lexer, buf + 4, size - 4, UTF32BE);
else if (size >= 4 && !memcmp (buf, boms, 4))
- lex_convert (buf + 4, size - 4, UTF32LE);
+ lex_convert (lexer, buf + 4, size - 4, UTF32LE);
else if (size >= 3 && !memcmp (buf, bom_utf8, 3))
{
- lexbuf += 3;
- lexbuf_size -= 3;
+ lexer->lexbuf += 3;
+ lexer->lexbuf_size -= 3;
}
else if (size >= 2 && !memcmp (buf, boms + 4, 2))
- lex_convert (buf + 2, size - 2, UTF16BE);
+ lex_convert (lexer, buf + 2, size - 2, UTF16BE);
else if (size >= 2 && !memcmp (buf, boms, 2))
- lex_convert (buf + 2, size - 2, UTF16LE);
+ lex_convert (lexer, buf + 2, size - 2, UTF16LE);
- lexbuf_pos = 0;
- lex_mode = NORMAL;
- in_comment = 0;
+ lexer->lexbuf_pos = 0;
+ lexer->lex_mode = NORMAL;
+ lexer->in_comment = 0;
lprintf("buffer length %d\n", size);
+ return lexer;
}
+void lexer_finalize_r(struct lexer * lexer)
+{
+ free(lexer->lex_malloc);
+ free(lexer);
+}
+
+/* for ABI compatibility */
int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
+ return lexer_get_token_d_r(static_lexer, _tok, _tok_size, fixed);
+}
+
+int lexer_get_token_d_r(struct lexer * lexer, char ** _tok, int * _tok_size, int fixed) {
char *tok = *_tok;
int tok_size = *_tok_size;
@@ -135,11 +148,11 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
char c;
if (tok) {
- while ((tok_pos < tok_size) && (lexbuf_pos < lexbuf_size)) {
- c = lexbuf[lexbuf_pos];
- lprintf("c=%c, state=%d, in_comment=%d\n", c, state, in_comment);
+ while ((tok_pos < tok_size) && (lexer->lexbuf_pos < lexer->lexbuf_size)) {
+ c = lexer->lexbuf[lexer->lexbuf_pos];
+ lprintf("c=%c, state=%d, in_comment=%d\n", c, state, lexer->in_comment);
- if (lex_mode == NORMAL) {
+ if (lexer->lex_mode == NORMAL) {
/* normal mode */
switch (state) {
/* init state */
@@ -172,7 +185,7 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
break;
case '/':
- if (!in_comment)
+ if (!lexer->in_comment)
state = 5;
tok[tok_pos] = c;
tok_pos++;
@@ -210,14 +223,14 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
tok_pos++;
break;
}
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
break;
/* end of line */
case 1:
if (c == '\n' || (c == '\r')) {
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok_pos++;
} else {
tok[tok_pos] = '\0';
@@ -229,7 +242,7 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
case 2:
if (c == ' ' || (c == '\t')) {
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok_pos++;
} else {
tok[tok_pos] = '\0';
@@ -242,20 +255,20 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
switch (c) {
case '/':
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok_pos++; /* FIXME */
tok[tok_pos] = '\0';
return T_M_START_2;
break;
case '!':
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok_pos++;
state = 8;
break;
case '?':
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok_pos++; /* FIXME */
tok[tok_pos] = '\0';
return T_TI_START;
@@ -269,8 +282,8 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
/* T_M_STOP_1 */
case 4:
tok[tok_pos] = '\0';
- if (!in_comment)
- lex_mode = DATA;
+ if (!lexer->in_comment)
+ lexer->lex_mode = DATA;
return T_M_STOP_1;
break;
@@ -278,11 +291,11 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
case 5:
if (c == '>') {
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok_pos++; /* FIXME */
tok[tok_pos] = '\0';
- if (!in_comment)
- lex_mode = DATA;
+ if (!lexer->in_comment)
+ lexer->lex_mode = DATA;
return T_M_STOP_2;
} else {
tok[tok_pos] = '\0';
@@ -299,7 +312,7 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
/* T_STRING */
case 7:
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
if (c == '\"') { /* " */
tok[tok_pos] = '\0'; /* FIXME */
return T_STRING;
@@ -311,22 +324,22 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
case 8:
switch (c) {
case '-':
- lexbuf_pos++;
- if (lexbuf[lexbuf_pos] == '-')
+ lexer->lexbuf_pos++;
+ if (lexer->lexbuf[lexer->lexbuf_pos] == '-')
{
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok[tok_pos++] = '-'; /* FIXME */
tok[tok_pos++] = '-';
tok[tok_pos] = '\0';
- in_comment = 1;
+ lexer->in_comment = 1;
return T_C_START;
}
break;
case 'D':
- lexbuf_pos++;
- if (strncmp(lexbuf + lexbuf_pos, "OCTYPE", 6) == 0) {
+ lexer->lexbuf_pos++;
+ if (strncmp(lexer->lexbuf + lexer->lexbuf_pos, "OCTYPE", 6) == 0) {
strncpy(tok + tok_pos, "DOCTYPE", 7); /* FIXME */
- lexbuf_pos += 6;
+ lexer->lexbuf_pos += 6;
return T_DOCTYPE_START;
} else {
return T_ERROR;
@@ -342,7 +355,7 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
case 9:
if (c == '>') {
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok_pos++; /* FIXME */
tok[tok_pos] = '\0';
return T_TI_STOP;
@@ -358,13 +371,13 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
case '-':
tok[tok_pos] = c;
tok_pos++;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
state = 11;
break;
default:
tok[tok_pos] = c;
tok_pos++;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
state = 100;
}
break;
@@ -375,21 +388,21 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
case '>':
tok[tok_pos] = c;
tok_pos++;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
tok[tok_pos] = '\0'; /* FIX ME */
if (strlen(tok) != 3) {
tok[tok_pos - 3] = '\0';
- lexbuf_pos -= 3;
+ lexer->lexbuf_pos -= 3;
return T_IDENT;
} else {
- in_comment = 0;
+ lexer->in_comment = 0;
return T_C_STOP;
}
break;
default:
tok[tok_pos] = c;
tok_pos++;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
state = 100;
}
break;
@@ -397,7 +410,7 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
/* T_STRING (single quotes) */
case 12:
tok[tok_pos] = c;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
if (c == '\'') { /* " */
tok[tok_pos] = '\0'; /* FIXME */
return T_STRING;
@@ -424,19 +437,19 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
case '?':
tok[tok_pos] = c;
tok_pos++;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
state = 9;
break;
case '-':
tok[tok_pos] = c;
tok_pos++;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
state = 10;
break;
default:
tok[tok_pos] = c;
tok_pos++;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
}
break;
default:
@@ -449,17 +462,17 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
{
case '<':
tok[tok_pos] = '\0';
- lex_mode = NORMAL;
+ lexer->lex_mode = NORMAL;
return T_DATA;
default:
tok[tok_pos] = c;
tok_pos++;
- lexbuf_pos++;
+ lexer->lexbuf_pos++;
}
}
}
lprintf ("loop done tok_pos = %d, tok_size=%d, lexbuf_pos=%d, lexbuf_size=%d\n",
- tok_pos, tok_size, lexbuf_pos, lexbuf_size);
+ tok_pos, tok_size, lexer->lexbuf_pos, lexer->lexbuf_size);
/* pb */
if (tok_pos >= tok_size) {
@@ -470,12 +483,12 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
lprintf("token buffer is too small\n");
lprintf("increasing buffer size to %d bytes\n", *_tok_size);
if (*_tok) {
- return lexer_get_token_d (_tok, _tok_size, 0);
+ return lexer_get_token_d_r (lexer, _tok, _tok_size, 0);
} else {
return T_ERROR;
}
} else {
- if (lexbuf_pos >= lexbuf_size) {
+ if (lexer->lexbuf_pos >= lexer->lexbuf_size) {
/* Terminate the current token */
tok[tok_pos] = '\0';
switch (state) {
diff --git a/src/xine-utils/xmllexer.h b/src/xine-utils/xmllexer.h
index 425d0e70a..bcea7d6b4 100644
--- a/src/xine-utils/xmllexer.h
+++ b/src/xine-utils/xmllexer.h
@@ -23,6 +23,10 @@
#ifndef XML_LEXER_H
#define XML_LEXER_H
+#ifndef XINE_DEPRECATED
+#define XINE_DEPRECATED
+#endif
+
#ifndef XINE_PROTECTED
#define XINE_PROTECTED
#endif
@@ -49,10 +53,25 @@
#define T_DOCTYPE_STOP 17 /* > */
+/* public structure */
+struct lexer
+{
+ const char * lexbuf;
+ int lexbuf_size;
+ int lexbuf_pos;
+ int lex_mode;
+ int in_comment;
+ char *lex_malloc;
+};
+
+
/* public functions */
-void lexer_init(const char * buf, int size) XINE_PROTECTED;
-int lexer_get_token_d(char ** tok, int * tok_size, int fixed) XINE_PROTECTED;
-int lexer_get_token(char * tok, int tok_size) XINE_PROTECTED;
+void lexer_init(const char * buf, int size) XINE_DEPRECATED XINE_PROTECTED;
+struct lexer *lexer_init_r(const char * buf, int size) XINE_PROTECTED;
+void lexer_finalize_r(struct lexer * lexer) XINE_PROTECTED;
+int lexer_get_token_d_r(struct lexer * lexer, char ** tok, int * tok_size, int fixed) XINE_PROTECTED;
+int lexer_get_token_d(char ** tok, int * tok_size, int fixed) XINE_DEPRECATED XINE_PROTECTED;
+int lexer_get_token(char * tok, int tok_size) XINE_DEPRECATED XINE_PROTECTED;
char *lexer_decode_entities (const char *tok) XINE_PROTECTED;
#endif
diff --git a/src/xine-utils/xmlparser.c b/src/xine-utils/xmlparser.c
index 93a707993..2e93da4e9 100644
--- a/src/xine-utils/xmlparser.c
+++ b/src/xine-utils/xmlparser.c
@@ -51,7 +51,7 @@
#define MAX_RECURSION 10
/* private global variables */
-static int xml_parser_mode;
+xml_parser_t * static_xml_parser;
/* private functions */
@@ -99,10 +99,24 @@ static void free_xml_property(xml_property_t * property) {
free(property);
}
+/* for ABI compatibility */
void xml_parser_init(const char * buf, int size, int mode) {
+ if (static_xml_parser) {
+ xml_parser_finalize_r(static_xml_parser);
+ }
+ static_xml_parser = xml_parser_init_r(buf, size, mode);
+}
+
+xml_parser_t *xml_parser_init_r(const char * buf, int size, int mode) {
+ xml_parser_t *xml_parser = malloc(sizeof(*xml_parser));
+ xml_parser->lexer = lexer_init_r(buf, size);
+ xml_parser->mode = mode;
+ return xml_parser;
+}
- lexer_init(buf, size);
- xml_parser_mode = mode;
+void xml_parser_finalize_r(xml_parser_t *xml_parser) {
+ lexer_finalize_r(xml_parser->lexer);
+ free(xml_parser);
}
static void xml_parser_free_props(xml_property_t *current_property) {
@@ -157,9 +171,9 @@ void xml_parser_free_tree(xml_node_t *current_node) {
#define STATE_NODE 1
#define STATE_COMMENT 7
-static int xml_parser_get_node (xml_node_t *current_node, char *root_name, int rec);
+static int xml_parser_get_node (xml_parser_t *xml_parser, xml_node_t *current_node, char *root_name, int rec);
-static int _xml_parser_get_node (char ** token_buffer, int * token_buffer_size,
+static int _xml_parser_get_node (xml_parser_t *xml_parser, char ** token_buffer, int * token_buffer_size,
char ** pname_buffer, int * pname_buffer_size,
char ** nname_buffer, int * nname_buffer_size,
xml_node_t *current_node, char *root_name, int rec) {
@@ -179,7 +193,7 @@ static int _xml_parser_get_node (char ** token_buffer, int * token_buffer_size,
memset (tok, 0, *token_buffer_size);
- while ((bypass_get_token) || (res = lexer_get_token_d(token_buffer, token_buffer_size, 0)) != T_ERROR) {
+ while ((bypass_get_token) || (res = lexer_get_token_d_r(xml_parser->lexer, token_buffer, token_buffer_size, 0)) != T_ERROR) {
tok = *token_buffer;
bypass_get_token = 0;
lprintf("info: %d - %d : '%s'\n", state, res, tok);
@@ -232,7 +246,7 @@ static int _xml_parser_get_node (char ** token_buffer, int * token_buffer_size,
current_property = NULL;
/* save node name */
- if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) {
+ if (xml_parser->mode == XML_PARSER_CASE_INSENSITIVE) {
strtoupper(tok);
}
/* make sure the buffer for the node name is big enough */
@@ -267,7 +281,7 @@ static int _xml_parser_get_node (char ** token_buffer, int * token_buffer_size,
/* set node propertys */
subtree->props = properties;
lprintf("info: rec %d new subtree %s\n", rec, node_name);
- parse_res = xml_parser_get_node(subtree, node_name, rec + 1);
+ parse_res = xml_parser_get_node(xml_parser, subtree, node_name, rec + 1);
if (parse_res != 0) {
return parse_res;
}
@@ -304,7 +318,7 @@ static int _xml_parser_get_node (char ** token_buffer, int * token_buffer_size,
break;
case (T_IDENT):
/* save property name */
- if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) {
+ if (xml_parser->mode == XML_PARSER_CASE_INSENSITIVE) {
strtoupper(tok);
}
/* make sure the buffer for the property name is big enough */
@@ -328,7 +342,7 @@ static int _xml_parser_get_node (char ** token_buffer, int * token_buffer_size,
switch (res) {
case (T_IDENT):
/* must be equal to root_name */
- if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) {
+ if (xml_parser->mode == XML_PARSER_CASE_INSENSITIVE) {
strtoupper(tok);
}
if (strcmp(tok, root_name) == 0) {
@@ -474,7 +488,7 @@ static int _xml_parser_get_node (char ** token_buffer, int * token_buffer_size,
}
}
-static int xml_parser_get_node (xml_node_t *current_node, char *root_name, int rec)
+static int xml_parser_get_node (xml_parser_t *xml_parser, xml_node_t *current_node, char *root_name, int rec)
{
int res = 0;
int token_buffer_size = TOKEN_SIZE;
@@ -484,7 +498,7 @@ static int xml_parser_get_node (xml_node_t *current_node, char *root_name, int r
char *pname_buffer = calloc(1, pname_buffer_size);
char *nname_buffer = calloc(1, nname_buffer_size);
- res = _xml_parser_get_node(&token_buffer, &token_buffer_size,
+ res = _xml_parser_get_node(xml_parser, &token_buffer, &token_buffer_size,
&pname_buffer, &pname_buffer_size,
&nname_buffer, &nname_buffer_size,
current_node, root_name, rec);
@@ -496,12 +510,17 @@ static int xml_parser_get_node (xml_node_t *current_node, char *root_name, int r
return res;
}
+/* for ABI compatibility */
int xml_parser_build_tree(xml_node_t **root_node) {
+ return xml_parser_build_tree_r(static_xml_parser, root_node);
+}
+
+int xml_parser_build_tree_r(xml_parser_t *xml_parser, xml_node_t **root_node) {
xml_node_t *tmp_node;
int res;
tmp_node = new_xml_node();
- res = xml_parser_get_node(tmp_node, "", 0);
+ res = xml_parser_get_node(xml_parser, tmp_node, "", 0);
if ((tmp_node->child) && (!tmp_node->child->next)) {
*root_node = tmp_node->child;
free_xml_node(tmp_node);
diff --git a/src/xine-utils/xmlparser.h b/src/xine-utils/xmlparser.h
index 98695a756..fe94e4b76 100644
--- a/src/xine-utils/xmlparser.h
+++ b/src/xine-utils/xmlparser.h
@@ -22,6 +22,10 @@
#ifndef XML_PARSER_H
#define XML_PARSER_H
+#ifndef XINE_DEPRECATED
+#define XINE_DEPRECATED
+#endif
+
#ifndef XINE_PROTECTED
#define XINE_PROTECTED
#endif
@@ -51,9 +55,18 @@ typedef struct xml_node_s {
struct xml_node_s *next;
} xml_node_t;
-void xml_parser_init(const char * buf, int size, int mode) XINE_PROTECTED;
+/* xml parser */
+typedef struct xml_parser_s {
+ struct lexer *lexer;
+ int mode;
+} xml_parser_t;
+
+void xml_parser_init(const char * buf, int size, int mode) XINE_DEPRECATED XINE_PROTECTED;
+xml_parser_t *xml_parser_init_r(const char * buf, int size, int mode) XINE_PROTECTED;
+void xml_parser_finalize_r(xml_parser_t *xml_parser) XINE_PROTECTED;
-int xml_parser_build_tree(xml_node_t **root_node) XINE_PROTECTED;
+int xml_parser_build_tree(xml_node_t **root_node) XINE_DEPRECATED XINE_PROTECTED;
+int xml_parser_build_tree_r(xml_parser_t *xml_parser, xml_node_t **root_node) XINE_PROTECTED;
void xml_parser_free_tree(xml_node_t *root_node) XINE_PROTECTED;