r13325: let samba register it's own utf8 aware functions in ldb
authorSimo Sorce <idra@samba.org>
Sat, 4 Feb 2006 01:27:47 +0000 (01:27 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:51:44 +0000 (13:51 -0500)
source/lib/db_wrap.c
source/lib/ldb/include/ldb.h

index e070d4eb14e732b99e8915e9e6a1ac7fb3fef3f7..f3358bff98bbdee279cc1966afcab727eb2fadfd 100644 (file)
@@ -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;
 }
 
index a8c2d176b59fc8fb4b3b61003e13ee03a919d0e8..7c39aeeeb9569bc97ed5afbdd67b5f0bbf8943b3 100644 (file)
@@ -1112,6 +1112,14 @@ int ldb_set_debug(struct ldb_context *ldb,
                                const char *fmt, va_list ap),
                  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
 */