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.1 by root, Sat Nov 3 19:41:56 2007 UTC vs.
Revision 1.7 by root, Thu Jan 31 13:10:56 2008 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/time.h>
32#include <stdint.h>
33#include <stdarg.h>
34
35#ifdef WIN32 32#ifdef _WIN32
36#define WIN32_LEAN_AND_MEAN 33# define WIN32_LEAN_AND_MEAN
37#include <windows.h> 34# include <windows.h>
38#undef WIN32_LEAN_AND_MEAN 35# undef WIN32_LEAN_AND_MEAN
39typedef unsigned char u_char; 36typedef unsigned char u_char;
40typedef 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>
41#endif 42#endif
43
44#include <stdarg.h>
42 45
43/* 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> */
44#ifndef TAILQ_ENTRY 47#ifndef TAILQ_ENTRY
45#define _EVENT_DEFINED_TQENTRY 48#define _EVENT_DEFINED_TQENTRY
46#define TAILQ_ENTRY(type) \ 49#define TAILQ_ENTRY(type) \
149struct bufferevent *bufferevent_new(int fd, 152struct bufferevent *bufferevent_new(int fd,
150 evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg); 153 evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg);
151int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev); 154int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev);
152int bufferevent_priority_set(struct bufferevent *bufev, int pri); 155int bufferevent_priority_set(struct bufferevent *bufev, int pri);
153void bufferevent_free(struct bufferevent *bufev); 156void bufferevent_free(struct bufferevent *bufev);
154int bufferevent_write(struct bufferevent *bufev, void *data, size_t size); 157int bufferevent_write(struct bufferevent *bufev, const void *data, size_t size);
155int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); 158int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf);
156size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); 159size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size);
157int bufferevent_enable(struct bufferevent *bufev, short event); 160int bufferevent_enable(struct bufferevent *bufev, short event);
158int bufferevent_disable(struct bufferevent *bufev, short event); 161int bufferevent_disable(struct bufferevent *bufev, short event);
159void bufferevent_settimeout(struct bufferevent *bufev, 162void bufferevent_settimeout(struct bufferevent *bufev,
185 * 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.
186 */ 189 */
187 190
188void evtag_init(void); 191void evtag_init(void);
189 192
190void evtag_marshal(struct evbuffer *evbuf, uint8_t tag, const void *data, 193void evtag_marshal(struct evbuffer *evbuf, uint32_t tag, const void *data,
191 uint32_t len); 194 uint32_t len);
192 195
193void encode_int(struct evbuffer *evbuf, uint32_t number); 196void encode_int(struct evbuffer *evbuf, uint32_t number);
194 197
195void 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);
196 199
197void evtag_marshal_string(struct evbuffer *buf, uint8_t tag, 200void evtag_marshal_string(struct evbuffer *buf, uint32_t tag,
198 const char *string); 201 const char *string);
199 202
200void evtag_marshal_timeval(struct evbuffer *evbuf, uint8_t tag, 203void evtag_marshal_timeval(struct evbuffer *evbuf, uint32_t tag,
201 struct timeval *tv); 204 struct timeval *tv);
202 205
203void evtag_test(void);
204
205int evtag_unmarshal(struct evbuffer *src, uint8_t *ptag, struct evbuffer *dst); 206int evtag_unmarshal(struct evbuffer *src, uint32_t *ptag, struct evbuffer *dst);
206int evtag_peek(struct evbuffer *evbuf, uint8_t *ptag); 207int evtag_peek(struct evbuffer *evbuf, uint32_t *ptag);
207int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength); 208int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength);
208int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength); 209int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength);
209int evtag_consume(struct evbuffer *evbuf); 210int evtag_consume(struct evbuffer *evbuf);
210 211
211int evtag_unmarshal_int(struct evbuffer *evbuf, uint8_t need_tag, 212int evtag_unmarshal_int(struct evbuffer *evbuf, uint32_t need_tag,
212 uint32_t *pinteger); 213 uint32_t *pinteger);
213 214
214int 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,
215 size_t len); 216 size_t len);
216 217
217int evtag_unmarshal_string(struct evbuffer *evbuf, uint8_t need_tag, 218int evtag_unmarshal_string(struct evbuffer *evbuf, uint32_t need_tag,
218 char **pstring); 219 char **pstring);
219 220
220int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint8_t need_tag, 221int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint32_t need_tag,
221 struct timeval *ptv); 222 struct timeval *ptv);
222 223
223#ifdef __cplusplus 224#ifdef __cplusplus
224} 225}
225#endif 226#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines