LCOV - code coverage report
Current view: top level - dynconfig - dynconfig.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 23 28 82.1 %
Date: 2024-02-28 12:06:22 Functions: 27 84 32.1 %

          Line data    Source code
       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             : /**
      22             :  * @file dynconfig.c
      23             :  *
      24             :  * @brief Global configurations, initialized to configured defaults.
      25             :  *
      26             :  * This file should be the only file that depends on path
      27             :  * configuration (--prefix, etc), so that if ./configure is re-run,
      28             :  * all programs will be appropriately updated.  Everything else in
      29             :  * Samba should import extern variables from here, rather than relying
      30             :  * on preprocessor macros.
      31             :  *
      32             :  * Eventually some of these may become even more variable, so that
      33             :  * they can for example consistently be set across the whole of Samba
      34             :  * by command-line parameters, config file entries, or environment
      35             :  * variables.
      36             :  *
      37             :  * @todo Perhaps eventually these should be merged into the parameter
      38             :  * table?  There's kind of a chicken-and-egg situation there...
      39             :  **/
      40             : 
      41             : #include "replace.h"
      42             : #include "dynconfig.h"
      43             : #include "lib/util/memory.h"
      44             : 
      45             : #define DEFINE_DYN_CONFIG_PARAM(name) \
      46             : const char *dyn_##name = name; \
      47             : \
      48             : bool is_default_dyn_##name(void) \
      49             : {\
      50             :         if (strcmp(name, dyn_##name) == 0) { \
      51             :                 return true; \
      52             :         } \
      53             :         return false; \
      54             : }\
      55             : \
      56             : const char *get_dyn_##name(void) \
      57             : {\
      58             :         return dyn_##name;\
      59             : }\
      60             : \
      61             : const char *set_dyn_##name(const char *newpath) \
      62             : {\
      63             :         if (newpath == NULL) { \
      64             :                 return NULL; \
      65             :         } \
      66             :         if (strcmp(name, newpath) == 0) { \
      67             :                 return dyn_##name; \
      68             :         } \
      69             :         newpath = strdup(newpath);\
      70             :         if (newpath == NULL) { \
      71             :                 return NULL; \
      72             :         } \
      73             :         if (is_default_dyn_##name()) { \
      74             :                 /* do not free a static string */ \
      75             :         } else if (dyn_##name) {\
      76             :                 free(discard_const(dyn_##name)); \
      77             :         }\
      78             :         dyn_##name = newpath; \
      79             :         return dyn_##name;\
      80             : }
      81             : 
      82          50 : DEFINE_DYN_CONFIG_PARAM(SBINDIR)
      83          58 : DEFINE_DYN_CONFIG_PARAM(BINDIR)
      84      165115 : DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/
      85       35772 : DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/
      86         616 : DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
      87           0 : DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR)
      88          50 : DEFINE_DYN_CONFIG_PARAM(LIBDIR)
      89      544209 : DEFINE_DYN_CONFIG_PARAM(MODULESDIR)
      90         164 : DEFINE_DYN_CONFIG_PARAM(SAMBA_LIBEXECDIR)
      91      181025 : DEFINE_DYN_CONFIG_PARAM(SHLIBEXT)
      92       98469 : DEFINE_DYN_CONFIG_PARAM(LOCKDIR)
      93      209440 : DEFINE_DYN_CONFIG_PARAM(STATEDIR) /** Persistent state files. Default LOCKDIR */
      94       98469 : DEFINE_DYN_CONFIG_PARAM(CACHEDIR) /** Temporary cache files. Default LOCKDIR */
      95       98469 : DEFINE_DYN_CONFIG_PARAM(PIDDIR)
      96       98419 : DEFINE_DYN_CONFIG_PARAM(NCALRPCDIR)
      97      111021 : DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE)
      98       98469 : DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR)
      99       98469 : DEFINE_DYN_CONFIG_PARAM(BINDDNS_DIR)
     100        3456 : DEFINE_DYN_CONFIG_PARAM(LOCALEDIR)
     101         922 : DEFINE_DYN_CONFIG_PARAM(NMBDSOCKETDIR)
     102          50 : DEFINE_DYN_CONFIG_PARAM(DATADIR)
     103          56 : DEFINE_DYN_CONFIG_PARAM(SAMBA_DATADIR)
     104           0 : DEFINE_DYN_CONFIG_PARAM(SETUPDIR)
     105           0 : DEFINE_DYN_CONFIG_PARAM(WINBINDD_SOCKET_DIR) /* from winbind_struct_protocol.h in s3 autoconf */
     106       98419 : DEFINE_DYN_CONFIG_PARAM(NTP_SIGND_SOCKET_DIR)
     107           0 : DEFINE_DYN_CONFIG_PARAM(PYTHONDIR)
     108           0 : DEFINE_DYN_CONFIG_PARAM(PYTHONARCHDIR)
     109      393676 : DEFINE_DYN_CONFIG_PARAM(SCRIPTSBINDIR)

Generated by: LCOV version 1.14