*/
#include "includes.h"
+#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_private.h"
#include "ldb/ldb_tdb/ldb_tdb.h"
#include "ldb/include/ldb_parse.h"
-
+#include <fnmatch.h>
/*
see if two ldb_val structures contain the same data as integers
return 1 for a match, 0 for a mis-match
*/
-static int ldb_val_equal_integer(const struct ldb_val *v1, const struct ldb_val *v2)
+static int ltdb_val_equal_integer(const struct ldb_val *v1, const struct ldb_val *v2)
{
int i1, i2;
see if two ldb_val structures contain the same data as case insensitive strings
return 1 for a match, 0 for a mis-match
*/
-static int ldb_val_equal_case_insensitive(const struct ldb_val *v1,
+static int ltdb_val_equal_case_insensitive(const struct ldb_val *v1,
const struct ldb_val *v2)
{
if (v1->length != v2->length) {
and case insensitive
return 1 for a match, 0 for a mis-match
*/
-static int ldb_val_equal_wildcard_ci(struct ldb_context *ldb,
+static int ltdb_val_equal_wildcard_ci(struct ldb_module *module,
const struct ldb_val *v1,
const struct ldb_val *v2)
{
+ struct ldb_context *ldb = module->ldb;
char *s1, *s2;
int ret;
see if two ldb_val structures contain the same data with wildcards
return 1 for a match, 0 for a mis-match
*/
-static int ldb_val_equal_wildcard(struct ldb_context *ldb,
+static int ltdb_val_equal_wildcard(struct ldb_module *module,
const struct ldb_val *v1,
const struct ldb_val *v2,
int flags)
{
if (flags & LTDB_FLAG_CASE_INSENSITIVE) {
- return ldb_val_equal_wildcard_ci(ldb, v1, v2);
+ return ltdb_val_equal_wildcard_ci(module, v1, v2);
}
if (!v1->data || !v2->data) {
return v1->data == v2->data;
return 1 for a match, 0 for a mis-match
*/
-static int ldb_val_equal_objectclass(struct ldb_context *ldb,
+static int ltdb_val_equal_objectclass(struct ldb_module *module,
const struct ldb_val *v1, const struct ldb_val *v2)
{
- struct ltdb_private *ltdb = ldb->private_data;
+ struct ltdb_private *ltdb = module->private_data;
unsigned int i;
- if (ldb_val_equal_case_insensitive(v1, v2) == 1) {
+ if (ltdb_val_equal_case_insensitive(v1, v2) == 1) {
return 1;
}
if (ldb_attr_cmp(el->name, v2->data) == 0) {
unsigned int j;
for (j=0;j<el->num_values;j++) {
- if (ldb_val_equal_objectclass(ldb, v1, &el->values[j])) {
+ if (ltdb_val_equal_objectclass(module, v1, &el->values[j])) {
return 1;
}
}
return 1 for a match, 0 for a mis-match
*/
-int ldb_val_equal(struct ldb_context *ldb,
+int ltdb_val_equal(struct ldb_module *module,
const char *attr_name,
const struct ldb_val *v1, const struct ldb_val *v2)
{
- int flags = ltdb_attribute_flags(ldb, attr_name);
+ int flags = ltdb_attribute_flags(module, attr_name);
if (flags & LTDB_FLAG_OBJECTCLASS) {
- return ldb_val_equal_objectclass(ldb, v1, v2);
+ return ltdb_val_equal_objectclass(module, v1, v2);
}
if (flags & LTDB_FLAG_INTEGER) {
- return ldb_val_equal_integer(v1, v2);
+ return ltdb_val_equal_integer(v1, v2);
}
if (flags & LTDB_FLAG_WILDCARD) {
- return ldb_val_equal_wildcard(ldb, v1, v2, flags);
+ return ltdb_val_equal_wildcard(module, v1, v2, flags);
}
if (flags & LTDB_FLAG_CASE_INSENSITIVE) {
- return ldb_val_equal_case_insensitive(v1, v2);
+ return ltdb_val_equal_case_insensitive(v1, v2);
}
if (v1->length != v2->length) return 0;
base_len = strlen(base);
dn_len = strlen(dn);
- if (ldb_dn_cmp(dn, base) == 0) {
+ if (scope != LDB_SCOPE_ONELEVEL && ldb_dn_cmp(dn, base) == 0) {
return 1;
}
/*
match a leaf node
*/
-static int match_leaf(struct ldb_context *ldb,
+static int match_leaf(struct ldb_module *module,
struct ldb_message *msg,
struct ldb_parse_tree *tree,
const char *base,
return 1;
}
for (j=0;j<msg->elements[i].num_values;j++) {
- if (ldb_val_equal(ldb, msg->elements[i].name,
+ if (ltdb_val_equal(module, msg->elements[i].name,
&msg->elements[i].values[j],
&tree->u.simple.value)) {
return 1;
this is a recursive function, and does short-circuit evaluation
*/
-int ldb_message_match(struct ldb_context *ldb,
+int ltdb_message_match(struct ldb_module *module,
struct ldb_message *msg,
struct ldb_parse_tree *tree,
const char *base,
break;
case LDB_OP_NOT:
- return ! ldb_message_match(ldb, msg, tree->u.not.child, base, scope);
+ return ! ltdb_message_match(module, msg, tree->u.not.child, base, scope);
case LDB_OP_AND:
for (i=0;i<tree->u.list.num_elements;i++) {
- v = ldb_message_match(ldb, msg, tree->u.list.elements[i],
+ v = ltdb_message_match(module, msg, tree->u.list.elements[i],
base, scope);
if (!v) return 0;
}
case LDB_OP_OR:
for (i=0;i<tree->u.list.num_elements;i++) {
- v = ldb_message_match(ldb, msg, tree->u.list.elements[i],
+ v = ltdb_message_match(module, msg, tree->u.list.elements[i],
base, scope);
if (v) return 1;
}
return 0;
}
- return match_leaf(ldb, msg, tree, base, scope);
+ return match_leaf(module, msg, tree, base, scope);
}