2 Unix SMB/CIFS implementation.
3 client message handling routines
4 Copyright (C) Andrew Tridgell 1994-1998
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /****************************************************************************
27 start a message sequence
28 ****************************************************************************/
29 BOOL cli_message_start(struct cli_state *cli, char *host, char *username,
34 /* send a SMBsendstrt command */
35 memset(cli->outbuf,'\0',smb_size);
36 set_message(cli->outbuf,0,0,True);
37 SCVAL(cli->outbuf,smb_com,SMBsendstrt);
38 SSVAL(cli->outbuf,smb_tid,cli->cnum);
39 cli_setup_packet(cli);
41 p = smb_buf(cli->outbuf);
43 p += clistr_push(cli, p, username, -1, STR_TERMINATE);
45 p += clistr_push(cli, p, host, -1, STR_TERMINATE);
47 cli_setup_bcc(cli, p);
51 if (!cli_receive_smb(cli)) {
55 if (cli_is_error(cli)) return False;
57 *grp = SVAL(cli->inbuf,smb_vwv0);
63 /****************************************************************************
65 ****************************************************************************/
66 BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp)
72 memset(cli->outbuf,'\0',smb_size);
73 set_message(cli->outbuf,1,0,True);
74 SCVAL(cli->outbuf,smb_com,SMBsendtxt);
75 SSVAL(cli->outbuf,smb_tid,cli->cnum);
76 cli_setup_packet(cli);
78 SSVAL(cli->outbuf,smb_vwv0,grp);
80 p = smb_buf(cli->outbuf);
83 if ((lendos = convert_string_allocate(CH_UNIX, CH_DOS, msg,len, (void **) &msgdos)) < 0 || !msgdos) {
84 DEBUG(3,("Conversion failed, sending message in UNIX charset\n"));
85 SSVAL(p, 0, len); p += 2;
89 SSVAL(p, 0, lendos); p += 2;
90 memcpy(p, msgdos, lendos);
95 cli_setup_bcc(cli, p);
98 if (!cli_receive_smb(cli)) {
102 if (cli_is_error(cli)) return False;
107 /****************************************************************************
109 ****************************************************************************/
110 BOOL cli_message_end(struct cli_state *cli, int grp)
112 memset(cli->outbuf,'\0',smb_size);
113 set_message(cli->outbuf,1,0,True);
114 SCVAL(cli->outbuf,smb_com,SMBsendend);
115 SSVAL(cli->outbuf,smb_tid,cli->cnum);
117 SSVAL(cli->outbuf,smb_vwv0,grp);
119 cli_setup_packet(cli);
123 if (!cli_receive_smb(cli)) {
127 if (cli_is_error(cli)) return False;