Branch libreoffice-5-0-4
[LibreOffice.git] / include / osl / module.h
blobb89c57115e0246128af518bfff753886c9125831
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 #ifdef SAL_DLLPREFIX
34 #define SAL_MODULENAME(name) SAL_DLLPREFIX name SAL_DLLEXTENSION
35 #else
36 #define SAL_MODULENAME(name) name SAL_DLLEXTENSION
37 #endif
39 #if defined(SAL_W32)
40 #define SAL_MODULENAME_WITH_VERSION(name, version) name version SAL_DLLEXTENSION
42 #elif defined(SAL_UNX)
43 #if defined(MACOSX)
44 #define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name ".dylib." version
45 #else
46 #define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name SAL_DLLEXTENSION "." version
47 #endif
49 #endif
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.
77 @since UDK 3.6
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.
83 @param baseModule
84 must point to a function that is part of the code of some loaded module;
85 must not be NULL.
87 @param relativePath
88 a relative URL; must not be NULL.
90 @param mode
91 the SAL_LOADMODULE_xxx flags.
93 @return
94 a non-NULL handle to the loaded module, or NULL if an error occurred.
96 @since UDK 3.2.8
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.
103 @param baseModule
104 must point to a function that is part of the code of some loaded module;
105 must not be NULL.
107 @param relativePath
108 a relative URL containing only ASCII (0x01--7F) characters; must not be
109 NULL.
111 @param mode
112 the SAL_LOADMODULE_xxx flags.
114 @return
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. */
125 #endif
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.
133 @param pModuleName
134 [in] denotes the name of the module to search for. Ignored on Unix
136 @param pResult
137 [out] a pointer to a oslModule that is updated with the requested module handle
138 on success.
140 @return
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);
155 #endif
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.
167 @param Module
168 [in] the handle of the Module.
170 @param ustrFunctionSymbolName
171 [in] Name of the function that will be looked up.
173 @return
174 <dl>
175 <dt>Function address.</dt>
176 <dd>on success</dd>
177 <dt>NULL</dt>
178 <dd>lookup failed or the parameter are invalid.</dd>
179 </dl>
181 @see osl_getSymbol
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.
192 @param Module
193 [in] a module handle as returned by osl_loadModule or osl_getModuleHandle
195 @param pSymbol
196 [in] Name of the function that will be looked up.
198 @return
199 <dl>
200 <dt>Function address.</dt>
201 <dd>on success</dd>
202 <dt>NULL</dt>
203 <dd>lookup failed or the parameter are invalid.</dd>
204 </dl>
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.
226 @param pf
227 [in] function address in oslGenericFunction format.
229 @param pustrFunctionURL
230 [out] receives the URL of the module that is mapped at pf.
232 @return
233 <dl>
234 <dt>sal_True</dt>
235 <dd>on success</dd>
236 <dt>sal_False</dt>
237 <dd>no module can be found at the specified function address or parameter is somewhat invalid.</dd>
238 </dl>
240 @see osl_getModuleURLFromAddress
242 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress(
243 oslGenericFunction pf, rtl_uString **pustrFunctionURL );
245 #ifdef __cplusplus
247 #endif
249 #endif // INCLUDED_OSL_MODULE_H
251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */