lib/util/charset Add convert_string_error()
authorAndrew Bartlett <abartlet@samba.org>
Tue, 12 Apr 2011 00:36:37 +0000 (10:36 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 13 Apr 2011 04:47:08 +0000 (14:47 +1000)
This adds an interface that matches the source3/ convert string code.

Andrew Bartlett

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

index 9e2aa8f1368ef68be35529bad4e89cafba78d858..1078035592af7e2020ea7d95b5acfc903e0f241d 100644 (file)
@@ -174,6 +174,10 @@ bool convert_string(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(charset_t from, charset_t to,
+                         void const *src, size_t srclen,
+                         void *dest, size_t destlen,
+                         size_t *converted_size);
 
 ssize_t iconv_talloc(TALLOC_CTX *mem_ctx, 
                                       smb_iconv_t cd,
index 41549bff8798fe9a7d29eba98e1bb80cce28959c..6737256a95713c5b162318a10cfe559b0312f942 100644 (file)
@@ -701,6 +701,27 @@ _PUBLIC_ bool convert_string(charset_t from, charset_t to,
                                        dest, destlen, converted_size);
 }
 
+/**
+ * Convert string from one encoding to another, making error checking etc
+ *
+ * @param src pointer to source string (multibyte or singlebyte)
+ * @param srclen length of the source string in bytes
+ * @param dest pointer to destination string (multibyte or singlebyte)
+ * @param destlen maximal length allowed for string
+ * @param converted_size the number of bytes occupied in the destination
+ *
+ * @returns true on success, false on fail.
+ **/
+_PUBLIC_ bool convert_string_error(charset_t from, charset_t to,
+                                  void const *src, size_t srclen,
+                                  void *dest, size_t destlen,
+                                  size_t *converted_size)
+{
+       return convert_string_error_handle(get_iconv_handle(), from, to,
+                                          src, srclen,
+                                          dest, destlen, converted_size);
+}
+
 /**
  * Convert between character sets, allocating a new buffer using talloc for the result.
  *