Changeset 6962020b256671f0d54793afbbd2e63d7a0e5d0b

Show
Ignore:
Timestamp:
28/03/08 16:45:15 (7 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1206719115 +0100
git-parent:

[242a2d12ffc267fae04a03d42d2b045cf5b2b441]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1206718967 +0100
Message:

module: Make sure we can escape ':' correctly.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/modules.c

    r58296b6 r6962020  
    907907 *****************************************************************************/ 
    908908 
     909 /***************************************************************************** 
     910 * copy_next_paths_token: from a PATH_SEP_CHAR (a ':' or a ';') separated paths 
     911 * return first path. 
     912 *****************************************************************************/ 
     913static char * copy_next_paths_token( char * paths, char ** remaining_paths ) 
     914{ 
     915    char * path; 
     916    int i; 
     917    bool escaped = false; 
     918 
     919    assert( paths ); 
     920 
     921    /* Alloc a buffer to store the path */ 
     922    path = malloc( strlen( paths ) ); 
     923    if( !path ) return NULL; 
     924 
     925    /* Look for PATH_SEP_CHAR (a ':' or a ';') */ 
     926    for( i = 0; paths[i]; i++ ) { 
     927        /* Take care of \\ and \: or \; escapement */ 
     928        if( escaped ) { 
     929            escaped = false; 
     930            path[i] = paths[i]; 
     931        } 
     932        else if( paths[i] == '\\' ) 
     933            escaped = true; 
     934        else if( paths[i] == PATH_SEP_CHAR ) 
     935            break; 
     936        else 
     937            path[i] = paths[i]; 
     938    } 
     939 
     940    /* Return the remaining paths */ 
     941    if( remaining_paths ) { 
     942        *remaining_paths = paths[i] ? &paths[i]+1 : NULL; 
     943    } 
     944 
     945    return path; 
     946} 
     947 
    909948/***************************************************************************** 
    910949 * AllocateAllPlugins: load all plugin modules we can find. 
     
    913952static void AllocateAllPlugins( vlc_object_t *p_this ) 
    914953{ 
    915     char *path, *ppsz_path, *psz_iter; 
     954    char *paths, *path, *paths_iter; 
    916955 
    917956#if defined( WIN32 ) || defined( UNDER_CE ) 
    918957    const char * extra_path = ""; 
    919958#else 
    920     const char * extra_path = PLUGIN_PATH; 
     959    const char * extra_path = ":" PLUGIN_PATH; 
    921960#endif 
    922961 
    923962    /* If the user provided a plugin path, we add it to the list */ 
    924     char * userpath = config_GetPsz( p_this, "plugin-path" ); 
    925     bool end = false; 
    926  
    927     if( asprintf( &path, "modules%s:plugins:%s", extra_path, userpath ) < 0 ) 
     963    char * userpaths = config_GetPsz( p_this, "plugin-path" ); 
     964 
     965    if( asprintf( &paths, "modules%s:plugins:%s", extra_path, userpaths ) < 0 ) 
    928966    { 
    929967        msg_Err( p_this, "Not enough memory" ); 
    930         free( userpath ); 
     968        free( userpaths ); 
    931969        return; 
    932970    } 
    933971 
    934972    /* Free plugin-path */ 
    935     free( userpath ); 
    936  
    937     for( ppsz_path = path; !end; ) 
     973    free( userpaths ); 
     974 
     975    for( paths_iter = paths; paths_iter; ) 
    938976    { 
    939977        char *psz_fullpath; 
    940  
    941         /* Look for PATH_SEP_CHAR (a ':' or a ';') */ 
    942         for( psz_iter = ppsz_path; *psz_iter && *psz_iter != PATH_SEP_CHAR; psz_iter++ ); 
    943         if( !*psz_iter ) end = true; 
    944         else *psz_iter = 0; 
     978  
     979        path = copy_next_paths_token( paths_iter, &paths_iter ); 
     980        if( !path ) 
     981        { 
     982            msg_Err( p_this, "Not enough memory" ); 
     983            return; 
     984        } 
    945985 
    946986#if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 ) 
     
    948988        /* Handle relative as well as absolute paths */ 
    949989#ifdef WIN32 
    950         if( ppsz_path[0] != '\\' && ppsz_path[0] != '/' && ppsz_path[0] != ':' ) 
     990        if( path[0] != '\\' && path[0] != '/' && path[0] != ':' ) 
    951991#else 
    952         if( ppsz_path[0] != '/' ) 
     992        if( path[0] != '/' ) 
    953993#endif 
    954994        { 
    955995            if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s", 
    956                               vlc_global()->psz_vlcpath, ppsz_path) ) 
     996                              vlc_global()->psz_vlcpath, path) ) 
    957997                psz_fullpath = NULL; 
    958998        } 
    959999        else 
    9601000#endif 
    961             psz_fullpath = strdup( ppsz_path ); 
     1001            psz_fullpath = strdup( path ); 
    9621002 
    9631003        if( psz_fullpath == NULL ) 
     
    9701010 
    9711011        free( psz_fullpath ); 
    972         if( !end ) ppsz_path = psz_iter + 1; 
    973     } 
    974  
    975     /* Free plugin-path */ 
    976     free( path ); 
     1012        free( path ); 
     1013    } 
     1014 
     1015    free( paths ); 
    9771016} 
    9781017