summaryrefslogtreecommitdiff
path: root/src/xine-engine/xine.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-engine/xine.c')
-rw-r--r--src/xine-engine/xine.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 17ea5d679..6d6e05b19 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -35,6 +35,7 @@
#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
+#include <ctype.h>
#if defined (__linux__) || defined (__GLIBC__)
#include <endian.h>
#elif defined (__FreeBSD__)
@@ -819,9 +820,9 @@ void _x_flush_events_queues (xine_stream_t *stream) {
pthread_mutex_unlock (&stream->event_queues_lock);
}
-static int open_internal (xine_stream_t *stream, const char *mrl) {
+/*static*/ int open_internal (xine_stream_t *stream, const char *mrl) {
- const char *stream_setup;
+ const char *stream_setup = NULL;
int no_cache = 0;
if (!mrl) {
@@ -846,13 +847,19 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
* look for a stream_setup in MRL and try finding an input plugin
*/
- stream_setup = mrl;
- /* look for the next '#' or try the whole MRL, if none is found */
- while (*stream_setup &&
- (stream_setup = (strchr(stream_setup, '#') ? strchr(stream_setup, '#') : strlen(mrl) + mrl))) {
- char *input_source = (char *)malloc(stream_setup - mrl + 1);
- memcpy(input_source, mrl, stream_setup - mrl);
- input_source[stream_setup - mrl] = '\0';
+ if (isalpha (*mrl))
+ {
+ stream_setup = mrl + 1;
+ while (isalnum (*stream_setup) || *stream_setup == '+' || *stream_setup == '-' || *stream_setup == '.')
+ ++stream_setup;
+ if (stream_setup[0] == ':' && stream_setup[1] == '/')
+ stream_setup = strchr (mrl, '#');
+ else
+ stream_setup = NULL;
+ }
+
+ {
+ char *input_source = strndup (mrl, stream_setup ? stream_setup - mrl : strlen (mrl));
/*
* find an input plugin
@@ -872,7 +879,6 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
res = (stream->input_plugin->open) (stream->input_plugin);
switch(res) {
case 1: /* Open successfull */
- free(input_source);
break;
case -1: /* Open unsuccessfull, but correct plugin */
free(input_source);
@@ -885,14 +891,9 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
stream->input_plugin = NULL;
stream->err = XINE_ERROR_INPUT_FAILED;
}
- if ( res ) break;
}
free(input_source);
- /* if we fail when passing up to the first '#' to the input plugins,
- * maybe the user stated a (invalid) MRL, with a '#' belonging to the
- * input source -> look for the next '#' and try again */
- if (*stream_setup) stream_setup++;
}
if (!stream->input_plugin) {
@@ -902,7 +903,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
return 0;
}
- if (*stream_setup) {
+ if (stream_setup) {
while (stream_setup && *stream_setup && *(++stream_setup)) {
if (strncasecmp(stream_setup, "demux", 5) == 0) {
@@ -1640,9 +1641,8 @@ static void config_demux_strategy_cb (void *this_gen, xine_cfg_entry_t *entry) {
static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) {
xine_t *this = (xine_t *)this_gen;
- char *homedir_trail_slash;
+ char homedir_trail_slash[strlen(xine_get_homedir()) + 2];
- homedir_trail_slash = (char *)malloc(strlen(xine_get_homedir()) + 2);
sprintf(homedir_trail_slash, "%s/", xine_get_homedir());
if (entry->str_value[0] &&
(entry->str_value[0] != '/' || strstr(entry->str_value, "/.") ||
@@ -1662,7 +1662,6 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) {
pthread_mutex_unlock(&this->streams_lock);
}
- free(homedir_trail_slash);
this->save_path = entry->str_value;
}