1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/*
FALCON - The Falcon Programming Language.
FILE: dll_win.cpp
Implementation of windows specific DLL system
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: mar ago 3 2004
-------------------------------------------------------------------
(C) Copyright 2004: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
#include <falcon/dll_dl.h>
#include <falcon/autocstring.h>
namespace Falcon
{
DllLoader_dl::~DllLoader_dl()
{
close();
}
bool DllLoader_dl::open( const String &dll_name )
{
AutoCString name( dll_name );
if( m_module != 0 )
if ( ! dlclose( m_module ) )
return false;
m_module = dlopen( name.c_str(), RTLD_NOW );
if ( m_module == 0 )
return false;
return true;
}
bool DllLoader_dl::close()
{
if ( m_module != 0 ) {
if ( dlclose( m_module ) ) {
m_module = 0;
return true;
}
}
return false;
}
void DllLoader_dl::assign( DllLoader_dl &other )
{
if ( m_module != 0 )
close();
m_module = other.m_module;
other.m_module = 0;
}
DllFunc DllLoader_dl::getSymbol( const String &sym_name ) const
{
AutoCString name( sym_name );
if ( m_module != 0 )
return DllFunc( dlsym( m_module, name.c_str() ) );
return DllFunc( 0 );
}
bool DllLoader_dl::isDllMark( char ch1, char ch2 )
{
if ( ch1 == 0x7f && ch2 == 'E' ) return true;
return false;
}
void DllLoader_dl::getErrorDescription( String &descr ) const
{
const char *le = dlerror();
if ( le == 0 )
return;
descr.bufferize( le );
}
}
/* end of dll_dl.cpp */
|