Rev 12124: Get rid of a couple more references to global_params. in file:///home/jelmer/bzr.samba/SAMBA_4_0/

Jelmer Vernooij jelmer at samba.org
Wed May 9 10:47:03 GMT 2007


At file:///home/jelmer/bzr.samba/SAMBA_4_0/

------------------------------------------------------------
revno: 12124
revision-id: jelmer at samba.org-20070509104652-bkzgo0ludqq6ycj2
parent: jelmer at samba.org-20070509011150-9opq848pjvql0065
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: SAMBA_4_0
timestamp: Wed 2007-05-09 12:46:52 +0200
message:
  Get rid of a couple more references to global_params.
modified:
  source/param/loadparm.c        svn-v2:2 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-trunk-source%2fparam%2floadparm.c
=== modified file 'source/param/loadparm.c'
--- a/source/param/loadparm.c	2007-05-09 01:11:50 +0000
+++ b/source/param/loadparm.c	2007-05-09 10:46:52 +0000
@@ -10,6 +10,7 @@
    Copyright (C) Stefan (metze) Metzmacher 2002
    Copyright (C) Jim McDonough (jmcd at us.ibm.com)  2003.
    Copyright (C) James Myers 2003 <myersjj at samba.org>
+   Copyright (C) Jelmer Vernooij 2007 <jelmer at samba.org>
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -64,13 +65,11 @@
 #include "lib/util/dlinklist.h"
 #include "param/loadparm.h"
 
-static BOOL bLoaded = false;
-
 #define standard_sub_basic(str,len)
 
 /* some helpful bits */
-#define LP_SNUM_OK(i) (((i) >= 0) && ((i) < global_params.iNumServices) && global_params.ServicePtrs[(i)]->valid)
-#define VALID(i) global_params.ServicePtrs[i]->valid
+#define LP_SNUM_OK(ctx, i) (((i) >= 0) && ((i) < (ctx)->iNumServices) && (ctx)->ServicePtrs[(i)]->valid)
+#define VALID(ctx, i) ctx->ServicePtrs[i]->valid
 
 static BOOL do_parameter_var(struct loadparm_context *, 
 							 const char *pszParmName, const char *fmt, ...);
@@ -103,7 +102,6 @@
 	char *szPidDir;
 	char *szSetupDir;
 	char *szServerString;
-	char *szAutoServices;
 	char *szPasswdChat;
 	char *szConfigFile;
 	char *szShareBackend;
@@ -255,15 +253,15 @@
 	True,			/* bAvailable */
 	True,			/* bBrowseable */
 	True,			/* bRead_only */
-	False,			/* bPrint_ok */
-	False,			/* bMap_system */
-	False,			/* bMap_hidden */
+	false,			/* bPrint_ok */
+	false,			/* bMap_system */
+	false,			/* bMap_hidden */
 	True,			/* bMap_archive */
 	True,			/* bStrictLocking */
 	NULL,			/* copymap */
-	False,			/* bMSDfsRoot */
-	False,			/* bStrictSync */
-	False,			/* bCIFileSystem */
+	false,			/* bMSDfsRoot */
+	false,			/* bStrictSync */
+	false,			/* bCIFileSystem */
 	NULL,			/* Parametric options */
 
 	""			/* dummy */
@@ -276,11 +274,20 @@
 struct loadparm_context {
 	int iNumServices;
 	service **ServicePtrs;
+	
+	/* Files used by this loadparm context */
+	struct file_lists {
+		struct file_lists *next;
+		char *name;
+		char *subfname;
+		time_t modtime;
+	} *file_lists;
 };
 
 struct loadparm_context global_params = {
 	.iNumServices = 0,
 	.ServicePtrs = NULL,
+	.file_lists = NULL,
 };
 
 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
@@ -539,8 +546,6 @@
 	
 	{"config file", P_STRING, P_GLOBAL, GLOBALS_OFFSET(szConfigFile), NULL, NULL, FLAG_HIDE},
 	{"share backend", P_STRING, P_GLOBAL, GLOBALS_OFFSET(szShareBackend), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
-	{"preload", P_STRING, P_GLOBAL, GLOBALS_OFFSET(szAutoServices), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
-	{"auto services", P_STRING, P_GLOBAL, GLOBALS_OFFSET(szAutoServices), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
 	{"lock dir", P_STRING, P_GLOBAL, GLOBALS_OFFSET(szLockDir), NULL, NULL, FLAG_HIDE}, 
 	{"lock directory", P_STRING, P_GLOBAL, GLOBALS_OFFSET(szLockDir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
 	{"modules dir", P_STRING, P_GLOBAL, GLOBALS_OFFSET(szModulesDir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
@@ -815,19 +820,19 @@
  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) && global_params.ServicePtrs[(i)]->val) ? global_params.ServicePtrs[(i)]->val : sDefault.val));}
+ const char *fn_name(int i) {return(lp_string((LP_SNUM_OK(&global_params, i) && global_params.ServicePtrs[(i)]->val) ? global_params.ServicePtrs[(i)]->val : sDefault.val));}
 #define FN_LOCAL_CONST_STRING(fn_name,val) \
- const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && global_params.ServicePtrs[(i)]->val) ? global_params.ServicePtrs[(i)]->val : sDefault.val);}
+ const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(&global_params, i) && global_params.ServicePtrs[(i)]->val) ? global_params.ServicePtrs[(i)]->val : sDefault.val);}
 #define FN_LOCAL_LIST(fn_name,val) \
- const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? global_params.ServicePtrs[(i)]->val : sDefault.val);}
+ const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(&global_params, i)? global_params.ServicePtrs[(i)]->val : sDefault.val);}
 #define FN_LOCAL_BOOL(fn_name,val) \
- BOOL fn_name(int i) {return(LP_SNUM_OK(i)? global_params.ServicePtrs[(i)]->val : sDefault.val);}
+ BOOL fn_name(int i) {return(LP_SNUM_OK(&global_params, i)? global_params.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)? global_params.ServicePtrs[(i)]->val : sDefault.val);}
 #endif
 #define FN_LOCAL_INTEGER(fn_name,val) \
- int fn_name(int i) {return(LP_SNUM_OK(i)? global_params.ServicePtrs[(i)]->val : sDefault.val);}
+ int fn_name(int i) {return(LP_SNUM_OK(&global_params, i)? global_params.ServicePtrs[(i)]->val : sDefault.val);}
 
 _PUBLIC_ FN_GLOBAL_INTEGER(lp_server_role, &Globals.server_role)
 _PUBLIC_ FN_GLOBAL_LIST(lp_smb_ports, &Globals.smb_ports)
@@ -867,7 +872,6 @@
 _PUBLIC_ FN_GLOBAL_LIST(lp_dcerpc_endpoint_servers, &Globals.dcerpc_ep_servers)
 _PUBLIC_ FN_GLOBAL_LIST(lp_server_services, &Globals.server_services)
 _PUBLIC_ FN_GLOBAL_STRING(lp_ntptr_providor, &Globals.ntptr_providor)
-_PUBLIC_ FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
 _PUBLIC_ FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
 _PUBLIC_ FN_GLOBAL_LIST(lp_passwordserver, &Globals.szPasswordServers)
 _PUBLIC_ FN_GLOBAL_LIST(lp_name_resolve_order, &Globals.szNameResolveOrder)
@@ -1454,7 +1458,7 @@
 	int iService;
 
 	for (iService = ctx->iNumServices - 1; iService >= 0; iService--)
-		if (VALID(iService) &&
+		if (VALID(ctx, iService) &&
 		    strwicmp(ctx->ServicePtrs[iService]->szService, pszServiceName) == 0) {
 			if (pserviceDest != NULL)
 				copy_service(pserviceDest, ctx->ServicePtrs[iService], NULL);
@@ -1588,21 +1592,15 @@
 	return (bRetval);
 }
 
-static struct file_lists {
-	struct file_lists *next;
-	char *name;
-	char *subfname;
-	time_t modtime;
-} *file_lists = NULL;
-
 /*******************************************************************
  Keep a linked list of all config files so we know when one has changed 
  it's date and needs to be reloaded.
 ********************************************************************/
 
-static void add_to_file_list(const char *fname, const char *subfname)
+static void add_to_file_list(struct loadparm_context *ctx,
+							 const char *fname, const char *subfname)
 {
-	struct file_lists *f = file_lists;
+	struct file_lists *f = ctx->file_lists;
 
 	while (f) {
 		if (f->name && !strcmp(f->name, fname))
@@ -1614,7 +1612,7 @@
 		f = malloc_p(struct file_lists);
 		if (!f)
 			return;
-		f->next = file_lists;
+		f->next = ctx->file_lists;
 		f->name = strdup(fname);
 		if (!f->name) {
 			SAFE_FREE(f);
@@ -1625,7 +1623,7 @@
 			SAFE_FREE(f);
 			return;
 		}
-		file_lists = f;
+		ctx->file_lists = f;
 		f->modtime = file_modtime(subfname);
 	} else {
 		time_t t = file_modtime(subfname);
@@ -1638,12 +1636,12 @@
  Check if a config file has changed date.
 ********************************************************************/
 
-BOOL lp_file_list_changed(void)
+BOOL lp_file_list_changed(struct loadparm_context *ctx)
 {
-	struct file_lists *f = file_lists;
+	struct file_lists *f;
 	DEBUG(6, ("lp_file_list_changed()\n"));
 
-	while (f) {
+	for (f = ctx->file_lists; f; f = f->next) {
 		pstring n2;
 		time_t mod_time;
 
@@ -1662,11 +1660,10 @@
 			f->modtime = mod_time;
 			SAFE_FREE(f->subfname);
 			f->subfname = strdup(n2);
-			return (True);
+			return true;
 		}
-		f = f->next;
 	}
-	return (False);
+	return false;
 }
 
 /***************************************************************************
@@ -1681,7 +1678,7 @@
 
 	standard_sub_basic(fname,sizeof(fname));
 
-	add_to_file_list(pszParmValue, fname);
+	add_to_file_list(ctx, pszParmValue, fname);
 
 	string_set(ptr, fname);
 
@@ -1727,14 +1724,14 @@
 	}
 
 	free_service(&serviceTemp);
-	return (bRetval);
+	return bRetval;
 }
 
 /***************************************************************************
  Initialise a copymap.
 ***************************************************************************/
 
-static void init_copymap(service * pservice)
+static void init_copymap(service *pservice)
 {
 	int i;
 	SAFE_FREE(pservice->copymap);
@@ -1748,18 +1745,6 @@
 			pservice->copymap[i] = true;
 }
 
-#if 0 /* not used anywhere */
-/***************************************************************************
- Return the local pointer to a parameter given the service number and the 
- pointer into the default structure.
-***************************************************************************/
-
-void *lp_local_ptr(int snum, void *ptr)
-{
-	return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
-}
-#endif
-
 /***************************************************************************
  Process a parametric option
 ***************************************************************************/
@@ -2219,7 +2204,7 @@
 static BOOL is_default(int i)
 {
 	if (!defaults_saved)
-		return False;
+		return false;
 	switch (parm_table[i].type) {
 		case P_LIST:
 			return str_list_equal((const char **)parm_table[i].def.lvalue, 
@@ -2239,7 +2224,7 @@
 		case P_SEP:
 			break;
 	}
-	return False;
+	return false;
 }
 
 /***************************************************************************
@@ -2327,7 +2312,7 @@
 	
 	parm = lp_parm_struct(parm_name);
 	if (!parm) {
-		return False;
+		return false;
 	}
 	
 	if (isGlobal)
@@ -2408,25 +2393,7 @@
 
 BOOL lp_snum_ok(struct loadparm_context *ctx, int iService)
 {
-	return (LP_SNUM_OK(iService) && ctx->ServicePtrs[iService]->bAvailable);
-}
-
-/***************************************************************************
- Auto-load some home services.
-***************************************************************************/
-
-static void lp_add_auto_services(const char *str)
-{
-	return;
-}
-
-/***************************************************************************
- Have we loaded a services file yet?
-***************************************************************************/
-
-BOOL lp_loaded(void)
-{
-	return (bLoaded);
+	return (LP_SNUM_OK(ctx, iService) && ctx->ServicePtrs[iService]->bAvailable);
 }
 
 /***************************************************************************
@@ -2439,7 +2406,7 @@
 {
 	int i;
 	for (i = 0; i < global_params.iNumServices; i++) {
-		if (!VALID(i))
+		if (!VALID(ctx, i))
 			continue;
 
 		if (!snumused || !snumused(smb, i)) {
@@ -2455,7 +2422,7 @@
 
 void lp_killservice(struct loadparm_context *ctx, int iServiceIn)
 {
-	if (VALID(iServiceIn)) {
+	if (VALID(ctx, iServiceIn)) {
 		ctx->ServicePtrs[iServiceIn]->valid = false;
 		free_service(ctx->ServicePtrs[iServiceIn]);
 	}
@@ -2495,7 +2462,7 @@
 	standard_sub_basic(n2,sizeof(n2));
 	DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
 	
-	add_to_file_list(lp_configfile(), n2);
+	add_to_file_list(ctx, lp_configfile(), n2);
 
 	/* We get sections first, so have to start 'behind' to make up */
 	iServiceIndex = -1;
@@ -2507,13 +2474,9 @@
 		if (iServiceIndex >= 0)
 			bRetval = service_ok(ctx, iServiceIndex);
 
-	lp_add_auto_services(lp_auto_services());
-
 	lp_add_hidden(ctx, "IPC$", "IPC");
 	lp_add_hidden(ctx, "ADMIN$", "DISK");
 
-	bLoaded = true;
-
 	if (!Globals.szWINSservers && Globals.bWINSsupport) {
 		lp_do_parameter(ctx, -1, "wins server", "127.0.0.1");
 	}
@@ -2568,7 +2531,7 @@
 void lp_dump_one(struct loadparm_context *ctx, 
 				 FILE * f, BOOL show_defaults, int snum)
 {
-	if (VALID(snum)) {
+	if (VALID(ctx, snum)) {
 		if (ctx->ServicePtrs[snum]->szService[0] == '\0')
 			return;
 		dump_a_service(ctx->ServicePtrs[snum], f);
@@ -2589,7 +2552,7 @@
  
  
 	for (iService = ctx->iNumServices - 1; iService >= 0; iService--) {
-		if (VALID(iService) && ctx->ServicePtrs[iService]->szService) {
+		if (VALID(ctx, iService) && ctx->ServicePtrs[iService]->szService) {
 			/*
 			 * The substitution here is used to support %U is
 			 * service names
@@ -2688,7 +2651,7 @@
 
 int lp_maxprintjobs(struct loadparm_context *ctx, int snum)
 {
-	int maxjobs = LP_SNUM_OK(snum) ? ctx->ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
+	int maxjobs = LP_SNUM_OK(ctx, snum) ? ctx->ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
 	if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
 		maxjobs = PRINT_MAX_JOBID - 1;
 



More information about the samba-cvs mailing list