1 #ifndef _EV_BUFFER_EVENT__HPP_
2 #define _EV_BUFFER_EVENT__HPP_
4 #include <EvBufferEventInternal.hpp>
7 struct EvBufferEvent
: EvBufferEventInternal
10 /// C read/write callback function used in the C evbuffer API.
11 typedef void (*readwritecb
)(struct bufferevent
*, void *);
13 /// C error callback function used in the C evbuffer API.
14 typedef void (*errorcb
)(struct bufferevent
*, short, void *);
16 // TODO: EvBufferEvent(int fd, ...) throw(...) { ... }
18 // Future: to be deprecated by EvBufferEvent(int fd, ...) throw(...)
21 * Constructor to setup callbacks
23 EvBufferEvent(readwritecb readcb
, readwritecb writecb
, errorcb errcb
, void * arg
)
32 // Future: to be deprecated by EvBufferEvent(...) throw(...)
35 * Open the bufferevent object with the file/socket descriptor
37 void open(int fd
) /* throw(...) */
39 (void)_bufferevent_new(fd
);
43 * Open the bufferevent object by accepting a connection on the socket descriptor
45 void accept(int listen_sock
) /* throw(...) */
47 (void)_bufev_socket_accept(listen_sock
);
53 * Write data to the buffer.
55 * @param buf Buffer of data to be written.
57 * @param len Length of data to be written.
60 int write(const void * buf
, int len
)
62 return _write((char *)buf
, len
);
66 * Read data from the buffer.
68 * @param buf Buffer to store data.
70 * @param len Size of buffer to store data.
73 int read(char * buf
, int len
)
75 return _read(buf
, len
);
80 void _readcb_handler()
82 (*_readcb
)(_bufferevent
, _arg
);
86 void _writecb_handler()
88 (*_writecb
)(_bufferevent
, _arg
);
92 void _errorcb_handler(short what
)
94 (*_errorcb
)(_bufferevent
, what
, _arg
);
101 readwritecb _readcb
, _writecb
;
106 #endif // _EV_BUFFER_EVENT__HPP_
108 // vim: set filetype=cpp :