1 /*****************************************************************************
2 * intf.c: interface configuration handling
3 *****************************************************************************
4 * Copyright (C) 2001-2007 the VideoLAN team
7 * Authors: Gildas Bazin <gbazin@videolan.org>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
30 /* Adds an extra interface to the configuration */
31 void __config_AddIntf( vlc_object_t *p_this, const char *psz_intf )
35 char *psz_config, *psz_parser;
36 size_t i_len = strlen( psz_intf );
38 psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "control" );
41 if( !strncmp( psz_intf, psz_parser, i_len ) )
46 psz_parser = strchr( psz_parser, ':' );
47 if( psz_parser ) psz_parser++; /* skip the ':' */
51 psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "extraintf" );
54 if( !strncmp( psz_intf, psz_parser, i_len ) )
59 psz_parser = strchr( psz_parser, ':' );
60 if( psz_parser ) psz_parser++; /* skip the ':' */
63 /* interface not found in the config, let's add it */
64 if( psz_config && strlen( psz_config ) > 0 )
67 if( asprintf( &psz_newconfig, "%s:%s", psz_config, psz_intf ) != -1 )
69 config_PutPsz( p_this->p_libvlc, "extraintf", psz_newconfig );
70 free( psz_newconfig );
74 config_PutPsz( p_this->p_libvlc, "extraintf", psz_intf );
79 /* Removes an extra interface from the configuration */
80 void __config_RemoveIntf( vlc_object_t *p_this, const char *psz_intf )
84 char *psz_config, *psz_parser;
85 size_t i_len = strlen( psz_intf );
87 psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "extraintf" );
90 if( !strncmp( psz_intf, psz_parser, i_len ) )
93 char *psz_end = psz_parser + i_len;
94 if( *psz_end == ':' ) psz_end++;
96 if( asprintf( &psz_newconfig, "%s%s", psz_config, psz_end ) != -1 )
98 config_PutPsz( p_this->p_libvlc, "extraintf", psz_newconfig );
99 free( psz_newconfig );
103 psz_parser = strchr( psz_parser, ':' );
104 if( psz_parser ) psz_parser++; /* skip the ':' */
108 psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "control" );
111 if( !strncmp( psz_intf, psz_parser, i_len ) )
114 char *psz_end = psz_parser + i_len;
115 if( *psz_end == ':' ) psz_end++;
117 if( asprintf( &psz_newconfig, "%s%s", psz_config, psz_end ) != -1 )
119 config_PutPsz( p_this->p_libvlc, "control", psz_newconfig );
120 free( psz_newconfig );
124 psz_parser = strchr( psz_parser, ':' );
125 if( psz_parser ) psz_parser++; /* skip the ':' */
131 * Returns VLC_TRUE if the specified extra interface is present in the
132 * configuration, VLC_FALSE if not
134 vlc_bool_t __config_ExistIntf( vlc_object_t *p_this, const char *psz_intf )
138 char *psz_config, *psz_parser;
139 size_t i_len = strlen( psz_intf );
141 psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "extraintf" );
144 if( !strncmp( psz_parser, psz_intf, i_len ) )
149 psz_parser = strchr( psz_parser, ':' );
150 if( psz_parser ) psz_parser++; /* skip the ':' */
154 psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "control" );
157 if( !strncmp( psz_parser, psz_intf, i_len ) )
162 psz_parser = strchr( psz_parser, ':' );
163 if( psz_parser ) psz_parser++; /* skip the ':' */