1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

s3-param Use .offset rather than .ptr when defining parameters

This change has a number of purposes:

 * It removes the fancy logic around pointers into sDefault for all
   per-share parameters.  Instead, this is always expressed as an
   offset, rather than implicitly via PTR_DIFF macros.

 * It makes struct parm_struct almost identical to that as used in
   source4/param.  This will very shortly allow the loadparm tables
   and most of the 'special' helper functions to be placed in common.

Andrew Bartlett

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Wed Jun 29 05:50:46 CEST 2011 on sn-devel-104
This commit is contained in:
Andrew Bartlett 2011-06-29 10:49:35 +10:00
parent 573109d346
commit 21756b7c7d
2 changed files with 6 additions and 7 deletions

View File

@ -731,7 +731,7 @@ struct parm_struct {
const char *label;
parm_type type;
parm_class p_class;
void *ptr;
offset_t offset;
bool (*special)(int snum, const char *, char **);
const struct enum_list *enum_list;
unsigned flags;

View File

@ -930,9 +930,8 @@ static const struct enum_list enum_kerberos_method[] = {
* name first, and all synonyms must follow it with the FLAG_HIDE attribute.
*/
#define GLOBAL_VAR(name) &Globals.name
#define LOCAL_VAR(name) &sDefault.name
#define offset ptr
#define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
#define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
static struct parm_struct parm_table[] = {
{N_("Base Options"), P_SEP, P_SEPARATOR},
@ -7755,12 +7754,12 @@ void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
{
if (service == NULL) {
if (parm->p_class == P_LOCAL)
return parm->ptr;
return (void *)(((char *)&sDefault)+parm->offset);
else if (parm->p_class == P_GLOBAL)
return parm->ptr;
return (void *)(((char *)&Globals)+parm->offset);
else return NULL;
} else {
return (void *)(((char *)service) + PTR_DIFF(parm->ptr, &sDefault));
return (void *)(((char *)service) + parm->offset);
}
}