root/source4/libcli/climessage.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. smbcli_message_start
  2. smbcli_message_text
  3. smbcli_message_end

   1 /* 
   2    Unix SMB/CIFS implementation.
   3    client message handling routines
   4    Copyright (C) Andrew Tridgell 1994-1998
   5    Copyright (C) James J Myers 2003  <myersjj@samba.org>
   6    
   7    This program is free software; you can redistribute it and/or modify
   8    it under the terms of the GNU General Public License as published by
   9    the Free Software Foundation; either version 3 of the License, or
  10    (at your option) any later version.
  11    
  12    This program is distributed in the hope that it will be useful,
  13    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15    GNU General Public License for more details.
  16    
  17    You should have received a copy of the GNU General Public License
  18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19 */
  20 
  21 #include "includes.h"
  22 #include "libcli/raw/libcliraw.h"
  23 #include "libcli/raw/raw_proto.h"
  24 #include "libcli/libcli.h"
  25 
  26 
  27 /****************************************************************************
  28 start a message sequence
  29 ****************************************************************************/
  30 bool smbcli_message_start(struct smbcli_tree *tree, const char *host, const char *username, 
     /* [<][>][^][v][top][bottom][index][help] */
  31                        int *grp)
  32 {
  33         struct smbcli_request *req; 
  34         
  35         req = smbcli_request_setup(tree, SMBsendstrt, 0, 0);
  36         smbcli_req_append_string(req, username, STR_TERMINATE);
  37         smbcli_req_append_string(req, host, STR_TERMINATE);
  38         if (!smbcli_request_send(req) || 
  39             !smbcli_request_receive(req) ||
  40             smbcli_is_error(tree)) {
  41                 smbcli_request_destroy(req);
  42                 return false;
  43         }
  44 
  45         *grp = SVAL(req->in.vwv, VWV(0));
  46         smbcli_request_destroy(req);
  47 
  48         return true;
  49 }
  50 
  51 
  52 /****************************************************************************
  53 send a message 
  54 ****************************************************************************/
  55 bool smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
     /* [<][>][^][v][top][bottom][index][help] */
  56 {
  57         struct smbcli_request *req; 
  58         
  59         req = smbcli_request_setup(tree, SMBsendtxt, 1, 0);
  60         SSVAL(req->out.vwv, VWV(0), grp);
  61 
  62         smbcli_req_append_bytes(req, (const uint8_t *)msg, len);
  63 
  64         if (!smbcli_request_send(req) || 
  65             !smbcli_request_receive(req) ||
  66             smbcli_is_error(tree)) {
  67                 smbcli_request_destroy(req);
  68                 return false;
  69         }
  70 
  71         smbcli_request_destroy(req);
  72         return true;
  73 }      
  74 
  75 /****************************************************************************
  76 end a message 
  77 ****************************************************************************/
  78 bool smbcli_message_end(struct smbcli_tree *tree, int grp)
     /* [<][>][^][v][top][bottom][index][help] */
  79 {
  80         struct smbcli_request *req; 
  81         
  82         req = smbcli_request_setup(tree, SMBsendend, 1, 0);
  83         SSVAL(req->out.vwv, VWV(0), grp);
  84 
  85         if (!smbcli_request_send(req) || 
  86             !smbcli_request_receive(req) ||
  87             smbcli_is_error(tree)) {
  88                 smbcli_request_destroy(req);
  89                 return false;
  90         }
  91 
  92         smbcli_request_destroy(req);
  93         return true;
  94 }      
  95 

/* [<][>][^][v][top][bottom][index][help] */