diff options
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/param/loadparm.c | 13 | ||||
-rw-r--r-- | source3/param/loadparm_ctx.c | 4 | ||||
-rw-r--r-- | source4/param/loadparm.c | 28 | ||||
-rw-r--r-- | source4/script/mks3param.pl | 4 |
5 files changed, 49 insertions, 2 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 5d15e4e77a..c3e680d8b6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1577,6 +1577,8 @@ const char *lp_ldap_idmap_suffix(void); struct parm_struct; /* Return a pointer to a service by name. */ struct loadparm_service *lp_service(const char *pszServiceName); +struct loadparm_service *lp_servicebynum(int snum); +struct loadparm_service *lp_default_loadparm_service(void); void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm); void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm); bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 79f1b236ca..1258709856 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -6419,6 +6419,19 @@ struct loadparm_service *lp_service(const char *pszServiceName) return ServicePtrs[iService]; } +struct loadparm_service *lp_servicebynum(int snum) +{ + if (snum = -1 || !LP_SNUM_OK(snum)) { + return NULL; + } + return ServicePtrs[snum]; +} + +struct loadparm_service *lp_default_loadparm_service() +{ + return &sDefault; +} + /*************************************************************************** Copy a service structure to another. diff --git a/source3/param/loadparm_ctx.c b/source3/param/loadparm_ctx.c index 7362279f9b..7c59ca709a 100644 --- a/source3/param/loadparm_ctx.c +++ b/source3/param/loadparm_ctx.c @@ -30,6 +30,10 @@ static const struct loadparm_s3_context s3_fns = .get_parm_struct = lp_get_parameter, .get_parm_ptr = lp_parm_ptr, .get_service = lp_service, + .get_servicebynum = lp_servicebynum, + .get_default_loadparm_service = lp_default_loadparm_service, + .get_numservices = lp_numservices, + .set_cmdline = lp_set_cmdline, .server_role = lp_server_role, diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index 18e2df1c70..b18f8fc429 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -1311,6 +1311,9 @@ struct loadparm_context { struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx) { + if (lp_ctx->s3_fns) { + return lp_ctx->s3_fns->get_default_loadparm_service(); + } return lp_ctx->sDefault; } @@ -1428,6 +1431,9 @@ static struct loadparm_context *global_loadparm_context; return lp_ctx->globals->var_name; \ } +/* Local parameters don't need the ->s3_fns because the struct + * loadparm_service is shared and lpcfg_service() checks the ->s3_fns + * hook */ #define FN_LOCAL_STRING(fn_name,val) \ _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \ struct loadparm_service *sDefault) { \ @@ -2079,6 +2085,10 @@ static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx { int iService; + if (lp_ctx->s3_fns) { + return lp_ctx->s3_fns->get_service(pszServiceName); + } + for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) if (lp_ctx->services[iService] != NULL && strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) { @@ -2724,9 +2734,15 @@ bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx, bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName, const char *pszParmValue) { - int parmnum = map_parameter(pszParmName); + int parmnum; int i; + if (lp_ctx->s3_fns) { + return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue); + } + + parmnum = map_parameter(pszParmName); + while (isspace((unsigned char)*pszParmValue)) pszParmValue++; @@ -3544,6 +3560,10 @@ bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename) int lpcfg_numservices(struct loadparm_context *lp_ctx) { + if (lp_ctx->s3_fns) { + return lp_ctx->s3_fns->get_numservices(); + } + return lp_ctx->iNumServices; } @@ -3579,8 +3599,12 @@ void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *servic } struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx, - int snum) + int snum) { + if (lp_ctx->s3_fns) { + return lp_ctx->s3_fns->get_servicebynum(snum); + } + return lp_ctx->services[snum]; } diff --git a/source4/script/mks3param.pl b/source4/script/mks3param.pl index dee3da192f..761cd6980f 100644 --- a/source4/script/mks3param.pl +++ b/source4/script/mks3param.pl @@ -89,6 +89,10 @@ sub print_header($$) $file->("\tstruct parm_struct * (*get_parm_struct)(const char *param_name);\n"); $file->("\tvoid * (*get_parm_ptr)(struct loadparm_service *service, struct parm_struct *parm);\n"); $file->("\tstruct loadparm_service * (*get_service)(const char *service_name);\n"); + $file->("\tstruct loadparm_service * (*get_default_loadparm_service)(void);\n"); + $file->("\tstruct loadparm_service * (*get_servicebynum)(int snum);\n"); + $file->("\tint (*get_numservices)(void);\n"); + $file->("\tbool (*set_cmdline)(const char *pszParmName, const char *pszParmValue);\n"); } sub print_footer($$) |