ldb_tdb: Remove unused function ltdb_add_attr_results
authorJakub Hrozek <jakub.hrozek@posteo.se>
Mon, 11 May 2015 20:24:01 +0000 (22:24 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 19 Apr 2017 13:46:25 +0000 (15:46 +0200)
Signed-off-by: Jakub Hrozek <jakub.hrozek@posteo.se>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
lib/ldb/ldb_tdb/ldb_search.c
lib/ldb/ldb_tdb/ldb_tdb.h

index 373855fd428bcddf930bcfd41084c10cd77e7f71..53355e04f6b0899086db498c89df218887684d93 100644 (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.
index 7caedebe4c7a0f3ad6401260dbf63d21672b8f37..26ae68e89c86e7dc0a805c0ffa770d704a22a17a 100644 (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);