diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-09-19 19:13:21 -0700 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-09-20 06:27:06 +0200 |
commit | f9acf770e9c121aa495cb7e19175a4a6e45ff3d9 (patch) | |
tree | b64283a8a0f929f28de73f84ef207f5f5018f8f9 /lib | |
parent | 8316577b7538f7204c5fd6328756c4c3f171b36e (diff) | |
download | samba-f9acf770e9c121aa495cb7e19175a4a6e45ff3d9.tar.gz samba-f9acf770e9c121aa495cb7e19175a4a6e45ff3d9.tar.bz2 samba-f9acf770e9c121aa495cb7e19175a4a6e45ff3d9.zip |
lib/util/charset: remove charset module loading
Now that the 'table' modules are gone, there is no reason for there to
be charset modules at all. This builds the macosxfs and weird modules
into the binary at the appropriate times, and changes the tests to
test instead the difference between the remaining internal handlers
and iconv().
Andrew Bartlett
Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Tue Sep 20 06:27:06 CEST 2011 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/charset/charset.h | 9 | ||||
-rw-r--r-- | lib/util/charset/charset_macosxfs.c | 26 | ||||
-rw-r--r-- | lib/util/charset/charset_proto.h | 36 | ||||
-rw-r--r-- | lib/util/charset/codepoints.c | 14 | ||||
-rw-r--r-- | lib/util/charset/iconv.c | 115 | ||||
-rw-r--r-- | lib/util/charset/tests/convert_string.c | 22 | ||||
-rw-r--r-- | lib/util/charset/tests/iconv.c | 7 | ||||
-rw-r--r-- | lib/util/charset/weird.c | 25 | ||||
-rw-r--r-- | lib/util/charset/wscript_build | 23 |
9 files changed, 105 insertions, 172 deletions
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index 2040e2a87c..d731ad1821 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -59,7 +59,7 @@ struct charset_functions { char **outbuf, size_t *outbytesleft); size_t (*push)(void *, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); - struct charset_functions *prev, *next; + bool samba_internal_charset; }; /* this type is used for manipulating unicode codepoints */ @@ -171,7 +171,7 @@ struct smb_iconv_handle *get_iconv_handle(void); struct smb_iconv_handle *get_iconv_testing_handle(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, - bool native_iconv); + bool use_builtin_handlers); smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic, charset_t from, charset_t to); const char *charset_name(struct smb_iconv_handle *ic, charset_t ch); @@ -200,7 +200,7 @@ int codepoint_cmpi(codepoint_t c1, codepoint_t c2); struct smb_iconv_handle *smb_iconv_handle_reinit(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, - bool native_iconv, + bool use_builtin_handlers, struct smb_iconv_handle *old_ic); bool convert_string_handle(struct smb_iconv_handle *ic, @@ -225,11 +225,10 @@ size_t smb_iconv(smb_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, - const char *fromcode, bool native_iconv); + const char *fromcode, bool use_builtin_handlers); void load_case_tables(void); void load_case_tables_library(void); -bool smb_register_charset(const struct charset_functions *funcs_in); /* The following definitions come from util_unistr_w.c */ diff --git a/lib/util/charset/charset_macosxfs.c b/lib/util/charset/charset_macosxfs.c index 4d2ba5b6ff..dfd142a51e 100644 --- a/lib/util/charset/charset_macosxfs.c +++ b/lib/util/charset/charset_macosxfs.c @@ -30,8 +30,11 @@ */ #include "includes.h" +#include "charset_proto.h" #undef realloc +#ifdef DARWIN + /* * Include OS frameworks. These are only needed in this module. */ @@ -201,7 +204,7 @@ static void hexdump( const char * label, const char * s, size_t len ) * generic, not specifically for the file system. So they may not be * perfect fits. */ -static size_t macosxfs_encoding_pull( +size_t macosxfs_encoding_pull( void *cd, /* Encoder handle */ char **inbuf, size_t *inbytesleft, /* Script string */ char **outbuf, size_t *outbytesleft) /* UTF-16-LE string */ @@ -323,7 +326,7 @@ static size_t macosxfs_encoding_pull( return 0; } -static size_t macosxfs_encoding_push( +size_t macosxfs_encoding_push( void *cd, /* Encoder handle */ char **inbuf, size_t *inbytesleft, /* UTF-16-LE string */ char **outbuf, size_t *outbytesleft) /* Script string */ @@ -587,19 +590,12 @@ static size_t macosxfs_encoding_push( #endif /* USE_INTERNAL_API */ -/* - * For initialization, actually install the encoding as "macosxfs". - */ -static struct charset_functions macosxfs_encoding_functions = { - "MACOSXFS", macosxfs_encoding_pull, macosxfs_encoding_push -}; - -NTSTATUS charset_macosxfs_init(void) +#else /* DARWIN */ + +void charset_macosfs_dummy(void); +void charset_macosfs_dummy(void) { - if (!smb_register_charset(&macosxfs_encoding_functions)) { - return NT_STATUS_INTERNAL_ERROR; - } - return NT_STATUS_OK; + return; } -/* eof */ +#endif /* DARWIN */ diff --git a/lib/util/charset/charset_proto.h b/lib/util/charset/charset_proto.h new file mode 100644 index 0000000000..3b3187a6eb --- /dev/null +++ b/lib/util/charset/charset_proto.h @@ -0,0 +1,36 @@ +/* + Unix SMB/CIFS implementation. + Samba charset modules + Copyright (C) Andrew Tridgell 2001 + Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Benjamin Riefenstahl 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); +size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); + +size_t macosxfs_encoding_pull( + void *cd, /* Encoder handle */ + char **inbuf, size_t *inbytesleft, /* Script string */ + char **outbuf, size_t *outbytesleft); /* UTF-16-LE string */ +size_t macosxfs_encoding_push( + void *cd, /* Encoder handle */ + char **inbuf, size_t *inbytesleft, /* UTF-16-LE string */ + char **outbuf, size_t *outbytesleft); /* Script string */ + + diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c index 0d1020f7a0..0984164d48 100644 --- a/lib/util/charset/codepoints.c +++ b/lib/util/charset/codepoints.c @@ -158,7 +158,7 @@ struct smb_iconv_handle { const char *unix_charset; const char *dos_charset; const char *display_charset; - bool native_iconv; + bool use_builtin_handlers; smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS]; }; @@ -175,10 +175,10 @@ struct smb_iconv_handle *get_iconv_handle(void) struct smb_iconv_handle *get_iconv_testing_handle(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, - bool native_iconv) + bool use_builtin_handlers) { return smb_iconv_handle_reinit(mem_ctx, - dos_charset, unix_charset, native_iconv, NULL); + dos_charset, unix_charset, use_builtin_handlers, NULL); } /** @@ -229,7 +229,7 @@ static int close_iconv_handle(struct smb_iconv_handle *data) _PUBLIC_ struct smb_iconv_handle *smb_iconv_handle_reinit(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, - bool native_iconv, + bool use_builtin_handlers, struct smb_iconv_handle *old_ic) { struct smb_iconv_handle *ret; @@ -262,7 +262,7 @@ _PUBLIC_ struct smb_iconv_handle *smb_iconv_handle_reinit(TALLOC_CTX *mem_ctx, ret->dos_charset = talloc_strdup(ret->child_ctx, dos_charset); ret->unix_charset = talloc_strdup(ret->child_ctx, unix_charset); - ret->native_iconv = native_iconv; + ret->use_builtin_handlers = use_builtin_handlers; return ret; } @@ -283,7 +283,7 @@ smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic, n2 = charset_name(ic, to); ic->conv_handles[from][to] = smb_iconv_open_ex(ic, n2, n1, - ic->native_iconv); + ic->use_builtin_handlers); if (ic->conv_handles[from][to] == (smb_iconv_t)-1) { if ((from == CH_DOS || to == CH_DOS) && @@ -296,7 +296,7 @@ smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic, n2 = charset_name(ic, to); ic->conv_handles[from][to] = - smb_iconv_open_ex(ic, n2, n1, ic->native_iconv); + smb_iconv_open_ex(ic, n2, n1, ic->use_builtin_handlers); } } diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c index fd8b8ae8ee..1c507b4b13 100644 --- a/lib/util/charset/iconv.c +++ b/lib/util/charset/iconv.c @@ -22,15 +22,12 @@ #include "../lib/util/dlinklist.h" #include "system/iconv.h" #include "system/filesys.h" +#include "charset_proto.h" #ifdef strcasecmp #undef strcasecmp #endif -#ifdef static_decl_charset -static_decl_charset; -#endif - /** * @file * @@ -78,65 +75,20 @@ static const struct charset_functions builtin_functions[] = { {"UTF-8", utf8_pull, utf8_push}, /* this handles the munging needed for String2Key */ - {"UTF16_MUNGED", utf16_munged_pull, iconv_copy}, + {"UTF16_MUNGED", utf16_munged_pull, iconv_copy, true}, {"ASCII", ascii_pull, ascii_push}, {"646", ascii_pull, ascii_push}, {"ISO-8859-1", latin1_pull, latin1_push}, - {"UCS2-HEX", ucs2hex_pull, ucs2hex_push} -}; - -static struct charset_functions *charsets = NULL; - -static struct charset_functions *find_charset_functions(const char *name) -{ - struct charset_functions *c; - - /* Check whether we already have this charset... */ - for (c = charsets; c != NULL; c = c->next) { - if(strcasecmp(c->name, name) == 0) { - return c; - } - } - - return NULL; -} - -bool smb_register_charset(const struct charset_functions *funcs_in) -{ - struct charset_functions *funcs; - - DEBUG(5, ("Attempting to register new charset %s\n", funcs_in->name)); - /* Check whether we already have this charset... */ - if (find_charset_functions(funcs_in->name)) { - DEBUG(0, ("Duplicate charset %s, not registering\n", funcs_in->name)); - return false; - } - - funcs = talloc(NULL, struct charset_functions); - if (!funcs) { - DEBUG(0, ("Out of memory duplicating charset %s\n", funcs_in->name)); - return false; - } - *funcs = *funcs_in; - - funcs->next = funcs->prev = NULL; - DEBUG(5, ("Registered charset %s\n", funcs->name)); - DLIST_ADD(charsets, funcs); - return true; -} - -static void lazy_initialize_iconv(void) -{ -#ifdef static_init_charset - static bool initialized = false; - - if (!initialized) { - static_init_charset; - initialized = true; - } +#ifdef DEVELOPER + {"WEIRD", weird_pull, weird_push, true}, #endif -} +#ifdef DARWINOS + {"MACOSXFS", macosxfs_encoding_pull, macosxfs_encoding_push, true}, +#endif + {"UCS2-HEX", ucs2hex_pull, ucs2hex_push, true} + +}; #ifdef HAVE_NATIVE_ICONV /* if there was an error then reset the internal state, @@ -244,14 +196,12 @@ static int smb_iconv_t_destructor(smb_iconv_t hwd) } _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, - const char *fromcode, bool allow_native_iconv) + const char *fromcode, bool use_builtin_handlers) { smb_iconv_t ret; const struct charset_functions *from=NULL, *to=NULL; int i; - lazy_initialize_iconv(); - ret = (smb_iconv_t)talloc_named(mem_ctx, sizeof(*ret), "iconv(%s,%s)", tocode, fromcode); @@ -271,10 +221,14 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, /* check if we have a builtin function for this conversion */ for (i=0;i<ARRAY_SIZE(builtin_functions);i++) { if (strcasecmp(fromcode, builtin_functions[i].name) == 0) { - from = &builtin_functions[i]; + if (use_builtin_handlers || builtin_functions[i].samba_internal_charset) { + from = &builtin_functions[i]; + } } - if (strcasecmp(tocode, builtin_functions[i].name) == 0) { - to = &builtin_functions[i]; + if (strcasecmp(tocode, builtin_functions[i].name) == 0) { + if (use_builtin_handlers || builtin_functions[i].samba_internal_charset) { + to = &builtin_functions[i]; + } } } @@ -284,7 +238,7 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, * initialised only in this block for iconv based * conversions */ - if (allow_native_iconv && from == NULL) { + if (from == NULL) { ret->cd_pull = iconv_open("UTF-16LE", fromcode); if (ret->cd_pull == (iconv_t)-1) ret->cd_pull = iconv_open("UCS-2LE", fromcode); @@ -293,7 +247,7 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, } } - if (allow_native_iconv && to == NULL) { + if (to == NULL) { ret->cd_push = iconv_open(tocode, "UTF-16LE"); if (ret->cd_push == (iconv_t)-1) ret->cd_push = iconv_open(tocode, "UCS-2LE"); @@ -303,35 +257,6 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, } #endif - /* If iconv was unable to provide the conversion, or if use of - * it was disabled, and it wasn't a builtin charset, try a - * module */ - if (ret->pull == NULL && from == NULL) { - from = find_charset_functions(fromcode); - } - - if (ret->push == NULL && to == NULL) { - to = find_charset_functions(tocode); - } - - /* In the WAF builds, all charset modules are linked in at compile - * time, as we have shared libs. Using run-time loading as well will - * cause dependency loops. For the autoconf build, try loading from a module */ -#ifndef _SAMBA_WAF_BUILD_ - /* check if there is a module available that can do this conversion */ - if (from == NULL && ret->pull == NULL && NT_STATUS_IS_OK(smb_probe_module("charset", fromcode))) { - if (!(from = find_charset_functions(fromcode))) { - DEBUG(0, ("Module %s doesn't provide charset %s!\n", fromcode, fromcode)); - } - } - - if (to == NULL && ret->push == NULL && NT_STATUS_IS_OK(smb_probe_module("charset", tocode))) { - if (!(to = find_charset_functions(tocode))) { - DEBUG(0, ("Module %s doesn't provide charset %s!\n", tocode, tocode)); - } - } -#endif - if (ret->pull == NULL && from == NULL) { goto failed; } diff --git a/lib/util/charset/tests/convert_string.c b/lib/util/charset/tests/convert_string.c index 2c0fe9fc8f..918be496b6 100644 --- a/lib/util/charset/tests/convert_string.c +++ b/lib/util/charset/tests/convert_string.c @@ -107,7 +107,7 @@ static bool test_gd_iso8859_cp850_handle(struct torture_context *tctx) talloc_steal(tctx, gd_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -300,7 +300,7 @@ static bool test_gd_minus_1_handle(struct torture_context *tctx) talloc_steal(tctx, gd_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "CP850", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); gd_utf8_terminated = data_blob_talloc(tctx, NULL, gd_utf8.length + 1); @@ -485,7 +485,7 @@ static bool test_gd_ascii_handle(struct torture_context *tctx) talloc_steal(tctx, gd_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -555,7 +555,7 @@ static bool test_plato_english_iso8859_cp850_handle(struct torture_context *tctx talloc_steal(tctx, plato_english_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -674,7 +674,7 @@ static bool test_plato_english_minus_1_handle(struct torture_context *tctx) talloc_steal(tctx, plato_english_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); plato_english_utf8_terminated = data_blob_talloc(tctx, NULL, plato_english_utf8.length + 1); @@ -816,7 +816,7 @@ static bool test_plato_minus_1_handle(struct torture_context *tctx) talloc_steal(tctx, plato_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); plato_utf8_terminated = data_blob_talloc(tctx, NULL, plato_utf8.length + 1); @@ -931,7 +931,7 @@ static bool test_plato_cp850_utf8_handle(struct torture_context *tctx) talloc_steal(tctx, plato_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "creating iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -1123,7 +1123,7 @@ static bool test_plato_latin_cp850_utf8_handle(struct torture_context *tctx) talloc_steal(tctx, plato_latin_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "creating iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -1192,7 +1192,7 @@ static bool test_gd_case_utf8_handle(struct torture_context *tctx) talloc_steal(tctx, gd_utf8.data); iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting utf8 iconv handle"); torture_assert(tctx, @@ -1256,7 +1256,7 @@ static bool test_gd_case_cp850_handle(struct torture_context *tctx) talloc_steal(tctx, gd_cp850.data); iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting cp850 iconv handle"); torture_assert(tctx, @@ -1318,7 +1318,7 @@ static bool test_plato_case_utf8_handle(struct torture_context *tctx) talloc_steal(tctx, plato_utf8.data); iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting utf8 iconv handle"); torture_assert(tctx, diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c index 48702e9c50..6704541016 100644 --- a/lib/util/charset/tests/iconv.c +++ b/lib/util/charset/tests/iconv.c @@ -35,9 +35,6 @@ static bool iconv_untestable(struct torture_context *tctx) { iconv_t cd; - if (!lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)) - torture_skip(tctx, "system iconv disabled - skipping test"); - cd = iconv_open("UTF-16LE", "UCS-4LE"); if (cd == (iconv_t)-1) torture_skip(tctx, "unable to test - system iconv library does not support UTF-16LE -> UCS-4LE"); @@ -158,14 +155,14 @@ static bool test_buffer(struct torture_context *test, "failed to open %s to UTF-16LE", charset)); } - cd2 = smb_iconv_open_ex(test, charset, "UTF-16LE", false); + cd2 = smb_iconv_open_ex(test, charset, "UTF-16LE", lpcfg_parm_bool(test->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); if (cd2 == (iconv_t)-1) { torture_fail(test, talloc_asprintf(test, "failed to open %s to UTF-16LE via smb_iconv_open_ex", charset)); } - cd3 = smb_iconv_open_ex(test, "UTF-16LE", charset, false); + cd3 = smb_iconv_open_ex(test, "UTF-16LE", charset, lpcfg_parm_bool(test->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); if (cd3 == (iconv_t)-1) { torture_fail(test, talloc_asprintf(test, diff --git a/lib/util/charset/weird.c b/lib/util/charset/weird.c index 5db8cdcecd..7f766417dc 100644 --- a/lib/util/charset/weird.c +++ b/lib/util/charset/weird.c @@ -19,6 +19,9 @@ */ #include "includes.h" +#include "charset_proto.h" + +#ifdef DEVELOPER static struct { char from; @@ -30,8 +33,8 @@ static struct { {0, NULL} }; -static size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) +size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft) { while (*inbytesleft >= 1 && *outbytesleft >= 2) { int i; @@ -73,8 +76,8 @@ static size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft, return 0; } -static size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) +size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft) { int ir_count=0; @@ -122,13 +125,11 @@ static size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft, return ir_count; } -struct charset_functions weird_functions = {"WEIRD", weird_pull, weird_push}; - -NTSTATUS charset_weird_init(void); -NTSTATUS charset_weird_init(void) +#else +void charset_weird_dummy(void); +void charset_weird_dummy(void) { - if (!smb_register_charset(&weird_functions)) { - return NT_STATUS_INTERNAL_ERROR; - } - return NT_STATUS_OK; + return; } + +#endif diff --git a/lib/util/charset/wscript_build b/lib/util/charset/wscript_build index 390a1448fb..621fed6c0e 100644 --- a/lib/util/charset/wscript_build +++ b/lib/util/charset/wscript_build @@ -6,27 +6,6 @@ bld.SAMBA_SUBSYSTEM('ICONV_WRAPPER', bld.SAMBA_SUBSYSTEM('charset', public_headers='charset.h', - source='codepoints.c convert_string.c util_str.c util_unistr_w.c charcnv.c pull_push.c util_unistr.c', + source='codepoints.c convert_string.c util_str.c util_unistr_w.c charcnv.c pull_push.c util_unistr.c weird.c charset_macosxfs.c', deps='DYNCONFIG ICONV_WRAPPER', public_deps='talloc') - -# In the WAF builds, all charset modules are linked in at compile -# time, as we have shared libs. Using run-time loading as well will -# cause dependency loops - -bld.SAMBA_MODULE('charset_weird', - subsystem='charset', - source='weird.c', - init_function='charset_weird_init', - deps='samba-util', - internal_module=True, - enabled=bld.SAMBA3_IS_ENABLED_MODULE('charset_weird')) - -bld.SAMBA_MODULE('charset_macosxfs', - subsystem='charset', - source='charset_macosxfs.c', - init_function='charset_macosxfs_init', - internal_module=True, - enabled=bld.SAMBA3_IS_ENABLED_MODULE('charset_macosxfs')) - - |