diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-01 23:22:24 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-06 17:37:51 +1000 |
commit | 1dfc6fa558e7735341a7095aa46e5568a4f56cfe (patch) | |
tree | 80c2474135ebb6eedb8287b2a469e3dd5754a68c /source4/param | |
parent | 521687be0d4bcd6326417696fabdce6506824b99 (diff) | |
download | samba-1dfc6fa558e7735341a7095aa46e5568a4f56cfe.tar.gz samba-1dfc6fa558e7735341a7095aa46e5568a4f56cfe.tar.bz2 samba-1dfc6fa558e7735341a7095aa46e5568a4f56cfe.zip |
s4-param Add hook between Samba3 and Samba4 loadparm systems.
In the top level build, this allows calls to code that requires a
lpcfg_ style loadparm_context, while using the global parameters
loaded from the source3 loadparm code.
Andrew Bartlett
Diffstat (limited to 'source4/param')
-rw-r--r-- | source4/param/loadparm.c | 86 | ||||
-rw-r--r-- | source4/param/param.h | 2 | ||||
-rw-r--r-- | source4/param/wscript_build | 5 |
3 files changed, 81 insertions, 12 deletions
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index d5c82354af..6a173b1afc 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -68,6 +68,7 @@ #include "rpc_server/common/common.h" #include "lib/socket/socket.h" #include "auth/gensec/gensec.h" +#include "s3_param.h" #define standard_sub_basic talloc_strdup @@ -520,6 +521,7 @@ struct loadparm_context { bool refuse_free; bool global; /* Is this the global context, which may set * global variables such as debug level etc? */ + struct loadparm_s3_context *s3_fns; }; @@ -601,32 +603,78 @@ static struct loadparm_context *global_loadparm_context; #define lpcfg_default_service global_loadparm_context->sDefault #define lpcfg_global_service(i) global_loadparm_context->services[i] -#define FN_GLOBAL_STRING(fn_name,var_name) \ - _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : "";} +#define FN_GLOBAL_STRING(fn_name,var_name) \ + _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \ + if (lp_ctx == NULL) return NULL; \ + if (lp_ctx->s3_fns) { \ + SMB_ASSERT(lp_ctx->s3_fns->fn_name); \ + return lp_ctx->s3_fns->fn_name(); \ + } \ + return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \ +} #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \ - _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name ? lp_ctx->globals->var_name : "";} - -#define FN_GLOBAL_LIST(fn_name,var_name) \ - _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name;} + _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\ + if (lp_ctx == NULL) return NULL; \ + if (lp_ctx->s3_fns) { \ + SMB_ASSERT(lp_ctx->s3_fns->fn_name); \ + return lp_ctx->s3_fns->fn_name(); \ + } \ + return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \ + } + +#define FN_GLOBAL_LIST(fn_name,var_name) \ + _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \ + if (lp_ctx == NULL) return NULL; \ + if (lp_ctx->s3_fns) { \ + SMB_ASSERT(lp_ctx->s3_fns->fn_name); \ + return lp_ctx->s3_fns->fn_name(); \ + } \ + return lp_ctx->globals->var_name; \ + } #define FN_GLOBAL_BOOL(fn_name,var_name) \ - _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return false; return lp_ctx->globals->var_name;} + _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\ + if (lp_ctx == NULL) return false; \ + if (lp_ctx->s3_fns) { \ + SMB_ASSERT(lp_ctx->s3_fns->fn_name); \ + return lp_ctx->s3_fns->fn_name(); \ + } \ + return lp_ctx->globals->var_name; \ +} #define FN_GLOBAL_INTEGER(fn_name,var_name) \ - _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {return lp_ctx->globals->var_name;} + _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \ + if (lp_ctx->s3_fns) { \ + SMB_ASSERT(lp_ctx->s3_fns->fn_name); \ + return lp_ctx->s3_fns->fn_name(); \ + } \ + return lp_ctx->globals->var_name; \ + } #define FN_LOCAL_STRING(fn_name,val) \ - _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)));} + _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \ + struct loadparm_service *sDefault) { \ + return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val))); \ + } #define FN_LOCAL_LIST(fn_name,val) \ - _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val);} + _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \ + struct loadparm_service *sDefault) {\ + return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \ + } #define FN_LOCAL_BOOL(fn_name,val) \ - _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);} + _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \ + struct loadparm_service *sDefault) { \ + return((service != NULL)? service->val : sDefault->val); \ + } #define FN_LOCAL_INTEGER(fn_name,val) \ - _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);} + _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \ + struct loadparm_service *sDefault) { \ + return((service != NULL)? service->val : sDefault->val); \ + } FN_GLOBAL_INTEGER(server_role, server_role) FN_GLOBAL_LIST(smb_ports, smb_ports) @@ -2560,6 +2608,20 @@ struct loadparm_context *loadparm_init_global(bool load_default) return global_loadparm_context; } +/** + * Initialise the global parameter structure. + */ +struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx, + struct loadparm_s3_context *s3_fns) +{ + struct loadparm_context *loadparm_context = loadparm_init(mem_ctx); + if (!loadparm_context) { + return NULL; + } + loadparm_context->s3_fns = s3_fns; + return loadparm_context; +} + const char *lpcfg_configfile(struct loadparm_context *lp_ctx) { return lp_ctx->szConfigFile; diff --git a/source4/param/param.h b/source4/param/param.h index 79a1bff2c7..f8ce15d7b6 100644 --- a/source4/param/param.h +++ b/source4/param/param.h @@ -20,6 +20,8 @@ #ifndef _PARAM_H /* _PARAM_H */ #define _PARAM_H +struct loadparm_s3_context; + struct parmlist_entry; struct param_context { diff --git a/source4/param/wscript_build b/source4/param/wscript_build index 72674e5574..98e838133e 100644 --- a/source4/param/wscript_build +++ b/source4/param/wscript_build @@ -1,5 +1,10 @@ #!/usr/bin/env python +bld.SAMBA_GENERATOR('s3_param_h', + source= 'loadparm.c ../script/mks3param.pl', + target='s3_param.h', + rule='${PERL} ${SRC[1].abspath(env)} ${SRC[0].abspath(env)} --file ${TGT}') + bld.SAMBA_LIBRARY('samba-hostconfig', source='loadparm.c generic.c util.c', pc_files='samba-hostconfig.pc', |