summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-02-04 01:27:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:44 -0500
commit48d8eee7522e1c1c45a9353ab77c96c20321f143 (patch)
tree630c0ca9a7fa4e05a49776ed1628c3c0c757ed96
parentf5ebc8e404f4397c0ef2c8b838984df1767c955c (diff)
downloadsamba-48d8eee7522e1c1c45a9353ab77c96c20321f143.tar.gz
samba-48d8eee7522e1c1c45a9353ab77c96c20321f143.tar.bz2
samba-48d8eee7522e1c1c45a9353ab77c96c20321f143.zip
r13325: let samba register it's own utf8 aware functions in ldb
(This used to be commit 12faf556833807d3f2aa4360c54e10583ac77fed)
-rw-r--r--source4/lib/db_wrap.c12
-rw-r--r--source4/lib/ldb/include/ldb.h8
2 files changed, 20 insertions, 0 deletions
diff --git a/source4/lib/db_wrap.c b/source4/lib/db_wrap.c
index e070d4eb14..f3358bff98 100644
--- a/source4/lib/db_wrap.c
+++ b/source4/lib/db_wrap.c
@@ -55,6 +55,16 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
free(s);
}
+static int wrap_caseless_cmp(void *context, const char *s1, const char *s2)
+{
+ return strcasecmp_m(s1, s2);
+}
+
+static char *wrap_casefold(void *context, void *mem_ctx, const char *s)
+{
+ return strupper_talloc(mem_ctx, s);
+}
+
/*
wrapped connection to a ldb database
to close just talloc_free() the returned ldb_context
@@ -123,6 +133,8 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
ldb_set_debug(ldb, ldb_wrap_debug, NULL);
+ ldb_set_utf8_fns(ldb, NULL, wrap_caseless_cmp, wrap_casefold);
+
return ldb;
}
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index a8c2d176b5..7c39aeeeb9 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -1113,6 +1113,14 @@ int ldb_set_debug(struct ldb_context *ldb,
void *context);
/**
+ this allows the user to set custom utf8 function for error reporting
+*/
+void ldb_set_utf8_fns(struct ldb_context *ldb,
+ void *context,
+ int (*cmp)(void *, const char *, const char *),
+ char *(*casefold)(void *, void *, const char *));
+
+/**
this sets up debug to print messages on stderr
*/
int ldb_set_debug_stderr(struct ldb_context *ldb);