Commit d9d51ffa authored by KO Myung-Hun's avatar KO Myung-Hun Committed by Rémi Denis-Courmont

Implement filesystem.c and plugin.c for OS/2

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 4fac1895
......@@ -48,14 +48,7 @@ VLC_API const char * IsUTF8( const char * ) VLC_USED;
VLC_API char * FromCharset( const char *charset, const void *data, size_t data_size ) VLC_USED;
VLC_API void * ToCharset( const char *charset, const char *in, size_t *outsize ) VLC_USED;
#ifndef WIN32
# define FromLocale(l) (l)
# define ToLocale(u) (u)
# define LocaleFree(s) ((void)(s))
# define FromLocaleDup strdup
# define ToLocaleDup strdup
#else
#ifdef WIN32
VLC_USED
static inline char *FromWide (const wchar_t *wide)
{
......@@ -143,6 +136,43 @@ static inline char *ToANSI (const char *utf8)
# define LocaleFree(s) free((char *)(s))
# define FromLocaleDup FromANSI
# define ToLocaleDup ToANSI
#elif defined(__OS2__)
VLC_USED static inline char *FromLocale (const char *locale)
{
return locale ? FromCharset ((char *)"", locale, strlen(locale)) : NULL;
}
VLC_USED static inline char *ToLocale (const char *utf8)
{
size_t outsize;
return utf8 ? (char *)ToCharset ("", utf8, &outsize) : NULL;
}
VLC_USED static inline void LocaleFree (const char *str)
{
free ((char *)str);
}
VLC_USED static inline char *FromLocaleDup (const char *locale)
{
return FromCharset ("", locale, strlen(locale));
}
VLC_USED static inline char *ToLocaleDup (const char *utf8)
{
size_t outsize;
return (char *)ToCharset ("", utf8, &outsize);
}
#else
# define FromLocale(l) (l)
# define ToLocale(u) (u)
# define LocaleFree(s) ((void)(s))
# define FromLocaleDup strdup
# define ToLocaleDup strdup
#endif
/**
......
......@@ -282,8 +282,8 @@ SOURCES_libvlc_os2 = \
os2/getaddrinfo.c \
os2/dirs.c \
misc/atomic.c \
posix/filesystem.c \
posix/plugin.c \
os2/filesystem.c \
os2/plugin.c \
os2/thread.c \
os2/specific.c \
os2/rand.c \
......
This diff is collapsed.
/*****************************************************************************
* plugin.c : Low-level dynamic library handling
*****************************************************************************
* Copyright (C) 2001-2007 VLC authors and VideoLAN
* Copyright (C) 2012 KO Myung-Hun
* $Id$
*
* Authors: Sam Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
* Hans-Peter Jansen <hpj@urpla.net>
* Gildas Bazin <gbazin@videolan.org>
* KO Myung-Hun <komh@chollian.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_charset.h>
#include "modules/modules.h"
#include <sys/types.h>
#include <dlfcn.h>
/**
* Load a dynamically linked library using a system dependent method.
*
* \param p_this vlc object
* \param psz_file library file
* \param p_handle the module handle returned
* \return 0 on success as well as the module handle.
*/
int module_Load( vlc_object_t *p_this, const char *psz_file,
module_handle_t *p_handle, bool lazy )
{
const int flags = lazy ? RTLD_LAZY : RTLD_NOW;
char *path = ToLocale( psz_file );
module_handle_t handle = dlopen( path, flags );
if( handle == NULL )
{
msg_Warn( p_this, "cannot load module `%s' (%s)", path, dlerror() );
LocaleFree( path );
return -1;
}
LocaleFree( path );
*p_handle = handle;
return 0;
}
/**
* CloseModule: unload a dynamic library
*
* This function unloads a previously opened dynamically linked library
* using a system dependent method. No return value is taken in consideration,
* since some libraries sometimes refuse to close properly.
* \param handle handle of the library
* \return nothing
*/
void module_Unload( module_handle_t handle )
{
dlclose( handle );
}
/**
* Looks up a symbol from a dynamically loaded library
*
* This function queries a loaded library for a symbol specified in a
* string, and returns a pointer to it. We don't check for dlerror() or
* similar functions, since we want a non-NULL symbol anyway.
*
* @param handle handle to the module
* @param psz_function function name
* @return NULL on error, or the address of the symbol
*/
void *module_Lookup( module_handle_t handle, const char *psz_function )
{
return dlsym( handle, psz_function );
}
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