svn commit: samba r25379 - in branches/SAMBA_4_0: . source/param
source/scripting/ejs source/utils
jelmer at samba.org
jelmer at samba.org
Thu Sep 27 19:49:54 GMT 2007
Author: jelmer
Date: 2007-09-27 19:49:53 +0000 (Thu, 27 Sep 2007)
New Revision: 25379
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25379
Log:
Use loadparm context parameter in a lot more places.
Modified:
branches/SAMBA_4_0/
branches/SAMBA_4_0/source/param/loadparm.c
branches/SAMBA_4_0/source/param/loadparm.h
branches/SAMBA_4_0/source/param/param.h
branches/SAMBA_4_0/source/param/share_classic.c
branches/SAMBA_4_0/source/scripting/ejs/smbcalls_config.c
branches/SAMBA_4_0/source/utils/testparm.c
Changeset:
Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...
Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c 2007-09-27 19:20:37 UTC (rev 25378)
+++ branches/SAMBA_4_0/source/param/loadparm.c 2007-09-27 19:49:53 UTC (rev 25379)
@@ -66,6 +66,8 @@
static bool bLoaded = false;
+struct loadparm_context *global_loadparm = NULL;
+
#define standard_sub_basic talloc_strdup
static bool do_parameter(const char *, const char *, void *);
@@ -2293,6 +2295,8 @@
int i;
char *myname;
+ lp_ctx->bInGlobalSection = true;
+
DEBUG(3, ("Initialising global parameters\n"));
for (i = 0; parm_table[i].label; i++) {
@@ -2458,6 +2462,8 @@
struct param_opt *data;
struct loadparm_context *lp_ctx = &loadparm;
+ global_loadparm = lp_ctx;
+
bRetval = false;
if (lp_ctx->Globals.param_opt != NULL) {
@@ -2509,22 +2515,20 @@
Return the max number of services.
***************************************************************************/
-int lp_numservices(void)
+int lp_numservices(struct loadparm_context *lp_ctx)
{
- return loadparm.iNumServices;
+ return lp_ctx->iNumServices;
}
/***************************************************************************
Display the contents of the services array in human-readable form.
***************************************************************************/
-void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
+void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
+ int maxtoprint)
{
- struct loadparm_context *lp_ctx;
int iService;
- lp_ctx = &loadparm;
-
if (show_defaults)
defaults_saved = false;
@@ -2549,28 +2553,30 @@
}
}
-struct loadparm_service *lp_servicebynum(int snum)
+struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx,
+ int snum)
{
- return loadparm.ServicePtrs[snum];
+ return lp_ctx->ServicePtrs[snum];
}
-struct loadparm_service *lp_service(const char *service_name)
+struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
+ const char *service_name)
{
int iService;
char *serviceName;
- for (iService = loadparm.iNumServices - 1; iService >= 0; iService--) {
- if (loadparm.ServicePtrs[iService] &&
- loadparm.ServicePtrs[iService]->szService) {
+ for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
+ if (lp_ctx->ServicePtrs[iService] &&
+ lp_ctx->ServicePtrs[iService]->szService) {
/*
* The substitution here is used to support %U is
* service names
*/
serviceName = standard_sub_basic(
- loadparm.ServicePtrs[iService],
- loadparm.ServicePtrs[iService]->szService);
+ lp_ctx->ServicePtrs[iService],
+ lp_ctx->ServicePtrs[iService]->szService);
if (strequal(serviceName, service_name))
- return loadparm.ServicePtrs[iService];
+ return lp_ctx->ServicePtrs[iService];
}
}
Modified: branches/SAMBA_4_0/source/param/loadparm.h
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.h 2007-09-27 19:20:37 UTC (rev 25378)
+++ branches/SAMBA_4_0/source/param/loadparm.h 2007-09-27 19:49:53 UTC (rev 25379)
@@ -80,4 +80,3 @@
#define HOMES_NAME "homes"
#endif
-
Modified: branches/SAMBA_4_0/source/param/param.h
===================================================================
--- branches/SAMBA_4_0/source/param/param.h 2007-09-27 19:20:37 UTC (rev 25378)
+++ branches/SAMBA_4_0/source/param/param.h 2007-09-27 19:49:53 UTC (rev 25379)
@@ -62,4 +62,6 @@
#include "param/proto.h"
+extern struct loadparm_context *global_loadparm;
+
#endif /* _PARAM_H */
Modified: branches/SAMBA_4_0/source/param/share_classic.c
===================================================================
--- branches/SAMBA_4_0/source/param/share_classic.c 2007-09-27 19:20:37 UTC (rev 25378)
+++ branches/SAMBA_4_0/source/param/share_classic.c 2007-09-27 19:49:53 UTC (rev 25379)
@@ -268,7 +268,7 @@
int num_services;
const char **n;
- num_services = lp_numservices();
+ num_services = lp_numservices(global_loadparm);
n = talloc_array(mem_ctx, const char *, num_services);
if (!n) {
@@ -277,7 +277,7 @@
}
for (i = 0; i < num_services; i++) {
- n[i] = talloc_strdup(n, lp_servicename(lp_servicebynum(i)));
+ n[i] = talloc_strdup(n, lp_servicename(lp_servicebynum(global_loadparm, i)));
if (!n[i]) {
DEBUG(0,("ERROR: Out of memory!\n"));
talloc_free(n);
@@ -299,7 +299,7 @@
struct share_config *s;
struct loadparm_service *service;
- service = lp_service(name);
+ service = lp_service(global_loadparm, name);
if (service == NULL) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_config.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbcalls_config.c 2007-09-27 19:20:37 UTC (rev 25378)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls_config.c 2007-09-27 19:49:53 UTC (rev 25379)
@@ -36,8 +36,8 @@
const char **list = NULL;
if (argc != 0) return -1;
- for (i=0;i<lp_numservices();i++) {
- list = str_list_add(list, lp_servicename(lp_servicebynum(i)));
+ for (i=0;i<lp_numservices(global_loadparm);i++) {
+ list = str_list_add(list, lp_servicename(lp_servicebynum(global_loadparm, i)));
}
talloc_steal(mprMemCtx(), list);
mpr_Return(eid, mprList("services", list));
@@ -89,7 +89,7 @@
if (argc == 2) {
struct loadparm_service *service;
/* its a share parameter */
- service = lp_service(argv[0]);
+ service = lp_service(global_loadparm, argv[0]);
if (service == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
Modified: branches/SAMBA_4_0/source/utils/testparm.c
===================================================================
--- branches/SAMBA_4_0/source/utils/testparm.c 2007-09-27 19:20:37 UTC (rev 25378)
+++ branches/SAMBA_4_0/source/utils/testparm.c 2007-09-27 19:49:53 UTC (rev 25379)
@@ -150,10 +150,10 @@
ret = do_global_checks();
- for (s=0;s<lp_numservices();s++) {
- struct loadparm_service *service = lp_servicebynum(s);
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
if (service != NULL)
- if (strlen(lp_servicename(lp_servicebynum(s))) > 12) {
+ if (strlen(lp_servicename(lp_servicebynum(global_loadparm, s))) > 12) {
fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" );
fprintf(stderr, "These may not be accessible to some older clients.\n" );
fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" );
@@ -161,8 +161,8 @@
}
}
- for (s=0;s<lp_numservices();s++) {
- struct loadparm_service *service = lp_servicebynum(s);
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
if (service != NULL) {
const char **deny_list = lp_hostsdeny(service);
const char **allow_list = lp_hostsallow(service);
@@ -204,7 +204,7 @@
section_name = GLOBAL_NAME;
service = NULL;
} else if ((!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
- (service=lp_service(section_name)) == NULL) {
+ (service=lp_service(global_loadparm, section_name)) == NULL) {
fprintf(stderr,"Unknown section %s\n",
section_name);
return(1);
@@ -215,15 +215,15 @@
ret = !lp_dump_a_parameter(s, parameter_name, stdout, (service == NULL));
}
} else {
- lp_dump(stdout, show_defaults, lp_numservices());
+ lp_dump(global_loadparm, stdout, show_defaults, lp_numservices(global_loadparm));
}
return(ret);
}
if(cname && caddr){
/* this is totally ugly, a real `quick' hack */
- for (s=0;s<lp_numservices();s++) {
- struct loadparm_service *service = lp_servicebynum(s);
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
if (service != NULL) {
if (allow_access(NULL, lp_hostsdeny(NULL), lp_hostsallow(NULL), cname, caddr)
&& allow_access(NULL, lp_hostsdeny(service), lp_hostsallow(service), cname, caddr)) {
More information about the samba-cvs
mailing list