1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ldb: Add helper function ldb_schema_attribute_fill_with_syntax()

This will allow us to avoid calling ldb_schema_attribute_add_with_syntax()
in a tight loop.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2016-10-20 16:01:42 +13:00
parent d8ee92734b
commit 393b8f3c1d
2 changed files with 41 additions and 0 deletions

View File

@ -31,6 +31,41 @@
#include "ldb_private.h"
#include "ldb_handlers.h"
/*
fill in an attribute to the ldb_schema into the supplied buffer
if flags contains LDB_ATTR_FLAG_ALLOCATED
the attribute name string will be copied using
talloc_strdup(), otherwise it needs to be a static const
string at least with a lifetime longer than the ldb struct!
the ldb_schema_syntax structure should be a pointer
to a static const struct or at least it needs to be
a struct with a longer lifetime than the ldb context!
*/
int ldb_schema_attribute_fill_with_syntax(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
const char *attribute,
unsigned flags,
const struct ldb_schema_syntax *syntax,
struct ldb_schema_attribute *a)
{
a->name = attribute;
a->flags = flags;
a->syntax = syntax;
if (a->flags & LDB_ATTR_FLAG_ALLOCATED) {
a->name = talloc_strdup(mem_ctx, a->name);
if (a->name == NULL) {
ldb_oom(ldb);
return -1;
}
}
return 0;
}
/*
add a attribute to the ldb_schema

View File

@ -169,6 +169,12 @@ int ldb_setup_wellknown_attributes(struct ldb_context *ldb);
This is to permit correct reloads
*/
void ldb_schema_attribute_remove_flagged(struct ldb_context *ldb, unsigned int flag);
int ldb_schema_attribute_fill_with_syntax(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
const char *attribute,
unsigned flags,
const struct ldb_schema_syntax *syntax,
struct ldb_schema_attribute *a);
const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname);
void ldb_subclass_remove(struct ldb_context *ldb, const char *classname);