]> git.sesse.net Git - vlc/blobdiff - src/misc/plugins.c
. kludge con pour �viter que �a segfaulte plus en sortant
[vlc] / src / misc / plugins.c
index ced56d186c491fb16e74188c40a3357e674d14a0..6f61d777cfc1443e64e4ea9b4c0d98f79306fee9 100644 (file)
@@ -9,27 +9,33 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- *
+ * 
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
+#include "defs.h"
 
 #include <stdlib.h>                                      /* free(), strtol() */
 #include <stdio.h>                                              /* sprintf() */
 
-#if defined(SYS_LINUX) || defined(SYS_BSD) || defined(SYS_GNU)
+#if defined(HAVE_DLFCN_H)                                /* Linux, BSD, Hurd */
 #include <dlfcn.h>                           /* dlopen(), dlsym(), dlclose() */
+
+#elif defined(HAVE_IMAGE_H)                                          /* BeOS */
+#include <image.h>
+
+#else
+#error no dynamic plugins available on your system !
 #endif
 
 #ifdef SYS_BEOS
-#include <image.h>
+#include "beos_specific.h"
 #endif
 
 #include "plugins.h"
@@ -43,33 +49,41 @@ int RequestPlugin ( plugin_id_t * p_plugin, char * psz_mask, char * psz_name )
     char * psz_plugin_path[ PLUGIN_PATH_COUNT ] =
     {
         ".",
-        PLUGIN_PATH,
-        /* these ones should disappear */
-        "./audio_output",
-        "./video_output",
-        "./interface"
+        "plugins/aout", "plugins/vout", "plugins/intf", /* these ones should disappear */
+        PLUGIN_PATH
     };
 
     i_length = strlen( psz_mask ) + strlen( psz_name );
 
     for ( i_count = 0 ; i_count < PLUGIN_PATH_COUNT ; i_count++ )
     {
+#ifdef SYS_BEOS
+        char * psz_program_path;
+        
+        psz_program_path = beos_GetProgramPath();
+        psz_plugin = malloc( strlen(psz_plugin_path[i_count]) + strlen(psz_program_path) + i_length + 6 );
+        sprintf( psz_plugin, "%s/%s/%s_%s.so", psz_program_path, psz_plugin_path[i_count], psz_mask, psz_name );        
+#else
         psz_plugin = malloc( strlen(psz_plugin_path[i_count]) + i_length + 6 );
         sprintf( psz_plugin, "%s/%s_%s.so", psz_plugin_path[i_count], psz_mask, psz_name );
-#ifdef SYS_BEOS
-        *p_plugin = load_addon_image( psz_plugin );
-#else  /* SYS_BEOS */
+#endif
+
+#if defined(HAVE_DLFCN_H)
         *p_plugin = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL );
-#endif /* SYS_BEOS */
+#elif defined(HAVE_IMAGE_H)
+        *p_plugin = load_add_on( psz_plugin );
+#endif
+
         free( psz_plugin );
 
-#ifdef SYS_BEOS
+#if defined(HAVE_DLFCN_H)
+       if( *p_plugin != NULL )
+#elif defined(HAVE_IMAGE_H)
         if( *p_plugin >= 0 )
-            return( 0 );
-#else
-        if( *p_plugin != NULL )
-            return( 0 );
 #endif
+        {
+            return( 0 );
+        }
     }
 
     return( -1 );
@@ -77,24 +91,23 @@ int RequestPlugin ( plugin_id_t * p_plugin, char * psz_mask, char * psz_name )
 
 void TrashPlugin ( plugin_id_t plugin )
 {
-#ifdef SYS_BEOS
-    unload_add_on( plugin );
-#else
+#if defined(HAVE_DLFCN_H)
     dlclose( plugin );
+#elif defined(HAVE_IMAGE_H)
+    unload_add_on( plugin );
 #endif
 }
 
 void * GetPluginFunction ( plugin_id_t plugin, char *psz_name )
 {
-#ifdef SYS_BEOS
-    void * p_func;
-    
+#if defined(HAVE_DLFCN_H)
+    return( dlsym(plugin, psz_name) );
+#elif defined(HAVE_IMAGE_H)
+    void * p_func;   
     if( get_image_symbol( plugin, psz_name, B_SYMBOL_TYPE_TEXT, &p_func ) )
         return( NULL );
     else
         return( p_func );    
-#else
-    return( dlsym(plugin, psz_name) );
 #endif
 }