1 /*****************************************************************************
2 * modules_plugin.h : Plugin management functions used by the core application.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * Automatically generated from src/misc/modules_plugin.h.in by bootstrap.sh
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
25 * Inline functions for handling dynamic modules
26 *****************************************************************************/
28 /*****************************************************************************
29 * module_load: load a dynamic library
30 *****************************************************************************
31 * This function loads a dynamically linked library using a system dependant
32 * method, and returns a non-zero value on error, zero otherwise.
33 *****************************************************************************/
34 static int module_load( const char * psz_filename, module_handle_t * handle )
37 *handle = load_add_on( psz_filename );
38 return( *handle < 0 );
41 *handle = LoadLibrary( psz_filename );
42 return( *handle == NULL );
44 #elif defined(RTLD_NOW)
45 # if defined(SYS_LINUX)
46 /* We should NOT open modules with RTLD_GLOBAL, or we are going to get
47 * namespace collisions when two modules have common public symbols,
48 * but ALSA is being a pest here. */
49 if( strstr( psz_filename, "alsa.so" ) )
51 *handle = dlopen( psz_filename, RTLD_NOW | RTLD_GLOBAL );
52 return( *handle == NULL );
55 *handle = dlopen( psz_filename, RTLD_NOW );
56 return( *handle == NULL );
59 *handle = dlopen( psz_filename, DL_LAZY );
60 return( *handle == NULL );
65 /*****************************************************************************
66 * module_unload: unload a dynamic library
67 *****************************************************************************
68 * This function unloads a previously opened dynamically linked library
69 * using a system dependant method. No return value is taken in consideration,
70 * since some libraries sometimes refuse to close properly.
71 *****************************************************************************/
72 static void module_unload( module_handle_t handle )
75 unload_add_on( handle );
78 FreeLibrary( handle );
87 /*****************************************************************************
88 * module_getsymbol: get a symbol from a dynamic library
89 *****************************************************************************
90 * This function queries a loaded library for a symbol specified in a
91 * string, and returns a pointer to it. We don't check for dlerror() or
92 * similar functions, since we want a non-NULL symbol anyway.
93 *****************************************************************************/
94 static void * _module_getsymbol( module_handle_t handle,
95 const char * psz_function )
99 if( B_OK == get_image_symbol( handle, psz_function,
100 B_SYMBOL_TYPE_TEXT, &p_symbol ) )
110 return( (void *)GetProcAddress( handle, psz_function ) );
113 return( dlsym( handle, psz_function ) );
118 static void * module_getsymbol( module_handle_t handle,
119 const char * psz_function )
121 void * p_symbol = _module_getsymbol( handle, psz_function );
123 /* MacOS X dl library expects symbols to begin with "_". So do
124 * some other operating systems. That's really lame, but hey, what
126 if( p_symbol == NULL )
128 char *psz_call = malloc( strlen( psz_function ) + 2 );
130 strcpy( psz_call + 1, psz_function );
132 p_symbol = _module_getsymbol( handle, psz_call );
139 /*****************************************************************************
140 * module_error: wrapper for dlerror()
141 *****************************************************************************
142 * This function returns the error message of the last module operation. It
143 * returns the string "failed" on systems which do not have a dlerror() like
144 * function. psz_buffer can be used to store temporary data, it is guaranteed
145 * to be kept intact until the return value of module_error has been used.
146 *****************************************************************************/
147 static const char * module_error( char *psz_buffer )
149 #if defined(SYS_BEOS)
153 int i, i_error = GetLastError();
155 FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
156 NULL, i_error, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
157 (LPTSTR) psz_buffer, 256, NULL);
159 /* Go to the end of the string */
161 psz_buffer[i] && psz_buffer[i] != '\r' && psz_buffer[i] != '\n';
166 snprintf( psz_buffer + i, 256 - i, " (error %i)", i_error );
167 psz_buffer[ 255 ] = '\0';
178 /*****************************************************************************
179 * STORE_SYMBOLS: store known symbols into p_symbols for plugin access.
180 *****************************************************************************/
181 #define STORE_SYMBOLS( p_symbols ) \
182 (p_symbols)->__aout_NewInstance_inner = __aout_NewInstance; \
183 (p_symbols)->aout_DeleteInstance_inner = aout_DeleteInstance; \
184 (p_symbols)->aout_BufferNew_inner = aout_BufferNew; \
185 (p_symbols)->aout_BufferDelete_inner = aout_BufferDelete; \
186 (p_symbols)->aout_BufferPlay_inner = aout_BufferPlay; \
187 (p_symbols)->aout_FormatTo_inner = aout_FormatTo; \
188 (p_symbols)->__aout_InputNew_inner = __aout_InputNew; \
189 (p_symbols)->aout_InputDelete_inner = aout_InputDelete; \
190 (p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \
191 (p_symbols)->__config_GetInt_inner = __config_GetInt; \
192 (p_symbols)->__config_PutInt_inner = __config_PutInt; \
193 (p_symbols)->__config_GetFloat_inner = __config_GetFloat; \
194 (p_symbols)->__config_PutFloat_inner = __config_PutFloat; \
195 (p_symbols)->__config_GetPsz_inner = __config_GetPsz; \
196 (p_symbols)->__config_PutPsz_inner = __config_PutPsz; \
197 (p_symbols)->__config_LoadCmdLine_inner = __config_LoadCmdLine; \
198 (p_symbols)->config_GetHomeDir_inner = config_GetHomeDir; \
199 (p_symbols)->__config_LoadConfigFile_inner = __config_LoadConfigFile; \
200 (p_symbols)->__config_SaveConfigFile_inner = __config_SaveConfigFile; \
201 (p_symbols)->config_FindConfig_inner = config_FindConfig; \
202 (p_symbols)->config_Duplicate_inner = config_Duplicate; \
203 (p_symbols)->config_SetCallbacks_inner = config_SetCallbacks; \
204 (p_symbols)->config_UnsetCallbacks_inner = config_UnsetCallbacks; \
205 (p_symbols)->InitBitstream_inner = InitBitstream; \
206 (p_symbols)->NextDataPacket_inner = NextDataPacket; \
207 (p_symbols)->BitstreamNextDataPacket_inner = BitstreamNextDataPacket; \
208 (p_symbols)->UnalignedShowBits_inner = UnalignedShowBits; \
209 (p_symbols)->UnalignedRemoveBits_inner = UnalignedRemoveBits; \
210 (p_symbols)->UnalignedGetBits_inner = UnalignedGetBits; \
211 (p_symbols)->CurrentPTS_inner = CurrentPTS; \
212 (p_symbols)->DecoderError_inner = DecoderError; \
213 (p_symbols)->__input_SetStatus_inner = __input_SetStatus; \
214 (p_symbols)->__input_Seek_inner = __input_Seek; \
215 (p_symbols)->__input_Tell_inner = __input_Tell; \
216 (p_symbols)->input_DumpStream_inner = input_DumpStream; \
217 (p_symbols)->input_OffsetToTime_inner = input_OffsetToTime; \
218 (p_symbols)->input_ToggleES_inner = input_ToggleES; \
219 (p_symbols)->input_ChangeArea_inner = input_ChangeArea; \
220 (p_symbols)->input_ChangeProgram_inner = input_ChangeProgram; \
221 (p_symbols)->input_InitStream_inner = input_InitStream; \
222 (p_symbols)->input_EndStream_inner = input_EndStream; \
223 (p_symbols)->input_FindProgram_inner = input_FindProgram; \
224 (p_symbols)->input_AddProgram_inner = input_AddProgram; \
225 (p_symbols)->input_DelProgram_inner = input_DelProgram; \
226 (p_symbols)->input_SetProgram_inner = input_SetProgram; \
227 (p_symbols)->input_AddArea_inner = input_AddArea; \
228 (p_symbols)->input_DelArea_inner = input_DelArea; \
229 (p_symbols)->input_FindES_inner = input_FindES; \
230 (p_symbols)->input_AddES_inner = input_AddES; \
231 (p_symbols)->input_DelES_inner = input_DelES; \
232 (p_symbols)->input_SelectES_inner = input_SelectES; \
233 (p_symbols)->input_UnselectES_inner = input_UnselectES; \
234 (p_symbols)->input_DecodePES_inner = input_DecodePES; \
235 (p_symbols)->input_ClockManageControl_inner = input_ClockManageControl; \
236 (p_symbols)->input_ClockManageRef_inner = input_ClockManageRef; \
237 (p_symbols)->input_ClockGetTS_inner = input_ClockGetTS; \
238 (p_symbols)->input_InfoCategory_inner = input_InfoCategory; \
239 (p_symbols)->input_AddInfo_inner = input_AddInfo; \
240 (p_symbols)->input_BuffersEnd_inner = input_BuffersEnd; \
241 (p_symbols)->input_NewBuffer_inner = input_NewBuffer; \
242 (p_symbols)->input_ReleaseBuffer_inner = input_ReleaseBuffer; \
243 (p_symbols)->input_ShareBuffer_inner = input_ShareBuffer; \
244 (p_symbols)->input_NewPacket_inner = input_NewPacket; \
245 (p_symbols)->input_DeletePacket_inner = input_DeletePacket; \
246 (p_symbols)->input_NewPES_inner = input_NewPES; \
247 (p_symbols)->input_DeletePES_inner = input_DeletePES; \
248 (p_symbols)->input_FillBuffer_inner = input_FillBuffer; \
249 (p_symbols)->input_Peek_inner = input_Peek; \
250 (p_symbols)->input_SplitBuffer_inner = input_SplitBuffer; \
251 (p_symbols)->input_AccessInit_inner = input_AccessInit; \
252 (p_symbols)->input_AccessReinit_inner = input_AccessReinit; \
253 (p_symbols)->input_AccessEnd_inner = input_AccessEnd; \
254 (p_symbols)->__input_FDClose_inner = __input_FDClose; \
255 (p_symbols)->__input_FDNetworkClose_inner = __input_FDNetworkClose; \
256 (p_symbols)->input_FDRead_inner = input_FDRead; \
257 (p_symbols)->input_FDNetworkRead_inner = input_FDNetworkRead; \
258 (p_symbols)->input_FDSeek_inner = input_FDSeek; \
259 (p_symbols)->__intf_Create_inner = __intf_Create; \
260 (p_symbols)->intf_RunThread_inner = intf_RunThread; \
261 (p_symbols)->intf_StopThread_inner = intf_StopThread; \
262 (p_symbols)->intf_Destroy_inner = intf_Destroy; \
263 (p_symbols)->__intf_Eject_inner = __intf_Eject; \
264 (p_symbols)->GetLang_1_inner = GetLang_1; \
265 (p_symbols)->GetLang_2T_inner = GetLang_2T; \
266 (p_symbols)->GetLang_2B_inner = GetLang_2B; \
267 (p_symbols)->DecodeLanguage_inner = DecodeLanguage; \
268 (p_symbols)->__module_Need_inner = __module_Need; \
269 (p_symbols)->__module_Unneed_inner = __module_Unneed; \
270 (p_symbols)->mstrtime_inner = mstrtime; \
271 (p_symbols)->mdate_inner = mdate; \
272 (p_symbols)->mwait_inner = mwait; \
273 (p_symbols)->msleep_inner = msleep; \
274 (p_symbols)->__network_ChannelJoin_inner = __network_ChannelJoin; \
275 (p_symbols)->__network_ChannelCreate_inner = __network_ChannelCreate; \
276 (p_symbols)->__vout_CreateThread_inner = __vout_CreateThread; \
277 (p_symbols)->vout_DestroyThread_inner = vout_DestroyThread; \
278 (p_symbols)->vout_ChromaCmp_inner = vout_ChromaCmp; \
279 (p_symbols)->vout_CreatePicture_inner = vout_CreatePicture; \
280 (p_symbols)->vout_AllocatePicture_inner = vout_AllocatePicture; \
281 (p_symbols)->vout_DestroyPicture_inner = vout_DestroyPicture; \
282 (p_symbols)->vout_DisplayPicture_inner = vout_DisplayPicture; \
283 (p_symbols)->vout_DatePicture_inner = vout_DatePicture; \
284 (p_symbols)->vout_LinkPicture_inner = vout_LinkPicture; \
285 (p_symbols)->vout_UnlinkPicture_inner = vout_UnlinkPicture; \
286 (p_symbols)->vout_PlacePicture_inner = vout_PlacePicture; \
287 (p_symbols)->vout_CreateSubPicture_inner = vout_CreateSubPicture; \
288 (p_symbols)->vout_DestroySubPicture_inner = vout_DestroySubPicture; \
289 (p_symbols)->vout_DisplaySubPicture_inner = vout_DisplaySubPicture; \
290 (p_symbols)->__msg_Generic_inner = __msg_Generic; \
291 (p_symbols)->__msg_Info_inner = __msg_Info; \
292 (p_symbols)->__msg_Err_inner = __msg_Err; \
293 (p_symbols)->__msg_Warn_inner = __msg_Warn; \
294 (p_symbols)->__msg_Dbg_inner = __msg_Dbg; \
295 (p_symbols)->__msg_Subscribe_inner = __msg_Subscribe; \
296 (p_symbols)->__msg_Unsubscribe_inner = __msg_Unsubscribe; \
297 (p_symbols)->__vlc_object_create_inner = __vlc_object_create; \
298 (p_symbols)->__vlc_object_destroy_inner = __vlc_object_destroy; \
299 (p_symbols)->__vlc_object_find_inner = __vlc_object_find; \
300 (p_symbols)->__vlc_object_yield_inner = __vlc_object_yield; \
301 (p_symbols)->__vlc_object_release_inner = __vlc_object_release; \
302 (p_symbols)->__vlc_object_detach_inner = __vlc_object_detach; \
303 (p_symbols)->__vlc_object_attach_inner = __vlc_object_attach; \
304 (p_symbols)->__vlc_dumpstructure_inner = __vlc_dumpstructure; \
305 (p_symbols)->playlist_Command_inner = playlist_Command; \
306 (p_symbols)->playlist_Add_inner = playlist_Add; \
307 (p_symbols)->playlist_Delete_inner = playlist_Delete; \
308 (p_symbols)->__vlc_threads_init_inner = __vlc_threads_init; \
309 (p_symbols)->__vlc_threads_end_inner = __vlc_threads_end; \
310 (p_symbols)->__vlc_mutex_init_inner = __vlc_mutex_init; \
311 (p_symbols)->__vlc_mutex_destroy_inner = __vlc_mutex_destroy; \
312 (p_symbols)->__vlc_cond_init_inner = __vlc_cond_init; \
313 (p_symbols)->__vlc_cond_destroy_inner = __vlc_cond_destroy; \
314 (p_symbols)->__vlc_thread_create_inner = __vlc_thread_create; \
315 (p_symbols)->__vlc_thread_ready_inner = __vlc_thread_ready; \
316 (p_symbols)->__vlc_thread_join_inner = __vlc_thread_join; \