r19832: better prototypes for the linearization functions:
[kamenim/samba.git] / source4 / lib / ldb / common / attrib_handlers.c
index 07a0ec6eb8889e108189cff1866151f81f77107f..c50f7ed7b1ab8305be442856f96e90d1ca582955 100644 (file)
@@ -154,7 +154,8 @@ static int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
                               const struct ldb_val *v1, const struct ldb_val *v2)
 {
        const char *s1=(const char *)v1->data, *s2=(const char *)v2->data;
-       char *b1, *b2, *u1, *u2;
+       const char *u1, *u2;
+       char *b1, *b2;
        int ret;
        while (*s1 == ' ') s1++;
        while (*s2 == ' ') s2++;
@@ -185,11 +186,14 @@ static int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
 
 utf8str:
        /* no need to recheck from the start, just from the first utf8 char found */
-       b1 = u1 = ldb_casefold(ldb, mem_ctx, s1);
-       b2 = u2 = ldb_casefold(ldb, mem_ctx, s2);
+       b1 = ldb_casefold(ldb, mem_ctx, s1);
+       b2 = ldb_casefold(ldb, mem_ctx, s2);
 
-       if (u1 && u2) {
+       if (b1 && b2) {
                /* Both strings converted correctly */
+
+               u1 = b1;
+               u2 = b2;
        } else {
                /* One of the strings was not UTF8, so we have no options but to do a binary compare */
 
@@ -230,12 +234,12 @@ static int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx,
        out->length = 0;
        out->data = NULL;
 
-       dn = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)in->data);
-       if (dn == NULL) {
+       dn = ldb_dn_new(ldb, mem_ctx, (char *)in->data);
+       if ( ! ldb_dn_validate(dn)) {
                return -1;
        }
 
-       out->data = (uint8_t *)ldb_dn_linearize(mem_ctx, dn);
+       out->data = (uint8_t *)ldb_dn_alloc_linearized(mem_ctx, dn);
        if (out->data == NULL) {
                goto done;
        }
@@ -258,16 +262,16 @@ static int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx,
        struct ldb_dn *dn1 = NULL, *dn2 = NULL;
        int ret;
 
-       dn1 = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)v1->data);
-       if (dn1 == NULL) return -1;
+       dn1 = ldb_dn_new(ldb, mem_ctx, (char *)v1->data);
+       if ( ! ldb_dn_validate(dn1)) return -1;
 
-       dn2 = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)v2->data);
-       if (dn2 == NULL) {
+       dn2 = ldb_dn_new(ldb, mem_ctx, (char *)v2->data);
+       if ( ! ldb_dn_validate(dn2)) {
                talloc_free(dn1);
                return -1;
        } 
 
-       ret = ldb_dn_compare(ldb, dn1, dn2);
+       ret = ldb_dn_compare(dn1, dn2);
 
        talloc_free(dn1);
        talloc_free(dn2);