2012-05-23 02:43:11 +09:00
|
|
|
#ifndef PHP_UV_H
|
|
|
|
|
|
|
|
#define PHP_UV_H
|
|
|
|
|
|
|
|
#define PHP_UV_EXTNAME "uv"
|
|
|
|
#define PHP_UV_EXTVER "0.1"
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-06-19 08:10:25 +09:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
#include <Winsock2.h>
|
|
|
|
#include <Mswsock.h>
|
|
|
|
#include <psapi.h>
|
|
|
|
#include <Iphlpapi.h>
|
2012-06-20 12:08:44 +09:00
|
|
|
#endif
|
2012-06-19 08:10:25 +09:00
|
|
|
|
2012-05-23 02:43:11 +09:00
|
|
|
#include "php.h"
|
2012-05-23 13:35:28 +09:00
|
|
|
#include "uv.h"
|
2012-05-23 02:43:11 +09:00
|
|
|
|
|
|
|
#include "zend_interfaces.h"
|
|
|
|
|
|
|
|
/* Define the entry point symbol
|
|
|
|
* Zend will use when loading this module
|
|
|
|
*/
|
|
|
|
extern zend_module_entry uv_module_entry;
|
|
|
|
#define phpext_uv_ptr &uv_module_entry;
|
|
|
|
|
|
|
|
extern zend_class_entry *uv_class_entry;
|
|
|
|
|
2012-05-30 01:47:30 +09:00
|
|
|
enum php_uv_resource_type{
|
|
|
|
IS_UV_TCP = 0,
|
|
|
|
IS_UV_UDP = 1,
|
|
|
|
IS_UV_PIPE = 2,
|
|
|
|
IS_UV_IDLE = 3,
|
|
|
|
IS_UV_TIMER = 4,
|
|
|
|
IS_UV_ASYNC = 5,
|
|
|
|
IS_UV_LOOP = 6,
|
|
|
|
IS_UV_HANDLE = 7,
|
|
|
|
IS_UV_STREAM = 8,
|
|
|
|
IS_UV_ADDRINFO = 9,
|
2012-06-14 22:24:19 +09:00
|
|
|
IS_UV_PROCESS = 10,
|
2012-06-17 22:50:18 +09:00
|
|
|
IS_UV_PREPARE = 11,
|
2012-06-17 23:04:54 +09:00
|
|
|
IS_UV_CHECK = 12,
|
2012-06-18 01:32:50 +09:00
|
|
|
IS_UV_WORK = 13,
|
2012-06-20 12:40:39 +09:00
|
|
|
IS_UV_FS = 14,
|
|
|
|
IS_UV_MAX = 15
|
2012-05-30 01:47:30 +09:00
|
|
|
};
|
|
|
|
|
2012-05-23 13:35:28 +09:00
|
|
|
typedef struct {
|
2012-05-27 15:36:03 +09:00
|
|
|
int in_free;
|
2012-06-15 00:18:05 +09:00
|
|
|
#ifdef ZTS
|
|
|
|
void ***thread_ctx;
|
|
|
|
#endif
|
2012-05-26 23:26:29 +09:00
|
|
|
int resource_id;
|
2012-05-30 01:47:30 +09:00
|
|
|
int type;
|
2012-05-26 22:59:59 +09:00
|
|
|
union {
|
|
|
|
uv_tcp_t tcp;
|
|
|
|
uv_udp_t udp;
|
|
|
|
uv_pipe_t pipe;
|
|
|
|
uv_idle_t idle;
|
|
|
|
uv_timer_t timer;
|
|
|
|
uv_async_t async;
|
|
|
|
uv_loop_t loop;
|
|
|
|
uv_handle_t handle;
|
|
|
|
uv_stream_t stream;
|
2012-05-29 01:12:09 +09:00
|
|
|
uv_getaddrinfo_t addrinfo;
|
2012-06-17 22:50:18 +09:00
|
|
|
uv_prepare_t prepare;
|
2012-06-17 23:04:54 +09:00
|
|
|
uv_check_t check;
|
2012-06-14 22:24:19 +09:00
|
|
|
uv_process_t process;
|
2012-06-18 01:32:50 +09:00
|
|
|
uv_work_t work;
|
2012-06-20 12:40:39 +09:00
|
|
|
uv_fs_t fs;
|
2012-05-26 22:59:59 +09:00
|
|
|
} uv;
|
2012-06-22 12:51:16 +09:00
|
|
|
char *buffer;
|
2012-05-29 01:12:09 +09:00
|
|
|
zval *address;
|
2012-05-26 22:25:15 +09:00
|
|
|
zval *listen_cb;
|
|
|
|
zval *read_cb;
|
|
|
|
zval *write_cb;
|
2012-05-26 22:54:43 +09:00
|
|
|
zval *close_cb;
|
2012-05-26 23:26:29 +09:00
|
|
|
zval *timer_cb;
|
2012-05-28 12:29:15 +09:00
|
|
|
zval *idle_cb;
|
2012-05-28 22:55:58 +09:00
|
|
|
zval *connect_cb;
|
2012-05-29 01:12:09 +09:00
|
|
|
zval *getaddr_cb;
|
2012-05-30 01:47:30 +09:00
|
|
|
zval *udp_recv_cb;
|
|
|
|
zval *udp_send_cb;
|
2012-06-01 02:23:34 +09:00
|
|
|
zval *pipe_connect_cb;
|
2012-06-14 22:24:19 +09:00
|
|
|
zval *proc_close_cb;
|
2012-06-17 22:50:18 +09:00
|
|
|
zval *prepare_cb;
|
2012-06-17 23:04:54 +09:00
|
|
|
zval *check_cb;
|
2012-06-17 23:18:33 +09:00
|
|
|
zval *async_cb;
|
2012-06-18 01:32:50 +09:00
|
|
|
zval *work_cb;
|
|
|
|
zval *after_work_cb;
|
2012-06-20 12:40:39 +09:00
|
|
|
zval *fs_cb;
|
2012-06-04 01:23:03 +09:00
|
|
|
} php_uv_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ares_channel channel;
|
|
|
|
struct ares_options options;
|
2012-06-04 00:10:30 +09:00
|
|
|
zval *gethostbyname_cb;
|
|
|
|
zval *gethostbyaddr_cb;
|
2012-06-04 01:23:03 +09:00
|
|
|
int resource_id;
|
|
|
|
} php_uv_ares_t;
|
2012-05-23 13:35:28 +09:00
|
|
|
|
2012-05-29 01:12:09 +09:00
|
|
|
typedef struct {
|
|
|
|
int is_ipv4;
|
|
|
|
int resource_id;
|
|
|
|
union {
|
|
|
|
struct sockaddr_in ipv4;
|
|
|
|
struct sockaddr_in6 ipv6;
|
|
|
|
} addr;
|
|
|
|
} php_uv_sockaddr_t;
|
|
|
|
|
2012-05-23 13:35:28 +09:00
|
|
|
#define PHP_UV_RESOURCE_NAME "uv"
|
2012-05-29 01:12:09 +09:00
|
|
|
#define PHP_UV_SOCKADDR_RESOURCE_NAME "uv_sockaddr"
|
2012-05-28 22:18:36 +09:00
|
|
|
#define PHP_UV_LOOP_RESOURCE_NAME "uv_loop"
|
2012-06-04 01:23:03 +09:00
|
|
|
#define PHP_UV_ARES_RESOURCE_NAME "uv_ares"
|
2012-06-16 17:22:29 +09:00
|
|
|
#define PHP_UV_RWLOCK_RESOURCE_NAME "uv_rwlock"
|
2012-06-17 21:18:30 +09:00
|
|
|
#define PHP_UV_MUTEX_RESOURCE_NAME "uv_mutex"
|
2012-05-23 13:35:28 +09:00
|
|
|
|
2012-05-23 02:43:11 +09:00
|
|
|
#endif /* PHP_UV_H */
|