summaryrefslogtreecommitdiff
path: root/source3/libsmb/clistr.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-03-14 12:42:43 +0000
committerAndrew Tridgell <tridge@samba.org>2001-03-14 12:42:43 +0000
commit9ea70bd00349bc391809bec374700c6d9ce2952b (patch)
tree4a5aeb71abe62792cb9fa9c03feaa6f2401e6272 /source3/libsmb/clistr.c
parent376a44c81d360026eb0c2886e9a05dd2bfefd2cc (diff)
downloadsamba-9ea70bd00349bc391809bec374700c6d9ce2952b.tar.gz
samba-9ea70bd00349bc391809bec374700c6d9ce2952b.tar.bz2
samba-9ea70bd00349bc391809bec374700c6d9ce2952b.zip
simpler clistr interface which handles individual packets having
unicode bit set differently to capabilities (This used to be commit 34a0821e087810381996f5ff6cf3b4d7b9bb53a0)
Diffstat (limited to 'source3/libsmb/clistr.c')
-rw-r--r--source3/libsmb/clistr.c52
1 files changed, 7 insertions, 45 deletions
diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c
index c0e7231d7a..feed10fa4e 100644
--- a/source3/libsmb/clistr.c
+++ b/source3/libsmb/clistr.c
@@ -45,14 +45,14 @@ int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len
dest_len = sizeof(pstring);
}
- if (!(flags & STR_ASCII) && clistr_align(cli, PTR_DIFF(dest, cli->outbuf))) {
+ if (!(flags & STR_ASCII) && clistr_align(cli->outbuf, dest)) {
*(char *)dest = 0;
dest++;
dest_len--;
len++;
}
- if ((flags & STR_ASCII) || !(cli->capabilities & CAP_UNICODE)) {
+ if ((flags & STR_ASCII) || !(SVAL(cli->outbuf, smb_flg2) & FLAGS2_UNICODE_STRINGS)) {
/* the server doesn't want unicode */
safe_strcpy(dest, src, dest_len);
len = strlen(dest);
@@ -76,27 +76,6 @@ int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len
return len;
}
-
-/****************************************************************************
-return the length that a string would occupy when copied with clistr_push()
- STR_TERMINATE means include the null termination
- STR_CONVERT means convert from unix to dos codepage
- STR_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, const void *dest, const char *src, int dest_len, int flags)
-{
- int len = strlen(src);
- if (flags & STR_TERMINATE) len++;
- if (!(flags & STR_ASCII) && (cli->capabilities & CAP_UNICODE)) len *= 2;
-
- if (!(flags & STR_ASCII) && dest && clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) {
- len++;
- }
-
- return len;
-}
-
/****************************************************************************
copy a string from a unicode or ascii source (depending on
cli->capabilities) to a char* destination
@@ -116,12 +95,12 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len
dest_len = sizeof(pstring);
}
- if (clistr_align(cli, PTR_DIFF(src, cli->inbuf))) {
+ if (clistr_align(cli->inbuf, src)) {
src++;
if (src_len > 0) src_len--;
}
- if (!(flags & STR_UNICODE) && !(cli->capabilities & CAP_UNICODE)) {
+ if (!(flags & STR_UNICODE) && !(SVAL(cli->inbuf, smb_flg2) & FLAGS2_UNICODE_STRINGS)) {
/* the server doesn't want unicode */
if (flags & STR_TERMINATE) {
safe_strcpy(dest, src, dest_len);
@@ -153,31 +132,14 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len
return len;
}
-/****************************************************************************
-return the length that a string would occupy (not including the null)
-when copied with clistr_pull()
-if src_len is -1 then assume the source is null terminated
-****************************************************************************/
-int clistr_pull_size(struct cli_state *cli, const void *src, int src_len)
-{
- if (clistr_align(cli, PTR_DIFF(src, cli->inbuf))) {
- src++;
- if (src_len > 0) src_len--;
- }
-
- if (!(cli->capabilities & CAP_UNICODE)) {
- return strlen(src);
- }
- return strlen_w(src);
-}
/****************************************************************************
return an alignment of either 0 or 1
if unicode is not negotiated then return 0
otherwise return 1 if offset is off
****************************************************************************/
-int clistr_align(struct cli_state *cli, int offset)
+int clistr_align(const void *buf, const void *p)
{
- if (!(cli->capabilities & CAP_UNICODE)) return 0;
- return offset & 1;
+ if (!(SVAL(buf, smb_flg2) & FLAGS2_UNICODE_STRINGS)) return 0;
+ return PTR_DIFF(p, buf) & 1;
}