1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "rtl/ustring.hxx"
25 #include "uno/environment.h"
26 #include "env_subst.hxx"
27
28
uno_getEnvironment(uno_Environment ** ppEnv,rtl_uString * pEnvDcp,void * pContext)29 void SAL_CALL uno_getEnvironment(uno_Environment ** ppEnv,
30 rtl_uString * pEnvDcp,
31 void * pContext)
32 SAL_THROW_EXTERN_C()
33 {
34 rtl::OUString envDcp(pEnvDcp);
35
36 rtl::OString a_envName("UNO_ENV_SUBST:");
37 a_envName += rtl::OUStringToOString(envDcp, RTL_TEXTENCODING_ASCII_US);
38 char * c_value = getenv(a_envName.getStr());
39 if (c_value && rtl_str_getLength(c_value))
40 {
41 rtl::OString a_envDcp(a_envName.copy(a_envName.indexOf(':') + 1));
42
43 OSL_TRACE("UNO_ENV_SUBST \"%s\" -> \"%s\"", a_envDcp.getStr(), c_value);
44 rtl::OUString value(c_value, rtl_str_getLength(c_value), RTL_TEXTENCODING_ASCII_US);
45
46 envDcp = value;
47 }
48
49 uno_direct_getEnvironment(ppEnv, envDcp.pData, pContext);
50 }
51