summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-25 16:36:23 -0600
committerStefan Metzmacher <metze@samba.org>2007-12-26 11:57:06 -0600
commitcc30cb5e24160d107b67936d71f54645d9b3d23f (patch)
tree7e741cee81c15e47f4d013bb8e05180b207f48ca /source4/param
parent3c22677a8ce1635d7e055f954153dec4c1796b17 (diff)
downloadsamba-cc30cb5e24160d107b67936d71f54645d9b3d23f.tar.gz
samba-cc30cb5e24160d107b67936d71f54645d9b3d23f.tar.bz2
samba-cc30cb5e24160d107b67936d71f54645d9b3d23f.zip
r26592: Finish fixing the samba3dump script.
(This used to be commit 85679f3fc98238f90280f9f10d42550d71eeb918)
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/param.i59
-rw-r--r--source4/param/param.py53
-rw-r--r--source4/param/param_wrap.c194
3 files changed, 306 insertions, 0 deletions
diff --git a/source4/param/param.i b/source4/param/param.i
index 11cda9910a..375c3d0da4 100644
--- a/source4/param/param.i
+++ b/source4/param/param.i
@@ -181,6 +181,7 @@ typedef struct param_context {
struct param_opt *get(const char *name, const char *section_name="global");
const char *get_string(const char *name, const char *section_name="global");
int set_string(const char *param, const char *value, const char *section="global");
+#ifdef SWIGPYTHON
int set(const char *parameter, PyObject *ob, const char *section_name="global")
{
struct param_opt *opt = param_get_add($self, parameter, section_name);
@@ -190,6 +191,11 @@ typedef struct param_context {
return 0;
}
+
+#endif
+
+ struct param_section *first_section() { return $self->sections; }
+ struct param_section *next_section(struct param_section *s) { return s->next; }
int read(const char *fn);
int write(const char *fn);
@@ -200,12 +206,38 @@ typedef struct param_context {
if ret is None:
raise KeyError("No such section %s" % name)
return ret
+
+ class SectionIterator:
+ def __init__(self, param):
+ self.param = param
+ self.key = None
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.key is None:
+ self.key = self.param.first_section()
+ if self.key is None:
+ raise StopIteration
+ return self.key
+ else:
+ self.key = self.param.next_section(self.key)
+ if self.key is None:
+ raise StopIteration
+ return self.key
+
+ def __iter__(self):
+ return self.SectionIterator(self)
}
} param;
%talloctype(param_opt);
typedef struct param_opt {
+ %immutable key;
+ %immutable value;
+ const char *key, *value;
%extend {
#ifdef SWIGPYTHON
const char *__str__() { return $self->value; }
@@ -215,8 +247,12 @@ typedef struct param_opt {
%talloctype(param);
typedef struct param_section {
+ %immutable name;
+ const char *name;
%extend {
struct param_opt *get(const char *name);
+ struct param_opt *first_parameter() { return $self->parameters; }
+ struct param_opt *next_parameter(struct param_opt *s) { return s->next; }
}
%pythoncode {
def __getitem__(self, name):
@@ -224,6 +260,29 @@ typedef struct param_section {
if ret is None:
raise KeyError("No such option %s" % name)
return ret
+
+ class ParamIterator:
+ def __init__(self, section):
+ self.section = section
+ self.key = None
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.key is None:
+ self.key = self.section.first_parameter()
+ if self.key is None:
+ raise StopIteration
+ return self.key
+ else:
+ self.key = self.section.next_parameter(self.key)
+ if self.key is None:
+ raise StopIteration
+ return self.key
+
+ def __iter__(self):
+ return self.ParamIterator(self)
}
} param_section;
diff --git a/source4/param/param.py b/source4/param/param.py
index 291459b9b6..66b51e5d3b 100644
--- a/source4/param/param.py
+++ b/source4/param/param.py
@@ -96,6 +96,29 @@ class ParamFile(object):
raise KeyError("No such section %s" % name)
return ret
+ class SectionIterator:
+ def __init__(self, param):
+ self.param = param
+ self.key = None
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.key is None:
+ self.key = self.param.first_section()
+ if self.key is None:
+ raise StopIteration
+ return self.key
+ else:
+ self.key = self.param.next_section(self.key)
+ if self.key is None:
+ raise StopIteration
+ return self.key
+
+ def __iter__(self):
+ return self.SectionIterator(self)
+
__swig_destroy__ = _param.delete_ParamFile
ParamFile.get_section = new_instancemethod(_param.ParamFile_get_section,None,ParamFile)
ParamFile.add_section = new_instancemethod(_param.ParamFile_add_section,None,ParamFile)
@@ -103,6 +126,8 @@ ParamFile.get = new_instancemethod(_param.ParamFile_get,None,ParamFile)
ParamFile.get_string = new_instancemethod(_param.ParamFile_get_string,None,ParamFile)
ParamFile.set_string = new_instancemethod(_param.ParamFile_set_string,None,ParamFile)
ParamFile.set = new_instancemethod(_param.ParamFile_set,None,ParamFile)
+ParamFile.first_section = new_instancemethod(_param.ParamFile_first_section,None,ParamFile)
+ParamFile.next_section = new_instancemethod(_param.ParamFile_next_section,None,ParamFile)
ParamFile.read = new_instancemethod(_param.ParamFile_read,None,ParamFile)
ParamFile.write = new_instancemethod(_param.ParamFile_write,None,ParamFile)
ParamFile_swigregister = _param.ParamFile_swigregister
@@ -112,6 +137,8 @@ class param_opt(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
+ key = _swig_property(_param.param_opt_key_get)
+ value = _swig_property(_param.param_opt_value_get)
__swig_destroy__ = _param.delete_param_opt
param_opt.__str__ = new_instancemethod(_param.param_opt___str__,None,param_opt)
param_opt_swigregister = _param.param_opt_swigregister
@@ -120,16 +147,42 @@ param_opt_swigregister(param_opt)
class param_section(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
+ name = _swig_property(_param.param_section_name_get)
def __getitem__(self, name):
ret = self.get(name)
if ret is None:
raise KeyError("No such option %s" % name)
return ret
+ class ParamIterator:
+ def __init__(self, section):
+ self.section = section
+ self.key = None
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.key is None:
+ self.key = self.section.first_parameter()
+ if self.key is None:
+ raise StopIteration
+ return self.key
+ else:
+ self.key = self.section.next_parameter(self.key)
+ if self.key is None:
+ raise StopIteration
+ return self.key
+
+ def __iter__(self):
+ return self.ParamIterator(self)
+
def __init__(self, *args, **kwargs):
_param.param_section_swiginit(self,_param.new_param_section(*args, **kwargs))
__swig_destroy__ = _param.delete_param_section
param_section.get = new_instancemethod(_param.param_section_get,None,param_section)
+param_section.first_parameter = new_instancemethod(_param.param_section_first_parameter,None,param_section)
+param_section.next_parameter = new_instancemethod(_param.param_section_next_parameter,None,param_section)
param_section_swigregister = _param.param_section_swigregister
param_section_swigregister(param_section)
diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c
index 49c986aeb7..5f7ff880ff 100644
--- a/source4/param/param_wrap.c
+++ b/source4/param/param_wrap.c
@@ -2751,9 +2751,13 @@ SWIGINTERN int param_set(param *self,char const *parameter,PyObject *ob,char con
return 0;
}
+SWIGINTERN struct param_section *param_first_section(param *self){ return self->sections; }
+SWIGINTERN struct param_section *param_next_section(param *self,struct param_section *s){ return s->next; }
SWIGINTERN void delete_param(param *self){ talloc_free(self); }
SWIGINTERN char const *param_opt___str__(param_opt *self){ return self->value; }
SWIGINTERN void delete_param_opt(param_opt *self){ talloc_free(self); }
+SWIGINTERN struct param_opt *param_section_first_parameter(param_section *self){ return self->parameters; }
+SWIGINTERN struct param_opt *param_section_next_parameter(param_section *self,struct param_opt *s){ return s->next; }
#ifdef __cplusplus
extern "C" {
#endif
@@ -3570,6 +3574,63 @@ fail:
}
+SWIGINTERN PyObject *_wrap_ParamFile_first_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ struct param_section *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_first_section" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ result = (struct param_section *)param_first_section(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_next_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ struct param_section *arg2 = (struct param_section *) 0 ;
+ struct param_section *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "s", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_next_section",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_next_section" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_next_section" "', argument " "2"" of type '" "struct param_section *""'");
+ }
+ arg2 = (struct param_section *)(argp2);
+ result = (struct param_section *)param_next_section(arg1,arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_ParamFile_read(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
param *arg1 = (param *) 0 ;
@@ -3678,6 +3739,52 @@ SWIGINTERN PyObject *ParamFile_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject
return SWIG_Python_InitShadowInstance(args);
}
+SWIGINTERN PyObject *_wrap_param_opt_key_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_opt *arg1 = (param_opt *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_opt, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_opt_key_get" "', argument " "1"" of type '" "param_opt *""'");
+ }
+ arg1 = (param_opt *)(argp1);
+ result = (char *) ((arg1)->key);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_param_opt_value_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_opt *arg1 = (param_opt *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_opt, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_opt_value_get" "', argument " "1"" of type '" "param_opt *""'");
+ }
+ arg1 = (param_opt *)(argp1);
+ result = (char *) ((arg1)->value);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_param_opt___str__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
param_opt *arg1 = (param_opt *) 0 ;
@@ -3731,6 +3838,29 @@ SWIGINTERN PyObject *param_opt_swigregister(PyObject *SWIGUNUSEDPARM(self), PyOb
return SWIG_Py_Void();
}
+SWIGINTERN PyObject *_wrap_param_section_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_section *arg1 = (param_section *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_section_name_get" "', argument " "1"" of type '" "param_section *""'");
+ }
+ arg1 = (param_section *)(argp1);
+ result = (char *) ((arg1)->name);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_param_section_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
param_section *arg1 = (param_section *) 0 ;
@@ -3768,6 +3898,63 @@ fail:
}
+SWIGINTERN PyObject *_wrap_param_section_first_parameter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_section *arg1 = (param_section *) 0 ;
+ struct param_opt *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_section_first_parameter" "', argument " "1"" of type '" "param_section *""'");
+ }
+ arg1 = (param_section *)(argp1);
+ result = (struct param_opt *)param_section_first_parameter(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_opt, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_param_section_next_parameter(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param_section *arg1 = (param_section *) 0 ;
+ struct param_opt *arg2 = (struct param_opt *) 0 ;
+ struct param_opt *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "s", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:param_section_next_parameter",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_section_next_parameter" "', argument " "1"" of type '" "param_section *""'");
+ }
+ arg1 = (param_section *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_param_opt, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "param_section_next_parameter" "', argument " "2"" of type '" "struct param_opt *""'");
+ }
+ arg2 = (struct param_opt *)(argp2);
+ result = (struct param_opt *)param_section_next_parameter(arg1,arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_opt, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_new_param_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
param_section *result = 0 ;
@@ -3863,15 +4050,22 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"ParamFile_get_string", (PyCFunction) _wrap_ParamFile_get_string, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_set_string", (PyCFunction) _wrap_ParamFile_set_string, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_set", (PyCFunction) _wrap_ParamFile_set, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_first_section", (PyCFunction)_wrap_ParamFile_first_section, METH_O, NULL},
+ { (char *)"ParamFile_next_section", (PyCFunction) _wrap_ParamFile_next_section, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_write", (PyCFunction) _wrap_ParamFile_write, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"delete_ParamFile", (PyCFunction)_wrap_delete_ParamFile, METH_O, NULL},
{ (char *)"ParamFile_swigregister", ParamFile_swigregister, METH_VARARGS, NULL},
{ (char *)"ParamFile_swiginit", ParamFile_swiginit, METH_VARARGS, NULL},
+ { (char *)"param_opt_key_get", (PyCFunction)_wrap_param_opt_key_get, METH_O, NULL},
+ { (char *)"param_opt_value_get", (PyCFunction)_wrap_param_opt_value_get, METH_O, NULL},
{ (char *)"param_opt___str__", (PyCFunction)_wrap_param_opt___str__, METH_O, NULL},
{ (char *)"delete_param_opt", (PyCFunction)_wrap_delete_param_opt, METH_O, NULL},
{ (char *)"param_opt_swigregister", param_opt_swigregister, METH_VARARGS, NULL},
+ { (char *)"param_section_name_get", (PyCFunction)_wrap_param_section_name_get, METH_O, NULL},
{ (char *)"param_section_get", (PyCFunction) _wrap_param_section_get, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"param_section_first_parameter", (PyCFunction)_wrap_param_section_first_parameter, METH_O, NULL},
+ { (char *)"param_section_next_parameter", (PyCFunction) _wrap_param_section_next_parameter, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"new_param_section", (PyCFunction)_wrap_new_param_section, METH_NOARGS, NULL},
{ (char *)"delete_param_section", (PyCFunction)_wrap_delete_param_section, METH_O, NULL},
{ (char *)"param_section_swigregister", param_section_swigregister, METH_VARARGS, NULL},