Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
06028f48
Commit
06028f48
authored
Feb 12, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify plugin paths tokenization
parent
c984067b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
82 deletions
+32
-82
src/modules/modules.c
src/modules/modules.c
+32
-82
No files found.
src/modules/modules.c
View file @
06028f48
...
...
@@ -68,6 +68,8 @@ int vlc_entry__main( module_t * );
*****************************************************************************/
#ifdef HAVE_DYNAMIC_PLUGINS
static
void
AllocateAllPlugins
(
vlc_object_t
*
,
module_bank_t
*
);
static
void
AllocatePluginPath
(
vlc_object_t
*
,
module_bank_t
*
,
const
char
*
,
bool
);
static
void
AllocatePluginDir
(
vlc_object_t
*
,
module_bank_t
*
,
const
char
*
,
unsigned
);
static
int
AllocatePluginFile
(
vlc_object_t
*
,
module_bank_t
*
,
const
char
*
,
...
...
@@ -827,93 +829,47 @@ void module_config_free( module_config_t *config )
* Following functions are local.
*****************************************************************************/
/*****************************************************************************
* copy_next_paths_token: from a PATH_SEP_CHAR (a ':' or a ';') separated paths
* return first path.
*****************************************************************************/
static
char
*
copy_next_paths_token
(
char
*
paths
,
char
**
remaining_paths
)
{
char
*
path
;
int
i
,
done
;
bool
escaped
=
false
;
assert
(
paths
);
/* Alloc a buffer to store the path */
path
=
malloc
(
strlen
(
paths
)
+
1
);
if
(
!
path
)
return
NULL
;
/* Look for PATH_SEP_CHAR (a ':' or a ';') */
for
(
i
=
0
,
done
=
0
;
paths
[
i
];
i
++
)
{
/* Take care of \\ and \: or \; escapement */
if
(
escaped
)
{
escaped
=
false
;
path
[
done
++
]
=
paths
[
i
];
}
#ifdef WIN32
else
if
(
paths
[
i
]
==
'/'
)
escaped
=
true
;
#else
else
if
(
paths
[
i
]
==
'\\'
)
escaped
=
true
;
#endif
else
if
(
paths
[
i
]
==
PATH_SEP_CHAR
)
break
;
else
path
[
done
++
]
=
paths
[
i
];
}
path
[
done
]
=
0
;
/* Return the remaining paths */
if
(
remaining_paths
)
{
*
remaining_paths
=
paths
[
i
]
?
&
paths
[
i
]
+
1
:
NULL
;
}
return
path
;
}
char
*
psz_vlcpath
=
NULL
;
#ifdef HAVE_DYNAMIC_PLUGINS
/*****************************************************************************
* AllocateAllPlugins: load all plugin modules we can find.
*****************************************************************************/
#ifdef HAVE_DYNAMIC_PLUGINS
static
void
AllocateAllPlugins
(
vlc_object_t
*
p_this
,
module_bank_t
*
p_bank
)
{
const
char
*
vlcpath
=
psz_vlcpath
;
int
count
,
i
;
char
*
path
;
vlc_array_t
*
arraypaths
=
vlc_array_new
();
char
*
paths
;
const
bool
b_reset
=
var_InheritBool
(
p_this
,
"reset-plugins-cache"
);
/* Contruct the special search path for system that have a relocatable
* executable. Set it to <vlc path>/plugins. */
assert
(
vlcpath
);
if
(
asprintf
(
&
path
,
"%s"
DIR_SEP
"plugins"
,
vlcpath
)
!=
-
1
)
vlc_array_append
(
arraypaths
,
path
);
if
(
asprintf
(
&
paths
,
"%s"
DIR_SEP
"plugins"
,
vlcpath
)
!=
-
1
)
{
AllocatePluginPath
(
p_this
,
p_bank
,
paths
,
b_reset
);
free
(
paths
);
}
/* If the user provided a plugin path, we add it to the list */
char
*
userpaths
=
var_InheritString
(
p_this
,
"plugin-path"
);
char
*
paths_iter
;
paths
=
var_InheritString
(
p_this
,
"plugin-path"
);
if
(
paths
==
NULL
)
return
;
for
(
paths_iter
=
userpaths
;
paths_iter
;
)
{
path
=
copy_next_paths_token
(
paths_iter
,
&
paths_iter
);
if
(
path
)
vlc_array_append
(
arraypaths
,
path
);
}
for
(
char
*
buf
,
*
path
=
strtok_r
(
paths
,
PATH_SEP
,
&
buf
);
path
!=
NULL
;
path
=
strtok_r
(
NULL
,
PATH_SEP
,
&
buf
)
)
AllocatePluginPath
(
p_this
,
p_bank
,
path
,
b_reset
);
count
=
vlc_array_count
(
arraypaths
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
path
=
vlc_array_item_at_index
(
arraypaths
,
i
);
if
(
!
path
)
continue
;
free
(
paths
);
}
static
void
AllocatePluginPath
(
vlc_object_t
*
p_this
,
module_bank_t
*
p_bank
,
const
char
*
path
,
bool
b_reset
)
{
size_t
offset
=
p_module_bank
->
i_cache
;
if
(
b_reset
)
CacheDelete
(
p_this
,
path
);
else
...
...
@@ -924,14 +880,8 @@ static void AllocateAllPlugins( vlc_object_t *p_this, module_bank_t *p_bank )
/* Don't go deeper than 5 subdirectories */
AllocatePluginDir
(
p_this
,
p_bank
,
path
,
5
);
CacheSave
(
p_this
,
path
,
p_module_bank
->
pp_cache
+
offset
,
p_module_bank
->
i_cache
-
offset
);
free
(
path
);
}
vlc_array_destroy
(
arraypaths
);
free
(
userpaths
);
}
/*****************************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment