bglibs: ibuf.h Source File

- Main Page
- Modules
- Data Structures
- Files
- Directories
- Related Pages
- Examples

# ibuf.h

    00001 /* $Id: ibuf.h 616 2005-08-19 20:11:01Z bruce $ */
    00002 #ifndef IO_BUF__IBUF__H__
    00003 #define IO_BUF__IBUF__H__
    00004
    00005 #include <iobuf/common.h>
    00006
    00017 typedef int (*ibuf_fn)(int, void*, unsigned long);
    00018
    00020 struct ibuf
    00021 {
    00023   iobuf io;
    00025   unsigned count;
    00027   ibuf_fn readfn;
    00028 };
    00030 typedef struct ibuf ibuf;
    00031
    00032 extern ibuf inbuf;
    00033
    00034 int ibuf_init(ibuf* in, int fd, ibuf_fn fn, unsigned flags, unsigned bufsize);
    00035 int ibuf_open(ibuf* in, const char* filename, unsigned bufsize);
    00036 int ibuf_eof(ibuf* in);
    00038 #define ibuf_close(in) iobuf_close(&((in)->io))
    00039
    00040 #define ibuf_closed(in) iobuf_closed(&((in)->io))
    00041
    00042 #define ibuf_error(in) iobuf_error(&((in)->io))
    00043
    00044 #define ibuf_timedout(in) iobuf_timedout(&((in)->io))
    00045 int ibuf_refill(ibuf* in);
    00046 int ibuf_read_large(ibuf* in, char* data, unsigned datalen);
    00047 int ibuf_read(ibuf* in, char* data, unsigned datalen);
    00048 unsigned ibuf_tell(ibuf* in);
    00049 int ibuf_seek(ibuf* in, unsigned offset);
    00051 #define ibuf_rewind(in) ibuf_seek(in,0)
    00052
    00053 #define ibuf_seekfwd(in,off) ibuf_seek(ibuf_tell(in)+(offset))
    00054
    00055 int ibuf_peek(ibuf* in, char* ch);
    00056 int ibuf_getc(ibuf* in, char* ch);
    00057 int ibuf_getu(ibuf* in, unsigned long* data);
    00058 int ibuf_gets(ibuf* in, char* data, unsigned datalen, char boundary);
    00059 int ibuf_getstr(ibuf* in, struct str* s, char boundary);
    00060 int ibuf_getstr_crlf(ibuf* in, struct str* s);
    00061 int ibuf_getnetstring(ibuf* in, struct str* s);
    00062 int ibuf_readall(ibuf* in, struct str* s);
    00063 int ibuf_openreadclose(const char* filename, struct str* s);
    00066 #endif