From cd63c9205e79df250c4d4fefb35c917701fd7db6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 11 Apr 2011 20:15:53 +1000 Subject: lib/util/charset Fix and add public interface for convert_string_error_handle It makes much more sense for this to match the source3/ interface and return a bool. Andrew Bartlett Signed-off-by: Andrew Tridgell --- lib/util/charset/charcnv.c | 15 ++++++++------- lib/util/charset/charset.h | 6 ++++++ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c index cefc788f79..998bb08fd7 100644 --- a/lib/util/charset/charcnv.c +++ b/lib/util/charset/charcnv.c @@ -124,10 +124,11 @@ convert: * @returns the number of bytes occupied in the destination * on error, returns -1, and sets errno **/ -_PUBLIC_ ssize_t convert_string_error_handle(struct smb_iconv_handle *ic, - charset_t from, charset_t to, - void const *src, size_t srclen, - void *dest, size_t destlen, size_t *converted_size) +_PUBLIC_ bool convert_string_error_handle(struct smb_iconv_handle *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen, + size_t *converted_size) { size_t i_len, o_len; ssize_t retval; @@ -154,7 +155,7 @@ _PUBLIC_ ssize_t convert_string_error_handle(struct smb_iconv_handle *ic, if (converted_size != NULL) *converted_size = destlen-o_len; - return retval; + return (retval != (ssize_t)-1); } @@ -172,10 +173,10 @@ _PUBLIC_ bool convert_string_handle(struct smb_iconv_handle *ic, void const *src, size_t srclen, void *dest, size_t destlen, size_t *converted_size) { - ssize_t retval; + bool retval; retval = convert_string_error_handle(ic, from, to, src, srclen, dest, destlen, converted_size); - if(retval==(size_t)-1) { + if(retval==false) { const char *reason; switch(errno) { case EINVAL: diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index 3a6e6a3216..9e2aa8f136 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -222,6 +222,12 @@ bool convert_string_handle(struct smb_iconv_handle *ic, charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t destlen, size_t *converted_size); +bool convert_string_error_handle(struct smb_iconv_handle *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen, + size_t *converted_size); + bool convert_string_talloc_handle(TALLOC_CTX *ctx, struct smb_iconv_handle *ic, charset_t from, charset_t to, -- cgit