summaryrefslogtreecommitdiff
path: root/source4/lib/tdb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-24 11:02:52 -0600
committerStefan Metzmacher <metze@samba.org>2007-12-26 11:57:04 -0600
commit59efa6e5d074f9f0fbc0b5fd2b5bcdc9d78b95e3 (patch)
tree2569ef771a66ee66e1b57672c4d475a083789d59 /source4/lib/tdb
parenta822a14d1ec7e2635c3d004cc7488e4fd27b8d16 (diff)
downloadsamba-59efa6e5d074f9f0fbc0b5fd2b5bcdc9d78b95e3.tar.gz
samba-59efa6e5d074f9f0fbc0b5fd2b5bcdc9d78b95e3.tar.bz2
samba-59efa6e5d074f9f0fbc0b5fd2b5bcdc9d78b95e3.zip
r26585: Fix samba3.python tests.
(This used to be commit 231ec0777b7d1fb1297e3a974871b8735a386cfa)
Diffstat (limited to 'source4/lib/tdb')
-rw-r--r--source4/lib/tdb/tdb.i32
-rw-r--r--source4/lib/tdb/tdb.py14
-rw-r--r--source4/lib/tdb/tdb_wrap.c87
3 files changed, 98 insertions, 35 deletions
diff --git a/source4/lib/tdb/tdb.i b/source4/lib/tdb/tdb.i
index 41eaf77202..933bfc7bb7 100644
--- a/source4/lib/tdb/tdb.i
+++ b/source4/lib/tdb/tdb.i
@@ -60,12 +60,16 @@ typedef TDB_CONTEXT tdb;
data.. */
%typemap(in,noblock=1) TDB_DATA {
- if (!PyString_Check($input)) {
+ if ($input == Py_None) {
+ $1.dsize = 0;
+ $1.dptr = NULL;
+ } else if (!PyString_Check($input)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
- }
- $1.dsize = PyString_Size($input);
- $1.dptr = (uint8_t *)PyString_AsString($input);
+ } else {
+ $1.dsize = PyString_Size($input);
+ $1.dptr = (uint8_t *)PyString_AsString($input);
+ }
}
%typemap(out,noblock=1) TDB_DATA {
@@ -74,7 +78,7 @@ typedef TDB_CONTEXT tdb;
} else {
$result = PyString_FromStringAndSize((const char *)$1.dptr, $1.dsize);
free($1.dptr);
- }
+ }
}
/* Treat a mode_t as an unsigned integer */
@@ -146,8 +150,8 @@ enum TDB_ERROR {
typedef struct tdb_context {
%extend {
- tdb(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode) {
- return tdb_open(name, hash_size, tdb_flags, open_flags, mode);
+ tdb(const char *name, int hash_size, int tdb_flags, int flags, mode_t mode) {
+ return tdb_open(name, hash_size, tdb_flags, flags, mode);
}
enum TDB_ERROR error();
~tdb() { tdb_close($self); }
@@ -202,6 +206,20 @@ typedef struct tdb_context {
def has_key(self, key):
return self.exists(key) != 0
+ def fetch_uint32(self, key):
+ data = self.fetch(key)
+ if data is None:
+ return None
+ import struct
+ return struct.unpack("<L", data)[0]
+
+ def fetch_int32(self, key):
+ data = self.fetch(key)
+ if data is None:
+ return None
+ import struct
+ return struct.unpack("<l", data)[0]
+
# Tdb iterator
class TdbIterator:
def __init__(self, tdb):
diff --git a/source4/lib/tdb/tdb.py b/source4/lib/tdb/tdb.py
index d4cf9f5c6f..8566397ed3 100644
--- a/source4/lib/tdb/tdb.py
+++ b/source4/lib/tdb/tdb.py
@@ -108,6 +108,20 @@ class tdb(object):
def has_key(self, key):
return self.exists(key) != 0
+ def fetch_uint32(self, key):
+ data = self.fetch(key)
+ if data is None:
+ return None
+ import struct
+ return struct.unpack("<L", data)[0]
+
+ def fetch_int32(self, key):
+ data = self.fetch(key)
+ if data is None:
+ return None
+ import struct
+ return struct.unpack("<l", data)[0]
+
class TdbIterator:
def __init__(self, tdb):
diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/tdb/tdb_wrap.c
index a58442b521..c6dc337f63 100644
--- a/source4/lib/tdb/tdb_wrap.c
+++ b/source4/lib/tdb/tdb_wrap.c
@@ -2747,8 +2747,8 @@ SWIG_AsVal_int (PyObject * obj, int *val)
return res;
}
-SWIGINTERN tdb *new_tdb(char const *name,int hash_size,int tdb_flags,int open_flags,mode_t mode){
- return tdb_open(name, hash_size, tdb_flags, open_flags, mode);
+SWIGINTERN tdb *new_tdb(char const *name,int hash_size,int tdb_flags,int flags,mode_t mode){
+ return tdb_open(name, hash_size, tdb_flags, flags, mode);
}
SWIGINTERN void delete_tdb(tdb *self){ tdb_close(self); }
@@ -2818,12 +2818,11 @@ SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
char * kwnames[] = {
- (char *) "name",(char *) "hash_size",(char *) "tdb_flags",(char *) "open_flags",(char *) "mode", NULL
+ (char *) "name",(char *) "hash_size",(char *) "tdb_flags",(char *) "flags",(char *) "mode", NULL
};
arg2 = 0;
arg3 = TDB_DEFAULT;
- arg4 = O_RDWR;
arg5 = 0600;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:new_Tdb",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
@@ -2964,18 +2963,26 @@ SWIGINTERN PyObject *_wrap_tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_append" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- if (!PyString_Check(obj1)) {
+ if (obj1 == Py_None) {
+ (&arg2)->dsize = 0;
+ (&arg2)->dptr = NULL;
+ } else if (!PyString_Check(obj1)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
+ } else {
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
}
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
- if (!PyString_Check(obj2)) {
+ if (obj2 == Py_None) {
+ (&arg3)->dsize = 0;
+ (&arg3)->dptr = NULL;
+ } else if (!PyString_Check(obj2)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
+ } else {
+ (&arg3)->dsize = PyString_Size(obj2);
+ (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
}
- (&arg3)->dsize = PyString_Size(obj2);
- (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
result = (int)tdb_append(arg1,arg2,arg3);
resultobj = SWIG_From_int((int)(result));
return resultobj;
@@ -3026,12 +3033,16 @@ SWIGINTERN PyObject *_wrap_tdb_fetch(PyObject *SWIGUNUSEDPARM(self), PyObject *a
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_fetch" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- if (!PyString_Check(obj1)) {
+ if (obj1 == Py_None) {
+ (&arg2)->dsize = 0;
+ (&arg2)->dptr = NULL;
+ } else if (!PyString_Check(obj1)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
+ } else {
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
}
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
result = tdb_fetch(arg1,arg2);
if ((&result)->dptr == NULL && (&result)->dsize == 0) {
resultobj = Py_None;
@@ -3064,12 +3075,16 @@ SWIGINTERN PyObject *_wrap_tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_delete" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- if (!PyString_Check(obj1)) {
+ if (obj1 == Py_None) {
+ (&arg2)->dsize = 0;
+ (&arg2)->dptr = NULL;
+ } else if (!PyString_Check(obj1)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
+ } else {
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
}
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
result = (int)tdb_delete(arg1,arg2);
resultobj = SWIG_From_int((int)(result));
return resultobj;
@@ -3104,18 +3119,26 @@ SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_store" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- if (!PyString_Check(obj1)) {
+ if (obj1 == Py_None) {
+ (&arg2)->dsize = 0;
+ (&arg2)->dptr = NULL;
+ } else if (!PyString_Check(obj1)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
+ } else {
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
}
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
- if (!PyString_Check(obj2)) {
+ if (obj2 == Py_None) {
+ (&arg3)->dsize = 0;
+ (&arg3)->dptr = NULL;
+ } else if (!PyString_Check(obj2)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
+ } else {
+ (&arg3)->dsize = PyString_Size(obj2);
+ (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
}
- (&arg3)->dsize = PyString_Size(obj2);
- (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
if (obj3) {
ecode4 = SWIG_AsVal_int(obj3, &val4);
if (!SWIG_IsOK(ecode4)) {
@@ -3150,12 +3173,16 @@ SWIGINTERN PyObject *_wrap_tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_exists" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- if (!PyString_Check(obj1)) {
+ if (obj1 == Py_None) {
+ (&arg2)->dsize = 0;
+ (&arg2)->dptr = NULL;
+ } else if (!PyString_Check(obj1)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
+ } else {
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
}
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
result = (int)tdb_exists(arg1,arg2);
resultobj = SWIG_From_int((int)(result));
return resultobj;
@@ -3211,12 +3238,16 @@ SWIGINTERN PyObject *_wrap_tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_nextkey" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- if (!PyString_Check(obj1)) {
+ if (obj1 == Py_None) {
+ (&arg2)->dsize = 0;
+ (&arg2)->dptr = NULL;
+ } else if (!PyString_Check(obj1)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
+ } else {
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
}
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
result = tdb_nextkey(arg1,arg2);
if ((&result)->dptr == NULL && (&result)->dsize == 0) {
resultobj = Py_None;