1 /*****************************************************************************
2 * tools.c: tools for dvd plugin.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: tools.c,v 1.4 2003/01/28 15:05:52 massiot Exp $
7 * Author: Stéphane Borel <stef@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
34 #include "stream_control.h"
35 #include "input_ext-intf.h"
36 #include "input_ext-dec.h"
37 #include "input_ext-plugins.h"
41 /*****************************************************************************
42 * dvdplay_ParseCL: parse command line
43 *****************************************************************************/
44 char * dvdplay_ParseCL( input_thread_t * p_input,
45 int * i_title, int * i_chapter, int * i_angle )
48 struct stat stat_info;
53 p_dvd = (dvd_data_t*)(p_input->p_access_data);
55 psz_source = strdup( p_input->psz_name );
56 if( psz_source == NULL )
65 /* Start with the end, because you could have :
66 * dvdplay:/Volumes/my@toto/VIDEO_TS@1,1
67 * (yes, this is kludgy). */
68 for ( psz_parser = psz_source + strlen(psz_source) - 1;
69 psz_parser >= psz_source && *psz_parser != '@';
72 if( psz_parser >= psz_source && *psz_parser == '@' )
78 *i_title = (int)strtol( psz_parser, &psz_next, 10 );
81 psz_parser = psz_next + 1;
82 *i_chapter = (int)strtol( psz_parser, &psz_next, 10 );
85 *i_angle = (int)strtol( psz_next + 1, NULL, 10 );
90 *i_title = *i_title >= 0 ? *i_title : 0;
91 *i_chapter = *i_chapter ? *i_chapter : 1;
92 *i_angle = *i_angle ? *i_angle : 1;
97 if( !p_input->psz_access )
101 psz_source = config_GetPsz( p_input, "dvd" );
102 if( !psz_source ) return NULL;
106 if( psz_source[0] && psz_source[1] == ':' && psz_source[2] == '\0' )
108 /* Don't try to stat the file */
113 if( stat( psz_source, &stat_info ) == -1 )
115 msg_Warn( p_input, "cannot stat() source `%s' (%s)",
116 psz_source, strerror(errno) );
121 if( !S_ISBLK(stat_info.st_mode) &&
122 !S_ISCHR(stat_info.st_mode) &&
123 !S_ISDIR(stat_info.st_mode) )
125 msg_Dbg( p_input, "plugin discarded (not a valid source)" );
131 msg_Dbg( p_input, "dvdroot=%s title=%d chapter=%d angle=%d",
132 psz_source, *i_title, *i_chapter, *i_angle );