From 5eecc854236f0b943aaa89e0c3a46f9fbd208ca9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:33 +0930 Subject: tdb2: create tdb2 versions of various testing TDBs. Soon, TDB2 will handle tdb1 files, but until then, we substitute. Signed-off-by: Rusty Russell --- lib/tdb2/pytdb.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/tdb2') diff --git a/lib/tdb2/pytdb.c b/lib/tdb2/pytdb.c index 86f604874b..c760045508 100644 --- a/lib/tdb2/pytdb.c +++ b/lib/tdb2/pytdb.c @@ -72,12 +72,21 @@ static PyObject *PyString_FromTDB_DATA(TDB_DATA data) return NULL; \ } +static void stderr_log(struct tdb_context *tdb, + enum tdb_log_level level, + const char *message, + void *data) +{ + fprintf(stderr, "%s:%s\n", tdb_name(tdb), message); +} + static PyObject *py_tdb_open(PyTypeObject *type, PyObject *args, PyObject *kwargs) { char *name = NULL; int tdb_flags = TDB_DEFAULT, flags = O_RDWR, mode = 0600; struct tdb_context *ctx; PyTdbObject *ret; + union tdb_attribute logattr; const char *kwnames[] = { "name", "tdb_flags", "flags", "mode", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|siii", (char **)kwnames, &name, &tdb_flags, &flags, &mode)) @@ -87,7 +96,10 @@ static PyObject *py_tdb_open(PyTypeObject *type, PyObject *args, PyObject *kwarg tdb_flags |= TDB_INTERNAL; } - ctx = tdb_open(name, tdb_flags, flags, mode, NULL); + logattr.log.base.attr = TDB_ATTRIBUTE_LOG; + logattr.log.base.next = NULL; + logattr.log.fn = stderr_log; + ctx = tdb_open(name, tdb_flags, flags, mode, &logattr); if (ctx == NULL) { PyErr_SetFromErrno(PyExc_IOError); return NULL; -- cgit