/*The following definitions come from libsmb/clistr.c */
int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len, int flags);
-int clistr_push_size(struct cli_state *cli, const void *dest, const char *src, int dest_len, int flags);
int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len, int src_len, int flags);
-int clistr_pull_size(struct cli_state *cli, const void *src, int src_len);
-int clistr_align(struct cli_state *cli, int offset);
+int clistr_align(const void *buf, const void *p);
/*The following definitions come from libsmb/clitrans.c */
p = smb_buf(cli->outbuf);
/* this alignment and termination is critical for netapp filers. Don't change */
- p += clistr_align(cli, PTR_DIFF(p, cli->outbuf));
+ p += clistr_align(cli->outbuf, p);
len = clistr_push(cli, p, fname, -1, STR_CONVERT);
p += len;
SSVAL(cli->outbuf,smb_ntcreate_NameLength, len);
break;
}
- param_len = 12+clistr_push_size(cli, NULL, mask, -1,
- STR_TERMINATE |
- STR_CONVERT);
-
if (First) {
setup = TRANSACT2_FINDFIRST;
SSVAL(param,0,attribute); /* attribute */
SSVAL(param,4,4+2); /* resume required + close on end */
SSVAL(param,6,info_level);
SIVAL(param,8,0);
- clistr_push(cli, param+12, mask, -1,
- STR_TERMINATE | STR_CONVERT);
+ p = param+12;
+ p += clistr_push(cli, param+12, mask, -1,
+ STR_TERMINATE | STR_CONVERT);
} else {
setup = TRANSACT2_FINDNEXT;
SSVAL(param,0,ff_dir_handle);
SSVAL(param,4,info_level);
SIVAL(param,6,0); /* ff_resume_key */
SSVAL(param,10,8+4+2); /* continue + resume required + close on end */
- clistr_push(cli, param+12, mask, -1,
- STR_TERMINATE | STR_CONVERT);
+ p = param+12;
+ p += clistr_push(cli, param+12, mask, -1,
+ STR_TERMINATE | STR_CONVERT);
}
+ param_len = PTR_DIFF(p, param);
+
if (!cli_send_trans(cli, SMBtrans2,
NULL, /* Name */
-1, 0, /* fid, flags */
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);
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
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);
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;
}
cli_setup_packet(cli);
if (pipe_name) {
- pipe_name_len = clistr_push_size(cli, smb_buf(cli->outbuf),
- pipe_name, -1,
- STR_TERMINATE);
+ pipe_name_len = clistr_push(cli, smb_buf(cli->outbuf), pipe_name, -1, STR_TERMINATE);
}
outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? pipe_name_len : 3);
for (i=0;i<lsetup;i++) /* setup[] */
SSVAL(cli->outbuf,smb_setup+i*2,setup[i]);
p = smb_buf(cli->outbuf);
- if (trans==SMBtrans) {
- clistr_push(cli, p, pipe_name, -1, STR_TERMINATE);
- } else {
+ if (trans != SMBtrans) {
*p++ = 0; /* put in a null smb_name */
*p++ = 'D'; *p++ = ' '; /* observed in OS/2 */
}