dynconfig: added SBINDIR and BINDIR as updated dynconfig variables
[bbaumbach/samba-autobuild/.git] / dynconfig / dynconfig.c
1 /*
2    Unix SMB/CIFS implementation.
3    Copyright (C) 2001 by Martin Pool <mbp@samba.org>
4    Copyright (C) Jim McDonough (jmcd@us.ibm.com)  2003.
5    Copyright (C) Stefan Metzmacher      2003
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "nsswitch/winbind_struct_protocol.h"
23
24 /**
25  * @file dynconfig.c
26  *
27  * @brief Global configurations, initialized to configured defaults.
28  *
29  * This file should be the only file that depends on path
30  * configuration (--prefix, etc), so that if ./configure is re-run,
31  * all programs will be appropriately updated.  Everything else in
32  * Samba should import extern variables from here, rather than relying
33  * on preprocessor macros.
34  *
35  * Eventually some of these may become even more variable, so that
36  * they can for example consistently be set across the whole of Samba
37  * by command-line parameters, config file entries, or environment
38  * variables.
39  *
40  * @todo Perhaps eventually these should be merged into the parameter
41  * table?  There's kind of a chicken-and-egg situation there...
42  **/
43
44 #include "dynconfig.h"
45 #ifdef strdup
46 #undef strdup
47 #endif
48
49 #define DEFINE_DYN_CONFIG_PARAM(name) \
50 const char *dyn_##name = name; \
51 \
52 bool is_default_dyn_##name(void) \
53 {\
54         if (strcmp(name, dyn_##name) == 0) { \
55                 return true; \
56         } \
57         return false; \
58 }\
59 \
60 const char *get_dyn_##name(void) \
61 {\
62         return dyn_##name;\
63 }\
64 \
65 const char *set_dyn_##name(const char *newpath) \
66 {\
67         if (newpath == NULL) { \
68                 return NULL; \
69         } \
70         if (strcmp(name, newpath) == 0) { \
71                 return dyn_##name; \
72         } \
73         newpath = strdup(newpath);\
74         if (newpath == NULL) { \
75                 return NULL; \
76         } \
77         if (is_default_dyn_##name()) { \
78                 /* do not free a static string */ \
79         } else if (dyn_##name) {\
80                 free(discard_const(dyn_##name)); \
81         }\
82         dyn_##name = newpath; \
83         return dyn_##name;\
84 }
85
86 /* these are in common with s3 */
87 DEFINE_DYN_CONFIG_PARAM(SBINDIR)
88 DEFINE_DYN_CONFIG_PARAM(BINDIR)
89 DEFINE_DYN_CONFIG_PARAM(SWATDIR)
90 DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/
91 DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/
92 DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
93 DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR)
94 DEFINE_DYN_CONFIG_PARAM(LIBDIR)
95 DEFINE_DYN_CONFIG_PARAM(MODULESDIR)
96 DEFINE_DYN_CONFIG_PARAM(SHLIBEXT)
97 DEFINE_DYN_CONFIG_PARAM(LOCKDIR)
98 DEFINE_DYN_CONFIG_PARAM(STATEDIR) /** Persistent state files. Default LOCKDIR */
99 DEFINE_DYN_CONFIG_PARAM(CACHEDIR) /** Temporary cache files. Default LOCKDIR */
100 DEFINE_DYN_CONFIG_PARAM(PIDDIR)
101 DEFINE_DYN_CONFIG_PARAM(NCALRPCDIR)
102 DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE)
103 DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR)
104 DEFINE_DYN_CONFIG_PARAM(LOCALEDIR)
105 DEFINE_DYN_CONFIG_PARAM(NMBDSOCKETDIR)
106 DEFINE_DYN_CONFIG_PARAM(DATADIR)
107 DEFINE_DYN_CONFIG_PARAM(SETUPDIR)
108 DEFINE_DYN_CONFIG_PARAM(WINBINDD_SOCKET_DIR) /* from winbind_struct_protocol.h in s3 autoconf */
109
110 /* these are not used in s3 */
111 #ifdef WINBINDD_PRIVILEGED_SOCKET_DIR
112 DEFINE_DYN_CONFIG_PARAM(WINBINDD_PRIVILEGED_SOCKET_DIR)
113 #endif
114 #ifdef NTP_SIGND_SOCKET_DIR
115 DEFINE_DYN_CONFIG_PARAM(NTP_SIGND_SOCKET_DIR)
116 #endif
117 #ifdef PYTHONDIR
118 DEFINE_DYN_CONFIG_PARAM(PYTHONDIR)
119 #endif
120 #ifdef PYTHONARCHDIR
121 DEFINE_DYN_CONFIG_PARAM(PYTHONARCHDIR)
122 #endif
123 #ifdef SCRIPTSBINDIR
124 DEFINE_DYN_CONFIG_PARAM(SCRIPTSBINDIR)
125 #endif