diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-05-07 23:54:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:47 -0500 |
commit | 265023fafa463c742f89510879acb2a830de8ab9 (patch) | |
tree | 1614be24e20bd5c0bfc9f4a5d657a2b574df2c63 /source4/lib/ldb/common/ldb_parse.c | |
parent | dee25d910e5ed3d07a240cebe8600f4a95c94159 (diff) | |
download | samba-265023fafa463c742f89510879acb2a830de8ab9.tar.gz samba-265023fafa463c742f89510879acb2a830de8ab9.tar.bz2 samba-265023fafa463c742f89510879acb2a830de8ab9.zip |
r574: - another attempt at const cleanliness in ldb
- fixed a problem with searching for values containing an '=' sign
- fixed the semantics of attempting an attribute deletion on an attribute that doesn't exist.
- added some more ldb_msg_*() utilities
(This used to be commit 62b4ec367d170330d837b0f1fe5cd13205a53b59)
Diffstat (limited to 'source4/lib/ldb/common/ldb_parse.c')
-rw-r--r-- | source4/lib/ldb/common/ldb_parse.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index 75eb44fcc0..5d2a42fd20 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -56,10 +56,12 @@ a filter is defined by: <filtertype> ::= '=' | '~=' | '<=' | '>=' */ +#define LDB_ALL_SEP "()&|=!" + /* return next token element. Caller frees */ -static char *ldb_parse_lex(struct ldb_context *ldb, const char **s) +static char *ldb_parse_lex(struct ldb_context *ldb, const char **s, const char *sep) { const char *p = *s; char *ret; @@ -73,7 +75,7 @@ static char *ldb_parse_lex(struct ldb_context *ldb, const char **s) return NULL; } - if (strchr("()&|=!", *p)) { + if (strchr(sep, *p)) { (*s) = p+1; ret = ldb_strndup(ldb, p, 1); if (!ret) { @@ -82,7 +84,7 @@ static char *ldb_parse_lex(struct ldb_context *ldb, const char **s) return ret; } - while (*p && (isalnum(*p) || !strchr("()&|=!", *p))) { + while (*p && (isalnum(*p) || !strchr(sep, *p))) { p++; } @@ -132,7 +134,7 @@ static struct ldb_parse_tree *ldb_parse_simple(struct ldb_context *ldb, const ch char *eq, *val, *l; struct ldb_parse_tree *ret; - l = ldb_parse_lex(ldb, &s); + l = ldb_parse_lex(ldb, &s, LDB_ALL_SEP); if (!l) { return NULL; } @@ -142,7 +144,7 @@ static struct ldb_parse_tree *ldb_parse_simple(struct ldb_context *ldb, const ch return NULL; } - eq = ldb_parse_lex(ldb, &s); + eq = ldb_parse_lex(ldb, &s, LDB_ALL_SEP); if (!eq || strcmp(eq, "=") != 0) { ldb_free(ldb, l); if (eq) ldb_free(ldb, eq); @@ -150,8 +152,8 @@ static struct ldb_parse_tree *ldb_parse_simple(struct ldb_context *ldb, const ch } ldb_free(ldb, eq); - val = ldb_parse_lex(ldb, &s); - if (val && strchr("()&|=", *val)) { + val = ldb_parse_lex(ldb, &s, ")"); + if (val && strchr("()&|", *val)) { ldb_free(ldb, l); if (val) ldb_free(ldb, val); return NULL; @@ -288,7 +290,7 @@ static struct ldb_parse_tree *ldb_parse_filter(struct ldb_context *ldb, const ch const char *p, *p2; struct ldb_parse_tree *ret; - l = ldb_parse_lex(ldb, s); + l = ldb_parse_lex(ldb, s, LDB_ALL_SEP); if (!l) { return NULL; } |