1 /*****************************************************************************
2 * vlc_modules.h : Module descriptor and load functions
3 *****************************************************************************
4 * Copyright (C) 2001-2011 VLC authors and VideoLAN
6 * Authors: Samuel Hocevar <sam@zoy.org>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
24 #define VLC_MODULES_H 1
28 * This file defines functions for modules in vlc
31 typedef int (*vlc_activate_t
)(void *func
, bool forced
, va_list args
);
34 /*****************************************************************************
36 *****************************************************************************/
39 * Finds and instantiates the best module of a certain type.
40 * All candidates modules having the specified capability and name will be
41 * sorted in decreasing order of priority. Then the probe callback will be
42 * invoked for each module, until it succeeds (returns 0), or all candidate
43 * module failed to initialize.
45 * The probe callback first parameter is the address of the module entry point.
46 * Further parameters are passed as an argument list; it corresponds to the
47 * variable arguments passed to this function. This scheme is meant to
48 * support arbitrary prototypes for the module entry point.
50 * \param log logger for debugging (or NULL to ignore)
51 * \param capability capability, i.e. class of module
52 * \param name name of the module asked, if any
53 * \param strict if true, do not fallback to plugin with a different name
54 * but the same capability
55 * \param probe module probe callback
56 * \return the module or NULL in case of a failure
58 VLC_API module_t
*vlc_module_load(struct vlc_logger
*log
, const char *cap
,
59 const char *name
, bool strict
,
60 vlc_activate_t probe
, ... ) VLC_USED
;
62 #define vlc_module_load(ctx, cap, name, strict, ...) \
64 struct vlc_logger *: \
65 vlc_module_load((void *)(ctx), cap, name, strict, __VA_ARGS__), \
67 vlc_module_load((void *)(ctx), cap, name, strict, __VA_ARGS__), \
69 vlc_module_load(vlc_object_logger((vlc_object_t *)(ctx)), cap, \
70 name, strict, __VA_ARGS__))
73 VLC_API module_t
* module_need( vlc_object_t
*, const char *, const char *, bool ) VLC_USED
;
74 #define module_need(a,b,c,d) module_need(VLC_OBJECT(a),b,c,d)
77 static inline module_t
*module_need_var(vlc_object_t
*obj
, const char *cap
,
80 char *list
= var_InheritString(obj
, varname
);
81 module_t
*m
= module_need(obj
, cap
, list
, false);
86 #define module_need_var(a,b,c) module_need_var(VLC_OBJECT(a),b,c)
88 VLC_API
void module_unneed( vlc_object_t
*, module_t
* );
89 #define module_unneed(a,b) module_unneed(VLC_OBJECT(a),b)
92 * Checks if a module exists.
94 * \param name name of the module
95 * \retval true if the module exists
96 * \retval false if the module does not exist (in the running installation)
98 VLC_API
bool module_exists(const char *) VLC_USED
;
101 * Get a pointer to a module_t given it's name.
103 * \param name the name of the module
104 * \return a pointer to the module or NULL in case of a failure
106 VLC_API module_t
*module_find(const char *name
) VLC_USED
;
109 * Gets the table of module configuration items.
111 * \note Use module_config_free() to release the allocated memory.
113 * \param module the module
114 * \param psize the size of the configuration returned
115 * \return the configuration as an array
117 VLC_API module_config_t
*module_config_get(const module_t
*module
,
118 unsigned *restrict psize
) VLC_USED
;
121 * Releases the configuration items table.
123 * \param tab base address of a table returned by module_config_get()
125 VLC_API
void module_config_free( module_config_t
*tab
);
127 VLC_API
void module_list_free(module_t
**);
128 VLC_API module_t
** module_list_get(size_t *n
) VLC_USED
;
131 * Checks whether a module implements a capability.
133 * \param m the module
134 * \param cap the capability to check
135 * \retval true if the module has the capability
136 * \retval false if the module has another capability
138 VLC_API
bool module_provides(const module_t
*m
, const char *cap
);
141 * Gets the internal name of a module.
143 * \param m the module
144 * \return the module name
146 VLC_API
const char * module_get_object(const module_t
*m
) VLC_USED
;
149 * Gets the human-friendly name of a module.
151 * \param m the module
152 * \param longname TRUE to have the long name of the module
153 * \return the short or long name of the module
155 VLC_API
const char *module_get_name(const module_t
*m
, bool longname
) VLC_USED
;
156 #define module_GetLongName( m ) module_get_name( m, true )
159 * Gets the help text for a module.
161 * \param m the module
164 VLC_API
const char *module_get_help(const module_t
*m
) VLC_USED
;
167 * Gets the capability string of a module.
169 * \param m the module
170 * \return the capability, or "none" if unspecified
172 VLC_API
const char *module_get_capability(const module_t
*m
) VLC_USED
;
175 * Gets the precedence of a module.
177 * \param m the module
178 * return the score for the capability
180 VLC_API
int module_get_score(const module_t
*m
) VLC_USED
;
183 * Translates a string using the module's text domain
185 * \param m the module
186 * \param s the American English ASCII string to localize
187 * \return the gettext-translated string
189 VLC_API
const char *module_gettext(const module_t
*m
, const char *s
) VLC_USED
;
191 VLC_USED
static inline module_t
*module_get_main (void)
193 return module_find ("core");
195 #define module_get_main(a) module_get_main()
197 VLC_USED
static inline bool module_is_main( const module_t
* p_module
)
199 return !strcmp( module_get_object( p_module
), "core" );
202 #endif /* VLC_MODULES_H */