xref: /AOO41X/main/tools/bootstrp/appdef.cxx (revision 89b56da77b74925c286b3e777681ba8dda16bf41)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_tools.hxx"
26 
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
30 
31 #include "bootstrp/appdef.hxx"
32 
GetDefStandList()33 const char* GetDefStandList()
34 {
35     char* pRet;
36     char* pEnv = getenv("STAR_STANDLST");
37     if ( pEnv )
38     {
39         int nLen = strlen( pEnv );
40         pRet = ( char *) malloc( nLen + 1 );
41         (void) strcpy( pRet, pEnv );
42     }
43     else
44     {
45         int nLen = strlen( _DEF_STAND_LIST );
46         pRet = ( char *) malloc( nLen + 1 );
47         (void) strcpy( pRet, _DEF_STAND_LIST );
48     }
49     return pRet;
50 }
51 
52 
GetIniRoot()53 const char* GetIniRoot()
54 {
55     char* pRet;
56     char* pEnv = getenv("STAR_INIROOT");
57     if ( pEnv )
58     {
59         int nLen = strlen( pEnv );
60         pRet = ( char *) malloc( nLen + 1 );
61         (void) strcpy( pRet, pEnv );
62     }
63     else
64     {
65         int nLen = strlen( _INIROOT );
66         pRet = ( char *) malloc( nLen + 1 );
67         (void) strcpy( pRet, _INIROOT );
68     }
69     return pRet;
70 }
71 
GetIniRootOld()72 const char* GetIniRootOld()
73 {
74     char* pRet;
75     char* pEnv = getenv("STAR_INIROOTOLD");
76     if ( pEnv )
77     {
78         int nLen = strlen( pEnv );
79         pRet = ( char *) malloc( nLen + 1 );
80         (void) strcpy( pRet, pEnv );
81     }
82     else
83     {
84         int nLen = strlen( _INIROOT_OLD );
85         pRet = ( char *) malloc( nLen + 1 );
86         (void) strcpy( pRet, _INIROOT_OLD );
87     }
88     return pRet;
89 }
90 
GetSSolarIni()91 const char* GetSSolarIni()
92 {
93     char* pRet;
94     char* pEnv = getenv("STAR_SSOLARINI");
95     if ( pEnv )
96     {
97         int nLen = strlen( pEnv );
98         pRet = ( char *) malloc( nLen + 1 );
99         (void) strcpy( pRet, pEnv );
100     }
101     else
102     {
103         int nLen = strlen( _DEF_SSOLARINI );
104         pRet = ( char *) malloc( nLen + 1 );
105         (void) strcpy( pRet, _DEF_SSOLARINI );
106     }
107     return pRet;
108 }
109 
110 
GetSSCommon()111 const char* GetSSCommon()
112 {
113     char* pRet;
114     char* pEnv = getenv("STAR_SSCOMMON");
115     if ( pEnv )
116     {
117         int nLen = strlen( pEnv );
118         pRet = ( char *) malloc( nLen + 1 );
119         (void) strcpy( pRet, pEnv );
120     }
121     else
122     {
123         int nLen = strlen( _DEF_SSCOMMON );
124         pRet = ( char *) malloc( nLen + 1 );
125         (void) strcpy( pRet, _DEF_SSCOMMON );
126     }
127     return pRet;
128 }
129 
130 
GetBServerRoot()131 const char* GetBServerRoot()
132 {
133     char* pRet;
134     char* pEnv = getenv("STAR_BSERVERROOT");
135     if ( pEnv )
136     {
137         int nLen = strlen( pEnv );
138         pRet = ( char *) malloc( nLen + 1 );
139         (void) strcpy( pRet, pEnv );
140     }
141     else
142     {
143         int nLen = strlen( B_SERVER_ROOT );
144         pRet = ( char *) malloc( nLen + 1 );
145         (void) strcpy( pRet, B_SERVER_ROOT );
146     }
147     return pRet;
148 }
149 
GetEnv(const char * pVar)150 const char* GetEnv( const char *pVar )
151 {
152     char const *pRet = getenv( pVar );
153     if ( !pRet )
154         pRet = "";
155     return pRet;
156 }
157 
GetEnv(const char * pVar,const char * pDefault)158 const char* GetEnv( const char *pVar, const char *pDefault )
159 {
160     char *pRet = getenv( pVar );
161     if ( !pRet )
162         return pDefault;
163     return pRet;
164 }
165