mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-26 20:14:47 +01:00
commit
13ae43f208
45
php_uv.c
45
php_uv.c
@ -339,7 +339,6 @@ static php_socket_t php_uv_zval_to_valid_poll_fd(zval *ptr)
|
||||
/* TODO: is this correct on windows platform? */
|
||||
if (Z_TYPE_P(ptr) == IS_RESOURCE) {
|
||||
if ((stream = (php_stream *) zend_fetch_resource_ex(ptr, NULL, php_file_le_stream()))) {
|
||||
|
||||
/* make sure only valid resource streams are passed - plainfiles and most php streams are invalid */
|
||||
if (stream->wrapper) {
|
||||
if (!strcmp((char *)stream->wrapper->wops->label, "plainfile") || (!strcmp((char *)stream->wrapper->wops->label, "PHP") && (!stream->orig_path || (strncmp(stream->orig_path, "php://std", sizeof("php://std") - 1) && strncmp(stream->orig_path, "php://fd/", sizeof("php://fd") - 1))))) {
|
||||
@ -3174,11 +3173,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_poll_init, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, fd)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_poll_init_socket, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, loop)
|
||||
ZEND_ARG_INFO(0, fd)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_poll_start, 0, 0, 3)
|
||||
ZEND_ARG_INFO(0, handle)
|
||||
ZEND_ARG_INFO(0, events)
|
||||
@ -6134,7 +6128,11 @@ PHP_FUNCTION(uv_poll_init)
|
||||
PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop);
|
||||
PHP_UV_ZVAL_TO_VALID_POLL_FD(fd, zstream);
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
error = uv_poll_init_socket(loop, &uv->uv.poll, (uv_os_sock_t)fd);
|
||||
#else
|
||||
error = uv_poll_init(loop, &uv->uv.poll, fd);
|
||||
#endif
|
||||
if (error) {
|
||||
PHP_UV_DEINIT_UV();
|
||||
php_error_docref(NULL, E_ERROR, "uv_poll_init failed");
|
||||
@ -6148,39 +6146,6 @@ PHP_FUNCTION(uv_poll_init)
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto uv uv_poll_init_socket([resource $uv_loop], zval fd)
|
||||
*/
|
||||
PHP_FUNCTION(uv_poll_init_socket)
|
||||
{
|
||||
zval *zstream, *zloop = NULL;
|
||||
uv_loop_t *loop;
|
||||
php_uv_t *uv;
|
||||
int error;
|
||||
unsigned long fd = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(),
|
||||
"rr", &zloop, &zstream) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
PHP_UV_INIT_UV(uv, IS_UV_POLL);
|
||||
PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop);
|
||||
PHP_UV_ZVAL_TO_FD(fd, zstream);
|
||||
|
||||
error = uv_poll_init_socket(loop, &uv->uv.poll, fd);
|
||||
if (error) {
|
||||
PHP_UV_DEINIT_UV();
|
||||
php_error_docref(NULL, E_ERROR, "uv_poll_init_socket failed");
|
||||
return;
|
||||
}
|
||||
|
||||
uv->uv.poll.data = uv;
|
||||
uv->sock = fd;
|
||||
ZVAL_RES(return_value, uv->resource_id);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ proto uv uv_poll_start(resource $handle, $events, $callback)
|
||||
*/
|
||||
@ -6411,7 +6376,7 @@ static zend_function_entry uv_functions[] = {
|
||||
PHP_FE(uv_udp_set_membership, arginfo_uv_udp_set_membership)
|
||||
/* poll */
|
||||
PHP_FE(uv_poll_init, arginfo_uv_poll_init)
|
||||
PHP_FE(uv_poll_init_socket, arginfo_uv_poll_init_socket)
|
||||
PHP_FALIAS(uv_poll_init_socket, uv_poll_init, arginfo_uv_poll_init)
|
||||
PHP_FE(uv_poll_start, arginfo_uv_poll_start)
|
||||
PHP_FE(uv_poll_stop, arginfo_uv_poll_stop)
|
||||
PHP_FE(uv_fs_poll_init, arginfo_uv_fs_poll_init)
|
||||
|
13
uv.c
13
uv.c
@ -125,6 +125,19 @@ static int php_uv_class_init(TSRMLS_D)
|
||||
#endif
|
||||
|
||||
#else
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IRWXU", sizeof("S_IRWXU")-1, _S_IWRITE | _S_IREAD TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IRUSR", sizeof("S_IRUSR")-1, _S_IREAD TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IWUSR", sizeof("S_IWUSR")-1, _S_IWRITE TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IXUSR", sizeof("S_IXUSR")-1, 0 TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IRWXG", sizeof("S_IRWXG")-1, _S_IWRITE | _S_IREAD TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IRGRP", sizeof("S_IRGRP")-1, _S_IREAD TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IWGRP", sizeof("S_IWGRP")-1, _S_IWRITE TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IXGRP", sizeof("S_IXGRP")-1, 0 TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IRWXO", sizeof("S_IRWXO")-1, _S_IWRITE | _S_IREAD TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IROTH", sizeof("S_IROTH")-1, _S_IREAD TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IWOTH", sizeof("S_IWOTH")-1, _S_IWRITE TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IXOTH", sizeof("S_IXOTH")-1, 0 TSRMLS_CC);
|
||||
|
||||
/* Windows Signal Constants */
|
||||
zend_declare_class_constant_long(uv_class_entry, "SIGBREAK", sizeof("SIGBREAK")-1, (long) SIGBREAK TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "SIGINT", sizeof("SIGINT")-1, (long) SIGINT TSRMLS_CC);
|
||||
|
Loading…
Reference in New Issue
Block a user