summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-03-31 10:27:41 +1100
committerAndrew Bartlett <abartlet@samba.org>2011-03-31 10:53:24 +1100
commitd4f3a380e429b9b8a4960a11995846c2b0f8c85d (patch)
tree4beb31b05b9bfe4c66e2bb536e8c4d5f3aa01af5 /lib
parent46db53b1596cccdd22cf44dc376e39601f01c29c (diff)
downloadsamba-d4f3a380e429b9b8a4960a11995846c2b0f8c85d.tar.gz
samba-d4f3a380e429b9b8a4960a11995846c2b0f8c85d.tar.bz2
samba-d4f3a380e429b9b8a4960a11995846c2b0f8c85d.zip
lib/util/charset Add wrapper to allow testing of strlen_m_ext()
This allows test routines to force in particular character sets, and not rely on the smb.conf. Andrew Bartlett
Diffstat (limited to 'lib')
-rw-r--r--lib/util/charset/charset.h8
-rw-r--r--lib/util/charset/util_str.c16
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index 7374d6e2ec..82396e1498 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -111,6 +111,14 @@ struct smb_iconv_handle;
#define strupper(s) strupper_m(s)
char *strchr_m(const char *s, char c);
+/**
+ * Calculate the number of units (8 or 16-bit, depending on the
+ * destination charset), that would be needed to convert the input
+ * string which is expected to be in in src_charset encoding to the
+ * destination charset (which should be a unicode charset).
+ */
+size_t strlen_m_ext_handle(struct smb_iconv_handle *ic,
+ const char *s, charset_t src_charset, charset_t dst_charset);
size_t strlen_m_ext(const char *s, charset_t src_charset, charset_t dst_charset);
size_t strlen_m_ext_term(const char *s, charset_t src_charset,
charset_t dst_charset);
diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c
index ff53b1875e..9aaf651589 100644
--- a/lib/util/charset/util_str.c
+++ b/lib/util/charset/util_str.c
@@ -140,10 +140,10 @@ _PUBLIC_ bool strcsequal(const char *s1,const char *s2)
* string which is expected to be in in src_charset encoding to the
* destination charset (which should be a unicode charset).
*/
-_PUBLIC_ size_t strlen_m_ext(const char *s, charset_t src_charset, charset_t dst_charset)
+_PUBLIC_ size_t strlen_m_ext_handle(struct smb_iconv_handle *ic,
+ const char *s, charset_t src_charset, charset_t dst_charset)
{
size_t count = 0;
- struct smb_iconv_handle *ic = get_iconv_handle();
if (!s) {
return 0;
@@ -203,6 +203,18 @@ _PUBLIC_ size_t strlen_m_ext(const char *s, charset_t src_charset, charset_t dst
return count;
}
+/**
+ * Calculate the number of units (8 or 16-bit, depending on the
+ * destination charset), that would be needed to convert the input
+ * string which is expected to be in in src_charset encoding to the
+ * destination charset (which should be a unicode charset).
+ */
+_PUBLIC_ size_t strlen_m_ext(const char *s, charset_t src_charset, charset_t dst_charset)
+{
+ struct smb_iconv_handle *ic = get_iconv_handle();
+ return strlen_m_ext_handle(ic, s, src_charset, dst_charset);
+}
+
_PUBLIC_ size_t strlen_m_ext_term(const char *s, const charset_t src_charset,
const charset_t dst_charset)
{