summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-06-20 14:14:01 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-06-20 14:14:01 +0200
commit7a064b9960ab3cfb4ef76a939da7670aa34519a6 (patch)
tree32c0c865f6389bf93145d80a4d59568a133e2280 /source4/param
parenta2540fb3cbf8f288b106b03589d097212629b386 (diff)
downloadsamba-7a064b9960ab3cfb4ef76a939da7670aa34519a6.tar.gz
samba-7a064b9960ab3cfb4ef76a939da7670aa34519a6.tar.bz2
samba-7a064b9960ab3cfb4ef76a939da7670aa34519a6.zip
pyparam: Support Loadparm.get(p, "global")
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/pyparam.c104
1 files changed, 52 insertions, 52 deletions
diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c
index d09cfb84dd..53f19f6098 100644
--- a/source4/param/pyparam.c
+++ b/source4/param/pyparam.c
@@ -42,63 +42,63 @@ PyObject *PyLoadparmService_FromService(struct loadparm_service *service)
static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const char *service_name, const char *param_name)
{
- struct parm_struct *parm = NULL;
- void *parm_ptr = NULL;
- int i;
+ struct parm_struct *parm = NULL;
+ void *parm_ptr = NULL;
+ int i;
- if (service_name != NULL) {
- struct loadparm_service *service;
- /* its a share parameter */
- service = lp_service(lp_ctx, service_name);
- if (service == NULL) {
- return NULL;
- }
- if (strchr(param_name, ':')) {
- /* its a parametric option on a share */
- const char *type = talloc_strndup(lp_ctx,
- param_name,
- strcspn(param_name, ":"));
- const char *option = strchr(param_name, ':') + 1;
- const char *value;
- if (type == NULL || option == NULL) {
- return NULL;
- }
- value = lp_get_parametric(lp_ctx, service, type, option);
- if (value == NULL) {
- return NULL;
- }
- return PyString_FromString(value);
- }
+ if (service_name != NULL && !strwicmp(service_name, GLOBAL_NAME) &&
+ !strwicmp(service_name, GLOBAL_NAME2)) {
+ struct loadparm_service *service;
+ /* its a share parameter */
+ service = lp_service(lp_ctx, service_name);
+ if (service == NULL) {
+ return NULL;
+ }
+ if (strchr(param_name, ':')) {
+ /* its a parametric option on a share */
+ const char *type = talloc_strndup(lp_ctx, param_name,
+ strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return NULL;
+ }
+ value = lp_get_parametric(lp_ctx, service, type, option);
+ if (value == NULL) {
+ return NULL;
+ }
+ return PyString_FromString(value);
+ }
- parm = lp_parm_struct(param_name);
- if (parm == NULL || parm->pclass == P_GLOBAL) {
- return NULL;
- }
- parm_ptr = lp_parm_ptr(lp_ctx, service, parm);
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL || parm->pclass == P_GLOBAL) {
+ return NULL;
+ }
+ parm_ptr = lp_parm_ptr(lp_ctx, service, parm);
} else if (strchr(param_name, ':')) {
- /* its a global parametric option */
- const char *type = talloc_strndup(lp_ctx,
- param_name, strcspn(param_name, ":"));
- const char *option = strchr(param_name, ':') + 1;
- const char *value;
- if (type == NULL || option == NULL) {
- return NULL;
- }
- value = lp_get_parametric(lp_ctx, NULL, type, option);
- if (value == NULL)
- return NULL;
- return PyString_FromString(value);
- } else {
- /* its a global parameter */
- parm = lp_parm_struct(param_name);
- if (parm == NULL) {
- return NULL;
+ /* its a global parametric option */
+ const char *type = talloc_strndup(lp_ctx,
+ param_name, strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return NULL;
+ }
+ value = lp_get_parametric(lp_ctx, NULL, type, option);
+ if (value == NULL)
+ return NULL;
+ return PyString_FromString(value);
+ } else {
+ /* its a global parameter */
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL) {
+ return NULL;
+ }
+ parm_ptr = lp_parm_ptr(lp_ctx, NULL, parm);
}
- parm_ptr = lp_parm_ptr(lp_ctx, NULL, parm);
- }
- if (parm == NULL || parm_ptr == NULL) {
- return NULL;
+ if (parm == NULL || parm_ptr == NULL) {
+ return NULL;
}
/* construct and return the right type of python object */