Ruslan Osmanov avatar Ruslan Osmanov committed ce812dc

Completed converting all to oop. Still have to add some properties and test it all

Comments (0)

Files changed (17)

 #include "util.h"
 #include "priv.h"
 
-extern zend_class_entry *php_event_base_ce;
-extern zend_class_entry *php_event_config_ce;
-
 /* {{{ proto EventBase EventBase::__construct([EventConfig cfg = null]); */
 PHP_METHOD(EventBase, __construct)
 {
 		return;
 	}
 
-	b = (php_event_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
+	PHP_EVENT_FETCH_BASE(b, getThis());
 
 	if (zcfg == NULL) {
 		b->base = event_base_new();
 	} else {
 		PHP_EVENT_FETCH_CONFIG(cfg, zcfg);
 
-		b->base = event_base_new_with_config(cfg);
-	}
-}
-/* }}} */
-
-/* {{{ proto void EventBase::free(void);
-   XXX FALIAS to __destruct? */
-PHP_METHOD(EventBase, free)
-{
-	zval *self = getThis();
-
-	if (zend_parse_parameters_none() == FAILURE) {
-		return;
+		b->base = event_base_new_with_config(cfg->ptr);
 	}
-
-	zval_ptr_dtor(&self);
 }
 /* }}} */
 
 }
 /* }}} */
 
-/* {{{ proto bool EventBase::break(void);
+/* {{{ proto bool EventBase::stop(void);
  * Tells event_base to stop. */
 PHP_METHOD(EventBase, event_base_loopbreak)
 {
 }
 /* }}} */
 
-/* {{{ proto bool EventBase::set(resource base, resource event);
+/* {{{ proto bool EventBase::set(Event event);
  * Associate event base with an event. */
 PHP_METHOD(EventBase, set)
 {
 }
 /* }}} */
 
-/* {{{ proto bool EventBase::gotBreak(void);
- * Checks if the event loop was told to abort immediately by <function>event_loopbreak</function> */
-PHP_METHOD(EventBase, EventBase::gotBreak)
+/* {{{ proto bool EventBase::gotStop(void);
+ *
+ * Checks if the event loop was told to abort immediately by EventBase::stop() */
+PHP_METHOD(EventBase, gotStop)
 {
 	zval             *zbase = getThis();
 	php_event_base_t *b;
 }
 /* }}} */
 
-/* {{{ proto double EventBase::getTimeOfDayCached(EventBase base);
+/* {{{ proto double EventBase::getTimeOfDayCached(void);
+ *
  * On success returns the current time(as returned by gettimeofday()), looking
  * at the cached value in 'base' if possible, and calling gettimeofday() or
  * clock_gettime() as appropriate if there is no cached time. On failure
 /* }}} */
 
 #if LIBEVENT_VERSION_NUMBER >= 0x02010100
-/* {{{ proto bool EventBase::updateCacheTime(resource base);
+/* {{{ proto bool EventBase::updateCacheTime(void);
  * Updates cache time. Available since libevent 2.1.1-alpha */
 PHP_METHOD(EventBase, updateCacheTime)
 {
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 1997-2013 The PHP Group                                |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license@php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Author: Ruslan Osmanov <osmanov@php.net>                             |
+   +----------------------------------------------------------------------+
+*/
+#include "common.h"
+#include "util.h"
+#include "priv.h"
+
+/* {{{ proto resource EventBuffer::__construct(void); */
+PHP_METHOD(EventBuffer, __construct)
+{
+	php_event_buffer_t *b;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, getThis());
+
+	b->buf = evbuffer_new();
+}
+/* }}} */
+
+/* {{{ proto bool EventBuffer::freeze(bool at_front);
+ * Prevent calls that modify an event buffer from succeeding. */
+PHP_METHOD(EventBuffer, freeze)
+{
+	zval               *zbuf = getThis();
+	php_event_buffer_t *b;
+	zend_bool           at_front;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b",
+				&at_front) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	if (evbuffer_freeze(b->buf, at_front)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventBuffer::unfreeze(bool at_front);
+ * Re-enable calls that modify an event buffer. */
+PHP_METHOD(EventBuffer, unfreeze)
+{
+	zval               *zbuf     = getThis();
+	php_event_buffer_t *b;
+	zend_bool           at_front;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b",
+				&at_front) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	if (evbuffer_unfreeze(b->buf, at_front)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto long EventBuffer::getLength(void);
+ * XXX Create property?
+ * Returns the total number of bytes stored in the event buffer. */
+PHP_METHOD(EventBuffer, get_length)
+{
+	zval               *zbuf = getThis();
+	php_event_buffer_t *b;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	RETVAL_LONG(evbuffer_get_length(b->buf));
+}
+/* }}} */
+
+/* {{{ proto void EventBuffer::lock(void);
+ * Acquire the lock on an evbuffer. 
+ * Has no effect if locking was not enabled with evbuffer_enable_locking.
+ */
+PHP_METHOD(EventBuffer, lock)
+{
+	zval               *zbuf = getThis();
+	php_event_buffer_t *b;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	evbuffer_lock(b->buf);
+}
+/* }}} */
+
+/* {{{ proto void EventBuffer::unlock(void);
+ * Release the lock on an evbuffer.
+ * Has no effect if locking was not enabled with evbuffer_enable_locking.
+ */
+PHP_METHOD(EventBuffer, unlock)
+{
+	zval               *zbuf = getThis();
+	php_event_buffer_t *b;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	evbuffer_unlock(b->buf);
+}
+/* }}} */
+
+/* {{{ proto void EventBuffer::enableLocking(void);
+ *
+ * Enable locking on an evbuffer so that it can safely be used by multiple threads at the same time.
+ * When locking is enabled, the lock will be held when callbacks are invoked.
+ * This could result in deadlock if you aren't careful. Plan accordingly!
+ */
+PHP_METHOD(EventBuffer, enableLocking)
+{
+	zval               *zbuf = getThis();
+	php_event_buffer_t *b;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	evbuffer_enable_locking(b->buf, NULL);
+}
+/* }}} */
+
+/* {{{ proto bool EventBuffer::add(string data); 
+ *
+ * Append data to the end of an event buffer.
+ */
+PHP_METHOD(EventBuffer, add)
+{
+	php_event_buffer_t  *b;
+	zval                *zbuf    = getThis();
+	zval               **ppzdata;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z",
+				&ppzdata) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	convert_to_string_ex(ppzdata);
+
+	if (evbuffer_add(b->buf, (void *) Z_STRVAL_PP(ppzdata), Z_STRLEN_PP(ppzdata))) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventBuffer::addBuffer(EventBuffer outbuf, EventBuffer inbuf); 
+ * Move all data from one evbuffer into another evbuffer.
+ * This is a destructive add. The data from one buffer moves into the other buffer. However, no unnecessary memory copies occur.
+ */
+PHP_METHOD(EventBuffer, add_buffer)
+{
+	php_event_buffer_t *b_out     , *b_in;
+	zval               *zbuf_out  , *zbuf_in;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OO",
+				&zbuf_out, php_event_buffer_ce,
+				&zbuf_in, php_event_buffer_ce) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b_out, zbuf_out);
+	PHP_EVENT_FETCH_BUFFER(b_in, zbuf_in);
+
+	if (evbuffer_add_buffer(b_out->buf, b_in->buf)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int EventBuffer::remove(string &data, long max_bytes);
+ *
+ * Read data from an evbuffer and drain the bytes read.  If more bytes are
+ * requested than are available in the evbuffer, we only extract as many bytes
+ * as were available.
+ *
+ * Returns the number of bytes read, or -1 if we can't drain the buffer.
+ */
+PHP_METHOD(EventBuffer, remove)
+{
+	php_event_buffer_t *b;
+	zval               *zbuf      = getThis();
+	zval               *zdata;
+	long                max_bytes;
+	long                ret;
+	char               *data;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl",
+				&zdata, &max_bytes) == FAILURE) {
+		return;
+	}
+
+	if (!Z_ISREF_P(zdata)) {
+		/* Was not passed by reference */
+		return;
+	}
+
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	data = emalloc(sizeof(char) * max_bytes + 1);
+
+	ret = evbuffer_remove(b->buf, data, max_bytes);
+
+	if (ret > 0) {
+		convert_to_string(zdata);
+		zval_dtor(zdata);
+		Z_STRVAL_P(zdata) = estrndup(data, ret);
+		Z_STRLEN_P(zdata) = ret;
+	}
+
+	efree(data);
+
+	RETVAL_LONG(ret);
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 sts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4 sts=4
+ */
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 1997-2013 The PHP Group                                |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license@php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Author: Ruslan Osmanov <osmanov@php.net>                             |
+   +----------------------------------------------------------------------+
+*/
+#include "common.h"
+#include "util.h"
+#include "priv.h"
+
+/* {{{ Private */
+
+/* {{{ bevent_rw_cb
+ * Is called from the bufferevent read and write callbacks */
+static zend_always_inline void bevent_rw_cb(struct bufferevent *bevent, php_event_bevent_t *bev, zend_fcall_info *pfci, zend_fcall_info_cache *pfcc)
+{
+	PHP_EVENT_ASSERT(bev);
+	PHP_EVENT_ASSERT(pfci && pfcc);
+
+	zval  *arg_data   = bev->data;
+	zval  *arg_bevent;
+	zval **args[2];
+	zval  *retval_ptr;
+
+	TSRMLS_FETCH_FROM_CTX(bev->thread_ctx);
+
+	if (ZEND_FCI_INITIALIZED(*pfci)) {
+		/* Setup callback args */
+		MAKE_STD_ZVAL(arg_bevent);
+
+		PHP_EVENT_ASSERT(bev->self);
+
+		if (bev->self) {
+			ZVAL_ZVAL(arg_bevent, bev->self, 0, 0);
+			Z_ADDREF_P(bev->self);
+		} else {
+			ZVAL_NULL(arg_bevent);
+		}
+		args[0] = &arg_bevent;
+
+		if (arg_data) {
+			Z_ADDREF_P(arg_data);
+		} else {
+			ALLOC_INIT_ZVAL(arg_data);
+		}
+		args[1] = &arg_data;
+
+		/* Prepare callback */
+		pfci->params		 = args;
+		pfci->retval_ptr_ptr = &retval_ptr;
+		pfci->param_count	 = 2;
+		pfci->no_separation  = 1;
+
+        if (zend_call_function(pfci, pfcc TSRMLS_CC) == SUCCESS
+                && retval_ptr) {
+            zval_ptr_dtor(&retval_ptr);
+        } else {
+            php_error_docref(NULL TSRMLS_CC, E_WARNING,
+                    "An error occurred while invoking the callback");
+        }
+
+        zval_ptr_dtor(&arg_bevent);
+        zval_ptr_dtor(&arg_data);
+	}
+}
+/* }}} */
+
+/* {{{ bevent_read_cb */
+static void bevent_read_cb(struct bufferevent *bevent, void *ptr)
+{
+	php_event_bevent_t *bev = (php_event_bevent_t *) ptr;
+
+	bevent_rw_cb(bevent, bev, bev->fci_read, bev->fcc_read);
+}
+/* }}} */
+
+/* {{{ bevent_write_cb */
+static void bevent_write_cb(struct bufferevent *bevent, void *ptr)
+{
+	php_event_bevent_t *bev = (php_event_bevent_t *) ptr;
+
+	bevent_rw_cb(bevent, bev, bev->fci_write, bev->fcc_write);
+}
+/* }}} */
+
+/* {{{ bevent_event_cb */
+static void bevent_event_cb(struct bufferevent *bevent, short events, void *ptr)
+{
+	php_event_bevent_t    *bev  = (php_event_bevent_t *) ptr;
+	zend_fcall_info       *pfci = bev->fci_event;
+	zend_fcall_info_cache *pfcc = bev->fcc_event;
+
+	PHP_EVENT_ASSERT(pfci && pfcc);
+
+	zval  *arg_data   = bev->data;
+	zval  *arg_bevent;
+	zval  *arg_events;
+	zval **args[3];
+	zval  *retval_ptr;
+
+	TSRMLS_FETCH_FROM_CTX(bev->thread_ctx);
+
+	if (ZEND_FCI_INITIALIZED(*pfci)) {
+		/* Setup callback args */
+		MAKE_STD_ZVAL(arg_bevent);
+
+		PHP_EVENT_ASSERT(bev->self);
+
+		if (bev->self) {
+			ZVAL_ZVAL(arg_bevent, bev->self, 0, 0);
+			Z_ADDREF_P(bev->self);
+		} else {
+			ZVAL_NULL(arg_bevent);
+		}
+		args[0] = &arg_bevent;
+
+		MAKE_STD_ZVAL(arg_events);
+		ZVAL_LONG(arg_events, events);
+		args[1] = &arg_events;
+
+		if (arg_data) {
+			Z_ADDREF_P(arg_data);
+		} else {
+			ALLOC_INIT_ZVAL(arg_data);
+		}
+		args[2] = &arg_data;
+
+		/* Prepare callback */
+		pfci->params		 = args;
+		pfci->retval_ptr_ptr = &retval_ptr;
+		pfci->param_count	 = 3;
+		pfci->no_separation  = 1;
+
+        if (zend_call_function(pfci, pfcc TSRMLS_CC) == SUCCESS
+                && retval_ptr) {
+            zval_ptr_dtor(&retval_ptr);
+        } else {
+            php_error_docref(NULL TSRMLS_CC, E_WARNING,
+                    "An error occurred while invoking the callback");
+        }
+
+        zval_ptr_dtor(&arg_bevent);
+        zval_ptr_dtor(&arg_events);
+        zval_ptr_dtor(&arg_data);
+	}
+}
+/* }}} */
+
+/* Private }}} */
+
+
+/* {{{ proto EventBufferEvent EventBufferEvent::__construct(EventBase base[, mixed socket = NULL[, int options = 0]]);
+ *
+ * Create a socket-based buffer event.
+ * options is one of EVENT_BEV_OPT_* constants, or 0.
+ * Passing NULL to socket parameter means that the socket stream should be created later,
+ * e.g. by means of bufferevent_socket_connect().
+ *
+ * socket parameter may be created as a stream(not necessarily by means of sockets extension)
+ *
+ * Returns buffer event resource optionally associated with socket resource. */
+PHP_METHOD(EventBufferEvent, __construct)
+{
+	zval                *zself   = getThis();
+	zval                *zbase;
+	php_event_base_t    *base;
+	zval               **ppzfd   = NULL;
+	evutil_socket_t      fd;
+	long                 options = 0;
+	php_event_bevent_t  *bev;
+	struct bufferevent  *bevent;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|Z!l",
+				&zbase, php_event_base_ce, &ppzfd, &options) == FAILURE) {
+		return;
+	}
+
+	if (ppzfd) {
+#ifdef PHP_EVENT_SOCKETS_SUPPORT 
+		if (ppzfd) {
+			/* php_event_zval_to_fd reports error
+	 	 	 * in case if it is not a valid socket resource */
+			/*fd = (evutil_socket_t) php_event_zval_to_fd(ppzfd TSRMLS_CC);*/
+			fd = php_event_zval_to_fd(ppzfd TSRMLS_CC);
+
+		}
+
+		if (fd < 0) {
+			RETURN_FALSE;
+		}
+		/* Make sure that the socket is in non-blocking mode(libevent's tip) */
+		evutil_make_socket_nonblocking(fd);
+#else
+		fd = -1;
+#endif
+	} else {
+ 		/* User decided to assign fd later,
+ 		 * e.g. by means of bufferevent_socket_connect()
+ 		 * which allocates new socket stream in this case. */
+		fd = -1;
+	}
+
+	PHP_EVENT_FETCH_BASE(base, zbase);
+
+	PHP_EVENT_FETCH_BEVENT(bev, zself);
+
+	bevent = bufferevent_socket_new(base->base, fd, options);
+	if (bevent == NULL) {
+		php_error_docref(NULL TSRMLS_CC, E_ERROR,
+				"Failed to allocate bufferevent for socket");
+		return;
+	}
+
+	bev->bevent = bevent;
+
+	if (ppzfd) {
+		/* lval of ppzfd is the resource ID */
+		bev->stream_id = Z_LVAL_PP(ppzfd);
+		zend_list_addref(Z_LVAL_PP(ppzfd));
+	} else {
+		/* Should be assigned in bufferevent_socket_connect() later
+		 * (by means of bufferevent_getfd()) */
+		bev->stream_id = -1;
+	}
+
+	bev->self = zself;
+	Z_ADDREF_P(zself);
+
+	/* Make sure base destroyed after the bufferevent
+	 * XXX Really need this? */
+	Z_ADDREF_P(zbase);
+}
+/* }}} */
+
+/* {{{ proto array EventBufferEvent::createPair(EventBase base[, int options = 0]);
+ *
+ * options is one of EVENT_BEV_OPT_* constants, or 0.
+ *
+ * Returns array of two EventBufferEvent objects connected to each other.
+ * All the usual options are supported, except for EVENT_BEV_OPT_CLOSE_ON_FREE,
+ * which has no effect, and EVENT_BEV_OPT_DEFER_CALLBACKS, which is always on.
+ */
+PHP_METHOD(EventBufferEvent, createPair)
+{
+	zval               *zbase;
+	php_event_base_t   *base;
+	long                options        = 0;
+	zval               *zbev[2];
+	php_event_bevent_t *b[2];
+	struct bufferevent *bevent_pair[2];
+	int                 i;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|l",
+				&zbase, php_event_base_ce, &options) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BASE(base, zbase);
+
+	if (bufferevent_pair_new(base->base, options, bevent_pair)) {
+		RETURN_FALSE;
+	}
+
+	array_init(return_value);
+
+	for (i = 0; i < 2; i++) {
+		MAKE_STD_ZVAL(zbev[i]);
+		PHP_EVENT_INIT_CLASS_OBJECT(zbev[i], php_event_bevent_ce);
+		PHP_EVENT_FETCH_BEVENT(b[i], zbev[i]);
+
+		b[i]->bevent    = bevent_pair[i];
+		b[i]->stream_id = -1;
+
+		add_next_index_zval(return_value, zbev[i]);
+	}
+}
+/* }}} */
+
+/* {{{ proto bool EventBufferEvent::connect(string addr[, bool sync_resolve = FALSE]);
+ *
+ * Connect buffer event's socket to given address(optionally with port).  The
+ * function available since libevent 2.0.2-alpha.
+ *
+ * This function doesn't require sockets support. If socket is not assigned to
+ * the bufferevent, this function allocates a socket stream and makes it
+ * non-blocking internally.
+ *
+ * If sync_resolve parameter is TRUE, the function tries to resolve the
+ * hostname within addr *syncronously*(!).  Otherwise addr parameter expected
+ * to be an IP address with optional port number. Recognized formats are:
+ *
+ *    [IPv6Address]:port
+ *    [IPv6Address]
+ *    IPv6Address
+ *    IPv4Address:port
+ *    IPv4Address
+ * 
+ * To resolve DNS names asyncronously, use
+ * bufferevent_socket_connect_hostname() function.
+ */
+PHP_METHOD(EventBufferEvent, connect)
+{
+	php_event_bevent_t *bev;
+	zval               *zbevent      = getThis();
+	char               *addr;
+	int                 addr_len;
+	struct sockaddr     sa;
+	socklen_t           sa_len       = sizeof(struct sockaddr);
+	zend_bool           sync_resolve = 0;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b",
+				&addr, &addr_len, &sync_resolve) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	if (sync_resolve) {
+		/* The PHP API *syncronously* resolves hostname, if it doesn't look
+		 * like IP(v4/v6) */
+		if (php_network_parse_network_address_with_port(addr, addr_len, &sa, &sa_len TSRMLS_CC) != SUCCESS) {
+			/* The function reports errors, if necessary */
+			RETURN_FALSE;
+		}
+	} else {
+		/* Numeric addresses only. Don't try to resolve hostname. */
+		if (evutil_parse_sockaddr_port(addr, &sa, (int *) &sa_len)) {
+			php_error_docref(NULL TSRMLS_CC, E_ERROR,
+					"Failed parsing address: the address is not well-formed, "
+					"or the port is out of range");
+			RETURN_FALSE;
+		}
+	}
+
+	/* bufferevent_socket_connect() allocates a socket stream internally, if we
+	 * didn't provide the file descriptor to the bufferevent before, e.g. with
+	 * bufferevent_socket_new() */
+	if (bufferevent_socket_connect(bev->bevent, &sa, sa_len)) {
+		RETURN_FALSE;
+	}
+
+	bev->stream_id = bufferevent_getfd(bev->bevent);
+
+	PHP_EVENT_ASSERT(bev->stream_id >= 0);
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventBufferEvent::connectHost(resource dns_base, string hostname, int port[, int family = EVENT_AF_UNSPEC]);
+ *
+ * Resolves the DNS name hostname, looking for addresses of type
+ * family(EVENT_AF_* constants). If the name resolution fails, it invokes the
+ * event callback with an error event. If it succeeds, it launches a connection
+ * attempt just as bufferevent_socket_connect would.
+ *
+ * dns_base is optional. May be NULL, or a resource created with
+ * event_dns_base_new()(requires --with-event-extra configure option).
+ * For asyncronous hostname resolving pass a valid event dns base resource.
+ * Otherwise the hostname resolving will block.
+ * Recognized hostname formats are:
+ * www.example.com (hostname) 1.2.3.4 (ipv4address) ::1 (ipv6address) [::1] ([ipv6address])
+ */
+PHP_METHOD(EventBufferEvent, connectHost)
+{
+#if LIBEVENT_VERSION_NUMBER < 0x02000300
+	PHP_EVENT_LIBEVENT_VERSION_REQUIRED(bufferevent_socket_connect_hostname, 2.0.3-alpha);
+	RETVAL_FALSE;
+#else
+	php_event_bevent_t *bev;
+	zval               *zbevent      = getThis();
+	zval               *zdns_base    = NULL;
+	char               *hostname;
+	int                 hostname_len;
+	long                port;
+	long                family;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O!sl|l",
+				&zdns_base, php_event_dns_base_ce, &hostname, &hostname_len,
+				&port, &family) == FAILURE) {
+		return;
+	}
+	
+	if (family & ~(AF_INET | AF_INET6 | AF_UNSPEC)) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING,
+				"Invalid address family specified");
+		RETURN_FALSE;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	/* bufferevent_socket_connect() allocates a socket stream internally, if we
+	 * didn't provide the file descriptor to the bufferevent before, e.g. with
+	 * bufferevent_socket_new() */
+
+#if HAVE_EVENT_EXTRA_LIB
+	php_event_dns_base_t *dnsb;
+
+	if (zdns_base) {
+		PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+	}
+
+	if (bufferevent_socket_connect_hostname(bev->bevent,
+				(zdns_base ? dnsb->dns_base : NULL),
+				family, hostname, port)) {
+# ifdef PHP_EVENT_DEBUG
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
+				evutil_gai_strerror(bufferevent_socket_get_dns_error(bev->bevent)));
+# endif
+		RETURN_FALSE;
+	}
+#else /* don't HAVE_EVENT_EXTRA_LIB */
+	if (bufferevent_socket_connect_hostname(bev->bevent,
+				NULL,
+				family, hostname, port)) {
+# ifdef PHP_EVENT_DEBUG
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
+				evutil_gai_strerror(bufferevent_socket_get_dns_error(bev->bevent)));
+# endif
+		RETURN_FALSE;
+	}
+#endif
+
+	bev->stream_id = bufferevent_getfd(bev->bevent);
+
+	/*
+	It may not work with evdns
+	if (bev->stream_id < 0) {
+		RETURN_FALSE;
+	}
+	 PHP_EVENT_ASSERT(bev->stream_id >= 0);
+	*/
+
+	RETVAL_TRUE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto string EventBufferEvent::getDnsErrorString(void);
+ * Returns string describing the last failed DNS lookup attempt made by
+ * bufferevent_socket_connect_hostname(), or an empty string, if no DNS error
+ * detected. */
+PHP_METHOD(EventBufferEvent, getDnsErrorString)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	int                 err;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	err = bufferevent_socket_get_dns_error(bev->bevent);
+
+	if (err == 0) {
+		RETURN_EMPTY_STRING();
+	}
+	RETVAL_STRING(evutil_gai_strerror(err), 1);
+}
+/* }}} */
+
+/* {{{ proto void EventBufferEvent::setCallbacks(callable readcb, callable writecb, callable eventcb[, mixed arg = NULL]);
+ * Changes one or more of the callbacks of a bufferevent.
+ * A callback may be disabled by passing NULL instead of the callable.
+ * arg is an argument passed to the callbacks.
+ */
+PHP_METHOD(EventBufferEvent, setCallbacks)
+{
+	zval                  *zbevent   = getThis();
+	php_event_bevent_t    *bev;
+	zend_fcall_info        fci_read;
+	zend_fcall_info_cache  fcc_read;
+	zend_fcall_info        fci_write;
+	zend_fcall_info_cache  fcc_write;
+	zend_fcall_info        fci_event;
+	zend_fcall_info_cache  fcc_event;
+	zval                  *zarg      = NULL;
+	bufferevent_data_cb    read_cb;
+	bufferevent_data_cb    write_cb;
+	bufferevent_event_cb   event_cb;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f!f!f!|z!",
+				&fci_read, &fcc_read,
+				&fci_write, &fcc_write,
+				&fci_event, &fcc_event,
+				&zarg) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	if (ZEND_FCI_INITIALIZED(fci_read)) {
+		read_cb = bevent_read_cb;
+		PHP_EVENT_FREE_FCALL_INFO(bev->fci_read, bev->fcc_read);
+		PHP_EVENT_COPY_FCALL_INFO(bev->fci_read, bev->fcc_read, &fci_read, &fcc_read);
+	} else {
+		read_cb = NULL;
+	}
+
+	if (ZEND_FCI_INITIALIZED(fci_write)) {
+		write_cb = bevent_write_cb;
+		PHP_EVENT_FREE_FCALL_INFO(bev->fci_write, bev->fcc_write);
+		PHP_EVENT_COPY_FCALL_INFO(bev->fci_write, bev->fcc_write, &fci_write, &fcc_write);
+	} else {
+		write_cb = NULL;
+	}
+
+	if (ZEND_FCI_INITIALIZED(fci_event)) {
+		event_cb = bevent_event_cb;
+		PHP_EVENT_FREE_FCALL_INFO(bev->fci_event, bev->fcc_event);
+		PHP_EVENT_COPY_FCALL_INFO(bev->fci_event, bev->fcc_event, &fci_event, &fcc_event);
+	} else {
+		event_cb = NULL;
+	}
+
+	if (zarg) {
+		Z_ADDREF_P(zarg);
+		bev->data = zarg;
+	}
+
+	TSRMLS_SET_CTX(bev->thread_ctx);
+
+	bufferevent_setcb(bev->bevent, read_cb, write_cb, event_cb, (void *) bev);
+}
+/* }}} */
+
+/* {{{ proto void EventBufferEvent::enable(int events);
+ * Enable events EVENT_READ, EVENT_WRITE, or EVENT_READ | EVENT_WRITE on a buffer event. */
+PHP_METHOD(EventBufferEvent, enable)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	long                events;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
+				&events) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	bufferevent_enable(bev->bevent, events);
+}
+/* }}} */
+
+/* {{{ proto void EventBufferEvent::disable(int events);
+ * Disable events EVENT_READ, EVENT_WRITE, or EVENT_READ | EVENT_WRITE on a buffer event. */
+PHP_METHOD(EventBufferEvent,disable)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	long                events;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
+				&events) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	bufferevent_disable(bev->bevent, events);
+}
+/* }}} */
+
+/* {{{ proto int EventBufferEvent::getEnabled(void);
+ * Returns bitmask of events currently enabled on the buffer event. */
+PHP_METHOD(EventBufferEvent,get_enabled)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	RETVAL_LONG(bufferevent_get_enabled(bev->bevent));
+}
+/* }}} */
+
+/* {{{ proto EventBuffer EventBufferEvent::getInput(void);
+ * Returns an input EventBuffer object associated with the buffer event */
+PHP_METHOD(EventBufferEvent, getInput)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	php_event_buffer_t *b;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	PHP_EVENT_INIT_CLASS_OBJECT(return_value, php_event_buffer_ce);
+
+
+	PHP_EVENT_FETCH_BUFFER(b, return_value);
+
+	b->buf = bufferevent_get_input(bev->bevent);
+}
+/* }}} */
+
+/* {{{ proto EventBuffer EventBufferEvent::getOutput(void);
+ * Returns an output EventBuffer object associated with the buffer event */
+PHP_METHOD(EventBufferEvent, getOutput)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	php_event_buffer_t *b;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	PHP_EVENT_INIT_CLASS_OBJECT(return_value, php_event_buffer_ce);
+	PHP_EVENT_FETCH_BUFFER(b, return_value);
+
+	b->buf = bufferevent_get_output(bev->bevent);
+}
+/* }}} */
+
+/* {{{ proto void EventBufferEvent::setWatermark(int events, int lowmark, int highmark);
+ * Adjusts the read watermarks, the write watermarks, or both, of a single bufferevent. */
+PHP_METHOD(EventBufferEvent,setwatermark)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	long                events;
+	long                lowmark;
+	long                highmark;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
+				&events, &lowmark, &highmark) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	bufferevent_setwatermark(bev->bevent, events, (size_t) lowmark, (size_t) highmark);
+}
+/* }}} */
+
+/* {{{ proto bool EventBufferEvent::write(string data);
+ * Adds `data' to a buffe revent's output buffer. */
+PHP_METHOD(EventBufferEvent, write)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	zval               *zdata;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z",
+				&zdata) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	convert_to_string(zdata);
+
+	if (bufferevent_write(bev->bevent, Z_STRVAL_P(zdata), Z_STRLEN_P(zdata))) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventBufferEvent::writeBuffer(EventBuffer buf);
+ * Adds contents of the entire buffer to a buffer event's output buffer. */
+PHP_METHOD(EventBufferEvent,write_buffer)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	php_event_buffer_t *b;
+	zval               *zbuf;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O",
+				&zbuf, php_event_buffer_ce) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	if (bufferevent_write_buffer(bev->bevent, b->buf)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int EventBufferEvent::read(string &data, int size);
+ * Removes up to size bytes from the input buffer, storing them into the memory at data.
+ *
+ * Returns the number of bytes actually removed.  */
+PHP_METHOD(EventBufferEvent, read)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	zval               *zdata;
+	long                size;
+	char               *data;
+	long                ret;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl",
+				&zdata, &size) == FAILURE) {
+		return;
+	}
+
+	if (!Z_ISREF_P(zdata)) {
+		/* Was not passed by reference */
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	data = safe_emalloc(size, sizeof(char), 1);
+
+	ret = bufferevent_read(bev->bevent, data, size);
+
+	if (ret > 0) {
+		convert_to_string(zdata);
+		zval_dtor(zdata);
+		Z_STRVAL_P(zdata) = estrndup(data, ret);
+		Z_STRLEN_P(zdata) = ret;
+	}
+
+	efree(data);
+
+	RETVAL_LONG(ret);
+}
+/* }}} */
+
+/* {{{ proto bool EventBufferEvent::readBuffer(EventBuffer buf);
+ * Drains the entire contents of the input buffer and places them into buf; it returns 0 on success and -1 on failure. */
+PHP_METHOD(EventBufferEvent, readBuffer)
+{
+	zval               *zbevent = getThis();
+	php_event_bevent_t *bev;
+	php_event_buffer_t *b;
+	zval               *zbuf;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O",
+				&zbuf, php_event_buffer_ce) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+	PHP_EVENT_FETCH_BUFFER(b, zbuf);
+
+	if (bufferevent_read_buffer(bev->bevent, b->buf)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventBufferEvent::setPriority(int priority);
+ * XXX make a property?
+ * Assign a priority to a bufferevent.
+ * Only supported for socket bufferevents. */
+PHP_METHOD(EventBufferEvent, setPriority)
+{
+	zval               *zbevent  = getThis();
+	php_event_bevent_t *bev;
+	long                priority;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
+				&priority) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	if (bufferevent_priority_set(bev->bevent, priority)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventBufferEvent::setTimeouts(double timeout_read, double timeout_write);
+ * Set the read and write timeout for a bufferevent. */
+PHP_METHOD(EventBufferEvent,set_timeouts)
+{
+	zval               *zbevent       = getThis();
+	php_event_bevent_t *bev;
+	double              timeout_read;
+	double              timeout_write;
+	struct timeval      tv_read;
+	struct timeval      tv_write;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
+				&timeout_read, &timeout_write) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	PHP_EVENT_TIMEVAL_SET(tv_read, timeout_read);
+	PHP_EVENT_TIMEVAL_SET(tv_write, timeout_write);
+
+	if (bufferevent_set_timeouts(bev->bevent, &tv_read, &tv_write)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 sts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4 sts=4
+ */
     -L$EVENT_DIR/lib
   ])
   dnl }}}
+  
+  event_src="php_event.c util.c event.c base.c event_config.c buffer_event.c \
+    buffer.c event_util.c"
 
   dnl {{{ --with-event-extra
   if test "$PHP_EVENT_EXTRA" != "no"; then
     ],[
       -L$EVENT_DIR/lib -levent_core
     ])
+
+    event_src="$event_src dns.c listener.c http.c http_connection.c"
   fi
   dnl }}}
+
+  event_src="$event_src fe.c"
  
-  event_src="php_event.c util.c event.c base.c fe.c"
   PHP_NEW_EXTENSION(event, $event_src, $ext_shared,,$CFLAGS)
   PHP_ADD_EXTENSION_DEP(event, sockets, true)
   PHP_SUBST(EVENT_SHARED_LIBADD)
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 1997-2013 The PHP Group                                |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license@php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Author: Ruslan Osmanov <osmanov@php.net>                             |
+   +----------------------------------------------------------------------+
+*/
+#include "common.h"
+#include "util.h"
+#include "priv.h"
+
+/* {{{ proto EventDnsBase EventDnsBase::__construct(EventBase base, bool initialize);
+ *
+ * Returns resource representing event dns base.
+ *
+ * If the initialize argument is true, it tries to configure the DNS base
+ * sensibly given your operating system’s default. Otherwise, it leaves the
+ * event dns base empty, with no nameservers or options configured. In the latter
+ * case you should configure dns base yourself, e.g. with
+ * EventDnsBase::parseResolvConf() */
+PHP_METHOD(EventDnsBase, __construct)
+{
+	php_event_base_t     *base;
+	zval                 *zbase;
+	php_event_dns_base_t *dnsb;
+	zend_bool             initialize;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ob",
+				&zbase, php_event_base_ce, &initialize) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BASE(base, zbase);
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, getThis());
+
+	dnsb->dns_base = evdns_base_new(base->base, initialize);
+}
+/* }}} */
+
+/* {{{ proto bool EventDnsBase::parseResolvConf(int flags, string filename);
+ * Scans the resolv.conf formatted file stored in filename, and read in all the
+ * options from it that are listed in flags */
+PHP_METHOD(EventDnsBase, parseResolvConf)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base = getThis();
+	long                  flags;
+	char                 *filename;
+	int                   filename_len;
+	int                   ret;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls",
+				&flags, &filename, &filename_len) == FAILURE) {
+		return;
+	}
+
+	if (flags & ~(DNS_OPTION_NAMESERVERS | DNS_OPTION_SEARCH | DNS_OPTION_MISC
+				| DNS_OPTIONS_ALL)) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING,
+				"Invalid flags");
+		RETURN_FALSE;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	ret = evdns_base_resolv_conf_parse(dnsb->dns_base, flags, filename);
+
+	if (ret) {
+		char err[40];
+
+		switch (ret) {
+			case 1:
+				strcpy(err, "Failed to open file");
+				break;
+			case 2:
+				strcpy(err, "Failed to stat file");
+				break;
+			case 3:
+				strcpy(err, "File too large");
+				break;
+			case 4:
+				strcpy(err, "Out of memory");
+				break;
+			case 5:
+				strcpy(err, "Short read from file");
+				break;
+			case 6:
+				strcpy(err, "No nameservers listed in the file");
+				break;
+		}
+
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", err);
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventDnsBase::addNameserverIp(string ip);
+ * Adds a nameserver to an existing evdns_base. It takes the nameserver in a
+ * text string, either as an IPv4 address, an IPv6 address, an IPv4 address
+ * with a port (IPv4:Port), or an IPv6 address with a port ([IPv6]:Port).
+ */
+PHP_METHOD(EventDnsBase, addNameserverIp)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base = getThis();
+	char                 *ip;
+	int                   ip_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
+				&ip, &ip_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	if (evdns_base_nameserver_ip_add(dnsb->dns_base, ip)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventDnsBase::loadHosts(string hosts);
+ *  Loads a hosts file (in the same format as /etc/hosts) from hosts file
+ */
+PHP_METHOD(EventDnsBase, loadHosts)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base = getThis();
+	char                 *hosts;
+	int                   hosts_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
+				&hosts, &hosts_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	if (evdns_base_load_hosts(dnsb->dns_base, hosts)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto void EventDnsBase::clearSearch(void);
+ * Removes all current search suffixes (as configured by the search option)
+ * from the evdns_base; the evdns_base_search_add() function adds a suffix
+ */
+PHP_METHOD(EventDnsBase, clearSearch)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base = getThis();
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	evdns_base_search_clear(dnsb->dns_base);
+}
+/* }}} */
+
+/* {{{ proto void EventDnsBase::addSearch(string domain);
+ */
+PHP_METHOD(EventDnsBase, addSearch)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base = getThis();
+	char                 *domain;
+	int                   domain_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
+				&domain, &domain_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	evdns_base_search_add(dnsb->dns_base, domain);
+}
+/* }}} */
+
+/* {{{ proto void EventDnsBase::setSearchNdots(int ndots);
+ */
+PHP_METHOD(EventDnsBase, base_search_ndots_set)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base = getThis();
+	long                  ndots;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
+				&ndots) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	evdns_base_search_ndots_set(dnsb->dns_base, ndots);
+}
+/* }}} */
+
+/* {{{ proto bool EventDnsBase::setOption(string option, string value);
+ */
+PHP_METHOD(EventDnsBase, setOption)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base = getThis();
+	char                 *option;
+	int                   option_len;
+	char                 *value;
+	int                   value_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+				&option, &option_len, &value, &value_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	if (evdns_base_set_option(dnsb->dns_base, option, value)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int EventDnsBase::countNameservers(void);
+ */
+PHP_METHOD(EventDnsBase, base_count_nameservers)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base = getThis();
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	RETURN_LONG(evdns_base_count_nameservers(dnsb->dns_base));
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 sts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4 sts=4
+ */
 #include "util.h"
 #include "priv.h"
 
-extern zend_class_entry *php_event_ce;
-extern zend_class_entry *php_event_base_ce;
-
 /* {{{ Private */
 
 /* {{{ zval_to_signum */
 /* }}} */
 
 
-
-/* {{{ proto Event Event::__construct(EventBase, mixed fd, int what, callable cb[, zval arg = NULL]);
+/* {{{ proto Event Event::__construct(EventBase base, mixed fd, int what, callable cb[, zval arg = NULL]);
  * Creates new event */
 PHP_METHOD(Event, __construct)
 {
 }
 /* }}} */
 
-/* {{{ proto void Event::free();
- * Free an event
- * XXX FALIAS of Event::__destruct? */
-PHP_METHOD(Event, free)
-{
-	zval *self = getThis();
-
-	if (zend_parse_parameters_none() == FAILURE) {
-		return;
-	}
-
-	/* Rely on the free-storage handler */
-	zval_ptr_dtor(&self);
-}
-/* }}} */
-
-/* {{{ proto bool Event::set(Event event, EventBase base, mixed fd,[ int what = NULL[, callable cb = NULL[, zval arg = NULL]]]);
+/* {{{ proto bool Event::set(EventBase base, mixed fd,[ int what = NULL[, callable cb = NULL[, zval arg = NULL]]]);
+ *
  * Re-configures event.
+ *
  * Note, this function doesn't invoke obsolete libevent's event_set. It calls event_assign instead.  */
 PHP_METHOD(Event, set)
 {
 	zval                   *zbase;
 	php_event_base_t       *b;
-	zval                   *zevent;
+	zval                   *zevent  = getThis();
 	php_event_t            *e;
 	zval                  **ppzfd   = NULL;
 	evutil_socket_t         fd;
 	zend_fcall_info_cache   fcc     = empty_fcall_info_cache;
 	zval                   *arg     = NULL;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OOZ!|lfz!",
-				&zevent, php_event_ce, &zbase, php_event_base_ce, &ppzfd,
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OZ!|lfz!",
+				&zbase, php_event_base_ce, &ppzfd,
 				&what, &fci, &fcc, &arg) == FAILURE) {
 		return;
 	}
 
 /* {{{ proto bool Event::del(void);
  * Remove an event from the set of monitored events. */
-PHP_METHOD(Event::del)
+PHP_METHOD(Event, del)
 {
 	zval        *zevent = getThis();
 	php_event_t *e;
 }
 /* }}} */
 
-/* {{{ proto bool Event::reinit(EventBase base);
+/* {{{ proto bool Event::reInit(EventBase base);
  * Re-initialize event base. Should be called after a fork.
  * XXX pthread_atfork() in MINIT */
-PHP_METHOD(Event::reinit)
+PHP_METHOD(Event, reInit)
 {
 	zval             *zbase;
 	php_event_base_t *b;
 }
 /* }}} */
 
-/* {{{ proto bool Event::timerPending(resource event);
+/* {{{ proto bool Event::timerPending(void);
  * Detect whether timer event is pending or scheduled.
  * XXX move to properties */
 PHP_METHOD(Event, timerPending)
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 1997-2013 The PHP Group                                |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license@php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Author: Ruslan Osmanov <osmanov@php.net>                             |
+   +----------------------------------------------------------------------+
+*/
+#include "common.h"
+#include "util.h"
+#include "priv.h"
+
+/* {{{ proto EventConfig::__construct(void);
+ * On success returns a valid resource representing an event configuration
+ * which can be passed to EventBase::__construct. */
+PHP_METHOD(EventConfig, __construct)
+{
+	php_event_config_t *cfg;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_CONFIG(cfg, getThis());
+
+	cfg->ptr = event_config_new();
+}
+/* }}} */
+
+/* {{{ proto bool EventConfig::avoidMethod(EventConfig cfg, string method);
+ * Tells libevent to avoid specific event method.
+ * See http://www.wangafu.net/~nickm/libevent-book/Ref2_eventbase.html#_creating_an_event_base
+ * Returns &true; on success, otherwise &false;.*/
+PHP_METHOD(EventConfig, avoidMethod)
+{
+	zval               *zcfg       = getThis();
+	char               *method;
+	int                 method_len;
+	php_event_config_t *cfg;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
+				&method, &method_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_CONFIG(cfg, zcfg);
+
+	if (event_config_avoid_method(cfg->ptr, method)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool EventConfig::requireFeatures(int feature);
+ * Enters a required event method feature that the application demands. */
+PHP_METHOD(EventConfig, requireFeatures)
+{
+	zval               *zcfg    = getThis();
+	long                feature;
+	php_event_config_t *cfg;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
+				&feature) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_CONFIG(cfg, zcfg);
+
+	if (event_config_require_features(cfg->ptr, feature)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
+}
+/* }}} */
+
+#if LIBEVENT_VERSION_NUMBER >= 0x02010000
+/* {{{ proto void EventConfig:setMaxDispatchInterval(int max_interval, int max_callbacks, int min_priority);
+ * Prevents priority inversion by limiting how many low-priority event
+ * callbacks can be invoked before checking for more high-priority events.
+ * Available since libevent 2.1.0-alpha. */
+PHP_METHOD(EventConfig, setMaxDispatchInterval)
+{
+	zval                  *zcfg          = getThis();
+	php_event_timestamp_t  max_interval;
+	long                   max_callbacks;
+	long                   min_priority;
+	php_event_config_t    *cfg;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dll",
+				&max_interval, &max_callbacks, min_priority) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_CONFIG(cfg, zcfg);
+
+	if (max_interval > 0) {
+		struct timeval tv;
+		PHP_EVENT_TIMEVAL_SET(tv, max_interval);
+
+		event_config_set_max_dispatch_interval(cfg->ptr, &tv, max_callbacks, min_priority);
+	} else {
+		event_config_set_max_dispatch_interval(cfg->ptr, NULL, max_callbacks, min_priority);
+	}
+}
+/* }}} */
+#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 sts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4 sts=4
+ */
+/*
+   +----------------------------------------------------------------------+
+   | PHP Version 5                                                        |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 1997-2013 The PHP Group                                |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 3.01 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available through the world-wide-web at the following url:           |
+   | http://www.php.net/license/3_01.txt                                  |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license@php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Author: Ruslan Osmanov <osmanov@php.net>                             |
+   +----------------------------------------------------------------------+
+*/
+#include "common.h"
+#include "util.h"
+#include "priv.h"
+
+/* {{{ proto int EventUtil::getLastSocketErrno([mixed socket = null]);
+ *
+ * Returns the most recent socket error number(errno). */
+PHP_METHOD(EventUtil, getLastSocketErrno)
+{
+	zval **ppzfd = NULL;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Z!",
+				&ppzfd) == FAILURE) {
+		return;
+	}
+
+	if (ppzfd) {
+		evutil_socket_t fd = (evutil_socket_t) php_event_zval_to_fd(ppzfd TSRMLS_CC);
+
+		if (fd < 0) {
+			RETURN_FALSE;
+		}
+
+		RETVAL_LONG(evutil_socket_geterror(fd));
+	} else {
+		RETVAL_LONG(EVUTIL_SOCKET_ERROR());
+	}
+}
+/* }}} */
+
+/* {{{ proto string EventUtil::getLastSocketError([resource socket = null]);
+ *
+ * Returns the most recent socket error */
+PHP_METHOD(EventUtil, getLastSocketError)
+{
+	zval **ppzfd = NULL;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Z!",
+				&ppzfd) == FAILURE) {
+		return;
+	}
+
+	if (ppzfd) {
+		evutil_socket_t fd = (evutil_socket_t) php_event_zval_to_fd(ppzfd TSRMLS_CC);
+
+		if (fd < 0) {
+			RETURN_FALSE;
+		}
+
+		RETVAL_STRING(evutil_socket_error_to_string(evutil_socket_geterror(fd)), 1);
+	} else {
+		RETVAL_STRING(evutil_socket_error_to_string(EVUTIL_SOCKET_ERROR()), 1);
+	}
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 sts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4 sts=4
+ */
 	ZEND_ARG_INFO(0, config)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base_1, 0, 0, 1)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base__construct, 0, 0, 0)
+	ZEND_ARG_INFO(0, cfg)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base_priority_init, 0, 0, 2)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base_void, 0, 0, 0)
+	ZEND_ARG_INFO(0, cfg)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base_priority_init, 0, 0, 1)
 	ZEND_ARG_INFO(0, n_priorities)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base_loop, 0, 0, 1)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base_loop, 0, 0, 0)
 	ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base_loopexit, 0, 0, 1)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_base_loopexit, 0, 0, 0)
 	ZEND_ARG_INFO(0, timeout)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_1, 0, 0, 1)
-	ZEND_ARG_INFO(0, event)
-ZEND_END_ARG_INFO();
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_new, 0, 0, 4)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event__construct, 0, 0, 4)
 	ZEND_ARG_INFO(0, base)
 	ZEND_ARG_INFO(0, fd)
 	ZEND_ARG_INFO(0, what)
 	ZEND_ARG_INFO(0, arg)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_set, 0, 0, 3)
-	ZEND_ARG_INFO(0, event)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_set, 0, 0, 2)
 	ZEND_ARG_INFO(0, base)
 	ZEND_ARG_INFO(0, fd)
 	ZEND_ARG_INFO(0, what)
 	ZEND_ARG_INFO(0, arg)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_add, 0, 0, 1)
-	ZEND_ARG_INFO(0, event)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_add, 0, 0, 0)
 	ZEND_ARG_INFO(0, timeout)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_config_avoid_method, 0, 0, 2)
-	ZEND_ARG_INFO(0, cfg)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_config_avoid_method, 0, 0, 1)
 	ZEND_ARG_INFO(0, method)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_config_require_features, 0, 0, 2)
-	ZEND_ARG_INFO(0, cfg)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_config_require_features, 0, 0, 1)
 	ZEND_ARG_INFO(0, feature)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_priority_set, 0, 0, 2)
-	ZEND_ARG_INFO(0, event)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_priority_set, 0, 0, 1)
 	ZEND_ARG_INFO(0, priority)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_pending, 0, 0, 2)
-	ZEND_ARG_INFO(0, event)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_pending, 0, 0, 1)
 	ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO();
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_reinit, 0, 0, 1)
+	ZEND_ARG_INFO(0, base)
+ZEND_END_ARG_INFO();
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_evtimer_new, 0, 0, 2)
 	ZEND_ARG_INFO(0, base)
 	ZEND_ARG_INFO(0, cb)
 	ZEND_ARG_INFO(0, arg)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evtimer_set, 0, 0, 3)
-	ZEND_ARG_INFO(0, event)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evtimer_set, 0, 0, 2)
 	ZEND_ARG_INFO(0, base)
 	ZEND_ARG_INFO(0, cb)
 	ZEND_ARG_INFO(0, arg)
 
 
 #if LIBEVENT_VERSION_NUMBER >= 0x02010000
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_config_set_max_dispatch_interval, 0, 0, 4)
-	ZEND_ARG_INFO(0, cfg)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_config_set_max_dispatch_interval, 0, 0, 3)
 	ZEND_ARG_INFO(0, max_interval)
 	ZEND_ARG_INFO(0, max_callbacks)
 	ZEND_ARG_INFO(0, min_priority)
 #endif
 
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_1, 0, 0, 1)
-	ZEND_ARG_INFO(0, bevent)
-ZEND_END_ARG_INFO();
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent__events, 0, 0, 2)
-	ZEND_ARG_INFO(0, bevent)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent__events, 0, 0, 1)
 	ZEND_ARG_INFO(0, events)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_socket_new, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent__construct, 0, 0, 1)
 	ZEND_ARG_INFO(0, base)
 	ZEND_ARG_INFO(0, fd)
 	ZEND_ARG_INFO(0, options)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_socket_connect, 0, 0, 2)
-	ZEND_ARG_INFO(0, bevent)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_connect, 0, 0, 2)
 	ZEND_ARG_INFO(0, addr)
+	ZEND_ARG_INFO(0, sync_resolve)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_socket_connect_hostname, 0, 0, 4)
-	ZEND_ARG_INFO(0, bevent)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_socket_connect_hostname, 0, 0, 3)
 	ZEND_ARG_INFO(0, dns_base)
 	ZEND_ARG_INFO(0, hostname)
 	ZEND_ARG_INFO(0, port)
 	ZEND_ARG_INFO(0, family)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_set_callbacks, 0, 0, 4)
-	ZEND_ARG_INFO(0, bevent)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_set_callbacks, 0, 0, 3)
 	ZEND_ARG_INFO(0, readcb)
 	ZEND_ARG_INFO(0, writecb)
 	ZEND_ARG_INFO(0, eventcb)
 	ZEND_ARG_INFO(0, arg)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_setwatermark, 0, 0, 4)
-	ZEND_ARG_INFO(0, bevent)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_setwatermark, 0, 0, 3)
 	ZEND_ARG_INFO(0, events)
 	ZEND_ARG_INFO(0, lowmark)
 	ZEND_ARG_INFO(0, highmark)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_write, 0, 0, 2)
-	ZEND_ARG_INFO(0, bevent)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_write, 0, 0, 1)
 	ZEND_ARG_INFO(0, data)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_write_buffer, 0, 0, 2)
-	ZEND_ARG_INFO(0, bevent)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_write_buffer, 0, 0, 1)
 	ZEND_ARG_INFO(0, buf)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_read, 0, 0, 3)
-	ZEND_ARG_INFO(0, bevent)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_read, 0, 0, 2)
 	ZEND_ARG_INFO(1, data)
 	ZEND_ARG_INFO(0, size)
 ZEND_END_ARG_INFO();
 	ZEND_ARG_INFO(0, events)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_priority_set, 0, 0, 2)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_priority_set, 0, 0, 1)
 	ZEND_ARG_INFO(0, priority)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_set_timeouts, 0, 0, 3)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_set_timeouts, 0, 0, 2)
 	ZEND_ARG_INFO(0, timeout_read)
 	ZEND_ARG_INFO(0, timeout_write)
 ZEND_END_ARG_INFO();
 
 
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evbuffer_1, 0, 0, 1)
-	ZEND_ARG_INFO(0, buf)
-ZEND_END_ARG_INFO();
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evbuffer_freeze, 0, 0, 2)
-	ZEND_ARG_INFO(0, buf)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evbuffer_freeze, 0, 0, 1)
 	ZEND_ARG_INFO(0, at_front)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evbuffer_add, 0, 0, 2)
-	ZEND_ARG_INFO(0, buf)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evbuffer_add, 0, 0, 1)
 	ZEND_ARG_INFO(0, data) 
 ZEND_END_ARG_INFO();
 
 	ZEND_ARG_INFO(0, inbuf) 
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evbuffer_remove, 0, 0, 3)
-	ZEND_ARG_INFO(0, buf)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evbuffer_remove, 0, 0, 2)
 	ZEND_ARG_INFO(1, data)
 	ZEND_ARG_INFO(0, max_bytes)
 ZEND_END_ARG_INFO();
 
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_socket_1, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_socket_1, 0, 0, 0)
 	ZEND_ARG_INFO(0, socket)
 ZEND_END_ARG_INFO();
 
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_base_new, 0, 0, 4)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection__construct, 0, 0, 4)
 	ZEND_ARG_INFO(0, base)
 	ZEND_ARG_INFO(0, dns_base)
 	ZEND_ARG_INFO(0, address)
 	ZEND_ARG_INFO(0, port)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_1, 0, 0, 1)
-	ZEND_ARG_INFO(0, evcon)
-ZEND_END_ARG_INFO();
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_get_peer, 0, 0, 3)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_get_peer, 0, 0, 2)
 	ZEND_ARG_INFO(1, address)
 	ZEND_ARG_INFO(1, port)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_local_address, 0, 0, 2)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_local_address, 0, 0, 1)
 	ZEND_ARG_INFO(0, address)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_local_port, 0, 0, 2)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_local_port, 0, 0, 1)
 	ZEND_ARG_INFO(0, port)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_timeout, 0, 0, 2)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_timeout, 0, 0, 1)
 	ZEND_ARG_INFO(0, timeout)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_max_size, 0, 0, 2)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_max_size, 0, 0, 1)
 	ZEND_ARG_INFO(0, max_size)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_retries, 0, 0, 2)
-	ZEND_ARG_INFO(0, base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_connection_set_retries, 0, 0, 1)
 	ZEND_ARG_INFO(0, retries)
 ZEND_END_ARG_INFO();
 
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_1, 0, 0, 1)
-	ZEND_ARG_INFO(0, evhttp)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_http__construct, 0, 0, 1)
+	ZEND_ARG_INFO(0, base)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_accept_socket, 0, 0, 2)
-	ZEND_ARG_INFO(0, evhttp)
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_http_accept, 0, 0, 1)
 	ZEND_ARG_INFO(0, socket)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_evhttp_bind_socket, 0, 0, 3)
-	ZEND_ARG_INFO(0, evhttp)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_http_bind, 0, 0, 2)
 	ZEND_ARG_INFO(0, address)
 	ZEND_ARG_INFO(0, port)
 ZEND_END_ARG_INFO();
 #if HAVE_EVENT_EXTRA_LIB
 /* {{{ ARGINFO for extra API */
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_1, 0, 0, 1)
-	ZEND_ARG_INFO(0, dns_base)
-ZEND_END_ARG_INFO();
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_new, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns__construct, 0, 0, 2)
 	ZEND_ARG_INFO(0, base)
 	ZEND_ARG_INFO(0, initialize)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_resolv_conf_parse, 0, 0, 3)
-	ZEND_ARG_INFO(0, dns_base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_resolv_conf_parse, 0, 0, 2)
 	ZEND_ARG_INFO(0, flags)
 	ZEND_ARG_INFO(0, filename)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_nameserver_ip_add, 0, 0, 2)
-	ZEND_ARG_INFO(0, dns_base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_nameserver_ip_add, 0, 0, 1)
 	ZEND_ARG_INFO(0, ip)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_load_hosts, 0, 0, 2)
-	ZEND_ARG_INFO(0, dns_base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_load_hosts, 0, 0, 1)
 	ZEND_ARG_INFO(0, hosts)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_search_add, 0, 0, 2)
-	ZEND_ARG_INFO(0, dns_base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_search_add, 0, 0, 1)
 	ZEND_ARG_INFO(0, domain)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_search_ndots_set, 0, 0, 2)
-	ZEND_ARG_INFO(0, dns_base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_search_ndots_set, 0, 0, 1)
 	ZEND_ARG_INFO(0, ndots)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_set_option, 0, 0, 3)
-	ZEND_ARG_INFO(0, dns_base)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_set_option, 0, 0, 2)
 	ZEND_ARG_INFO(0, option)
 	ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO();
 
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener_1, 0, 0, 1)
-	ZEND_ARG_INFO(0, listener)
-ZEND_END_ARG_INFO();
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener_new, 0, 0, 5)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener__construct, 0, 0, 5)
 	ZEND_ARG_INFO(0, base)
 	ZEND_ARG_INFO(0, cb)
 	ZEND_ARG_INFO(0, data)
 	ZEND_ARG_INFO(0, port)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener_set_cb, 0, 0, 2)
-	ZEND_ARG_INFO(0, listener)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener_set_cb, 0, 0, 1)
 	ZEND_ARG_INFO(0, cb)
 	ZEND_ARG_INFO(0, arg)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener_set_error_cb, 0, 0, 2)
-	ZEND_ARG_INFO(0, listener)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener_set_error_cb, 0, 0, 1)
 	ZEND_ARG_INFO(0, cb)
 ZEND_END_ARG_INFO();
 
 #endif
 
 
-/* {{{ event_functions[] */
-const zend_function_entry event_functions[] = {
-	PHP_FE(event_new,                   arginfo_event_new)
-	PHP_FE(event_free,                  arginfo_event_1)
-	PHP_FE(event_set,                   arginfo_event_set)
-	PHP_FE(event_add,                   arginfo_event_add)
-	PHP_FE(event_del,                   arginfo_event_1)
-	PHP_FE(event_priority_set,          arginfo_event_priority_set)
-	PHP_FE(event_pending,               arginfo_event_pending)
-	PHP_FE(event_reinit,                arginfo_event_base_1)
-	PHP_FE(event_get_supported_methods, arginfo_event__void)
+const zend_function_entry php_event_ce_functions[] = {/* {{{ */
+	PHP_ME(Event, __construct,         arginfo_event__construct,   ZEND_ACC_PUBLIC  | ZEND_ACC_CTOR)
+	PHP_ME(Event, set,                 arginfo_event_set,          ZEND_ACC_PUBLIC)
+	PHP_ME(Event, getSupportedMethods, arginfo_event__void,        ZEND_ACC_PUBLIC  | ZEND_ACC_STATIC)
+	PHP_ME(Event, add,                 arginfo_event_add,          ZEND_ACC_PUBLIC)
+	PHP_ME(Event, del,                 arginfo_event__void,        ZEND_ACC_PUBLIC)
+	PHP_ME(Event, setPriority,         arginfo_event_priority_set, ZEND_ACC_PUBLIC)
+	PHP_ME(Event, pending,             arginfo_event_pending,      ZEND_ACC_PUBLIC)
+	PHP_ME(Event, reInit,              arginfo_event_reinit,       ZEND_ACC_PUBLIC)
 #if LIBEVENT_VERSION_NUMBER >= 0x02010200
-	PHP_FE(event_remove_timer, arginfo_event_1)
+	PHP_ME(Event, removeTimer, arginfo_event__void, ZEND_ACC_PUBLIC)
 #endif
 
-	PHP_FE(evtimer_new,     arginfo_evtimer_new)
-	PHP_FE(evtimer_set,     arginfo_evtimer_set)
-	PHP_FE(evtimer_pending, arginfo_event_1)
-
-	PHP_FALIAS(evtimer_add, event_add, arginfo_event_add)
-	PHP_FALIAS(evtimer_del, event_del, arginfo_event_1)
-
-	PHP_FE(evsignal_new,     arginfo_evsignal_new)
-
-	PHP_FALIAS(evsignal_add,     event_add,     arginfo_event_add)
-	PHP_FALIAS(evsignal_del,     event_del,     arginfo_event_1)
-	PHP_FALIAS(evsignal_pending, event_pending, arginfo_event_pending)
-
-	PHP_FE(event_base_new,                 arginfo_event__void)
-	PHP_FE(event_base_new_with_config,     arginfo_event_base_config_1)
-	PHP_FE(event_base_free,                arginfo_event_base_1)
-	PHP_FE(event_base_get_method,          arginfo_event_base_1)
-	PHP_FE(event_base_get_features,        arginfo_event_base_1)
-	PHP_FE(event_base_priority_init,       arginfo_event_base_priority_init)
-	PHP_FE(event_base_loop,                arginfo_event_base_loop)
-	PHP_FE(event_base_dispatch,            arginfo_event_base_1)
-	PHP_FE(event_base_loopexit,            arginfo_event_base_loopexit)
-	PHP_FE(event_base_loopbreak,           arginfo_event_base_1)
-	PHP_FE(event_base_got_break,           arginfo_event_base_1)
-	PHP_FE(event_base_got_exit,            arginfo_event_base_1)
-	PHP_FE(event_base_gettimeofday_cached, arginfo_event_base_1)
+	PHP_ME(Event, timer,        arginfo_evtimer_new,  ZEND_ACC_PUBLIC)
+	PHP_ME(Event, setTimer,     arginfo_evtimer_set,  ZEND_ACC_PUBLIC)
+	PHP_ME(Event, timerPending, arginfo_event__void,  ZEND_ACC_PUBLIC)
+	PHP_ME(Event, signal,       arginfo_evsignal_new, ZEND_ACC_PUBLIC)
+
+	PHP_MALIAS(Event, addTimer,  add, arginfo_event_add,   ZEND_ACC_PUBLIC)
+	PHP_MALIAS(Event, delTimer,  del, arginfo_event__void, ZEND_ACC_PUBLIC)
+	PHP_MALIAS(Event, addSignal, add, arginfo_event_add,   ZEND_ACC_PUBLIC)
+	PHP_MALIAS(Event, delSignal, del, arginfo_event__void, ZEND_ACC_PUBLIC)
+													  
+	PHP_FE_END
+};
+/* }}} */
+
+const zend_function_entry php_event_base_ce_functions[] = {/* {{{ */
+	PHP_ME(EventBase, __construct,        arginfo_event_base__construct,    ZEND_ACC_PUBLIC  | ZEND_ACC_CTOR)
+	PHP_ME(EventBase, getMethod,          arginfo_event_base_void,          ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, getFeatures,        arginfo_event__void,              ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, priorityInit,       arginfo_event_base_priority_init, ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, loop,               arginfo_event_base_loop,          ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, dispatch,           arginfo_event__void,              ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, exit,               arginfo_event_base_loopexit,      ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, stop,               arginfo_event__void,              ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, gotStop,            arginfo_event__void,              ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, gotExit,            arginfo_event__void,              ZEND_ACC_PUBLIC)
+	PHP_ME(EventBase, getTimeOfDayCached, arginfo_event__void,              ZEND_ACC_PUBLIC)
 #if LIBEVENT_VERSION_NUMBER >= 0x02010100
-	PHP_FE(event_base_update_cache_time, arginfo_event_base_1)
+	PHP_ME(EventBase, updateCacheTime, arginfo_event__void, ZEND_ACC_PUBLIC)
 #endif
+														   
+	PHP_FE_END
+};
+/* }}} */
 
-	PHP_FE(event_config_new,              arginfo_event__void)
-	PHP_FE(event_config_avoid_method,     arginfo_event_config_avoid_method)
-	PHP_FE(event_config_require_features, arginfo_event_config_require_features)
+const zend_function_entry php_event_config_ce_functions[] = {/* {{{ */
+	PHP_ME(EventConfig, __construct,     arginfo_event__void,                   ZEND_ACC_PUBLIC  | ZEND_ACC_CTOR)
+	PHP_ME(EventConfig, avoidMethod,     arginfo_event_config_avoid_method,     ZEND_ACC_PUBLIC)
+	PHP_ME(EventConfig, requireFeatures, arginfo_event_config_require_features, ZEND_ACC_PUBLIC)
 #if LIBEVENT_VERSION_NUMBER >= 0x02010000
-	PHP_FE(event_config_set_max_dispatch_interval, arginfo_event_config_set_max_dispatch_interval)
+	PHP_ME(EventConfig, setMaxDispatchInterval, arginfo_event_config_set_max_dispatch_interval, ZEND_ACC_PUBLIC)
 #endif
 
-	PHP_FE(bufferevent_socket_new,              arginfo_bufferevent_socket_new)
-	PHP_FE(bufferevent_free,                    arginfo_bufferevent_1)
-	PHP_FE(bufferevent_socket_connect,          arginfo_bufferevent_socket_connect)
-	PHP_FE(bufferevent_socket_connect_hostname, arginfo_bufferevent_socket_connect_hostname)
-	PHP_FE(bufferevent_socket_get_dns_error,    arginfo_bufferevent_1)
-	PHP_FE(bufferevent_setcb,                   arginfo_bufferevent_set_callbacks)
-	PHP_FE(bufferevent_enable,                  arginfo_bufferevent__events)
-	PHP_FE(bufferevent_disable,                 arginfo_bufferevent__events)
-	PHP_FE(bufferevent_get_enabled,             arginfo_bufferevent_1)
-	PHP_FE(bufferevent_get_input,               arginfo_bufferevent_1)
-	PHP_FE(bufferevent_get_output,              arginfo_bufferevent_1)
-	PHP_FE(bufferevent_setwatermark,            arginfo_bufferevent_setwatermark)
-	PHP_FE(bufferevent_write,                   arginfo_bufferevent_write)
-	PHP_FE(bufferevent_write_buffer,            arginfo_bufferevent_write_buffer)
-	PHP_FE(bufferevent_read,                    arginfo_bufferevent_read)
-	PHP_FE(bufferevent_read_buffer,             arginfo_bufferevent_write_buffer)
-	PHP_FE(bufferevent_pair_new,                arginfo_bufferevent_pair_new)
-	PHP_FE(bufferevent_priority_set,            arginfo_bufferevent_priority_set)
-	PHP_FE(bufferevent_set_timeouts,            arginfo_bufferevent_set_timeouts)
-
-	PHP_FE(evbuffer_new,            arginfo_event__void)
-	PHP_FE(evbuffer_free,           arginfo_evbuffer_1)
-	PHP_FE(evbuffer_freeze,         arginfo_evbuffer_freeze)
-	PHP_FE(evbuffer_unfreeze,       arginfo_evbuffer_freeze)
-	PHP_FE(evbuffer_get_length,     arginfo_evbuffer_1)
-	PHP_FE(evbuffer_lock,           arginfo_evbuffer_1)
-	PHP_FE(evbuffer_unlock,         arginfo_evbuffer_1)
-	PHP_FE(evbuffer_enable_locking, arginfo_evbuffer_1)
-	PHP_FE(evbuffer_add,            arginfo_evbuffer_add)
-	PHP_FE(evbuffer_add_buffer,     arginfo_evbuffer_add_buffer)
-	PHP_FE(evbuffer_remove,         arginfo_evbuffer_remove)
-
-	PHP_FE(event_socket_get_last_errno, arginfo_event_socket_1)
-	PHP_FE(event_socket_get_last_error, arginfo_event_socket_1)
-
-	/* These aliases are for compatibility with libevent extension */
-
-	PHP_FALIAS(event_timer_new,            evtimer_new,               arginfo_evtimer_new)
-	PHP_FALIAS(event_timer_set,            evtimer_set,               arginfo_evtimer_set)
-	PHP_FALIAS(event_timer_pending,        evtimer_pending,           arginfo_event_1)
-	PHP_FALIAS(event_timer_add,            event_add,                 arginfo_event_add)
-	PHP_FALIAS(event_timer_del,            event_del,                 arginfo_event_1)
-
-	PHP_FALIAS(event_buffer_free,          bufferevent_free,          arginfo_bufferevent_1)
-	PHP_FALIAS(event_buffer_set_callback,  bufferevent_setcb,         arginfo_bufferevent_set_callbacks)
-	PHP_FALIAS(event_buffer_enable,        bufferevent_enable,        arginfo_bufferevent__events)
-	PHP_FALIAS(event_buffer_disable,       bufferevent_disable,       arginfo_bufferevent__events)
-	PHP_FALIAS(event_buffer_watermark_set, bufferevent_setwatermark,  arginfo_bufferevent_setwatermark)
-	PHP_FALIAS(event_buffer_write,         bufferevent_write,         arginfo_bufferevent_write)
-	PHP_FALIAS(event_buffer_priority_set,  bufferevent_priority_set,  arginfo_bufferevent_priority_set)
-	PHP_FALIAS(event_buffer_timeout_set,   bufferevent_set_timeouts,  arginfo_bufferevent_set_timeouts)
+	PHP_FE_END
+};
+/* }}} */
+
+const zend_function_entry php_event_bevent_ce_functions[] = {/* {{{ */
+	PHP_ME(EventBufferEvent, __construct,       arginfo_bufferevent__construct,              ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, connect,           arginfo_bufferevent_connect,                 ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, connectHost,       arginfo_bufferevent_socket_connect_hostname, ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, getDnsErrorString, arginfo_event__void,                         ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, setCallbacks,      arginfo_bufferevent_set_callbacks,           ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, enable,            arginfo_bufferevent__events,                 ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, disable,           arginfo_bufferevent__events,                 ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, getEnabled,        arginfo_event__void,                         ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, getInput,          arginfo_event__void,                         ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, getOutput,         arginfo_event__void,                         ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, setWatermark,      arginfo_bufferevent_setwatermark,            ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, write,             arginfo_bufferevent_write,                   ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, writeBuffer,       arginfo_bufferevent_write_buffer,            ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, read,              arginfo_bufferevent_read,                    ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, readBuffer,        arginfo_bufferevent_write_buffer,            ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, createPair,        arginfo_bufferevent_pair_new,                ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, setPriority,       arginfo_bufferevent_priority_set,            ZEND_ACC_PUBLIC)
+	PHP_ME(EventBufferEvent, setTimeouts,       arginfo_bufferevent_set_timeouts,            ZEND_ACC_PUBLIC)
+
+	PHP_FE_END
+};
+/* }}} */
+
+const zend_function_entry php_event_buffer_ce_functions[] = {/* {{{ */
+	PHP_ME(EventBuffer, __construct,   arginfo_event__void,         ZEND_ACC_PUBLIC  | ZEND_ACC_CTOR)
+	PHP_ME(EventBuffer, freeze,        arginfo_evbuffer_freeze,     ZEND_ACC_PUBLIC)
+	PHP_ME(EventBuffer, unfreeze,      arginfo_evbuffer_freeze,     ZEND_ACC_PUBLIC)
+	PHP_ME(EventBuffer, getLength,     arginfo_event__void,         ZEND_ACC_PUBLIC)
+	PHP_ME(EventBuffer, lock,          arginfo_event__void,         ZEND_ACC_PUBLIC)
+	PHP_ME(EventBuffer, unlock,        arginfo_event__void,         ZEND_ACC_PUBLIC)
+	PHP_ME(EventBuffer, enableLocking, arginfo_event__void,         ZEND_ACC_PUBLIC)
+	PHP_ME(EventBuffer, add,           arginfo_evbuffer_add,        ZEND_ACC_PUBLIC)
+	PHP_ME(EventBuffer, addBuffer,     arginfo_evbuffer_add_buffer, ZEND_ACC_PUBLIC)
+	PHP_ME(EventBuffer, remove,        arginfo_evbuffer_remove,     ZEND_ACC_PUBLIC)
+
+	PHP_FE_END
+};
+/* }}} */
+
+const zend_function_entry php_event_util_ce_functions[] = {/* {{{ */
+	PHP_ME(EventUtil, getLastSocketErrno, arginfo_event_socket_1, ZEND_ACC_PUBLIC)
+	PHP_ME(EventUtil, getLastSocketError, arginfo_event_socket_1, ZEND_ACC_PUBLIC)
 
+	PHP_FE_END