… | |
… | |
26 | */ |
26 | */ |
27 | #ifdef __cplusplus |
27 | #ifdef __cplusplus |
28 | extern "C" { |
28 | extern "C" { |
29 | #endif |
29 | #endif |
30 | |
30 | |
31 | #include <sys/types.h> |
|
|
32 | #include <sys/time.h> |
|
|
33 | #include <stdint.h> |
|
|
34 | #include <stdarg.h> |
|
|
35 | |
|
|
36 | #ifdef WIN32 |
31 | #ifdef _WIN32 |
37 | #define WIN32_LEAN_AND_MEAN |
32 | # define WIN32_LEAN_AND_MEAN |
38 | #include <windows.h> |
33 | # include <windows.h> |
39 | #undef WIN32_LEAN_AND_MEAN |
34 | # undef WIN32_LEAN_AND_MEAN |
40 | typedef unsigned char u_char; |
35 | typedef unsigned char u_char; |
41 | typedef unsigned short u_short; |
36 | typedef unsigned short u_short; |
|
|
37 | #else |
|
|
38 | # include <sys/types.h> |
|
|
39 | # include <sys/time.h> |
|
|
40 | # include <inttypes.h> |
42 | #endif |
41 | #endif |
|
|
42 | |
|
|
43 | #include <stdarg.h> |
43 | |
44 | |
44 | /* Fix so that ppl dont have to run with <sys/queue.h> */ |
45 | /* Fix so that ppl dont have to run with <sys/queue.h> */ |
45 | #ifndef TAILQ_ENTRY |
46 | #ifndef TAILQ_ENTRY |
46 | #define _EVENT_DEFINED_TQENTRY |
47 | #define _EVENT_DEFINED_TQENTRY |
47 | #define TAILQ_ENTRY(type) \ |
48 | #define TAILQ_ENTRY(type) \ |
… | |
… | |
150 | struct bufferevent *bufferevent_new(int fd, |
151 | struct bufferevent *bufferevent_new(int fd, |
151 | evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg); |
152 | evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg); |
152 | int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev); |
153 | int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev); |
153 | int bufferevent_priority_set(struct bufferevent *bufev, int pri); |
154 | int bufferevent_priority_set(struct bufferevent *bufev, int pri); |
154 | void bufferevent_free(struct bufferevent *bufev); |
155 | void bufferevent_free(struct bufferevent *bufev); |
155 | int bufferevent_write(struct bufferevent *bufev, void *data, size_t size); |
156 | int bufferevent_write(struct bufferevent *bufev, const void *data, size_t size); |
156 | int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); |
157 | int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); |
157 | size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); |
158 | size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); |
158 | int bufferevent_enable(struct bufferevent *bufev, short event); |
159 | int bufferevent_enable(struct bufferevent *bufev, short event); |
159 | int bufferevent_disable(struct bufferevent *bufev, short event); |
160 | int bufferevent_disable(struct bufferevent *bufev, short event); |
160 | void bufferevent_settimeout(struct bufferevent *bufev, |
161 | void bufferevent_settimeout(struct bufferevent *bufev, |
… | |
… | |
186 | * known ones - and we can just ignore the end of an event buffer. |
187 | * known ones - and we can just ignore the end of an event buffer. |
187 | */ |
188 | */ |
188 | |
189 | |
189 | void evtag_init(void); |
190 | void evtag_init(void); |
190 | |
191 | |
191 | void evtag_marshal(struct evbuffer *evbuf, uint8_t tag, const void *data, |
192 | void evtag_marshal(struct evbuffer *evbuf, uint32_t tag, const void *data, |
192 | uint32_t len); |
193 | uint32_t len); |
193 | |
194 | |
194 | void encode_int(struct evbuffer *evbuf, uint32_t number); |
195 | void encode_int(struct evbuffer *evbuf, uint32_t number); |
195 | |
196 | |
196 | void evtag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer); |
197 | void evtag_marshal_int(struct evbuffer *evbuf, uint32_t tag, uint32_t integer); |
197 | |
198 | |
198 | void evtag_marshal_string(struct evbuffer *buf, uint8_t tag, |
199 | void evtag_marshal_string(struct evbuffer *buf, uint32_t tag, |
199 | const char *string); |
200 | const char *string); |
200 | |
201 | |
201 | void evtag_marshal_timeval(struct evbuffer *evbuf, uint8_t tag, |
202 | void evtag_marshal_timeval(struct evbuffer *evbuf, uint32_t tag, |
202 | struct timeval *tv); |
203 | struct timeval *tv); |
203 | |
204 | |
204 | void evtag_test(void); |
|
|
205 | |
|
|
206 | int evtag_unmarshal(struct evbuffer *src, uint8_t *ptag, struct evbuffer *dst); |
205 | int evtag_unmarshal(struct evbuffer *src, uint32_t *ptag, struct evbuffer *dst); |
207 | int evtag_peek(struct evbuffer *evbuf, uint8_t *ptag); |
206 | int evtag_peek(struct evbuffer *evbuf, uint32_t *ptag); |
208 | int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength); |
207 | int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength); |
209 | int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength); |
208 | int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength); |
210 | int evtag_consume(struct evbuffer *evbuf); |
209 | int evtag_consume(struct evbuffer *evbuf); |
211 | |
210 | |
212 | int evtag_unmarshal_int(struct evbuffer *evbuf, uint8_t need_tag, |
211 | int evtag_unmarshal_int(struct evbuffer *evbuf, uint32_t need_tag, |
213 | uint32_t *pinteger); |
212 | uint32_t *pinteger); |
214 | |
213 | |
215 | int evtag_unmarshal_fixed(struct evbuffer *src, uint8_t need_tag, void *data, |
214 | int evtag_unmarshal_fixed(struct evbuffer *src, uint32_t need_tag, void *data, |
216 | size_t len); |
215 | size_t len); |
217 | |
216 | |
218 | int evtag_unmarshal_string(struct evbuffer *evbuf, uint8_t need_tag, |
217 | int evtag_unmarshal_string(struct evbuffer *evbuf, uint32_t need_tag, |
219 | char **pstring); |
218 | char **pstring); |
220 | |
219 | |
221 | int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint8_t need_tag, |
220 | int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint32_t need_tag, |
222 | struct timeval *ptv); |
221 | struct timeval *ptv); |
223 | |
222 | |
224 | #ifdef __cplusplus |
223 | #ifdef __cplusplus |
225 | } |
224 | } |
226 | #endif |
225 | #endif |