param: turn 'printcap name' into a generated function
[gd/samba-autobuild/.git] / source3 / param / loadparm.c
index b53cae29973c9b4cd36ee1b76246f63871defb80..98eaec590f5ced70e622ac2bfc75b924babf7d27 100644 (file)
@@ -158,7 +158,7 @@ static struct loadparm_service sDefault =
        .aio_write_behind = NULL,
        .dfree_command = NULL,
        .min_print_space = 0,
-       .iMaxPrintJobs = 1000,
+       .max_print_jobs = 1000,
        .max_reported_print_jobs = 0,
        .write_cache_size = 0,
        .create_mask = 0744,
@@ -185,6 +185,7 @@ static struct loadparm_service sDefault =
        .access_based_share_enum = false,
        .bAvailable = true,
        .read_only = true,
+       .spotlight = false,
        .guest_only = false,
        .administrative_share = false,
        .guest_ok = false,
@@ -238,8 +239,6 @@ static struct loadparm_service sDefault =
        .acl_map_full_control = true,
        .acl_group_control = false,
        .acl_allow_execute_always = false,
-       .change_notify = true,
-       .kernel_change_notify = true,
        .allocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE,
        .aio_read_size = 0,
        .aio_write_size = 0,
@@ -643,7 +642,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
        Globals.large_readwrite = true;
        Globals.max_log_size = 5000;
        Globals.max_open_files = max_open_files();
-       Globals.server_max_protocol = PROTOCOL_SMB3_00;
+       Globals.server_max_protocol = PROTOCOL_SMB3_11;
        Globals.server_min_protocol = PROTOCOL_LANMAN1;
        Globals._client_max_protocol = PROTOCOL_DEFAULT;
        Globals.client_min_protocol = PROTOCOL_CORE;
@@ -721,12 +720,15 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
           a large number of sites (tridge) */
        Globals.hostname_lookups = false;
 
+       Globals.change_notify = true,
+       Globals.kernel_change_notify = true,
+
        string_set(Globals.ctx, &Globals.passdb_backend, "tdbsam");
        string_set(Globals.ctx, &Globals.ldap_suffix, "");
-       string_set(Globals.ctx, &Globals.szLdapMachineSuffix, "");
-       string_set(Globals.ctx, &Globals.szLdapUserSuffix, "");
-       string_set(Globals.ctx, &Globals.szLdapGroupSuffix, "");
-       string_set(Globals.ctx, &Globals.szLdapIdmapSuffix, "");
+       string_set(Globals.ctx, &Globals._ldap_machine_suffix, "");
+       string_set(Globals.ctx, &Globals._ldap_user_suffix, "");
+       string_set(Globals.ctx, &Globals._ldap_group_suffix, "");
+       string_set(Globals.ctx, &Globals._ldap_idmap_suffix, "");
 
        string_set(Globals.ctx, &Globals.ldap_admin_dn, "");
        Globals.ldap_ssl = LDAP_SSL_START_TLS;
@@ -848,7 +850,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
        /* By default no shares out of the registry */
        Globals.registry_shares = false;
 
-       Globals.iminreceivefile = 0;
+       Globals.min_receivefile_size = 0;
 
        Globals.map_untrusted_to_domain = false;
        Globals.multicast_dns_register = true;
@@ -870,10 +872,11 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
        string_set(Globals.ctx, &Globals._tls_keyfile, "tls/key.pem");
        string_set(Globals.ctx, &Globals._tls_certfile, "tls/cert.pem");
        string_set(Globals.ctx, &Globals._tls_cafile, "tls/ca.pem");
+       string_set(Globals.ctx, &Globals.tls_priority, "NORMAL:-VERS-SSL3.0");
 
        string_set(Globals.ctx, &Globals.share_backend, "classic");
 
-       Globals.iPreferredMaster = Auto;
+       Globals._preferred_master = Auto;
 
        Globals.allow_dns_updates = DNS_UPDATE_SIGNED;
 
@@ -1395,7 +1398,7 @@ static bool hash_a_service(const char *name, int idx)
        canon_name = canonicalize_servicename(talloc_tos(), name );
 
        dbwrap_store_bystring(ServiceHash, canon_name,
-                             make_tdb_data((uint8 *)&idx, sizeof(idx)),
+                             make_tdb_data((uint8_t *)&idx, sizeof(idx)),
                              TDB_REPLACE);
 
        TALLOC_FREE(canon_name);
@@ -1567,22 +1570,6 @@ bool lp_parameter_is_global(const char *pszParmName)
        return false;
 }
 
-/**************************************************************************
- Check whether the given name is the canonical name of a parameter.
- Returns false if it is not a valid parameter Name.
- For parametric options, true is returned.
-**************************************************************************/
-
-bool lp_parameter_is_canonical(const char *parm_name)
-{
-       if (!lp_parameter_is_valid(parm_name)) {
-               return false;
-       }
-
-       return (lpcfg_map_parameter(parm_name) ==
-               map_parameter_canonical(parm_name, NULL));
-}
-
 /**************************************************************************
  Determine the canonical name for a parameter.
  Indicate when it is an inverse (boolean) synonym instead of a
@@ -1668,7 +1655,7 @@ static int map_parameter_canonical(const char *pszParmName, bool *inverse)
        bool loc_inverse = false;
 
        parm_num = lpcfg_map_parameter(pszParmName);
-       if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_HIDE)) {
+       if ((parm_num < 0) || !(parm_table[parm_num].flags & FLAG_SYNONYM)) {
                /* invalid, parametric or no canidate for synonyms ... */
                goto done;
        }
@@ -1698,8 +1685,8 @@ static bool is_synonym_of(int parm1, int parm2, bool *inverse)
 {
        if ((parm_table[parm1].offset == parm_table[parm2].offset) &&
            (parm_table[parm1].p_class == parm_table[parm2].p_class) &&
-           (parm_table[parm1].flags & FLAG_HIDE) &&
-           !(parm_table[parm2].flags & FLAG_HIDE))
+           (parm_table[parm1].flags & FLAG_SYNONYM) &&
+           !(parm_table[parm2].flags & FLAG_SYNONYM))
        {
                if (inverse != NULL) {
                        if ((parm_table[parm1].type == P_BOOLREV) &&
@@ -1729,13 +1716,9 @@ static void show_parameter(int parmIndex)
        bool inverse;
        const char *type[] = { "P_BOOL", "P_BOOLREV", "P_CHAR", "P_INTEGER",
                "P_OCTAL", "P_LIST", "P_STRING", "P_USTRING",
-               "P_ENUM", "P_SEP"};
-       unsigned flags[] = { FLAG_BASIC, FLAG_SHARE, FLAG_PRINT, FLAG_GLOBAL,
-               FLAG_WIZARD, FLAG_ADVANCED, FLAG_DEVELOPER, FLAG_DEPRECATED,
-               FLAG_HIDE};
-       const char *flag_names[] = { "FLAG_BASIC", "FLAG_SHARE", "FLAG_PRINT",
-               "FLAG_GLOBAL", "FLAG_WIZARD", "FLAG_ADVANCED", "FLAG_DEVELOPER",
-               "FLAG_DEPRECATED", "FLAG_HIDE", NULL};
+               "P_ENUM", "P_BYTES", "P_CMDLIST" };
+       unsigned flags[] = { FLAG_DEPRECATED, FLAG_SYNONYM };
+       const char *flag_names[] = { "FLAG_DEPRECATED", "FLAG_SYNONYM", NULL};
 
        printf("%s=%s", parm_table[parmIndex].label,
               type[parm_table[parmIndex].type]);
@@ -2378,32 +2361,32 @@ static const char *append_ldap_suffix(TALLOC_CTX *ctx, const char *str )
 
 const char *lp_ldap_machine_suffix(TALLOC_CTX *ctx)
 {
-       if (Globals.szLdapMachineSuffix[0])
-               return append_ldap_suffix(ctx, Globals.szLdapMachineSuffix);
+       if (Globals._ldap_machine_suffix[0])
+               return append_ldap_suffix(ctx, Globals._ldap_machine_suffix);
 
        return lp_string(ctx, Globals.ldap_suffix);
 }
 
 const char *lp_ldap_user_suffix(TALLOC_CTX *ctx)
 {
-       if (Globals.szLdapUserSuffix[0])
-               return append_ldap_suffix(ctx, Globals.szLdapUserSuffix);
+       if (Globals._ldap_user_suffix[0])
+               return append_ldap_suffix(ctx, Globals._ldap_user_suffix);
 
        return lp_string(ctx, Globals.ldap_suffix);
 }
 
 const char *lp_ldap_group_suffix(TALLOC_CTX *ctx)
 {
-       if (Globals.szLdapGroupSuffix[0])
-               return append_ldap_suffix(ctx, Globals.szLdapGroupSuffix);
+       if (Globals._ldap_group_suffix[0])
+               return append_ldap_suffix(ctx, Globals._ldap_group_suffix);
 
        return lp_string(ctx, Globals.ldap_suffix);
 }
 
 const char *lp_ldap_idmap_suffix(TALLOC_CTX *ctx)
 {
-       if (Globals.szLdapIdmapSuffix[0])
-               return append_ldap_suffix(ctx, Globals.szLdapIdmapSuffix);
+       if (Globals._ldap_idmap_suffix[0])
+               return append_ldap_suffix(ctx, Globals._ldap_idmap_suffix);
 
        return lp_string(ctx, Globals.ldap_suffix);
 }
@@ -2840,8 +2823,6 @@ static void lp_save_defaults(void)
                                parm_table[i].def.ivalue =
                                        *(int *)lp_parm_ptr(NULL, &parm_table[i]);
                                break;
-                       case P_SEP:
-                               break;
                }
        }
 
@@ -4120,10 +4101,12 @@ static bool lp_domain_master_true_or_auto(void)
 
 bool lp_preferred_master(void)
 {
-       if (Globals.iPreferredMaster == Auto)
+       int preferred_master = lp__preferred_master();
+
+       if (preferred_master == Auto)
                return (lp_local_master() && lp_domain_master());
 
-       return (bool)Globals.iPreferredMaster;
+       return (bool)preferred_master;
 }
 
 /*******************************************************************
@@ -4162,7 +4145,8 @@ void lp_set_logfile(const char *name)
 
 int lp_maxprintjobs(int snum)
 {
-       int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
+       int maxjobs = lp_max_print_jobs(snum);
+
        if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
                maxjobs = PRINT_MAX_JOBID - 1;
 
@@ -4171,9 +4155,11 @@ int lp_maxprintjobs(int snum)
 
 const char *lp_printcapname(void)
 {
-       if ((Globals.szPrintcapname != NULL) &&
-           (Globals.szPrintcapname[0] != '\0'))
-               return Globals.szPrintcapname;
+       const char *printcap_name = lp_printcap_name();
+
+       if ((printcap_name != NULL) &&
+           (printcap_name[0] != '\0'))
+               return printcap_name;
 
        if (sDefault.printing == PRINT_CUPS) {
                return "cups";
@@ -4185,7 +4171,7 @@ const char *lp_printcapname(void)
        return PRINTCAP_NAME;
 }
 
-static uint32 spoolss_state;
+static uint32_t spoolss_state;
 
 bool lp_disable_spoolss( void )
 {
@@ -4195,14 +4181,14 @@ bool lp_disable_spoolss( void )
        return spoolss_state == SVCCTL_STOPPED ? true : false;
 }
 
-void lp_set_spoolss_state( uint32 state )
+void lp_set_spoolss_state( uint32_t state )
 {
        SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) );
 
        spoolss_state = state;
 }
 
-uint32 lp_get_spoolss_state( void )
+uint32_t lp_get_spoolss_state( void )
 {
        return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING;
 }
@@ -4303,10 +4289,12 @@ void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
 
 int lp_min_receive_file_size(void)
 {
-       if (Globals.iminreceivefile < 0) {
+       int min_receivefile_size = lp_min_receivefile_size();
+
+       if (min_receivefile_size < 0) {
                return 0;
        }
-       return Globals.iminreceivefile;
+       return min_receivefile_size;
 }
 
 /*******************************************************************