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

ldb_tdb: Remove unused function ltdb_add_attr_results

Signed-off-by: Jakub Hrozek <jakub.hrozek@posteo.se>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
This commit is contained in:
Jakub Hrozek 2015-05-11 22:24:01 +02:00 committed by Andreas Schneider
parent d58481bd13
commit 9d4168e745
2 changed files with 0 additions and 140 deletions

View File

@ -108,102 +108,6 @@ static int msg_add_distinguished_name(struct ldb_message *msg)
return ret;
}
/*
add all elements from one message into another
*/
static int msg_add_all_elements(struct ldb_module *module, struct ldb_message *ret,
const struct ldb_message *msg)
{
struct ldb_context *ldb;
unsigned int i;
int check_duplicates = (ret->num_elements != 0);
ldb = ldb_module_get_ctx(module);
if (msg_add_distinguished_name(ret) != 0) {
return -1;
}
for (i=0;i<msg->num_elements;i++) {
const struct ldb_schema_attribute *a;
a = ldb_schema_attribute_by_name(ldb, msg->elements[i].name);
if (a->flags & LDB_ATTR_FLAG_HIDDEN) {
continue;
}
if (msg_add_element(ret, &msg->elements[i],
check_duplicates) != 0) {
return -1;
}
}
return 0;
}
/*
pull the specified list of attributes from a message
*/
static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
const struct ldb_message *msg,
const char * const *attrs)
{
struct ldb_message *ret;
unsigned int i;
ret = talloc(mem_ctx, struct ldb_message);
if (!ret) {
return NULL;
}
ret->dn = ldb_dn_copy(ret, msg->dn);
if (!ret->dn) {
talloc_free(ret);
return NULL;
}
ret->num_elements = 0;
ret->elements = NULL;
if (!attrs) {
if (msg_add_all_elements(module, ret, msg) != 0) {
talloc_free(ret);
return NULL;
}
return ret;
}
for (i=0;attrs[i];i++) {
struct ldb_message_element *el;
if (strcmp(attrs[i], "*") == 0) {
if (msg_add_all_elements(module, ret, msg) != 0) {
talloc_free(ret);
return NULL;
}
continue;
}
if (ldb_attr_cmp(attrs[i], "distinguishedName") == 0) {
if (msg_add_distinguished_name(ret) != 0) {
return NULL;
}
continue;
}
el = ldb_msg_find_element(msg, attrs[i]);
if (!el) {
continue;
}
if (msg_add_element(ret, el, 1) != 0) {
talloc_free(ret);
return NULL;
}
}
return ret;
}
/*
search the database for a single simple dn.
return LDB_ERR_NO_SUCH_OBJECT on record-not-found
@ -345,44 +249,6 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
return LDB_SUCCESS;
}
/*
add a set of attributes from a record to a set of results
return 0 on success, -1 on failure
*/
int ltdb_add_attr_results(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_message *msg,
const char * const attrs[],
unsigned int *count,
struct ldb_message ***res)
{
struct ldb_message *msg2;
struct ldb_message **res2;
/* pull the attributes that the user wants */
msg2 = ltdb_pull_attrs(module, mem_ctx, msg, attrs);
if (!msg2) {
return -1;
}
/* add to the results list */
res2 = talloc_realloc(mem_ctx, *res, struct ldb_message *, (*count)+2);
if (!res2) {
talloc_free(msg2);
return -1;
}
(*res) = res2;
(*res)[*count] = talloc_move(*res, &msg2);
(*res)[(*count)+1] = NULL;
(*count)++;
return 0;
}
/*
filter the specified list of attributes from a message
removing not requested attrs from the new message constructed.

View File

@ -102,12 +102,6 @@ int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name,
void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg,
unsigned int unpack_flags);
int ltdb_add_attr_results(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_message *msg,
const char * const attrs[],
unsigned int *count,
struct ldb_message ***res);
int ltdb_filter_attrs(TALLOC_CTX *mem_ctx,
const struct ldb_message *msg, const char * const *attrs,
struct ldb_message **filtered_msg);