--- cvsroot/libev/event_compat.h 2007/11/03 19:41:56 1.1 +++ cvsroot/libev/event_compat.h 2011/02/16 08:02:51 1.8 @@ -1,5 +1,6 @@ /* * Copyright (c) 2000-2004 Niels Provos + * Copyright (c) 2008 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,18 +29,20 @@ extern "C" { #endif -#include -#include -#include - -#ifdef WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +# include +# undef WIN32_LEAN_AND_MEAN typedef unsigned char u_char; typedef unsigned short u_short; +#else +# include +# include +# include #endif +#include + /* Fix so that ppl dont have to run with */ #ifndef TAILQ_ENTRY #define _EVENT_DEFINED_TQENTRY @@ -151,7 +154,7 @@ int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev); int bufferevent_priority_set(struct bufferevent *bufev, int pri); void bufferevent_free(struct bufferevent *bufev); -int bufferevent_write(struct bufferevent *bufev, void *data, size_t size); +int bufferevent_write(struct bufferevent *bufev, const void *data, size_t size); int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); int bufferevent_enable(struct bufferevent *bufev, short event); @@ -179,7 +182,7 @@ u_char *evbuffer_find(struct evbuffer *, const u_char *, size_t); void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_t, void *), void *); -/* +/* * Marshaling tagged data - We assume that all tags are inserted in their * numeric order - so that unknown tags will always be higher than the * known ones - and we can just ignore the end of an event buffer. @@ -187,37 +190,35 @@ void evtag_init(void); -void evtag_marshal(struct evbuffer *evbuf, uint8_t tag, const void *data, +void evtag_marshal(struct evbuffer *evbuf, uint32_t tag, const void *data, uint32_t len); void encode_int(struct evbuffer *evbuf, uint32_t number); -void evtag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer); +void evtag_marshal_int(struct evbuffer *evbuf, uint32_t tag, uint32_t integer); -void evtag_marshal_string(struct evbuffer *buf, uint8_t tag, +void evtag_marshal_string(struct evbuffer *buf, uint32_t tag, const char *string); -void evtag_marshal_timeval(struct evbuffer *evbuf, uint8_t tag, +void evtag_marshal_timeval(struct evbuffer *evbuf, uint32_t tag, struct timeval *tv); -void evtag_test(void); - -int evtag_unmarshal(struct evbuffer *src, uint8_t *ptag, struct evbuffer *dst); -int evtag_peek(struct evbuffer *evbuf, uint8_t *ptag); +int evtag_unmarshal(struct evbuffer *src, uint32_t *ptag, struct evbuffer *dst); +int evtag_peek(struct evbuffer *evbuf, uint32_t *ptag); int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength); int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength); int evtag_consume(struct evbuffer *evbuf); -int evtag_unmarshal_int(struct evbuffer *evbuf, uint8_t need_tag, +int evtag_unmarshal_int(struct evbuffer *evbuf, uint32_t need_tag, uint32_t *pinteger); -int evtag_unmarshal_fixed(struct evbuffer *src, uint8_t need_tag, void *data, +int evtag_unmarshal_fixed(struct evbuffer *src, uint32_t need_tag, void *data, size_t len); -int evtag_unmarshal_string(struct evbuffer *evbuf, uint8_t need_tag, +int evtag_unmarshal_string(struct evbuffer *evbuf, uint32_t need_tag, char **pstring); -int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint8_t need_tag, +int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint32_t need_tag, struct timeval *ptv); #ifdef __cplusplus