From 78c50015bb8bd5a1d831a6e7ec796b3367c73145 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Jan 2006 15:40:05 +0000 Subject: r12694: Move some headers to the directory of the subsystem they belong to. (This used to be commit c722f665c90103f3ed57621c460e32ad33e7a8a3) --- source4/lib/charset/charset.h | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 source4/lib/charset/charset.h (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h new file mode 100644 index 0000000000..5ad2f431bf --- /dev/null +++ b/source4/lib/charset/charset.h @@ -0,0 +1,69 @@ +/* + Unix SMB/CIFS implementation. + charset defines + Copyright (C) Andrew Tridgell 2001 + Copyright (C) Jelmer Vernooij 2002 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* this defines the charset types used in samba */ +typedef enum {CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t; + +#define NUM_CHARSETS 6 + +/* + * 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 + * */ + +struct charset_functions { + const char *name; + size_t (*pull)(void *, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); + size_t (*push)(void *, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); + struct charset_functions *prev, *next; +}; + +/* this type is used for manipulating unicode codepoints */ +typedef uint32_t codepoint_t; + +#define INVALID_CODEPOINT ((codepoint_t)-1) + + +/* generic iconv conversion structure */ +typedef struct { + size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); + size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); + size_t (*push)(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); + void *cd_direct, *cd_pull, *cd_push; +} *smb_iconv_t; + +/* string manipulation flags */ +#define STR_TERMINATE 1 +#define STR_UPPER 2 +#define STR_ASCII 4 +#define STR_UNICODE 8 +#define STR_NOALIGN 16 +#define STR_NO_RANGE_CHECK 32 +#define STR_LEN8BIT 64 +#define STR_TERMINATE_ASCII 128 /* only terminate if ascii */ +#define STR_LEN_NOTERM 256 /* the length field is the unterminated length */ + +#include "lib/charset/charset_proto.h" -- cgit From ecf0dd6bafaa95692c3ece94b6f71446cd54ebdc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 20:02:31 +0000 Subject: r14488: Install more headers. Generate different #include lines in pidl depending on whether we're building inside or outside of the Samba tree (useful for 3rd-party projects). (This used to be commit 0c188833154c1fe565cb1735909e408a4a1a6049) --- source4/lib/charset/charset.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 5ad2f431bf..df67aebb55 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -19,6 +19,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef __CHARSET_H__ +#define __CHARSET_H__ + /* this defines the charset types used in samba */ typedef enum {CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t; @@ -67,3 +70,5 @@ typedef struct { #define STR_LEN_NOTERM 256 /* the length field is the unterminated length */ #include "lib/charset/charset_proto.h" + +#endif /* __CHARSET_H__ */ -- cgit From 5b0051e0325aea7e46715aa61bba0a1dc025132c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 17 Mar 2006 13:55:10 +0000 Subject: r14511: Install more headers (This used to be commit e1f896948fad8cf5a1aec300865c250c5721ee7d) --- source4/lib/charset/charset.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index df67aebb55..629786ee95 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -22,6 +22,8 @@ #ifndef __CHARSET_H__ #define __CHARSET_H__ +#include "lib/talloc/talloc.h" + /* this defines the charset types used in samba */ typedef enum {CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t; -- cgit From 8d137d97858a618c8c5451bb7b11fb95990540c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 27 Apr 2006 16:05:05 +0000 Subject: r15295: Fix some dependencies Move unistr-specific code to lib/charset/. Remove _m from some places where it's not needed. (This used to be commit 03224e112424968fc3f547c6159c7ccae2d1aa5b) --- source4/lib/charset/charset.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 629786ee95..e91f81f30d 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -73,4 +73,9 @@ typedef struct { #include "lib/charset/charset_proto.h" +/* replace some string functions with multi-byte + versions */ +#define strlower(s) strlower_m(s) +#define strupper(s) strupper_m(s) + #endif /* __CHARSET_H__ */ -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/charset/charset.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index e91f81f30d..e62f99a8fe 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, @@ -15,8 +15,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #ifndef __CHARSET_H__ -- cgit From 0b91f3916430d0271eab867675d44c5439de40c2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 29 Aug 2007 13:07:03 +0000 Subject: r24780: More work allowing libutil to be used by external users. (This used to be commit 31993cf67b816a184a4a4e92ef8ca2532c797190) --- source4/lib/charset/charset.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index e62f99a8fe..3c548192b6 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -77,4 +77,9 @@ typedef struct { #define strlower(s) strlower_m(s) #define strupper(s) strupper_m(s) +/* from lib/charset */ +extern char *dos_charset; +extern char *unix_charset; +extern char *display_charset; + #endif /* __CHARSET_H__ */ -- cgit From 82037a75eae9deaf6ec80b5ecc3bb89aab6e6dd8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 30 Aug 2007 23:15:12 +0000 Subject: r24814: Fix headers, trim core.h even more. (This used to be commit 9647f860bdd5c0a74583e886182bd041a45e7655) --- source4/lib/charset/charset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 3c548192b6..6943a60182 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -21,7 +21,7 @@ #ifndef __CHARSET_H__ #define __CHARSET_H__ -#include "lib/talloc/talloc.h" +#include /* this defines the charset types used in samba */ typedef enum {CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t; -- cgit From c37fa61abcfceb36c6f5e25ed20f43019ea8bd3f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 1 Sep 2007 20:19:29 +0000 Subject: r24867: Avoid anonymous struct. Patch from Brad Hards. (This used to be commit e7866857fbdc9b7b7bebcecd41f34f54b37f3b04) --- source4/lib/charset/charset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 6943a60182..91408365ac 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -49,7 +49,7 @@ typedef uint32_t codepoint_t; /* generic iconv conversion structure */ -typedef struct { +typedef struct smb_iconv_s { size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft, -- cgit From 5ecd526d1ca41821118165af039d16d0e729b59d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Oct 2007 23:26:37 +0000 Subject: r25456: Avoid externs for charsets for now - it breaks openchange. (This used to be commit 836431af83674018e9700f9da92ce251d108687a) --- source4/lib/charset/charset.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 91408365ac..be2705100a 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -77,9 +77,4 @@ typedef struct smb_iconv_s { #define strlower(s) strlower_m(s) #define strupper(s) strupper_m(s) -/* from lib/charset */ -extern char *dos_charset; -extern char *unix_charset; -extern char *display_charset; - #endif /* __CHARSET_H__ */ -- cgit From 6901b3c64a65d9745efac13f071225d5d2949f4d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Dec 2007 01:51:44 +0100 Subject: r26278: Tallocify convenience table for iconv handles. (This used to be commit ad64b3baa4a5383c603d17ae75c33083af4690bb) --- source4/lib/charset/charset.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index be2705100a..96762af85a 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -70,6 +70,8 @@ typedef struct smb_iconv_s { #define STR_TERMINATE_ASCII 128 /* only terminate if ascii */ #define STR_LEN_NOTERM 256 /* the length field is the unterminated length */ +struct loadparm_context; + #include "lib/charset/charset_proto.h" /* replace some string functions with multi-byte -- cgit From 39ee38d9c1aabf4db065b433d067d0da053d7d61 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 6 Dec 2007 17:52:23 +0100 Subject: r26316: Use contexts for conversion functions. (This used to be commit f6420d933b5b011d428974f3a2a57edf19e6f482) --- source4/lib/charset/charset.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 96762af85a..b1bb18a7c8 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -71,6 +71,8 @@ typedef struct smb_iconv_s { #define STR_LEN_NOTERM 256 /* the length field is the unterminated length */ struct loadparm_context; +struct smb_iconv_convenience; +extern struct smb_iconv_convenience *global_smb_iconv_convenience; #include "lib/charset/charset_proto.h" -- cgit From 2bf0cdd01cf399bf28125f9e2a0d419f4e94996c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:33 +0100 Subject: r26434: Remove display charset from iconv convenience context. (This used to be commit a76625994abf9906d54ae11f9c171f89063cf508) --- source4/lib/charset/charset.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index b1bb18a7c8..1d42a0ad91 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -24,9 +24,9 @@ #include /* this defines the charset types used in samba */ -typedef enum {CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t; +typedef enum {CH_UTF16=0, CH_UNIX, CH_DOS, CH_UTF8, CH_UTF16BE} charset_t; -#define NUM_CHARSETS 6 +#define NUM_CHARSETS 5 /* * for each charset we have a function that pulls from that charset to -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/lib/charset/charset.h | 68 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 1d42a0ad91..baa7df532b 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -18,6 +18,10 @@ along with this program. If not, see . */ +/* This is a public header file that is installed as part of Samba. + * If you remove any functions or change their signature, update + * the so version number. */ + #ifndef __CHARSET_H__ #define __CHARSET_H__ @@ -74,11 +78,71 @@ struct loadparm_context; struct smb_iconv_convenience; extern struct smb_iconv_convenience *global_smb_iconv_convenience; -#include "lib/charset/charset_proto.h" - /* replace some string functions with multi-byte versions */ #define strlower(s) strlower_m(s) #define strupper(s) strupper_m(s) +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); +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); +void strupper_m(char *s); +void strlower_m(char *s); +char *strupper_talloc(TALLOC_CTX *ctx, const char *src); +char *strlower_talloc(TALLOC_CTX *ctx, const char *src); +bool strhasupper(const char *string); +bool strhaslower(const char *string); +char *strrchr_m(const char *s, char c); +char *strchr_m(const char *s, char c); + +/* 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); +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); +ssize_t convert_string(struct smb_iconv_convenience *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen); +ssize_t convert_string_talloc_descriptor(TALLOC_CTX *ctx, smb_iconv_t descriptor, void const *src, size_t srclen, void **dest); +ssize_t convert_string_talloc(TALLOC_CTX *ctx, + struct smb_iconv_convenience *ic, + 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); +size_t smb_iconv(smb_iconv_t cd, + const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); +smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, + const char *fromcode, bool native_iconv); + +/* 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); #endif /* __CHARSET_H__ */ -- cgit From cc43037f19056ed24d7fffa54456d597c63ad105 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Aug 2008 17:36:56 +1000 Subject: fixed a problem with length limited ldap values The core ldb code for string matching assumed NULL terminated strings, whereas the anr module used data_blob_const() to effectively truncate a ldb_val by changing its length. The ldb code is supposed to be based around length limited blobs, not NULL terminated strings, so the correct fix was to change the string comparison functions to be length limited (This used to be commit 26c6aa5a80ffaf06fc33f30a6533f8f16ef538bc) --- source4/lib/charset/charset.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/charset/charset.h') diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index baa7df532b..c49745cd7f 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -97,6 +97,7 @@ size_t count_chars_w(const char *s, char c); void strupper_m(char *s); void strlower_m(char *s); char *strupper_talloc(TALLOC_CTX *ctx, const char *src); +char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n); char *strlower_talloc(TALLOC_CTX *ctx, const char *src); bool strhasupper(const char *string); bool strhaslower(const char *string); -- cgit