s3-param Rename struct service and struct globals
[ira/wip.git] / source3 / param / loadparm.c
index 18fdc75834c9908b7c4b31dd4c1176e621809813..a1ee2a7caa8f1111e735d46425131e7e1deccebb 100644 (file)
@@ -125,7 +125,7 @@ struct param_opt_struct {
 /*
  * This structure describes global (ie., server-wide) parameters.
  */
-struct global {
+struct loadparm_global {
        int ConfigBackend;
        char *smb_ports;
        char *dos_charset;
@@ -175,7 +175,6 @@ struct global {
        char *szSocketAddress;
        bool bNmbdBindExplicitBroadcast;
        char *szNISHomeMapName;
-       char *szAnnounceVersion;        /* This is initialised in init_globals */
        char *szWorkgroup;
        char *szNetbiosName;
        char **szNetbiosAliases;
@@ -260,7 +259,6 @@ struct global {
        int min_wins_ttl;
        int lm_announce;
        int lm_interval;
-       int announce_as;        /* This is initialised in init_globals */
        int machine_password_timeout;
        int map_to_guest;
        int oplock_break_wait_time;
@@ -387,12 +385,12 @@ struct global {
        char *ncalrpc_dir;
 };
 
-static struct global Globals;
+static struct loadparm_global Globals;
 
 /*
  * This structure describes a single service.
  */
-struct service {
+struct loadparm_service {
        bool valid;
        bool autoloaded;
        int usershare;
@@ -537,7 +535,7 @@ struct service {
 
 
 /* This is a default service used to prime a services structure */
-static struct service sDefault = {
+static struct loadparm_service sDefault = {
        True,                   /* valid */
        False,                  /* not autoloaded */
        0,                      /* not a usershare */
@@ -685,7 +683,7 @@ static struct service sDefault = {
 };
 
 /* local variables */
-static struct service **ServicePtrs = NULL;
+static struct loadparm_service **ServicePtrs = NULL;
 static int iNumServices = 0;
 static int iServiceIndex = 0;
 static struct db_context *ServiceHash;
@@ -714,7 +712,7 @@ static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **
 static void set_default_server_announce_type(void);
 static void set_allowed_client_auth(void);
 
-static void *lp_local_ptr(struct service *service, void *ptr);
+static void *lp_local_ptr(struct loadparm_service *service, void *ptr);
 
 static void add_to_file_list(const char *fname, const char *subfname);
 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
@@ -798,21 +796,6 @@ static const struct enum_list enum_ldap_passwd_sync[] = {
        {-1, NULL}
 };
 
-/* Types of machine we can announce as. */
-#define ANNOUNCE_AS_NT_SERVER 1
-#define ANNOUNCE_AS_WIN95 2
-#define ANNOUNCE_AS_WFW 3
-#define ANNOUNCE_AS_NT_WORKSTATION 4
-
-static const struct enum_list enum_announce_as[] = {
-       {ANNOUNCE_AS_NT_SERVER, "NT"},
-       {ANNOUNCE_AS_NT_SERVER, "NT Server"},
-       {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
-       {ANNOUNCE_AS_WIN95, "win95"},
-       {ANNOUNCE_AS_WFW, "WfW"},
-       {-1, NULL}
-};
-
 static const struct enum_list enum_map_readonly[] = {
        {MAP_READONLY_NO, "no"},
        {MAP_READONLY_NO, "false"},
@@ -2168,24 +2151,6 @@ static struct parm_struct parm_table[] = {
                .enum_list      = NULL,
                .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
        },
-       {
-               .label          = "announce version",
-               .type           = P_STRING,
-               .p_class        = P_GLOBAL,
-               .ptr            = &Globals.szAnnounceVersion,
-               .special        = NULL,
-               .enum_list      = NULL,
-               .flags          = FLAG_ADVANCED,
-       },
-       {
-               .label          = "announce as",
-               .type           = P_ENUM,
-               .p_class        = P_GLOBAL,
-               .ptr            = &Globals.announce_as,
-               .special        = NULL,
-               .enum_list      = enum_announce_as,
-               .flags          = FLAG_ADVANCED,
-       },
        {
                .label          = "map acl inherit",
                .type           = P_BOOL,
@@ -4775,7 +4740,7 @@ static struct parm_struct parm_table[] = {
  Initialise the sDefault parameter structure for the printer values.
 ***************************************************************************/
 
-static void init_printer_values(struct service *pService)
+static void init_printer_values(struct loadparm_service *pService)
 {
        /* choose defaults depending on the type of printing */
        switch (pService->iPrinting) {
@@ -4977,7 +4942,7 @@ static void free_one_parameter_common(void *parm_ptr,
  * Free the allocated data for one parameter for a share
  * given as a service struct.
  */
-static void free_one_parameter(struct service *service,
+static void free_one_parameter(struct loadparm_service *service,
                               struct parm_struct parm)
 {
        void *parm_ptr;
@@ -4995,7 +4960,7 @@ static void free_one_parameter(struct service *service,
  * Free the allocated parameter data of a share given
  * as a service struct.
  */
-static void free_parameters(struct service *service)
+static void free_parameters(struct loadparm_service *service)
 {
        uint32_t i;
 
@@ -5203,12 +5168,6 @@ static void init_globals(bool reinit_globals)
        }
        string_set(&Globals.szServerString, s);
        SAFE_FREE(s);
-       if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
-                       DEFAULT_MINOR_VERSION) < 0) {
-               smb_panic("init_globals: ENOMEM");
-       }
-       string_set(&Globals.szAnnounceVersion, s);
-       SAFE_FREE(s);
 #ifdef DEVELOPER
        string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
 #endif
@@ -5273,7 +5232,6 @@ static void init_globals(bool reinit_globals)
        Globals.machine_password_timeout = 60 * 60 * 24 * 7;    /* 7 days default. */
        Globals.lm_announce = 2;        /* = Auto: send only if LM clients found */
        Globals.lm_interval = 60;
-       Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
 #if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
        Globals.bNISHomeMap = False;
 #ifdef WITH_NISPLUS_HOME
@@ -5607,50 +5565,8 @@ FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, bNmbdBindExplicitBroadcast)
 FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
 FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
 FN_GLOBAL_STRING(lp_nis_home_map_name, szNISHomeMapName)
-static FN_GLOBAL_STRING(lp_announce_version, szAnnounceVersion)
 FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
-/* FN_GLOBAL_STRING(lp_passdb_backend, szPassdbBackend)
- * lp_passdb_backend() should be replace by the this macro again after
- * some releases.
- * */
-const char *lp_passdb_backend(void)
-{
-       char *delim, *quote;
-
-       delim = strchr( Globals.szPassdbBackend, ' ');
-       /* no space at all */
-       if (delim == NULL) {
-               goto out;
-       }
-
-       quote = strchr(Globals.szPassdbBackend, '"');
-       /* no quote char or non in the first part */
-       if (quote == NULL || quote > delim) {
-               *delim = '\0';
-               goto warn;
-       }
-
-       quote = strchr(quote+1, '"');
-       if (quote == NULL) {
-               DEBUG(0, ("WARNING: Your 'passdb backend' configuration is invalid due to a missing second \" char.\n"));
-               goto out;
-       } else if (*(quote+1) == '\0') {
-               /* space, fitting quote char, and one backend only */
-               goto out;
-       } else {
-               /* terminate string after the fitting quote char */
-               *(quote+1) = '\0';
-       }
-
-warn:
-       DEBUG(0, ("WARNING: Your 'passdb backend' configuration includes multiple backends.  This\n"
-               "is deprecated since Samba 3.0.23.  Please check WHATSNEW.txt or the section 'Passdb\n"
-               "Changes' from the ChangeNotes as part of the Samba HOWTO collection.  Only the first\n"
-               "backend (%s) is used.  The rest is ignored.\n", Globals.szPassdbBackend));
-
-out:
-       return Globals.szPassdbBackend;
-}
+FN_GLOBAL_CONST_STRING(lp_passdb_backend, szPassdbBackend)
 FN_GLOBAL_LIST(lp_preload_modules, szPreloadModules)
 FN_GLOBAL_STRING(lp_panic_action, szPanicAction)
 FN_GLOBAL_STRING(lp_adduser_script, szAddUserScript)
@@ -5836,7 +5752,6 @@ FN_GLOBAL_INTEGER(lp_lpqcachetime, lpqcachetime)
 FN_GLOBAL_INTEGER(lp_max_smbd_processes, iMaxSmbdProcesses)
 FN_GLOBAL_BOOL(_lp_disable_spoolss, bDisableSpoolss)
 FN_GLOBAL_INTEGER(lp_syslog, syslog)
-static FN_GLOBAL_INTEGER(lp_announce_as, announce_as)
 FN_GLOBAL_INTEGER(lp_lm_announce, lm_announce)
 FN_GLOBAL_INTEGER(lp_lm_interval, lm_interval)
 FN_GLOBAL_INTEGER(lp_machine_password_timeout, machine_password_timeout)
@@ -6029,14 +5944,14 @@ FN_GLOBAL_CONST_STRING(lp_ncalrpc_dir, ncalrpc_dir)
 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
 static const char *get_boolean(bool bool_value);
 static int getservicebyname(const char *pszServiceName,
-                           struct service *pserviceDest);
-static void copy_service(struct service *pserviceDest,
-                        struct service *pserviceSource,
+                           struct loadparm_service *pserviceDest);
+static void copy_service(struct loadparm_service *pserviceDest,
+                        struct loadparm_service *pserviceSource,
                         struct bitmap *pcopymapDest);
 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
                         void *userdata);
 static bool do_section(const char *pszSectionName, void *userdata);
-static void init_copymap(struct service *pservice);
+static void init_copymap(struct loadparm_service *pservice);
 static bool hash_a_service(const char *name, int number);
 static void free_service_byindex(int iService);
 static void free_param_opts(struct param_opt_struct **popts);
@@ -6170,18 +6085,6 @@ static int lp_enum(const char *s,const struct enum_list *_enum)
 
 #undef MISSING_PARAMETER
 
-/* DO NOT USE lp_parm_string ANYMORE!!!!
- * use lp_parm_const_string or lp_parm_talloc_string
- *
- * lp_parm_string is only used to let old modules find this symbol
- */
-#undef lp_parm_string
- char *lp_parm_string(const char *servicename, const char *type, const char *option);
- char *lp_parm_string(const char *servicename, const char *type, const char *option)
-{
-       return lp_parm_talloc_string(lp_servicenumber(servicename), type, option, NULL);
-}
-
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
 /* the returned value is talloced on the talloc_tos() */
@@ -6287,9 +6190,9 @@ int lp_parm_enum(int snum, const char *type, const char *option,
  Initialise a service to the defaults.
 ***************************************************************************/
 
-static void init_service(struct service *pservice)
+static void init_service(struct loadparm_service *pservice)
 {
-       memset((char *)pservice, '\0', sizeof(struct service));
+       memset((char *)pservice, '\0', sizeof(struct loadparm_service));
        copy_service(pservice, &sDefault, NULL);
 }
 
@@ -6327,7 +6230,7 @@ static void free_param_opts(struct param_opt_struct **popts)
  Free the dynamically allocated parts of a service struct.
 ***************************************************************************/
 
-static void free_service(struct service *pservice)
+static void free_service(struct loadparm_service *pservice)
 {
        if (!pservice)
                return;
@@ -6379,10 +6282,10 @@ static void free_service_byindex(int idx)
  service. 
 ***************************************************************************/
 
-static int add_a_service(const struct service *pservice, const char *name)
+static int add_a_service(const struct loadparm_service *pservice, const char *name)
 {
        int i;
-       struct service tservice;
+       struct loadparm_service tservice;
        int num_to_alloc = iNumServices + 1;
 
        tservice = *pservice;
@@ -6403,16 +6306,16 @@ static int add_a_service(const struct service *pservice, const char *name)
 
        /* if not, then create one */
        if (i == iNumServices) {
-               struct service **tsp;
+               struct loadparm_service **tsp;
                int *tinvalid;
 
-               tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
+               tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct loadparm_service *, num_to_alloc);
                if (tsp == NULL) {
                        DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
                        return (-1);
                }
                ServicePtrs = tsp;
-               ServicePtrs[iNumServices] = SMB_MALLOC_P(struct service);
+               ServicePtrs[iNumServices] = SMB_MALLOC_P(struct loadparm_service);
                if (!ServicePtrs[iNumServices]) {
                        DEBUG(0,("add_a_service: out of memory!\n"));
                        return (-1);
@@ -6986,7 +6889,7 @@ bool lp_canonicalize_boolean(const char *str, const char**canon_str)
 Find a service by name. Otherwise works like get_service.
 ***************************************************************************/
 
-static int getservicebyname(const char *pszServiceName, struct service *pserviceDest)
+static int getservicebyname(const char *pszServiceName, struct loadparm_service *pserviceDest)
 {
        int iService = -1;
        char *canon_name;
@@ -7067,7 +6970,7 @@ static void set_param_opt(struct param_opt_struct **opt_list,
        }
 }
 
-static void copy_service(struct service *pserviceDest, struct service *pserviceSource,
+static void copy_service(struct loadparm_service *pserviceDest, struct loadparm_service *pserviceSource,
                         struct bitmap *pcopymapDest)
 {
        int i;
@@ -7622,7 +7525,7 @@ static bool handle_copy(int snum, const char *pszParmValue, char **ptr)
 {
        bool bRetval;
        int iTemp;
-       struct service serviceTemp;
+       struct loadparm_service serviceTemp;
 
        string_set(ptr, pszParmValue);
 
@@ -7813,7 +7716,7 @@ static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue
 static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
 {
        static int parm_num = -1;
-       struct service *s;
+       struct loadparm_service *s;
 
        if ( parm_num == -1 )
                parm_num = map_parameter( "printing" );
@@ -7835,7 +7738,7 @@ static bool handle_printing(int snum, const char *pszParmValue, char **ptr)
  Initialise a copymap.
 ***************************************************************************/
 
-static void init_copymap(struct service *pservice)
+static void init_copymap(struct loadparm_service *pservice)
 {
        int i;
 
@@ -7856,7 +7759,7 @@ static void init_copymap(struct service *pservice)
  pointer into the default structure.
 ***************************************************************************/
 
-static void *lp_local_ptr(struct service *service, void *ptr)
+static void *lp_local_ptr(struct loadparm_service *service, void *ptr)
 {
        return (void *)(((char *)service) + PTR_DIFF(ptr, &sDefault));
 }
@@ -8348,7 +8251,7 @@ bool lp_is_default(int snum, struct parm_struct *parm)
  Display the contents of a single services record.
 ***************************************************************************/
 
-static void dump_a_service(struct service *pService, FILE * f)
+static void dump_a_service(struct loadparm_service *pService, FILE * f)
 {
        int i;
        struct param_opt_struct *data;
@@ -8446,7 +8349,7 @@ bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
                        if (isGlobal) {
                                ptr = parm_table[i].ptr;
                        } else {
-                               struct service *pService = ServicePtrs[snum];
+                               struct loadparm_service *pService = ServicePtrs[snum];
                                ptr = ((char *)pService) +
                                        PTR_DIFF(parm_table[i].ptr, &sDefault);
                        }
@@ -8507,7 +8410,7 @@ struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
                        return &parm_table[(*i)++];
                }
        } else {
-               struct service *pService = ServicePtrs[snum];
+               struct loadparm_service *pService = ServicePtrs[snum];
 
                for (; parm_table[*i].label; (*i)++) {
                        if (parm_table[*i].p_class == P_SEPARATOR)
@@ -9122,7 +9025,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
 
        /* Everything ok - add the service possibly using a template. */
        if (iService < 0) {
-               const struct service *sp = &sDefault;
+               const struct loadparm_service *sp = &sDefault;
                if (snum_template != -1) {
                        sp = ServicePtrs[snum_template];
                }
@@ -9800,22 +9703,8 @@ static void set_default_server_announce_type(void)
 
        default_server_announce |= SV_TYPE_PRINTQ_SERVER;
 
-       switch (lp_announce_as()) {
-               case ANNOUNCE_AS_NT_SERVER:
-                       default_server_announce |= SV_TYPE_SERVER_NT;
-                       /* fall through... */
-               case ANNOUNCE_AS_NT_WORKSTATION:
-                       default_server_announce |= SV_TYPE_NT;
-                       break;
-               case ANNOUNCE_AS_WIN95:
-                       default_server_announce |= SV_TYPE_WIN95_PLUS;
-                       break;
-               case ANNOUNCE_AS_WFW:
-                       default_server_announce |= SV_TYPE_WFW;
-                       break;
-               default:
-                       break;
-       }
+       default_server_announce |= SV_TYPE_SERVER_NT;
+       default_server_announce |= SV_TYPE_NT;
 
        switch (lp_server_role()) {
                case ROLE_DOMAIN_MEMBER:
@@ -9908,54 +9797,6 @@ int lp_default_server_announce(void)
        return default_server_announce;
 }
 
-/*******************************************************************
- Split the announce version into major and minor numbers.
-********************************************************************/
-
-int lp_major_announce_version(void)
-{
-       static bool got_major = False;
-       static int major_version = DEFAULT_MAJOR_VERSION;
-       char *vers;
-       char *p;
-
-       if (got_major)
-               return major_version;
-
-       got_major = True;
-       if ((vers = lp_announce_version()) == NULL)
-               return major_version;
-
-       if ((p = strchr_m(vers, '.')) == 0)
-               return major_version;
-
-       *p = '\0';
-       major_version = atoi(vers);
-       return major_version;
-}
-
-int lp_minor_announce_version(void)
-{
-       static bool got_minor = False;
-       static int minor_version = DEFAULT_MINOR_VERSION;
-       char *vers;
-       char *p;
-
-       if (got_minor)
-               return minor_version;
-
-       got_minor = True;
-       if ((vers = lp_announce_version()) == NULL)
-               return minor_version;
-
-       if ((p = strchr_m(vers, '.')) == 0)
-               return minor_version;
-
-       p++;
-       minor_version = atoi(p);
-       return minor_version;
-}
-
 /***********************************************************
  Set the global name resolution order (used in smbclient).
 ************************************************************/