Add tldap_search_va
authorVolker Lendecke <vl@samba.org>
Sun, 28 Jun 2009 12:41:11 +0000 (14:41 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 28 Jun 2009 13:51:02 +0000 (15:51 +0200)
source3/include/tldap_util.h
source3/lib/tldap_util.c

index 9b0393eefcb0d7de10019c639e4742daa2721354..f257afc0b02f27b2ade5eee9ced46595f30036b1 100644 (file)
@@ -45,6 +45,10 @@ bool tldap_make_mod_fmt(struct tldap_message *existing, TALLOC_CTX *mem_ctx,
 
 const char *tldap_errstr(TALLOC_CTX *mem_ctx, struct tldap_context *ld,
                         int rc);
+int tldap_search_va(struct tldap_context *ld, const char *base, int scope,
+                   const char *attrs[], int num_attrs, int attrsonly,
+                   TALLOC_CTX *mem_ctx, struct tldap_message ***res,
+                   const char *fmt, va_list ap);
 int tldap_search_fmt(struct tldap_context *ld, const char *base, int scope,
                     const char *attrs[], int num_attrs, int attrsonly,
                     TALLOC_CTX *mem_ctx, struct tldap_message ***res,
index f4fffb57d4f703b1f78cd54a5b5e8196b6e04cf3..f3a8c71216c2435a9a182d8c406edb7710d6f966 100644 (file)
@@ -325,22 +325,19 @@ const char *tldap_errstr(TALLOC_CTX *mem_ctx, struct tldap_context *ld, int rc)
        return res;
 }
 
-int tldap_search_fmt(struct tldap_context *ld, const char *base, int scope,
-                    const char *attrs[], int num_attrs, int attrsonly,
-                    TALLOC_CTX *mem_ctx, struct tldap_message ***res,
-                    const char *fmt, ...)
+int tldap_search_va(struct tldap_context *ld, const char *base, int scope,
+                   const char *attrs[], int num_attrs, int attrsonly,
+                   TALLOC_CTX *mem_ctx, struct tldap_message ***res,
+                   const char *fmt, va_list ap)
 {
-       va_list ap;
        char *filter;
        int ret;
 
-       va_start(ap, fmt);
        filter = talloc_vasprintf(talloc_tos(), fmt, ap);
-       va_end(ap);
-
        if (filter == NULL) {
                return TLDAP_NO_MEMORY;
        }
+
        ret = tldap_search(ld, base, scope, filter,
                           attrs, num_attrs, attrsonly,
                           NULL /*sctrls*/, 0, NULL /*cctrls*/, 0,
@@ -350,6 +347,21 @@ int tldap_search_fmt(struct tldap_context *ld, const char *base, int scope,
        return ret;
 }
 
+int tldap_search_fmt(struct tldap_context *ld, const char *base, int scope,
+                    const char *attrs[], int num_attrs, int attrsonly,
+                    TALLOC_CTX *mem_ctx, struct tldap_message ***res,
+                    const char *fmt, ...)
+{
+       va_list ap;
+       int ret;
+
+       va_start(ap, fmt);
+       ret = tldap_search_va(ld, base, scope, attrs, num_attrs, attrsonly,
+                             mem_ctx, res, fmt, ap);
+       va_end(ap);
+       return ret;
+}
+
 bool tldap_pull_uint64(struct tldap_message *msg, const char *attr,
                       uint64_t *presult)
 {