diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-04-12 16:31:08 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-04-13 14:47:07 +1000 |
commit | 9941dfe9f6532ecbc317685046d74e6f90c41695 (patch) | |
tree | ab591eead8e1d38e0167f005730a4ac76dd4fa74 /source3/lib/charcnv.c | |
parent | ce2f217bd2402ada76c13bf3c170c8f55752fb11 (diff) | |
download | samba-9941dfe9f6532ecbc317685046d74e6f90c41695.tar.gz samba-9941dfe9f6532ecbc317685046d74e6f90c41695.tar.bz2 samba-9941dfe9f6532ecbc317685046d74e6f90c41695.zip |
lib/util/charset Move source3/lib/util_unistr.c to the common code.
This file (largely) contains functions to deal with UTF16 strings.
Andrew Bartlett
Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'source3/lib/charcnv.c')
-rw-r--r-- | source3/lib/charcnv.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 6e5b606e64..edcccc25e7 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -1366,3 +1366,42 @@ size_t align_string(const void *base_ptr, const char *p, int flags) return 0; } +/******************************************************************* + Write a string in (little-endian) unicode format. src is in + the current DOS codepage. len is the length in bytes of the + string pointed to by dst. + + if null_terminate is True then null terminate the packet (adds 2 bytes) + + the return value is the length in bytes consumed by the string, including the + null termination if applied +********************************************************************/ + +size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate) +{ + int flags = null_terminate ? STR_UNICODE|STR_NOALIGN|STR_TERMINATE + : STR_UNICODE|STR_NOALIGN; + return push_ucs2(NULL, dst, src, len, flags); +} + + +/* Converts a string from internal samba format to unicode + */ + +int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags) +{ + return push_ucs2(NULL, dest, src, dest_len, flags|STR_UNICODE|STR_NOALIGN); +} + +/* Converts a string from internal samba format to unicode. Always terminates. + * Actually just a wrapper round push_ucs2_talloc(). + */ + +int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src) +{ + size_t size; + if (push_ucs2_talloc(ctx, dest, src, &size)) + return size; + else + return -1; +} |