Commit 455221a0 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/misc/modules.c: support for Unicode filenames under WinCE; VLC now

    successfully opens plugins.
  * ./modules/misc/dummy/*: hacked the dummy plugin so that it compiles for
    WinCE.
parent f5ee3066
......@@ -357,7 +357,7 @@ RSC=rc.exe
# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "_X86_" /d "x86" /d "i486" /r
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D "i486" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /Yu"stdafx.h" /Gz /c
# ADD CPP /nologo /W3 /Zi /Od /I "." /I "..\include" /D "DEBUG" /D "i486" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /Gz /c
# ADD CPP /nologo /W3 /Zi /Od /I "." /I "..\include" /D "DEBUG" /D "i486" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /FR /Gz /c
# SUBTRACT CPP /YX /Yc /Yu
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
......@@ -383,14 +383,257 @@ LINK32=link.exe
# Name "vlc - Win32 (WCE ARM) Debug"
# Name "vlc - Win32 (WCE x86em) Release"
# Name "vlc - Win32 (WCE x86em) Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE="..\evc\vlc.c"
!IF "$(CFG)" == "vlc - Win32 (WCE MIPS) Release"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE MIPS) Debug"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE SH4) Release"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE SH4) Debug"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE SH3) Release"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE SH3) Debug"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE ARM) Release"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE ARM) Debug"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE x86em) Release"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ELSEIF "$(CFG)" == "vlc - Win32 (WCE x86em) Debug"
DEP_CPP_VLC_C=\
"..\include\beos_specific.h"\
"..\include\configuration.h"\
"..\include\darwin_specific.h"\
"..\include\main.h"\
"..\include\modules.h"\
"..\include\modules_inner.h"\
"..\include\mtime.h"\
"..\include\os_specific.h"\
"..\include\variables.h"\
"..\include\vlc\vlc.h"\
"..\include\vlc_common.h"\
"..\include\vlc_config.h"\
"..\include\vlc_messages.h"\
"..\include\vlc_objects.h"\
"..\include\vlc_symbols.h"\
"..\include\vlc_threads.h"\
"..\include\vlc_threads_funcs.h"\
"..\include\win32_specific.h"\
".\config.h"\
!ENDIF
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
......
......@@ -15,7 +15,7 @@ Package=<4>
###############################################################################
Project: "plugin_foo"=.\plugin_foo\plugin_foo.vcp - Package Owner=<4>
Project: "plugin_dummy"=.\plugin_dummy.vcp - Package Owner=<4>
Package=<5>
{{{
......@@ -27,21 +27,6 @@ Package=<4>
###############################################################################
Project: "plugins"=.\plugins.vcp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libvlc
End Project Dependency
}}}
###############################################################################
Project: "vlc"=.\vlc.vcp - Package Owner=<4>
Package=<5>
......
......@@ -2,7 +2,7 @@
* modules_inner.h : Macros used from within a module.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules_inner.h,v 1.32 2002/09/30 11:05:33 sam Exp $
* $Id: modules_inner.h,v 1.33 2002/11/18 18:05:13 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -64,6 +64,14 @@
# define STORE_SYMBOLS p_symbols = p_module->p_symbols
#endif
#if defined( __PLUGIN__ ) && ( defined( WIN32 ) || defined( UNDER_CE ) )
# define DLL_SYMBOL __declspec(dllexport)
# define CDECL_SYMBOL __cdecl
#else
# define DLL_SYMBOL
# define CDECL_SYMBOL
#endif
#if defined( __cplusplus )
# define EXTERN_SYMBOL extern "C"
#else
......@@ -80,7 +88,8 @@
*/
#define vlc_module_begin( ) \
DECLARE_SYMBOLS; \
EXTERN_SYMBOL int __VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \
EXTERN_SYMBOL DLL_SYMBOL int CDECL_SYMBOL \
__VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \
{ \
int i_shortcut = 1, i_config = 0; \
module_config_t p_config[ 100 ]; \
......@@ -114,7 +123,7 @@
} \
return 0 && i_shortcut; \
} \
int __VLC_SYMBOL(vlc_entry) ( module_t * ) /* the ; gets added */
struct _u_n_u_s_e_d_ /* the ; gets added */
#define add_submodule( ) \
......
......@@ -2,7 +2,7 @@
* dec_dummy.c: dummy decoder plugin for vlc.
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: decoder.c,v 1.3 2002/10/27 16:58:13 gbazin Exp $
* $Id: decoder.c,v 1.4 2002/11/18 18:05:13 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -30,10 +30,15 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* write(), close() */
#endif
#include <sys/types.h> /* open() */
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h> /* open() */
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#include <stdio.h> /* sprintf() */
......@@ -66,9 +71,12 @@ static int Run ( decoder_fifo_t *p_fifo )
size_t i_bytes = 0;
char psz_file[100];
#ifndef UNDER_CE
int i_fd;
#endif
sprintf( psz_file, "stream.%i", p_fifo->i_object_id );
#ifndef UNDER_CE
i_fd = open( psz_file, O_WRONLY | O_CREAT | O_TRUNC, 00644 );
if( i_fd == -1 )
......@@ -78,6 +86,7 @@ static int Run ( decoder_fifo_t *p_fifo )
DecoderError( p_fifo );
return -1;
}
#endif
msg_Dbg( p_fifo, "dumping stream to file `%s'", psz_file );
......@@ -86,16 +95,20 @@ static int Run ( decoder_fifo_t *p_fifo )
msg_Err( p_fifo, "cannot initialize bitstream" );
p_fifo->b_error = 1;
DecoderError( p_fifo );
#ifndef UNDER_CE
close( i_fd );
#endif
return -1;
}
while( !p_fifo->b_die && !p_fifo->b_error )
{
GetChunk( &bit_stream, p_buffer, 1024 );
#ifndef UNDER_CE
write( i_fd, p_buffer, 1024 );
i_bytes += 1024;
#endif
if( mdate() < last_date + 2000000 )
{
......@@ -113,7 +126,9 @@ static int Run ( decoder_fifo_t *p_fifo )
msg_Dbg( p_fifo, "dumped %i bytes", i_bytes );
}
#ifndef UNDER_CE
close( i_fd );
#endif
CloseBitstream( &bit_stream );
if( p_fifo->b_error )
......
......@@ -2,7 +2,7 @@
* input_dummy.c: dummy input plugin, to manage "vlc:***" special options
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: input.c,v 1.1 2002/08/04 17:23:43 sam Exp $
* $Id: input.c,v 1.2 2002/11/18 18:05:13 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -25,14 +25,16 @@
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/input.h>
#ifndef HAVE_STRNCASECMP
# define strncasecmp(a,b,c) strcmp(a,b)
#endif
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......
......@@ -2,7 +2,7 @@
* vout_dummy.c: Dummy video output display method for testing purposes
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: vout.c,v 1.2 2002/09/10 12:58:42 sam Exp $
* $Id: vout.c,v 1.3 2002/11/18 18:05:13 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -24,7 +24,6 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* free() */
#include <string.h> /* strerror() */
......
......@@ -2,7 +2,7 @@
* modules.c : Builtin and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.c,v 1.104 2002/11/13 15:28:24 sam Exp $
* $Id: modules.c,v 1.105 2002/11/18 18:05:13 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
......@@ -37,6 +37,8 @@
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#elif defined( UNDER_CE )
# include <windows.h> /* GetFileAttributes() */
#else
# include "../extras/dirent.h"
#endif
......@@ -87,6 +89,12 @@
#include "iso_lang.h"
#if defined( UNDER_CE )
# define MYCHAR wchar_t
#else
# define MYCHAR char
#endif
#ifdef HAVE_DYNAMIC_PLUGINS
# include "modules_plugin.h"
#endif
......@@ -104,8 +112,8 @@
*****************************************************************************/
#ifdef HAVE_DYNAMIC_PLUGINS
static void AllocateAllPlugins ( vlc_object_t * );
static void AllocatePluginDir ( vlc_object_t *, const char *, int );
static int AllocatePluginFile ( vlc_object_t *, char * );
static void AllocatePluginDir ( vlc_object_t *, const MYCHAR *, int );
static int AllocatePluginFile ( vlc_object_t *, MYCHAR * );
#endif
static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) );
static int DeleteModule ( module_t * );
......@@ -550,6 +558,10 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
vlc_bool_t b_notinroot;
#endif
#if defined( UNDER_CE )
wchar_t psz_dir[MAX_PATH];
#endif
/* If the user provided a plugin path, we add it to the list */
path[ sizeof(path)/sizeof(char*) - 2 ] = config_GetPsz( p_this,
"plugin-path" );
......@@ -584,7 +596,12 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
msg_Dbg( p_this, "recursively browsing `%s'", psz_fullpath );
/* Don't go deeper than 5 subdirectories */
#if defined( UNDER_CE )
MultiByteToWideChar( CP_ACP, 0, psz_fullpath, -1, psz_dir, MAX_PATH );
AllocatePluginDir( p_this, psz_dir, 5 );
#else
AllocatePluginDir( p_this, psz_fullpath, 5 );
#endif
#if defined( SYS_BEOS ) || defined( SYS_DARWIN )
if( b_notinroot )
......@@ -602,22 +619,66 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
/*****************************************************************************
* AllocatePluginDir: recursively parse a directory to look for plugins
*****************************************************************************/
static void AllocatePluginDir( vlc_object_t *p_this, const char *psz_dir,
static void AllocatePluginDir( vlc_object_t *p_this, const MYCHAR *psz_dir,
int i_maxdepth )
{
#ifdef UNDER_CE
MYCHAR psz_path[MAX_PATH + 256];
WIN32_FIND_DATA finddata;
HANDLE handle;
unsigned int rc;
#else
int i_dirlen;
DIR * dir;
char * psz_file;
struct dirent * file;
#endif
if( i_maxdepth < 0 )
{
return;
}
dir = opendir( psz_dir );
#ifdef UNDER_CE
rc = GetFileAttributes( psz_dir );
if( !(rc & FILE_ATTRIBUTE_DIRECTORY) )
{
/* Not a directory */
return;
}
/* Parse all files in the directory */
swprintf( psz_path, L"%s\\*.*", psz_dir );
handle = FindFirstFile( psz_path, &finddata );
if( handle == INVALID_HANDLE_VALUE )
{
/* Empty directory */
return;
}
/* Parse the directory and try to load all files it contains. */
do
{
unsigned int i_len = wcslen( finddata.cFileName );
swprintf( psz_path, L"%s\\%s", psz_dir, finddata.cFileName );
if( GetFileAttributes( psz_path ) & FILE_ATTRIBUTE_DIRECTORY )
{
AllocatePluginDir( p_this, psz_path, i_maxdepth - 1 );
}
else if( i_len > strlen( LIBEXT ) )
{
AllocatePluginFile( p_this, psz_path );
}
}
while( FindNextFile( handle, &finddata ) );
/* Close the directory */
FindClose( handle );
#else
dir = opendir( psz_dir );
if( !dir )
{
return;
......@@ -628,9 +689,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, const char *psz_dir,
/* Parse the directory and try to load all files it contains. */
while( (file = readdir( dir )) )
{
#ifndef UNDER_CE
struct stat statbuf;
#endif
unsigned int i_len;
/* Skip ".", ".." and anything starting with "." */
......@@ -640,15 +699,10 @@ static void AllocatePluginDir( vlc_object_t *p_this, const char *psz_dir,
}
i_len = strlen( file->d_name );
psz_file = malloc( i_dirlen + 1 /* / */ + i_len + 1 /* \0 */ );
psz_file = malloc( i_dirlen + 1 + i_len + 1 );
sprintf( psz_file, "%s/%s", psz_dir, file->d_name );
#ifdef UNDER_CE
if( GetFileAttributes( psz_file ) & FILE_ATTRIBUTE_DIRECTORY )
#else
if( !stat( psz_file, &statbuf ) && statbuf.st_mode & S_IFDIR )
#endif
{
AllocatePluginDir( p_this, psz_file, i_maxdepth - 1 );
}
......@@ -657,7 +711,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, const char *psz_dir,
&& !strncasecmp( file->d_name + i_len - strlen( LIBEXT ),
LIBEXT, strlen( LIBEXT ) ) )
{
AllocatePluginFile( p_this, psz_file );
AllocatePluginFile( p_this, psz_file )
}
free( psz_file );
......@@ -665,6 +719,8 @@ static void AllocatePluginDir( vlc_object_t *p_this, const char *psz_dir,
/* Close the directory */
closedir( dir );
#endif
}
/*****************************************************************************
......@@ -674,7 +730,7 @@ static void AllocatePluginDir( vlc_object_t *p_this, const char *psz_dir,
* for its information data. The module can then be handled by module_Need
* and module_Unneed. It can be removed by DeleteModule.
*****************************************************************************/
static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file )
static int AllocatePluginFile( vlc_object_t * p_this, MYCHAR * psz_file )
{
module_t * p_module;
module_handle_t handle;
......@@ -701,7 +757,8 @@ static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file )
}
/* We need to fill these since they may be needed by CallEntry() */
p_module->psz_filename = psz_file;
/* FIXME: this is not unicode-compliant */
p_module->psz_filename = (char *)psz_file;
p_module->handle = handle;
p_module->p_symbols = &p_this->p_libvlc->p_module_bank->symbols;
......
......@@ -2,7 +2,7 @@
* modules_plugin.h : Plugin management functions used by the core application.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules_plugin.h.in,v 1.6 2002/11/11 14:39:12 sam Exp $
* $Id: modules_plugin.h.in,v 1.7 2002/11/18 18:05:13 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -31,7 +31,7 @@
* This function loads a dynamically linked library using a system dependant
* method, and returns a non-zero value on error, zero otherwise.
*****************************************************************************/
static int module_load( const char * psz_filename, module_handle_t * handle )
static int module_load( const MYCHAR * psz_filename, module_handle_t * handle )
{
#ifdef SYS_BEOS
*handle = load_add_on( psz_filename );
......@@ -99,18 +99,24 @@ static void * _module_getsymbol( module_handle_t handle,
if( B_OK == get_image_symbol( handle, psz_function,
B_SYMBOL_TYPE_TEXT, &p_symbol ) )
{
return( p_symbol );
return p_symbol;
}
else
{
return( NULL );
return NULL;
}
#elif defined(WIN32) || defined(UNDER_CE)
return( (void *)GetProcAddress( handle, psz_function ) );
#elif defined( UNDER_CE )
wchar_t psz_real[256];
MultiByteToWideChar( CP_ACP, 0, psz_function, -1, psz_real, 256 );
return (void *)GetProcAddress( handle, psz_real );
#elif defined( WIN32 )
return (void *)GetProcAddress( handle, (MYCHAR*)psz_function );
#else
return( dlsym( handle, psz_function ) );
return dlsym( handle, psz_function );
#endif
}
......@@ -149,12 +155,37 @@ static const char * module_error( char *psz_buffer )
#if defined(SYS_BEOS)
return( "failed" );
#elif defined(WIN32) || defined(UNDER_CE)
#elif defined(UNDER_CE)
wchar_t psz_tmp[256];
int i, i_error = GetLastError();
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, i_error, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) psz_tmp, 256, NULL );
/* Go to the end of the string */
for( i = 0;
psz_tmp[i] && psz_tmp[i] != L'\r' && psz_tmp[i] != L'\n';
i++ ) {};
if( psz_tmp[i] )
{
swprintf( psz_tmp + i, L" (error %i)", i_error );
psz_tmp[ 255 ] = L'\0';
}
WideCharToMultiByte( CP_ACP, WC_DEFAULTCHAR, psz_tmp, -1,
psz_buffer, 256, NULL, NULL );
return psz_buffer;
#elif defined(WIN32)
int i, i_error = GetLastError();
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, i_error, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) psz_buffer, 256, NULL);
(LPTSTR) psz_buffer, 256, NULL );
/* Go to the end of the string */
for( i = 0;
......@@ -164,7 +195,7 @@ static const char * module_error( char *psz_buffer )
if( psz_buffer[i] )
{
snprintf( psz_buffer + i, 256 - i, " (error %i)", i_error );
psz_buffer[ 255 ] = '\0';
psz_buffer[ 255 ] = '\0';
}
return psz_buffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment