diff options
author | Kurt Zenker <kz@openoffice.org> | 2007-06-19 15:16:39 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2007-06-19 15:16:39 +0000 |
commit | b27e02bc2cd76477c86356e1606c0625eda3790c (patch) | |
tree | 4acc5a9b4cd46817f811a39e64dd4e8571a84153 /sal | |
parent | a185ef2bea72ba959f8702cda3b097bb0d0f44e5 (diff) |
INTEGRATION: CWS obr05 (1.33.142); FILE MERGED
2007/06/07 08:09:27 obr 1.33.142.2: #i76025# comply to local naming convention
2007/04/03 09:46:22 obr 1.33.142.1: #i76025# New OSL API: osl_getModuleHandle & osl_getAsciiFunctionSymbol
Also removed usage of osl_psz_getSymbol and osl_psz_loadModule in
nlsupport.c and security.c
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/module.c | 106 |
1 files changed, 52 insertions, 54 deletions
diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.c index b830a5f41f10..ad8e593a8f3d 100644 --- a/sal/osl/unx/module.c +++ b/sal/osl/unx/module.c @@ -4,9 +4,9 @@ * * $RCSfile: module.c,v $ * - * $Revision: 1.33 $ + * $Revision: 1.34 $ * - * last change: $Author: hr $ $Date: 2006-05-09 15:43:15 $ + * last change: $Author: kz $ $Date: 2007-06-19 16:16:39 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -93,7 +93,6 @@ int dladdr(void *address, Dl_info *dl) extern int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32); oslModule SAL_CALL osl_psz_loadModule(const sal_Char *pszModuleName, sal_Int32 nRtldMode); -void* SAL_CALL osl_psz_getSymbol(oslModule hModule, const sal_Char* pszSymbolName); /*****************************************************************************/ /* osl_loadModule */ @@ -134,16 +133,6 @@ oslModule SAL_CALL osl_psz_loadModule(const sal_Char *pszModuleName, sal_Int32 n { #ifndef NO_DL_FUNCTIONS void* pLib = dlopen(pszModuleName, rtld_mode); - if ((pLib == 0) && (strchr (pszModuleName, '/') == 0)) - { - /* module w/o pathname not found, try cwd as last chance */ - char buffer[PATH_MAX]; - - buffer[0] = '.', buffer[1] = '/', buffer[2] = '\0'; - strncat (buffer, pszModuleName, sizeof(buffer) - 2); - - pLib = dlopen(buffer, rtld_mode); - } #if OSL_DEBUG_LEVEL > 1 if (pLib == 0) @@ -163,6 +152,18 @@ oslModule SAL_CALL osl_psz_loadModule(const sal_Char *pszModuleName, sal_Int32 n } /*****************************************************************************/ +/* osl_getModuleHandle */ +/*****************************************************************************/ + +sal_Bool SAL_CALL +osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult) +{ + (void) pModuleName; /* avoid warning about unused parameter */ + *pResult = (oslModule) RTLD_DEFAULT; + return sal_True; +} + +/*****************************************************************************/ /* osl_unloadModule */ /*****************************************************************************/ void SAL_CALL osl_unloadModule(oslModule hModule) @@ -194,63 +195,60 @@ void SAL_CALL osl_unloadModule(oslModule hModule) /*****************************************************************************/ /* osl_getSymbol */ /*****************************************************************************/ -void* SAL_CALL osl_getSymbol(oslModule Module, rtl_uString* ustrSymbolName) +void* SAL_CALL +osl_getSymbol(oslModule Module, rtl_uString* pSymbolName) { - void* pHandle = 0; - - OSL_ENSURE(Module,"osl_getSymbol : module handle is not valid"); - OSL_ENSURE(Module,"osl_getSymbol : ustrSymbolName"); - - if (Module!= 0 && ustrSymbolName != 0) - { - rtl_String* strSymbolName = 0; - sal_Char* pszSymbolName = 0; - - rtl_uString2String( &strSymbolName, - rtl_uString_getStr(ustrSymbolName), - rtl_uString_getLength(ustrSymbolName), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS ); - - pszSymbolName = rtl_string_getStr(strSymbolName); - - pHandle=osl_psz_getSymbol(Module,pszSymbolName); - - if (strSymbolName != 0) - { - rtl_string_release(strSymbolName); - } - } - return pHandle; + return (void *) osl_getFunctionSymbol(Module, pSymbolName); } /*****************************************************************************/ -/* osl_psz_getSymbol */ +/* osl_getAsciiFunctionSymbol */ /*****************************************************************************/ -void* SAL_CALL osl_psz_getSymbol(oslModule hModule, const sal_Char* pszSymbolName) +oslGenericFunction SAL_CALL +osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol) { - if (hModule && pszSymbolName) - { + void *fcnAddr = NULL; + #ifndef NO_DL_FUNCTIONS - void* pSym = dlsym(hModule, pszSymbolName); + if (pSymbol) + { + fcnAddr = dlsym(Module, pSymbol); -#if OSL_DEBUG_LEVEL > 1 - if (!pSym) - fprintf(stderr, "Error osl_getSymbol: %s\n", dlerror()); -#endif - return pSym; -#endif + if (!fcnAddr) + OSL_TRACE("Error osl_getAsciiFunctionSymbol: %s\n", dlerror()); } - return NULL; +#endif + + return (oslGenericFunction) fcnAddr; } /*****************************************************************************/ /* osl_getFunctionSymbol */ /*****************************************************************************/ -oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString *ustrFunctionSymbolName ) +oslGenericFunction SAL_CALL +osl_getFunctionSymbol(oslModule module, rtl_uString *puFunctionSymbolName) { - return (oslGenericFunction)osl_getSymbol( Module, ustrFunctionSymbolName); + oslGenericFunction pSymbol = NULL; + + if( puFunctionSymbolName ) + { + rtl_String* pSymbolName = NULL; + + rtl_uString2String( &pSymbolName, + rtl_uString_getStr(puFunctionSymbolName), + rtl_uString_getLength(puFunctionSymbolName), + RTL_TEXTENCODING_UTF8, + OUSTRING_TO_OSTRING_CVTFLAGS ); + + if( pSymbolName != NULL ) + { + pSymbol = osl_getAsciiFunctionSymbol(module, rtl_string_getStr(pSymbolName)); + rtl_string_release(pSymbolName); + } + } + + return pSymbol; } /*****************************************************************************/ |