| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | Utilities around tsocket
|
|---|
| 4 | Copyright (C) Volker Lendecke 2009
|
|---|
| 5 |
|
|---|
| 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 3 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 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.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | #include "includes.h"
|
|---|
| 21 |
|
|---|
| 22 | struct tstream_read_packet_state {
|
|---|
| 23 | struct tevent_context *ev;
|
|---|
| 24 | struct tstream_context *stream;
|
|---|
| 25 | ssize_t (*more)(uint8_t *buf, size_t buflen, void *private_data);
|
|---|
| 26 | void *private_data;
|
|---|
| 27 | uint8_t *buf;
|
|---|
| 28 | struct iovec iov;
|
|---|
| 29 | };
|
|---|
| 30 |
|
|---|
| 31 | static void tstream_read_packet_done(struct tevent_req *subreq);
|
|---|
| 32 |
|
|---|
| 33 | struct tevent_req *tstream_read_packet_send(TALLOC_CTX *mem_ctx,
|
|---|
| 34 | struct tevent_context *ev,
|
|---|
| 35 | struct tstream_context *stream,
|
|---|
| 36 | size_t initial,
|
|---|
| 37 | ssize_t (*more)(uint8_t *buf,
|
|---|
| 38 | size_t buflen,
|
|---|
| 39 | void *private_data),
|
|---|
| 40 | void *private_data)
|
|---|
| 41 | {
|
|---|
| 42 | struct tevent_req *req, *subreq;
|
|---|
| 43 | struct tstream_read_packet_state *state;
|
|---|
| 44 |
|
|---|
| 45 | req = tevent_req_create(mem_ctx, &state,
|
|---|
| 46 | struct tstream_read_packet_state);
|
|---|
| 47 | if (req == NULL) {
|
|---|
| 48 | return NULL;
|
|---|
| 49 | }
|
|---|
| 50 | state->buf = talloc_array(state, uint8_t, initial);
|
|---|
| 51 | if (tevent_req_nomem(state->buf, req)) {
|
|---|
| 52 | return tevent_req_post(req, ev);
|
|---|
| 53 | }
|
|---|
| 54 | state->iov.iov_base = state->buf;
|
|---|
| 55 | state->iov.iov_len = initial;
|
|---|
| 56 |
|
|---|
| 57 | state->ev = ev;
|
|---|
| 58 | state->stream = stream;
|
|---|
| 59 | state->more = more;
|
|---|
| 60 | state->private_data = private_data;
|
|---|
| 61 |
|
|---|
|
|---|