source: branches/samba-3.0/source/dynconfig.c@ 431

Last change on this file since 431 was 367, checked in by Herwig Bauernfeind, 16 years ago

_divers os2_getExePath applied to BINDIR, SBINDIR and SWATDIR in 3.0.x

File size: 5.9 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Copyright (C) 2001 by Martin Pool <mbp@samba.org>
4 Copyright (C) 2003 by Jim McDonough <jmcd@us.ibm.com>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#include "includes.h"
22
23/**
24 * @file dynconfig.c
25 *
26 * @brief Global configurations, initialized to configured defaults.
27 *
28 * This file should be the only file that depends on path
29 * configuration (--prefix, etc), so that if ./configure is re-run,
30 * all programs will be appropriately updated. Everything else in
31 * Samba should import extern variables from here, rather than relying
32 * on preprocessor macros.
33 *
34 * Eventually some of these may become even more variable, so that
35 * they can for example consistently be set across the whole of Samba
36 * by command-line parameters, config file entries, or environment
37 * variables.
38 *
39 * @todo Perhaps eventually these should be merged into the parameter
40 * table? There's kind of a chicken-and-egg situation there...
41 **/
42
43
44#ifdef __OS2__
45
46/* Directory the binary was called from, same as getbindir() */
47const char * getsbindir()
48{
49 static pstring buffer = "";
50 if (!*buffer)
51 {
52 pstring exedir = "";
53 if (os2_GetExePath(exedir) != 0)
54 {
55 snprintf(buffer, 260, "%s", SBINDIR);
56 } else {
57 snprintf(buffer, 260, "%s", exedir);
58 }
59 }
60 return buffer;
61}
62
63/* Directory the binary was called from, same as getsbindir() */
64const char * getbindir()
65{
66 static pstring buffer = "";
67 if (!*buffer)
68 {
69 pstring exedir = "";
70 if (os2_GetExePath(exedir) != 0)
71 {
72 snprintf(buffer, 260, "%s", BINDIR);
73 } else {
74 snprintf(buffer, 260, "%s", exedir);
75 }
76 }
77 return buffer;
78}
79
80/* Directory holding the SWAT files */
81const char * getswatdir()
82{
83 static pstring buffer = "";
84 if (!*buffer)
85 {
86 pstring exedir = "";
87 if (os2_GetExePath(exedir) != 0)
88 {
89 snprintf(buffer, 260, "%s", SWATDIR);
90 } else {
91 snprintf(buffer, 260, "%s/%s", exedir,"swat");
92 }
93 }
94 return buffer;
95}
96
97/* Location of smb.conf file. */
98const char * getconfigfile()
99{
100 static pstring buffer = "";
101 if (!*buffer)
102 {
103 snprintf(buffer, 260, "%s/samba/smb.conf", getenv("ETC"));
104
105 /* Set UNIXROOT to x:\MPTN if UNIXROOT is undefined */
106 if (getenv("UNIXROOT") == NULL) {
107 static pstring unixroot = "";
108 strncpy(unixroot,getenv("ETC"),strlen(getenv("ETC"))-4);
109 setenv("UNIXROOT",unixroot,0);
110 }
111 /* Make sure TMPIR points to a proper value */
112 static pstring tmpdir = "";
113 if (getenv("TMPDIR") == NULL && getenv("TEMP") != NULL) {
114 strncpy(tmpdir,getenv("TEMP"),strlen(getenv("TEMP")));
115 setenv("TMPDIR",tmpdir,0);
116 }
117 if (getenv("TMPDIR") == NULL) {
118 strncpy(tmpdir,getenv("ETC"),2);
119 stpcpy(tmpdir,"/OS2/SYSTEM");
120 setenv("TMPDIR",tmpdir,0);
121 }
122 }
123 return buffer;
124}
125
126/* Log file directory */
127const char * getlogbase()
128{
129 static pstring buffer = "";
130 if (!*buffer)
131 {
132 snprintf(buffer, 260, "%s/samba/log", getenv("ETC"));
133 }
134 return buffer;
135}
136
137/* Directory holding lock files */
138const char * getlockdir()
139{
140 static pstring buffer = "";
141 if (!*buffer)
142 {
143 snprintf(buffer, 260, "%s/samba/lock", getenv("ETC"));
144 }
145 return buffer;
146}
147
148/* Directory holding the pid files */
149const char * getpiddir()
150{
151 static pstring buffer = "";
152 if (!*buffer)
153 {
154 snprintf(buffer, 260, "%s/samba/pid", getenv("ETC"));
155 }
156 return buffer;
157}
158
159/* Directory holding the private files */
160const char * getprivatedir()
161{
162 static pstring buffer = "";
163 if (!*buffer)
164 {
165 snprintf(buffer, 260, "%s/samba/private", getenv("ETC"));
166 }
167 return buffer;
168}
169
170/* Location of smbpasswd */
171const char * getsmbpasswd()
172{
173 static pstring buffer = "";
174 if (!*buffer)
175 {
176 snprintf(buffer, 260, "%s/samba/private/smbpasswd", getenv("ETC"));
177 }
178 return buffer;
179}
180
181/* Statically configured LanMan hosts */
182const char * getlmhosts()
183{
184 static pstring buffer = "";
185 if (!*buffer)
186 {
187 snprintf(buffer, 260, "%s/samba/lmhosts", getenv("ETC"));
188 }
189 return buffer;
190}
191
192/**
193 * @brief Samba library directory.
194 *
195 * @sa lib_path() to get the path to a file inside the LIBDIR.
196 **/
197// SCS we try to set the libdir based on the current running process
198const char * getlibdir()
199{
200 static pstring buffer = "";
201 if (!*buffer)
202 {
203 pstring exedir = "";
204 if (os2_GetExePath(exedir) != 0)
205 {
206 snprintf(buffer, 260, "%s", LIBDIR);
207 } else {
208 snprintf(buffer, 260, "%s/%s", exedir, "lib");
209 }
210 }
211 return buffer;
212}
213
214fstring dyn_SHLIBEXT = SHLIBEXT;
215
216#else
217
218char const *dyn_SBINDIR = SBINDIR,
219 *dyn_BINDIR = BINDIR,
220 *dyn_SWATDIR = SWATDIR;
221
222/**< Location of smb.conf file. **/
223pstring dyn_CONFIGFILE = CONFIGFILE;
224
225/** Log file directory. **/
226pstring dyn_LOGFILEBASE = LOGFILEBASE;
227
228/** Statically configured LanMan hosts. **/
229pstring dyn_LMHOSTSFILE = LMHOSTSFILE;
230
231/**
232 * @brief Samba library directory.
233 *
234 * @sa lib_path() to get the path to a file inside the LIBDIR.
235 **/
236pstring dyn_LIBDIR = LIBDIR;
237fstring dyn_SHLIBEXT = SHLIBEXT;
238
239/**
240 * @brief Directory holding lock files.
241 *
242 * Not writable, but used to set a default in the parameter table.
243 **/
244pstring dyn_LOCKDIR = LOCKDIR;
245pstring dyn_PIDDIR = PIDDIR;
246
247pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE;
248pstring dyn_PRIVATE_DIR = PRIVATE_DIR;
249#endif /* __OS2__ */
Note: See TracBrowser for help on using the repository browser.