File: streambuf.h

package info (click to toggle)
rtpengine 13.5.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,676 kB
  • sloc: ansic: 86,764; perl: 59,422; python: 3,193; sh: 1,030; makefile: 693; asm: 211
file content (53 lines) | stat: -rw-r--r-- 1,217 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef __BUFFER_H__
#define __BUFFER_H__



#include <sys/types.h>
#include <time.h>
#include <glib.h>
#include <stdarg.h>

#include "compat.h"
#include "str.h"
#include "auxlib.h"



struct poller;



struct streambuf_funcs {
	ssize_t (*write)(void *, const void *, size_t);
	ssize_t (*read)(void *, void *, size_t);
};
struct streambuf {
	mutex_t		lock;
	GString		*buf;
	void		*fd_ptr;
	struct poller	*poller;
	int64_t		active_us;
	int		eof;
	const struct streambuf_funcs
			*funcs;
};



struct streambuf *streambuf_new(struct poller *, int);
struct streambuf *streambuf_new_ptr(struct poller *, void *, const struct streambuf_funcs *);
void streambuf_destroy(struct streambuf *);
int streambuf_writeable(struct streambuf *);
int streambuf_readable(struct streambuf *);
char *streambuf_getline(struct streambuf *);
size_t streambuf_bufsize(struct streambuf *);
size_t streambuf_printf(struct streambuf *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
size_t streambuf_vprintf(struct streambuf *, const char *, va_list);
void streambuf_write(struct streambuf *, const char *, unsigned int);
INLINE void streambuf_write_str(struct streambuf *b, str *s) {
	streambuf_write(b, s->s, s->len);
}


#endif