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