-
-/*****************************************************************************
- * ParseCL: parse command line. Titles, chapters and angles start from 1.
- *****************************************************************************/
-static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force,
- int *i_title, int *i_chapter, int *i_angle )
-{
- char *psz_parser, *psz_source, *psz_next;
-
- psz_source = strdup( psz_name );
- if( psz_source == NULL ) return NULL;
-
- *i_title = 1;
- *i_chapter = 1;
- *i_angle = 1;
-
- /* Start with the end, because you could have :
- * dvdnav:/Volumes/my@toto/VIDEO_TS@1,1
- * (yes, this is kludgy). */
- for( psz_parser = psz_source + strlen(psz_source) - 1;
- psz_parser >= psz_source && *psz_parser != '@';
- psz_parser-- );
-
- if( psz_parser >= psz_source && *psz_parser == '@' )
- {
- /* Found options */
- *psz_parser = '\0';
- ++psz_parser;
-
- *i_title = (int)strtol( psz_parser, &psz_next, 10 );
- if( *psz_next )
- {
- psz_parser = psz_next + 1;
- *i_chapter = (int)strtol( psz_parser, &psz_next, 10 );
- if( *psz_next )
- {
- *i_angle = (int)strtol( psz_next + 1, NULL, 10 );
- }
- }
- }
-
- *i_title = *i_title > 0 ? *i_title : 1;
- *i_chapter = *i_chapter > 0 ? *i_chapter : 1;
- *i_angle = *i_angle > 0 ? *i_angle : 1;
-
- if( !*psz_source )
- {
- free( psz_source );
- if( !b_force )
- {
- return NULL;
- }
- psz_source = config_GetPsz( p_this, "dvd" );
- if( !psz_source ) return NULL;
- }
-
-#ifdef WIN32
- if( psz_source[0] && psz_source[1] == ':' &&
- psz_source[2] == '\\' && psz_source[3] == '\0' )
- {
- psz_source[2] = '\0';
- }
-#endif
-
- msg_Dbg( p_this, "dvdroot=%s title=%d chapter=%d angle=%d",
- psz_source, *i_title, *i_chapter, *i_angle );
-
- /* Get back to a 0-based offset */
- (*i_title)--;
- (*i_chapter)--;
-
- return psz_source;
-}