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 {
24  unsigned count;
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
iobuf io
Definition: ibuf.h:22
int ibuf_peek(ibuf *in, char *ch)
Definition: ibuf_peek.c:5
int ibuf_getstr(ibuf *in, struct str *s, char boundary)
Definition: ibuf_getstr.c:5
int ibuf_read_large(ibuf *in, char *data, unsigned datalen)
Definition: ibuf_read.c:13
int ibuf_getnetstring(ibuf *in, struct str *s)
Definition: ibuf_getnetstring.c:10
unsigned count
Definition: ibuf.h:24
ibuf_fn readfn
Definition: ibuf.h:26
int ibuf_seek(ibuf *in, unsigned offset)
Definition: ibuf_seek.c:7
int ibuf_getstr_crlf(ibuf *in, struct str *s)
Definition: ibuf_getstr_crlf.c:21
Definition: ibuf.h:19
int ibuf_open(ibuf *in, const char *filename, unsigned bufsize)
Definition: ibuf_open.c:5
ibuf inbuf
Definition: ibuf_stdin.c:7
int ibuf_eof(ibuf *in)
Definition: ibuf_status.c:4
int ibuf_init(ibuf *in, int fd, ibuf_fn fn, unsigned flags, unsigned bufsize)
Definition: ibuf_init.c:5
int ibuf_readall(ibuf *in, struct str *s)
Definition: ibuf_readall.c:5
int ibuf_read(ibuf *in, char *data, unsigned datalen)
Definition: ibuf_read.c:55
int ibuf_refill(ibuf *in)
Definition: ibuf_refill.c:11
int ibuf_gets(ibuf *in, char *data, unsigned datalen, char boundary)
Definition: ibuf_gets.c:4
Definition: str.h:30
int ibuf_openreadclose(const char *filename, struct str *s)
Definition: ibuf_openreadclose.c:5
Definition: iobuf_common.h:48
unsigned ibuf_tell(ibuf *in)
Definition: ibuf_tell.c:4
int(* ibuf_fn)(int, void *, unsigned long)
Definition: ibuf.h:16
int ibuf_getc(ibuf *in, char *ch)
Definition: ibuf_getc.c:4
int ibuf_getu(ibuf *in, unsigned long *data)
Definition: ibuf_getu.c:4