1 /*****************************************************************************
2 * tools.c: tools for dvd plugin.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: tools.c,v 1.1 2002/07/23 19:56:19 stef 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_parser = psz_source = strdup( p_input->psz_name );
61 while( *psz_parser && *psz_parser != '@' )
70 if( *psz_parser == '@' )
76 *i_title = (int)strtol( psz_parser, &psz_next, 10 );
79 psz_parser = psz_next + 1;
80 *i_chapter = (int)strtol( psz_parser, &psz_next, 10 );
83 *i_angle = (int)strtol( psz_next + 1, NULL, 10 );
88 *i_title = *i_title >= 0 ? *i_title : 0;
89 *i_chapter = *i_chapter ? *i_chapter : 1;
90 *i_angle = *i_angle ? *i_angle : 1;
95 if( !p_input->psz_access )
99 psz_source = config_GetPsz( p_input, "dvd" );
102 if( stat( psz_source, &stat_info ) == -1 )
104 msg_Err( p_input, "cannot stat() source `%s' (%s)",
105 psz_source, strerror(errno));
108 if( !S_ISBLK(stat_info.st_mode) &&
109 !S_ISCHR(stat_info.st_mode) &&
110 !S_ISDIR(stat_info.st_mode) )
112 msg_Dbg( p_input, "plugin discarded"
113 " (not a valid source)" );
117 msg_Dbg( p_input, "dvdroot=%s title=%d chapter=%d angle=%d",
118 psz_source, *i_title, *i_chapter, *i_angle );