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/sbuf.h
2 views
1
/* SPDX-License-Identifier: BSD-3-Clause */
2
/*
3
* Copyright (c) 1995 Danny Gasparovski.
4
*/
5
6
#ifndef SBUF_H
7
#define SBUF_H
8
9
/* How many bytes are free in the sbuf */
10
#define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)
11
12
struct sbuf {
13
uint32_t sb_cc; /* actual chars in buffer */
14
uint32_t sb_datalen; /* Length of data */
15
char *sb_wptr; /* write pointer. points to where the next
16
* bytes should be written in the sbuf */
17
char *sb_rptr; /* read pointer. points to where the next
18
* byte should be read from the sbuf */
19
char *sb_data; /* Actual data */
20
};
21
22
/* Release the sbuf */
23
void sbfree(struct sbuf *sb);
24
25
/* Drop len bytes from the reading end of the sbuf */
26
bool sbdrop(struct sbuf *sb, size_t len);
27
28
/* (re)Allocate sbuf buffer to store size bytes */
29
void sbreserve(struct sbuf *sb, size_t size);
30
31
/*
32
* Try and write() to the socket, whatever doesn't get written
33
* append to the buffer... for a host with a fast net connection,
34
* this prevents an unnecessary copy of the data
35
* (the socket is non-blocking, so we won't hang)
36
*/
37
void sbappend(struct socket *sb, struct mbuf *mb);
38
39
/*
40
* Copy data from sbuf to a normal, straight buffer
41
* Don't update the sbuf rptr, this will be
42
* done in sbdrop when the data is acked
43
*/
44
void sbcopy(struct sbuf *sb, size_t off, size_t len, char *p);
45
46
#endif
47
48