ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/event_compat.h
(Generate patch)

Comparing libev/event_compat.h (file contents):
Revision 1.2 by root, Thu Nov 8 23:53:41 2007 UTC vs.
Revision 1.8 by root, Wed Feb 16 08:02:51 2011 UTC

1/* 1/*
2 * Copyright (c) 2000-2004 Niels Provos <provos@citi.umich.edu> 2 * Copyright (c) 2000-2004 Niels Provos <provos@citi.umich.edu>
3 * Copyright (c) 2008 Marc Alexander Lehmann <libev@schmorp.de>
3 * All rights reserved. 4 * All rights reserved.
4 * 5 *
5 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
7 * are met: 8 * are met:
26 */ 27 */
27#ifdef __cplusplus 28#ifdef __cplusplus
28extern "C" { 29extern "C" {
29#endif 30#endif
30 31
31#include <sys/types.h>
32#include <sys/time.h>
33#include <stdint.h>
34#include <stdarg.h>
35
36#ifdef WIN32 32#ifdef _WIN32
37#define WIN32_LEAN_AND_MEAN 33# define WIN32_LEAN_AND_MEAN
38#include <windows.h> 34# include <windows.h>
39#undef WIN32_LEAN_AND_MEAN 35# undef WIN32_LEAN_AND_MEAN
40typedef unsigned char u_char; 36typedef unsigned char u_char;
41typedef unsigned short u_short; 37typedef unsigned short u_short;
38#else
39# include <sys/types.h>
40# include <sys/time.h>
41# include <inttypes.h>
42#endif 42#endif
43
44#include <stdarg.h>
43 45
44/* Fix so that ppl dont have to run with <sys/queue.h> */ 46/* Fix so that ppl dont have to run with <sys/queue.h> */
45#ifndef TAILQ_ENTRY 47#ifndef TAILQ_ENTRY
46#define _EVENT_DEFINED_TQENTRY 48#define _EVENT_DEFINED_TQENTRY
47#define TAILQ_ENTRY(type) \ 49#define TAILQ_ENTRY(type) \
150struct bufferevent *bufferevent_new(int fd, 152struct bufferevent *bufferevent_new(int fd,
151 evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg); 153 evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg);
152int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev); 154int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev);
153int bufferevent_priority_set(struct bufferevent *bufev, int pri); 155int bufferevent_priority_set(struct bufferevent *bufev, int pri);
154void bufferevent_free(struct bufferevent *bufev); 156void bufferevent_free(struct bufferevent *bufev);
155int bufferevent_write(struct bufferevent *bufev, void *data, size_t size); 157int bufferevent_write(struct bufferevent *bufev, const void *data, size_t size);
156int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); 158int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf);
157size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); 159size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size);
158int bufferevent_enable(struct bufferevent *bufev, short event); 160int bufferevent_enable(struct bufferevent *bufev, short event);
159int bufferevent_disable(struct bufferevent *bufev, short event); 161int bufferevent_disable(struct bufferevent *bufev, short event);
160void bufferevent_settimeout(struct bufferevent *bufev, 162void bufferevent_settimeout(struct bufferevent *bufev,
178int evbuffer_write(struct evbuffer *, int); 180int evbuffer_write(struct evbuffer *, int);
179int evbuffer_read(struct evbuffer *, int, int); 181int evbuffer_read(struct evbuffer *, int, int);
180u_char *evbuffer_find(struct evbuffer *, const u_char *, size_t); 182u_char *evbuffer_find(struct evbuffer *, const u_char *, size_t);
181void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_t, void *), void *); 183void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_t, void *), void *);
182 184
183/* 185/*
184 * Marshaling tagged data - We assume that all tags are inserted in their 186 * Marshaling tagged data - We assume that all tags are inserted in their
185 * numeric order - so that unknown tags will always be higher than the 187 * numeric order - so that unknown tags will always be higher than the
186 * known ones - and we can just ignore the end of an event buffer. 188 * known ones - and we can just ignore the end of an event buffer.
187 */ 189 */
188 190
189void evtag_init(void); 191void evtag_init(void);
190 192
191void evtag_marshal(struct evbuffer *evbuf, uint8_t tag, const void *data, 193void evtag_marshal(struct evbuffer *evbuf, uint32_t tag, const void *data,
192 uint32_t len); 194 uint32_t len);
193 195
194void encode_int(struct evbuffer *evbuf, uint32_t number); 196void encode_int(struct evbuffer *evbuf, uint32_t number);
195 197
196void evtag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer); 198void evtag_marshal_int(struct evbuffer *evbuf, uint32_t tag, uint32_t integer);
197 199
198void evtag_marshal_string(struct evbuffer *buf, uint8_t tag, 200void evtag_marshal_string(struct evbuffer *buf, uint32_t tag,
199 const char *string); 201 const char *string);
200 202
201void evtag_marshal_timeval(struct evbuffer *evbuf, uint8_t tag, 203void evtag_marshal_timeval(struct evbuffer *evbuf, uint32_t tag,
202 struct timeval *tv); 204 struct timeval *tv);
203 205
204void evtag_test(void);
205
206int evtag_unmarshal(struct evbuffer *src, uint8_t *ptag, struct evbuffer *dst); 206int evtag_unmarshal(struct evbuffer *src, uint32_t *ptag, struct evbuffer *dst);
207int evtag_peek(struct evbuffer *evbuf, uint8_t *ptag); 207int evtag_peek(struct evbuffer *evbuf, uint32_t *ptag);
208int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength); 208int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength);
209int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength); 209int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength);
210int evtag_consume(struct evbuffer *evbuf); 210int evtag_consume(struct evbuffer *evbuf);
211 211
212int evtag_unmarshal_int(struct evbuffer *evbuf, uint8_t need_tag, 212int evtag_unmarshal_int(struct evbuffer *evbuf, uint32_t need_tag,
213 uint32_t *pinteger); 213 uint32_t *pinteger);
214 214
215int evtag_unmarshal_fixed(struct evbuffer *src, uint8_t need_tag, void *data, 215int evtag_unmarshal_fixed(struct evbuffer *src, uint32_t need_tag, void *data,
216 size_t len); 216 size_t len);
217 217
218int evtag_unmarshal_string(struct evbuffer *evbuf, uint8_t need_tag, 218int evtag_unmarshal_string(struct evbuffer *evbuf, uint32_t need_tag,
219 char **pstring); 219 char **pstring);
220 220
221int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint8_t need_tag, 221int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint32_t need_tag,
222 struct timeval *ptv); 222 struct timeval *ptv);
223 223
224#ifdef __cplusplus 224#ifdef __cplusplus
225} 225}
226#endif 226#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines