Merge branch 'master' of ssh://git.samba.org/data/git/samba
authorJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 02:19:08 +0000 (04:19 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 02:19:08 +0000 (04:19 +0200)
51 files changed:
lib/talloc/pytalloc.c [moved from source4/scripting/python/pytalloc.c with 96% similarity]
lib/talloc/pytalloc.h [moved from source4/scripting/python/pytalloc.h with 100% similarity]
lib/util/charset/charcnv.c [moved from source4/lib/charset/charcnv.c with 54% similarity]
lib/util/charset/charset.h [moved from source4/lib/charset/charset.h with 79% similarity]
lib/util/charset/codepoints.c [new file with mode: 0644]
lib/util/charset/config.m4 [moved from source4/lib/charset/config.m4 with 100% similarity]
lib/util/charset/config.mk [moved from source4/lib/charset/config.mk with 73% similarity]
lib/util/charset/iconv.c [moved from source4/lib/charset/iconv.c with 100% similarity]
lib/util/charset/tests/charset.c [moved from source4/lib/charset/tests/charset.c with 79% similarity]
lib/util/charset/tests/iconv.c [moved from source4/lib/charset/tests/iconv.c with 100% similarity]
lib/util/charset/util_unistr.c [new file with mode: 0644]
lib/util/util.h
librpc/ndr/libndr.h
pidl/lib/Parse/Pidl/Samba4/Python.pm
source3/samba4.m4
source3/samba4.mk
source4/Makefile
source4/auth/ntlm/auth_util.c
source4/auth/ntlmssp/ntlmssp_client.c
source4/auth/ntlmssp/ntlmssp_parse.c
source4/auth/ntlmssp/ntlmssp_server.c
source4/auth/ntlmssp/ntlmssp_sign.c
source4/configure.ac
source4/dsdb/schema/schema_syntax.c
source4/kdc/kpasswdd.c
source4/lib/charset/util_unistr.c [deleted file]
source4/lib/tdr/tdr.h
source4/libcli/auth/smbencrypt.c
source4/libcli/raw/clitree.c
source4/libcli/raw/rawrequest.c
source4/libcli/smb_composite/sesssetup.c
source4/libnet/libnet_user.h
source4/main.mk
source4/nsswitch/wbinfo.c
source4/ntvfs/posix/pvfs_util.c
source4/ntvfs/print/vfs_print.c
source4/scripting/python/config.mk
source4/smb_server/blob.c
source4/smb_server/smb/nttrans.c
source4/smb_server/smb/request.c
source4/smb_server/smb2/fileio.c
source4/static_deps.mk
source4/torture/basic/scanner.c
source4/torture/local/config.mk
source4/torture/rap/rap.c
source4/torture/rpc/netlogon.c
source4/torture/rpc/samba3rpc.c
source4/torture/rpc/samlogon.c
source4/torture/rpc/schannel.c
source4/torture/rpc/wkssvc.c
source4/winbind/wb_pam_auth.c

similarity index 96%
rename from source4/scripting/python/pytalloc.c
rename to lib/talloc/pytalloc.c
index ca476e9604552f0582614a1adfb61f5525292879..f4b7d10e9711b1b6541a4a2091793cbfac5ad764 100644 (file)
@@ -17,8 +17,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
-#include "scripting/python/pytalloc.h"
+#include <talloc.h>
+#include "../lib/talloc/pytalloc.h"
 
 void py_talloc_dealloc(PyObject* self)
 {
similarity index 54%
rename from source4/lib/charset/charcnv.c
rename to lib/util/charset/charcnv.c
index 3e384304cf55811b3583797bbf934de2f1896699..91a16a1cdae4c8f1b973afafbdc6bdfa98dc3c05 100644 (file)
@@ -22,7 +22,6 @@
 */
 #include "includes.h"
 #include "system/iconv.h"
-#include "param/param.h"
 
 /**
  * @file
@@ -66,7 +65,7 @@ static const char *charset_name(struct smb_iconv_convenience *ic, charset_t ch)
 /**
  re-initialize iconv conversion descriptors
 **/
-static int close_iconv(struct smb_iconv_convenience *data)
+static int close_iconv_convenience(struct smb_iconv_convenience *data)
 {
        unsigned c1, c2;
        for (c1=0;c1<NUM_CHARSETS;c1++) {
@@ -95,7 +94,7 @@ _PUBLIC_ struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *me
                return NULL;
        }
 
-       talloc_set_destructor(ret, close_iconv);
+       talloc_set_destructor(ret, close_iconv_convenience);
 
        ret->dos_charset = talloc_strdup(ret, dos_charset);
        ret->unix_charset = talloc_strdup(ret, unix_charset);
@@ -313,329 +312,6 @@ _PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx,
        return convert_string_talloc_descriptor(ctx, descriptor, src, srclen, dest);
 }
 
-/**
- * Copy a string from a char* unix src to a dos codepage string destination.
- *
- * @return the number of bytes occupied by the string in the destination.
- *
- * @param flags can include
- * <dl>
- * <dt>STR_TERMINATE</dt> <dd>means include the null termination</dd>
- * <dt>STR_UPPER</dt> <dd>means uppercase in the destination</dd>
- * </dl>
- *
- * @param dest_len the maximum length in bytes allowed in the
- * destination.  If @p dest_len is -1 then no maximum is used.
- **/
-static ssize_t push_ascii(struct smb_iconv_convenience *ic, 
-                         void *dest, const char *src, size_t dest_len, int flags)
-{
-       size_t src_len;
-       ssize_t ret;
-
-       if (flags & STR_UPPER) {
-               char *tmpbuf = strupper_talloc(NULL, src);
-               if (tmpbuf == NULL) {
-                       return -1;
-               }
-               ret = push_ascii(ic, dest, tmpbuf, dest_len, flags & ~STR_UPPER);
-               talloc_free(tmpbuf);
-               return ret;
-       }
-
-       src_len = strlen(src);
-
-       if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII))
-               src_len++;
-
-       return convert_string(ic, CH_UNIX, CH_DOS, src, src_len, dest, dest_len);
-}
-
-/**
- * Copy a string from a unix char* src to an ASCII destination,
- * allocating a buffer using talloc().
- *
- * @param dest always set at least to NULL 
- *
- * @returns The number of bytes occupied by the string in the destination
- *         or -1 in case of error.
- **/
-_PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src)
-{
-       size_t src_len = strlen(src)+1;
-       *dest = NULL;
-       return convert_string_talloc(ctx, ic, CH_UNIX, CH_DOS, src, src_len, (void **)dest);
-}
-
-
-/**
- * Copy a string from a dos codepage source to a unix char* destination.
- *
- * The resulting string in "dest" is always null terminated.
- *
- * @param flags can have:
- * <dl>
- * <dt>STR_TERMINATE</dt>
- * <dd>STR_TERMINATE means the string in @p src
- * is null terminated, and src_len is ignored.</dd>
- * </dl>
- *
- * @param src_len is the length of the source area in bytes.
- * @returns the number of bytes occupied by the string in @p src.
- **/
-static ssize_t pull_ascii(struct smb_iconv_convenience *ic, char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
-{
-       size_t ret;
-
-       if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII)) {
-               if (src_len == (size_t)-1) {
-                       src_len = strlen((const char *)src) + 1;
-               } else {
-                       size_t len = strnlen((const char *)src, src_len);
-                       if (len < src_len)
-                               len++;
-                       src_len = len;
-               }
-       }
-
-       ret = convert_string(ic, CH_DOS, CH_UNIX, src, src_len, dest, dest_len);
-
-       if (dest_len)
-               dest[MIN(ret, dest_len-1)] = 0;
-
-       return src_len;
-}
-
-/**
- * Copy a string from a char* src to a unicode destination.
- *
- * @returns the number of bytes occupied by the string in the destination.
- *
- * @param flags can have:
- *
- * <dl>
- * <dt>STR_TERMINATE <dd>means include the null termination.
- * <dt>STR_UPPER     <dd>means uppercase in the destination.
- * <dt>STR_NOALIGN   <dd>means don't do alignment.
- * </dl>
- *
- * @param dest_len is the maximum length allowed in the
- * destination. If dest_len is -1 then no maxiumum is used.
- **/
-static ssize_t push_ucs2(struct smb_iconv_convenience *ic, 
-                        void *dest, const char *src, size_t dest_len, int flags)
-{
-       size_t len=0;
-       size_t src_len = strlen(src);
-       size_t ret;
-
-       if (flags & STR_UPPER) {
-               char *tmpbuf = strupper_talloc(NULL, src);
-               if (tmpbuf == NULL) {
-                       return -1;
-               }
-               ret = push_ucs2(ic, dest, tmpbuf, dest_len, flags & ~STR_UPPER);
-               talloc_free(tmpbuf);
-               return ret;
-       }
-
-       if (flags & STR_TERMINATE)
-               src_len++;
-
-       if (ucs2_align(NULL, dest, flags)) {
-               *(char *)dest = 0;
-               dest = (void *)((char *)dest + 1);
-               if (dest_len) dest_len--;
-               len++;
-       }
-
-       /* ucs2 is always a multiple of 2 bytes */
-       dest_len &= ~1;
-
-       ret = convert_string(ic, CH_UNIX, CH_UTF16, src, src_len, dest, dest_len);
-       if (ret == (size_t)-1) {
-               return 0;
-       }
-
-       len += ret;
-
-       return len;
-}
-
-
-/**
- * Copy a string from a unix char* src to a UCS2 destination,
- * allocating a buffer using talloc().
- *
- * @param dest always set at least to NULL 
- *
- * @returns The number of bytes occupied by the string in the destination
- *         or -1 in case of error.
- **/
-_PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, void **dest, const char *src)
-{
-       size_t src_len = strlen(src)+1;
-       *dest = NULL;
-       return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF16, src, src_len, dest);
-}
-
-
-/**
- * Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL 
- *
- * @returns The number of bytes occupied by the string in the destination
- **/
-
-_PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src)
-{
-       size_t src_len = strlen(src)+1;
-       *dest = NULL;
-       return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF8, src, src_len, (void **)dest);
-}
-
-/**
- Copy a string from a ucs2 source to a unix char* destination.
- Flags can have:
-  STR_TERMINATE means the string in src is null terminated.
-  STR_NOALIGN   means don't try to align.
- if STR_TERMINATE is set then src_len is ignored if it is -1.
- src_len is the length of the source area in bytes
- Return the number of bytes occupied by the string in src.
- The resulting string in "dest" is always null terminated.
-**/
-
-static size_t pull_ucs2(struct smb_iconv_convenience *ic, char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
-{
-       size_t ret;
-
-       if (ucs2_align(NULL, src, flags)) {
-               src = (const void *)((const char *)src + 1);
-               if (src_len > 0)
-                       src_len--;
-       }
-
-       if (flags & STR_TERMINATE) {
-               if (src_len == (size_t)-1) {
-                       src_len = utf16_len(src);
-               } else {
-                       src_len = utf16_len_n(src, src_len);
-               }
-       }
-
-       /* ucs2 is always a multiple of 2 bytes */
-       if (src_len != (size_t)-1)
-               src_len &= ~1;
-       
-       ret = convert_string(ic, CH_UTF16, CH_UNIX, src, src_len, dest, dest_len);
-       if (dest_len)
-               dest[MIN(ret, dest_len-1)] = 0;
-
-       return src_len;
-}
-
-/**
- * Copy a string from a ASCII src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL 
- *
- * @returns The number of bytes occupied by the string in the destination
- **/
-
-_PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src)
-{
-       size_t src_len = strlen(src)+1;
-       *dest = NULL;
-       return convert_string_talloc(ctx, ic, CH_DOS, CH_UNIX, src, src_len, (void **)dest);
-}
-
-/**
- * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL 
- *
- * @returns The number of bytes occupied by the string in the destination
- **/
-
-_PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const void *src)
-{
-       size_t src_len = utf16_len(src);
-       *dest = NULL;
-       return convert_string_talloc(ctx, ic, CH_UTF16, CH_UNIX, src, src_len, (void **)dest);
-}
-
-/**
- * Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL 
- *
- * @returns The number of bytes occupied by the string in the destination
- **/
-
-_PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src)
-{
-       size_t src_len = strlen(src)+1;
-       *dest = NULL;
-       return convert_string_talloc(ctx, ic, CH_UTF8, CH_UNIX, src, src_len, (void **)dest);
-}
-
-/**
- Copy a string from a char* src to a unicode or ascii
- dos codepage destination choosing unicode or ascii based on the 
- flags in the SMB buffer starting at base_ptr.
- Return the number of bytes occupied by the string in the destination.
- flags can have:
-  STR_TERMINATE means include the null termination.
-  STR_UPPER     means uppercase in the destination.
-  STR_ASCII     use ascii even with unicode packet.
-  STR_NOALIGN   means don't do alignment.
- dest_len is the maximum length allowed in the destination. If dest_len
- is -1 then no maxiumum is used.
-**/
-
-_PUBLIC_ ssize_t push_string(struct smb_iconv_convenience *ic, 
-                            void *dest, const char *src, size_t dest_len, int flags)
-{
-       if (flags & STR_ASCII) {
-               return push_ascii(ic, dest, src, dest_len, flags);
-       } else if (flags & STR_UNICODE) {
-               return push_ucs2(ic, dest, src, dest_len, flags);
-       } else {
-               smb_panic("push_string requires either STR_ASCII or STR_UNICODE flag to be set");
-               return -1;
-       }
-}
-
-
-/**
- Copy a string from a unicode or ascii source (depending on
- the packet flags) to a char* destination.
- Flags can have:
-  STR_TERMINATE means the string in src is null terminated.
-  STR_UNICODE   means to force as unicode.
-  STR_ASCII     use ascii even with unicode packet.
-  STR_NOALIGN   means don't do alignment.
- if STR_TERMINATE is set then src_len is ignored is it is -1
- src_len is the length of the source area in bytes.
- Return the number of bytes occupied by the string in src.
- The resulting string in "dest" is always null terminated.
-**/
-
-_PUBLIC_ ssize_t pull_string(struct smb_iconv_convenience *ic,
-                            char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
-{
-       if (flags & STR_ASCII) {
-               return pull_ascii(ic, dest, src, dest_len, src_len, flags);
-       } else if (flags & STR_UNICODE) {
-               return pull_ucs2(ic, dest, src, dest_len, src_len, flags);
-       } else {
-               smb_panic("pull_string requires either STR_ASCII or STR_UNICODE flag to be set");
-               return -1;
-       }
-}
-
-
 /*
   return the unicode codepoint for the next multi-byte CH_UNIX character
   in the string
similarity index 79%
rename from source4/lib/charset/charset.h
rename to lib/util/charset/charset.h
index 041eaeace7a7d9991b830d3af335818a00a66ad9..cba8aaf5f3af75739d841a2d1b327c92f7c12e6d 100644 (file)
@@ -76,7 +76,6 @@ typedef struct smb_iconv_s {
 
 struct loadparm_context;
 struct smb_iconv_convenience;
-extern struct smb_iconv_convenience *global_smb_iconv_convenience;
 
 /* replace some string functions with multi-byte
    versions */
@@ -87,13 +86,13 @@ char *strchr_m(const char *s, char c);
 size_t strlen_m_term(const char *s);
 size_t strlen_m(const char *s);
 char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength);
-void string_replace_w(char *s, char oldc, char newc);
-bool strcsequal_w(const char *s1,const char *s2);
-bool strequal_w(const char *s1, const char *s2);
+void string_replace_m(char *s, char oldc, char newc);
+bool strcsequal_m(const char *s1,const char *s2);
+bool strequal_m(const char *s1, const char *s2);
 int strncasecmp_m(const char *s1, const char *s2, size_t n);
 bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize);
 int strcasecmp_m(const char *s1, const char *s2);
-size_t count_chars_w(const char *s, char c);
+size_t count_chars_m(const char *s, char c);
 void strupper_m(char *s);
 void strlower_m(char *s);
 char *strupper_talloc(TALLOC_CTX *ctx, const char *src);
@@ -105,17 +104,30 @@ bool strhaslower(const char *string);
 char *strrchr_m(const char *s, char c);
 char *strchr_m(const char *s, char c);
 
+ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
+ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src);
+ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
+ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
+ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src);
+ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
+ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags);
+ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
+
 /* codepoints */
 codepoint_t next_codepoint(struct smb_iconv_convenience *ic, 
                            const char *str, size_t *size);
 ssize_t push_codepoint(struct smb_iconv_convenience *ic, 
                                char *str, codepoint_t c);
-codepoint_t toupper_w(codepoint_t val);
-codepoint_t tolower_w(codepoint_t val);
+codepoint_t toupper_m(codepoint_t val);
+codepoint_t tolower_m(codepoint_t val);
 int codepoint_cmpi(codepoint_t c1, codepoint_t c2);
-ssize_t push_string(struct smb_iconv_convenience *ic, void *dest, const char *src, size_t dest_len, int flags);
-ssize_t pull_string(struct smb_iconv_convenience *ic,
-                   char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
+
+/* Iconv convenience functions */
+struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx,
+                                                        const char *dos_charset,
+                                                        const char *unix_charset,
+                                                        bool native_iconv);
+
 ssize_t convert_string(struct smb_iconv_convenience *ic,
                                charset_t from, charset_t to,
                                void const *src, size_t srclen, 
@@ -126,13 +138,6 @@ ssize_t convert_string_talloc(TALLOC_CTX *ctx,
                                       charset_t from, charset_t to, 
                                       void const *src, size_t srclen, 
                                       void **dest);
-ssize_t push_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src);
-ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, void **dest, const char *src);
-ssize_t push_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src);
-ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src);
-ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const void *src);
-ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src);
-
 /* iconv */
 smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode);
 int smb_iconv_close(smb_iconv_t cd);
@@ -142,12 +147,6 @@ size_t smb_iconv(smb_iconv_t cd,
 smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, 
                              const char *fromcode, bool native_iconv);
 
-/* iconv convenience */
-struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx,
-                                                        const char *dos_charset,
-                                                        const char *unix_charset,
-                                                        bool native_iconv);
-
 void load_case_tables(void);
 bool charset_register_backend(const void *_funcs);
 
diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c
new file mode 100644 (file)
index 0000000..a940c1b
--- /dev/null
@@ -0,0 +1,118 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Andrew Tridgell 1992-2001
+   Copyright (C) Simo Sorce 2001
+   
+   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/>.
+*/
+
+#include "includes.h"
+#include "system/locale.h"
+#include "dynconfig/dynconfig.h"
+
+/**
+ * @file
+ * @brief Unicode string manipulation
+ */
+
+/* these 2 tables define the unicode case handling.  They are loaded
+   at startup either via mmap() or read() from the lib directory */
+static void *upcase_table;
+static void *lowcase_table;
+
+
+/*******************************************************************
+load the case handling tables
+********************************************************************/
+void load_case_tables(void)
+{
+       TALLOC_CTX *mem_ctx;
+
+       mem_ctx = talloc_init("load_case_tables");
+       if (!mem_ctx) {
+               smb_panic("No memory for case_tables");
+       }
+       upcase_table = map_file(talloc_asprintf(mem_ctx, "%s/upcase.dat", dyn_DATADIR), 0x20000);
+       lowcase_table = map_file(talloc_asprintf(mem_ctx, "%s/lowcase.dat", dyn_DATADIR), 0x20000);
+       talloc_free(mem_ctx);
+       if (upcase_table == NULL) {
+               /* try also under codepages for testing purposes */
+               upcase_table = map_file("codepages/upcase.dat", 0x20000);
+               if (upcase_table == NULL) {
+                       upcase_table = (void *)-1;
+               }
+       }
+       if (lowcase_table == NULL) {
+               /* try also under codepages for testing purposes */
+               lowcase_table = map_file("codepages/lowcase.dat", 0x20000);
+               if (lowcase_table == NULL) {
+                       lowcase_table = (void *)-1;
+               }
+       }
+}
+
+/**
+ Convert a codepoint_t to upper case.
+**/
+_PUBLIC_ codepoint_t toupper_m(codepoint_t val)
+{
+       if (val < 128) {
+               return toupper(val);
+       }
+       if (upcase_table == NULL) {
+               load_case_tables();
+       }
+       if (upcase_table == (void *)-1) {
+               return val;
+       }
+       if (val & 0xFFFF0000) {
+               return val;
+       }
+       return SVAL(upcase_table, val*2);
+}
+
+/**
+ Convert a codepoint_t to lower case.
+**/
+_PUBLIC_ codepoint_t tolower_m(codepoint_t val)
+{
+       if (val < 128) {
+               return tolower(val);
+       }
+       if (lowcase_table == NULL) {
+               load_case_tables();
+       }
+       if (lowcase_table == (void *)-1) {
+               return val;
+       }
+       if (val & 0xFFFF0000) {
+               return val;
+       }
+       return SVAL(lowcase_table, val*2);
+}
+
+/**
+  compare two codepoints case insensitively
+*/
+_PUBLIC_ int codepoint_cmpi(codepoint_t c1, codepoint_t c2)
+{
+       if (c1 == c2 ||
+           toupper_m(c1) == toupper_m(c2)) {
+               return 0;
+       }
+       return c1 - c2;
+}
+
+
similarity index 73%
rename from source4/lib/charset/config.mk
rename to lib/util/charset/config.mk
index 12c2f5f321f6b2506e5c15ce247b82492bfc3602..952c13a84d37bbeafdd15894d179da79dce1157f 100644 (file)
@@ -6,8 +6,6 @@ PRIVATE_DEPENDENCIES = DYNCONFIG
 # End SUBSYSTEM CHARSET
 ################################################
 
-CHARSET_OBJ_FILES = $(addprefix $(libcharsetsrcdir)/, iconv.o charcnv.o util_unistr.o)
+CHARSET_OBJ_FILES = $(addprefix $(libcharsetsrcdir)/, iconv.o charcnv.o util_unistr.o codepoints.o)
 
 PUBLIC_HEADERS += $(libcharsetsrcdir)/charset.h
-
-$(eval $(call proto_header_template,$(libcharsetsrcdir)/charset_proto.h,$(CHARSET_OBJ_FILES:.o=.c)))
similarity index 79%
rename from source4/lib/charset/tests/charset.c
rename to lib/util/charset/tests/charset.c
index 5e42ca2932444e501f4f898d7c8a5d2b0ce612c1..06acda80ab51ff6d3ffbd406f52a3221da185683 100644 (file)
 #include "includes.h"
 #include "torture/torture.h"
 
-static bool test_toupper_w(struct torture_context *tctx)
+static bool test_toupper_m(struct torture_context *tctx)
 {
-       torture_assert_int_equal(tctx, toupper_w('c'), 'C', "c");
-       torture_assert_int_equal(tctx, toupper_w('Z'), 'Z', "z");
-       torture_assert_int_equal(tctx, toupper_w(0xFFFF4565), 0xFFFF4565, "0xFFFF4565");
+       torture_assert_int_equal(tctx, toupper_m('c'), 'C', "c");
+       torture_assert_int_equal(tctx, toupper_m('Z'), 'Z', "z");
+       torture_assert_int_equal(tctx, toupper_m(0xFFFF4565), 0xFFFF4565, "0xFFFF4565");
        return true;
 }
 
-static bool test_tolower_w(struct torture_context *tctx)
+static bool test_tolower_m(struct torture_context *tctx)
 {
-       torture_assert_int_equal(tctx, tolower_w('C'), 'c', "c");
-       torture_assert_int_equal(tctx, tolower_w('z'), 'z', "z");
-       torture_assert_int_equal(tctx, tolower_w(0xFFFF4565), 0xFFFF4565, "0xFFFF4565");
+       torture_assert_int_equal(tctx, tolower_m('C'), 'c', "c");
+       torture_assert_int_equal(tctx, tolower_m('z'), 'z', "z");
+       torture_assert_int_equal(tctx, tolower_m(0xFFFF4565), 0xFFFF4565, "0xFFFF4565");
        return true;
 }
 
@@ -58,43 +58,43 @@ static bool test_strcasecmp_m(struct torture_context *tctx)
 }
 
 
-static bool test_strequal_w(struct torture_context *tctx)
+static bool test_strequal_m(struct torture_context *tctx)
 {
-       torture_assert(tctx, !strequal_w("foo", "bar"), "different strings");
-       torture_assert(tctx, strequal_w("foo", "foo"), "same case strings");
-       torture_assert(tctx, strequal_w("foo", "Foo"), "different case strings");
-       torture_assert(tctx, !strequal_w(NULL, "Foo"), "one NULL");
-       torture_assert(tctx, !strequal_w("foo", NULL), "other NULL");
-       torture_assert(tctx, strequal_w(NULL, NULL), "both NULL");
+       torture_assert(tctx, !strequal_m("foo", "bar"), "different strings");
+       torture_assert(tctx, strequal_m("foo", "foo"), "same case strings");
+       torture_assert(tctx, strequal_m("foo", "Foo"), "different case strings");
+       torture_assert(tctx, !strequal_m(NULL, "Foo"), "one NULL");
+       torture_assert(tctx, !strequal_m("foo", NULL), "other NULL");
+       torture_assert(tctx, strequal_m(NULL, NULL), "both NULL");
        return true;
 }
 
-static bool test_strcsequal_w(struct torture_context *tctx)
+static bool test_strcsequal_m(struct torture_context *tctx)
 {
-       torture_assert(tctx, !strcsequal_w("foo", "bar"), "different strings");
-       torture_assert(tctx, strcsequal_w("foo", "foo"), "same case strings");
-       torture_assert(tctx, !strcsequal_w("foo", "Foo"), "different case strings");
-       torture_assert(tctx, !strcsequal_w(NULL, "Foo"), "one NULL");
-       torture_assert(tctx, !strcsequal_w("foo", NULL), "other NULL");
-       torture_assert(tctx, strcsequal_w(NULL, NULL), "both NULL");
+       torture_assert(tctx, !strcsequal_m("foo", "bar"), "different strings");
+       torture_assert(tctx, strcsequal_m("foo", "foo"), "same case strings");
+       torture_assert(tctx, !strcsequal_m("foo", "Foo"), "different case strings");
+       torture_assert(tctx, !strcsequal_m(NULL, "Foo"), "one NULL");
+       torture_assert(tctx, !strcsequal_m("foo", NULL), "other NULL");
+       torture_assert(tctx, strcsequal_m(NULL, NULL), "both NULL");
        return true;
 }
 
-static bool test_string_replace_w(struct torture_context *tctx)
+static bool test_string_replace_m(struct torture_context *tctx)
 {
        char data[6] = "bla";
-       string_replace_w(data, 'b', 'c');
+       string_replace_m(data, 'b', 'c');
        torture_assert_str_equal(tctx, data, "cla", "first char replaced");
        memcpy(data, "bab", 4);
-       string_replace_w(data, 'b', 'c');
+       string_replace_m(data, 'b', 'c');
        torture_assert_str_equal(tctx, data, "cac", "other chars replaced");
        memcpy(data, "bba", 4);
-       string_replace_w(data, 'b', 'c');
+       string_replace_m(data, 'b', 'c');
        torture_assert_str_equal(tctx, data, "cca", "other chars replaced");
        memcpy(data, "blala", 6);
-       string_replace_w(data, 'o', 'c');
+       string_replace_m(data, 'o', 'c');
        torture_assert_str_equal(tctx, data, "blala", "no chars replaced");
-       string_replace_w(NULL, 'b', 'c');
+       string_replace_m(NULL, 'b', 'c');
        return true;
 }
 
@@ -235,12 +235,12 @@ static bool test_strhasupper(struct torture_context *tctx)
        return true;
 }
 
-static bool test_count_chars_w(struct torture_context *tctx)
+static bool test_count_chars_m(struct torture_context *tctx)
 {
-       torture_assert_int_equal(tctx, count_chars_w("foo", 'o'), 2, "simple");
-       torture_assert_int_equal(tctx, count_chars_w("", 'o'), 0, "empty");
-       torture_assert_int_equal(tctx, count_chars_w("bla", 'o'), 0, "none");
-       torture_assert_int_equal(tctx, count_chars_w("bla", '\0'), 0, "null");
+       torture_assert_int_equal(tctx, count_chars_m("foo", 'o'), 2, "simple");
+       torture_assert_int_equal(tctx, count_chars_m("", 'o'), 0, "empty");
+       torture_assert_int_equal(tctx, count_chars_m("bla", 'o'), 0, "none");
+       torture_assert_int_equal(tctx, count_chars_m("bla", '\0'), 0, "null");
        return true;
 }
 
@@ -248,13 +248,13 @@ struct torture_suite *torture_local_charset(TALLOC_CTX *mem_ctx)
 {
        struct torture_suite *suite = torture_suite_create(mem_ctx, "CHARSET");
 
-       torture_suite_add_simple_test(suite, "toupper_w", test_toupper_w);
-       torture_suite_add_simple_test(suite, "tolower_w", test_tolower_w);
+       torture_suite_add_simple_test(suite, "toupper_m", test_toupper_m);
+       torture_suite_add_simple_test(suite, "tolower_m", test_tolower_m);
        torture_suite_add_simple_test(suite, "codepoint_cmpi", test_codepoint_cmpi);
        torture_suite_add_simple_test(suite, "strcasecmp_m", test_strcasecmp_m);
-       torture_suite_add_simple_test(suite, "strequal_w", test_strequal_w);
-       torture_suite_add_simple_test(suite, "strcsequal_w", test_strcsequal_w);
-       torture_suite_add_simple_test(suite, "string_replace_w", test_string_replace_w);
+       torture_suite_add_simple_test(suite, "strequal_m", test_strequal_m);
+       torture_suite_add_simple_test(suite, "strcsequal_m", test_strcsequal_m);
+       torture_suite_add_simple_test(suite, "string_replace_m", test_string_replace_m);
        torture_suite_add_simple_test(suite, "strncasecmp_m", test_strncasecmp_m);
        torture_suite_add_simple_test(suite, "next_token", test_next_token);
        torture_suite_add_simple_test(suite, "next_token_null", test_next_token_null);
@@ -266,7 +266,7 @@ struct torture_suite *torture_local_charset(TALLOC_CTX *mem_ctx)
        torture_suite_add_simple_test(suite, "strlen_m_term", test_strlen_m_term);
        torture_suite_add_simple_test(suite, "strhaslower", test_strhaslower);
        torture_suite_add_simple_test(suite, "strhasupper", test_strhasupper);
-       torture_suite_add_simple_test(suite, "count_chars_w", test_count_chars_w);
+       torture_suite_add_simple_test(suite, "count_chars_m", test_count_chars_m);
 
        return suite;
 }
diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c
new file mode 100644 (file)
index 0000000..85f9755
--- /dev/null
@@ -0,0 +1,927 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Andrew Tridgell 1992-2001
+   Copyright (C) Simo Sorce 2001
+   
+   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/>.
+*/
+
+#include "includes.h"
+#include "system/locale.h"
+#include "param/param.h"
+
+static inline struct smb_iconv_convenience *get_iconv_convenience(void)
+{
+       static struct smb_iconv_convenience *ic = NULL;
+       if (ic == NULL)
+               ic = lp_iconv_convenience(global_loadparm);
+       return ic;
+}
+
+/**
+ Case insensitive string compararison
+**/
+_PUBLIC_ int strcasecmp_m(const char *s1, const char *s2)
+{
+       codepoint_t c1=0, c2=0;
+       size_t size1, size2;
+       struct smb_iconv_convenience *iconv_convenience = get_iconv_convenience();
+
+       /* handle null ptr comparisons to simplify the use in qsort */
+       if (s1 == s2) return 0;
+       if (s1 == NULL) return -1;
+       if (s2 == NULL) return 1;
+
+       while (*s1 && *s2) {
+               c1 = next_codepoint(iconv_convenience, s1, &size1);
+               c2 = next_codepoint(iconv_convenience, s2, &size2);
+
+               s1 += size1;
+               s2 += size2;
+
+               if (c1 == c2) {
+                       continue;
+               }
+
+               if (c1 == INVALID_CODEPOINT ||
+                   c2 == INVALID_CODEPOINT) {
+                       /* what else can we do?? */
+                       return strcasecmp(s1, s2);
+               }
+
+               if (toupper_m(c1) != toupper_m(c2)) {
+                       return c1 - c2;
+               }
+       }
+
+       return *s1 - *s2;
+}
+
+/**
+ * Get the next token from a string, return False if none found.
+ * Handles double-quotes.
+ * 
+ * Based on a routine by GJC@VILLAGE.COM. 
+ * Extensively modified by Andrew.Tridgell@anu.edu.au
+ **/
+_PUBLIC_ bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
+{
+       const char *s;
+       bool quoted;
+       size_t len=1;
+
+       if (!ptr)
+               return false;
+
+       s = *ptr;
+
+       /* default to simple separators */
+       if (!sep)
+               sep = " \t\n\r";
+
+       /* find the first non sep char */
+       while (*s && strchr_m(sep,*s))
+               s++;
+       
+       /* nothing left? */
+       if (!*s)
+               return false;
+       
+       /* copy over the token */
+       for (quoted = false; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) {
+               if (*s == '\"') {
+                       quoted = !quoted;
+               } else {
+                       len++;
+                       *buff++ = *s;
+               }
+       }
+       
+       *ptr = (*s) ? s+1 : s;  
+       *buff = 0;
+       
+       return true;
+}
+
+/**
+ Case insensitive string compararison, length limited
+**/
+_PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n)
+{
+       codepoint_t c1=0, c2=0;
+       size_t size1, size2;
+       struct smb_iconv_convenience *iconv_convenience = get_iconv_convenience();
+
+       /* handle null ptr comparisons to simplify the use in qsort */
+       if (s1 == s2) return 0;
+       if (s1 == NULL) return -1;
+       if (s2 == NULL) return 1;
+
+       while (*s1 && *s2 && n) {
+               n--;
+
+               c1 = next_codepoint(iconv_convenience, s1, &size1);
+               c2 = next_codepoint(iconv_convenience, s2, &size2);
+
+               s1 += size1;
+               s2 += size2;
+
+               if (c1 == c2) {
+                       continue;
+               }
+
+               if (c1 == INVALID_CODEPOINT ||
+                   c2 == INVALID_CODEPOINT) {
+                       /* what else can we do?? */
+                       return strcasecmp(s1, s2);
+               }
+
+               if (toupper_m(c1) != toupper_m(c2)) {
+                       return c1 - c2;
+               }
+       }
+
+       if (n == 0) {
+               return 0;
+       }
+
+       return *s1 - *s2;
+}
+
+/**
+ * Compare 2 strings.
+ *
+ * @note The comparison is case-insensitive.
+ **/
+_PUBLIC_ bool strequal_m(const char *s1, const char *s2)
+{
+       return strcasecmp_m(s1,s2) == 0;
+}
+
+/**
+ Compare 2 strings (case sensitive).
+**/
+_PUBLIC_ bool strcsequal_m(const char *s1,const char *s2)
+{
+       if (s1 == s2)
+               return true;
+       if (!s1 || !s2)
+               return false;
+       
+       return strcmp(s1,s2) == 0;
+}
+
+
+/**
+ String replace.
+ NOTE: oldc and newc must be 7 bit characters
+**/
+_PUBLIC_ void string_replace_m(char *s, char oldc, char newc)
+{
+       while (s && *s) {
+               size_t size;
+               codepoint_t c = next_codepoint(get_iconv_convenience(), s, &size);
+               if (c == oldc) {
+                       *s = newc;
+               }
+               s += size;
+       }
+}
+
+/**
+ Paranoid strcpy into a buffer of given length (includes terminating
+ zero. Strips out all but 'a-Z0-9' and the character in other_safe_chars
+ and replaces with '_'. Deliberately does *NOT* check for multibyte
+ characters. Don't change it !
+**/
+
+_PUBLIC_ char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength)
+{
+       size_t len, i;
+
+       if (maxlength == 0) {
+               /* can't fit any bytes at all! */
+               return NULL;
+       }
+
+       if (!dest) {
+               DEBUG(0,("ERROR: NULL dest in alpha_strcpy\n"));
+               return NULL;
+       }
+
+       if (!src) {
+               *dest = 0;
+               return dest;
+       }  
+
+       len = strlen(src);
+       if (len >= maxlength)
+               len = maxlength - 1;
+
+       if (!other_safe_chars)
+               other_safe_chars = "";
+
+       for(i = 0; i < len; i++) {
+               int val = (src[i] & 0xff);
+               if (isupper(val) || islower(val) || isdigit(val) || strchr_m(other_safe_chars, val))
+                       dest[i] = src[i];
+               else
+                       dest[i] = '_';
+       }
+
+       dest[i] = '\0';
+
+       return dest;
+}
+
+/**
+ Count the number of UCS2 characters in a string. Normally this will
+ be the same as the number of bytes in a string for single byte strings,
+ but will be different for multibyte.
+**/
+_PUBLIC_ size_t strlen_m(const char *s)
+{
+       size_t count = 0;
+
+       if (!s) {
+               return 0;
+       }
+
+       while (*s && !(((uint8_t)*s) & 0x80)) {
+               s++;
+               count++;
+       }
+
+       if (!*s) {
+               return count;
+       }
+
+       while (*s) {
+               size_t c_size;
+               codepoint_t c = next_codepoint(get_iconv_convenience(), s, &c_size);
+               if (c < 0x10000) {
+                       count += 1;
+               } else {
+                       count += 2;
+               }
+               s += c_size;
+       }
+
+       return count;
+}
+
+/**
+   Work out the number of multibyte chars in a string, including the NULL
+   terminator.
+**/
+_PUBLIC_ size_t strlen_m_term(const char *s)
+{
+       if (!s) {
+               return 0;
+       }
+
+       return strlen_m(s) + 1;
+}
+
+/**
+ Strchr and strrchr_m are a bit complex on general multi-byte strings. 
+**/
+_PUBLIC_ char *strchr_m(const char *s, char c)
+{
+       if (s == NULL) {
+               return NULL;
+       }
+       /* characters below 0x3F are guaranteed to not appear in
+          non-initial position in multi-byte charsets */
+       if ((c & 0xC0) == 0) {
+               return strchr(s, c);
+       }
+
+       while (*s) {
+               size_t size;
+               codepoint_t c2 = next_codepoint(get_iconv_convenience(), s, &size);
+               if (c2 == c) {
+                       return discard_const_p(char, s);
+               }
+               s += size;
+       }
+
+       return NULL;
+}
+
+/**
+ * Multibyte-character version of strrchr
+ */
+_PUBLIC_ char *strrchr_m(const char *s, char c)
+{
+       char *ret = NULL;
+
+       if (s == NULL) {
+               return NULL;
+       }
+
+       /* characters below 0x3F are guaranteed to not appear in
+          non-initial position in multi-byte charsets */
+       if ((c & 0xC0) == 0) {
+               return strrchr(s, c);
+       }
+
+       while (*s) {
+               size_t size;
+               codepoint_t c2 = next_codepoint(get_iconv_convenience(), s, &size);
+               if (c2 == c) {
+                       ret = discard_const_p(char, s);
+               }
+               s += size;
+       }
+
+       return ret;
+}
+
+/**
+  return True if any (multi-byte) character is lower case
+*/
+_PUBLIC_ bool strhaslower(const char *string)
+{
+       while (*string) {
+               size_t c_size;
+               codepoint_t s;
+               codepoint_t t;
+
+               s = next_codepoint(get_iconv_convenience(), string, &c_size);
+               string += c_size;
+
+               t = toupper_m(s);
+
+               if (s != t) {
+                       return true; /* that means it has lower case chars */
+               }
+       }
+
+       return false;
+} 
+
+/**
+  return True if any (multi-byte) character is upper case
+*/
+_PUBLIC_ bool strhasupper(const char *string)
+{
+       while (*string) {
+               size_t c_size;
+               codepoint_t s;
+               codepoint_t t;
+
+               s = next_codepoint(get_iconv_convenience(), string, &c_size);
+               string += c_size;
+
+               t = tolower_m(s);
+
+               if (s != t) {
+                       return true; /* that means it has upper case chars */
+               }
+       }
+
+       return false;
+} 
+
+/**
+ Convert a string to lower case, allocated with talloc
+**/
+_PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
+{
+       size_t size=0;
+       char *dest;
+       struct smb_iconv_convenience *iconv_convenience = get_iconv_convenience();
+
+       /* this takes advantage of the fact that upper/lower can't
+          change the length of a character by more than 1 byte */
+       dest = talloc_array(ctx, char, 2*(strlen(src))+1);
+       if (dest == NULL) {
+               return NULL;
+       }
+
+       while (*src) {
+               size_t c_size;
+               codepoint_t c = next_codepoint(iconv_convenience, src, &c_size);
+               src += c_size;
+
+               c = tolower_m(c);
+
+               c_size = push_codepoint(iconv_convenience, dest+size, c);
+               if (c_size == -1) {
+                       talloc_free(dest);
+                       return NULL;
+               }
+               size += c_size;
+       }
+
+       dest[size] = 0;
+
+       /* trim it so talloc_append_string() works */
+       dest = talloc_realloc(ctx, dest, char, size+1);
+
+       talloc_set_name_const(dest, dest);
+
+       return dest;
+}
+
+/**
+ Convert a string to UPPER case, allocated with talloc
+ source length limited to n bytes
+**/
+_PUBLIC_ char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n)
+{
+       size_t size=0;
+       char *dest;
+       struct smb_iconv_convenience *iconv_convenience = get_iconv_convenience();
+       
+       if (!src) {
+               return NULL;
+       }
+
+       /* this takes advantage of the fact that upper/lower can't
+          change the length of a character by more than 1 byte */
+       dest = talloc_array(ctx, char, 2*(n+1));
+       if (dest == NULL) {
+               return NULL;
+       }
+
+       while (*src && n--) {
+               size_t c_size;
+               codepoint_t c = next_codepoint(iconv_convenience, src, &c_size);
+               src += c_size;
+
+               c = toupper_m(c);
+
+               c_size = push_codepoint(iconv_convenience, dest+size, c);
+               if (c_size == -1) {
+                       talloc_free(dest);
+                       return NULL;
+               }
+               size += c_size;
+       }
+
+       dest[size] = 0;
+
+       /* trim it so talloc_append_string() works */
+       dest = talloc_realloc(ctx, dest, char, size+1);
+
+       talloc_set_name_const(dest, dest);
+
+       return dest;
+}
+
+/**
+ Convert a string to UPPER case, allocated with talloc
+**/
+_PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
+{
+       return strupper_talloc_n(ctx, src, src?strlen(src):0);
+}
+
+/**
+ talloc_strdup() a unix string to upper case.
+**/
+_PUBLIC_ char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *src)
+{
+       return strupper_talloc(ctx, src);
+}
+
+/**
+ Convert a string to lower case.
+**/
+_PUBLIC_ void strlower_m(char *s)
+{
+       char *d;
+       struct smb_iconv_convenience *iconv_convenience;
+
+       /* this is quite a common operation, so we want it to be
+          fast. We optimise for the ascii case, knowing that all our
+          supported multi-byte character sets are ascii-compatible
+          (ie. they match for the first 128 chars) */
+       while (*s && !(((uint8_t)*s) & 0x80)) {
+               *s = tolower((uint8_t)*s);
+               s++;
+       }
+
+       if (!*s)
+               return;
+
+       iconv_convenience = get_iconv_convenience();
+
+       d = s;
+
+       while (*s) {
+               size_t c_size, c_size2;
+               codepoint_t c = next_codepoint(iconv_convenience, s, &c_size);
+               c_size2 = push_codepoint(iconv_convenience, d, tolower_m(c));
+               if (c_size2 > c_size) {
+                       DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strlower_m\n",
+                                c, tolower_m(c), (int)c_size, (int)c_size2));
+                       smb_panic("codepoint expansion in strlower_m\n");
+               }
+               s += c_size;
+               d += c_size2;
+       }
+       *d = 0;
+}
+
+/**
+ Convert a string to UPPER case.
+**/
+_PUBLIC_ void strupper_m(char *s)
+{
+       char *d;
+       struct smb_iconv_convenience *iconv_convenience;
+
+       /* this is quite a common operation, so we want it to be
+          fast. We optimise for the ascii case, knowing that all our
+          supported multi-byte character sets are ascii-compatible
+          (ie. they match for the first 128 chars) */
+       while (*s && !(((uint8_t)*s) & 0x80)) {
+               *s = toupper((uint8_t)*s);
+               s++;
+       }
+
+       if (!*s)
+               return;
+
+       iconv_convenience = get_iconv_convenience();
+
+       d = s;
+
+       while (*s) {
+               size_t c_size, c_size2;
+               codepoint_t c = next_codepoint(iconv_convenience, s, &c_size);
+               c_size2 = push_codepoint(iconv_convenience, d, toupper_m(c));
+               if (c_size2 > c_size) {
+                       DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strupper_m\n",
+                                c, toupper_m(c), (int)c_size, (int)c_size2));
+                       smb_panic("codepoint expansion in strupper_m\n");
+               }
+               s += c_size;
+               d += c_size2;
+       }
+       *d = 0;
+}
+
+
+/**
+ Find the number of 'c' chars in a string
+**/
+_PUBLIC_ size_t count_chars_m(const char *s, char c)
+{
+       size_t count = 0;
+
+       while (*s) {
+               size_t size;
+               codepoint_t c2 = next_codepoint(get_iconv_convenience(), s, &size);
+               if (c2 == c) count++;
+               s += size;
+       }
+
+       return count;
+}
+
+
+/**
+ * Copy a string from a char* unix src to a dos codepage string destination.
+ *
+ * @return the number of bytes occupied by the string in the destination.
+ *
+ * @param flags can include
+ * <dl>
+ * <dt>STR_TERMINATE</dt> <dd>means include the null termination</dd>
+ * <dt>STR_UPPER</dt> <dd>means uppercase in the destination</dd>
+ * </dl>
+ *
+ * @param dest_len the maximum length in bytes allowed in the
+ * destination.  If @p dest_len is -1 then no maximum is used.
+ **/
+static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flags)
+{
+       size_t src_len;
+       ssize_t ret;
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+
+       if (flags & STR_UPPER) {
+               char *tmpbuf = strupper_talloc(NULL, src);
+               if (tmpbuf == NULL) {
+                       return -1;
+               }
+               ret = push_ascii(dest, tmpbuf, dest_len, flags & ~STR_UPPER);
+               talloc_free(tmpbuf);
+               return ret;
+       }
+
+       src_len = strlen(src);
+
+       if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII))
+               src_len++;
+
+       return convert_string(ic, CH_UNIX, CH_DOS, src, src_len, dest, dest_len);
+}
+
+/**
+ * Copy a string from a unix char* src to an ASCII destination,
+ * allocating a buffer using talloc().
+ *
+ * @param dest always set at least to NULL 
+ *
+ * @returns The number of bytes occupied by the string in the destination
+ *         or -1 in case of error.
+ **/
+_PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t src_len = strlen(src)+1;
+       *dest = NULL;
+       return convert_string_talloc(ctx, ic, CH_UNIX, CH_DOS, src, src_len, (void **)dest);
+}
+
+
+/**
+ * Copy a string from a dos codepage source to a unix char* destination.
+ *
+ * The resulting string in "dest" is always null terminated.
+ *
+ * @param flags can have:
+ * <dl>
+ * <dt>STR_TERMINATE</dt>
+ * <dd>STR_TERMINATE means the string in @p src
+ * is null terminated, and src_len is ignored.</dd>
+ * </dl>
+ *
+ * @param src_len is the length of the source area in bytes.
+ * @returns the number of bytes occupied by the string in @p src.
+ **/
+static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t ret;
+
+       if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII)) {
+               if (src_len == (size_t)-1) {
+                       src_len = strlen((const char *)src) + 1;
+               } else {
+                       size_t len = strnlen((const char *)src, src_len);
+                       if (len < src_len)
+                               len++;
+                       src_len = len;
+               }
+       }
+
+       ret = convert_string(ic, CH_DOS, CH_UNIX, src, src_len, dest, dest_len);
+
+       if (dest_len)
+               dest[MIN(ret, dest_len-1)] = 0;
+
+       return src_len;
+}
+
+/**
+ * Copy a string from a char* src to a unicode destination.
+ *
+ * @returns the number of bytes occupied by the string in the destination.
+ *
+ * @param flags can have:
+ *
+ * <dl>
+ * <dt>STR_TERMINATE <dd>means include the null termination.
+ * <dt>STR_UPPER     <dd>means uppercase in the destination.
+ * <dt>STR_NOALIGN   <dd>means don't do alignment.
+ * </dl>
+ *
+ * @param dest_len is the maximum length allowed in the
+ * destination. If dest_len is -1 then no maxiumum is used.
+ **/
+static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t len=0;
+       size_t src_len = strlen(src);
+       size_t ret;
+
+       if (flags & STR_UPPER) {
+               char *tmpbuf = strupper_talloc(NULL, src);
+               if (tmpbuf == NULL) {
+                       return -1;
+               }
+               ret = push_ucs2(dest, tmpbuf, dest_len, flags & ~STR_UPPER);
+               talloc_free(tmpbuf);
+               return ret;
+       }
+
+       if (flags & STR_TERMINATE)
+               src_len++;
+
+       if (ucs2_align(NULL, dest, flags)) {
+               *(char *)dest = 0;
+               dest = (void *)((char *)dest + 1);
+               if (dest_len) dest_len--;
+               len++;
+       }
+
+       /* ucs2 is always a multiple of 2 bytes */
+       dest_len &= ~1;
+
+       ret = convert_string(ic, CH_UNIX, CH_UTF16, src, src_len, dest, dest_len);
+       if (ret == (size_t)-1) {
+               return 0;
+       }
+
+       len += ret;
+
+       return len;
+}
+
+
+/**
+ * Copy a string from a unix char* src to a UCS2 destination,
+ * allocating a buffer using talloc().
+ *
+ * @param dest always set at least to NULL 
+ *
+ * @returns The number of bytes occupied by the string in the destination
+ *         or -1 in case of error.
+ **/
+_PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t src_len = strlen(src)+1;
+       *dest = NULL;
+       return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF16, src, src_len, dest);
+}
+
+
+/**
+ * Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL 
+ *
+ * @returns The number of bytes occupied by the string in the destination
+ **/
+
+_PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t src_len = strlen(src)+1;
+       *dest = NULL;
+       return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF8, src, src_len, (void **)dest);
+}
+
+/**
+ Copy a string from a ucs2 source to a unix char* destination.
+ Flags can have:
+  STR_TERMINATE means the string in src is null terminated.
+  STR_NOALIGN   means don't try to align.
+ if STR_TERMINATE is set then src_len is ignored if it is -1.
+ src_len is the length of the source area in bytes
+ Return the number of bytes occupied by the string in src.
+ The resulting string in "dest" is always null terminated.
+**/
+
+static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t ret;
+
+       if (ucs2_align(NULL, src, flags)) {
+               src = (const void *)((const char *)src + 1);
+               if (src_len > 0)
+                       src_len--;
+       }
+
+       if (flags & STR_TERMINATE) {
+               if (src_len == (size_t)-1) {
+                       src_len = utf16_len(src);
+               } else {
+                       src_len = utf16_len_n(src, src_len);
+               }
+       }
+
+       /* ucs2 is always a multiple of 2 bytes */
+       if (src_len != (size_t)-1)
+               src_len &= ~1;
+       
+       ret = convert_string(ic, CH_UTF16, CH_UNIX, src, src_len, dest, dest_len);
+       if (dest_len)
+               dest[MIN(ret, dest_len-1)] = 0;
+
+       return src_len;
+}
+
+/**
+ * Copy a string from a ASCII src to a unix char * destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL 
+ *
+ * @returns The number of bytes occupied by the string in the destination
+ **/
+
+_PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t src_len = strlen(src)+1;
+       *dest = NULL;
+       return convert_string_talloc(ctx, ic, CH_DOS, CH_UNIX, src, src_len, (void **)dest);
+}
+
+/**
+ * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL 
+ *
+ * @returns The number of bytes occupied by the string in the destination
+ **/
+
+_PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t src_len = utf16_len(src);
+       *dest = NULL;
+       return convert_string_talloc(ctx, ic, CH_UTF16, CH_UNIX, src, src_len, (void **)dest);
+}
+
+/**
+ * Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL 
+ *
+ * @returns The number of bytes occupied by the string in the destination
+ **/
+
+_PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+{
+       struct smb_iconv_convenience *ic = get_iconv_convenience();
+       size_t src_len = strlen(src)+1;
+       *dest = NULL;
+       return convert_string_talloc(ctx, ic, CH_UTF8, CH_UNIX, src, src_len, (void **)dest);
+}
+
+/**
+ Copy a string from a char* src to a unicode or ascii
+ dos codepage destination choosing unicode or ascii based on the 
+ flags in the SMB buffer starting at base_ptr.
+ Return the number of bytes occupied by the string in the destination.
+ flags can have:
+  STR_TERMINATE means include the null termination.
+  STR_UPPER     means uppercase in the destination.
+  STR_ASCII     use ascii even with unicode packet.
+  STR_NOALIGN   means don't do alignment.
+ dest_len is the maximum length allowed in the destination. If dest_len
+ is -1 then no maxiumum is used.
+**/
+
+_PUBLIC_ ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags)
+{
+       if (flags & STR_ASCII) {
+               return push_ascii(dest, src, dest_len, flags);
+       } else if (flags & STR_UNICODE) {
+               return push_ucs2(dest, src, dest_len, flags);
+       } else {
+               smb_panic("push_string requires either STR_ASCII or STR_UNICODE flag to be set");
+               return -1;
+       }
+}
+
+
+/**
+ Copy a string from a unicode or ascii source (depending on
+ the packet flags) to a char* destination.
+ Flags can have:
+  STR_TERMINATE means the string in src is null terminated.
+  STR_UNICODE   means to force as unicode.
+  STR_ASCII     use ascii even with unicode packet.
+  STR_NOALIGN   means don't do alignment.
+ if STR_TERMINATE is set then src_len is ignored is it is -1
+ src_len is the length of the source area in bytes.
+ Return the number of bytes occupied by the string in src.
+ The resulting string in "dest" is always null terminated.
+**/
+
+_PUBLIC_ ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
+{
+       if (flags & STR_ASCII) {
+               return pull_ascii(dest, src, dest_len, src_len, flags);
+       } else if (flags & STR_UNICODE) {
+               return pull_ucs2(dest, src, dest_len, src_len, flags);
+       } else {
+               smb_panic("pull_string requires either STR_ASCII or STR_UNICODE flag to be set");
+               return -1;
+       }
+}
+
+
index c2407ae9c9f260c9d2bbaa78ce2469adbdf275bb..1cf60bae390ca70e6b7932d411f6927508236ae8 100644 (file)
@@ -22,7 +22,7 @@
 #define _SAMBA_UTIL_H_
 
 #if _SAMBA_BUILD_ == 4
-#include "lib/charset/charset.h"
+#include "../lib/util/charset/charset.h"
 #endif
 #include "../lib/util/attr.h"
 
index 05455da0846ea395e59a544760b7400dd8e80d03..127f6734e3707f56c5affa795feeb9ce997c7be9 100644 (file)
@@ -29,7 +29,7 @@
 #include <sys/time.h>
 #if _SAMBA_BUILD_ == 4
 #include "../lib/util/util.h" /* for discard_const */
-#include "lib/charset/charset.h"
+#include "../lib/util/charset/charset.h"
 #endif
 
 /*
index fc64c35fca1858da2f57f42cf684c4e316d6f26b..58e6910d3dffbd5bdea7e999755a8d7580ec7cf3 100644 (file)
@@ -1142,7 +1142,7 @@ sub Parse($$$$$)
 #include \"includes.h\"
 #include <Python.h>
 #include \"librpc/rpc/dcerpc.h\"
-#include \"scripting/python/pytalloc.h\"
+#include \"lib/talloc/pytalloc.h\"
 #include \"librpc/rpc/pyrpc.h\"
 #include \"lib/events/events.h\"
 #include \"$hdr\"
index 15fffb9e738abd67bbf65050702b65b3934a4ff8..c68057fd35c4faebe81c5e3f5eb3c5ed1ca9c271 100644 (file)
@@ -33,7 +33,7 @@ m4_include(../lib/util/xattr.m4)
 m4_include(../lib/util/capability.m4)
 m4_include(../lib/util/time.m4)
 m4_include(../lib/popt/samba.m4)
-m4_include(lib/charset/config.m4)
+m4_include(../lib/util/charset/config.m4)
 m4_include(lib/socket/config.m4)
 m4_include(nsswitch/nsstest.m4)
 m4_include(../pidl/config.m4)
index 5d1f0d105282d98bd54394d75c114ec000019917..e08cbfcfecef33034d513c296a5db18df3f2d012 100644 (file)
@@ -73,7 +73,7 @@ authsrcdir := $(samba4srcdir)/auth
 nsswitchsrcdir := $(samba4srcdir)/nsswitch
 libsrcdir := $(samba4srcdir)/lib
 libsocketsrcdir := $(samba4srcdir)/lib/socket
-libcharsetsrcdir := $(samba4srcdir)/lib/charset
+libcharsetsrcdir := $(samba4srcdir)/../lib/util/charset
 ldb_sambasrcdir := $(samba4srcdir)/lib/ldb-samba
 libtlssrcdir := $(samba4srcdir)/lib/tls
 libregistrysrcdir := $(samba4srcdir)/lib/registry
index 26cab668c80135cc555a8a4bb50aa951b513a6aa..be41d02a3847f3dfa2a377b3bd9d3b0057f1b73d 100644 (file)
@@ -59,7 +59,7 @@ authsrcdir := auth
 nsswitchsrcdir := nsswitch
 libsrcdir := lib
 libsocketsrcdir := lib/socket
-libcharsetsrcdir := lib/charset
+libcharsetsrcdir := ../lib/util/charset
 ldb_sambasrcdir := lib/ldb-samba
 tdbsrcdir := ../lib/tdb
 ldbsrcdir := lib/ldb
index 64ceb437ad6dc4b9a3ba71ab23811ef52144a3fb..2f8ef10e05a3c54c0d72a691fa2b94f19a1397d1 100644 (file)
@@ -145,7 +145,7 @@ NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_contex
                        
                        chall_blob = data_blob_talloc(mem_ctx, challenge, 8);
                        if (lp_client_ntlmv2_auth(auth_context->lp_ctx)) {
-                               DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_iconv_convenience(auth_context->lp_ctx), lp_netbios_name(auth_context->lp_ctx), lp_workgroup(auth_context->lp_ctx));
+                               DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx,  lp_netbios_name(auth_context->lp_ctx), lp_workgroup(auth_context->lp_ctx));
                                DATA_BLOB lmv2_response, ntlmv2_response, lmv2_session_key, ntlmv2_session_key;
                                
                                if (!SMBNTLMv2encrypt_hash(user_info_temp,
index eb990dee9cb5b350bed89c943f8bee4c3caa2796..0ef40200fe5eb3f5c1fc7edb1798e2f4bffa59b4 100644 (file)
@@ -73,7 +73,6 @@ NTSTATUS ntlmssp_client_initial(struct gensec_security *gensec_security,
 
        /* generate the ntlmssp negotiate packet */
        msrpc_gen(out_mem_ctx, 
-                 lp_iconv_convenience(gensec_security->lp_ctx),
                  out, "CddAA",
                  "NTLMSSP",
                  NTLMSSP_NEGOTIATE,
@@ -258,7 +257,6 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
 
        /* this generates the actual auth packet */
        if (!msrpc_gen(mem_ctx, 
-                      lp_iconv_convenience(gensec_security->lp_ctx),
                       out, auth_gen_string, 
                       "NTLMSSP", 
                       NTLMSSP_AUTH, 
index 9256872036de5cb29208a4d2027cc02ab61a7998..cd270590f15547cfa4e5f45788811c0803821d15 100644 (file)
@@ -42,7 +42,6 @@
   C = constant ascii string
  */
 bool msrpc_gen(TALLOC_CTX *mem_ctx, 
-              struct smb_iconv_convenience *iconv_convenience,
               DATA_BLOB *blob,
               const char *format, ...)
 {
@@ -67,7 +66,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
                case 'U':
                        s = va_arg(ap, char *);
                        head_size += 8;
-                       n = push_ucs2_talloc(pointers, iconv_convenience, (void **)&pointers[i].data, s);
+                       n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s);
                        if (n == -1) {
                                return false;
                        }
@@ -78,7 +77,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
                case 'A':
                        s = va_arg(ap, char *);
                        head_size += 8;
-                       n = push_ascii_talloc(pointers, iconv_convenience, (char **)&pointers[i].data, s);
+                       n = push_ascii_talloc(pointers, (char **)&pointers[i].data, s);
                        if (n == -1) {
                                return false;
                        }
@@ -90,7 +89,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
                        n = va_arg(ap, int);
                        intargs[i] = n;
                        s = va_arg(ap, char *);
-                       n = push_ucs2_talloc(pointers, iconv_convenience, (void **)&pointers[i].data, s);
+                       n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s);
                        if (n == -1) {
                                return false;
                        }
@@ -248,7 +247,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
                                }
 
                                if (0 < len1) {
-                                       pull_string(iconv_convenience, p, blob->data + ptr, p_len, 
+                                       pull_string(p, blob->data + ptr, p_len, 
                                                    len1, STR_UNICODE|STR_NOALIGN);
                                        (*ps) = talloc_strdup(mem_ctx, p);
                                        if (!(*ps)) {
@@ -283,7 +282,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
                                }
 
                                if (0 < len1) {
-                                       pull_string(iconv_convenience, p, blob->data + ptr, p_len, 
+                                       pull_string(p, blob->data + ptr, p_len, 
                                                    len1, STR_ASCII|STR_NOALIGN);
                                        (*ps) = talloc_strdup(mem_ctx, p);
                                        if (!(*ps)) {
@@ -348,7 +347,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
                                goto cleanup;
                        }
 
-                       head_ofs += pull_string(iconv_convenience, p,
+                       head_ofs += pull_string(p,
                                        blob->data+head_ofs, p_len,
                                        blob->length - head_ofs,
                                        STR_ASCII|STR_TERMINATE);
index ad1ee8e871b6d045a69db776bbeed6d0d2c6cb46..38973f623d4da2b827d049b3855a150167fca4d3 100644 (file)
@@ -205,7 +205,6 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
                }
 
                msrpc_gen(out_mem_ctx, 
-                         lp_iconv_convenience(gensec_security->lp_ctx),
                          &struct_blob, "aaaaa",
                          NTLMSSP_NAME_TYPE_DOMAIN, target_name,
                          NTLMSSP_NAME_TYPE_SERVER, gensec_ntlmssp_state->server_name,
@@ -226,7 +225,6 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
                }
                
                msrpc_gen(out_mem_ctx, 
-                         lp_iconv_convenience(gensec_security->lp_ctx),
                          out, gen_string,
                          "NTLMSSP", 
                          NTLMSSP_CHALLENGE,
index 49ed48df984eefc5a66b64e553cb099671f925c8..47d7a2104a648a64d70f44f149c5735a5d497fdf 100644 (file)
@@ -119,7 +119,6 @@ static NTSTATUS ntlmssp_make_packet_signature(struct gensec_ntlmssp_state *gense
                uint32_t crc;
                crc = crc32_calc_buffer(data, length);
                if (!msrpc_gen(sig_mem_ctx, 
-                              lp_iconv_convenience(gensec_ntlmssp_state->gensec_security->lp_ctx),
                               sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
                        return NT_STATUS_NO_MEMORY;
                }
@@ -248,7 +247,6 @@ NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
                uint32_t crc;
                crc = crc32_calc_buffer(data, length);
                if (!msrpc_gen(sig_mem_ctx, 
-                              lp_iconv_convenience(gensec_security->lp_ctx),
                               sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
                        return NT_STATUS_NO_MEMORY;
                }
index 9d387fcb4c1a7b193f73f81870079cf96e4c3362..cf85b13225dc795f80ebaf8e5ee99f0b5ca56816 100644 (file)
@@ -22,7 +22,7 @@ m4_include(../lib/util/xattr.m4)
 m4_include(../lib/util/capability.m4)
 m4_include(../lib/util/time.m4)
 m4_include(../lib/popt/samba.m4)
-m4_include(lib/charset/config.m4)
+m4_include(../lib/util/charset/config.m4)
 m4_include(lib/socket/config.m4)
 m4_include(../lib/zlib/zlib.m4)
 AC_ZLIB([
index 97cd0020a973b95ec580499f9cd0cbfda38c5ade..b0018c816123368ad3018897569bc4fedd774110 100644 (file)
@@ -25,7 +25,7 @@
 #include "librpc/gen_ndr/ndr_drsuapi.h"
 #include "lib/ldb/include/ldb.h"
 #include "system/time.h"
-#include "lib/charset/charset.h"
+#include "../lib/util/charset/charset.h"
 #include "librpc/ndr/libndr.h"
 #include "param/param.h"
 
index 1336b0157ecc03eda7e7b915d2128b05d55419da..63b5f2a2e4de70601abb0d48e54ccec37725a9ad 100644 (file)
@@ -65,7 +65,7 @@ static bool kpasswdd_make_error_reply(struct kdc_server *kdc,
        
        DEBUG(result_code ? 3 : 10, ("kpasswdd: %s\n", error_string));
 
-       len = push_utf8_talloc(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), &error_string_utf8, error_string);
+       len = push_utf8_talloc(mem_ctx, &error_string_utf8, error_string);
        if (len == -1) {
                return false;
        }
diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c
deleted file mode 100644 (file)
index e4f4bb5..0000000
+++ /dev/null
@@ -1,684 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   Samba utility functions
-   Copyright (C) Andrew Tridgell 1992-2001
-   Copyright (C) Simo Sorce 2001
-   
-   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/>.
-*/
-
-#include "includes.h"
-#include "system/locale.h"
-#include "dynconfig/dynconfig.h"
-#include "param/param.h"
-
-/**
- * @file
- * @brief Unicode string manipulation
- */
-
-/* these 2 tables define the unicode case handling.  They are loaded
-   at startup either via mmap() or read() from the lib directory */
-static void *upcase_table;
-static void *lowcase_table;
-
-
-/*******************************************************************
-load the case handling tables
-********************************************************************/
-void load_case_tables(void)
-{
-       TALLOC_CTX *mem_ctx;
-
-       mem_ctx = talloc_init("load_case_tables");
-       if (!mem_ctx) {
-               smb_panic("No memory for case_tables");
-       }
-       upcase_table = map_file(talloc_asprintf(mem_ctx, "%s/upcase.dat", dyn_DATADIR), 0x20000);
-       lowcase_table = map_file(talloc_asprintf(mem_ctx, "%s/lowcase.dat", dyn_DATADIR), 0x20000);
-       talloc_free(mem_ctx);
-       if (upcase_table == NULL) {
-               /* try also under codepages for testing purposes */
-               upcase_table = map_file("codepages/upcase.dat", 0x20000);
-               if (upcase_table == NULL) {
-                       upcase_table = (void *)-1;
-               }
-       }
-       if (lowcase_table == NULL) {
-               /* try also under codepages for testing purposes */
-               lowcase_table = map_file("codepages/lowcase.dat", 0x20000);
-               if (lowcase_table == NULL) {
-                       lowcase_table = (void *)-1;
-               }
-       }
-}
-
-/**
- Convert a codepoint_t to upper case.
-**/
-_PUBLIC_ codepoint_t toupper_w(codepoint_t val)
-{
-       if (val < 128) {
-               return toupper(val);
-       }
-       if (upcase_table == NULL) {
-               load_case_tables();
-       }
-       if (upcase_table == (void *)-1) {
-               return val;
-       }
-       if (val & 0xFFFF0000) {
-               return val;
-       }
-       return SVAL(upcase_table, val*2);
-}
-
-/**
- Convert a codepoint_t to lower case.
-**/
-_PUBLIC_ codepoint_t tolower_w(codepoint_t val)
-{
-       if (val < 128) {
-               return tolower(val);
-       }
-       if (lowcase_table == NULL) {
-               load_case_tables();
-       }
-       if (lowcase_table == (void *)-1) {
-               return val;
-       }
-       if (val & 0xFFFF0000) {
-               return val;
-       }
-       return SVAL(lowcase_table, val*2);
-}
-
-/**
-  compare two codepoints case insensitively
-*/
-_PUBLIC_ int codepoint_cmpi(codepoint_t c1, codepoint_t c2)
-{
-       if (c1 == c2 ||
-           toupper_w(c1) == toupper_w(c2)) {
-               return 0;
-       }
-       return c1 - c2;
-}
-
-/**
- Case insensitive string compararison
-**/
-_PUBLIC_ int strcasecmp_m(const char *s1, const char *s2)
-{
-       codepoint_t c1=0, c2=0;
-       size_t size1, size2;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
-
-       /* handle null ptr comparisons to simplify the use in qsort */
-       if (s1 == s2) return 0;
-       if (s1 == NULL) return -1;
-       if (s2 == NULL) return 1;
-
-       while (*s1 && *s2) {
-               c1 = next_codepoint(iconv_convenience, s1, &size1);
-               c2 = next_codepoint(iconv_convenience, s2, &size2);
-
-               s1 += size1;
-               s2 += size2;
-
-               if (c1 == c2) {
-                       continue;
-               }
-
-               if (c1 == INVALID_CODEPOINT ||
-                   c2 == INVALID_CODEPOINT) {
-                       /* what else can we do?? */
-                       return strcasecmp(s1, s2);
-               }
-
-               if (toupper_w(c1) != toupper_w(c2)) {
-                       return c1 - c2;
-               }
-       }
-
-       return *s1 - *s2;
-}
-
-/**
- * Get the next token from a string, return False if none found.
- * Handles double-quotes.
- * 
- * Based on a routine by GJC@VILLAGE.COM. 
- * Extensively modified by Andrew.Tridgell@anu.edu.au
- **/
-_PUBLIC_ bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
-{
-       const char *s;
-       bool quoted;
-       size_t len=1;
-
-       if (!ptr)
-               return false;
-
-       s = *ptr;
-
-       /* default to simple separators */
-       if (!sep)
-               sep = " \t\n\r";
-
-       /* find the first non sep char */
-       while (*s && strchr_m(sep,*s))
-               s++;
-       
-       /* nothing left? */
-       if (!*s)
-               return false;
-       
-       /* copy over the token */
-       for (quoted = false; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) {
-               if (*s == '\"') {
-                       quoted = !quoted;
-               } else {
-                       len++;
-                       *buff++ = *s;
-               }
-       }
-       
-       *ptr = (*s) ? s+1 : s;  
-       *buff = 0;
-       
-       return true;
-}
-
-/**
- Case insensitive string compararison, length limited
-**/
-_PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n)
-{
-       codepoint_t c1=0, c2=0;
-       size_t size1, size2;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
-
-       /* handle null ptr comparisons to simplify the use in qsort */
-       if (s1 == s2) return 0;
-       if (s1 == NULL) return -1;
-       if (s2 == NULL) return 1;
-
-       while (*s1 && *s2 && n) {
-               n--;
-
-               c1 = next_codepoint(iconv_convenience, s1, &size1);
-               c2 = next_codepoint(iconv_convenience, s2, &size2);
-
-               s1 += size1;
-               s2 += size2;
-
-               if (c1 == c2) {
-                       continue;
-               }
-
-               if (c1 == INVALID_CODEPOINT ||
-                   c2 == INVALID_CODEPOINT) {
-                       /* what else can we do?? */
-                       return strcasecmp(s1, s2);
-               }
-
-               if (toupper_w(c1) != toupper_w(c2)) {
-                       return c1 - c2;
-               }
-       }
-
-       if (n == 0) {
-               return 0;
-       }
-
-       return *s1 - *s2;
-}
-
-/**
- * Compare 2 strings.
- *
- * @note The comparison is case-insensitive.
- **/
-_PUBLIC_ bool strequal_w(const char *s1, const char *s2)
-{
-       return strcasecmp_m(s1,s2) == 0;
-}
-
-/**
- Compare 2 strings (case sensitive).
-**/
-_PUBLIC_ bool strcsequal_w(const char *s1,const char *s2)
-{
-       if (s1 == s2)
-               return true;
-       if (!s1 || !s2)
-               return false;
-       
-       return strcmp(s1,s2) == 0;
-}
-
-
-/**
- String replace.
- NOTE: oldc and newc must be 7 bit characters
-**/
-_PUBLIC_ void string_replace_w(char *s, char oldc, char newc)
-{
-       while (s && *s) {
-               size_t size;
-               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), s, &size);
-               if (c == oldc) {
-                       *s = newc;
-               }
-               s += size;
-       }
-}
-
-/**
- Paranoid strcpy into a buffer of given length (includes terminating
- zero. Strips out all but 'a-Z0-9' and the character in other_safe_chars
- and replaces with '_'. Deliberately does *NOT* check for multibyte
- characters. Don't change it !
-**/
-
-_PUBLIC_ char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength)
-{
-       size_t len, i;
-
-       if (maxlength == 0) {
-               /* can't fit any bytes at all! */
-               return NULL;
-       }
-
-       if (!dest) {
-               DEBUG(0,("ERROR: NULL dest in alpha_strcpy\n"));
-               return NULL;
-       }
-
-       if (!src) {
-               *dest = 0;
-               return dest;
-       }  
-
-       len = strlen(src);
-       if (len >= maxlength)
-               len = maxlength - 1;
-
-       if (!other_safe_chars)
-               other_safe_chars = "";
-
-       for(i = 0; i < len; i++) {
-               int val = (src[i] & 0xff);
-               if (isupper(val) || islower(val) || isdigit(val) || strchr_m(other_safe_chars, val))
-                       dest[i] = src[i];
-               else
-                       dest[i] = '_';
-       }
-
-       dest[i] = '\0';
-
-       return dest;
-}
-
-/**
- Count the number of UCS2 characters in a string. Normally this will
- be the same as the number of bytes in a string for single byte strings,
- but will be different for multibyte.
-**/
-_PUBLIC_ size_t strlen_m(const char *s)
-{
-       size_t count = 0;
-
-       if (!s) {
-               return 0;
-       }
-
-       while (*s && !(((uint8_t)*s) & 0x80)) {
-               s++;
-               count++;
-       }
-
-       if (!*s) {
-               return count;
-       }
-
-       while (*s) {
-               size_t c_size;
-               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), s, &c_size);
-               if (c < 0x10000) {
-                       count += 1;
-               } else {
-                       count += 2;
-               }
-               s += c_size;
-       }
-
-       return count;
-}
-
-/**
-   Work out the number of multibyte chars in a string, including the NULL
-   terminator.
-**/
-_PUBLIC_ size_t strlen_m_term(const char *s)
-{
-       if (!s) {
-               return 0;
-       }
-
-       return strlen_m(s) + 1;
-}
-
-/**
- Strchr and strrchr_m are a bit complex on general multi-byte strings. 
-**/
-_PUBLIC_ char *strchr_m(const char *s, char c)
-{
-       if (s == NULL) {
-               return NULL;
-       }
-       /* characters below 0x3F are guaranteed to not appear in
-          non-initial position in multi-byte charsets */
-       if ((c & 0xC0) == 0) {
-               return strchr(s, c);
-       }
-
-       while (*s) {
-               size_t size;
-               codepoint_t c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s, &size);
-               if (c2 == c) {
-                       return discard_const_p(char, s);
-               }
-               s += size;
-       }
-
-       return NULL;
-}
-
-/**
- * Multibyte-character version of strrchr
- */
-_PUBLIC_ char *strrchr_m(const char *s, char c)
-{
-       char *ret = NULL;
-
-       if (s == NULL) {
-               return NULL;
-       }
-
-       /* characters below 0x3F are guaranteed to not appear in
-          non-initial position in multi-byte charsets */
-       if ((c & 0xC0) == 0) {
-               return strrchr(s, c);
-       }
-
-       while (*s) {
-               size_t size;
-               codepoint_t c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s, &size);
-               if (c2 == c) {
-                       ret = discard_const_p(char, s);
-               }
-               s += size;
-       }
-
-       return ret;
-}
-
-/**
-  return True if any (multi-byte) character is lower case
-*/
-_PUBLIC_ bool strhaslower(const char *string)
-{
-       while (*string) {
-               size_t c_size;
-               codepoint_t s;
-               codepoint_t t;
-
-               s = next_codepoint(lp_iconv_convenience(global_loadparm), string, &c_size);
-               string += c_size;
-
-               t = toupper_w(s);
-
-               if (s != t) {
-                       return true; /* that means it has lower case chars */
-               }
-       }
-
-       return false;
-} 
-
-/**
-  return True if any (multi-byte) character is upper case
-*/
-_PUBLIC_ bool strhasupper(const char *string)
-{
-       while (*string) {
-               size_t c_size;
-               codepoint_t s;
-               codepoint_t t;
-
-               s = next_codepoint(lp_iconv_convenience(global_loadparm), string, &c_size);
-               string += c_size;
-
-               t = tolower_w(s);
-
-               if (s != t) {
-                       return true; /* that means it has upper case chars */
-               }
-       }
-
-       return false;
-} 
-
-/**
- Convert a string to lower case, allocated with talloc
-**/
-_PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
-{
-       size_t size=0;
-       char *dest;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
-
-       /* this takes advantage of the fact that upper/lower can't
-          change the length of a character by more than 1 byte */
-       dest = talloc_array(ctx, char, 2*(strlen(src))+1);
-       if (dest == NULL) {
-               return NULL;
-       }
-
-       while (*src) {
-               size_t c_size;
-               codepoint_t c = next_codepoint(iconv_convenience, src, &c_size);
-               src += c_size;
-
-               c = tolower_w(c);
-
-               c_size = push_codepoint(iconv_convenience, dest+size, c);
-               if (c_size == -1) {
-                       talloc_free(dest);
-                       return NULL;
-               }
-               size += c_size;
-       }
-
-       dest[size] = 0;
-
-       /* trim it so talloc_append_string() works */
-       dest = talloc_realloc(ctx, dest, char, size+1);
-
-       talloc_set_name_const(dest, dest);
-
-       return dest;
-}
-
-/**
- Convert a string to UPPER case, allocated with talloc
- source length limited to n bytes
-**/
-_PUBLIC_ char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n)
-{
-       size_t size=0;
-       char *dest;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
-       
-       if (!src) {
-               return NULL;
-       }
-
-       /* this takes advantage of the fact that upper/lower can't
-          change the length of a character by more than 1 byte */
-       dest = talloc_array(ctx, char, 2*(n+1));
-       if (dest == NULL) {
-               return NULL;
-       }
-
-       while (*src && n--) {
-               size_t c_size;
-               codepoint_t c = next_codepoint(iconv_convenience, src, &c_size);
-               src += c_size;
-
-               c = toupper_w(c);
-
-               c_size = push_codepoint(iconv_convenience, dest+size, c);
-               if (c_size == -1) {
-                       talloc_free(dest);
-                       return NULL;
-               }
-               size += c_size;
-       }
-
-       dest[size] = 0;
-
-       /* trim it so talloc_append_string() works */
-       dest = talloc_realloc(ctx, dest, char, size+1);
-
-       talloc_set_name_const(dest, dest);
-
-       return dest;
-}
-
-/**
- Convert a string to UPPER case, allocated with talloc
-**/
-_PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
-{
-       return strupper_talloc_n(ctx, src, src?strlen(src):0);
-}
-
-/**
- talloc_strdup() a unix string to upper case.
-**/
-_PUBLIC_ char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *src)
-{
-       return strupper_talloc(ctx, src);
-}
-
-/**
- Convert a string to lower case.
-**/
-_PUBLIC_ void strlower_m(char *s)
-{
-       char *d;
-       struct smb_iconv_convenience *iconv_convenience;
-
-       /* this is quite a common operation, so we want it to be
-          fast. We optimise for the ascii case, knowing that all our
-          supported multi-byte character sets are ascii-compatible
-          (ie. they match for the first 128 chars) */
-       while (*s && !(((uint8_t)*s) & 0x80)) {
-               *s = tolower((uint8_t)*s);
-               s++;
-       }
-
-       if (!*s)
-               return;
-
-       iconv_convenience = lp_iconv_convenience(global_loadparm);
-
-       d = s;
-
-       while (*s) {
-               size_t c_size, c_size2;
-               codepoint_t c = next_codepoint(iconv_convenience, s, &c_size);
-               c_size2 = push_codepoint(iconv_convenience, d, tolower_w(c));
-               if (c_size2 > c_size) {
-                       DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strlower_m\n",
-                                c, tolower_w(c), (int)c_size, (int)c_size2));
-                       smb_panic("codepoint expansion in strlower_m\n");
-               }
-               s += c_size;
-               d += c_size2;
-       }
-       *d = 0;
-}
-
-/**
- Convert a string to UPPER case.
-**/
-_PUBLIC_ void strupper_m(char *s)
-{
-       char *d;
-       struct smb_iconv_convenience *iconv_convenience;
-
-       /* this is quite a common operation, so we want it to be
-          fast. We optimise for the ascii case, knowing that all our
-          supported multi-byte character sets are ascii-compatible
-          (ie. they match for the first 128 chars) */
-       while (*s && !(((uint8_t)*s) & 0x80)) {
-               *s = toupper((uint8_t)*s);
-               s++;
-       }
-
-       if (!*s)
-               return;
-
-       iconv_convenience = lp_iconv_convenience(global_loadparm);
-
-       d = s;
-
-       while (*s) {
-               size_t c_size, c_size2;
-               codepoint_t c = next_codepoint(iconv_convenience, s, &c_size);
-               c_size2 = push_codepoint(iconv_convenience, d, toupper_w(c));
-               if (c_size2 > c_size) {
-                       DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strupper_m\n",
-                                c, toupper_w(c), (int)c_size, (int)c_size2));
-                       smb_panic("codepoint expansion in strupper_m\n");
-               }
-               s += c_size;
-               d += c_size2;
-       }
-       *d = 0;
-}
-
-
-/**
- Find the number of 'c' chars in a string
-**/
-_PUBLIC_ size_t count_chars_w(const char *s, char c)
-{
-       size_t count = 0;
-
-       while (*s) {
-               size_t size;
-               codepoint_t c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s, &size);
-               if (c2 == c) count++;
-               s += size;
-       }
-
-       return count;
-}
-
-
index 301cd3002e96fcaf4f111bed7ee915ac2a67cdc8..c983cd35c14ed3e941858f8c20946ac3ee27d23b 100644 (file)
@@ -21,7 +21,7 @@
 #define __TDR_H__
 
 #include <talloc.h>
-#include "charset/charset.h"
+#include "../lib/util/charset/charset.h"
 
 #define TDR_BIG_ENDIAN                 0x01
 #define TDR_ALIGN2                     0x02
index a78c444da79df69940f8536b9acc4165cc7fe1f9..2803aaff5e3bbb82f1eb46ecc94d090f21c02847 100644 (file)
@@ -67,7 +67,7 @@ bool E_md4hash(const char *passwd, uint8_t p16[16])
        int len;
        void *wpwd;
 
-       len = push_ucs2_talloc(NULL, lp_iconv_convenience(global_loadparm), &wpwd, passwd);
+       len = push_ucs2_talloc(NULL, &wpwd, passwd);
        if (len < 2) {
                /* We don't want to return fixed data, as most callers
                 * don't check */
@@ -97,7 +97,7 @@ bool E_deshash(const char *passwd, uint8_t p16[16])
        ZERO_STRUCT(dospwd);
 
        /* Password must be converted to DOS charset - null terminated, uppercase. */
-       push_string(lp_iconv_convenience(global_loadparm), dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE);
+       push_string(dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE);
 
        /* Only the first 14 chars are considered, password need not be null terminated. */
        E_P16((const uint8_t *)dospwd, p16);
@@ -124,7 +124,6 @@ bool ntv2_owf_gen(const uint8_t owf[16],
 
        HMACMD5Context ctx;
        TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in); 
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        if (!mem_ctx) {
                return false;
@@ -152,14 +151,14 @@ bool ntv2_owf_gen(const uint8_t owf[16],
                }
        }
 
-       user_byte_len = push_ucs2_talloc(mem_ctx, iconv_convenience, &user, user_in);
+       user_byte_len = push_ucs2_talloc(mem_ctx, &user, user_in);
        if (user_byte_len == (ssize_t)-1) {
                DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n"));
                talloc_free(mem_ctx);
                return false;
        }
 
-       domain_byte_len = push_ucs2_talloc(mem_ctx, iconv_convenience, &domain, domain_in);
+       domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in);
        if (domain_byte_len == (ssize_t)-1) {
                DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n"));
                talloc_free(mem_ctx);
@@ -295,13 +294,12 @@ void SMBsesskeygen_lm_sess_key(const uint8_t lm_hash[16],
 }
 
 DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx, 
-                                    struct smb_iconv_convenience *iconv_convenience,
                                     const char *hostname, 
                                     const char *domain)
 {
        DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0);
        
-       msrpc_gen(mem_ctx, iconv_convenience, &names_blob, 
+       msrpc_gen(mem_ctx, &names_blob, 
                  "aaa", 
                  NTLMSSP_NAME_TYPE_DOMAIN, domain,
                  NTLMSSP_NAME_TYPE_SERVER, hostname,
@@ -324,7 +322,7 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO
 
        /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */
 
-       msrpc_gen(mem_ctx, NULL, &response, "ddbbdb", 
+       msrpc_gen(mem_ctx, &response, "ddbbdb", 
                  0x00000101,     /* Header  */
                  0,              /* 'Reserved'  */
                  long_date, 8,   /* Timestamp */
@@ -472,7 +470,7 @@ bool encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag
        /* the incoming buffer can be any alignment. */
        string_flags |= STR_NOALIGN;
 
-       new_pw_len = push_string(lp_iconv_convenience(global_loadparm), new_pw,
+       new_pw_len = push_string(new_pw,
                                 password, 
                                 sizeof(new_pw), string_flags);
        
@@ -525,7 +523,7 @@ bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
        }
 
        /* decode into the return buffer.  Buffer length supplied */
-       converted_pw_len = pull_string(lp_iconv_convenience(global_loadparm), new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, 
+       converted_pw_len = pull_string(new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, 
                                  byte_len, string_flags);
 
        if (converted_pw_len == -1) {
index 4b5d2dc39787baa1dd3cad6869adb38189043ca4..ccfb28b84dba9b42fcc896388652443e23204d50 100644 (file)
@@ -196,10 +196,9 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
        io.in.fallback_to_anonymous = false;
 
        /* This workgroup gets sent out by the SPNEGO session setup.
-        * I don't know of any servers that look at it, so we might
-        * hardcode it to "" some day, when the war on global_loadparm
-        * is complete -- abartlet 2008-04-28 */
-       io.in.workgroup = lp_workgroup(global_loadparm);
+        * I don't know of any servers that look at it, so we 
+        * hardcode it to "". */
+       io.in.workgroup = "";
        io.in.options = *options;
        io.in.session_options = *session_options;
        
index 353b66c6220271a808688a73ef5e121e41aebaed..caef28d7fc25f40f28ff597b6277a437dd85af4a 100644 (file)
@@ -430,7 +430,7 @@ size_t smbcli_req_append_string(struct smbcli_request *req, const char *str, uin
 
        smbcli_req_grow_allocation(req, len + req->out.data_size);
 
-       len = push_string(lp_iconv_convenience(global_loadparm), req->out.data + req->out.data_size, str, len, flags);
+       len = push_string(req->out.data + req->out.data_size, str, len, flags);
 
        smbcli_req_grow_data(req, len + req->out.data_size);
 
@@ -977,7 +977,7 @@ size_t smbcli_blob_append_string(struct smbcli_session *session,
                return 0;
        }
 
-       len = push_string(lp_iconv_convenience(global_loadparm), blob->data + blob->length, str, max_len, flags);
+       len = push_string(blob->data + blob->length, str, max_len, flags);
 
        blob->length += len;
 
index 645f5362ac30238d5ec3a2c57ff74b504d9eeb19..76c1f952e79fbe3554eacdf2a3bf90a135971f66 100644 (file)
@@ -260,7 +260,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
 {
        NTSTATUS nt_status = NT_STATUS_INTERNAL_ERROR;
        struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
-       DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm));
+       DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
        DATA_BLOB session_key = data_blob(NULL, 0);
        int flags = CLI_CRED_NTLM_AUTH;
 
@@ -334,7 +334,7 @@ static NTSTATUS session_setup_old(struct composite_context *c,
        NTSTATUS nt_status;
        struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
        const char *password = cli_credentials_get_password(io->in.credentials);
-       DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm));
+       DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
        DATA_BLOB session_key;
        int flags = 0;
        if (session->options.lanman_auth) {
index 7095160004541c6da79d4087bb95035559c7abf5..4aad654b3bf9b64bd261a23c2028f4b5934220d8 100644 (file)
@@ -67,7 +67,7 @@ struct libnet_ModifyUser {
 
 #define SET_FIELD_LSA_STRING(new, current, mod, field, flag) \
        if (new.field != NULL && \
-           !strequal_w(current->field.string, new.field)) { \
+           !strequal_m(current->field.string, new.field)) { \
                \
                mod->field = talloc_strdup(mem_ctx, new.field); \
                if (mod->field == NULL) return NT_STATUS_NO_MEMORY; \
index 8ce86b91ca2eac19a9f2a7fad9c9918f584b4e2a..278c38454d57b6e0da2a50a2672a77bc6d09db3f 100644 (file)
@@ -9,7 +9,7 @@ mkinclude auth/config.mk
 mkinclude nsswitch/config.mk
 mkinclude lib/samba3/config.mk
 mkinclude lib/socket/config.mk
-mkinclude lib/charset/config.mk
+mkinclude ../lib/util/charset/config.mk
 mkinclude lib/ldb-samba/config.mk
 mkinclude lib/tls/config.mk
 mkinclude lib/registry/config.mk
index a36a66b80f3dabba78e685c640ed29e1e61ce3b4..60c95a3bd06d95a4864e83c9ea3ab4e44f6aa553 100644 (file)
@@ -836,7 +836,7 @@ static bool wbinfo_auth_crap(struct loadparm_context *lp_ctx, char *username)
                server_chal = data_blob(request.data.auth_crap.chal, 8); 
                
                /* Pretend this is a login to 'us', for blob purposes */
-               names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_iconv_convenience(lp_ctx), lp_netbios_name(lp_ctx), lp_workgroup(lp_ctx));
+               names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(lp_ctx), lp_workgroup(lp_ctx));
                
                if (!SMBNTLMv2encrypt(mem_ctx, name_user, name_domain, pass, &server_chal, 
                                      &names_blob,
index b52c3e387bd45516a44d478e1a0c0b2fd6734dd9..720ddaaa7bf09a4fd00c1b123bd13a47a063293b 100644 (file)
@@ -183,7 +183,7 @@ uint32_t pvfs_name_hash(const char *key, size_t length)
        while (*key && length--) {
                size_t c_size;
                codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), key, &c_size);
-               c = toupper_w(c);
+               c = toupper_m(c);
                 value *= fnv1_prime;
                 value ^= (uint32_t)c;
                key += c_size;
index aa9b11a9737ebae0ba395441cf66a8792f4843e7..540e51a43b779a3ed6ecb12d3e1829497f3807b9 100644 (file)
@@ -83,8 +83,8 @@ static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs,
 
                p = (char *)io->ioctl.out.blob.data;
                SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */);
-               push_string(lp_iconv_convenience(ntvfs->ctx->lp_ctx), p+2, lp_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
-               push_string(lp_iconv_convenience(ntvfs->ctx->lp_ctx), p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
+               push_string(p+2, lp_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
+               push_string(p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
                return NT_STATUS_OK;
        }
 
index c88728a9fdc6ef1df45fe78182da41544dbc63cc..5a44fd5ae692fc3021d9fcbbd92d0c12287b324b 100644 (file)
@@ -8,7 +8,7 @@ LIBPYTHON_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, modules.o)
 [SUBSYSTEM::PYTALLOC]
 PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON LIBTALLOC
 
-PYTALLOC_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, pytalloc.o)
+PYTALLOC_OBJ_FILES = ../lib/talloc/pytalloc.o
 
 [PYTHON::python_uuid]
 PRIVATE_DEPENDENCIES = LIBNDR 
index bd250361a402d0cebe00dcd15ac21baa101851e6..baa9b3e4d80939c9460eafcf578fd33d7bb16e4e 100644 (file)
@@ -140,10 +140,10 @@ size_t smbsrv_blob_push_string(TALLOC_CTX *mem_ctx,
                alignment = 1;
                if (dest_len > 0) {
                        SCVAL(blob->data + offset, 0, 0);
-                       ret = push_string(lp_iconv_convenience(global_loadparm), blob->data + offset + 1, str, dest_len-1, flags);
+                       ret = push_string(blob->data + offset + 1, str, dest_len-1, flags);
                }
        } else {
-               ret = push_string(lp_iconv_convenience(global_loadparm), blob->data + offset, str, dest_len, flags);
+               ret = push_string(blob->data + offset, str, dest_len, flags);
        }
 
        /* sometimes the string needs to be terminated, but the length
index 4a06ea4b91e04869853207b444a2cfb2294d61b7..3480711ed20bfc2df42e7897760fb45637e05efc 100644 (file)
@@ -398,7 +398,7 @@ static NTSTATUS nttrans_notify_change_send(struct nttrans_op *op)
                ssize_t len;
 
                SIVAL(p, 4, info->nttrans.out.changes[i].action);
-               len = push_string(lp_iconv_convenience(global_loadparm), p + 12, info->nttrans.out.changes[i].name.s, 
+               len = push_string(p + 12, info->nttrans.out.changes[i].name.s, 
                                  op->trans->out.params.length - 
                                  (p+12 - op->trans->out.params.data), STR_UNICODE);
                SIVAL(p, 8, len);
index 241c2628572c2fdd1acb9fa8ab41bac92fc302b2..52eb69fe68fbb3d10915e22a08f968fc2d949ae5 100644 (file)
@@ -428,7 +428,7 @@ size_t req_push_str(struct smbsrv_request *req, uint8_t *dest, const char *str,
                dest = req->out.buffer + PTR_DIFF(dest, buf0);
        }
 
-       len = push_string(lp_iconv_convenience(req->smb_conn->lp_ctx), dest, str, len, flags);
+       len = push_string(dest, str, len, flags);
 
        grow_size = len + PTR_DIFF(dest, req->out.data);
 
index 4f4402ba3301d2e11ab20958807376c6d925ce70..221fafadfdbfe8612af383ffd1b9199c6fd4f41c 100644 (file)
@@ -458,7 +458,7 @@ static void smb2srv_notify_send(struct ntvfs_request *ntvfs)
                ssize_t len;
 
                SIVAL(p, 4, io->smb2.out.changes[i].action);
-               len = push_string(lp_iconv_convenience(ntvfs->ctx->lp_ctx), p + 12, io->smb2.out.changes[i].name.s, 
+               len = push_string(p + 12, io->smb2.out.changes[i].name.s, 
                                  blob.length - (p+12 - blob.data), STR_UNICODE);
                SIVAL(p, 8, len);
 
index 2768ea8ab5c581f21a8672391add533cb0700212..e366abf681eae1bd43b63d6610b76190c236b09b 100644 (file)
@@ -2,15 +2,13 @@
 # perhaps by some perl scripts run from config.status ?
 #
 $(gen_ndrsrcdir)/misc.h: idl
-$(ndrsrcdir)/libndr.h: $(ndrsrcdir)/libndr_proto.h $(gen_ndrsrcdir)/misc.h
+$(ndrsrcdir)/libndr.h: $(gen_ndrsrcdir)/misc.h
 $(dcerpcsrcdir)/dcerpc.h: $(dcerpcsrcdir)/dcerpc_proto.h
 $(authsrcdir)/credentials/credentials.h: $(authsrcdir)/credentials/credentials_proto.h
 $(libclisrcdir)/nbt/libnbt.h: $(libclisrcdir)/nbt/nbt_proto.h
-$(libcharsetsrcdir)/charset.h: $(libcharsetsrcdir)/charset_proto.h
 
 include/includes.h: \
                include/config.h \
-               $(libcharsetsrcdir)/charset.h \
                $(gen_ndrsrcdir)/misc.h
 
 proto::
index 5212f1edeec21b879479591fbde0da1c3c83b640..7f88662baa5fe6c4163e6e24f5a8eaa393513e0a 100644 (file)
@@ -163,7 +163,7 @@ static bool trans2_op_exists(struct smbcli_state *cli, int op)
 /****************************************************************************
 check for existance of a trans2 call
 ****************************************************************************/
-static bool scan_trans2(struct smb_iconv_convenience *iconv_convenience, 
+static bool scan_trans2(
                        struct smbcli_state *cli, int op, int level,
                        int fnum, int dnum, int qfnum, const char *fname)
 {
@@ -233,7 +233,7 @@ static bool scan_trans2(struct smb_iconv_convenience *iconv_convenience,
        SSVAL(param, 0, level);
        SSVAL(param, 2, 0);
        SSVAL(param, 4, 0);
-       param_len += push_string(iconv_convenience,
+       param_len += push_string(
                        &param[6], fname, PARAM_SIZE-7,
                        STR_TERMINATE|STR_UNICODE);
 
@@ -249,7 +249,7 @@ static bool scan_trans2(struct smb_iconv_convenience *iconv_convenience,
        SSVAL(param, 0, level);
        SSVAL(param, 2, 0);
        SSVAL(param, 4, 0);
-       param_len += push_string(iconv_convenience,
+       param_len += push_string(
                        &param[6], "\\newfile.dat", PARAM_SIZE-7,
                        STR_TERMINATE|STR_UNICODE);
 
@@ -266,7 +266,7 @@ static bool scan_trans2(struct smb_iconv_convenience *iconv_convenience,
        smbcli_mkdir(cli->tree, "\\testdir");
        param_len = 2;
        SSVAL(param, 0, level);
-       param_len += push_string(iconv_convenience,
+       param_len += push_string(
                        &param[2], "\\testdir", PARAM_SIZE-3,
                        STR_TERMINATE|STR_UNICODE);
 
@@ -321,15 +321,15 @@ bool torture_trans2_scan(struct torture_context *torture,
                }
 
                for (level = 0; level <= 50; level++) {
-                       scan_trans2(lp_iconv_convenience(torture->lp_ctx), cli, op, level, fnum, dnum, qfnum, fname);
+                       scan_trans2(cli, op, level, fnum, dnum, qfnum, fname);
                }
 
                for (level = 0x100; level <= 0x130; level++) {
-                       scan_trans2(lp_iconv_convenience(torture->lp_ctx), cli, op, level, fnum, dnum, qfnum, fname);
+                       scan_trans2(cli, op, level, fnum, dnum, qfnum, fname);
                }
 
                for (level = 1000; level < 1050; level++) {
-                       scan_trans2(lp_iconv_convenience(torture->lp_ctx), cli, op, level, fnum, dnum, qfnum, fname);
+                       scan_trans2(cli, op, level, fnum, dnum, qfnum, fname);
                }
        }
 
@@ -494,7 +494,7 @@ static bool scan_nttrans(struct smb_iconv_convenience *iconv_convenience,
        SSVAL(param, 0, level);
        SSVAL(param, 2, 0);
        SSVAL(param, 4, 0);
-       param_len += push_string(iconv_convenience,
+       param_len += push_string(
                        &param[6], fname, PARAM_SIZE,
                        STR_TERMINATE | STR_UNICODE);
 
@@ -510,7 +510,7 @@ static bool scan_nttrans(struct smb_iconv_convenience *iconv_convenience,
        SSVAL(param, 0, level);
        SSVAL(param, 2, 0);
        SSVAL(param, 4, 0);
-       param_len += push_string(iconv_convenience,
+       param_len += push_string(
                        &param[6], "\\newfile.dat", PARAM_SIZE,
                        STR_TERMINATE | STR_UNICODE);
 
@@ -527,8 +527,7 @@ static bool scan_nttrans(struct smb_iconv_convenience *iconv_convenience,
        smbcli_mkdir(cli->tree, "\\testdir");
        param_len = 2;
        SSVAL(param, 0, level);
-       param_len += push_string(iconv_convenience,
-                       &param[2], "\\testdir", PARAM_SIZE,
+       param_len += push_string(&param[2], "\\testdir", PARAM_SIZE,
                        STR_TERMINATE | STR_UNICODE);
 
        status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len,
index 9ea212dfa56ceda6cde1519bc0ea393248f82823..def391ba4eec898b59e1bf4c903d90335ed8bcb6 100644 (file)
@@ -19,7 +19,7 @@ PRIVATE_DEPENDENCIES = \
 #################################
 
 TORTURE_LOCAL_OBJ_FILES = \
-               $(torturesrcdir)/../lib/charset/tests/iconv.o \
+               $(torturesrcdir)/../../lib/util/charset/tests/iconv.o \
                $(torturesrcdir)/../../lib/talloc/testsuite.o \
                $(torturesrcdir)/../../lib/replace/test/getifaddrs.o \
                $(torturesrcdir)/../../lib/replace/test/os2_delete.o \
@@ -39,7 +39,7 @@ TORTURE_LOCAL_OBJ_FILES = \
                $(torturesrcdir)/../../lib/util/tests/file.o \
                $(torturesrcdir)/../../lib/util/tests/genrand.o \
                $(torturesrcdir)/../../lib/compression/testsuite.o \
-               $(torturesrcdir)/../lib/charset/tests/charset.o \
+               $(torturesrcdir)/../../lib/util/charset/tests/charset.o \
                $(torturesrcdir)/../libcli/security/tests/sddl.o \
                $(torturesrcdir)/../lib/tdr/testsuite.o \
                $(torturesrcdir)/../lib/events/testsuite.o \
index e93bd52b9a7d6586b59fc3ea4c062566eaf5705c..be231107dd6e9240786ffcf3ac0fd6f9828d0ffd 100644 (file)
@@ -184,7 +184,7 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr,
                return NT_STATUS_INVALID_PARAMETER;
 
        *dest = talloc_zero_array(mem_ctx, char, len+1);
-       pull_string(ndr->iconv_convenience, *dest, p, len+1, len, STR_ASCII);
+       pull_string(*dest, p, len+1, len, STR_ASCII);
 
        return NT_STATUS_OK;
 }
index f4ae5b35ebcc72c2471b7f5b61683d51c314719f..c2e12ec01dbb1425f01d614185ba9a9e23ebea5e 100644 (file)
@@ -592,7 +592,7 @@ bool test_netlogon_ops(struct dcerpc_pipe *p, struct torture_context *tctx,
        chal = data_blob_const(ninfo.challenge, 
                               sizeof(ninfo.challenge));
 
-       names_blob = NTLMv2_generate_names_blob(tctx, lp_iconv_convenience(tctx->lp_ctx), cli_credentials_get_workstation(credentials), 
+       names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials), 
                                                cli_credentials_get_domain(credentials));
 
        status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx, 
index 260c1cc1499bc6baeb74f19b8c940352e00e0d49..25ff7d0ea9b4052c8ec5360836e2d73f18c69495 100644 (file)
@@ -1041,7 +1041,7 @@ static bool schan(struct smbcli_state *cli,
 
                generate_random_buffer(chal.data, chal.length);
                names_blob = NTLMv2_generate_names_blob(
-                       mem_ctx, lp_iconv_convenience(lp_ctx), 
+                       mem_ctx, 
                        cli_credentials_get_workstation(user_creds),
                        cli_credentials_get_domain(user_creds));
                status = cli_credentials_get_ntlm_response(
@@ -2420,8 +2420,7 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
        memcpy(servername, r.out.info.info0.name, 16);
        servername[16] = '\0';
 
-       if (pull_ascii_talloc(mem_ctx, iconv_convenience, 
-                             name, servername) < 0) {
+       if (pull_ascii_talloc(mem_ctx, name, servername) < 0) {
                return NT_STATUS_NO_MEMORY;
        }
 
index b7028e660959d5e74d46ea0fa6db585ab742c206..01368cccad950fe32b6367134eeb34fd43d207c2 100644 (file)
@@ -595,7 +595,7 @@ static bool test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
        DATA_BLOB lmv2_response = data_blob(NULL, 0);
        DATA_BLOB lmv2_session_key = data_blob(NULL, 0);
        DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0);
-       DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, TEST_MACHINE_NAME, samlogon_state->workgroup);
+       DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, TEST_MACHINE_NAME, samlogon_state->workgroup);
 
        uint8_t lm_session_key[8];
        uint8_t user_session_key[16];
@@ -743,7 +743,7 @@ static bool test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
        DATA_BLOB lmv2_response = data_blob(NULL, 0);
        DATA_BLOB lmv2_session_key = data_blob(NULL, 0);
        DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0);
-       DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, samlogon_state->netbios_name, samlogon_state->workgroup);
+       DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->netbios_name, samlogon_state->workgroup);
 
        DATA_BLOB ntlm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
        DATA_BLOB ntlm_session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16);
@@ -1162,7 +1162,6 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
        ZERO_STRUCT(user_session_key);
        
        if ((push_ucs2_talloc(samlogon_state->mem_ctx, 
-                             samlogon_state->iconv_convenience, 
                              &unicodepw, samlogon_state->password)) == -1) {
                DEBUG(0, ("push_ucs2_allocate failed!\n"));
                exit(1);
index fae0093e4d12a5fb3d4344036be3d5581f6273e4..15d40a2e176a3250c8c14a7e1717eeef9c9f3bc4 100644 (file)
@@ -68,7 +68,7 @@ bool test_netlogon_ex_ops(struct dcerpc_pipe *p, struct torture_context *tctx,
        chal = data_blob_const(ninfo.challenge, 
                               sizeof(ninfo.challenge));
 
-       names_blob = NTLMv2_generate_names_blob(tctx, lp_iconv_convenience(tctx->lp_ctx), cli_credentials_get_workstation(credentials), 
+       names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials), 
                                                cli_credentials_get_domain(credentials));
 
        status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx, 
@@ -573,7 +573,7 @@ static bool torture_schannel_bench_start(struct torture_schannel_bench_conn *con
        chal = data_blob_const(conn->ninfo.challenge,
                               sizeof(conn->ninfo.challenge));
 
-       names_blob = NTLMv2_generate_names_blob(conn->tmp, lp_iconv_convenience(s->tctx->lp_ctx),
+       names_blob = NTLMv2_generate_names_blob(conn->tmp, 
                                                cli_credentials_get_workstation(conn->wks_creds),
                                                cli_credentials_get_domain(conn->wks_creds));
 
index 015f20f6e2cdbc815c4d2fc7df1cdee8cf508e16..0f49562d8b334bcf32cb59a23742f732b9254bcd 100644 (file)
@@ -966,8 +966,7 @@ static bool test_NetrMessageBufferSend(struct torture_context *tctx,
        size_t size;
        uint8_t *msg;
 
-       size = push_ucs2_talloc(tctx, lp_iconv_convenience(tctx->lp_ctx), 
-                               (void **)&msg, message);
+       size = push_ucs2_talloc(tctx, (void **)&msg, message);
 
        r.in.server_name = dcerpc_server_name(p);
        r.in.message_name = dcerpc_server_name(p);
index ee54bcd58f7818a1873b53c53e0f0aea007fc9e2..5913f8d1bfe704147d660e2bc1da3ef327a3a406 100644 (file)
@@ -245,7 +245,6 @@ struct composite_context *wb_cmd_pam_auth_send(TALLOC_CTX *mem_ctx,
 
        names_blob = NTLMv2_generate_names_blob(
                mem_ctx,
-               lp_iconv_convenience(service->task->lp_ctx),
                cli_credentials_get_workstation(credentials), 
                cli_credentials_get_domain(credentials));