diff options
author | Simo Sorce <idra@samba.org> | 2005-08-18 16:18:48 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:33:33 -0500 |
commit | ac90ddfdb28050912ecab0e998089b93216c5c35 (patch) | |
tree | cb37f9654b81ec3575466689cd130dd8c92b48fd /source4/lib/ldb/common | |
parent | 3e4c4cff2177af33efdb15f03a1bbcb639505cee (diff) | |
download | samba-ac90ddfdb28050912ecab0e998089b93216c5c35.tar.gz samba-ac90ddfdb28050912ecab0e998089b93216c5c35.tar.bz2 samba-ac90ddfdb28050912ecab0e998089b93216c5c35.zip |
r9392: Fix ldb_dn_compose to make build farm happy
Add ldb_dn_string_compose so that you can build a dn starting from a
struct ldb_dn base and a set of parameters to be composed in a format
string with the same syntax of printf
(This used to be commit 31c69d0655752cc8ea3bc5b7ea87792291302091)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb_dn.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index dae79fd9e1..df95e37dac 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -771,7 +771,9 @@ struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const str new->comp_num = dn1->comp_num; new->components = talloc_array(new, struct ldb_dn_component, new->comp_num); } else { - new = ldb_dn_copy_partial(mem_ctx, dn2, dn2->comp_num + dn1?dn1->comp_num:0); + int comp_num = dn2->comp_num; + if (dn1 != NULL) comp_num += dn1->comp_num; + new = ldb_dn_copy_partial(mem_ctx, dn2, comp_num); } if (dn1 == NULL) { @@ -790,11 +792,26 @@ failed: return NULL; } -struct ldb_dn *ldb_dn_compose_string_dn(void *mem_ctx, const char *dn1, const struct ldb_dn *dn2) +struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...) { - if (dn1 == NULL) return NULL; + struct ldb_dn *dn; + char *child_str; + va_list ap; + int ret; + + if (child_fmt == NULL) return NULL; + + va_start(ap, child_fmt); + ret = vasprintf(&child_str, child_fmt, ap); + va_end(ap); + + if (ret <= 0) return NULL; - return ldb_dn_compose(mem_ctx, ldb_dn_explode(mem_ctx, dn1), dn2); + dn = ldb_dn_compose(mem_ctx, ldb_dn_explode(mem_ctx, child_str), base); + + free(child_str); + + return dn; } struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn) |