1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_OSL_MODULE_H
21 #define INCLUDED_OSL_MODULE_H
23 #include <sal/config.h>
25 #include <rtl/tencinfo.h>
26 #include <rtl/ustring.h>
27 #include <sal/saldllapi.h>
34 #define SAL_MODULENAME(name) SAL_DLLPREFIX name SAL_DLLEXTENSION
36 #define SAL_MODULENAME(name) name SAL_DLLEXTENSION
40 #define SAL_MODULENAME_WITH_VERSION(name, version) name version SAL_DLLEXTENSION
42 #elif defined(SAL_UNX)
44 #define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name ".dylib." version
46 #define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name SAL_DLLEXTENSION "." version
51 #define SAL_LOADMODULE_DEFAULT 0x00000
52 #define SAL_LOADMODULE_LAZY 0x00001
53 #define SAL_LOADMODULE_NOW 0x00002
54 #define SAL_LOADMODULE_GLOBAL 0x00100
56 typedef void* oslModule
;
58 /** Generic Function pointer type that will be used as symbol address.
59 @see osl_getFunctionSymbol.
60 @see osl_getModuleURLFromFunctionAddress.
62 typedef void ( SAL_CALL
*oslGenericFunction
)( void );
64 #ifndef DISABLE_DYNLOADING
66 /** Load a shared library or module.
67 @param strModuleName denotes the name of the module to be loaded.
68 @param nRtldMode denotes the mode.
69 @return NULL if the module could not be loaded, otherwise a handle to the module.
71 SAL_DLLPUBLIC oslModule SAL_CALL
osl_loadModule(rtl_uString
*strModuleName
, sal_Int32 nRtldMode
);
73 /** Load a shared library or module.
74 @param pModuleName denotes the name of the module to be loaded.
75 @param nRtldMode denotes the mode.
76 @return NULL if the module could not be loaded, otherwise a handle to the module.
79 SAL_DLLPUBLIC oslModule SAL_CALL
osl_loadModuleAscii(const sal_Char
*pModuleName
, sal_Int32 nRtldMode
);
81 /** Load a module located relative to some other module.
84 must point to a function that is part of the code of some loaded module;
88 a relative URL; must not be NULL.
91 the SAL_LOADMODULE_xxx flags.
94 a non-NULL handle to the loaded module, or NULL if an error occurred.
98 SAL_DLLPUBLIC oslModule SAL_CALL
osl_loadModuleRelative(
99 oslGenericFunction baseModule
, rtl_uString
* relativePath
, sal_Int32 mode
);
101 /** Load a module located relative to some other module.
104 must point to a function that is part of the code of some loaded module;
108 a relative URL containing only ASCII (0x01--7F) characters; must not be
112 the SAL_LOADMODULE_xxx flags.
115 a non-NULL handle to the loaded module, or NULL if an error occurred.
117 @since LibreOffice 3.5
119 SAL_DLLPUBLIC oslModule SAL_CALL
osl_loadModuleRelativeAscii(
120 oslGenericFunction baseModule
, char const * relativePath
, sal_Int32 mode
);
121 /* This function is guaranteed not to call into
122 FullTextEncodingDataSingleton in sal/textenc/textenc.cxx, so can be used
123 in its implementation without running into circles. */
127 /** Retrieve the handle of an already loaded module.
129 This function can be used to search for a function symbol in the process address space.
130 Do not use the returned handle as an argument to osl_unloadModule. On Unix platforms,
131 pModuleName gets ignored and the special handle RTLD_DEFAULT is returned.
134 [in] denotes the name of the module to search for. Ignored on Unix
137 [out] a pointer to a oslModule that is updated with the requested module handle
141 sal_True if the module handle could be retrieved and has been copied to *pResult.
142 sal_False if the module has not been loaded yet.
144 @see osl_getFunctionSymbol
145 @see osl_getAsciiFunctionSymbol
147 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getModuleHandle(rtl_uString
*pModuleName
, oslModule
*pResult
);
149 #ifndef DISABLE_DYNLOADING
151 /** Release the module
153 SAL_DLLPUBLIC
void SAL_CALL
osl_unloadModule(oslModule Module
);
157 /** lookup the specified symbol name.
158 @return address of the symbol or NULL if lookup failed.
160 SAL_DLLPUBLIC
void* SAL_CALL
osl_getSymbol( oslModule Module
, rtl_uString
*strSymbolName
);
162 /** Lookup the specified function symbol name.
164 osl_getFunctionSymbol is an alternative function for osl_getSymbol.
165 Use Function pointer as symbol address to conceal type conversion.
168 [in] the handle of the Module.
170 @param ustrFunctionSymbolName
171 [in] Name of the function that will be looked up.
175 <dt>Function address.</dt>
178 <dd>lookup failed or the parameter are invalid.</dd>
182 @see osl_getAsciiFunctionSymbol
184 SAL_DLLPUBLIC oslGenericFunction SAL_CALL
osl_getFunctionSymbol(
185 oslModule Module
, rtl_uString
*ustrFunctionSymbolName
);
187 /** Lookup the specified function symbol name.
189 osl_getAsciiFunctionSymbol is an alternative function for osl_getFunctionSymbol.
190 It expects the C-style function name string to contain ascii characters only.
193 [in] a module handle as returned by osl_loadModule or osl_getModuleHandle
196 [in] Name of the function that will be looked up.
200 <dt>Function address.</dt>
203 <dd>lookup failed or the parameter are invalid.</dd>
206 @see osl_getModuleHandle
207 @see osl_getFunctionSymbol
209 SAL_DLLPUBLIC oslGenericFunction SAL_CALL
osl_getAsciiFunctionSymbol(
210 oslModule Module
, const sal_Char
*pSymbol
);
213 /** Lookup URL of module which is mapped at the specified address.
214 @param pv specifies an address in the process memory space.
215 @param pustrURL receives the URL of the module that is mapped at pv.
216 @return sal_True on success, sal_False if no module can be found at the specified address.
218 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getModuleURLFromAddress(
219 void *pv
, rtl_uString
**pustrURL
);
221 /** Lookup URL of module which is mapped at the specified function address.
223 osl_getModuleURLFromFunctionAddress is an alternative function for osl_getModuleURLFromAddress.
224 Use Function pointer as symbol address to conceal type conversion.
227 [in] function address in oslGenericFunction format.
229 @param pustrFunctionURL
230 [out] receives the URL of the module that is mapped at pf.
237 <dd>no module can be found at the specified function address or parameter is somewhat invalid.</dd>
240 @see osl_getModuleURLFromAddress
242 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getModuleURLFromFunctionAddress(
243 oslGenericFunction pf
, rtl_uString
**pustrFunctionURL
);
249 #endif // INCLUDED_OSL_MODULE_H
251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */