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