diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-12-15 13:08:57 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:29:19 -0500 |
commit | b97b8f5dcbce006f005e53ca79df3330e62f117b (patch) | |
tree | b4e3b2e41a8c0c3d76f8965748b0322b68ad0320 /source/lib/ldb/ldb_tdb | |
parent | 1f67433914bfab83bf1950263809c9e152ad6dcc (diff) | |
download | samba-b97b8f5dcbce006f005e53ca79df3330e62f117b.tar.gz |
r20184: change ldb_attrib_handler into ldb_schema_attribute, which has a pointer
to a ldb_schema_syntax struct.
the default attribute handler is now registered dynamicly as "*"
attribute, instead of having its own code path.
ldb_schema_attribute's can be added to the ldb_schema given a
ldb_schema_syntax struct or the syntax name
we may also need to introduce a ldb_schema_matching_rule,
and add a pointer to a default ldb_schema_matching_rule
in the ldb_schema_syntax.
metze
Diffstat (limited to 'source/lib/ldb/ldb_tdb')
-rw-r--r-- | source/lib/ldb/ldb_tdb/ldb_cache.c | 14 | ||||
-rw-r--r-- | source/lib/ldb/ldb_tdb/ldb_index.c | 6 | ||||
-rw-r--r-- | source/lib/ldb/ldb_tdb/ldb_search.c | 6 | ||||
-rw-r--r-- | source/lib/ldb/ldb_tdb/ldb_tdb.c | 6 |
4 files changed, 13 insertions, 19 deletions
diff --git a/source/lib/ldb/ldb_tdb/ldb_cache.c b/source/lib/ldb/ldb_tdb/ldb_cache.c index d64340b5d04..dbd5222ce59 100644 --- a/source/lib/ldb/ldb_tdb/ldb_cache.c +++ b/source/lib/ldb/ldb_tdb/ldb_cache.c @@ -71,7 +71,7 @@ static void ltdb_attributes_unload(struct ldb_module *module) msg = ltdb->cache->attributes; for (i=0;i<msg->num_elements;i++) { - ldb_remove_attrib_handler(module->ldb, msg->elements[i].name); + ldb_schema_attribute_remove(module->ldb, msg->elements[i].name); } talloc_free(ltdb->cache->attributes); @@ -126,7 +126,6 @@ static int ltdb_attributes_load(struct ldb_module *module) unsigned flags; const char *syntax; const struct ldb_schema_syntax *s; - struct ldb_attrib_handler h; if (ltdb_attributes_flags(&msg->elements[i], &flags) != 0) { ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name); @@ -156,14 +155,9 @@ static int ltdb_attributes_load(struct ldb_module *module) syntax, msg->elements[i].name); goto failed; } - h.attr = msg->elements[i].name; - h.flags |= LDB_ATTR_FLAG_ALLOCATED; - h.ldif_read_fn = s->ldif_read_fn; - h.ldif_write_fn = s->ldif_write_fn; - h.canonicalise_fn = s->canonicalise_fn; - h.comparison_fn = s->comparison_fn; - - if (ldb_set_attrib_handlers(module->ldb, &h, 1) != 0) { + + flags |= LDB_ATTR_FLAG_ALLOCATED; + if (ldb_schema_attribute_add_with_syntax(module->ldb, msg->elements[i].name, flags, s) != 0) { goto failed; } } diff --git a/source/lib/ldb/ldb_tdb/ldb_index.c b/source/lib/ldb/ldb_tdb/ldb_index.c index 19385f55048..fd61d410375 100644 --- a/source/lib/ldb/ldb_tdb/ldb_index.c +++ b/source/lib/ldb/ldb_tdb/ldb_index.c @@ -108,7 +108,7 @@ static struct ldb_dn *ltdb_index_key(struct ldb_context *ldb, { struct ldb_dn *ret; struct ldb_val v; - const struct ldb_attrib_handler *h; + const struct ldb_schema_attribute *a; char *attr_folded; int r; @@ -117,8 +117,8 @@ static struct ldb_dn *ltdb_index_key(struct ldb_context *ldb, return NULL; } - h = ldb_attrib_handler(ldb, attr); - r = h->canonicalise_fn(ldb, ldb, value, &v); + a = ldb_schema_attribute_by_name(ldb, attr); + r = a->syntax->canonicalise_fn(ldb, ldb, value, &v); if (r != LDB_SUCCESS) { const char *errstr = ldb_errstring(ldb); /* canonicalisation can be refused. For example, diff --git a/source/lib/ldb/ldb_tdb/ldb_search.c b/source/lib/ldb/ldb_tdb/ldb_search.c index 5736b7684b8..6890378185f 100644 --- a/source/lib/ldb/ldb_tdb/ldb_search.c +++ b/source/lib/ldb/ldb_tdb/ldb_search.c @@ -123,9 +123,9 @@ static int msg_add_all_elements(struct ldb_module *module, struct ldb_message *r } for (i=0;i<msg->num_elements;i++) { - const struct ldb_attrib_handler *h; - h = ldb_attrib_handler(ldb, msg->elements[i].name); - if (h->flags & LDB_ATTR_FLAG_HIDDEN) { + const struct ldb_schema_attribute *a; + a = ldb_schema_attribute_by_name(ldb, msg->elements[i].name); + if (a->flags & LDB_ATTR_FLAG_HIDDEN) { continue; } if (msg_add_element(ret, &msg->elements[i], diff --git a/source/lib/ldb/ldb_tdb/ldb_tdb.c b/source/lib/ldb/ldb_tdb/ldb_tdb.c index 09ddca50342..6adf6f48cae 100644 --- a/source/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source/lib/ldb/ldb_tdb/ldb_tdb.c @@ -558,7 +558,7 @@ static int msg_delete_element(struct ldb_module *module, unsigned int i; int found; struct ldb_message_element *el; - const struct ldb_attrib_handler *h; + const struct ldb_schema_attribute *a; found = find_element(msg, name); if (found == -1) { @@ -567,10 +567,10 @@ static int msg_delete_element(struct ldb_module *module, el = &msg->elements[found]; - h = ldb_attrib_handler(ldb, el->name); + a = ldb_schema_attribute_by_name(ldb, el->name); for (i=0;i<el->num_values;i++) { - if (h->comparison_fn(ldb, ldb, &el->values[i], val) == 0) { + if (a->syntax->comparison_fn(ldb, ldb, &el->values[i], val) == 0) { if (i<el->num_values-1) { memmove(&el->values[i], &el->values[i+1], sizeof(el->values[i])*(el->num_values-(i+1))); |