diff options
author | Tim Potter <tpot@samba.org> | 2001-06-22 01:09:40 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2001-06-22 01:09:40 +0000 |
commit | ff5a18ad3e5a9a4dac6947e3551126c8ea9077dd (patch) | |
tree | e3587c96dd3810e789c1a4f900e43320cf54dda6 | |
parent | 100a54e221dd0712ab37daa5359b202d0a059090 (diff) | |
download | samba-ff5a18ad3e5a9a4dac6947e3551126c8ea9077dd.tar.gz samba-ff5a18ad3e5a9a4dac6947e3551126c8ea9077dd.tar.bz2 samba-ff5a18ad3e5a9a4dac6947e3551126c8ea9077dd.zip |
Merged cli_read_one() function for reading DCE/RPC reply fragments.
(This used to be commit 9e074bc2bf2df34048b67457623bb8219fb1e4d6)
-rw-r--r-- | source3/libsmb/clireadwrite.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index 70266a2d9a..f5ddc77c8f 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -49,6 +49,52 @@ static void cli_issue_read(struct cli_state *cli, int fnum, off_t offset, } /**************************************************************************** + issue a single SMBread and wait for a reply. This function only called + in the rpc pipe code to read dce/rpc reply fragments. +****************************************************************************/ +size_t cli_read_one(struct cli_state *cli, int fnum, char *buf, off_t offset, + size_t size) +{ + uint32 ecode; + uint8 eclass; + char *p; + int size2; + + if (size == 0) + return 0; + + /* Issue a read and receive a reply */ + + cli_issue_read(cli, fnum, offset, size, 0); + + if (!cli_receive_smb(cli)) + return -1; + + size2 = SVAL(cli->inbuf, smb_vwv5); + + /* Check for error. Because the client library doesn't support + STATUS32, we need to check for and ignore the more data error + for pipe support. */ + + if (cli_error(cli, &eclass, &ecode, NULL) && + (eclass != ERRDOS && ecode != ERRmoredata)) { + return -1; + } + + if (size2 > size) { + DEBUG(5,("server returned more than we wanted!\n")); + return -1; + } + + /* Copy data into buffer */ + + p = smb_base(cli->inbuf) + SVAL(cli->inbuf,smb_vwv6); + memcpy(buf, p, size2); + + return size2; +} + +/**************************************************************************** read from a file ****************************************************************************/ size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size) |