s3-libnet: Add libnet_join_get_machine_spns().
[Samba.git] / dynconfig / dynconfig.c
blobcf35bdb435dccdc9264df734126b4463932efac6
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
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.
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.
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/>.
21 #include "includes.h"
23 /**
24 * @file dynconfig.c
26 * @brief Global configurations, initialized to configured defaults.
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.
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.
39 * @todo Perhaps eventually these should be merged into the parameter
40 * table? There's kind of a chicken-and-egg situation there...
41 **/
43 #include "dynconfig.h"
44 #ifdef strdup
45 #undef strdup
46 #endif
48 #define DEFINE_DYN_CONFIG_PARAM(name) \
49 const char *dyn_##name = name; \
51 bool is_default_dyn_##name(void) \
53 if (strcmp(name, dyn_##name) == 0) { \
54 return true; \
55 } \
56 return false; \
59 const char *get_dyn_##name(void) \
61 return dyn_##name;\
64 const char *set_dyn_##name(const char *newpath) \
66 if (newpath == NULL) { \
67 return NULL; \
68 } \
69 if (strcmp(name, newpath) == 0) { \
70 return dyn_##name; \
71 } \
72 newpath = strdup(newpath);\
73 if (newpath == NULL) { \
74 return NULL; \
75 } \
76 if (is_default_dyn_##name()) { \
77 /* do not free a static string */ \
78 } else if (dyn_##name) {\
79 free(discard_const(dyn_##name)); \
81 dyn_##name = newpath; \
82 return dyn_##name;\
85 DEFINE_DYN_CONFIG_PARAM(SBINDIR)
86 DEFINE_DYN_CONFIG_PARAM(BINDIR)
87 DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/
88 DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/
89 DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
90 DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR)
91 DEFINE_DYN_CONFIG_PARAM(LIBDIR)
92 DEFINE_DYN_CONFIG_PARAM(MODULESDIR)
93 DEFINE_DYN_CONFIG_PARAM(SHLIBEXT)
94 DEFINE_DYN_CONFIG_PARAM(LOCKDIR)
95 DEFINE_DYN_CONFIG_PARAM(STATEDIR) /** Persistent state files. Default LOCKDIR */
96 DEFINE_DYN_CONFIG_PARAM(CACHEDIR) /** Temporary cache files. Default LOCKDIR */
97 DEFINE_DYN_CONFIG_PARAM(PIDDIR)
98 DEFINE_DYN_CONFIG_PARAM(NCALRPCDIR)
99 DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE)
100 DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR)
101 DEFINE_DYN_CONFIG_PARAM(LOCALEDIR)
102 DEFINE_DYN_CONFIG_PARAM(NMBDSOCKETDIR)
103 DEFINE_DYN_CONFIG_PARAM(DATADIR)
104 DEFINE_DYN_CONFIG_PARAM(SETUPDIR)
105 DEFINE_DYN_CONFIG_PARAM(WINBINDD_SOCKET_DIR) /* from winbind_struct_protocol.h in s3 autoconf */
106 DEFINE_DYN_CONFIG_PARAM(WINBINDD_PRIVILEGED_SOCKET_DIR)
107 DEFINE_DYN_CONFIG_PARAM(NTP_SIGND_SOCKET_DIR)
108 DEFINE_DYN_CONFIG_PARAM(PYTHONDIR)
109 DEFINE_DYN_CONFIG_PARAM(PYTHONARCHDIR)
110 DEFINE_DYN_CONFIG_PARAM(SCRIPTSBINDIR)