[vlc-devel] commit: Add module_find_by_short() (internal only) ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sun Feb 8 19:14:32 CET 2009
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Feb 8 20:06:24 2009 +0200| [a3e70b4e36d7300276ad4263407cd9f5bad2a16d] | committer: Rémi Denis-Courmont
Add module_find_by_short() (internal only)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a3e70b4e36d7300276ad4263407cd9f5bad2a16d
---
src/libvlc.h | 1 +
src/modules/modules.c | 37 +++++++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/libvlc.h b/src/libvlc.h
index 8d945b6..650a93c 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -146,6 +146,7 @@ extern char *psz_vlcpath;
* Free after uses both the string and the table. */
VLC_EXPORT(char **, module_GetModulesNamesForCapability,
( const char * psz_capability, char ***psz_longname ) );
+module_t *module_find_by_shortcut (const char *psz_shortcut);
/**
* Private LibVLC data for each object.
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 07ae7db..56cf5e7 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -689,7 +689,6 @@ void __module_unneed( vlc_object_t * p_this, module_t * p_module )
/**
* Get a pointer to a module_t given it's name.
*
- * \param p_this vlc object structure
* \param psz_name the name of the module
* \return a pointer to the module or NULL in case of a failure
*/
@@ -718,7 +717,6 @@ module_t *module_find( const char * psz_name )
/**
* Tell if a module exists and release it in thic case
*
- * \param p_this vlc object structure
* \param psz_name th name of the module
* \return TRUE if the module exists
*/
@@ -731,6 +729,41 @@ bool module_exists (const char * psz_name)
}
/**
+ * Get a pointer to a module_t that matches a shortcut.
+ * This is a temporary hack for SD. Do not re-use (generally multiple modules
+ * can have the same shortcut, so this is *broken* - use module_need()!).
+ *
+ * \param psz_shortcut shortcut of the module
+ * \param psz_cap capability of the module
+ * \return a pointer to the module or NULL in case of a failure
+ */
+module_t *module_find_by_shortcut (const char *psz_shortcut)
+{
+ module_t **list, *module;
+
+ list = module_list_get (NULL);
+ if (!list)
+ return NULL;
+
+ for (size_t i = 0; (module = list[i]) != NULL; i++)
+ {
+ for (size_t j = 0;
+ (module->pp_shortcuts[j] != NULL) && (j < MODULE_SHORTCUT_MAX);
+ j++)
+ {
+ if (!strcmp (module->pp_shortcuts[j], psz_shortcut))
+ {
+ module_hold (module);
+ goto out;
+ }
+ }
+ }
+out:
+ module_list_free (list);
+ return module;
+}
+
+/**
* GetModuleNamesForCapability
*
* Return a NULL terminated array with the names of the modules
More information about the vlc-devel
mailing list