]> git.sesse.net Git - vlc/blob - src/misc/modules_plugin.h
4bd86bccd786ff43cdc1f8adf3f45c665b031384
[vlc] / src / misc / modules_plugin.h
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
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Inline functions for handling dynamic modules
26  *****************************************************************************/
27
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 inline int module_load( const char * psz_filename,
35                                module_handle_t * handle )
36 {
37 #ifdef SYS_BEOS
38     *handle = load_add_on( psz_filename );
39     return( *handle < 0 );
40
41 #elif defined(WIN32)
42     *handle = LoadLibrary( psz_filename );
43     return( *handle == NULL ); 
44
45 #elif defined(RTLD_NOW)
46 #   if defined(SYS_LINUX)
47     /* We should NOT open modules with RTLD_GLOBAL, or we are going to get
48      * namespace collisions when two modules have common public symbols,
49      * but ALSA is being a pest here. */
50     if( strstr( psz_filename, "alsa.so" ) )
51     {
52         *handle = dlopen( psz_filename, RTLD_NOW | RTLD_GLOBAL );
53         return( *handle == NULL );
54     }
55 #   endif
56     *handle = dlopen( psz_filename, RTLD_NOW );
57     return( *handle == NULL );
58
59 #else
60     *handle = dlopen( psz_filename, DL_LAZY );
61     return( *handle == NULL );
62
63 #endif
64 }
65
66 /*****************************************************************************
67  * module_unload: unload a dynamic library
68  *****************************************************************************
69  * This function unloads a previously opened dynamically linked library
70  * using a system dependant method. No return value is taken in consideration,
71  * since some libraries sometimes refuse to close properly.
72  *****************************************************************************/
73 static inline void module_unload( module_handle_t handle )
74 {
75 #ifdef SYS_BEOS
76     unload_add_on( handle );
77
78 #elif defined(WIN32)
79     FreeLibrary( handle );
80
81 #else
82     dlclose( handle );
83
84 #endif
85     return;
86 }
87
88 /*****************************************************************************
89  * module_getsymbol: get a symbol from a dynamic library
90  *****************************************************************************
91  * This function queries a loaded library for a symbol specified in a
92  * string, and returns a pointer to it. We don't check for dlerror() or
93  * similar functions, since we want a non-NULL symbol anyway.
94  *****************************************************************************/
95 static inline void * _module_getsymbol( module_handle_t handle,
96                                         const char * psz_function )
97 {
98 #ifdef SYS_BEOS
99     void * p_symbol;
100     if( B_OK == get_image_symbol( handle, psz_function,
101                                   B_SYMBOL_TYPE_TEXT, &p_symbol ) )
102     {
103         return( p_symbol );
104     }
105     else
106     {
107         return( NULL );
108     }
109
110 #elif defined(WIN32)
111     return( (void *)GetProcAddress( handle, psz_function ) );
112
113 #else
114     return( dlsym( handle, psz_function ) );
115
116 #endif
117 }
118
119 static inline void * module_getsymbol( module_handle_t handle,
120                                        const char * psz_function )
121 {
122     void * p_symbol = _module_getsymbol( handle, psz_function );
123
124     /* MacOS X dl library expects symbols to begin with "_". So do
125      * some other operating systems. That's really lame, but hey, what
126      * can we do ? */
127     if( p_symbol == NULL )
128     {
129         char *psz_call = malloc( strlen( psz_function ) + 2 );
130
131         strcpy( psz_call + 1, psz_function );
132         psz_call[ 0 ] = '_';
133         p_symbol = _module_getsymbol( handle, psz_call );
134         free( psz_call );
135     }
136
137     return p_symbol;
138 }
139
140 /*****************************************************************************
141  * module_error: wrapper for dlerror()
142  *****************************************************************************
143  * This function returns the error message of the last module operation. It
144  * returns the string "failed" on systems which do not have a dlerror() like
145  * function. psz_buffer can be used to store temporary data, it is guaranteed
146  * to be kept intact until the return value of module_error has been used.
147  *****************************************************************************/
148 static inline const char * module_error( char *psz_buffer )
149 {
150 #if defined(SYS_BEOS)
151     return( "failed" );
152
153 #elif defined(WIN32)
154     int i, i_error = GetLastError();
155
156     FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
157                    NULL, i_error, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
158                    (LPTSTR) psz_buffer, 256, NULL);
159
160     /* Go to the end of the string */
161     for( i = 0;
162          psz_buffer[i] && psz_buffer[i] != '\r' && psz_buffer[i] != '\n';
163          i++ ) {};
164
165     if( psz_buffer[i] )
166     {
167         snprintf( psz_buffer + i, 256 - i, " (error %i)", i_error );
168         psz_buffer[ 255 ] = '\0';
169     }
170     
171     return psz_buffer;
172
173 #else
174     return( dlerror() );
175
176 #endif
177 }
178
179 /*****************************************************************************
180  * STORE_SYMBOLS: store known symbols into p_symbols for plugin access.
181  *****************************************************************************/
182 #define STORE_SYMBOLS( p_symbols ) \
183     (p_symbols)->__aout_NewInstance_inner = __aout_NewInstance; \
184     (p_symbols)->aout_DeleteInstance_inner = aout_DeleteInstance; \
185     (p_symbols)->aout_BufferNew_inner = aout_BufferNew; \
186     (p_symbols)->aout_BufferDelete_inner = aout_BufferDelete; \
187     (p_symbols)->aout_BufferPlay_inner = aout_BufferPlay; \
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_detach_all_inner = __vlc_object_detach_all; \
304     (p_symbols)->__vlc_object_attach_inner = __vlc_object_attach; \
305     (p_symbols)->__vlc_dumpstructure_inner = __vlc_dumpstructure; \
306     (p_symbols)->playlist_Command_inner = playlist_Command; \
307     (p_symbols)->playlist_Add_inner = playlist_Add; \
308     (p_symbols)->playlist_Delete_inner = playlist_Delete; \
309     (p_symbols)->__vlc_threads_init_inner = __vlc_threads_init; \
310     (p_symbols)->__vlc_threads_end_inner = __vlc_threads_end; \
311     (p_symbols)->__vlc_mutex_init_inner = __vlc_mutex_init; \
312     (p_symbols)->__vlc_mutex_destroy_inner = __vlc_mutex_destroy; \
313     (p_symbols)->__vlc_cond_init_inner = __vlc_cond_init; \
314     (p_symbols)->__vlc_cond_destroy_inner = __vlc_cond_destroy; \
315     (p_symbols)->__vlc_thread_create_inner = __vlc_thread_create; \
316     (p_symbols)->__vlc_thread_ready_inner = __vlc_thread_ready; \
317     (p_symbols)->__vlc_thread_join_inner = __vlc_thread_join; \
318