bglibs: ibuf.h Source File

bglibs

ibuf.h
1 #ifndef IO_BUF__IBUF__H__
2 #define IO_BUF__IBUF__H__
3
4 #include "iobuf_common.h"
5
16 typedef int (*ibuf_fn)(int, void*, unsigned long);
17
19 struct ibuf
20 {
22 iobuf io;
24 unsigned count;
26 ibuf_fn readfn;
27 };
29 typedef struct ibuf ibuf;
30
31 extern ibuf inbuf;
32
33 int ibuf_init(ibuf* in, int fd, ibuf_fn fn, unsigned flags, unsigned bufsize);
34 int ibuf_open(ibuf* in, const char* filename, unsigned bufsize);
35 int ibuf_eof(ibuf* in);
37 #define ibuf_close(in) iobuf_close(&((in)->io))
38
39 #define ibuf_closed(in) iobuf_closed(&((in)->io))
40
41 #define ibuf_error(in) iobuf_error(&((in)->io))
42
43 #define ibuf_timedout(in) iobuf_timedout(&((in)->io))
44 int ibuf_refill(ibuf* in);
45 int ibuf_read_large(ibuf* in, char* data, unsigned datalen);
46 int ibuf_read(ibuf* in, char* data, unsigned datalen);
47 unsigned ibuf_tell(ibuf* in);
48 int ibuf_seek(ibuf* in, unsigned offset);
50 #define ibuf_rewind(in) ibuf_seek(in,0)
51
52 #define ibuf_seekfwd(in,off) ibuf_seek(ibuf_tell(in)+(offset))
53
54 int ibuf_peek(ibuf* in, char* ch);
55 int ibuf_getc(ibuf* in, char* ch);
56 int ibuf_getu(ibuf* in, unsigned long* data);
57 int ibuf_gets(ibuf* in, char* data, unsigned datalen, char boundary);
58 int ibuf_getstr(ibuf* in, struct str* s, char boundary);
59 int ibuf_getstr_crlf(ibuf* in, struct str* s);
60 int ibuf_getnetstring(ibuf* in, struct str* s);
61 int ibuf_readall(ibuf* in, struct str* s);
62 int ibuf_openreadclose(const char* filename, struct str* s);
65 #endif
ibuf::io
iobuf io
Definition: ibuf.h:22
ibuf_peek
int ibuf_peek(ibuf *in, char *ch)
Definition: ibuf_peek.c:5
ibuf_getstr
int ibuf_getstr(ibuf *in, struct str *s, char boundary)
Definition: ibuf_getstr.c:5
ibuf_read_large
int ibuf_read_large(ibuf *in, char *data, unsigned datalen)
Definition: ibuf_read.c:13
ibuf_getnetstring
int ibuf_getnetstring(ibuf *in, struct str *s)
Definition: ibuf_getnetstring.c:10
ibuf::count
unsigned count
Definition: ibuf.h:24
ibuf::readfn
ibuf_fn readfn
Definition: ibuf.h:26
ibuf_seek
int ibuf_seek(ibuf *in, unsigned offset)
Definition: ibuf_seek.c:7
ibuf_getstr_crlf
int ibuf_getstr_crlf(ibuf *in, struct str *s)
Definition: ibuf_getstr_crlf.c:21
ibuf
Definition: ibuf.h:19
ibuf_open
int ibuf_open(ibuf *in, const char *filename, unsigned bufsize)
Definition: ibuf_open.c:5
inbuf
ibuf inbuf
Definition: ibuf_stdin.c:7
ibuf_eof
int ibuf_eof(ibuf *in)
Definition: ibuf_status.c:4
ibuf_init
int ibuf_init(ibuf *in, int fd, ibuf_fn fn, unsigned flags, unsigned bufsize)
Definition: ibuf_init.c:5
ibuf_readall
int ibuf_readall(ibuf *in, struct str *s)
Definition: ibuf_readall.c:5
ibuf_read
int ibuf_read(ibuf *in, char *data, unsigned datalen)
Definition: ibuf_read.c:55
ibuf_refill
int ibuf_refill(ibuf *in)
Definition: ibuf_refill.c:11
ibuf_gets
int ibuf_gets(ibuf *in, char *data, unsigned datalen, char boundary)
Definition: ibuf_gets.c:4
str
Definition: str.h:30
ibuf_openreadclose
int ibuf_openreadclose(const char *filename, struct str *s)
Definition: ibuf_openreadclose.c:5
iobuf
Definition: iobuf_common.h:48
ibuf_tell
unsigned ibuf_tell(ibuf *in)
Definition: ibuf_tell.c:4
ibuf_fn
int(* ibuf_fn)(int, void *, unsigned long)
Definition: ibuf.h:16
ibuf_getc
int ibuf_getc(ibuf *in, char *ch)
Definition: ibuf_getc.c:4
ibuf_getu
int ibuf_getu(ibuf *in, unsigned long *data)
Definition: ibuf_getu.c:4