Commits

Ruslan Osmanov committed 8fc2096

Add: some bufferevent funcs

Comments (0)

Files changed (3)

 }
 /* }}} */
 
-/* {{{ proto void bufferevent_set_watermark(resource bevent, int events, int lowmark, int highmark);
+/* {{{ proto void bufferevent_setwatermark(resource bevent, int events, int lowmark, int highmark);
  * Adjusts the read watermarks, the write watermarks, or both, of a single bufferevent. */
-PHP_FUNCTION(bufferevent_set_watermark)
+PHP_FUNCTION(bufferevent_setwatermark)
 {
 	php_event_bevent_t *bev;
 	zval               *zbevent;
 }
 /* }}} */
 
+/* {{{ proto bool bufferevent_priority_set(resource bevent, int priority);
+ * Assign a priority to a bufferevent.
+ * Only supported for socket bufferevents. */
+PHP_FUNCTION(bufferevent_priority_set)
+{
+	php_event_bevent_t *bev;
+	zval               *zbevent;
+	long                priority;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl",
+				&zbevent, &priority) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
+
+	if (bufferevent_priority_set(bev->bevent, priority)) {
+		RETURN_FALSE;
+	}
+	RETVAL_TRUE;
+}
+/* }}} */
 
+/* {{{ proto bool bufferevent_set_timeouts(resource bevent, double timeout_read, double timeout_write);
+ * Set the read and write timeout for a bufferevent. */
+PHP_FUNCTION(bufferevent_set_timeouts)
+{
+	php_event_bevent_t *bev;
+	zval               *zbevent;
+	double              timeout_read;
+	double              timeout_write;
+	struct timeval      tv_read;
+	struct timeval      tv_write;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll",
+				&zbevent, &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;
+}
+/* }}} */
 
 /* {{{ proto resource evbuffer_new(void);
  * Allocates storage for new event buffer and returns it's resource. */
 	ZEND_ARG_INFO(0, arg)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_set_watermark, 0, 0, 4)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent_setwatermark, 0, 0, 4)
 	ZEND_ARG_INFO(0, bevent)
 	ZEND_ARG_INFO(0, events)
 	ZEND_ARG_INFO(0, lowmark)
 	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_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_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)
 	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_set_watermark,           arginfo_bufferevent_set_watermark)
+	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_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_set_watermark, arginfo_bufferevent_set_watermark)
+	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)
 
 
 #if HAVE_EVENT_EXTRA_LIB
 #endif
 
 PHP_FUNCTION(bufferevent_socket_new);
+PHP_FUNCTION(bufferevent_pair_new);
 PHP_FUNCTION(bufferevent_free);
 PHP_FUNCTION(bufferevent_socket_connect);
 PHP_FUNCTION(bufferevent_socket_connect_hostname);
 PHP_FUNCTION(bufferevent_get_enabled);
 PHP_FUNCTION(bufferevent_get_input);
 PHP_FUNCTION(bufferevent_get_output);
-PHP_FUNCTION(bufferevent_set_watermark);
+PHP_FUNCTION(bufferevent_setwatermark);
 PHP_FUNCTION(bufferevent_socket_get_dns_error);
 PHP_FUNCTION(bufferevent_write);
 PHP_FUNCTION(bufferevent_write_buffer);
 PHP_FUNCTION(bufferevent_read);
 PHP_FUNCTION(bufferevent_read_buffer);
-PHP_FUNCTION(bufferevent_pair_new);
+PHP_FUNCTION(bufferevent_priority_set);
+PHP_FUNCTION(bufferevent_set_timeouts);
 
 PHP_FUNCTION(evbuffer_new);
 PHP_FUNCTION(evbuffer_free);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.