]> git.sesse.net Git - vlc/blob - src/input/access.c
48bccdba03402c0b90d5c795c4f4084715179d41
[vlc] / src / input / access.c
1 /*****************************************************************************
2  * access.c
3  *****************************************************************************
4  * Copyright (C) 1999-2004 VideoLAN
5  * $Id: demux.c 7546 2004-04-29 13:53:29Z gbazin $
6  *
7  * Author: Laurent Aimar <fenrir@via.ecp.fr>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include <stdlib.h>
25 #include <vlc/vlc.h>
26 #include <vlc/input.h>
27
28 #include "input_internal.h"
29
30 /*****************************************************************************
31  * access2_New:
32  *****************************************************************************/
33 access_t *__access2_New( vlc_object_t *p_obj,
34                          char *psz_access, char *psz_demux, char *psz_path,
35                          vlc_bool_t b_quick )
36 {
37     access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
38
39     if( p_access == NULL )
40     {
41         msg_Err( p_obj, "vlc_object_create( p_obj, VLC_OBJECT_ACCESS ) failed" );
42         return NULL;
43     }
44
45     /* Parse URL */
46     p_access->psz_access = b_quick ? strdup( "file" ) : strdup( psz_access );
47     p_access->psz_path   = strdup( psz_path );
48     p_access->psz_demux  = strdup( "" );
49
50     if( !b_quick )
51         msg_Dbg( p_obj, "access2_New: access='%s' path='%s'",
52                  p_access->psz_access, p_access->psz_path );
53
54     p_access->pf_read    = NULL;
55     p_access->pf_block   = NULL;
56     p_access->pf_seek    = NULL;
57     p_access->pf_control = NULL;
58     p_access->p_sys      = NULL;
59     p_access->info.i_update = 0;
60     p_access->info.i_size   = 0;
61     p_access->info.i_pos    = 0;
62     p_access->info.b_eof    = VLC_FALSE;
63     p_access->info.i_title  = 0;
64     p_access->info.i_seekpoint = 0;
65
66
67     /* Before module_Need (for var_Create...) */
68     vlc_object_attach( p_access, p_obj );
69
70     p_access->p_module =
71         module_Need( p_access, "access2", p_access->psz_access,
72                      b_quick ? VLC_TRUE : VLC_FALSE );
73
74     if( p_access->p_module == NULL )
75     {
76         vlc_object_detach( p_access );
77         free( p_access->psz_access );
78         free( p_access->psz_path );
79         free( p_access->psz_demux );
80         vlc_object_destroy( p_access );
81         return NULL;
82     }
83
84     return p_access;
85 }
86
87 /*****************************************************************************
88  * demux2_Delete:
89  *****************************************************************************/
90 void access2_Delete( access_t *p_access )
91 {
92     module_Unneed( p_access, p_access->p_module );
93     vlc_object_detach( p_access );
94
95     free( p_access->psz_access );
96     free( p_access->psz_path );
97     free( p_access->psz_demux );
98
99     vlc_object_destroy( p_access );
100 }