From 29ba7765d90eda0b3d0f45f7a970272f0ef2ab2f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 8 Sep 2009 20:57:31 +1000 Subject: s4/ldb: added --show-binary command line option This add --show-binary to ldbsearch. When this flag is set, binary blobs will be shown as-is, instead of base64 encoded. This is useful for some XML encoded attributes, and will also be used as part of some NDR print formatting for attributes like repsTo. --- source4/lib/ldb/common/ldb_ldif.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/common/ldb_ldif.c') diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index 83f08b609b..b73fee1843 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -185,11 +185,15 @@ char *ldb_base64_encode(void *mem_ctx, const char *buf, int len) /* see if a buffer should be base64 encoded */ -int ldb_should_b64_encode(const struct ldb_val *val) +int ldb_should_b64_encode(struct ldb_context *ldb, const struct ldb_val *val) { unsigned int i; uint8_t *p = val->data; + if (ldb->flags & LDB_FLG_SHOW_BINARY) { + return 0; + } + if (val->length == 0) { return 0; } @@ -333,7 +337,7 @@ int ldb_ldif_write(struct ldb_context *ldb, if (ret != LDB_SUCCESS) { v = msg->elements[i].values[j]; } - if (ret != LDB_SUCCESS || ldb_should_b64_encode(&v)) { + if (ret != LDB_SUCCESS || ldb_should_b64_encode(ldb, &v)) { ret = fprintf_fn(private_data, "%s:: ", msg->elements[i].name); CHECK_RET; -- cgit