* It only knows about a very small number of character sets - just
* enough that Samba works on systems that don't have iconv.
**/
-size_t smb_iconv(smb_iconv_t cd,
+_PUBLIC_ size_t smb_iconv(smb_iconv_t cd,
const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{
strcasecmp(name, "UTF-16LE") == 0;
}
-/*
- simple iconv_open() wrapper
- */
-smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
+
+
+_PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode,
+ const char *fromcode, bool native_iconv)
{
smb_iconv_t ret;
const struct charset_functions *from=NULL, *to=NULL;
int i;
- ret = (smb_iconv_t)talloc_named(NULL, sizeof(*ret),
+ ret = (smb_iconv_t)talloc_named(mem_ctx,
+ sizeof(*ret),
"iconv(%s,%s)", tocode, fromcode);
if (!ret) {
errno = ENOMEM;
}
#ifdef HAVE_NATIVE_ICONV
- if ((!from || !to) && !lp_parm_bool(NULL, "iconv", "native", true)) {
+ if ((!from || !to) && !native_iconv) {
goto failed;
}
if (!from) {
return (smb_iconv_t)-1;
}
+/*
+ simple iconv_open() wrapper
+ */
+_PUBLIC_ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
+{
+ return smb_iconv_open_ex(NULL, tocode, fromcode, true);
+}
+
/*
simple iconv_close() wrapper
*/
-int smb_iconv_close(smb_iconv_t cd)
+_PUBLIC_ int smb_iconv_close(smb_iconv_t cd)
{
#ifdef HAVE_NATIVE_ICONV
if (cd->cd_direct) iconv_close((iconv_t)cd->cd_direct);
return 0;
}
+/*
+ this takes a UTF8 sequence and produces a UTF16 sequence
+ */
static size_t utf8_pull(void *cd, const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{
return -1;
}
+
+/*
+ this takes a UTF16 sequence and produces a UTF8 sequence
+ */
static size_t utf8_push(void *cd, const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{