From 4786a493f70070dce6de4cbe488c9de1bdbb75ad Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 17 Mar 2009 14:04:43 +1100 Subject: Solve some of the conflict between Samba3 and Samba4 push_string This renames push_string in Samba3 into push_string_base and push_string_check for the two different use cases. This should allow push_string to be imported from Samba4, using it's calling conventions. --- source3/lib/charcnv.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 03b32c13d4..0c0d654e99 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -1763,6 +1763,44 @@ bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, (void **)dest, converted_size, True); } +/** + Copy a string from a char* src to a unicode or ascii + dos codepage destination choosing unicode or ascii based on the + flags supplied + Return the number of bytes occupied by the string in the destination. + flags can have: + STR_TERMINATE means include the null termination. + STR_UPPER means uppercase in the destination. + STR_ASCII use ascii even with unicode packet. + STR_NOALIGN means don't do alignment. + dest_len is the maximum length allowed in the destination. If dest_len + is -1 then no maxiumum is used. +**/ + +size_t push_string_check_fn(const char *function, unsigned int line, + void *dest, const char *src, + size_t dest_len, int flags) +{ +#ifdef DEVELOPER + /* We really need to zero fill here, not clobber + * region, as we want to ensure that valgrind thinks + * all of the outgoing buffer has been written to + * so a send() or write() won't trap an error. + * JRA. + */ +#if 0 + clobber_region(function, line, dest, dest_len); +#else + memset(dest, '\0', dest_len); +#endif +#endif + + if (!(flags & STR_ASCII) && (flags & STR_UNICODE)) { + return push_ucs2(NULL, dest, src, dest_len, flags); + } + return push_ascii(dest, src, dest_len, flags); +} + /** Copy a string from a char* src to a unicode or ascii dos codepage destination choosing unicode or ascii based on the @@ -1777,10 +1815,10 @@ bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, is -1 then no maxiumum is used. **/ -size_t push_string_fn(const char *function, unsigned int line, - const void *base_ptr, uint16 flags2, - void *dest, const char *src, - size_t dest_len, int flags) +size_t push_string_base(const char *function, unsigned int line, + const char *base, uint16 flags2, + void *dest, const char *src, + size_t dest_len, int flags) { #ifdef DEVELOPER /* We really need to zero fill here, not clobber @@ -1799,7 +1837,7 @@ size_t push_string_fn(const char *function, unsigned int line, if (!(flags & STR_ASCII) && \ ((flags & STR_UNICODE || \ (flags2 & FLAGS2_UNICODE_STRINGS)))) { - return push_ucs2(base_ptr, dest, src, dest_len, flags); + return push_ucs2(base, dest, src, dest_len, flags); } return push_ascii(dest, src, dest_len, flags); } -- cgit