Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/SharedDependencies/Sources/libslirp/include/stream.h
2 views
1
/* SPDX-License-Identifier: BSD-3-Clause */
2
#ifndef STREAM_H_
3
#define STREAM_H_
4
5
#include "libslirp.h"
6
7
typedef struct SlirpIStream {
8
SlirpReadCb read_cb;
9
void *opaque;
10
} SlirpIStream;
11
12
typedef struct SlirpOStream {
13
SlirpWriteCb write_cb;
14
void *opaque;
15
} SlirpOStream;
16
17
/* Read exactly size bytes from stream, return 1 if all ok, 0 otherwise */
18
bool slirp_istream_read(SlirpIStream *f, void *buf, size_t size);
19
/* Write exactly size bytes to stream, return 1 if all ok, 0 otherwise */
20
bool slirp_ostream_write(SlirpOStream *f, const void *buf, size_t size);
21
22
/* Read exactly one byte from stream, return it, otherwise return 0 */
23
uint8_t slirp_istream_read_u8(SlirpIStream *f);
24
/* Write exactly one byte to stream, return 1 if all ok, 0 otherwise */
25
bool slirp_ostream_write_u8(SlirpOStream *f, uint8_t b);
26
27
/* Read exactly two bytes from big-endian stream, return it, otherwise return 0 */
28
uint16_t slirp_istream_read_u16(SlirpIStream *f);
29
/* Write exactly two bytes to big-endian stream, return 1 if all ok, 0 otherwise */
30
bool slirp_ostream_write_u16(SlirpOStream *f, uint16_t b);
31
32
/* Read exactly four bytes from big-endian stream, return it, otherwise return 0 */
33
uint32_t slirp_istream_read_u32(SlirpIStream *f);
34
/* Write exactly four bytes to big-endian stream, return 1 if all ok, 0 otherwise */
35
bool slirp_ostream_write_u32(SlirpOStream *f, uint32_t b);
36
37
/* Read exactly two bytes from big-endian stream (signed), return it, otherwise return 0 */
38
int16_t slirp_istream_read_i16(SlirpIStream *f);
39
/* Write exactly two bytes to big-endian stream (signed), return 1 if all ok, 0 otherwise */
40
bool slirp_ostream_write_i16(SlirpOStream *f, int16_t b);
41
42
/* Read exactly four bytes from big-endian stream (signed), return it, otherwise return 0 */
43
int32_t slirp_istream_read_i32(SlirpIStream *f);
44
/* Write exactly four bytes to big-endian stream (signed), return 1 if all ok, 0 otherwise */
45
bool slirp_ostream_write_i32(SlirpOStream *f, int32_t b);
46
47
#endif /* STREAM_H_ */
48
49