From 56cc32800036472ebc29362d65e422c0b410e3fc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 19 Jun 2005 01:31:27 +0000 Subject: r7740: get rid of our duplicate base64 routines (This used to be commit cf17f90a83cf04815544c5408eb56d00546b3e88) --- source4/lib/ldb/common/ldb_ldif.c | 8 ++++---- source4/lib/ldb/include/ldb.h | 2 ++ source4/lib/ldb/include/ldb_private.h | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb') diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index 225fa3f3c9..9492aa3634 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -46,7 +46,7 @@ this base64 decoder was taken from jitterbug (written by tridge). we might need to replace it with a new version */ -static int base64_decode(char *s) +int ldb_base64_decode(char *s) { const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int bit_offset, byte_offset, idx, i, n; @@ -92,7 +92,7 @@ static int base64_decode(char *s) encode as base64 caller frees */ -char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len) +char *ldb_base64_encode(void *mem_ctx, const char *buf, int len) { const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int bit_offset, byte_offset, idx, i; @@ -100,7 +100,7 @@ char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len) int bytes = (len*8 + 5)/6; char *out; - out = talloc_array(ldb, char, bytes+2); + out = talloc_array(mem_ctx, char, bytes+2); if (!out) return NULL; for (i=0;idata); + int len = ldb_base64_decode(value->data); if (len == -1) { /* it wasn't valid base64 data */ return -1; diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index ecfa77f436..e980633a62 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -270,6 +270,8 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char *s); int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); +char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); +int ldb_base64_decode(char *s); /* useful functions for ldb_message structure manipulation */ diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 76a43cdbc2..92588e13fd 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -116,7 +116,6 @@ const char *ldb_next_errstring(struct ldb_module *module); void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); /* The following definitions come from lib/ldb/common/ldb_ldif.c */ -char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len); int ldb_should_b64_encode(const struct ldb_val *val); int ltdb_connect(struct ldb_context *ldb, const char *url, -- cgit