[Libreoffice-commits] .: 2 commits - extensions/source sal/Library_sal.mk sal/osl
Stephan Bergmann
sbergmann at kemper.freedesktop.org
Mon Mar 12 03:55:14 PDT 2012
extensions/source/config/ldap/ldapaccess.cxx | 26 +
sal/Library_sal.mk | 2
sal/osl/unx/module.c | 364 ---------------------------
sal/osl/unx/module.cxx | 356 ++++++++++++++++++++++++++
4 files changed, 371 insertions(+), 377 deletions(-)
New commits:
commit 6a94909b44126428133e87033959c94ead3f16b4
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Mar 12 11:53:37 2012 +0100
Fix WITH_OPENLDAP case
diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx
index 681c33c..c1d07ed 100644
--- a/extensions/source/config/ldap/ldapaccess.cxx
+++ b/extensions/source/config/ldap/ldapaccess.cxx
@@ -273,26 +273,28 @@ void LdapConnection::initConnection()
return userDn ;
}
+#if defined WNT || !defined WITH_OPENLDAP
extern "C" { static void SAL_CALL thisModule() {} }
+#endif
+
void LdapConnection::loadModule()
{
if ( !s_Ldap_Module )
{
-#if defined(WNT)
-# define LIBLDAP "nsldap32v50.dll"
+#if defined WNT
+ s_Ldap_Module = osl_loadModuleRelativeAscii(
+ &thisModule, "nsldap32v50.dll", 0);
+#elif defined WITH_OPENLDAP
+ s_Ldap_Module = osl_loadModuleAscii(
+ ("libldap-" SAL_STRINGIFY(LDAP_VENDOR_VERSION_MAJOR) "."
+ SAL_STRINGIFY(LDAP_VENDOR_VERSION_MINOR) ".so."
+ SAL_STRINGIFY(LDAP_VENDOR_VERSION_MAJOR)),
+ 0);
#else
-# ifdef WITH_OPENLDAP
-# define xstr(s) str(s)
-# define str(s) #s
-# define LIBLDAP "libldap-" xstr(LDAP_VENDOR_VERSION_MAJOR) "." xstr(LDAP_VENDOR_VERSION_MINOR) ".so." xstr(LDAP_VENDOR_VERSION_MAJOR)
-# else
-# define LIBLDAP "libldap50.so"
-# endif
+ s_Ldap_Module = osl_loadModuleRelativeAscii(
+ &thisModule, "libldap50.so", 0);
#endif
- const ::rtl::OUString sModuleName(RTL_CONSTASCII_USTRINGPARAM(LIBLDAP));
- // load the dbtools library
- s_Ldap_Module = osl_loadModuleRelative(&thisModule, sModuleName.pData, 0);
if ( s_Ldap_Module != NULL )
{
s_p_unbind_s = (t_ldap_unbind_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ldap_unbind_s")).pData));
commit 25292b154ecfb33450307357f006b652cd673967
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Mar 12 11:52:26 2012 +0100
module.c -> module.cxx, use sal/log.hxx
diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk
index ed738d7..f573bfa 100644
--- a/sal/Library_sal.mk
+++ b/sal/Library_sal.mk
@@ -159,6 +159,7 @@ $(eval $(call gb_Library_add_exception_objects,sal,\
sal/osl/unx/file_stat \
sal/osl/unx/file_url \
sal/osl/unx/file_volume \
+ sal/osl/unx/module \
sal/osl/unx/process \
sal/osl/unx/process_impl \
sal/osl/unx/salinit \
@@ -166,7 +167,6 @@ $(eval $(call gb_Library_add_exception_objects,sal,\
))
$(eval $(call gb_Library_add_cobjects,sal,\
sal/osl/unx/diagnose \
- sal/osl/unx/module \
sal/osl/unx/mutex \
sal/osl/unx/nlsupport \
sal/osl/unx/pipe \
diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.c
deleted file mode 100644
index ea41a7e..0000000
--- a/sal/osl/unx/module.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <sal/types.h>
-#include <osl/diagnose.h>
-#include <osl/module.h>
-#include <osl/thread.h>
-#include <osl/process.h>
-#include <osl/file.h>
-
-#include "system.h"
-
-#if OSL_DEBUG_LEVEL > 1
-#include <stdio.h>
-#endif
-
-#ifdef AIX
-#include <sys/ldr.h>
-#endif
-
-#ifdef ANDROID
-#include <osl/detail/android-bootstrap.h>
-#endif
-
-/* implemented in file.c */
-extern int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32);
-
-static sal_Bool getModulePathFromAddress(void * address, rtl_String ** path) {
- sal_Bool result = sal_False;
-/* Bah, we do want to use dladdr here also on iOS, I think? */
-#if !defined(NO_DL_FUNCTIONS) || defined(IOS)
-#if defined(AIX)
- int size = 4 * 1024;
- char *buf, *filename=NULL;
- struct ld_info *lp;
-
- if ((buf = malloc(size)) == NULL)
- return result;
-
- while(loadquery(L_GETINFO, buf, size) == -1 && errno == ENOMEM)
- {
- size += 4 * 1024;
- if ((buf = malloc(size)) == NULL)
- break;
- }
-
- lp = (struct ld_info*) buf;
- while (lp)
- {
- unsigned long start = (unsigned long)lp->ldinfo_dataorg;
- unsigned long end = start + lp->ldinfo_datasize;
- if (start <= (unsigned long)address && end > (unsigned long)address)
- {
- filename = lp->ldinfo_filename;
- break;
- }
- if (!lp->ldinfo_next)
- break;
- lp = (struct ld_info*) ((char *) lp + lp->ldinfo_next);
- }
-
- if (filename)
- {
- rtl_string_newFromStr(path, filename);
- result = sal_True;
- }
- else
- {
- result = sal_False;
- }
-
- free(buf);
-#else
- Dl_info dl_info;
-
-#ifdef ANDROID
- result = lo_dladdr(address, &dl_info);
-#else
- result = dladdr(address, &dl_info);
-#endif
-
- if (result != 0)
- {
- rtl_string_newFromStr(path, dl_info.dli_fname);
-#ifdef ANDROID
- free((void *) dl_info.dli_fname);
-#endif
- result = sal_True;
- }
- else
- {
- result = sal_False;
- }
-#endif
-#endif
- return result;
-}
-
-/*****************************************************************************/
-/* osl_loadModule */
-/*****************************************************************************/
-
-oslModule SAL_CALL osl_loadModule(rtl_uString *ustrModuleName, sal_Int32 nRtldMode)
-{
- oslModule pModule=0;
- rtl_uString* ustrTmp = NULL;
-
- OSL_ENSURE(ustrModuleName,"osl_loadModule : string is not valid");
-
- /* ensure ustrTmp hold valid string */
- if (osl_File_E_None != osl_getSystemPathFromFileURL(ustrModuleName, &ustrTmp))
- rtl_uString_assign(&ustrTmp, ustrModuleName);
-
- if (ustrTmp)
- {
- char buffer[PATH_MAX];
-
- if (UnicodeToText(buffer, PATH_MAX, ustrTmp->buffer, ustrTmp->length))
- pModule = osl_loadModuleAscii(buffer, nRtldMode);
- rtl_uString_release(ustrTmp);
- }
-
- return pModule;
-}
-
-/*****************************************************************************/
-/* osl_loadModuleAscii */
-/*****************************************************************************/
-
-oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nRtldMode)
-{
- OSL_ASSERT(
- (nRtldMode & SAL_LOADMODULE_LAZY) == 0 ||
- (nRtldMode & SAL_LOADMODULE_NOW) == 0); /* only either LAZY or NOW */
- if (pModuleName)
- {
-#ifndef NO_DL_FUNCTIONS
-#ifdef ANDROID
- void *pLib = lo_dlopen(pModuleName);
- (void) nRtldMode;
-#else
- int rtld_mode =
- ((nRtldMode & SAL_LOADMODULE_NOW) ? RTLD_NOW : RTLD_LAZY) |
- ((nRtldMode & SAL_LOADMODULE_GLOBAL) ? RTLD_GLOBAL : RTLD_LOCAL);
- void* pLib = dlopen(pModuleName, rtld_mode);
-#endif
-#if OSL_DEBUG_LEVEL > 1
- if (pLib == 0)
- OSL_TRACE("Error osl_loadModule: %s", dlerror());
-#endif /* OSL_DEBUG_LEVEL */
-
- return ((oslModule)(pLib));
-
-#else /* NO_DL_FUNCTIONS */
- (void) nRtldMode;
- printf("No DL Functions\n");
-#endif /* NO_DL_FUNCTIONS */
- }
- return NULL;
-}
-
-oslModule osl_loadModuleRelativeAscii(
- oslGenericFunction baseModule, char const * relativePath, sal_Int32 mode)
-{
- OSL_ASSERT(relativePath != NULL);
- if (relativePath[0] == '/') {
- return osl_loadModuleAscii(relativePath, mode);
- } else {
- rtl_String * path = NULL;
- rtl_String * suffix = NULL;
- oslModule module;
- if (!getModulePathFromAddress(baseModule, &path)) {
- return NULL;
- }
- rtl_string_newFromStr_WithLength(
- &path, path->buffer,
- (rtl_str_lastIndexOfChar_WithLength(path->buffer, path->length, '/')
- + 1));
- /* cut off everything after the last slash; should the original path
- contain no slash, the resulting path is the empty string */
- rtl_string_newFromStr(&suffix, relativePath);
- rtl_string_newConcat(&path, path, suffix);
- rtl_string_release(suffix);
- module = osl_loadModuleAscii(path->buffer, mode);
- rtl_string_release(path);
- return module;
- }
-}
-
-/*****************************************************************************/
-/* osl_getModuleHandle */
-/*****************************************************************************/
-
-sal_Bool SAL_CALL
-osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult)
-{
- (void) pModuleName; /* avoid warning about unused parameter */
-#if !defined(NO_DL_FUNCTIONS) || defined(IOS)
- *pResult = (oslModule) RTLD_DEFAULT;
-#else
- *pResult = NULL;
-#endif
- return sal_True;
-}
-
-/*****************************************************************************/
-/* osl_unloadModule */
-/*****************************************************************************/
-void SAL_CALL osl_unloadModule(oslModule hModule)
-{
- if (hModule)
- {
-#ifndef NO_DL_FUNCTIONS
-#ifdef ANDROID
- int nRet = lo_dlclose(hModule);
-#else
- int nRet = dlclose(hModule);
-#endif
-
-#if OSL_DEBUG_LEVEL > 1
- if (nRet != 0)
- {
- fprintf(stderr, "Error osl_unloadModule: %s\n", dlerror());
- }
-#else
- (void) nRet;
-#endif /* if OSL_DEBUG_LEVEL */
-
-#endif /* ifndef NO_DL_FUNCTIONS */
- }
-}
-
-/*****************************************************************************/
-/* osl_getSymbol */
-/*****************************************************************************/
-void* SAL_CALL
-osl_getSymbol(oslModule Module, rtl_uString* pSymbolName)
-{
- return (void *) osl_getFunctionSymbol(Module, pSymbolName);
-}
-
-
-/*****************************************************************************/
-/* osl_getAsciiFunctionSymbol */
-/*****************************************************************************/
-oslGenericFunction SAL_CALL
-osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol)
-{
- void *fcnAddr = NULL;
-
-/* We do want to use dlsym on iOS */
-#if !defined(NO_DL_FUNCTIONS) || defined(IOS)
- if (pSymbol)
- {
- fcnAddr = dlsym(Module, pSymbol);
-
- if (!fcnAddr)
- OSL_TRACE("Error osl_getAsciiFunctionSymbol: %s", dlerror());
- }
-#endif
-
- return (oslGenericFunction) fcnAddr;
-}
-
-/*****************************************************************************/
-/* osl_getFunctionSymbol */
-/*****************************************************************************/
-oslGenericFunction SAL_CALL
-osl_getFunctionSymbol(oslModule module, rtl_uString *puFunctionSymbolName)
-{
- 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;
-}
-
-/*****************************************************************************/
-/* osl_getModuleURLFromAddress */
-/*****************************************************************************/
-sal_Bool SAL_CALL osl_getModuleURLFromAddress(void * addr, rtl_uString ** ppLibraryUrl)
-{
- sal_Bool result = sal_False;
- rtl_String * path = NULL;
- if (getModulePathFromAddress(addr, &path))
- {
- rtl_uString * workDir = NULL;
- osl_getProcessWorkingDir(&workDir);
- if (workDir)
- {
-#if OSL_DEBUG_LEVEL > 1
- OSL_TRACE("module.c::osl_getModuleURLFromAddress - %s", path->buffer);
-#endif
- rtl_string2UString(ppLibraryUrl,
- path->buffer,
- path->length,
- osl_getThreadTextEncoding(),
- OSTRING_TO_OUSTRING_CVTFLAGS);
-
- OSL_ASSERT(*ppLibraryUrl != NULL);
- osl_getFileURLFromSystemPath(*ppLibraryUrl, ppLibraryUrl);
- osl_getAbsoluteFileURL(workDir, *ppLibraryUrl, ppLibraryUrl);
-
- rtl_uString_release(workDir);
- result = sal_True;
- }
- else
- {
- result = sal_False;
- }
- rtl_string_release(path);
- }
- return result;
-}
-
-/*****************************************************************************/
-/* osl_getModuleURLFromFunctionAddress */
-/*****************************************************************************/
-sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress(oslGenericFunction addr, rtl_uString ** ppLibraryUrl)
-{
- return osl_getModuleURLFromAddress((void*)addr, ppLibraryUrl);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/unx/module.cxx b/sal/osl/unx/module.cxx
new file mode 100644
index 0000000..e5e91e6
--- /dev/null
+++ b/sal/osl/unx/module.cxx
@@ -0,0 +1,356 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sal/config.h"
+
+#include <sal/log.hxx>
+#include <sal/types.h>
+#include <osl/module.h>
+#include <osl/thread.h>
+#include <osl/process.h>
+#include <osl/file.h>
+
+#include "system.h"
+
+#ifdef AIX
+#include <sys/ldr.h>
+#endif
+
+#ifdef ANDROID
+#include <osl/detail/android-bootstrap.h>
+#endif
+
+/* implemented in file.c */
+extern "C" int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32);
+
+static sal_Bool getModulePathFromAddress(void * address, rtl_String ** path) {
+ sal_Bool result = sal_False;
+/* Bah, we do want to use dladdr here also on iOS, I think? */
+#if !defined(NO_DL_FUNCTIONS) || defined(IOS)
+#if defined(AIX)
+ int size = 4 * 1024;
+ char *buf, *filename=NULL;
+ struct ld_info *lp;
+
+ if ((buf = malloc(size)) == NULL)
+ return result;
+
+ while(loadquery(L_GETINFO, buf, size) == -1 && errno == ENOMEM)
+ {
+ size += 4 * 1024;
+ if ((buf = malloc(size)) == NULL)
+ break;
+ }
+
+ lp = (struct ld_info*) buf;
+ while (lp)
+ {
+ unsigned long start = (unsigned long)lp->ldinfo_dataorg;
+ unsigned long end = start + lp->ldinfo_datasize;
+ if (start <= (unsigned long)address && end > (unsigned long)address)
+ {
+ filename = lp->ldinfo_filename;
+ break;
+ }
+ if (!lp->ldinfo_next)
+ break;
+ lp = (struct ld_info*) ((char *) lp + lp->ldinfo_next);
+ }
+
+ if (filename)
+ {
+ rtl_string_newFromStr(path, filename);
+ result = sal_True;
+ }
+ else
+ {
+ result = sal_False;
+ }
+
+ free(buf);
+#else
+ Dl_info dl_info;
+
+#ifdef ANDROID
+ result = lo_dladdr(address, &dl_info);
+#else
+ result = dladdr(address, &dl_info);
+#endif
+
+ if (result != 0)
+ {
+ rtl_string_newFromStr(path, dl_info.dli_fname);
+#ifdef ANDROID
+ free((void *) dl_info.dli_fname);
+#endif
+ result = sal_True;
+ }
+ else
+ {
+ result = sal_False;
+ }
+#endif
+#endif
+ return result;
+}
+
+/*****************************************************************************/
+/* osl_loadModule */
+/*****************************************************************************/
+
+oslModule SAL_CALL osl_loadModule(rtl_uString *ustrModuleName, sal_Int32 nRtldMode)
+{
+ oslModule pModule=0;
+ rtl_uString* ustrTmp = NULL;
+
+ SAL_WARN_IF(ustrModuleName == 0, "sal.osl", "string is not valid");
+
+ /* ensure ustrTmp hold valid string */
+ if (osl_File_E_None != osl_getSystemPathFromFileURL(ustrModuleName, &ustrTmp))
+ rtl_uString_assign(&ustrTmp, ustrModuleName);
+
+ if (ustrTmp)
+ {
+ char buffer[PATH_MAX];
+
+ if (UnicodeToText(buffer, PATH_MAX, ustrTmp->buffer, ustrTmp->length))
+ pModule = osl_loadModuleAscii(buffer, nRtldMode);
+ rtl_uString_release(ustrTmp);
+ }
+
+ return pModule;
+}
+
+/*****************************************************************************/
+/* osl_loadModuleAscii */
+/*****************************************************************************/
+
+oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nRtldMode)
+{
+ SAL_WARN_IF(
+ ((nRtldMode & SAL_LOADMODULE_LAZY) != 0
+ && (nRtldMode & SAL_LOADMODULE_NOW) != 0),
+ "sal.osl", "only either LAZY or NOW");
+ if (pModuleName)
+ {
+#ifndef NO_DL_FUNCTIONS
+#ifdef ANDROID
+ void *pLib = lo_dlopen(pModuleName);
+ (void) nRtldMode;
+#else
+ int rtld_mode =
+ ((nRtldMode & SAL_LOADMODULE_NOW) ? RTLD_NOW : RTLD_LAZY) |
+ ((nRtldMode & SAL_LOADMODULE_GLOBAL) ? RTLD_GLOBAL : RTLD_LOCAL);
+ void* pLib = dlopen(pModuleName, rtld_mode);
+#endif
+ SAL_INFO_IF(
+ pLib == 0, "sal.osl",
+ "dlopen(" << pModuleName << ", " << rtld_mode << "): "
+ << dlerror());
+
+ return ((oslModule)(pLib));
+
+#else /* NO_DL_FUNCTIONS */
+ (void) nRtldMode;
+ printf("No DL Functions\n");
+#endif /* NO_DL_FUNCTIONS */
+ }
+ return NULL;
+}
+
+oslModule osl_loadModuleRelativeAscii(
+ oslGenericFunction baseModule, char const * relativePath, sal_Int32 mode)
+{
+ SAL_WARN_IF(relativePath == 0, "sal.osl", "illegal argument");
+ if (relativePath[0] == '/') {
+ return osl_loadModuleAscii(relativePath, mode);
+ } else {
+ rtl_String * path = NULL;
+ rtl_String * suffix = NULL;
+ oslModule module;
+ if (!getModulePathFromAddress(
+ reinterpret_cast< void * >(baseModule), &path))
+ {
+ return NULL;
+ }
+ rtl_string_newFromStr_WithLength(
+ &path, path->buffer,
+ (rtl_str_lastIndexOfChar_WithLength(path->buffer, path->length, '/')
+ + 1));
+ /* cut off everything after the last slash; should the original path
+ contain no slash, the resulting path is the empty string */
+ rtl_string_newFromStr(&suffix, relativePath);
+ rtl_string_newConcat(&path, path, suffix);
+ rtl_string_release(suffix);
+ module = osl_loadModuleAscii(path->buffer, mode);
+ rtl_string_release(path);
+ return module;
+ }
+}
+
+/*****************************************************************************/
+/* osl_getModuleHandle */
+/*****************************************************************************/
+
+sal_Bool SAL_CALL
+osl_getModuleHandle(rtl_uString *, oslModule *pResult)
+{
+#if !defined(NO_DL_FUNCTIONS) || defined(IOS)
+ *pResult = (oslModule) RTLD_DEFAULT;
+#else
+ *pResult = NULL;
+#endif
+ return sal_True;
+}
+
+/*****************************************************************************/
+/* osl_unloadModule */
+/*****************************************************************************/
+void SAL_CALL osl_unloadModule(oslModule hModule)
+{
+ if (hModule)
+ {
+#ifndef NO_DL_FUNCTIONS
+#ifdef ANDROID
+ int nRet = lo_dlclose(hModule);
+#else
+ int nRet = dlclose(hModule);
+#endif
+ SAL_INFO_IF(
+ nRet != 0, "sal.osl", "dlclose(" << hModule << "): " << dlerror());
+#endif /* ifndef NO_DL_FUNCTIONS */
+ }
+}
+
+/*****************************************************************************/
+/* osl_getSymbol */
+/*****************************************************************************/
+void* SAL_CALL
+osl_getSymbol(oslModule Module, rtl_uString* pSymbolName)
+{
+ return (void *) osl_getFunctionSymbol(Module, pSymbolName);
+}
+
+
+/*****************************************************************************/
+/* osl_getAsciiFunctionSymbol */
+/*****************************************************************************/
+oslGenericFunction SAL_CALL
+osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol)
+{
+ void *fcnAddr = NULL;
+
+/* We do want to use dlsym on iOS */
+#if !defined(NO_DL_FUNCTIONS) || defined(IOS)
+ if (pSymbol)
+ {
+ fcnAddr = dlsym(Module, pSymbol);
+ SAL_INFO_IF(
+ fcnAddr == 0, "sal.osl",
+ "dlsym(" << Module << ", " << pSymbol << "): " << dlerror());
+ }
+#endif
+
+ return (oslGenericFunction) fcnAddr;
+}
+
+/*****************************************************************************/
+/* osl_getFunctionSymbol */
+/*****************************************************************************/
+oslGenericFunction SAL_CALL
+osl_getFunctionSymbol(oslModule module, rtl_uString *puFunctionSymbolName)
+{
+ 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;
+}
+
+/*****************************************************************************/
+/* osl_getModuleURLFromAddress */
+/*****************************************************************************/
+sal_Bool SAL_CALL osl_getModuleURLFromAddress(void * addr, rtl_uString ** ppLibraryUrl)
+{
+ sal_Bool result = sal_False;
+ rtl_String * path = NULL;
+ if (getModulePathFromAddress(addr, &path))
+ {
+ rtl_uString * workDir = NULL;
+ osl_getProcessWorkingDir(&workDir);
+ if (workDir)
+ {
+ SAL_INFO(
+ "sal.osl", "osl_getModuleURLFromAddress: " << path->buffer);
+ rtl_string2UString(ppLibraryUrl,
+ path->buffer,
+ path->length,
+ osl_getThreadTextEncoding(),
+ OSTRING_TO_OUSTRING_CVTFLAGS);
+
+ SAL_WARN_IF(
+ *ppLibraryUrl == 0, "sal.osl", "rtl_string2UString failed");
+ osl_getFileURLFromSystemPath(*ppLibraryUrl, ppLibraryUrl);
+ osl_getAbsoluteFileURL(workDir, *ppLibraryUrl, ppLibraryUrl);
+
+ rtl_uString_release(workDir);
+ result = sal_True;
+ }
+ else
+ {
+ result = sal_False;
+ }
+ rtl_string_release(path);
+ }
+ return result;
+}
+
+/*****************************************************************************/
+/* osl_getModuleURLFromFunctionAddress */
+/*****************************************************************************/
+sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress(oslGenericFunction addr, rtl_uString ** ppLibraryUrl)
+{
+ return osl_getModuleURLFromAddress((void*)addr, ppLibraryUrl);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list