r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots of associ...
authorAndrew Tridgell <tridge@samba.org>
Fri, 8 Oct 2004 08:13:00 +0000 (08:13 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:39 +0000 (12:59 -0500)
commit814881f0e50019196b3aa9fbe4aeadbb98172040
tree628f9d0e4704e25e109497de93ba791450c29854
parent1b3c7d9cfa250d917a7fb96b315da9ed7d7a91d6
r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots of associated functions.

The motivation for this change was to avoid having to convert to/from
ucs2 strings for so many operations. Doing that was slow, used many
static buffers, and was also incorrect as it didn't cope properly with
unicode codepoints above 65536 (which could not be represented
correctly as smb_ucs2_t chars)

The two core functions that allowed this change are next_codepoint()
and push_codepoint(). These functions allow you to correctly walk a
arbitrary multi-byte string a character at a time without converting
the whole string to ucs2.

While doing this cleanup I also fixed several ucs2 string handling
bugs. See the commit for details.

The following code (which counts the number of occuraces of 'c' in a
string) shows how to use the new interface:

size_t count_chars(const char *s, char c)
{
size_t count = 0;

while (*s) {
size_t size;
codepoint_t c2 = next_codepoint(s, &size);
if (c2 == c) count++;
s += size;
}

return count;
}
24 files changed:
source/auth/pass_check.c
source/include/charset.h
source/include/rewrite.h
source/include/safe_string.h
source/lib/basic.mk
source/lib/charcnv.c
source/lib/cmdline/popt_common.c
source/lib/iconv.c
source/lib/ms_fnmatch.c
source/lib/registry/reg_backend_nt4/reg_backend_nt4.c
source/lib/util_str.c
source/lib/util_strlist.c [new file with mode: 0644]
source/lib/util_unistr.c
source/libads/ldap_printer.c
source/libcli/auth/ntlmssp_parse.c
source/libcli/raw/rawrequest.c
source/libcli/util/smbencrypt.c
source/librpc/ndr/ndr_basic.c
source/smb_server/request.c
source/smbd/server.c
source/torture/basic/utable.c
source/torture/local/iconv.c
source/torture/masktest.c
source/torture/rpc/netlogon.c