]> git.sesse.net Git - vlc/blob - src/misc/modules_plugin.h
* ALL: added *.am files here and there for future automake support.
[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 int module_load( const char * psz_filename, module_handle_t * handle )
35 {
36 #ifdef SYS_BEOS
37     *handle = load_add_on( psz_filename );
38     return( *handle < 0 );
39
40 #elif defined(WIN32)
41     *handle = LoadLibrary( psz_filename );
42     return( *handle == NULL ); 
43
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" ) )
50     {
51         *handle = dlopen( psz_filename, RTLD_NOW | RTLD_GLOBAL );
52         return( *handle == NULL );
53     }
54 #   endif
55     *handle = dlopen( psz_filename, RTLD_NOW );
56     return( *handle == NULL );
57
58 #else
59     *handle = dlopen( psz_filename, DL_LAZY );
60     return( *handle == NULL );
61
62 #endif
63 }
64
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 )
73 {
74 #ifdef SYS_BEOS
75     unload_add_on( handle );
76
77 #elif defined(WIN32)
78     FreeLibrary( handle );
79
80 #else
81     dlclose( handle );
82
83 #endif
84     return;
85 }
86
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 )
96 {
97 #ifdef SYS_BEOS
98     void * p_symbol;
99     if( B_OK == get_image_symbol( handle, psz_function,
100                                   B_SYMBOL_TYPE_TEXT, &p_symbol ) )
101     {
102         return( p_symbol );
103     }
104     else
105     {
106         return( NULL );
107     }
108
109 #elif defined(WIN32)
110     return( (void *)GetProcAddress( handle, psz_function ) );
111
112 #else
113     return( dlsym( handle, psz_function ) );
114
115 #endif
116 }
117
118 static void * module_getsymbol( module_handle_t handle,
119                                 const char * psz_function )
120 {
121     void * p_symbol = _module_getsymbol( handle, psz_function );
122
123     /* MacOS X dl library expects symbols to begin with "_". So do
124      * some other operating systems. That's really lame, but hey, what
125      * can we do ? */
126     if( p_symbol == NULL )
127     {
128         char *psz_call = malloc( strlen( psz_function ) + 2 );
129
130         strcpy( psz_call + 1, psz_function );
131         psz_call[ 0 ] = '_';
132         p_symbol = _module_getsymbol( handle, psz_call );
133         free( psz_call );
134     }
135
136     return p_symbol;
137 }
138
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 )
148 {
149 #if defined(SYS_BEOS)
150     return( "failed" );
151
152 #elif defined(WIN32)
153     int i, i_error = GetLastError();
154
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);
158
159     /* Go to the end of the string */
160     for( i = 0;
161          psz_buffer[i] && psz_buffer[i] != '\r' && psz_buffer[i] != '\n';
162          i++ ) {};
163
164     if( psz_buffer[i] )
165     {
166         snprintf( psz_buffer + i, 256 - i, " (error %i)", i_error );
167         psz_buffer[ 255 ] = '\0';
168     }
169     
170     return psz_buffer;
171
172 #else
173     return( dlerror() );
174
175 #endif
176 }
177
178 /*****************************************************************************
179  * STORE_SYMBOLS: store known symbols into p_symbols for plugin access.
180  *****************************************************************************/
181 #define STORE_SYMBOLS( p_symbols ) \
182     (p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \
183     (p_symbols)->aout_FormatNbChannels_inner = aout_FormatNbChannels; \
184     (p_symbols)->aout_FifoPop_inner = aout_FifoPop; \
185     (p_symbols)->aout_VolumeSoftInit_inner = aout_VolumeSoftInit; \
186     (p_symbols)->aout_VolumeNoneInit_inner = aout_VolumeNoneInit; \
187     (p_symbols)->__aout_New_inner = __aout_New; \
188     (p_symbols)->aout_Delete_inner = aout_Delete; \
189     (p_symbols)->aout_DateInit_inner = aout_DateInit; \
190     (p_symbols)->aout_DateSet_inner = aout_DateSet; \
191     (p_symbols)->aout_DateMove_inner = aout_DateMove; \
192     (p_symbols)->aout_DateGet_inner = aout_DateGet; \
193     (p_symbols)->aout_DateIncrement_inner = aout_DateIncrement; \
194     (p_symbols)->__aout_DecNew_inner = __aout_DecNew; \
195     (p_symbols)->aout_DecDelete_inner = aout_DecDelete; \
196     (p_symbols)->aout_DecNewBuffer_inner = aout_DecNewBuffer; \
197     (p_symbols)->aout_DecDeleteBuffer_inner = aout_DecDeleteBuffer; \
198     (p_symbols)->aout_DecPlay_inner = aout_DecPlay; \
199     (p_symbols)->aout_VolumeGet_inner = aout_VolumeGet; \
200     (p_symbols)->aout_VolumeSet_inner = aout_VolumeSet; \
201     (p_symbols)->aout_VolumeInfos_inner = aout_VolumeInfos; \
202     (p_symbols)->aout_VolumeUp_inner = aout_VolumeUp; \
203     (p_symbols)->aout_VolumeDown_inner = aout_VolumeDown; \
204     (p_symbols)->aout_Restart_inner = aout_Restart; \
205     (p_symbols)->__config_GetInt_inner = __config_GetInt; \
206     (p_symbols)->__config_PutInt_inner = __config_PutInt; \
207     (p_symbols)->__config_GetFloat_inner = __config_GetFloat; \
208     (p_symbols)->__config_PutFloat_inner = __config_PutFloat; \
209     (p_symbols)->__config_GetPsz_inner = __config_GetPsz; \
210     (p_symbols)->__config_PutPsz_inner = __config_PutPsz; \
211     (p_symbols)->__config_LoadCmdLine_inner = __config_LoadCmdLine; \
212     (p_symbols)->config_GetHomeDir_inner = config_GetHomeDir; \
213     (p_symbols)->__config_LoadConfigFile_inner = __config_LoadConfigFile; \
214     (p_symbols)->__config_SaveConfigFile_inner = __config_SaveConfigFile; \
215     (p_symbols)->config_FindConfig_inner = config_FindConfig; \
216     (p_symbols)->config_Duplicate_inner = config_Duplicate; \
217     (p_symbols)->config_SetCallbacks_inner = config_SetCallbacks; \
218     (p_symbols)->config_UnsetCallbacks_inner = config_UnsetCallbacks; \
219     (p_symbols)->InitBitstream_inner = InitBitstream; \
220     (p_symbols)->NextDataPacket_inner = NextDataPacket; \
221     (p_symbols)->BitstreamNextDataPacket_inner = BitstreamNextDataPacket; \
222     (p_symbols)->UnalignedShowBits_inner = UnalignedShowBits; \
223     (p_symbols)->UnalignedRemoveBits_inner = UnalignedRemoveBits; \
224     (p_symbols)->UnalignedGetBits_inner = UnalignedGetBits; \
225     (p_symbols)->CurrentPTS_inner = CurrentPTS; \
226     (p_symbols)->NextPTS_inner = NextPTS; \
227     (p_symbols)->DecoderError_inner = DecoderError; \
228     (p_symbols)->__input_SetStatus_inner = __input_SetStatus; \
229     (p_symbols)->__input_Seek_inner = __input_Seek; \
230     (p_symbols)->__input_Tell_inner = __input_Tell; \
231     (p_symbols)->input_DumpStream_inner = input_DumpStream; \
232     (p_symbols)->input_OffsetToTime_inner = input_OffsetToTime; \
233     (p_symbols)->input_ToggleES_inner = input_ToggleES; \
234     (p_symbols)->input_ChangeArea_inner = input_ChangeArea; \
235     (p_symbols)->input_ChangeProgram_inner = input_ChangeProgram; \
236     (p_symbols)->input_InitStream_inner = input_InitStream; \
237     (p_symbols)->input_EndStream_inner = input_EndStream; \
238     (p_symbols)->input_FindProgram_inner = input_FindProgram; \
239     (p_symbols)->input_AddProgram_inner = input_AddProgram; \
240     (p_symbols)->input_DelProgram_inner = input_DelProgram; \
241     (p_symbols)->input_SetProgram_inner = input_SetProgram; \
242     (p_symbols)->input_AddArea_inner = input_AddArea; \
243     (p_symbols)->input_DelArea_inner = input_DelArea; \
244     (p_symbols)->input_FindES_inner = input_FindES; \
245     (p_symbols)->input_AddES_inner = input_AddES; \
246     (p_symbols)->input_DelES_inner = input_DelES; \
247     (p_symbols)->input_SelectES_inner = input_SelectES; \
248     (p_symbols)->input_UnselectES_inner = input_UnselectES; \
249     (p_symbols)->input_DecodePES_inner = input_DecodePES; \
250     (p_symbols)->input_ClockManageControl_inner = input_ClockManageControl; \
251     (p_symbols)->input_ClockManageRef_inner = input_ClockManageRef; \
252     (p_symbols)->input_ClockGetTS_inner = input_ClockGetTS; \
253     (p_symbols)->input_InfoCategory_inner = input_InfoCategory; \
254     (p_symbols)->input_AddInfo_inner = input_AddInfo; \
255     (p_symbols)->input_BuffersEnd_inner = input_BuffersEnd; \
256     (p_symbols)->input_NewBuffer_inner = input_NewBuffer; \
257     (p_symbols)->input_ReleaseBuffer_inner = input_ReleaseBuffer; \
258     (p_symbols)->input_ShareBuffer_inner = input_ShareBuffer; \
259     (p_symbols)->input_NewPacket_inner = input_NewPacket; \
260     (p_symbols)->input_DeletePacket_inner = input_DeletePacket; \
261     (p_symbols)->input_NewPES_inner = input_NewPES; \
262     (p_symbols)->input_DeletePES_inner = input_DeletePES; \
263     (p_symbols)->input_FillBuffer_inner = input_FillBuffer; \
264     (p_symbols)->input_Peek_inner = input_Peek; \
265     (p_symbols)->input_SplitBuffer_inner = input_SplitBuffer; \
266     (p_symbols)->input_AccessInit_inner = input_AccessInit; \
267     (p_symbols)->input_AccessReinit_inner = input_AccessReinit; \
268     (p_symbols)->input_AccessEnd_inner = input_AccessEnd; \
269     (p_symbols)->__input_FDClose_inner = __input_FDClose; \
270     (p_symbols)->__input_FDNetworkClose_inner = __input_FDNetworkClose; \
271     (p_symbols)->input_FDRead_inner = input_FDRead; \
272     (p_symbols)->input_FDNetworkRead_inner = input_FDNetworkRead; \
273     (p_symbols)->input_FDSeek_inner = input_FDSeek; \
274     (p_symbols)->__intf_Create_inner = __intf_Create; \
275     (p_symbols)->intf_RunThread_inner = intf_RunThread; \
276     (p_symbols)->intf_StopThread_inner = intf_StopThread; \
277     (p_symbols)->intf_Destroy_inner = intf_Destroy; \
278     (p_symbols)->__intf_Eject_inner = __intf_Eject; \
279     (p_symbols)->GetLang_1_inner = GetLang_1; \
280     (p_symbols)->GetLang_2T_inner = GetLang_2T; \
281     (p_symbols)->GetLang_2B_inner = GetLang_2B; \
282     (p_symbols)->DecodeLanguage_inner = DecodeLanguage; \
283     (p_symbols)->__module_Need_inner = __module_Need; \
284     (p_symbols)->__module_Unneed_inner = __module_Unneed; \
285     (p_symbols)->mstrtime_inner = mstrtime; \
286     (p_symbols)->mdate_inner = mdate; \
287     (p_symbols)->mwait_inner = mwait; \
288     (p_symbols)->msleep_inner = msleep; \
289     (p_symbols)->__network_ChannelJoin_inner = __network_ChannelJoin; \
290     (p_symbols)->__network_ChannelCreate_inner = __network_ChannelCreate; \
291     (p_symbols)->__sout_NewInstance_inner = __sout_NewInstance; \
292     (p_symbols)->sout_DeleteInstance_inner = sout_DeleteInstance; \
293     (p_symbols)->__vout_CreateThread_inner = __vout_CreateThread; \
294     (p_symbols)->vout_DestroyThread_inner = vout_DestroyThread; \
295     (p_symbols)->vout_ChromaCmp_inner = vout_ChromaCmp; \
296     (p_symbols)->vout_CreatePicture_inner = vout_CreatePicture; \
297     (p_symbols)->vout_AllocatePicture_inner = vout_AllocatePicture; \
298     (p_symbols)->vout_DestroyPicture_inner = vout_DestroyPicture; \
299     (p_symbols)->vout_DisplayPicture_inner = vout_DisplayPicture; \
300     (p_symbols)->vout_DatePicture_inner = vout_DatePicture; \
301     (p_symbols)->vout_LinkPicture_inner = vout_LinkPicture; \
302     (p_symbols)->vout_UnlinkPicture_inner = vout_UnlinkPicture; \
303     (p_symbols)->vout_PlacePicture_inner = vout_PlacePicture; \
304     (p_symbols)->vout_CreateSubPicture_inner = vout_CreateSubPicture; \
305     (p_symbols)->vout_DestroySubPicture_inner = vout_DestroySubPicture; \
306     (p_symbols)->vout_DisplaySubPicture_inner = vout_DisplaySubPicture; \
307     (p_symbols)->__msg_Generic_inner = __msg_Generic; \
308     (p_symbols)->__msg_Info_inner = __msg_Info; \
309     (p_symbols)->__msg_Err_inner = __msg_Err; \
310     (p_symbols)->__msg_Warn_inner = __msg_Warn; \
311     (p_symbols)->__msg_Dbg_inner = __msg_Dbg; \
312     (p_symbols)->__msg_Subscribe_inner = __msg_Subscribe; \
313     (p_symbols)->__msg_Unsubscribe_inner = __msg_Unsubscribe; \
314     (p_symbols)->__vlc_object_create_inner = __vlc_object_create; \
315     (p_symbols)->__vlc_object_destroy_inner = __vlc_object_destroy; \
316     (p_symbols)->__vlc_object_attach_inner = __vlc_object_attach; \
317     (p_symbols)->__vlc_object_detach_inner = __vlc_object_detach; \
318     (p_symbols)->__vlc_object_find_inner = __vlc_object_find; \
319     (p_symbols)->__vlc_object_yield_inner = __vlc_object_yield; \
320     (p_symbols)->__vlc_object_release_inner = __vlc_object_release; \
321     (p_symbols)->__vlc_list_find_inner = __vlc_list_find; \
322     (p_symbols)->vlc_list_release_inner = vlc_list_release; \
323     (p_symbols)->__vlc_liststructure_inner = __vlc_liststructure; \
324     (p_symbols)->__vlc_dumpstructure_inner = __vlc_dumpstructure; \
325     (p_symbols)->playlist_Command_inner = playlist_Command; \
326     (p_symbols)->playlist_Add_inner = playlist_Add; \
327     (p_symbols)->playlist_Delete_inner = playlist_Delete; \
328     (p_symbols)->__vlc_threads_init_inner = __vlc_threads_init; \
329     (p_symbols)->__vlc_threads_end_inner = __vlc_threads_end; \
330     (p_symbols)->__vlc_mutex_init_inner = __vlc_mutex_init; \
331     (p_symbols)->__vlc_mutex_destroy_inner = __vlc_mutex_destroy; \
332     (p_symbols)->__vlc_cond_init_inner = __vlc_cond_init; \
333     (p_symbols)->__vlc_cond_destroy_inner = __vlc_cond_destroy; \
334     (p_symbols)->__vlc_thread_create_inner = __vlc_thread_create; \
335     (p_symbols)->__vlc_thread_ready_inner = __vlc_thread_ready; \
336     (p_symbols)->__vlc_thread_join_inner = __vlc_thread_join; \
337