Changeset 6962020b256671f0d54793afbbd2e63d7a0e5d0b
- 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
| r58296b6 |
r6962020 |
|
| 907 | 907 | *****************************************************************************/ |
|---|
| 908 | 908 | |
|---|
| | 909 | /***************************************************************************** |
|---|
| | 910 | * copy_next_paths_token: from a PATH_SEP_CHAR (a ':' or a ';') separated paths |
|---|
| | 911 | * return first path. |
|---|
| | 912 | *****************************************************************************/ |
|---|
| | 913 | static 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 | |
|---|
| 909 | 948 | /***************************************************************************** |
|---|
| 910 | 949 | * AllocateAllPlugins: load all plugin modules we can find. |
|---|
| … | … | |
| 913 | 952 | static void AllocateAllPlugins( vlc_object_t *p_this ) |
|---|
| 914 | 953 | { |
|---|
| 915 | | char *path, *ppsz_path, *psz_iter; |
|---|
| | 954 | char *paths, *path, *paths_iter; |
|---|
| 916 | 955 | |
|---|
| 917 | 956 | #if defined( WIN32 ) || defined( UNDER_CE ) |
|---|
| 918 | 957 | const char * extra_path = ""; |
|---|
| 919 | 958 | #else |
|---|
| 920 | | const char * extra_path = PLUGIN_PATH; |
|---|
| | 959 | const char * extra_path = ":" PLUGIN_PATH; |
|---|
| 921 | 960 | #endif |
|---|
| 922 | 961 | |
|---|
| 923 | 962 | /* 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 ) |
|---|
| 928 | 966 | { |
|---|
| 929 | 967 | msg_Err( p_this, "Not enough memory" ); |
|---|
| 930 | | free( userpath ); |
|---|
| | 968 | free( userpaths ); |
|---|
| 931 | 969 | return; |
|---|
| 932 | 970 | } |
|---|
| 933 | 971 | |
|---|
| 934 | 972 | /* Free plugin-path */ |
|---|
| 935 | | free( userpath ); |
|---|
| 936 | | |
|---|
| 937 | | for( ppsz_path = path; !end; ) |
|---|
| | 973 | free( userpaths ); |
|---|
| | 974 | |
|---|
| | 975 | for( paths_iter = paths; paths_iter; ) |
|---|
| 938 | 976 | { |
|---|
| 939 | 977 | 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 | } |
|---|
| 945 | 985 | |
|---|
| 946 | 986 | #if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 ) |
|---|
| … | … | |
| 948 | 988 | /* Handle relative as well as absolute paths */ |
|---|
| 949 | 989 | #ifdef WIN32 |
|---|
| 950 | | if( ppsz_path[0] != '\\' && ppsz_path[0] != '/' && ppsz_path[0] != ':' ) |
|---|
| | 990 | if( path[0] != '\\' && path[0] != '/' && path[0] != ':' ) |
|---|
| 951 | 991 | #else |
|---|
| 952 | | if( ppsz_path[0] != '/' ) |
|---|
| | 992 | if( path[0] != '/' ) |
|---|
| 953 | 993 | #endif |
|---|
| 954 | 994 | { |
|---|
| 955 | 995 | if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s", |
|---|
| 956 | | vlc_global()->psz_vlcpath, ppsz_path) ) |
|---|
| | 996 | vlc_global()->psz_vlcpath, path) ) |
|---|
| 957 | 997 | psz_fullpath = NULL; |
|---|
| 958 | 998 | } |
|---|
| 959 | 999 | else |
|---|
| 960 | 1000 | #endif |
|---|
| 961 | | psz_fullpath = strdup( ppsz_path ); |
|---|
| | 1001 | psz_fullpath = strdup( path ); |
|---|
| 962 | 1002 | |
|---|
| 963 | 1003 | if( psz_fullpath == NULL ) |
|---|
| … | … | |
| 970 | 1010 | |
|---|
| 971 | 1011 | 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 ); |
|---|
| 977 | 1016 | } |
|---|
| 978 | 1017 | |
|---|