diff options
author | Volker Lendecke <vl@samba.org> | 2011-05-19 08:36:54 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2011-05-19 13:46:47 +0200 |
commit | efbed2ce90ff10cd82543f22cba1fe0a4cfbb7fd (patch) | |
tree | 33496fa90e6b57339582184baf1a918d35a285a8 | |
parent | e7e43ba6a135b23865a7c9363a0ee0f479696067 (diff) | |
download | samba-efbed2ce90ff10cd82543f22cba1fe0a4cfbb7fd.tar.gz samba-efbed2ce90ff10cd82543f22cba1fe0a4cfbb7fd.tar.bz2 samba-efbed2ce90ff10cd82543f22cba1fe0a4cfbb7fd.zip |
s3: Add sync read_smb
-rw-r--r-- | source3/libsmb/read_smb.c | 24 | ||||
-rw-r--r-- | source3/libsmb/read_smb.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/source3/libsmb/read_smb.c b/source3/libsmb/read_smb.c index 5397fdb5ea..f530633c9f 100644 --- a/source3/libsmb/read_smb.c +++ b/source3/libsmb/read_smb.c @@ -108,3 +108,27 @@ ssize_t read_smb_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, *pbuf = talloc_move(mem_ctx, &state->buf); return talloc_get_size(*pbuf); } + +ssize_t read_smb(int fd, TALLOC_CTX *mem_ctx, uint8_t **pbuf, int *perrno) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct tevent_req *req; + ssize_t ret = -1; + + ev = event_context_init(frame); + if (ev == NULL) { + goto fail; + } + req = read_smb_send(frame, ev, fd); + if (req == NULL) { + goto fail; + } + if (!tevent_req_poll(req, ev)) { + goto fail; + } + ret = read_smb_recv(req, mem_ctx, pbuf, perrno); + fail: + TALLOC_FREE(frame); + return ret; +} diff --git a/source3/libsmb/read_smb.h b/source3/libsmb/read_smb.h index ae4dfdd63a..b0846c1ec3 100644 --- a/source3/libsmb/read_smb.h +++ b/source3/libsmb/read_smb.h @@ -29,5 +29,6 @@ struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx, ssize_t read_smb_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, uint8_t **pbuf, int *perrno); +ssize_t read_smb(int fd, TALLOC_CTX *mem_ctx, uint8_t **pbuf, int *perrno); #endif |