Changeset 751d2f1a63d1d4fe2ea19c6b10b176a98bc46615

Show
Ignore:
Timestamp:
02/07/08 23:51:30 (7 months ago)
Author:
Christophe Mutricy <xtophe@videolan.org>
git-committer:
Christophe Mutricy <xtophe@videolan.org> 1202424690 +0000
git-parent:

[e3421975ebd9f0b6ce7f3aae799cc0b991b58897]

git-author:
Christophe Mutricy <xtophe@videolan.org> 1202424690 +0000
Message:

Distribute include/vlc_plugin.h and src/config/intf.c
Remove code duplication

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/Makefile.am

    r9291c27 r751d2f1  
    7272    ../include/vlc_pgpkey.h \ 
    7373    ../include/vlc_playlist.h \ 
     74    ../include/vlc_plugin.h \ 
    7475    ../include/vlc_rand.h \ 
    7576    ../include/vlc_services_discovery.h \ 
     
    308309    config/chain.c \ 
    309310    config/file.c \ 
     311    config/intf.c \ 
    310312    config/cmdline.c \ 
    311313    misc/events.c \ 
  • src/config/core.c

    r12d327f r751d2f1  
    823823#endif 
    824824} 
    825  
    826 /* Adds an extra interface to the configuration */ 
    827 void __config_AddIntf( vlc_object_t *p_this, const char *psz_intf ) 
    828 { 
    829     assert( psz_intf ); 
    830  
    831     char *psz_config, *psz_parser; 
    832     size_t i_len = strlen( psz_intf ); 
    833  
    834     psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "control" ); 
    835     while( psz_parser ) 
    836     { 
    837         if( !strncmp( psz_intf, psz_parser, i_len ) ) 
    838         { 
    839             free( psz_config ); 
    840             return; 
    841         } 
    842         psz_parser = strchr( psz_parser, ':' ); 
    843         if( psz_parser ) psz_parser++; /* skip the ':' */ 
    844     } 
    845     free( psz_config ); 
    846  
    847     psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "extraintf" ); 
    848     while( psz_parser ) 
    849     { 
    850         if( !strncmp( psz_intf, psz_parser, i_len ) ) 
    851         { 
    852             free( psz_config ); 
    853             return; 
    854         } 
    855         psz_parser = strchr( psz_parser, ':' ); 
    856         if( psz_parser ) psz_parser++; /* skip the ':' */ 
    857     } 
    858  
    859     /* interface not found in the config, let's add it */ 
    860     if( psz_config && strlen( psz_config ) > 0 ) 
    861     { 
    862         char *psz_newconfig; 
    863         if( asprintf( &psz_newconfig, "%s:%s", psz_config, psz_intf ) != -1 ) 
    864         { 
    865             config_PutPsz( p_this->p_libvlc, "extraintf", psz_newconfig ); 
    866             free( psz_newconfig ); 
    867         } 
    868     } 
    869     else 
    870         config_PutPsz( p_this->p_libvlc, "extraintf", psz_intf ); 
    871  
    872     free( psz_config ); 
    873 } 
    874  
    875 /* Removes an extra interface from the configuration */ 
    876 void __config_RemoveIntf( vlc_object_t *p_this, const char *psz_intf ) 
    877 { 
    878     assert( psz_intf ); 
    879  
    880     char *psz_config, *psz_parser; 
    881     size_t i_len = strlen( psz_intf ); 
    882  
    883     psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "extraintf" ); 
    884     while( psz_parser ) 
    885     { 
    886         if( !strncmp( psz_intf, psz_parser, i_len ) ) 
    887         { 
    888             char *psz_newconfig; 
    889             char *psz_end = psz_parser + i_len; 
    890             if( *psz_end == ':' ) psz_end++; 
    891             *psz_parser = '\0'; 
    892             if( asprintf( &psz_newconfig, "%s%s", psz_config, psz_end ) != -1 ) 
    893             { 
    894                 config_PutPsz( p_this->p_libvlc, "extraintf", psz_newconfig ); 
    895                 free( psz_newconfig ); 
    896             } 
    897             break; 
    898         } 
    899         psz_parser = strchr( psz_parser, ':' ); 
    900         if( psz_parser ) psz_parser++; /* skip the ':' */ 
    901     } 
    902     free( psz_config ); 
    903  
    904     psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "control" ); 
    905     while( psz_parser ) 
    906     { 
    907         if( !strncmp( psz_intf, psz_parser, i_len ) ) 
    908         { 
    909             char *psz_newconfig; 
    910             char *psz_end = psz_parser + i_len; 
    911             if( *psz_end == ':' ) psz_end++; 
    912             *psz_parser = '\0'; 
    913             if( asprintf( &psz_newconfig, "%s%s", psz_config, psz_end ) != -1 ) 
    914             { 
    915                 config_PutPsz( p_this->p_libvlc, "control", psz_newconfig ); 
    916                 free( psz_newconfig ); 
    917             } 
    918             break; 
    919         } 
    920         psz_parser = strchr( psz_parser, ':' ); 
    921         if( psz_parser ) psz_parser++; /* skip the ':' */ 
    922     } 
    923     free( psz_config ); 
    924 } 
    925  
    926 /* 
    927  * Returns VLC_TRUE if the specified extra interface is present in the 
    928  * configuration, VLC_FALSE if not 
    929  */ 
    930 vlc_bool_t __config_ExistIntf( vlc_object_t *p_this, const char *psz_intf ) 
    931 { 
    932     assert( psz_intf ); 
    933  
    934     char *psz_config, *psz_parser; 
    935     size_t i_len = strlen( psz_intf ); 
    936  
    937     psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "extraintf" ); 
    938     while( psz_parser ) 
    939     { 
    940         if( !strncmp( psz_parser, psz_intf, i_len ) ) 
    941         { 
    942             free( psz_config ); 
    943             return VLC_TRUE; 
    944         } 
    945         psz_parser = strchr( psz_parser, ':' ); 
    946         if( psz_parser ) psz_parser++; /* skip the ':' */ 
    947     } 
    948     free( psz_config ); 
    949  
    950     psz_config = psz_parser = config_GetPsz( p_this->p_libvlc, "control" ); 
    951     while( psz_parser ) 
    952     { 
    953         if( !strncmp( psz_parser, psz_intf, i_len ) ) 
    954         { 
    955             free( psz_config ); 
    956             return VLC_TRUE; 
    957         } 
    958         psz_parser = strchr( psz_parser, ':' ); 
    959         if( psz_parser ) psz_parser++; /* skip the ':' */ 
    960     } 
    961     free( psz_config ); 
    962  
    963     return VLC_FALSE; 
    964 } 
    965