The branch, master has been updated via f092214 charcnv: ensure convert_string_error doesn't conflict with s3 function via 0189087 s3-charcnv: fixed converted_size return in fast paths via f08ec22 s3-charcnv: removed unused function via b5616ad lib/util/charset rename iconv_convenience to iconv_handle via 7824111 s3-charcnv: convert_string_internal() should not display errors via d85dbfb s3-string: removed the conv_silent global via 232fb01 s3-string: removed last use of conv_silent via 64258a3 s3-charcnv Add convert_string_error() via 2643a7b charcnv: added convert_string_error() via 3726192 s3-includes: fixed CONST_DISCARD() to actually discard const via aaae412 unistr: moved some UCS2 macros into util_unistr via 5a20325 libcli: created smb_constants.h via bfce962 tdb: rename convert_string() to tdb_convert_string() via 2588e71 s3-libsmb: work our correct length for EA strings via 5ed2039 s3-string: sec_len==-1 support is no longer needed via 4d47493 s3-dfs: removed the last user of sec_len==-1 in pull_*_base_talloc() via 3ceb353 s3-lib: make pull_ucs2_base_talloc static via 980064b lib: remove unused pieces of string_wrappers.h via 8cd4a38 lib: move the string wrappers from source3/include to common lib/util via f705fc9 s3-string: moved fstring functions into their own file from 8812148 s3:dbwrap_ctdb: fix non-locked fetch on persistent db's causing corruption
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit f0922147fec83fc4900208669e6cb0e0607757cd Author: Andrew Tridgell <tri...@samba.org> Date: Fri Mar 25 14:34:43 2011 +1100 charcnv: ensure convert_string_error doesn't conflict with s3 function use _handle for handle based functions Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> Autobuild-User: Andrew Tridgell <tri...@samba.org> Autobuild-Date: Fri Mar 25 05:22:24 CET 2011 on sn-devel-104 commit 0189087e257f37dc52beebc49967ac763f58dec4 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Mar 25 12:10:41 2011 +1100 s3-charcnv: fixed converted_size return in fast paths commit f08ec2296edf4cc8f6f5b7a6f3f69975a8724933 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Mar 25 11:41:52 2011 +1100 s3-charcnv: removed unused function lp_failed_convert_char() is not needed any more commit b5616adc8adbcee61bb670378f9c066225d9dcf3 Author: Andrew Bartlett <abart...@samba.org> Date: Fri Mar 25 08:37:00 2011 +1100 lib/util/charset rename iconv_convenience to iconv_handle This better reflects what this structure is Andrew Bartlett commit 7824111d07ae12b34e03da1e72884d421a9f9f33 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Mar 25 10:52:32 2011 +1100 s3-charcnv: convert_string_internal() should not display errors debug error display happens in the convert_string() outer function commit d85dbfb3dbb7a17c38f1f981362cc68400fa4410 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 15:43:02 2011 +1100 s3-string: removed the conv_silent global use convert_string_error() instead Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> commit 232fb016a15c0536aabc3bc23607721398693037 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 15:44:03 2011 +1100 s3-string: removed last use of conv_silent This replaces the push_ascii_nstring() implementation with a call to convert_string_error() Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> commit 64258a300f3a8e1c1e0d8e7edcf71ace5a573d0e Author: Andrew Bartlett <abart...@samba.org> Date: Fri Mar 25 09:15:06 2011 +1100 s3-charcnv Add convert_string_error() This function returns errors rather than printing them. Andrew Bartlett commit 2643a7ba6b87d0378323237e143ce128dfc09837 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 15:59:26 2011 +1100 charcnv: added convert_string_error() this will allow us to remove conv_silent Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> commit 37261928bec145f4cbd85f3e409063563c00ac9e Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 15:40:45 2011 +1100 s3-includes: fixed CONST_DISCARD() to actually discard const a cast is not enough Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> commit aaae4123b9bcdf0a3d5d006fcb7daf10a1d95fbc Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 15:39:27 2011 +1100 unistr: moved some UCS2 macros into util_unistr we need to move towards eliminating smb_ucs2_t. This moves a couple of the related macros into the only file they are used in Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> commit 5a20325c867b32333f489b7d04c6b8e6571ed06d Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 15:35:28 2011 +1100 libcli: created smb_constants.h this starts the (long!) process of moving some of the SMB constants into common files. This just moves the FLAGS2_ defines, which are needed for common string routines (for FLAGS2_UNICODE_STRINGS) commit bfce962c8f5219e72a07810a663a14542355927d Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 15:33:39 2011 +1100 tdb: rename convert_string() to tdb_convert_string() this prevents a conflict with the convert_string() in samba commit 2588e7180974d11a1e9cad19542bfcbfc30a1918 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 14:45:27 2011 +1100 s3-libsmb: work our correct length for EA strings commit 5ed2039e1ed44006750fe6e15948bdff241de6ff Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 13:00:05 2011 +1100 s3-string: sec_len==-1 support is no longer needed Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> commit 4d47493368c0bdfa715814bf5736866a369f00f5 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 13:00:37 2011 +1100 s3-dfs: removed the last user of sec_len==-1 in pull_*_base_talloc() hopefully there aren't any others lurking in the code commit 3ceb353939e4c67b41cde5af1e7f261cd697b2e6 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 12:09:03 2011 +1100 s3-lib: make pull_ucs2_base_talloc static it is local to charcnv.c commit 980064b76d774680febc5d201a1aacc4b9fa8b86 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 11:42:40 2011 +1100 lib: remove unused pieces of string_wrappers.h commit 8cd4a38d722af31bc94b9868d27bed2f9f7c5cff Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 11:40:43 2011 +1100 lib: move the string wrappers from source3/include to common lib/util this will allow the common charcnv library to use the string wrappers Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> commit f705fc9002ffc32a6155b5411f896212a9408f33 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Mar 24 15:56:26 2011 +1100 s3-string: moved fstring functions into their own file Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> ----------------------------------------------------------------------- Summary of changes: lib/tdb/tools/tdbtool.c | 10 +- lib/util/charset/charcnv.c | 95 ++++-- lib/util/charset/charset.h | 35 +-- lib/util/charset/codepoints.c | 48 ++-- lib/util/charset/tests/iconv.c | 4 +- lib/util/charset/util_str.c | 32 +- lib/util/charset/util_unistr.c | 40 ++-- .../safe_string.h => lib/util/string_wrappers.h | 71 +---- libcli/smb/smb_common.h | 1 + libcli/smb/smb_constants.h | 39 +++ libgpo/gpo_fetch.c | 2 +- source3/Makefile.in | 2 +- source3/include/includes.h | 2 +- source3/include/proto.h | 13 +- source3/include/safe_string.h | 106 +------ source3/include/smb.h | 17 +- source3/lib/charcnv.c | 354 +++++++------------- source3/lib/fstring.c | 111 ++++++ source3/lib/util_unistr.c | 9 + source3/libsmb/clidfs.c | 3 +- source3/libsmb/clifile.c | 2 +- source3/libsmb/clistr.c | 14 +- source3/wscript_build | 2 +- source4/kdc/kpasswdd.c | 4 +- source4/libcli/raw/smb.h | 13 +- source4/libnet/libnet_samdump.c | 2 +- source4/param/loadparm.c | 16 +- source4/param/param.h | 6 +- source4/param/util.c | 6 +- source4/rpc_server/samr/samr_password.c | 6 +- source4/torture/basic/charset.c | 2 +- 31 files changed, 480 insertions(+), 587 deletions(-) copy source3/include/safe_string.h => lib/util/string_wrappers.h (76%) create mode 100644 libcli/smb/smb_constants.h create mode 100644 source3/lib/fstring.c Changeset truncated at 500 lines: diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c index 3511dc1..cd17f79 100644 --- a/lib/tdb/tools/tdbtool.c +++ b/lib/tdb/tools/tdbtool.c @@ -693,7 +693,7 @@ static int do_command(void) return 0; } -static char *convert_string(char *instring, size_t *sizep) +static char *tdb_convert_string(char *instring, size_t *sizep) { size_t length = 0; char *outp, *inp; @@ -759,15 +759,15 @@ int main(int argc, char *argv[]) } } } - if (arg1) arg1 = convert_string(arg1,&arg1len); - if (arg2) arg2 = convert_string(arg2,&arg2len); + if (arg1) arg1 = tdb_convert_string(arg1,&arg1len); + if (arg2) arg2 = tdb_convert_string(arg2,&arg2len); if (do_command()) break; } break; case 5: - arg2 = convert_string(argv[4],&arg2len); + arg2 = tdb_convert_string(argv[4],&arg2len); case 4: - arg1 = convert_string(argv[3],&arg1len); + arg1 = tdb_convert_string(argv[3],&arg1len); case 3: cmdname = argv[2]; default: diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c index 1e1f2a3..3b7dbb3 100644 --- a/lib/util/charset/charcnv.c +++ b/lib/util/charset/charcnv.c @@ -22,6 +22,7 @@ */ #include "includes.h" #include "system/iconv.h" +#include "libcli/smb/smb_common.h" /** * @file @@ -121,14 +122,15 @@ convert: * @param dest pointer to destination string (multibyte or singlebyte) * @param destlen maximal length allowed for string * @returns the number of bytes occupied in the destination + * on error, returns -1, and sets errno **/ -_PUBLIC_ bool convert_string_convenience(struct smb_iconv_convenience *ic, - charset_t from, charset_t to, - void const *src, size_t srclen, - void *dest, size_t destlen, size_t *converted_size) +_PUBLIC_ ssize_t convert_string_error_handle(struct smb_iconv_handle *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen, size_t *converted_size) { size_t i_len, o_len; - size_t retval; + ssize_t retval; const char* inbuf = (const char*)src; char* outbuf = (char*)dest; smb_iconv_t descriptor; @@ -137,45 +139,68 @@ _PUBLIC_ bool convert_string_convenience(struct smb_iconv_convenience *ic, srclen = strlen(inbuf)+1; descriptor = get_conv_handle(ic, from, to); - if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) { - /* conversion not supported, use as is */ - size_t len = MIN(srclen,destlen); - memcpy(dest,src,len); - *converted_size = len; - return true; + if (converted_size) { + *converted_size = 0; + } + errno = EINVAL; + return -1; } i_len=srclen; o_len=destlen; + retval = smb_iconv(descriptor, &inbuf, &i_len, &outbuf, &o_len); + + if (converted_size != NULL) + *converted_size = destlen-o_len; + return retval; +} + + +/** + * Convert string from one encoding to another, making error checking etc + * + * @param src pointer to source string (multibyte or singlebyte) + * @param srclen length of the source string in bytes + * @param dest pointer to destination string (multibyte or singlebyte) + * @param destlen maximal length allowed for string + * @returns the number of bytes occupied in the destination + **/ +_PUBLIC_ bool convert_string_handle(struct smb_iconv_handle *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen, size_t *converted_size) +{ + ssize_t retval; + + retval = convert_string_error_handle(ic, from, to, src, srclen, dest, destlen, converted_size); if(retval==(size_t)-1) { const char *reason; switch(errno) { - case EINVAL: - reason="Incomplete multibyte sequence"; - return false; - case E2BIG: - reason="No more room"; - if (from == CH_UNIX) { - DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d - '%s'\n", - charset_name(ic, from), charset_name(ic, to), - (int)srclen, (int)destlen, - (const char *)src)); - } else { - DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d\n", - charset_name(ic, from), charset_name(ic, to), - (int)srclen, (int)destlen)); - } - return false; - case EILSEQ: - reason="Illegal multibyte sequence"; - return false; + case EINVAL: + reason="Incomplete multibyte sequence"; + return false; + case E2BIG: + reason="No more room"; + if (from == CH_UNIX) { + DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d - '%s'\n", + charset_name(ic, from), charset_name(ic, to), + (int)srclen, (int)destlen, + (const char *)src)); + } else { + DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d\n", + charset_name(ic, from), charset_name(ic, to), + (int)srclen, (int)destlen)); + } + return false; + case EILSEQ: + reason="Illegal multibyte sequence"; + return false; + default: + return false; } - /* smb_panic(reason); */ } - if (converted_size != NULL) - *converted_size = destlen-o_len; return true; } @@ -189,8 +214,8 @@ _PUBLIC_ bool convert_string_convenience(struct smb_iconv_convenience *ic, * @returns Size in bytes of the converted string; or -1 in case of error. **/ -_PUBLIC_ bool convert_string_talloc_convenience(TALLOC_CTX *ctx, - struct smb_iconv_convenience *ic, +_PUBLIC_ bool convert_string_talloc_handle(TALLOC_CTX *ctx, + struct smb_iconv_handle *ic, charset_t from, charset_t to, void const *src, size_t srclen, void *dst, size_t *converted_size) diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index 494a4eb..30ebcd5 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -48,15 +48,6 @@ typedef uint16_t smb_ucs2_t; /* turn a 7 bit character into a ucs2 character */ #define UCS2_CHAR(c) ((c) << UCS2_SHIFT) -/* return an ascii version of a ucs2 character */ -#define UCS2_TO_CHAR(c) (((c) >> UCS2_SHIFT) & 0xff) - -/* Copy into a smb_ucs2_t from a possibly unaligned buffer. Return the copied smb_ucs2_t */ -#define COPY_UCS2_CHAR(dest,src) (((unsigned char *)(dest))[0] = ((unsigned char *)(src))[0],\ - ((unsigned char *)(dest))[1] = ((unsigned char *)(src))[1], (dest)) - - - /* * for each charset we have a function that pulls from that charset to * a ucs2 buffer, and a function that pushes to a ucs2 buffer @@ -112,7 +103,7 @@ typedef struct smb_iconv_s { #define STR_LEN_NOTERM 256 /* the length field is the unterminated length */ struct loadparm_context; -struct smb_iconv_convenience; +struct smb_iconv_handle; /* replace some string functions with multi-byte versions */ @@ -168,11 +159,11 @@ ssize_t iconv_talloc(TALLOC_CTX *mem_ctx, void const *src, size_t srclen, void *dest); -extern struct smb_iconv_convenience *global_iconv_convenience; -struct smb_iconv_convenience *get_iconv_convenience(void); -smb_iconv_t get_conv_handle(struct smb_iconv_convenience *ic, +extern struct smb_iconv_handle *global_iconv_handle; +struct smb_iconv_handle *get_iconv_handle(void); +smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic, charset_t from, charset_t to); -const char *charset_name(struct smb_iconv_convenience *ic, charset_t ch); +const char *charset_name(struct smb_iconv_handle *ic, charset_t ch); codepoint_t next_codepoint_ext(const char *str, charset_t src_charset, size_t *size); @@ -180,12 +171,12 @@ codepoint_t next_codepoint(const char *str, size_t *size); ssize_t push_codepoint(char *str, codepoint_t c); /* codepoints */ -codepoint_t next_codepoint_convenience_ext(struct smb_iconv_convenience *ic, +codepoint_t next_codepoint_handle_ext(struct smb_iconv_handle *ic, const char *str, charset_t src_charset, size_t *size); -codepoint_t next_codepoint_convenience(struct smb_iconv_convenience *ic, +codepoint_t next_codepoint_handle(struct smb_iconv_handle *ic, const char *str, size_t *size); -ssize_t push_codepoint_convenience(struct smb_iconv_convenience *ic, +ssize_t push_codepoint_handle(struct smb_iconv_handle *ic, char *str, codepoint_t c); codepoint_t toupper_m(codepoint_t val); @@ -195,19 +186,19 @@ bool isupper_m(codepoint_t val); int codepoint_cmpi(codepoint_t c1, codepoint_t c2); /* Iconv convenience functions */ -struct smb_iconv_convenience *smb_iconv_convenience_reinit(TALLOC_CTX *mem_ctx, +struct smb_iconv_handle *smb_iconv_handle_reinit(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, const char *display_charset, bool native_iconv, - struct smb_iconv_convenience *old_ic); + struct smb_iconv_handle *old_ic); -bool convert_string_convenience(struct smb_iconv_convenience *ic, +bool convert_string_handle(struct smb_iconv_handle *ic, charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t destlen, size_t *converted_size); -bool convert_string_talloc_convenience(TALLOC_CTX *ctx, - struct smb_iconv_convenience *ic, +bool convert_string_talloc_handle(TALLOC_CTX *ctx, + struct smb_iconv_handle *ic, charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t *converted_size); diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c index 5ee95a8..62a80a3 100644 --- a/lib/util/charset/codepoints.c +++ b/lib/util/charset/codepoints.c @@ -153,7 +153,7 @@ _PUBLIC_ int codepoint_cmpi(codepoint_t c1, codepoint_t c2) } -struct smb_iconv_convenience { +struct smb_iconv_handle { TALLOC_CTX *child_ctx; const char *unix_charset; const char *dos_charset; @@ -162,20 +162,20 @@ struct smb_iconv_convenience { smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS]; }; -struct smb_iconv_convenience *global_iconv_convenience = NULL; +struct smb_iconv_handle *global_iconv_handle = NULL; -struct smb_iconv_convenience *get_iconv_convenience(void) +struct smb_iconv_handle *get_iconv_handle(void) { - if (global_iconv_convenience == NULL) - global_iconv_convenience = smb_iconv_convenience_reinit(talloc_autofree_context(), + if (global_iconv_handle == NULL) + global_iconv_handle = smb_iconv_handle_reinit(talloc_autofree_context(), "ASCII", "UTF-8", "ASCII", true, NULL); - return global_iconv_convenience; + return global_iconv_handle; } /** * Return the name of a charset to give to iconv(). **/ -const char *charset_name(struct smb_iconv_convenience *ic, charset_t ch) +const char *charset_name(struct smb_iconv_handle *ic, charset_t ch) { switch (ch) { case CH_UTF16: return "UTF-16LE"; @@ -193,7 +193,7 @@ const char *charset_name(struct smb_iconv_convenience *ic, charset_t ch) /** re-initialize iconv conversion descriptors **/ -static int close_iconv_convenience(struct smb_iconv_convenience *data) +static int close_iconv_handle(struct smb_iconv_handle *data) { unsigned c1, c2; for (c1=0;c1<NUM_CHARSETS;c1++) { @@ -242,31 +242,31 @@ static const char *map_locale(const char *charset) } /* - the old_ic is passed in here as the smb_iconv_convenience structure + the old_ic is passed in here as the smb_iconv_handle structure is used as a global pointer in some places (eg. python modules). We don't want to invalidate those global pointers, but we do want to update them with the right charset information when loadparm runs. To do that we need to re-use the structure pointer, but re-fill the elements in the structure with the updated values */ -_PUBLIC_ struct smb_iconv_convenience *smb_iconv_convenience_reinit(TALLOC_CTX *mem_ctx, +_PUBLIC_ struct smb_iconv_handle *smb_iconv_handle_reinit(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, const char *display_charset, bool native_iconv, - struct smb_iconv_convenience *old_ic) + struct smb_iconv_handle *old_ic) { - struct smb_iconv_convenience *ret; + struct smb_iconv_handle *ret; display_charset = map_locale(display_charset); if (old_ic != NULL) { ret = old_ic; - close_iconv_convenience(ret); + close_iconv_handle(ret); talloc_free(ret->child_ctx); ZERO_STRUCTP(ret); } else { - ret = talloc_zero(mem_ctx, struct smb_iconv_convenience); + ret = talloc_zero(mem_ctx, struct smb_iconv_handle); } if (ret == NULL) { return NULL; @@ -279,7 +279,7 @@ _PUBLIC_ struct smb_iconv_convenience *smb_iconv_convenience_reinit(TALLOC_CTX * return NULL; } - talloc_set_destructor(ret, close_iconv_convenience); + talloc_set_destructor(ret, close_iconv_handle); ret->dos_charset = talloc_strdup(ret->child_ctx, dos_charset); ret->unix_charset = talloc_strdup(ret->child_ctx, unix_charset); @@ -292,7 +292,7 @@ _PUBLIC_ struct smb_iconv_convenience *smb_iconv_convenience_reinit(TALLOC_CTX * /* on-demand initialisation of conversion handles */ -smb_iconv_t get_conv_handle(struct smb_iconv_convenience *ic, +smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic, charset_t from, charset_t to) { const char *n1, *n2; @@ -344,8 +344,8 @@ smb_iconv_t get_conv_handle(struct smb_iconv_convenience *ic, * * Return INVALID_CODEPOINT if the next character cannot be converted. */ -_PUBLIC_ codepoint_t next_codepoint_convenience_ext( - struct smb_iconv_convenience *ic, +_PUBLIC_ codepoint_t next_codepoint_handle_ext( + struct smb_iconv_handle *ic, const char *str, charset_t src_charset, size_t *bytes_consumed) { @@ -421,10 +421,10 @@ _PUBLIC_ codepoint_t next_codepoint_convenience_ext( return INVALID_CODEPOINT if the next character cannot be converted */ -_PUBLIC_ codepoint_t next_codepoint_convenience(struct smb_iconv_convenience *ic, +_PUBLIC_ codepoint_t next_codepoint_handle(struct smb_iconv_handle *ic, const char *str, size_t *size) { - return next_codepoint_convenience_ext(ic, str, CH_UNIX, size); + return next_codepoint_handle_ext(ic, str, CH_UNIX, size); } /* @@ -437,7 +437,7 @@ _PUBLIC_ codepoint_t next_codepoint_convenience(struct smb_iconv_convenience *ic return the number of bytes occupied by the CH_UNIX character, or -1 on failure */ -_PUBLIC_ ssize_t push_codepoint_convenience(struct smb_iconv_convenience *ic, +_PUBLIC_ ssize_t push_codepoint_handle(struct smb_iconv_handle *ic, char *str, codepoint_t c) { smb_iconv_t descriptor; @@ -489,16 +489,16 @@ _PUBLIC_ ssize_t push_codepoint_convenience(struct smb_iconv_convenience *ic, _PUBLIC_ codepoint_t next_codepoint_ext(const char *str, charset_t src_charset, size_t *size) { - return next_codepoint_convenience_ext(get_iconv_convenience(), str, + return next_codepoint_handle_ext(get_iconv_handle(), str, src_charset, size); } _PUBLIC_ codepoint_t next_codepoint(const char *str, size_t *size) { - return next_codepoint_convenience(get_iconv_convenience(), str, size); + return next_codepoint_handle(get_iconv_handle(), str, size); } _PUBLIC_ ssize_t push_codepoint(char *str, codepoint_t c) { - return push_codepoint_convenience(get_iconv_convenience(), str, c); + return push_codepoint_handle(get_iconv_handle(), str, c); } diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c index 9b48771..c27c263 100644 --- a/lib/util/charset/tests/iconv.c +++ b/lib/util/charset/tests/iconv.c @@ -289,7 +289,7 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint) size_t size, size2; codepoint_t c; - size = push_codepoint_convenience(lpcfg_iconv_convenience(tctx->lp_ctx), (char *)buf, codepoint); + size = push_codepoint_handle(lpcfg_iconv_handle(tctx->lp_ctx), (char *)buf, codepoint); torture_assert(tctx, size != -1 || (codepoint >= 0xd800 && codepoint <= 0x10000), "Invalid Codepoint range"); @@ -300,7 +300,7 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint) buf[size+2] = random(); buf[size+3] = random(); - c = next_codepoint_convenience(lpcfg_iconv_convenience(tctx->lp_ctx), (char *)buf, &size2); + c = next_codepoint_handle(lpcfg_iconv_handle(tctx->lp_ctx), (char *)buf, &size2); torture_assert(tctx, c == codepoint, talloc_asprintf(tctx, diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c index 597b031..30961d0 100644 --- a/lib/util/charset/util_str.c +++ b/lib/util/charset/util_str.c @@ -34,7 +34,7 @@ _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(); + struct smb_iconv_handle *iconv_handle = get_iconv_handle(); /* handle null ptr comparisons to simplify the use in qsort */ if (s1 == s2) return 0; @@ -42,8 +42,8 @@ _PUBLIC_ int strcasecmp_m(const char *s1, const char *s2) if (s2 == NULL) return 1; while (*s1 && *s2) { - c1 = next_codepoint_convenience(iconv_convenience, s1, &size1); - c2 = next_codepoint_convenience(iconv_convenience, s2, &size2); + c1 = next_codepoint_handle(iconv_handle, s1, &size1); + c2 = next_codepoint_handle(iconv_handle, s2, &size2); s1 += size1; s2 += size2; @@ -73,7 +73,7 @@ _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(); + struct smb_iconv_handle *iconv_handle = get_iconv_handle(); /* handle null ptr comparisons to simplify the use in qsort */ if (s1 == s2) return 0; @@ -83,8 +83,8 @@ _PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n) while (*s1 && *s2 && n) { n--; - c1 = next_codepoint_convenience(iconv_convenience, s1, &size1); - c2 = next_codepoint_convenience(iconv_convenience, s2, &size2); + c1 = next_codepoint_handle(iconv_handle, s1, &size1); + c2 = next_codepoint_handle(iconv_handle, s2, &size2); s1 += size1; s2 += size2; @@ -143,7 +143,7 @@ _PUBLIC_ bool strcsequal(const char *s1,const char *s2) _PUBLIC_ size_t strlen_m_ext(const char *s, charset_t src_charset, charset_t dst_charset) { size_t count = 0; - struct smb_iconv_convenience *ic = get_iconv_convenience(); + struct smb_iconv_handle *ic = get_iconv_handle(); if (!s) { return 0; @@ -160,7 +160,7 @@ _PUBLIC_ size_t strlen_m_ext(const char *s, charset_t src_charset, charset_t dst while (*s) { size_t c_size; - codepoint_t c = next_codepoint_convenience_ext(ic, s, src_charset, &c_size); + codepoint_t c = next_codepoint_handle_ext(ic, s, src_charset, &c_size); s += c_size; -- Samba Shared Repository