diff options
author | James Courtier-Dutton <jcdutton@users.sourceforge.net> | 2004-08-28 15:06:26 +0000 |
---|---|---|
committer | James Courtier-Dutton <jcdutton@users.sourceforge.net> | 2004-08-28 15:06:26 +0000 |
commit | 03162b0a56938768864c78b14847e429e396f7c7 (patch) | |
tree | 44a404b6ee27f64d11194a22e93d12da8eef114b | |
parent | 9e4f77e44c96cf4ff4e0186e645dbe08b1e80761 (diff) | |
download | xine-lib-03162b0a56938768864c78b14847e429e396f7c7.tar.gz xine-lib-03162b0a56938768864c78b14847e429e396f7c7.tar.bz2 |
Improved MRL parsing in the dvd plugin.
Works now for all types of MRL, and works in DVD Title mode as well.
Removes the requirement to have a "/" at the end of the MRL.
Eg.
xine dvd:/ <- plays a DVD from the default dvd device.
xine dvd://dev/sr0 <- plays a DVD from /dev/sr0
xine dvd:/dvd.img <- plays a DVD image from the current directory.
xine dvd://dvd/dvd.img <- plays a DVD from full path /dvd/dvd.img
xine dvd://dvd/dvd.img/ <- plays a DVD from full path /dvd/dvd.img. Having the last / makes no difference.
xine dvd://dvd/dvd.img:1.2 <- plays Title 1, Part 2 of DVD image.
CVS patchset: 6912
CVS date: 2004/08/28 15:06:26
-rw-r--r-- | src/input/input_dvd.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index e20d1c21b..076ba20f0 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_dvd.c,v 1.187 2004/08/19 10:30:04 mroi Exp $ + * $Id: input_dvd.c,v 1.188 2004/08/28 15:06:26 jcdutton Exp $ * */ @@ -1322,7 +1322,8 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { dvd_input_class_t *class = (dvd_input_class_t*)this_gen->input_class; char *locator; - int last_slash = 0, mode; + int last_colon = 0, mode; + int locator_len; dvdnav_status_t ret; char *intended_dvd_device; xine_event_t event; @@ -1330,31 +1331,31 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { trace_print("Called\n"); + mode = MODE_NAVIGATE; /* we already checked the "dvd:/" MRL before */ locator = &this->mrl[strlen("dvd:/")]; - while (*locator == '/') locator++; - -#ifndef _MSC_VER - /* we skipped at least one slash, get it back */ - locator--; -#endif /* Attempt to parse MRL */ - last_slash = strlen(locator); - while (last_slash && locator[last_slash] != '/' && locator[last_slash] != '\\') - last_slash--; + /* FIXME: strlen is dangerous, we should use a bounded max len version of strlen. */ + last_colon = locator_len = strlen(locator); + while (last_colon && locator[last_colon] != ':' ) + last_colon--; - if(last_slash) { + if((last_colon == 0) && (locator_len > 0)) { + last_colon = locator_len; + } + if(last_colon) { /* we have an alternative dvd_path */ intended_dvd_device = locator; - intended_dvd_device[last_slash] = '\0'; - locator += last_slash; + intended_dvd_device[last_colon] = '\0'; + locator += last_colon; /* Set locator to null string */ + if ( (last_colon + 1) < locator_len ) { + locator++; /* Only if there are more characters after the colon, use them for Title mode */ + mode = MODE_TITLE; + } /* do not use the raw device for the alternative */ xine_setenv("DVDCSS_RAW_DEVICE", "", 1); -#ifdef _MSC_VER - locator++; -#endif }else{ xine_cfg_entry_t raw_device; @@ -1365,16 +1366,6 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { intended_dvd_device=class->dvd_device; } -#ifndef _MSC_VER - locator++; -#endif - - if(locator[0]) { - mode = MODE_TITLE; - } else { - mode = MODE_NAVIGATE; - } - if(this->opened) { if ( intended_dvd_device==this->current_dvd_device ) { /* Already open, so skip opening */ |