From 9cb3b2d49bf4093f9eff8cd26a0c9c994da5d096 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Jun 2005 05:33:55 +0000 Subject: r7515: merge in the binary encode/decode enhancements from the libcli/ldap/ code into the ldb parse code (This used to be commit 12647e37223847da810c2d4e5f83328b1fcf88cb) --- source4/lib/ldb/common/ldb_parse.c | 70 +++++++++++++++++++++++++++++++++++-- source4/lib/ldb/include/ldb_parse.h | 1 + 2 files changed, 69 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb') diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index e64e6d82d3..80841054c6 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -126,6 +126,73 @@ static const char *match_brace(const char *s) return s; } +/* + decode a RFC2254 binary string representation of a buffer. + Used in LDAP filters. +*/ +struct ldb_val ldb_binary_decode(TALLOC_CTX *ctx, const char *str) +{ + int i, j; + struct ldb_val ret; + int slen = strlen(str); + + ret.data = talloc_size(ctx, slen); + ret.length = 0; + if (ret.data == NULL) return ret; + + for (i=j=0;ioperation = LDB_OP_SIMPLE; ret->u.simple.attr = l; - ret->u.simple.value.data = val?val:discard_const_p(char, ""); - ret->u.simple.value.length = val?strlen(val):0; + ret->u.simple.value = ldb_binary_decode(ret, val); return ret; } diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h index 50a9382534..741a8af618 100644 --- a/source4/lib/ldb/include/ldb_parse.h +++ b/source4/lib/ldb/include/ldb_parse.h @@ -55,5 +55,6 @@ struct ldb_parse_tree { }; struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s); +const char *ldb_binary_encode(TALLOC_CTX *ctx, struct ldb_val val); #endif -- cgit