xref: /aoo41x/main/soldep/bootstrp/appdef.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31 
32 #include <soldep/appdef.hxx>
33 
34 const char* GetDefStandList()
35 {
36 	char* pRet;
37 	char* pEnv = getenv("STAR_STANDLST");
38 	if ( pEnv )
39 	{
40 		int nLen = strlen( pEnv );
41 		pRet = ( char *) malloc( nLen + 1 );
42 		(void) strcpy( pRet, pEnv );
43 	}
44 	else
45 	{
46 		int nLen = strlen( _DEF_STAND_LIST );
47 		pRet = ( char *) malloc( nLen + 1 );
48 		(void) strcpy( pRet, _DEF_STAND_LIST );
49 	}
50 	return pRet;
51 }
52 
53 
54 const char* GetIniRoot()
55 {
56 	char* pRet;
57 	char* pEnv = getenv("STAR_INIROOT");
58 	if ( pEnv )
59 	{
60 		int nLen = strlen( pEnv );
61 		pRet = ( char *) malloc( nLen + 1 );
62 		(void) strcpy( pRet, pEnv );
63 	}
64 	else
65 	{
66 		int nLen = strlen( _INIROOT );
67 		pRet = ( char *) malloc( nLen + 1 );
68 		(void) strcpy( pRet, _INIROOT );
69 	}
70 	return pRet;
71 }
72 
73 const char* GetIniRootOld()
74 {
75 	char* pRet;
76 	char* pEnv = getenv("STAR_INIROOTOLD");
77 	if ( pEnv )
78 	{
79 		int nLen = strlen( pEnv );
80 		pRet = ( char *) malloc( nLen + 1 );
81 		(void) strcpy( pRet, pEnv );
82 	}
83 	else
84 	{
85 		int nLen = strlen( _INIROOT_OLD );
86 		pRet = ( char *) malloc( nLen + 1 );
87 		(void) strcpy( pRet, _INIROOT_OLD );
88 	}
89 	return pRet;
90 }
91 
92 const char* GetSSolarIni()
93 {
94 	char* pRet;
95 	char* pEnv = getenv("STAR_SSOLARINI");
96 	if ( pEnv )
97 	{
98 		int nLen = strlen( pEnv );
99 		pRet = ( char *) malloc( nLen + 1 );
100 		(void) strcpy( pRet, pEnv );
101 	}
102 	else
103 	{
104 		int nLen = strlen( _DEF_SSOLARINI );
105 		pRet = ( char *) malloc( nLen + 1 );
106 		(void) strcpy( pRet, _DEF_SSOLARINI );
107 	}
108 	return pRet;
109 }
110 
111 
112 const char* GetSSCommon()
113 {
114 	char* pRet;
115 	char* pEnv = getenv("STAR_SSCOMMON");
116 	if ( pEnv )
117 	{
118 		int nLen = strlen( pEnv );
119 		pRet = ( char *) malloc( nLen + 1 );
120 		(void) strcpy( pRet, pEnv );
121 	}
122 	else
123 	{
124 		int nLen = strlen( _DEF_SSCOMMON );
125 		pRet = ( char *) malloc( nLen + 1 );
126 		(void) strcpy( pRet, _DEF_SSCOMMON );
127 	}
128 	return pRet;
129 }
130 
131 
132 const char* GetBServerRoot()
133 {
134 	char* pRet;
135 	char* pEnv = getenv("STAR_BSERVERROOT");
136 	if ( pEnv )
137 	{
138 		int nLen = strlen( pEnv );
139 		pRet = ( char *) malloc( nLen + 1 );
140 		(void) strcpy( pRet, pEnv );
141 	}
142 	else
143 	{
144 		int nLen = strlen( B_SERVER_ROOT );
145 		pRet = ( char *) malloc( nLen + 1 );
146 		(void) strcpy( pRet, B_SERVER_ROOT );
147 	}
148 	return pRet;
149 }
150 
151 const char* GetEnv( const char *pVar )
152 {
153 	char *pRet = getenv( pVar );
154 	if ( !pRet )
155 		pRet = "";
156 	return pRet;
157 }
158 
159 const char* GetEnv( const char *pVar, const char *pDefault )
160 {
161 	char *pRet = getenv( pVar );
162 	if ( !pRet )
163 		return pDefault;
164 	return pRet;
165 }
166