mirror of
https://github.com/samba-team/samba.git
synced 2025-07-30 19:42:05 +03:00
param: add FN_{GLOBAL,LOCAL}_SUBSTITUTED_STRING support
Pair-Programmed-With: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
@ -167,6 +167,15 @@ static struct loadparm_context *global_loadparm_context;
|
||||
return lp_ctx->globals->var_name ? talloc_strdup(ctx, lpcfg_string(lp_ctx->globals->var_name)) : talloc_strdup(ctx, ""); \
|
||||
}
|
||||
|
||||
#define FN_GLOBAL_SUBSTITUTED_STRING(fn_name,var_name) \
|
||||
_PUBLIC_ char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx, \
|
||||
const struct loadparm_substitution *lp_sub, TALLOC_CTX *mem_ctx) \
|
||||
{ \
|
||||
if (lp_ctx == NULL) return NULL; \
|
||||
return lpcfg_substituted_string(mem_ctx, lp_sub, \
|
||||
lp_ctx->globals->var_name ? 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; \
|
||||
@ -199,6 +208,9 @@ static struct loadparm_context *global_loadparm_context;
|
||||
return(talloc_strdup(ctx, lpcfg_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)))); \
|
||||
}
|
||||
|
||||
/* just a copy for now */
|
||||
#define FN_LOCAL_SUBSTITUTED_STRING(fn_name,val) FN_LOCAL_STRING(fn_name,val)
|
||||
|
||||
#define FN_LOCAL_CONST_STRING(fn_name,val) \
|
||||
_PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
|
||||
struct loadparm_service *sDefault) { \
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define _PARAM_H
|
||||
|
||||
struct loadparm_s3_helpers;
|
||||
struct loadparm_substitution;
|
||||
|
||||
struct parmlist_entry;
|
||||
|
||||
|
@ -75,6 +75,7 @@ def iterate_all(path):
|
||||
continue
|
||||
|
||||
constant = parameter.attrib.get("constant")
|
||||
substitution = parameter.attrib.get("substitution")
|
||||
parm = parameter.attrib.get("parm")
|
||||
if name is None or param_type is None or context is None:
|
||||
raise Exception("Error parsing parameter: " + name)
|
||||
@ -89,6 +90,7 @@ def iterate_all(path):
|
||||
'context': context,
|
||||
'function': func,
|
||||
'constant': (constant == '1'),
|
||||
'substitution': (substitution == '1'),
|
||||
'parm': (parm == '1'),
|
||||
'synonym' : synonym,
|
||||
'generated' : generated,
|
||||
@ -135,6 +137,8 @@ def generate_functions(path_in, path_out):
|
||||
output_string += temp
|
||||
if parameter['constant']:
|
||||
output_string += "_CONST"
|
||||
if parameter['substitution']:
|
||||
output_string += "_SUBSTITUTED"
|
||||
if parameter['parm']:
|
||||
output_string += "_PARM"
|
||||
temp = param_type_dict.get(parameter['type'])
|
||||
@ -192,7 +196,14 @@ def make_s3_param_proto(path_in, path_out):
|
||||
else:
|
||||
param = "int"
|
||||
|
||||
if parameter['type'] == 'string' and not parameter['constant']:
|
||||
if parameter['type'] == 'string' and parameter['substitution']:
|
||||
if parameter['context'] == 'G':
|
||||
output_string += '(TALLOC_CTX *ctx, const struct loadparm_substitution *lp_sub);\n'
|
||||
elif parameter['context'] == 'S':
|
||||
output_string += '(TALLOC_CTX *ctx, const struct loadparm_substitution *lp_sub, %s);\n' % param
|
||||
else:
|
||||
raise Exception(parameter['name'] + " has an invalid param type " + parameter['type'])
|
||||
elif parameter['type'] == 'string' and not parameter['constant']:
|
||||
if parameter['context'] == 'G':
|
||||
output_string += '(TALLOC_CTX *ctx);\n'
|
||||
elif parameter['context'] == 'S':
|
||||
@ -237,7 +248,14 @@ def make_lib_proto(path_in, path_out):
|
||||
|
||||
output_string += "lpcfg_%s" % parameter['function']
|
||||
|
||||
if parameter['type'] == 'string' and not parameter['constant']:
|
||||
if parameter['type'] == 'string' and parameter['substitution']:
|
||||
if parameter['context'] == 'G':
|
||||
output_string += '(struct loadparm_context *, const struct loadparm_substitution *lp_sub, TALLOC_CTX *ctx);\n'
|
||||
elif parameter['context'] == 'S':
|
||||
output_string += '(struct loadparm_service *, struct loadparm_service *, TALLOC_CTX *ctx);\n'
|
||||
else:
|
||||
raise Exception(parameter['name'] + " has an invalid context " + parameter['context'])
|
||||
elif parameter['type'] == 'string' and not parameter['constant']:
|
||||
if parameter['context'] == 'G':
|
||||
output_string += '(struct loadparm_context *, TALLOC_CTX *ctx);\n'
|
||||
elif parameter['context'] == 'S':
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "lib/util/samba_util.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
struct loadparm_substitution;
|
||||
struct share_params;
|
||||
#include "source3/param/param_proto.h"
|
||||
|
||||
|
@ -1049,6 +1049,9 @@ char *lp_string(TALLOC_CTX *ctx, const char *s)
|
||||
|
||||
#define FN_GLOBAL_STRING(fn_name,ptr) \
|
||||
char *lp_ ## fn_name(TALLOC_CTX *ctx) {return(lp_string((ctx), *(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
|
||||
#define FN_GLOBAL_SUBSTITUTED_STRING(fn_name,ptr) \
|
||||
char *lp_ ## fn_name(TALLOC_CTX *ctx, const struct loadparm_substitution *lp_sub) \
|
||||
{return lpcfg_substituted_string(ctx, lp_sub, *(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : "");}
|
||||
#define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
|
||||
const char *lp_ ## fn_name(void) {return(*(const char * const *)(&Globals.ptr) ? *(const char * const *)(&Globals.ptr) : "");}
|
||||
#define FN_GLOBAL_LIST(fn_name,ptr) \
|
||||
@ -1062,6 +1065,9 @@ char *lp_ ## fn_name(TALLOC_CTX *ctx) {return(lp_string((ctx), *(char **)(&Globa
|
||||
|
||||
#define FN_LOCAL_STRING(fn_name,val) \
|
||||
char *lp_ ## fn_name(TALLOC_CTX *ctx,int i) {return(lp_string((ctx), (LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
|
||||
#define FN_LOCAL_SUBSTITUTED_STRING(fn_name,val) \
|
||||
char *lp_ ## fn_name(TALLOC_CTX *ctx, const struct loadparm_substitution *lp_sub, int i) \
|
||||
{return lpcfg_substituted_string((ctx), lp_sub, (LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
|
||||
#define FN_LOCAL_CONST_STRING(fn_name,val) \
|
||||
const char *lp_ ## fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
|
||||
#define FN_LOCAL_LIST(fn_name,val) \
|
||||
|
Reference in New Issue
Block a user