forked from OFLOPS-Turbo/oflops-turbo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msgbuf.h
27 lines (22 loc) · 1.01 KB
/
msgbuf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef MSGBUF_H
#define MSGBUF_H
// this code is not currently used by the system as it statically allocated buffers and
// forgot to check if new data would fit the buffer remaining size.
struct msgbuf
{
char * buf;
int len, start, end;
};
struct msgbuf * msgbuf_new(int bufsize);
int msgbuf_read(struct msgbuf * mbuf, int sock);
int msgbuf_read_all(struct msgbuf * mbuf, int sock, int len);
int msgbuf_write(struct msgbuf * mbuf, int sock, int len);
int msgbuf_write_all(struct msgbuf * mbuf, int sock, int len);
void msgbuf_grow(struct msgbuf *mbuf);
void msgbuf_clear(struct msgbuf *mbuf);
void * msgbuf_peek(struct msgbuf *mbuf);
int msgbuf_pull(struct msgbuf *mbuf, char * buf, int count);
void msgbuf_push(struct msgbuf *mbuf, char * buf, int count);
//int msgbuf_count_buffered(struct msgbuf * mbuf);
#define msgbuf_count_buffered(mbuf) ((mbuf->end - mbuf->start))
#endif