From 3910d7baca440b21e66c1dc15556748c6f028085 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 21 Feb 2001 02:51:22 +0000 Subject: added support for a CLISTR_ASCII flag so we can use a uniform interface for ascii-only fields (This used to be commit cdf0316610803e6743936b29f232b32f9ec81422) --- source3/libsmb/clistr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/libsmb') diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c index 4c7c8e3077..da40fba9e6 100644 --- a/source3/libsmb/clistr.c +++ b/source3/libsmb/clistr.c @@ -35,6 +35,7 @@ flags can have: CLISTR_TERMINATE means include the null termination CLISTR_CONVERT means convert from unix to dos codepage CLISTR_UPPER means uppercase in the destination + CLISTR_ASCII use ascii even with unicode servers dest_len is the maximum length allowed in the destination. If dest_len is -1 then no maxiumum is used ****************************************************************************/ @@ -47,14 +48,14 @@ int clistr_push(struct cli_state *cli, void *dest, char *src, int dest_len, int dest_len = sizeof(pstring); } - if (clistr_align(cli, PTR_DIFF(dest, cli->outbuf))) { + if (!(flags & CLISTR_ASCII) && clistr_align(cli, PTR_DIFF(dest, cli->outbuf))) { *(char *)dest = 0; dest++; dest_len--; len++; } - if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { + if ((flags & CLISTR_ASCII) || !cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ safe_strcpy(dest, src, dest_len); len = strlen(dest); @@ -90,9 +91,9 @@ int clistr_push_size(struct cli_state *cli, void *dest, char *src, int dest_len, { int len = strlen(src); if (flags & CLISTR_TERMINATE) len++; - if (cli_use_unicode && (cli->capabilities & CAP_UNICODE)) len *= 2; + if (!(flags & CLISTR_ASCII) && cli_use_unicode && (cli->capabilities & CAP_UNICODE)) len *= 2; - if (dest && clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { + if (!(flags & CLISTR_ASCII) && dest && clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { len++; } -- cgit