2012-05-22 19:43:11 +02: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 01:10:25 +02:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
#include <Winsock2.h>
|
|
|
|
#include <Mswsock.h>
|
|
|
|
#include <psapi.h>
|
|
|
|
#include <Iphlpapi.h>
|
2012-06-20 05:08:44 +02:00
|
|
|
#endif
|
2012-06-19 01:10:25 +02:00
|
|
|
|
2012-05-22 19:43:11 +02:00
|
|
|
#include "php.h"
|
2012-05-23 06:35:28 +02:00
|
|
|
#include "uv.h"
|
2012-05-22 19:43:11 +02: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-29 18:47:30 +02: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 15:24:19 +02:00
|
|
|
IS_UV_PROCESS = 10,
|
2012-06-17 15:50:18 +02:00
|
|
|
IS_UV_PREPARE = 11,
|
2012-06-17 16:04:54 +02:00
|
|
|
IS_UV_CHECK = 12,
|
2012-06-17 18:32:50 +02:00
|
|
|
IS_UV_WORK = 13,
|
2012-06-20 05:40:39 +02:00
|
|
|
IS_UV_FS = 14,
|
2012-06-23 07:18:38 +02:00
|
|
|
IS_UV_FS_EVENT = 15,
|
2012-06-23 08:05:14 +02:00
|
|
|
IS_UV_TTY = 16,
|
|
|
|
IS_UV_MAX = 16
|
2012-05-29 18:47:30 +02:00
|
|
|
};
|
|
|
|
|
2012-05-23 06:35:28 +02:00
|
|
|
typedef struct {
|
2012-05-27 08:36:03 +02:00
|
|
|
int in_free;
|
2012-06-14 17:18:05 +02:00
|
|
|
#ifdef ZTS
|
|
|
|
void ***thread_ctx;
|
|
|
|
#endif
|
2012-05-26 16:26:29 +02:00
|
|
|
int resource_id;
|
2012-05-29 18:47:30 +02:00
|
|
|
int type;
|
2012-05-26 15:59:59 +02: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-28 18:12:09 +02:00
|
|
|
uv_getaddrinfo_t addrinfo;
|
2012-06-17 15:50:18 +02:00
|
|
|
uv_prepare_t prepare;
|
2012-06-17 16:04:54 +02:00
|
|
|
uv_check_t check;
|
2012-06-14 15:24:19 +02:00
|
|
|
uv_process_t process;
|
2012-06-17 18:32:50 +02:00
|
|
|
uv_work_t work;
|
2012-06-20 05:40:39 +02:00
|
|
|
uv_fs_t fs;
|
2012-06-23 07:18:38 +02:00
|
|
|
uv_fs_event_t fs_event;
|
2012-06-23 08:05:14 +02:00
|
|
|
uv_tty_t tty;
|
2012-05-26 15:59:59 +02:00
|
|
|
} uv;
|
2012-06-22 05:51:16 +02:00
|
|
|
char *buffer;
|
2012-05-28 18:12:09 +02:00
|
|
|
zval *address;
|
2012-05-26 15:25:15 +02:00
|
|
|
zval *listen_cb;
|
|
|
|
zval *read_cb;
|
|
|
|
zval *write_cb;
|
2012-05-26 15:54:43 +02:00
|
|
|
zval *close_cb;
|
2012-05-26 16:26:29 +02:00
|
|
|
zval *timer_cb;
|
2012-05-28 05:29:15 +02:00
|
|
|
zval *idle_cb;
|
2012-05-28 15:55:58 +02:00
|
|
|
zval *connect_cb;
|
2012-05-28 18:12:09 +02:00
|
|
|
zval *getaddr_cb;
|
2012-05-29 18:47:30 +02:00
|
|
|
zval *udp_recv_cb;
|
|
|
|
zval *udp_send_cb;
|
2012-05-31 19:23:34 +02:00
|
|
|
zval *pipe_connect_cb;
|
2012-06-14 15:24:19 +02:00
|
|
|
zval *proc_close_cb;
|
2012-06-17 15:50:18 +02:00
|
|
|
zval *prepare_cb;
|
2012-06-17 16:04:54 +02:00
|
|
|
zval *check_cb;
|
2012-06-17 16:18:33 +02:00
|
|
|
zval *async_cb;
|
2012-06-17 18:32:50 +02:00
|
|
|
zval *work_cb;
|
|
|
|
zval *after_work_cb;
|
2012-06-20 05:40:39 +02:00
|
|
|
zval *fs_cb;
|
2012-06-23 07:18:38 +02:00
|
|
|
zval *fs_event_cb;
|
2012-06-03 18:23:03 +02:00
|
|
|
} php_uv_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ares_channel channel;
|
|
|
|
struct ares_options options;
|
2012-06-03 17:10:30 +02:00
|
|
|
zval *gethostbyname_cb;
|
|
|
|
zval *gethostbyaddr_cb;
|
2012-06-03 18:23:03 +02:00
|
|
|
int resource_id;
|
|
|
|
} php_uv_ares_t;
|
2012-05-23 06:35:28 +02:00
|
|
|
|
2012-05-28 18:12:09 +02: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 06:35:28 +02:00
|
|
|
#define PHP_UV_RESOURCE_NAME "uv"
|
2012-05-28 18:12:09 +02:00
|
|
|
#define PHP_UV_SOCKADDR_RESOURCE_NAME "uv_sockaddr"
|
2012-05-28 15:18:36 +02:00
|
|
|
#define PHP_UV_LOOP_RESOURCE_NAME "uv_loop"
|
2012-06-03 18:23:03 +02:00
|
|
|
#define PHP_UV_ARES_RESOURCE_NAME "uv_ares"
|
2012-06-16 10:22:29 +02:00
|
|
|
#define PHP_UV_RWLOCK_RESOURCE_NAME "uv_rwlock"
|
2012-06-17 14:18:30 +02:00
|
|
|
#define PHP_UV_MUTEX_RESOURCE_NAME "uv_mutex"
|
2012-05-23 06:35:28 +02:00
|
|
|
|
2012-06-23 13:27:30 +02:00
|
|
|
/* TODO: remove these macro when libuv provides uv_inet_ntop & uv_inet_pton */
|
|
|
|
#ifdef PHP_WIN32
|
|
|
|
# include <inet_net_pton.h>
|
|
|
|
# include <inet_ntop.h>
|
|
|
|
# define uv_inet_pton ares_inet_pton
|
|
|
|
# define uv_inet_ntop ares_inet_ntop
|
|
|
|
#else
|
|
|
|
# include <arpa/inet.h>
|
|
|
|
# define uv_inet_pton inet_pton
|
|
|
|
# define uv_inet_ntop inet_ntop
|
|
|
|
#endif
|
|
|
|
|
2012-05-22 19:43:11 +02:00
|
|
|
#endif /* PHP_UV_H */
|