187d2adbcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
387d2adbcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
487d2adbcSAndrew Rist * or more contributor license agreements. See the NOTICE file
587d2adbcSAndrew Rist * distributed with this work for additional information
687d2adbcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
787d2adbcSAndrew Rist * to you under the Apache License, Version 2.0 (the
887d2adbcSAndrew Rist * "License"); you may not use this file except in compliance
987d2adbcSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
1187d2adbcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
1387d2adbcSAndrew Rist * Unless required by applicable law or agreed to in writing,
1487d2adbcSAndrew Rist * software distributed under the License is distributed on an
1587d2adbcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1687d2adbcSAndrew Rist * KIND, either express or implied. See the License for the
1787d2adbcSAndrew Rist * specific language governing permissions and limitations
1887d2adbcSAndrew Rist * under the License.
19cdf0e10cSrcweir *
2087d2adbcSAndrew Rist *************************************************************/
2187d2adbcSAndrew Rist
2287d2adbcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sal.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "sal/config.h"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <cstddef>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include "osl/diagnose.h"
32cdf0e10cSrcweir #include "osl/module.h"
33cdf0e10cSrcweir #include "osl/module.hxx"
34cdf0e10cSrcweir #include "osl/thread.h"
35cdf0e10cSrcweir #include "rtl/malformeduriexception.hxx"
36cdf0e10cSrcweir #include "rtl/uri.hxx"
37cdf0e10cSrcweir #include "rtl/ustring.h"
38cdf0e10cSrcweir #include "rtl/ustring.hxx"
39cdf0e10cSrcweir #include "sal/types.h"
40cdf0e10cSrcweir
41cdf0e10cSrcweir extern "C" {
42cdf0e10cSrcweir
osl_loadModuleRelative(oslGenericFunction const baseModule,rtl_uString * const relativePath,sal_Int32 const mode)43cdf0e10cSrcweir oslModule SAL_CALL osl_loadModuleRelative(
44cdf0e10cSrcweir oslGenericFunction const baseModule, rtl_uString * const relativePath,
45cdf0e10cSrcweir sal_Int32 const mode)
46cdf0e10cSrcweir {
47cdf0e10cSrcweir ::rtl::OUString base;
48cdf0e10cSrcweir if (!::osl::Module::getUrlFromAddress(baseModule, base)) {
49cdf0e10cSrcweir OSL_TRACE("osl::Module::getUrlFromAddress failed");
50cdf0e10cSrcweir return NULL;
51cdf0e10cSrcweir }
52cdf0e10cSrcweir ::rtl::OUString abs;
53cdf0e10cSrcweir try {
54cdf0e10cSrcweir abs = ::rtl::Uri::convertRelToAbs(base, relativePath);
55cdf0e10cSrcweir } catch (::rtl::MalformedUriException & e) {
56cdf0e10cSrcweir (void) e; // avoid warnings
57cdf0e10cSrcweir OSL_TRACE(
58cdf0e10cSrcweir "rtl::MalformedUriException <%s>",
59cdf0e10cSrcweir rtl::OUStringToOString(e.getMessage(), osl_getThreadTextEncoding()).
60cdf0e10cSrcweir getStr());
61cdf0e10cSrcweir //TODO: let some OSL_TRACE variant take care of text conversion?
62cdf0e10cSrcweir return NULL;
63cdf0e10cSrcweir }
64cdf0e10cSrcweir return ::osl_loadModule(abs.pData, mode);
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
osl_loadAsciiModuleRelative(oslGenericFunction const baseModule,const sal_Char * pRelativePathName,sal_Int32 const nRtldMode)67ca2659a9SHerbert Dürr oslModule SAL_CALL osl_loadAsciiModuleRelative(
68ca2659a9SHerbert Dürr oslGenericFunction const baseModule, const sal_Char* pRelativePathName,
69ca2659a9SHerbert Dürr sal_Int32 const nRtldMode)
70ca2659a9SHerbert Dürr {
71ca2659a9SHerbert Dürr rtl_uString* pUniName = NULL;
72ca2659a9SHerbert Dürr rtl_uString_newFromAscii( &pUniName, pRelativePathName );
73ca2659a9SHerbert Dürr oslModule aModule = osl_loadModuleRelative( baseModule, pUniName, nRtldMode );
74ca2659a9SHerbert Dürr rtl_uString_release( pUniName );
75*80036c20SHerbert Dürr return aModule;
76ca2659a9SHerbert Dürr }
77ca2659a9SHerbert Dürr
78cdf0e10cSrcweir }
79