diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-02-20 12:45:50 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-02-20 12:45:50 +0000 |
commit | 8acf5e04482cb43734fbb786f8d363ee3bfff652 (patch) | |
tree | 3777683d2de87352854953cb0d9fcec91e15e0b7 /source3/libsmb | |
parent | 20b037b84951368cdac7fb65cd77aee0aeae9b37 (diff) | |
download | samba-8acf5e04482cb43734fbb786f8d363ee3bfff652.tar.gz samba-8acf5e04482cb43734fbb786f8d363ee3bfff652.tar.bz2 samba-8acf5e04482cb43734fbb786f8d363ee3bfff652.zip |
- neater setting of bcc
- converted cli_rename and cli_unlink
(This used to be commit 0a8992e224b7a3d90d45b13d73fa8a6f155efa79)
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/cliconnect.c | 6 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 7 | ||||
-rw-r--r-- | source3/libsmb/clifile.c | 27 | ||||
-rw-r--r-- | source3/libsmb/climessage.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clitrans.c | 12 |
5 files changed, 29 insertions, 25 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 31bdfdca46..4a957a9ccd 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -137,7 +137,7 @@ BOOL cli_session_setup(struct cli_state *cli, memcpy(p,pword,passlen); p += passlen; p += clistr_push(cli, p, user, -1, CLISTR_CONVERT|CLISTR_UPPER|CLISTR_TERMINATE); - set_message(cli->outbuf,10,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); } else { @@ -171,7 +171,7 @@ BOOL cli_session_setup(struct cli_state *cli, p += clistr_push(cli, p, workgroup, -1, CLISTR_CONVERT|CLISTR_TERMINATE|CLISTR_UPPER); p += clistr_push(cli, p, "Unix", -1, CLISTR_CONVERT|CLISTR_TERMINATE); p += clistr_push(cli, p, "Samba", -1, CLISTR_CONVERT|CLISTR_TERMINATE); - set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); } cli_send_smb(cli); @@ -279,7 +279,7 @@ BOOL cli_send_tconX(struct cli_state *cli, p += clistr_push(cli, p, fullshare, -1, CLISTR_CONVERT | CLISTR_TERMINATE); fstrcpy(p, dev); p += strlen(dev)+1; - set_message(cli->outbuf,4,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); SCVAL(cli->inbuf,smb_rcls, 1); diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index d7649074db..c25e71ff3d 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -127,6 +127,13 @@ void cli_setup_packet(struct cli_state *cli) } } +/**************************************************************************** +setup the bcc length of the packet from a pointer to the end of the data +****************************************************************************/ +void cli_setup_bcc(struct cli_state *cli, void *p) +{ + set_message_bcc(cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf))); +} /**************************************************************************** diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 8dc16c3f66..10b6a9e543 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -33,7 +33,7 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,1, 4 + strlen(fname_src) + strlen(fname_dst), True); + set_message(cli->outbuf,1, 0, True); CVAL(cli->outbuf,smb_com) = SMBmv; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -43,12 +43,13 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,fname_src); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, fname_src, -1, + CLISTR_TERMINATE | CLISTR_CONVERT); *p++ = 4; - pstrcpy(p,fname_dst); - unix_to_dos(p,True); + p += clistr_push(cli, p, fname_dst, -1, + CLISTR_TERMINATE | CLISTR_CONVERT); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -72,7 +73,7 @@ BOOL cli_unlink(struct cli_state *cli, char *fname) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,1, 2 + strlen(fname),True); + set_message(cli->outbuf,1, 0,True); CVAL(cli->outbuf,smb_com) = SMBunlink; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -82,9 +83,9 @@ BOOL cli_unlink(struct cli_state *cli, char *fname) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,fname); - unix_to_dos(p,True); + p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { return False; @@ -117,7 +118,7 @@ BOOL cli_mkdir(struct cli_state *cli, char *dname) *p++ = 4; p += clistr_push(cli, p, dname, -1, CLISTR_CONVERT|CLISTR_TERMINATE); - set_message(cli->outbuf,0, PTR_DIFF(p, smb_buf(cli->outbuf)), False); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -151,7 +152,7 @@ BOOL cli_rmdir(struct cli_state *cli, char *dname) *p++ = 4; p += clistr_push(cli, p, dname, -1, CLISTR_TERMINATE|CLISTR_CONVERT); - set_message(cli->outbuf,0, PTR_DIFF(p, smb_buf(cli->outbuf)), False); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -326,7 +327,7 @@ int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode) p = smb_buf(cli->outbuf); p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); - set_message(cli->outbuf,15, PTR_DIFF(p, smb_buf(cli->outbuf)), False); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -719,7 +720,7 @@ BOOL cli_chkpath(struct cli_state *cli, char *path) *p++ = 4; p += clistr_push(cli, p, path2, -1, CLISTR_TERMINATE | CLISTR_CONVERT); - set_message(cli->outbuf,0,PTR_DIFF(p, smb_buf(cli->outbuf)), False); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index c15fdbce8c..058358e2f1 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -49,7 +49,7 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, unix_to_dos(p,True); p = skip_string(p,1); - set_message(cli->outbuf,0,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); cli_send_smb(cli); diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c index 3afca997cc..630e9f93c0 100644 --- a/source3/libsmb/clitrans.c +++ b/source3/libsmb/clitrans.c @@ -85,8 +85,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, memcpy(outparam,param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data,this_ldata); - set_message(cli->outbuf,14+lsetup, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -126,8 +125,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, memcpy(outparam,param+tot_param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data+tot_data,this_ldata); - set_message(cli->outbuf,trans==SMBtrans?8:9, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -295,8 +293,7 @@ BOOL cli_send_nt_trans(struct cli_state *cli, if (this_ldata) /* data[] */ memcpy(outdata,data,this_ldata); - set_message(cli->outbuf,19+lsetup, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -335,8 +332,7 @@ BOOL cli_send_nt_trans(struct cli_state *cli, memcpy(outparam,param+tot_param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data+tot_data,this_ldata); - set_message(cli->outbuf,18, - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); |