diff options
Diffstat (limited to 'src/lib-ldap/ldap-iterator.c')
-rw-r--r-- | src/lib-ldap/ldap-iterator.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/lib-ldap/ldap-iterator.c b/src/lib-ldap/ldap-iterator.c new file mode 100644 index 0000000..d825f6c --- /dev/null +++ b/src/lib-ldap/ldap-iterator.c @@ -0,0 +1,29 @@ +/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "ldap-private.h" + +struct ldap_search_iterator* ldap_search_iterator_init(struct ldap_result *result) +{ + struct ldap_search_iterator *iter; + + i_assert(result->openldap_ret == LDAP_SUCCESS); + i_assert(result->error_string == NULL); + + iter = p_new(result->pool, struct ldap_search_iterator, 1); + iter->result = result; + return iter; +} + +const struct ldap_entry *ldap_search_iterator_next(struct ldap_search_iterator *iter) +{ + if (iter->idx >= array_count(&iter->result->entries)) + return NULL; + return array_idx(&iter->result->entries, iter->idx++); +} + +void ldap_search_iterator_deinit(struct ldap_search_iterator **iter) +{ + *iter = NULL; +} |