s3: Slightly simplify open_file_ntcreate
[Samba/gebeck_regimport.git] / libcli / util / tstream.h
blob36ae65d9e5bd39ee7720cf035fe1271412247154
1 /*
2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Stefan Metzmacher 2009
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.
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, see <http://www.gnu.org/licenses/>.
20 #ifndef _LIBCLI_UTIL_TSTREAM_H_
21 #define _LIBCLI_UTIL_TSTREAM_H_
23 /**
24 * @brief The function which will report the size of the full pdu.
26 * @param[in] private_data Some private data which could be used.
28 * @param[in] blob The received blob to get the size from.
30 * @param[out] packet_size The pointer to store the size of the full pdu.
32 * @return NT_STATUS_OK on success, STATUS_MORE_ENTRIES if there
33 * are more entries.
35 typedef NTSTATUS tstream_read_pdu_blob_full_fn_t(void *private_data,
36 DATA_BLOB blob,
37 size_t *packet_size);
39 /**
40 * @brief A helper function to read a full PDU from a stream
42 * This function is designed for simple PDUs and as compat layer
43 * for the Samba4 packet interface.
45 * tstream_readv_pdu_send() is a more powerful interface,
46 * which is part of the main (non samba specific) tsocket code.
48 * @param[in] mem_ctx The memory context for the result.
50 * @param[in] ev The event context the operation should work on.
52 * @param[in] stream The stream to read data from.
54 * @param[in] inital_read_size The initial byte count that is needed to workout
55 * the full pdu size.
57 * @param[in] full_fn The callback function that will report the size
58 * of the full pdu.
60 * @param[in] full_private The private data for the callback function.
62 * @return The async request handle. NULL on fatal error.
64 * @see tstream_read_pdu_blob_recv()
65 * @see tstream_readv_pdu_send()
66 * @see tstream_readv_pdu_queue_send()
69 struct tevent_req *tstream_read_pdu_blob_send(TALLOC_CTX *mem_ctx,
70 struct tevent_context *ev,
71 struct tstream_context *stream,
72 size_t inital_read_size,
73 tstream_read_pdu_blob_full_fn_t *full_fn,
74 void *full_private);
75 /**
76 * @brief Receive the result of the tstream_read_pdu_blob_send() call.
78 * @param[in] req The tevent request from tstream_read_pdu_blob_send().
80 * @param[in] mem_ctx The memory context for returned pdu DATA_BLOB.
82 * @param[in] pdu_blob The DATA_BLOB with the full pdu.
84 * @return The NTSTATUS result, NT_STATUS_OK on success
85 * and others on failure.
87 * @see tstream_read_pdu_blob_send()
89 NTSTATUS tstream_read_pdu_blob_recv(struct tevent_req *req,
90 TALLOC_CTX *mem_ctx,
91 DATA_BLOB *pdu_blob);
93 #endif /* _LIBCLI_UTIL_TSTREAM_H_ */