From f5ebc8e404f4397c0ef2c8b838984df1767c955c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 00:38:48 +0000 Subject: r13324: From now on check attribute names obey rfc2251 Also add a way to provide utf8 compliant functions by registering them with ldb_set_utf8_fns() Next comes code to register samba internal utf8 functions. Simo. (This used to be commit ac9b8a41ffca8e06c5e849d544d3203a665b8e0d) --- source4/lib/ldb/include/ldb.h | 36 +++++++++++++++++++++++++++++++---- source4/lib/ldb/include/ldb_private.h | 7 +++++++ 2 files changed, 39 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9139e6d2f5..a8c2d176b5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -208,6 +208,16 @@ struct ldb_debug_ops { void *context; }; +/** + The user can optionally supply a custom utf8 functions, + to handle comparisons and casefolding. +*/ +struct ldb_utf8_fns { + void *context; + int (*caseless_cmp)(void *context, const char *s1, const char *s2); + char *(*casefold)(void *context, void *mem_ctx, const char *s); +}; + /** Flag value for database connection mode. @@ -718,30 +728,48 @@ int ldb_transaction_cancel(struct ldb_context *ldb); */ const char *ldb_errstring(struct ldb_context *ldb); +/** + setup the default utf8 functions + FIXME: these functions do not yet handle utf8 +*/ +void ldb_set_utf8_default(struct ldb_context *ldb); + /** Casefold a string + \param ldb the ldb context \param mem_ctx the memory context to allocate the result string memory from. \param s the string that is to be folded \return a copy of the string, converted to upper case - \todo This function should be UTF8 aware, but currently is not. + \note The default function is not yet UTF8 aware. Provide your own + set of functions through ldb_set_utf8_fns() */ -char *ldb_casefold(void *mem_ctx, const char *s); +char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); /** Compare two strings, without regard to case. + \param ldb the ldb context \param s1 the first string to compare \param s2 the second string to compare \return 0 if the strings are the same, non-zero if there are any differences except for case. - \note This function is not UTF8 aware. + \note The default function is not yet UTF8 aware. Provide your own + set of functions through ldb_set_utf8_fns() +*/ +int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); + +/** + Check the attribute name is valid according to rfc2251 + \param s tthe string to check + + \return 1 if the name is ok */ -int ldb_caseless_cmp(const char *s1, const char *s2); +int ldb_valid_attr_name(const char *s); /* ldif manipulation functions diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 6871d8d552..fffda77ff8 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -90,6 +90,9 @@ struct ldb_context { /* debugging operations */ struct ldb_debug_ops debug_ops; + /* custom utf8 functions */ + struct ldb_utf8_fns utf8_fns; + /* backend specific opaque parameters */ struct ldb_opaque { struct ldb_opaque *next; @@ -191,4 +194,8 @@ int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx, struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid); int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver); int check_critical_controls(struct ldb_control **controls); + +/* The following definitions come from lib/ldb/common/ldb_utf8.c */ +char *ldb_casefold_default(void *context, void *mem_ctx, const char *s); +int ldb_caseless_cmp_default(void *context, const char *s1, const char *s2); #endif -- cgit