lib/util/charset: remove charset module loading
authorAndrew Bartlett <abartlet@samba.org>
Tue, 20 Sep 2011 02:13:21 +0000 (19:13 -0700)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 20 Sep 2011 04:27:06 +0000 (06:27 +0200)
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

15 files changed:
lib/util/charset/charset.h
lib/util/charset/charset_macosxfs.c
lib/util/charset/charset_proto.h [new file with mode: 0644]
lib/util/charset/codepoints.c
lib/util/charset/iconv.c
lib/util/charset/tests/convert_string.c
lib/util/charset/tests/iconv.c
lib/util/charset/weird.c
lib/util/charset/wscript_build
source3/Makefile.in
source3/configure.in
source4/param/util.c
source4/selftest/knownfail
source4/selftest/tests.py
source4/torture/smbiconv.c

index 2040e2a87cc672bf82d7195aa60e420326344de5..d731ad18213a6eecb086564a06f587c7899f9fc1 100644 (file)
@@ -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  */
 
index 4d2ba5b6ffd5c7f70bd09fc26cabd5b4a5c89b91..dfd142a51e470557175533c5f3ca432c2970abc6 100644 (file)
  */
 
 #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 (file)
index 0000000..3b3187a
--- /dev/null
@@ -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 */
+
+
index 0d1020f7a0bb60edb17d7747ce369c7303641f9d..0984164d4838dffd46a2a4d7d596b06eb0cf937c 100644 (file)
@@ -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);
                }
        }
 
index fd8b8ae8eef700cfd67e7274e4d2f882cbbb8942..1c507b4b13707d1fd3142d09ef79d58593c1ed69 100644 (file)
 #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;
        }
index 2c0fe9fc8f9699b93953ab324bce9b9e35a22352..918be496b6e78cc1b974dd67d960199147c6cbc0 100644 (file)
@@ -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,
index 48702e9c508a602cb901a94e59b6ab33773710f7..670454101619ef1e13a39aa457d51312e5c11a34 100644 (file)
@@ -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, 
index 5db8cdcecd126b91e674589892ff8858fbe2cc59..7f766417dc4833bcbceb4dd5b33fb0625a877455 100644 (file)
@@ -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
index 390a1448fb5533ac34d268dbd07e4ea1ec3e5f05..621fed6c0ebc9bc57e48e4fd31dda16c049c377b 100644 (file)
@@ -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'))
-
-
index 02b7a294f5afb5a533b3197c207bdfff2c4f0e94..d64adb8baaf3f3764876462257ce31262a8d0d9a 100644 (file)
@@ -460,7 +460,8 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) $(LIBTSOCKET_OBJ) \
          lib/ms_fnmatch.o ../lib/util/ms_fnmatch.o lib/errmap_unix.o ../libcli/util/errmap_unix.o \
          lib/tallocmsg.o lib/dmallocmsg.o \
          libsmb/smb_signing.o \
-         ../lib/util/charset/iconv.o intl/lang_tdb.o \
+         ../lib/util/charset/iconv.o ../lib/util/charset/weird.o \
+         ../lib/util/charset/charset_macosxfs.o intl/lang_tdb.o \
          lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \
          lib/sessionid_tdb.o \
          lib/module.o lib/events.o @LIBTEVENT_OBJ0@ \
@@ -2905,14 +2906,6 @@ bin/ldap.@SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_ldap.o $(IDMAP_RW_OBJ)
        @echo "Building plugin $@"
        @$(SHLD_MODULE) winbindd/idmap_ldap.o $(IDMAP_RW_OBJ)
 
-bin/weird.@SHLIBEXT@: $(BINARY_PREREQS) $(DEVEL_HELP_WEIRD_OBJ)
-       @echo "Building plugin $@"
-       @$(SHLD_MODULE) $(DEVEL_HELP_WEIRD_OBJ)
-
-bin/macosxfs.@SHLIBEXT@: $(BINARY_PREREQS) $(CHARSET_MACOSXFS_OBJ)
-       @echo "Building plugin $@"
-       @$(SHLD_MODULE) $(CHARSET_MACOSXFS_OBJ) -framework CoreFoundation
-
 # NOTE, there is no build rule for a dynamic default VFS module because
 # this one MUST MUST MUST be built statically.
 
index 32172faec4101a536b49b8d41e8140435b2d2159..068728578e1fbd03e9c01d692235f1cf3d37b119 100644 (file)
@@ -474,7 +474,7 @@ default_shared_modules="$default_shared_modules idmap_autorid"
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
    default_static_modules="$default_static_modules auth_netlogond"
-   default_shared_modules="$default_shared_modules charset_weird perfcount_test"
+   default_shared_modules="$default_shared_modules perfcount_test"
 fi
 
 #
@@ -683,7 +683,7 @@ main() {
        AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
 
 # Add a system specific charset module.
-       default_shared_modules="$default_shared_modules charset_macosxfs"
+       default_shared_modules="$default_shared_modules"
 
        ;;
     *hurd*)
@@ -6877,8 +6877,6 @@ SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
 SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
 SMB_SUBSYSTEM(NSS_INFO, winbindd/nss_info.o)
 
-SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
-SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
 
 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
index 92672ecba2c6b85dde2814beab5a312e675cece8..d5b9583795869b436a8dbaae16647079dce1cf30 100644 (file)
@@ -351,9 +351,9 @@ struct smb_iconv_handle *smb_iconv_handle_reinit_lp(TALLOC_CTX *mem_ctx,
                                                              struct smb_iconv_handle *old_ic)
 {
        return smb_iconv_handle_reinit(mem_ctx, lpcfg_dos_charset(lp_ctx),
-                                           lpcfg_unix_charset(lp_ctx),
-                                           lpcfg_parm_bool(lp_ctx, NULL, "iconv", "native", true),
-                                           old_ic);
+                                      lpcfg_unix_charset(lp_ctx),
+                                      true,
+                                      old_ic);
 }
 
 
index 0152676b77d24c88efa13726015e7164a1744452..ab1f8170c7e4a87abacfde4b8561ea6d631fce5d 100644 (file)
@@ -5,9 +5,11 @@
 # a successful run for any of these tests an error.
 ^samba4.local.resolve.*.async
 ^samba4.local.iconv.*.next_codepoint()
-^samba4.local.iconv.5M random UTF-16LE sequences # Fails because our CP850 module returns the wrong error codes
-^samba4.local.convert_string_handle.iconv.modules.plato_cp850_utf8
-^samba4.local.convert_string.iconv.modules.plato
+# these show that we still have some differences between our system
+# with our internal iconv because it passes except when we bypass our
+# internal iconv modules
+^samba4.local.convert_string_handle.system.iconv.gd_ascii
+^samba4.local.convert_string_handle.system.iconv.gd_iso8859_cp850
 ^samba4..*base.delete.*.deltest17
 ^samba4..*base.delete.*.deltest20a
 ^samba4..*base.delete.*.deltest20b
index 60e16a5d1684e6be3d99dfb1ce047fa4f75edf00..5b008a0e9d17fbf6b750f03de9bd45c2248e8b29 100755 (executable)
@@ -273,9 +273,9 @@ for t in smb4torture_testsuites("local."):
 
 # Confirm these tests with the system iconv too
 for t in ["local.convert_string_handle", "local.convert_string", "local.ndr"]:
-    modname = "samba4.%s.iconv.modules" % t
-    cmdline = "%s %s %s" % (valgrindify(smb4torture), "ncalrpc: --option='iconv:native=false'", t)
-    plantestsuite_loadlist(modname, env, cmdline)
+    modname = "samba4.%s.system.iconv" % t
+    cmdline = "%s %s %s" % (valgrindify(smb4torture), "ncalrpc: --option='iconv:use_builtin_handlers=false'", t)
+    plantestsuite_loadlist(modname, "none", cmdline)
 
 tdbtorture4 = binpath("tdbtorture")
 if os.path.exists(tdbtorture4):
index f1a7d899a576f17cdcceef634930b447495f486a..45166083b749b10d80520bbd099aea873ae5a040 100644 (file)
@@ -205,7 +205,7 @@ int main(int argc, char *argv[])
                }
        }
 
-       cd = smb_iconv_open_ex(tctx, to, from, lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
+       cd = smb_iconv_open_ex(tctx, to, from, lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true));
        if((int)cd == -1) {
                DEBUG(0,("unable to find from or to encoding, exiting...\n"));
                if (out != stdout) fclose(out);