From c565c98723f1fab04d47ae6076d742c8ee2dcb49 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Feb 2001 10:11:40 +0000 Subject: pipe opening now works with unicode (This used to be commit ba3ce3404e1cd2e9da3ba1708f6fc8a12c085ef2) --- source3/libsmb/clistr.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clistr.c') diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c index 839dec7592..eb66d08c30 100644 --- a/source3/libsmb/clistr.c +++ b/source3/libsmb/clistr.c @@ -47,6 +47,11 @@ 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(cli->outbuf, dest))) { + dest++; + dest_len--; + } + if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ safe_strcpy(dest, src, dest_len); @@ -77,12 +82,18 @@ return the length that a string would occupy when copied with clistr_push() CLISTR_TERMINATE means include the null termination CLISTR_CONVERT means convert from unix to dos codepage CLISTR_UPPER means uppercase in the destination +note that dest is only used for alignment purposes. No data is written. ****************************************************************************/ -int clistr_push_size(struct cli_state *cli, char *src, int dest_len, int flags) +int clistr_push_size(struct cli_state *cli, void *dest, char *src, int dest_len, int flags) { int len = strlen(src); if (flags & CLISTR_TERMINATE) len++; if (cli_use_unicode && (cli->capabilities & CAP_UNICODE)) len *= 2; + + if (clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { + len++; + } + return len; } @@ -104,6 +115,11 @@ int clistr_pull(struct cli_state *cli, char *dest, void *src, int dest_len, int dest_len = sizeof(pstring); } + if (clistr_align(cli, PTR_DIFF(cli->inbuf, src))) { + src++; + if (src_len > 0) src_len--; + } + if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ if (flags & CLISTR_TERMINATE) { @@ -143,6 +159,11 @@ if src_len is -1 then assume the source is null terminated ****************************************************************************/ int clistr_pull_size(struct cli_state *cli, void *src, int src_len) { + if (clistr_align(cli, PTR_DIFF(cli->inbuf, src))) { + src++; + if (src_len > 0) src_len--; + } + if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { return strlen(src); } -- cgit