From f0f1a5f4bf1c0c732a6c5a80c275656ac7d5617f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 27 Jun 2006 17:58:57 +0000 Subject: r16571: - make push/pull_ascii()/_ucs() functions static, callers should use push/pull_string() functions with STR_ASCII or STR_UNICODE - make the push/pull_ascii/ucs2/utf8_talloc() functions complete (they should be reduced to pull/push_string_talloc() later...) metze (This used to be commit b0af976187d2d46b7dbe5a532a5491476b459119) --- source4/lib/charset/charcnv.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'source4/lib/charset/charcnv.c') diff --git a/source4/lib/charset/charcnv.c b/source4/lib/charset/charcnv.c index ca06b3b7d6..0df77f4eff 100644 --- a/source4/lib/charset/charcnv.c +++ b/source4/lib/charset/charcnv.c @@ -286,7 +286,7 @@ convert: * @param dest_len the maximum length in bytes allowed in the * destination. If @p dest_len is -1 then no maximum is used. **/ -_PUBLIC_ ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flags) +static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flags) { size_t src_len; ssize_t ret; @@ -321,7 +321,6 @@ _PUBLIC_ ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int fl _PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src) { size_t src_len = strlen(src)+1; - *dest = NULL; return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest); } @@ -342,7 +341,7 @@ _PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src * @param src_len is the length of the source area in bytes. * @returns the number of bytes occupied by the string in @p src. **/ -_PUBLIC_ ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) +static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) { size_t ret; @@ -381,7 +380,7 @@ _PUBLIC_ ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t * @param dest_len is the maximum length allowed in the * destination. If dest_len is -1 then no maxiumum is used. **/ -_PUBLIC_ ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags) +static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags) { size_t len=0; size_t src_len = strlen(src); @@ -449,7 +448,6 @@ _PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) _PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) { size_t src_len = strlen(src)+1; - *dest = NULL; return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest); } @@ -465,7 +463,7 @@ _PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) The resulting string in "dest" is always null terminated. **/ -_PUBLIC_ size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) +static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) { size_t ret; @@ -494,6 +492,21 @@ _PUBLIC_ size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t s 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) +{ + size_t src_len = strlen(src)+1; + *dest = NULL; + return convert_string_talloc(ctx, 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 * -- cgit