* fix to display correct form information in REG_BINARY information
[Samba.git] / source / libsmb / climessage.c
blob1587e6f4cd77cad21ba6ce8f46f56648ddb6be3f
1 /*
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.
21 #define NO_SYSLOG
23 #include "includes.h"
26 /****************************************************************************
27 start a message sequence
28 ****************************************************************************/
29 BOOL cli_message_start(struct cli_state *cli, char *host, char *username,
30 int *grp)
32 char *p;
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);
42 *p++ = 4;
43 p += clistr_push(cli, p, username, -1, STR_TERMINATE);
44 *p++ = 4;
45 p += clistr_push(cli, p, host, -1, STR_TERMINATE);
47 cli_setup_bcc(cli, p);
49 cli_send_smb(cli);
51 if (!cli_receive_smb(cli)) {
52 return False;
55 if (cli_is_error(cli)) return False;
57 *grp = SVAL(cli->inbuf,smb_vwv0);
59 return True;
63 /****************************************************************************
64 send a message
65 ****************************************************************************/
66 BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp)
68 char *p;
70 memset(cli->outbuf,'\0',smb_size);
71 set_message(cli->outbuf,1,0,True);
72 SCVAL(cli->outbuf,smb_com,SMBsendtxt);
73 SSVAL(cli->outbuf,smb_tid,cli->cnum);
74 cli_setup_packet(cli);
76 SSVAL(cli->outbuf,smb_vwv0,grp);
78 p = smb_buf(cli->outbuf);
79 *p++ = 1;
80 SSVAL(p,0,len); p += 2;
81 memcpy(p,msg,len);
82 p += len;
84 cli_setup_bcc(cli, p);
85 cli_send_smb(cli);
87 if (!cli_receive_smb(cli)) {
88 return False;
91 if (cli_is_error(cli)) return False;
93 return True;
96 /****************************************************************************
97 end a message
98 ****************************************************************************/
99 BOOL cli_message_end(struct cli_state *cli, int grp)
101 memset(cli->outbuf,'\0',smb_size);
102 set_message(cli->outbuf,1,0,True);
103 SCVAL(cli->outbuf,smb_com,SMBsendend);
104 SSVAL(cli->outbuf,smb_tid,cli->cnum);
106 SSVAL(cli->outbuf,smb_vwv0,grp);
108 cli_setup_packet(cli);
110 cli_send_smb(cli);
112 if (!cli_receive_smb(cli)) {
113 return False;
116 if (cli_is_error(cli)) return False;
118 return True;