return ret;
}
+static int ltdb_tdb_store(struct ltdb_private *ltdb, TDB_DATA key, TDB_DATA data, int flags)
+{
+ return tdb_store(ltdb->tdb, key, data, flags);
+}
+
+static int ltdb_error(struct ltdb_private *ltdb)
+{
+ return ltdb_err_map(tdb_error(ltdb->tdb));
+}
+
/*
store a record into the db
*/
return ret;
}
+static int ltdb_tdb_delete(struct ltdb_private *ltdb, TDB_DATA tdb_key)
+{
+ return tdb_delete(ltdb->tdb, tdb_key);
+}
+
/*
delete a record from the database, not updating indexes (used for deleting
index records)
ltdb_request_extended_done(ctx, ext, ret);
}
+static const char * ltdb_tdb_name(struct ltdb_private *ltdb)
+{
+ return tdb_name(ltdb->tdb);
+}
+
+static const struct kv_db_ops key_value_ops = {
+ .store = ltdb_tdb_store,
+ .delete = ltdb_tdb_delete,
+ .lock_read = ltdb_lock_read,
+ .unlock_read = ltdb_unlock_read,
+ .error = ltdb_error,
+ .name = ltdb_tdb_name,
+};
+
static void ltdb_callback(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval t,
}
ltdb->sequence_number = 0;
+ ltdb->kv_ops = &key_value_ops;
module = ldb_module_new(ldb, ldb, "ldb_tdb backend", <db_ops);
if (!module) {
#include "tdb.h"
#include "ldb_module.h"
+struct ltdb_private;
+struct kv_db_ops {
+ int (*store)(struct ltdb_private *ltdb, TDB_DATA key, TDB_DATA data, int flags);
+ int (*delete)(struct ltdb_private *ltdb, TDB_DATA key);
+ int (*lock_read)(struct ldb_module *);
+ int (*unlock_read)(struct ldb_module *);
+ int (*error)(struct ltdb_private *ltdb);
+ const char * (*name)(struct ltdb_private *ltdb);
+};
+
/* this private structure is used by the ltdb backend in the
ldb_context */
struct ltdb_private {
+ const struct kv_db_ops *kv_ops;
TDB_CONTEXT *tdb;
unsigned int connect_flags;