00001 #ifndef IO_BUF__IBUF__H__ 00002 #define IO_BUF__IBUF__H__ 00003 00004 #include <iobuf/common.h> 00005 00016 typedef int (*ibuf_fn)(int, void*, unsigned long); 00017 00019 struct ibuf 00020 { 00022 iobuf io; 00024 unsigned count; 00026 ibuf_fn readfn; 00027 }; 00029 typedef struct ibuf ibuf; 00030 00031 extern ibuf inbuf; 00032 00033 int ibuf_init(ibuf* in, int fd, ibuf_fn fn, unsigned flags, unsigned bufsize); 00034 int ibuf_open(ibuf* in, const char* filename, unsigned bufsize); 00035 int ibuf_eof(ibuf* in); 00037 #define ibuf_close(in) iobuf_close(&((in)->io)) 00038 00039 #define ibuf_closed(in) iobuf_closed(&((in)->io)) 00040 00041 #define ibuf_error(in) iobuf_error(&((in)->io)) 00042 00043 #define ibuf_timedout(in) iobuf_timedout(&((in)->io)) 00044 int ibuf_refill(ibuf* in); 00045 int ibuf_read_large(ibuf* in, char* data, unsigned datalen); 00046 int ibuf_read(ibuf* in, char* data, unsigned datalen); 00047 unsigned ibuf_tell(ibuf* in); 00048 int ibuf_seek(ibuf* in, unsigned offset); 00050 #define ibuf_rewind(in) ibuf_seek(in,0) 00051 00052 #define ibuf_seekfwd(in,off) ibuf_seek(ibuf_tell(in)+(offset)) 00053 00054 int ibuf_peek(ibuf* in, char* ch); 00055 int ibuf_getc(ibuf* in, char* ch); 00056 int ibuf_getu(ibuf* in, unsigned long* data); 00057 int ibuf_gets(ibuf* in, char* data, unsigned datalen, char boundary); 00058 int ibuf_getstr(ibuf* in, struct str* s, char boundary); 00059 int ibuf_getstr_crlf(ibuf* in, struct str* s); 00060 int ibuf_getnetstring(ibuf* in, struct str* s); 00061 int ibuf_readall(ibuf* in, struct str* s); 00062 int ibuf_openreadclose(const char* filename, struct str* s); 00065 #endif