lib/util/charset Fix and add public interface for convert_string_error_handle
authorAndrew Bartlett <abartlet@samba.org>
Mon, 11 Apr 2011 10:15:53 +0000 (20:15 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 13 Apr 2011 04:47:07 +0000 (14:47 +1000)
It makes much more sense for this to match the source3/ interface and
return a bool.

Andrew Bartlett

Signed-off-by: Andrew Tridgell <tridge@samba.org>
lib/util/charset/charcnv.c
lib/util/charset/charset.h

index cefc788f7941673295bfc440d63850cc181c68cf..998bb08fd710836e4f91198c896091598204d0a7 100644 (file)
@@ -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:
index 3a6e6a321666347a0cc90ec1d6662e75c78494ee..9e2aa8f1368ef68be35529bad4e89cafba78d858 100644 (file)
@@ -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,