From 679e95db033fd11d17c1f1ac5e44f6cc4df2220e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 15 Nov 2004 11:40:27 +0000 Subject: r3754: merge in ldb modules support from the tmp branch ldbPlugins (This used to be commit 71323f424b4561af1fdddd2358629049be3dad8c) --- source4/lib/ldb/ldb_tdb/ldb_cache.c | 57 ++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'source4/lib/ldb/ldb_tdb/ldb_cache.c') diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c index 55dea406b5..cf175090e6 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_cache.c +++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c @@ -38,9 +38,10 @@ /* initialise the baseinfo record */ -static int ltdb_baseinfo_init(struct ldb_context *ldb) +static int ltdb_baseinfo_init(struct ldb_module *module) { - struct ltdb_private *ltdb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct ltdb_private *ltdb = module->private_data; struct ldb_message msg; struct ldb_message_element el; struct ldb_val val; @@ -77,7 +78,7 @@ static int ltdb_baseinfo_init(struct ldb_context *ldb) } val.length = 1; - ret = ltdb_store(ldb, &msg, TDB_INSERT); + ret = ltdb_store(module, &msg, TDB_INSERT); ldb_free(ldb, msg.dn); ldb_free(ldb, el.name); @@ -89,17 +90,18 @@ static int ltdb_baseinfo_init(struct ldb_context *ldb) /* free any cache records */ -void ltdb_cache_free(struct ldb_context *ldb) +void ltdb_cache_free(struct ldb_module *module) { - struct ltdb_private *ltdb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct ltdb_private *ltdb = module->private_data; struct ldb_alloc_ops alloc = ldb->alloc_ops; ldb->alloc_ops.alloc = NULL; ltdb->sequence_number = 0; - ltdb_search_dn1_free(ldb, <db->cache.baseinfo); - ltdb_search_dn1_free(ldb, <db->cache.indexlist); - ltdb_search_dn1_free(ldb, <db->cache.subclasses); - ltdb_search_dn1_free(ldb, <db->cache.attributes); + ltdb_search_dn1_free(module, <db->cache.baseinfo); + ltdb_search_dn1_free(module, <db->cache.indexlist); + ltdb_search_dn1_free(module, <db->cache.subclasses); + ltdb_search_dn1_free(module, <db->cache.attributes); ldb_free(ldb, ltdb->cache.last_attribute.name); memset(<db->cache, 0, sizeof(ltdb->cache)); @@ -110,26 +112,27 @@ void ltdb_cache_free(struct ldb_context *ldb) /* load the cache records */ -int ltdb_cache_load(struct ldb_context *ldb) +int ltdb_cache_load(struct ldb_module *module) { - struct ltdb_private *ltdb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct ltdb_private *ltdb = module->private_data; double seq; struct ldb_alloc_ops alloc = ldb->alloc_ops; ldb->alloc_ops.alloc = NULL; - ltdb_search_dn1_free(ldb, <db->cache.baseinfo); + ltdb_search_dn1_free(module, <db->cache.baseinfo); - if (ltdb_search_dn1(ldb, LTDB_BASEINFO, <db->cache.baseinfo) == -1) { + if (ltdb_search_dn1(module, LTDB_BASEINFO, <db->cache.baseinfo) == -1) { goto failed; } /* possibly initialise the baseinfo */ if (!ltdb->cache.baseinfo.dn) { - if (ltdb_baseinfo_init(ldb) != 0) { + if (ltdb_baseinfo_init(module) != 0) { goto failed; } - if (ltdb_search_dn1(ldb, LTDB_BASEINFO, <db->cache.baseinfo) != 1) { + if (ltdb_search_dn1(module, LTDB_BASEINFO, <db->cache.baseinfo) != 1) { goto failed; } } @@ -145,17 +148,17 @@ int ltdb_cache_load(struct ldb_context *ldb) ldb_free(ldb, ltdb->cache.last_attribute.name); memset(<db->cache.last_attribute, 0, sizeof(ltdb->cache.last_attribute)); - ltdb_search_dn1_free(ldb, <db->cache.indexlist); - ltdb_search_dn1_free(ldb, <db->cache.subclasses); - ltdb_search_dn1_free(ldb, <db->cache.attributes); + ltdb_search_dn1_free(module, <db->cache.indexlist); + ltdb_search_dn1_free(module, <db->cache.subclasses); + ltdb_search_dn1_free(module, <db->cache.attributes); - if (ltdb_search_dn1(ldb, LTDB_INDEXLIST, <db->cache.indexlist) == -1) { + if (ltdb_search_dn1(module, LTDB_INDEXLIST, <db->cache.indexlist) == -1) { goto failed; } - if (ltdb_search_dn1(ldb, LTDB_SUBCLASSES, <db->cache.subclasses) == -1) { + if (ltdb_search_dn1(module, LTDB_SUBCLASSES, <db->cache.subclasses) == -1) { goto failed; } - if (ltdb_search_dn1(ldb, LTDB_ATTRIBUTES, <db->cache.attributes) == -1) { + if (ltdb_search_dn1(module, LTDB_ATTRIBUTES, <db->cache.attributes) == -1) { goto failed; } @@ -172,9 +175,10 @@ failed: /* increase the sequence number to indicate a database change */ -int ltdb_increase_sequence_number(struct ldb_context *ldb) +int ltdb_increase_sequence_number(struct ldb_module *module) { - struct ltdb_private *ltdb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct ltdb_private *ltdb = module->private_data; struct ldb_message msg; struct ldb_message_element el; struct ldb_val val; @@ -197,7 +201,7 @@ int ltdb_increase_sequence_number(struct ldb_context *ldb) val.data = s; val.length = strlen(s); - ret = ltdb_modify_internal(ldb, &msg); + ret = ltdb_modify_internal(module, &msg); ldb_free(ldb, s); ldb_free(ldb, msg.dn); @@ -215,9 +219,10 @@ int ltdb_increase_sequence_number(struct ldb_context *ldb) return the attribute flags from the @ATTRIBUTES record for the given attribute */ -int ltdb_attribute_flags(struct ldb_context *ldb, const char *attr_name) +int ltdb_attribute_flags(struct ldb_module *module, const char *attr_name) { - struct ltdb_private *ltdb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct ltdb_private *ltdb = module->private_data; const char *attrs; const struct { const char *name; -- cgit