summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-08 16:46:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:05:43 -0500
commit98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8 (patch)
tree044b24a249cc2b63c2f69214d7e7da288c170c74 /source4/param
parentce0ff008b5c5af931526d14fa6232f8647e0880f (diff)
downloadsamba-98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8.tar.gz
samba-98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8.tar.bz2
samba-98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8.zip
r25035: Fix some more warnings, use service pointer rather than service number in more places.
(This used to be commit df9cebcb97e20564359097148665bd519f31bc6f)
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/loadparm.c137
-rw-r--r--source4/param/param.h2
-rw-r--r--source4/param/share_classic.c120
3 files changed, 123 insertions, 136 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index c7c7656863..61b1aafbf4 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -819,19 +819,15 @@ static const char *lp_string(const char *s)
int fn_name(void) {return(*(int *)(ptr));}
#define FN_LOCAL_STRING(fn_name,val) \
- const char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && loadparm.ServicePtrs[(i)]->val) ? loadparm.ServicePtrs[(i)]->val : sDefault.val));}
+ const char *fn_name(struct service *service) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault.val)));}
#define FN_LOCAL_CONST_STRING(fn_name,val) \
- const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && loadparm.ServicePtrs[(i)]->val) ? loadparm.ServicePtrs[(i)]->val : sDefault.val);}
+ const char *fn_name(struct service *service) {return (const char *)(service != NULL && service->val != NULL) ? service->val : sDefault.val;}
#define FN_LOCAL_LIST(fn_name,val) \
- const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? loadparm.ServicePtrs[(i)]->val : sDefault.val);}
+ const char **fn_name(struct service *service) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault.val);}
#define FN_LOCAL_BOOL(fn_name,val) \
- bool fn_name(int i) {return(LP_SNUM_OK(i)? loadparm.ServicePtrs[(i)]->val : sDefault.val);}
-#if 0 /* unused */
-#define FN_LOCAL_CHAR(fn_name,val) \
- char fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
-#endif
+ bool fn_name(struct service *service) {return((service != NULL)? service->val : sDefault.val);}
#define FN_LOCAL_INTEGER(fn_name,val) \
- int fn_name(int i) {return(LP_SNUM_OK(i)? loadparm.ServicePtrs[(i)]->val : sDefault.val);}
+ int fn_name(struct service *service) {return((service != NULL)? service->val : sDefault.val);}
_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_role, &loadparm.Globals.server_role)
_PUBLIC_ FN_GLOBAL_LIST(lp_smb_ports, &loadparm.Globals.smb_ports)
@@ -968,16 +964,12 @@ static void init_copymap(struct service * pservice);
/* This is a helper function for parametrical options support. */
/* It returns a pointer to parametrical option value if it exists or NULL otherwise */
/* Actual parametrical functions are quite simple */
-const char *lp_get_parametric(int lookup_service, const char *type, const char *option)
+const char *lp_get_parametric(struct service *service, const char *type, const char *option)
{
char *vfskey;
struct param_opt *data;
- if (lookup_service >= 0 && !LP_SNUM_OK(lookup_service))
- return NULL;
-
- data = (lookup_service < 0) ?
- loadparm.Globals.param_opt : loadparm.ServicePtrs[lookup_service]->param_opt;
+ data = (service == NULL ? loadparm.Globals.param_opt : service->param_opt);
asprintf(&vfskey, "%s:%s", type, option);
strlower(vfskey);
@@ -990,7 +982,7 @@ const char *lp_get_parametric(int lookup_service, const char *type, const char *
data = data->next;
}
- if (lookup_service >= 0) {
+ if (service != NULL) {
/* Try to fetch the same option but from globals */
/* but only if we are not already working with Globals */
for (data = loadparm.Globals.param_opt; data;
@@ -1075,9 +1067,10 @@ static bool lp_bool(const char *s)
/* Parametric option has following syntax: 'Type: option = value' */
/* Returned value is allocated in 'lp_talloc' context */
-const char *lp_parm_string(int lookup_service, const char *type, const char *option)
+const char *lp_parm_string(struct service *service, const char *type,
+ const char *option)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(service, type, option);
if (value)
return lp_string(value);
@@ -1089,10 +1082,10 @@ const char *lp_parm_string(int lookup_service, const char *type, const char *opt
/* Parametric option has following syntax: 'Type: option = value' */
/* Returned value is allocated in 'lp_talloc' context */
-const char **lp_parm_string_list(int lookup_service, const char *type, const char *option,
- const char *separator)
+const char **lp_parm_string_list(struct service *service, const char *type,
+ const char *option, const char *separator)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(service, type, option);
if (value)
return str_list_make(talloc_autofree_context(), value, separator);
@@ -1103,9 +1096,10 @@ const char **lp_parm_string_list(int lookup_service, const char *type, const cha
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
-int lp_parm_int(int lookup_service, const char *type, const char *option, int default_v)
+int lp_parm_int(struct service *service, const char *type, const char *option,
+ int default_v)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(service, type, option);
if (value)
return lp_int(value);
@@ -1118,11 +1112,12 @@ int lp_parm_int(int lookup_service, const char *type, const char *option, int de
* Parametric option has following syntax: 'Type: option = value'.
*/
-int lp_parm_bytes(int lookup_service, const char *type, const char *option, int default_v)
+int lp_parm_bytes(struct service *service, const char *type,
+ const char *option, int default_v)
{
uint64_t bval;
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(service, type, option);
if (value && conv_str_size(value, &bval)) {
if (bval <= INT_MAX) {
@@ -1136,9 +1131,10 @@ int lp_parm_bytes(int lookup_service, const char *type, const char *option, int
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
-unsigned long lp_parm_ulong(int lookup_service, const char *type, const char *option, unsigned long default_v)
+unsigned long lp_parm_ulong(struct service *service, const char *type,
+ const char *option, unsigned long default_v)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(service, type, option);
if (value)
return lp_ulong(value);
@@ -1147,9 +1143,10 @@ unsigned long lp_parm_ulong(int lookup_service, const char *type, const char *op
}
-double lp_parm_double(int lookup_service, const char *type, const char *option, double default_v)
+double lp_parm_double(struct service *service, const char *type,
+ const char *option, double default_v)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(service, type, option);
if (value)
return lp_double(value);
@@ -1160,10 +1157,10 @@ double lp_parm_double(int lookup_service, const char *type, const char *option,
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
-bool lp_parm_bool(int lookup_service, const char *type, const char *option,
- bool default_v)
+bool lp_parm_bool(struct service *service, const char *type,
+ const char *option, bool default_v)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(service, type, option);
if (value)
return lp_bool(value);
@@ -1261,22 +1258,22 @@ static struct service *add_a_service(const struct service *pservice, const char
from service ifrom.
***************************************************************************/
-bool lp_add_home(const char *pszHomename, int iDefaultService,
+bool lp_add_home(const char *pszHomename, struct service *default_service,
const char *user, const char *pszHomedir)
{
struct service *service;
pstring newHomedir;
- service = add_a_service(loadparm.ServicePtrs[iDefaultService], pszHomename);
+ service = add_a_service(default_service, pszHomename);
if (service == NULL)
return false;
- if (!(*(loadparm.ServicePtrs[iDefaultService]->szPath))
- || strequal(loadparm.ServicePtrs[iDefaultService]->szPath, lp_pathname(-1))) {
+ if (!(*(default_service->szPath))
+ || strequal(default_service->szPath, sDefault.szPath)) {
pstrcpy(newHomedir, pszHomedir);
} else {
- pstrcpy(newHomedir, lp_pathname(iDefaultService));
+ pstrcpy(newHomedir, lp_pathname(default_service));
string_sub(newHomedir,"%H", pszHomedir, sizeof(newHomedir));
}
@@ -1285,8 +1282,8 @@ bool lp_add_home(const char *pszHomename, int iDefaultService,
if (!(*(service->comment))) {
service->comment = talloc_asprintf(service, "Home directory of %s", user);
}
- service->bAvailable = sDefault.bAvailable;
- service->bBrowseable = sDefault.bBrowseable;
+ service->bAvailable = default_service->bAvailable;
+ service->bBrowseable = default_service->bBrowseable;
DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
pszHomename, user, newHomedir));
@@ -1298,9 +1295,10 @@ bool lp_add_home(const char *pszHomename, int iDefaultService,
Add a new service, based on an old one.
***************************************************************************/
-struct service *lp_add_service(const char *pszService, int iDefaultService)
+struct service *lp_add_service(const char *pszService,
+ struct service *default_service)
{
- return add_a_service(loadparm.ServicePtrs[iDefaultService], pszService);
+ return add_a_service(default_service, pszService);
}
/***************************************************************************
@@ -1338,12 +1336,11 @@ static bool lp_add_hidden(const char *name, const char *fstype)
Add a new printer service, with defaults coming from service iFrom.
***************************************************************************/
-bool lp_add_printer(const char *pszPrintername, int iDefaultService)
+bool lp_add_printer(const char *pszPrintername, struct service *default_service)
{
const char *comment = "From Printcap";
struct service *service;
- service = add_a_service(loadparm.ServicePtrs[iDefaultService],
- pszPrintername);
+ service = add_a_service(default_service, pszPrintername);
if (service == NULL)
return false;
@@ -1406,12 +1403,12 @@ struct parm_struct *lp_parm_struct(const char *name)
/*
return the parameter pointer for a parameter
*/
-void *lp_parm_ptr(int snum, struct parm_struct *parm)
+void *lp_parm_ptr(struct service *service, struct parm_struct *parm)
{
- if (snum == -1) {
+ if (service == NULL)
return parm->ptr;
- }
- return ((char *)loadparm.ServicePtrs[snum]) + PTR_DIFF(parm->ptr, &sDefault);
+
+ return ((char *)service) + PTR_DIFF(parm->ptr, &sDefault);
}
/***************************************************************************
@@ -2517,15 +2514,6 @@ bool lp_load(void)
}
/***************************************************************************
- Reset the max number of services.
-***************************************************************************/
-
-void lp_resetnumservices(void)
-{
- loadparm.iNumServices = 0;
-}
-
-/***************************************************************************
Return the max number of services.
***************************************************************************/
@@ -2550,22 +2538,35 @@ void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
dump_a_service(&sDefault, f);
for (iService = 0; iService < maxtoprint; iService++)
- lp_dump_one(f, show_defaults, iService);
+ lp_dump_one(f, show_defaults, loadparm.ServicePtrs[iService]);
}
/***************************************************************************
Display the contents of one service in human-readable form.
***************************************************************************/
-void lp_dump_one(FILE *f, bool show_defaults, int snum)
+void lp_dump_one(FILE *f, bool show_defaults, struct service *service)
{
- if (VALID(snum)) {
- if (loadparm.ServicePtrs[snum]->szService[0] == '\0')
+ if (service != NULL) {
+ if (service->szService[0] == '\0')
return;
- dump_a_service(loadparm.ServicePtrs[snum], f);
+ dump_a_service(service, f);
}
}
+struct service *lp_servicebynum(int snum)
+{
+ return loadparm.ServicePtrs[snum];
+}
+
+struct service *lp_service(const char *service_name)
+{
+ int snum = lp_servicenumber(service_name);
+ if (snum < 0)
+ return NULL;
+ return loadparm.ServicePtrs[snum];
+}
+
/***************************************************************************
Return the number of the service with the given name, or -1 if it doesn't
exist. Note that this is a DIFFERENT ANIMAL from the internal function
@@ -2619,11 +2620,11 @@ int lp_find_valid_service(const char *pszServiceName)
/*******************************************************************
A useful volume label function.
********************************************************************/
-const char *volume_label(int snum)
+const char *volume_label(struct service *service)
{
- const char *ret = lp_volume(snum);
+ const char *ret = lp_volume(service);
if (!*ret)
- return lp_servicename(snum);
+ return lp_servicename(service);
return ret;
}
@@ -2646,11 +2647,11 @@ void lp_remove_service(int snum)
loadparm.ServicePtrs[snum] = NULL;
}
-const char *lp_printername(int snum)
+const char *lp_printername(struct service *service)
{
- const char *ret = _lp_printername(snum);
+ const char *ret = _lp_printername(service);
if (ret == NULL || (ret != NULL && *ret == '\0'))
- ret = lp_const_servicename(snum);
+ ret = lp_const_servicename(service);
return ret;
}
diff --git a/source4/param/param.h b/source4/param/param.h
index 5f5da58388..9b21acf726 100644
--- a/source4/param/param.h
+++ b/source4/param/param.h
@@ -57,7 +57,7 @@ enum announce_as {/* Types of machine we can announce as. */
ANNOUNCE_AS_NT_WORKSTATION=4
};
-
+struct service;
#include "param/proto.h"
diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c
index 15f52eb9f1..0c39322345 100644
--- a/source4/param/share_classic.c
+++ b/source4/param/share_classic.c
@@ -23,8 +23,8 @@
#include "param/share.h"
#include "param/param.h"
-struct sclassic_snum {
- int snum;
+struct service {
+ struct service *service;
};
static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, struct share_context **ctx)
@@ -43,7 +43,7 @@ static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops,
static const char *sclassic_string_option(struct share_config *scfg, const char *opt_name, const char *defval)
{
- struct sclassic_snum *s = talloc_get_type(scfg->opaque, struct sclassic_snum);
+ struct service *s = talloc_get_type(scfg->opaque, struct service);
char *parm, *val;
const char *ret;
@@ -56,7 +56,7 @@ static const char *sclassic_string_option(struct share_config *scfg, const char
*val = '\0';
val++;
- ret = lp_parm_string(s->snum, parm, val);
+ ret = lp_parm_string(s, parm, val);
if (!ret) {
ret = defval;
}
@@ -69,25 +69,25 @@ static const char *sclassic_string_option(struct share_config *scfg, const char
}
if (strcmp(opt_name, SHARE_PATH) == 0) {
- return lp_pathname(s->snum);
+ return lp_pathname(s);
}
if (strcmp(opt_name, SHARE_COMMENT) == 0) {
- return lp_comment(s->snum);
+ return lp_comment(s);
}
if (strcmp(opt_name, SHARE_VOLUME) == 0) {
- return volume_label(s->snum);
+ return volume_label(s);
}
if (strcmp(opt_name, SHARE_TYPE) == 0) {
- if (lp_print_ok(s->snum)) {
+ if (lp_print_ok(s)) {
return "PRINTER";
}
- if (strcmp("NTFS", lp_fstype(s->snum)) == 0) {
+ if (strcmp("NTFS", lp_fstype(s)) == 0) {
return "DISK";
}
- return lp_fstype(s->snum);
+ return lp_fstype(s);
}
if (strcmp(opt_name, SHARE_PASSWORD) == 0) {
@@ -100,9 +100,9 @@ static const char *sclassic_string_option(struct share_config *scfg, const char
return defval;
}
-int sclassic_int_option(struct share_config *scfg, const char *opt_name, int defval)
+static int sclassic_int_option(struct share_config *scfg, const char *opt_name, int defval)
{
- struct sclassic_snum *s = talloc_get_type(scfg->opaque, struct sclassic_snum);
+ struct service *s = talloc_get_type(scfg->opaque, struct service);
char *parm, *val;
int ret;
@@ -115,7 +115,7 @@ int sclassic_int_option(struct share_config *scfg, const char *opt_name, int def
*val = '\0';
val++;
- ret = lp_parm_int(s->snum, parm, val, defval);
+ ret = lp_parm_int(s, parm, val, defval);
if (!ret) {
ret = defval;
}
@@ -124,27 +124,27 @@ int sclassic_int_option(struct share_config *scfg, const char *opt_name, int def
}
if (strcmp(opt_name, SHARE_CSC_POLICY) == 0) {
- return lp_csc_policy(s->snum);
+ return lp_csc_policy(s);
}
if (strcmp(opt_name, SHARE_MAX_CONNECTIONS) == 0) {
- return lp_max_connections(s->snum);
+ return lp_max_connections(s);
}
if (strcmp(opt_name, SHARE_CREATE_MASK) == 0) {
- return lp_create_mask(s->snum);
+ return lp_create_mask(s);
}
if (strcmp(opt_name, SHARE_DIR_MASK) == 0) {
- return lp_dir_mask(s->snum);
+ return lp_dir_mask(s);
}
if (strcmp(opt_name, SHARE_FORCE_DIR_MODE) == 0) {
- return lp_force_dir_mode(s->snum);
+ return lp_force_dir_mode(s);
}
if (strcmp(opt_name, SHARE_FORCE_CREATE_MODE) == 0) {
- return lp_force_create_mode(s->snum);
+ return lp_force_create_mode(s);
}
@@ -154,9 +154,10 @@ int sclassic_int_option(struct share_config *scfg, const char *opt_name, int def
return defval;
}
-BOOL sclassic_bool_option(struct share_config *scfg, const char *opt_name, BOOL defval)
+static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name,
+ bool defval)
{
- struct sclassic_snum *s = talloc_get_type(scfg->opaque, struct sclassic_snum);
+ struct service *s = talloc_get_type(scfg->opaque, struct service);
char *parm, *val;
BOOL ret;
@@ -169,49 +170,49 @@ BOOL sclassic_bool_option(struct share_config *scfg, const char *opt_name, BOOL
*val = '\0';
val++;
- ret = lp_parm_bool(s->snum, parm, val, defval);
+ ret = lp_parm_bool(s, parm, val, defval);
talloc_free(parm);
return ret;
}
if (strcmp(opt_name, SHARE_AVAILABLE) == 0) {
- return lp_snum_ok(s->snum);
+ return s != NULL;
}
if (strcmp(opt_name, SHARE_BROWSEABLE) == 0) {
- return lp_browseable(s->snum);
+ return lp_browseable(s);
}
if (strcmp(opt_name, SHARE_READONLY) == 0) {
- return lp_readonly(s->snum);
+ return lp_readonly(s);
}
if (strcmp(opt_name, SHARE_MAP_SYSTEM) == 0) {
- return lp_map_system(s->snum);
+ return lp_map_system(s);
}
if (strcmp(opt_name, SHARE_MAP_HIDDEN) == 0) {
- return lp_map_hidden(s->snum);
+ return lp_map_hidden(s);
}
if (strcmp(opt_name, SHARE_MAP_ARCHIVE) == 0) {
- return lp_map_archive(s->snum);
+ return lp_map_archive(s);
}
if (strcmp(opt_name, SHARE_STRICT_LOCKING) == 0) {
- return lp_strict_locking(s->snum);
+ return lp_strict_locking(s);
}
if (strcmp(opt_name, SHARE_STRICT_SYNC) == 0) {
- return lp_strict_sync(s->snum);
+ return lp_strict_sync(s);
}
if (strcmp(opt_name, SHARE_MSDFS_ROOT) == 0) {
- return lp_msdfs_root(s->snum);
+ return lp_msdfs_root(s);
}
if (strcmp(opt_name, SHARE_CI_FILESYSTEM) == 0) {
- return lp_ci_filesystem(s->snum);
+ return lp_ci_filesystem(s);
}
DEBUG(0,("request for unknown share bool option '%s'\n",
@@ -220,9 +221,9 @@ BOOL sclassic_bool_option(struct share_config *scfg, const char *opt_name, BOOL
return defval;
}
-const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name)
+static const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name)
{
- struct sclassic_snum *s = talloc_get_type(scfg->opaque, struct sclassic_snum);
+ struct service *s = talloc_get_type(scfg->opaque, struct service);
char *parm, *val;
const char **ret;
@@ -235,21 +236,21 @@ const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_confi
*val = '\0';
val++;
- ret = lp_parm_string_list(s->snum, parm, val, ",;");
+ ret = lp_parm_string_list(s, parm, val, ",;");
talloc_free(parm);
return ret;
}
if (strcmp(opt_name, SHARE_HOSTS_ALLOW) == 0) {
- return lp_hostsallow(s->snum);
+ return lp_hostsallow(s);
}
if (strcmp(opt_name, SHARE_HOSTS_DENY) == 0) {
- return lp_hostsdeny(s->snum);
+ return lp_hostsdeny(s);
}
if (strcmp(opt_name, SHARE_NTVFS_HANDLER) == 0) {
- return lp_ntvfs_handler(s->snum);
+ return lp_ntvfs_handler(s);
}
DEBUG(0,("request for unknown share list option '%s'\n",
@@ -258,10 +259,10 @@ const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_confi
return NULL;
}
-NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
- struct share_context *ctx,
- int *count,
- const char ***names)
+static NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
+ struct share_context *ctx,
+ int *count,
+ const char ***names)
{
int i;
int num_services;
@@ -276,7 +277,7 @@ NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
}
for (i = 0; i < num_services; i++) {
- n[i] = talloc_strdup(n, lp_servicename(i));
+ n[i] = talloc_strdup(n, lp_servicename(lp_servicebynum(i)));
if (!n[i]) {
DEBUG(0,("ERROR: Out of memory!\n"));
talloc_free(n);
@@ -290,24 +291,17 @@ NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
-NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
- struct share_context *ctx,
- const char *name,
- struct share_config **scfg)
+static NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
+ struct share_context *ctx,
+ const char *name,
+ struct share_config **scfg)
{
- int i, snum;
struct share_config *s;
- struct sclassic_snum *scnum;
+ struct service *service;
- snum = -1;
- for (i = 0; i < lp_numservices(); i++) {
- if (strcasecmp_m(name, lp_servicename(i)) == 0) {
- snum = i;
- break;
- }
- }
+ service = lp_service(name);
- if (snum < 0) {
+ if (service == NULL) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
@@ -317,22 +311,14 @@ NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- s->name = talloc_strdup(s, lp_servicename(snum));
+ s->name = talloc_strdup(s, lp_servicename(service));
if (!s->name) {
DEBUG(0,("ERROR: Out of memory!\n"));
talloc_free(s);
return NT_STATUS_NO_MEMORY;
}
- scnum = talloc(s, struct sclassic_snum);
- if (!scnum) {
- DEBUG(0,("ERROR: Out of memory!\n"));
- talloc_free(s);
- return NT_STATUS_NO_MEMORY;
- }
- scnum->snum = snum;
-
- s->opaque = (void *)scnum;
+ s->opaque = (void *)service;
s->ctx = ctx;
*scfg = s;