mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +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:
parent
d8ee92734b
commit
393b8f3c1d
@ -31,6 +31,41 @@
|
|||||||
#include "ldb_private.h"
|
#include "ldb_private.h"
|
||||||
#include "ldb_handlers.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
|
add a attribute to the ldb_schema
|
||||||
|
|
||||||
|
@ -169,6 +169,12 @@ int ldb_setup_wellknown_attributes(struct ldb_context *ldb);
|
|||||||
This is to permit correct reloads
|
This is to permit correct reloads
|
||||||
*/
|
*/
|
||||||
void ldb_schema_attribute_remove_flagged(struct ldb_context *ldb, unsigned int flag);
|
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);
|
const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname);
|
||||||
void ldb_subclass_remove(struct ldb_context *ldb, const char *classname);
|
void ldb_subclass_remove(struct ldb_context *ldb, const char *classname);
|
||||||
|
Loading…
Reference in New Issue
Block a user