2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2006, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
21 #include "ext/standard/info.h"
25 #ifdef HAVE_ARES_VERSION
26 # include <ares_version.h>
34 #ifdef HAVE_ARPA_INET_H
35 # include <arpa/inet.h>
37 #ifdef HAVE_ARPA_NAMESER_H
38 # include <arpa/nameser.h>
44 # define zend_is_callable(a,b,c) 1
46 # undef TSRMLS_SET_CTX
47 # define TSRMLS_SET_CTX
48 # undef TSRMLS_FETCH_FROM_CTX
49 # define TSRMLS_FETCH_FROM_CTX
53 #define PHP_ARES_LE_NAME "AsyncResolver"
54 #define PHP_ARES_QUERY_LE_NAME "AsyncResolverQuery"
56 static int le_ares_query
;
58 #ifdef HAVE_OLD_ARES_STRERROR
59 # define PHP_ARES_ERROR(err) { \
61 php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ares_strerror(err, &__tmp)); \
62 if (__tmp) ares_free_errmem(__tmp); \
65 # define PHP_ARES_ERROR(err) \
66 php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ares_strerror(err))
69 #define RETURN_ARES_ERROR(err) \
70 PHP_ARES_ERROR(err); \
72 #define PHP_ARES_CB_ERROR(param) \
73 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected the " param " argument to be a valid callback")
74 #define RETURN_ARES_CB_ERROR(param) \
75 PHP_ARES_CB_ERROR(param); \
79 typedef struct _php_ares_options
{
80 struct ares_options strct
;
84 typedef struct _php_ares
{
86 php_ares_options options
;
89 unsigned in_callback
:1;
93 typedef enum _php_ares_query_type
{
97 } php_ares_query_type
;
99 typedef enum _php_ares_query_packet_type
{
100 PHP_ARES_PCKT_SEARCH
,
106 } php_ares_query_packet_type
;
108 typedef union _php_ares_query_packet_data
{
142 } php_ares_query_packet_data
;
144 typedef struct _php_ares_query_packet
{
145 php_ares_query_packet_type type
;
146 php_ares_query_packet_data data
;
147 } php_ares_query_packet
;
149 typedef union _php_ares_query_result
{
159 } php_ares_query_result
;
161 typedef struct _php_ares_query
{
166 php_ares_query_type type
;
167 php_ares_query_packet packet
;
168 php_ares_query_result result
;
172 local
struct hostent
*php_ares_hostent_ctor(struct hostent
*host
) /* {{{ */
175 host
= emalloc(sizeof(struct hostent
));
177 memset(host
, 0, sizeof(struct hostent
));
183 local
void php_ares_hostent_copy(struct hostent
*from
, struct hostent
*to
) /* {{{ */
188 memcpy(to
, from
, sizeof(struct hostent
));
189 to
->h_name
= estrdup(from
->h_name
);
190 for (c
= 0, ptr
= from
->h_aliases
; *ptr
; ++ptr
, ++c
);
191 to
->h_aliases
= ecalloc((c
+1), sizeof(char *));
192 for (i
= 0; i
< c
; ++i
) {
193 to
->h_aliases
[i
] = estrdup(from
->h_aliases
[i
]);
195 for (c
= 0, ptr
= from
->h_addr_list
; *ptr
; ++ptr
, ++c
);
196 to
->h_addr_list
= ecalloc((c
+1), sizeof(char *));
197 for (i
= 0; i
< c
; ++i
) {
198 to
->h_addr_list
[i
] = emalloc(from
->h_length
);
199 memcpy(to
->h_addr_list
[i
], from
->h_addr_list
[i
], from
->h_length
);
204 local
void php_ares_hostent_to_struct(struct hostent
*hostent
, HashTable
*ht
) /* {{{ */
210 Z_TYPE(array
) = IS_ARRAY
;
211 Z_ARRVAL(array
) = ht
;
214 add_assoc_string(&array
, "name", hostent
->h_name
, 1);
218 if (hostent
->h_aliases
) {
219 for (ptr
= hostent
->h_aliases
; *ptr
; ++ptr
) {
220 add_next_index_string(tmp
, *ptr
, 1);
223 add_assoc_zval(&array
, "aliases", tmp
);
224 add_assoc_long(&array
, "addrtype", hostent
->h_addrtype
);
228 if (hostent
->h_addr_list
) {
229 for (ptr
= hostent
->h_addr_list
; *ptr
; ++ptr
) {
232 if (inet_ntop(hostent
->h_addrtype
, *ptr
, name
, sizeof(name
)-1)) {
233 add_next_index_string(tmp
, name
, 1);
237 add_assoc_zval(&array
, "addrlist", tmp
);
242 local
void php_ares_hostent_dtor(struct hostent
*host
) /* {{{ */
246 STR_FREE(host
->h_name
);
247 if (host
->h_aliases
) {
248 for (ptr
= host
->h_aliases
; *ptr
; ++ptr
) {
251 efree(host
->h_aliases
);
253 if (host
->h_addr_list
) {
254 for (ptr
= host
->h_addr_list
; *ptr
; ++ptr
) {
257 efree(host
->h_addr_list
);
259 memset(host
, 0, sizeof(struct hostent
));
263 local
void php_ares_hostent_free(struct hostent
**host
) /* {{{ */
265 php_ares_hostent_dtor(*host
);
271 local php_ares_query
*php_ares_query_ctor(php_ares_query
*query
, php_ares_query_type type
, php_ares
*ares
, zval
*callback
) /* {{{ */
274 query
= emalloc(sizeof(php_ares_query
));
276 memset(query
, 0, sizeof(php_ares_query
));
283 ZVAL_ADDREF(callback
);
284 query
->callback
= callback
;
291 local
void php_ares_query_rsrc(php_ares_query
*query
, zval
*return_value
) /* {{{ */
293 TSRMLS_FETCH_FROM_CTX(query
->ares
->tsrm_ls
);
295 ZEND_REGISTER_RESOURCE(return_value
, query
, le_ares_query
);
296 query
->id
= Z_LVAL_P(return_value
);
297 zend_list_addref(query
->id
);
298 zend_llist_add_element(&query
->ares
->queries
, &query
);
302 local
void php_ares_query_pckt(php_ares_query
*query
, php_ares_query_packet_type type
, ...)
308 va_start(argv
, type
);
310 switch (query
->packet
.type
= type
) {
311 case PHP_ARES_PCKT_SEARCH
:
312 buf
= va_arg(argv
, char *);
313 len
= va_arg(argv
, int);
314 query
->packet
.data
.search
.name
= estrndup(buf
, len
);
315 query
->packet
.data
.search
.name_len
= len
;
316 query
->packet
.data
.search
.type
= va_arg(argv
, long);
317 query
->packet
.data
.search
.dnsclass
= va_arg(argv
, long);
320 case PHP_ARES_PCKT_QUERY
:
321 buf
= va_arg(argv
, char *);
322 len
= va_arg(argv
, int);
323 query
->packet
.data
.query
.name
= estrndup(buf
, len
);
324 query
->packet
.data
.query
.name_len
= len
;
325 query
->packet
.data
.query
.type
= va_arg(argv
, long);
326 query
->packet
.data
.query
.dnsclass
= va_arg(argv
, long);
329 case PHP_ARES_PCKT_SEND
:
330 buf
= va_arg(argv
, char *);
331 len
= va_arg(argv
, int);
332 query
->packet
.data
.send
.buf
= estrndup(buf
, len
);
333 query
->packet
.data
.send
.len
= len
;
336 case PHP_ARES_PCKT_HNAME
:
337 buf
= va_arg(argv
, char *);
338 len
= va_arg(argv
, int);
339 query
->packet
.data
.hname
.name
= estrndup(buf
, len
);
340 query
->packet
.data
.hname
.name_len
= len
;
341 query
->packet
.data
.hname
.family
= va_arg(argv
, long);
344 case PHP_ARES_PCKT_HADDR
:
345 buf
= va_arg(argv
, char *);
346 len
= va_arg(argv
, int);
347 query
->packet
.data
.haddr
.addr
= estrndup(buf
, len
);
348 query
->packet
.data
.haddr
.addr_len
= len
;
349 query
->packet
.data
.haddr
.family
= va_arg(argv
, long);
352 case PHP_ARES_PCKT_NINFO
:
353 query
->packet
.data
.ninfo
.flags
= va_arg(argv
, long);
354 buf
= va_arg(argv
, char *);
355 len
= va_arg(argv
, int);
356 query
->packet
.data
.ninfo
.addr
= estrndup(buf
, len
);
357 query
->packet
.data
.ninfo
.addr_len
= len
;
358 query
->packet
.data
.ninfo
.family
= va_arg(argv
, long);
359 query
->packet
.data
.ninfo
.port
= va_arg(argv
, long);
366 local
void php_ares_query_dtor(php_ares_query
*query
) /* {{{ */
368 struct php_ares_query_packet_buf
{char *buf
;} *packet
;
370 packet
= (struct php_ares_query_packet_buf
*) &query
->packet
.data
;
374 switch (query
->type
) {
375 case PHP_ARES_CB_STD
:
376 STR_FREE(query
->result
.std
.buf
);
378 case PHP_ARES_CB_HOST
:
379 php_ares_hostent_dtor(&query
->result
.host
);
381 case PHP_ARES_CB_NINFO
:
382 STR_FREE(query
->result
.ninfo
.service
);
383 STR_FREE(query
->result
.ninfo
.node
);
386 if (query
->callback
) {
387 zval_ptr_dtor(&query
->callback
);
389 memset(query
, 0, sizeof(php_ares_query
));
393 local
void php_ares_query_free(php_ares_query
**query
) /* {{{ */
395 php_ares_query_dtor(*query
);
401 local php_ares_options
*php_ares_options_ctor(php_ares_options
*options
, HashTable
*ht
) /* {{{ */
407 options
= emalloc(sizeof(php_ares_options
));
409 memset(options
, 0, sizeof(php_ares_options
));
411 if (ht
&& zend_hash_num_elements(ht
)) {
412 if ((SUCCESS
== zend_hash_find(ht
, "flags", sizeof("flags"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_LONG
)) {
413 options
->flags
|= ARES_OPT_FLAGS
;
414 options
->strct
.flags
= Z_LVAL_PP(opt
);
416 if ((SUCCESS
== zend_hash_find(ht
, "timeout", sizeof("timeout"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_LONG
)) {
417 options
->flags
|= ARES_OPT_TIMEOUT
;
418 options
->strct
.timeout
= Z_LVAL_PP(opt
);
420 if ((SUCCESS
== zend_hash_find(ht
, "tries", sizeof("tries"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_LONG
)) {
421 options
->flags
|= ARES_OPT_TRIES
;
422 options
->strct
.tries
= Z_LVAL_PP(opt
);
424 if ((SUCCESS
== zend_hash_find(ht
, "ndots", sizeof("ndots"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_LONG
)) {
425 options
->flags
|= ARES_OPT_NDOTS
;
426 options
->strct
.ndots
= Z_LVAL_PP(opt
);
428 if ((SUCCESS
== zend_hash_find(ht
, "udp_port", sizeof("udp_port"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_LONG
)) {
429 options
->flags
|= ARES_OPT_UDP_PORT
;
430 options
->strct
.udp_port
= Z_LVAL_PP(opt
);
432 if ((SUCCESS
== zend_hash_find(ht
, "tcp_port", sizeof("tcp_port"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_LONG
)) {
433 options
->flags
|= ARES_OPT_TCP_PORT
;
434 options
->strct
.tcp_port
= Z_LVAL_PP(opt
);
436 if ((SUCCESS
== zend_hash_find(ht
, "servers", sizeof("servers"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_ARRAY
) && (i
= zend_hash_num_elements(Z_ARRVAL_PP(opt
)))) {
437 options
->strct
.servers
= ecalloc(i
, sizeof(struct in_addr
));
438 for ( zend_hash_internal_pointer_reset(Z_ARRVAL_PP(opt
));
439 SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_PP(opt
), (void *) &entry
);
440 zend_hash_move_forward(Z_ARRVAL_PP(opt
))) {
441 if (Z_TYPE_PP(entry
) == IS_STRING
) {
442 inet_aton(Z_STRVAL_PP(entry
), &options
->strct
.servers
[options
->strct
.nservers
++]);
445 if (options
->strct
.nservers
) {
446 options
->flags
|= ARES_OPT_SERVERS
;
449 if ((SUCCESS
== zend_hash_find(ht
, "domains", sizeof("domains"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_ARRAY
) && (i
= zend_hash_num_elements(Z_ARRVAL_PP(opt
)))) {
450 options
->strct
.domains
= ecalloc(i
, sizeof(char *));
451 for ( zend_hash_internal_pointer_reset(Z_ARRVAL_PP(opt
));
452 SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_PP(opt
), (void *) &entry
);
453 zend_hash_move_forward(Z_ARRVAL_PP(opt
))) {
454 if (Z_TYPE_PP(entry
) == IS_STRING
) {
455 options
->strct
.domains
[options
->strct
.ndomains
++] = estrdup(Z_STRVAL_PP(entry
));
458 if (options
->strct
.ndomains
) {
459 options
->flags
|= ARES_OPT_DOMAINS
;
462 if ((SUCCESS
== zend_hash_find(ht
, "lookups", sizeof("lookups"), (void *) &opt
)) && (Z_TYPE_PP(opt
) == IS_STRING
)) {
463 options
->flags
|= ARES_OPT_LOOKUPS
;
464 options
->strct
.lookups
= estrdup(Z_STRVAL_PP(opt
));
472 local
void php_ares_options_dtor(php_ares_options
*options
) /* {{{ */
476 if (options
->strct
.servers
) {
477 efree(options
->strct
.servers
);
480 if (options
->strct
.domains
) {
481 for (i
= 0; i
< options
->strct
.ndomains
; ++i
) {
482 efree(options
->strct
.domains
[i
]);
484 efree(options
->strct
.domains
);
487 STR_FREE(options
->strct
.lookups
);
489 memset(options
, 0, sizeof(php_ares_options
));
493 local
void php_ares_options_free(php_ares_options
**options
) /* {{{ */
495 php_ares_options_dtor(*options
);
502 static void php_ares_callback_func(void *aq
, int status
, unsigned char *abuf
, int alen
)
504 php_ares_query
*q
= (php_ares_query
*) aq
;
505 zval
*params
[3], *retval
;
506 TSRMLS_FETCH_FROM_CTX(q
->ares
->tsrm_ls
);
510 q
->result
.std
.buf
= estrndup((char *) abuf
, alen
);
511 q
->result
.std
.len
= alen
;
515 MAKE_STD_ZVAL(retval
);
516 MAKE_STD_ZVAL(params
[0]);
517 MAKE_STD_ZVAL(params
[1]);
518 MAKE_STD_ZVAL(params
[2]);
520 zend_list_addref(q
->id
);
521 Z_LVAL_P(params
[0]) = q
->id
;
522 Z_TYPE_P(params
[0]) = IS_RESOURCE
;
523 ZVAL_LONG(params
[1], status
);
524 ZVAL_STRINGL(params
[2], (char *) abuf
, alen
, 1);
526 q
->ares
->in_callback
= 1;
527 call_user_function(EG(function_table
), NULL
, q
->callback
, retval
, 3, params TSRMLS_CC
);
528 q
->ares
->in_callback
= 0;
530 zval_ptr_dtor(&retval
);
531 zval_ptr_dtor(¶ms
[0]);
532 zval_ptr_dtor(¶ms
[1]);
533 zval_ptr_dtor(¶ms
[2]);
537 static void php_ares_host_callback_func(void *aq
, int status
, struct hostent
*hostent
)
539 php_ares_query
*q
= (php_ares_query
*) aq
;
540 zval
*params
[3], *retval
;
541 TSRMLS_FETCH_FROM_CTX(q
->ares
->tsrm_ls
);
545 php_ares_hostent_copy(hostent
, &q
->result
.host
);
549 MAKE_STD_ZVAL(retval
);
550 MAKE_STD_ZVAL(params
[0]);
551 MAKE_STD_ZVAL(params
[1]);
552 MAKE_STD_ZVAL(params
[2]);
554 zend_list_addref(q
->id
);
555 Z_LVAL_P(params
[0]) = q
->id
;
556 Z_TYPE_P(params
[0]) = IS_RESOURCE
;
557 ZVAL_LONG(params
[1], status
);
558 object_init(params
[2]);
559 php_ares_hostent_to_struct(hostent
, HASH_OF(params
[2]));
561 q
->ares
->in_callback
= 1;
562 call_user_function(EG(function_table
), NULL
, q
->callback
, retval
, 3, params TSRMLS_CC
);
563 q
->ares
->in_callback
= 0;
565 zval_ptr_dtor(&retval
);
566 zval_ptr_dtor(¶ms
[0]);
567 zval_ptr_dtor(¶ms
[1]);
568 zval_ptr_dtor(¶ms
[2]);
572 #ifdef HAVE_ARES_GETNAMEINFO
573 static void php_ares_nameinfo_callback_func(void *aq
, int status
, char *node
, char *service
)
575 php_ares_query
*q
= (php_ares_query
*) aq
;
576 zval
*params
[4], *retval
;
577 TSRMLS_FETCH_FROM_CTX(q
->ares
->tsrm_ls
);
581 q
->result
.ninfo
.node
= estrdup(node
);
584 q
->result
.ninfo
.service
= estrdup(service
);
588 MAKE_STD_ZVAL(retval
);
589 MAKE_STD_ZVAL(params
[0]);
590 MAKE_STD_ZVAL(params
[1]);
591 MAKE_STD_ZVAL(params
[2]);
592 MAKE_STD_ZVAL(params
[3]);
594 zend_list_addref(q
->id
);
595 Z_LVAL_P(params
[0]) = q
->id
;
596 Z_TYPE_P(params
[0]) = IS_RESOURCE
;
597 ZVAL_LONG(params
[1], status
);
599 ZVAL_STRING(params
[2], node
, 1);
601 ZVAL_NULL(params
[2]);
604 ZVAL_STRING(params
[3], service
, 1);
606 ZVAL_NULL(params
[3]);
609 q
->ares
->in_callback
= 1;
610 call_user_function(EG(function_table
), NULL
, q
->callback
, retval
, 4, params TSRMLS_CC
);
611 q
->ares
->in_callback
= 0;
613 zval_ptr_dtor(&retval
);
614 zval_ptr_dtor(¶ms
[0]);
615 zval_ptr_dtor(¶ms
[1]);
616 zval_ptr_dtor(¶ms
[2]);
617 zval_ptr_dtor(¶ms
[3]);
623 local
struct timeval
*php_ares_timeout(php_ares
*ares
, long max_timeout
, struct timeval
*tv_buf
) /* {{{ */
625 struct timeval maxtv
;
627 if (max_timeout
> -1) {
628 maxtv
.tv_sec
= max_timeout
/ 1000;
629 maxtv
.tv_usec
= max_timeout
% (max_timeout
* 1000);
632 return ares_timeout(ares
->channel
, max_timeout
> -1 ? &maxtv
: NULL
, tv_buf
);
636 local
int php_ares_process(php_ares
*ares
, long max_timeout
) /* {{{ */
645 if ((nfds
= ares_fds(ares
->channel
, &R
, &W
))) {
646 if (0 < select(nfds
, &R
, &W
, NULL
, php_ares_timeout(ares
, max_timeout
, &tv
))) {
647 ares_process(ares
->channel
, &R
, &W
);
655 local
int php_ares_publish_fds(fd_set
*R
, fd_set
*W
, zval
*r
, zval
*w
) /* {{{ */
659 for (i
= 0; i
< FD_SETSIZE
; ++i
) {
660 if (FD_ISSET(i
, R
)) {
661 add_next_index_long(r
, i
);
668 for (i
= 0; i
< FD_SETSIZE
; ++i
) {
669 if (FD_ISSET(i
, W
)) {
670 add_next_index_long(w
, i
);
677 return nfds
? nfds
+ 1 : 0;
681 local
int php_ares_extract_fds(zval
*r
, zval
*w
, fd_set
*R
, fd_set
*W
) /* {{{ */
686 if (r
&& zend_hash_num_elements(Z_ARRVAL_P(r
))) {
687 for ( zend_hash_internal_pointer_reset(Z_ARRVAL_P(r
));
688 SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_P(r
), (void *) &fd
);
689 zend_hash_move_forward(Z_ARRVAL_P(r
))) {
690 if (Z_TYPE_PP(fd
) == IS_LONG
) {
691 FD_SET(Z_LVAL_PP(fd
), R
);
692 if (Z_LVAL_PP(fd
) > nfds
) {
693 nfds
= Z_LVAL_PP(fd
);
699 if (w
&& zend_hash_num_elements(Z_ARRVAL_P(w
))) {
700 for ( zend_hash_internal_pointer_reset(Z_ARRVAL_P(w
));
701 SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_P(w
), (void *) &fd
);
702 zend_hash_move_forward(Z_ARRVAL_P(w
))) {
703 if (Z_TYPE_PP(fd
) == IS_LONG
) {
704 FD_SET(Z_LVAL_PP(fd
), W
);
705 if (Z_LVAL_PP(fd
) > nfds
) {
706 nfds
= Z_LVAL_PP(fd
);
712 return nfds
? nfds
+ 1 : 0;
716 static void php_ares_query_llist_dtor(void *entry
)
718 php_ares_query
*q
= *(php_ares_query
**) entry
;
719 TSRMLS_FETCH_FROM_CTX(q
->ares
->tsrm_ls
);
720 zend_list_delete(q
->id
);
723 #ifdef HAVE_ARES_VERSION
724 /* {{{ proto string ares_version()
725 Get libares version */
726 static PHP_FUNCTION(ares_version
)
728 if (ZEND_NUM_ARGS()) {
732 RETURN_STRING(estrdup(ares_version(NULL
)), 0);
737 /* {{{ proto resource ares_init([array options])
738 Create an ares resource */
739 static PHP_FUNCTION(ares_init
)
741 zval
*opt_array
= NULL
;
742 php_ares
*ares
= NULL
;
745 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!", &opt_array
)) {
749 ares
= emalloc(sizeof(php_ares
));
750 TSRMLS_SET_CTX(ares
->tsrm_ls
);
751 zend_llist_init(&ares
->queries
, sizeof(php_ares_query
*), (llist_dtor_func_t
) php_ares_query_llist_dtor
, 0);
752 php_ares_options_ctor(&ares
->options
, opt_array
? Z_ARRVAL_P(opt_array
) : NULL
);
754 if (ARES_SUCCESS
!= (err
= ares_init_options(&ares
->channel
, &ares
->options
.strct
, ares
->options
.flags
))) {
755 php_ares_options_dtor(&ares
->options
);
756 zend_llist_destroy(&ares
->queries
);
758 RETURN_ARES_ERROR(err
);
761 ZEND_REGISTER_RESOURCE(return_value
, ares
, le_ares
);
765 /* {{{ proto void ares_destroy(resource ares)
766 Destroy the ares handle */
767 static PHP_FUNCTION(ares_destroy
)
772 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r", &rsrc
)) {
773 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
774 if (ares
->in_callback
) {
775 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "Cannot destroy ares handle while in callback");
777 zend_list_delete(Z_LVAL_P(rsrc
));
783 /* {{{ proto string ares_strerror(int status)
784 Get description of status code */
785 static PHP_FUNCTION(ares_strerror
)
788 #ifdef HAVE_OLD_ARES_STRERROR
793 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &err
)) {
797 #ifdef HAVE_OLD_ARES_STRERROR
798 __err
= ares_strerror(err
, &__tmp
);
799 RETVAL_STRING(estrdup(__err
), 0);
801 ares_free_errmem(__tmp
);
804 RETURN_STRING(estrdup(ares_strerror(err
)), 0);
809 /* {{{ proto string ares_mkquery(string name, int dnsclass, int type, int id, int rd)
810 Compose a custom query */
811 static PHP_FUNCTION(ares_mkquery
)
813 char *name_str
, *query_str
;
814 int name_len
, query_len
, err
;
815 long dnsclass
, type
, id
, rd
;
817 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sllll", &name_str
, &name_len
, &dnsclass
, &type
, &id
, &rd
)) {
821 if (ARES_SUCCESS
!= (err
= ares_mkquery(name_str
, dnsclass
, type
, id
, rd
, &query_str
, &query_len
))) {
822 RETURN_ARES_ERROR(err
);
824 RETVAL_STRINGL(query_str
, query_len
, 1);
825 ares_free_string(query_str
);
829 /* {{{ proto resource ares_search(resource ares, mixed callback, string name[, int type = ARES_T_A[, int dnsclass = ARES_C_IN]])
830 Issue a domain search for name */
831 static PHP_FUNCTION(ares_search
)
833 zval
*rsrc
, *cb
= NULL
;
835 php_ares_query
*query
;
838 long dnsclass
= ns_c_in
, type
= ns_t_a
;
840 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "rz!s|ll", &rsrc
, &cb
, &name
, &name_len
, &type
, &dnsclass
)) {
843 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
845 if (cb
&& !zend_is_callable(cb
, 0, NULL
)) {
846 RETURN_ARES_CB_ERROR("second");
849 query
= php_ares_query_ctor(NULL
, PHP_ARES_CB_STD
, ares
, cb
);
850 php_ares_query_rsrc(query
, return_value
);
851 php_ares_query_pckt(query
, PHP_ARES_PCKT_SEARCH
, name
, name_len
, type
, dnsclass
);
852 ares_search(ares
->channel
, name
, dnsclass
, type
, php_ares_callback_func
, query
);
856 /* {{{ proto resource ares_query(resource ares, mixed callback, string name[, int type = ARES_T_A[, int dnsclass = ARES_C_IN]])
857 Issue a single DNS query */
858 static PHP_FUNCTION(ares_query
)
860 zval
*rsrc
, *cb
= NULL
;
862 php_ares_query
*query
;
865 long dnsclass
= ns_c_in
, type
= ns_t_a
;
867 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "rz!s|ll", &rsrc
, &cb
, &name
, &name_len
, &type
, &dnsclass
)) {
870 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
872 if (cb
&& !zend_is_callable(cb
, 0, NULL
)) {
873 RETURN_ARES_CB_ERROR("second");
876 query
= php_ares_query_ctor(NULL
, PHP_ARES_CB_STD
, ares
, cb
);
877 php_ares_query_rsrc(query
, return_value
);
878 php_ares_query_pckt(query
, PHP_ARES_PCKT_QUERY
, name
, name_len
, type
, dnsclass
);
879 ares_query(ares
->channel
, name
, dnsclass
, type
, php_ares_callback_func
, query
);
883 /* {{{ proto resource ares_send(resource ares, mixed callback, string buf)
885 static PHP_FUNCTION(ares_send
)
887 zval
*rsrc
, *cb
= NULL
;
889 php_ares_query
*query
;
893 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "rz!s", &rsrc
, &cb
, &buf
, &len
)) {
896 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
898 if (cb
&& !zend_is_callable(cb
, 0, NULL
)) {
899 RETURN_ARES_CB_ERROR("second");
902 query
= php_ares_query_ctor(NULL
, PHP_ARES_CB_STD
, ares
, cb
);
903 php_ares_query_rsrc(query
, return_value
);
904 php_ares_query_pckt(query
, PHP_ARES_PCKT_SEND
, buf
, len
);
905 ares_send(ares
->channel
, (const unsigned char *) buf
, len
, php_ares_callback_func
, query
);
909 /* {{{ proto resource ares_gethostbyname(resource ares, mixed callback, string name[, int family = AF_INET])
911 static PHP_FUNCTION(ares_gethostbyname
)
913 zval
*rsrc
, *cb
= NULL
;
915 php_ares_query
*query
;
918 long family
= AF_INET
;
920 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "rz!s|l", &rsrc
, &cb
, &name
, &name_len
, &family
)) {
923 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
925 if (cb
&& !zend_is_callable(cb
, 0, NULL
)) {
926 RETURN_ARES_CB_ERROR("second");
929 query
= php_ares_query_ctor(NULL
, PHP_ARES_CB_HOST
, ares
, cb
);
930 php_ares_query_rsrc(query
, return_value
);
931 php_ares_query_pckt(query
, PHP_ARES_PCKT_HNAME
, name
, name_len
, family
);
932 ares_gethostbyname(ares
->channel
, name
, family
, php_ares_host_callback_func
, query
);
936 /* {{{ proto resource ares_gethostbyaddr(resuorce ares, mixed callback, string address[, int family = AF_INET])
937 Get host by address */
938 static PHP_FUNCTION(ares_gethostbyaddr
)
940 zval
*rsrc
, *cb
= NULL
;
942 php_ares_query
*query
;
945 long family
= AF_INET
;
949 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "rz!s|l", &rsrc
, &cb
, &addr
, &addr_len
, &family
)) {
952 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
954 if (cb
&& !zend_is_callable(cb
, 0, NULL
)) {
955 PHP_ARES_CB_ERROR("second");
961 sa
= emalloc(sa_len
= sizeof(struct in_addr
));
964 sa
= emalloc(sa_len
= sizeof(struct in6_addr
));
967 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "Parameter family is neither AF_INET nor AF_INET6");
972 if (1 > inet_pton(family
, addr
, sa
)) {
973 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "inet_pton('%s') failed", addr
);
976 query
= php_ares_query_ctor(NULL
, PHP_ARES_CB_HOST
, ares
, cb
);
977 php_ares_query_rsrc(query
, return_value
);
978 php_ares_query_pckt(query
, PHP_ARES_PCKT_HADDR
, addr
, addr_len
, family
);
979 ares_gethostbyaddr(ares
->channel
, sa
, sa_len
, family
, php_ares_host_callback_func
, query
);
985 #ifdef HAVE_ARES_GETNAMEINFO
986 /* {{{ proto resource ares_getnameinfo(resource ares, mixed callback, int flags, string addr[, int family[, int port]])
988 static PHP_FUNCTION(ares_getnameinfo
)
990 zval
*rsrc
, *cb
= NULL
;
992 php_ares_query
*query
;
995 long flags
, port
= 0, family
= AF_INET
;
997 struct sockaddr_in
*in
;
998 struct sockaddr_in6
*in6
;
1001 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "rz!ls|ll", &rsrc
, &cb
, &flags
, &addr
, &addr_len
, &family
, &port
)) {
1004 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
1006 if (cb
&& !zend_is_callable(cb
, 0, NULL
)) {
1007 PHP_ARES_CB_ERROR("second");
1014 in
= emalloc(sa_len
= sizeof(struct sockaddr_in
));
1015 in
->sin_family
= AF_INET
;
1016 in
->sin_port
= port
;
1017 if (1 > inet_pton(in
->sin_family
, addr
, &in
->sin_addr
)) {
1018 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "inet_pton('%s') failed", addr
);
1021 sa
= (struct sockaddr
*) in
;
1024 in6
= emalloc(sa_len
= sizeof(struct sockaddr_in6
));
1025 in6
->sin6_family
= AF_INET6
;
1026 in6
->sin6_port
= port
;
1027 if (1 > inet_pton(in6
->sin6_family
, addr
, &in6
->sin6_addr
)) {
1028 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "inet_pton('%s') failed", addr
);
1031 sa
= (struct sockaddr
*) in6
;
1034 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "Parameter family is neither AF_INET nor AF_INET6");
1039 if (Z_BVAL_P(return_value
)) {
1040 query
= php_ares_query_ctor(NULL
, PHP_ARES_CB_NINFO
, ares
, cb
);
1041 php_ares_query_rsrc(query
, return_value
);
1042 php_ares_query_pckt(query
, PHP_ARES_PCKT_NINFO
, flags
, addr
, addr_len
, family
, port
);
1043 ares_getnameinfo(ares
->channel
, sa
, sa_len
, flags
, php_ares_nameinfo_callback_func
, query
);
1050 /* {{{ proto mixed ares_result(resource query, int &errno, string &error)
1051 Check a query for its result */
1052 static PHP_FUNCTION(ares_result
)
1054 zval
*rsrc
, *zerrno
= NULL
, *zerror
= NULL
;
1055 php_ares_query
*query
;
1057 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r|zz", &rsrc
, &zerrno
, &zerror
)) {
1060 ZEND_FETCH_RESOURCE(query
, php_ares_query
*, &rsrc
, -1, PHP_ARES_QUERY_LE_NAME
, le_ares_query
);
1064 ZVAL_LONG(zerrno
, query
->error
);
1071 switch (query
->error
) {
1073 switch (query
->type
) {
1074 case PHP_ARES_CB_STD
:
1075 RETVAL_STRINGL(query
->result
.std
.buf
, query
->result
.std
.len
, 1);
1077 case PHP_ARES_CB_HOST
:
1078 object_init(return_value
);
1079 php_ares_hostent_to_struct(&query
->result
.host
, HASH_OF(return_value
));
1081 case PHP_ARES_CB_NINFO
:
1082 object_init(return_value
);
1083 add_property_string(return_value
, "node", query
->result
.ninfo
.node
? query
->result
.ninfo
.node
: "", 1);
1084 add_property_string(return_value
, "service", query
->result
.ninfo
.service
? query
->result
.ninfo
.service
: "", 1);
1093 #ifdef HAVE_OLD_ARES_STRERROR
1095 const char *__err
= ares_strerror(query
->error
, &__tmp
);
1096 ZVAL_STRING(zerror
, estrdup(__err
), 0);
1097 if (__tmp
) ares_free_errmem(__tmp
);
1099 ZVAL_STRING(zerror
, estrdup(ares_strerror(query
->error
)), 0);
1108 /* {{{ proto object ares_packet(resource query)
1109 Check a query for its question packet */
1110 static PHP_FUNCTION(ares_packet
)
1113 php_ares_query
*query
;
1115 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r", &rsrc
)) {
1118 ZEND_FETCH_RESOURCE(query
, php_ares_query
*, &rsrc
, -1, PHP_ARES_QUERY_LE_NAME
, le_ares_query
);
1120 object_init(return_value
);
1121 add_property_long(return_value
, "type", query
->packet
.type
);
1122 add_property_null(return_value
, "search");
1123 add_property_null(return_value
, "query");
1124 add_property_null(return_value
, "send");
1125 add_property_null(return_value
, "gethostbyname");
1126 add_property_null(return_value
, "gethostbyaddr");
1127 add_property_null(return_value
, "getnameinfo");
1128 MAKE_STD_ZVAL(prop
);
1130 switch (query
->packet
.type
) {
1131 case PHP_ARES_PCKT_SEARCH
:
1133 add_property_stringl(prop
, "name", query
->packet
.data
.search
.name
, query
->packet
.data
.search
.name_len
, 1);
1134 add_property_long(prop
, "type", query
->packet
.data
.search
.type
);
1135 add_property_long(prop
, "dnsclass", query
->packet
.data
.search
.dnsclass
);
1136 add_property_zval(return_value
, "search", prop
);
1139 case PHP_ARES_PCKT_QUERY
:
1141 add_property_stringl(prop
, "name", query
->packet
.data
.query
.name
, query
->packet
.data
.query
.name_len
, 1);
1142 add_property_long(prop
, "type", query
->packet
.data
.query
.type
);
1143 add_property_long(prop
, "dnsclass", query
->packet
.data
.query
.dnsclass
);
1144 add_property_zval(return_value
, "query", prop
);
1147 case PHP_ARES_PCKT_SEND
:
1148 ZVAL_STRINGL(prop
, query
->packet
.data
.send
.buf
, query
->packet
.data
.send
.len
, 1);
1149 add_property_zval(return_value
, "send", prop
);
1152 case PHP_ARES_PCKT_HNAME
:
1154 add_property_stringl(prop
, "name", query
->packet
.data
.hname
.name
, query
->packet
.data
.hname
.name_len
, 1);
1155 add_property_long(prop
, "family", query
->packet
.data
.hname
.family
);
1156 add_property_zval(return_value
, "gethostbyname", prop
);
1159 case PHP_ARES_PCKT_HADDR
:
1161 add_property_stringl(prop
, "addr", query
->packet
.data
.haddr
.addr
, query
->packet
.data
.haddr
.addr_len
, 1);
1162 add_property_long(prop
, "family", query
->packet
.data
.haddr
.family
);
1163 add_property_zval(return_value
, "gethostbyaddr", prop
);
1166 case PHP_ARES_PCKT_NINFO
:
1168 add_property_long(prop
, "flags", query
->packet
.data
.ninfo
.flags
);
1169 add_property_stringl(prop
, "addr", query
->packet
.data
.ninfo
.addr
, query
->packet
.data
.ninfo
.addr_len
, 1);
1170 add_property_long(prop
, "family", query
->packet
.data
.ninfo
.family
);
1171 add_property_long(prop
, "port", query
->packet
.data
.ninfo
.port
);
1172 add_property_zval(return_value
, "getnameinfo", prop
);
1176 zval_ptr_dtor(&prop
);
1180 #ifdef HAVE_ARES_CANCEL
1181 /* {{{ proto void ares_cancel(resource ares)
1182 Cancel pending queries */
1183 static PHP_FUNCTION(ares_cancel
)
1188 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r", &rsrc
)) {
1189 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
1190 ares_cancel(ares
->channel
);
1196 /* {{{ proto void ares_process_all(resource ares[, int max_timeout_ms])
1197 Process all pending queries */
1198 static PHP_FUNCTION(ares_process_all
)
1202 long max_timeout
= -1;
1204 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r|l", &rsrc
, &max_timeout
)) {
1207 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
1209 while (php_ares_process(ares
, max_timeout
));
1213 /* {{{ proto bool ares_process_once(resource ares[, int max_timout_ms])
1214 Process once and return whether it should be called again */
1215 static PHP_FUNCTION(ares_process_once
)
1219 long max_timeout
= -1;
1221 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r|l", &rsrc
, &max_timeout
)) {
1224 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
1226 RETVAL_BOOL(php_ares_process(ares
, max_timeout
));
1230 /* {{{ proto void ares_process(resource ares, array read, array write)
1232 static PHP_FUNCTION(ares_process
)
1234 zval
*rsrc
, *read
= NULL
, *write
= NULL
;
1238 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r|a!a!", &rsrc
, &read
, &write
)) {
1241 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
1246 php_ares_extract_fds(read
, write
, &R
, &W
);
1247 ares_process(ares
->channel
, &R
, &W
);
1251 /* proto bool ares_select(array &read, array &write, int timeout_ms)
1253 static PHP_FUNCTION(ares_select
)
1255 zval
*read
= NULL
, *write
= NULL
;
1261 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "aal", &read
, &write
, &timeout
)) {
1266 tv
.tv_sec
= timeout
/ 1000;
1267 tv
.tv_usec
= timeout
% (timeout
* 1000);
1276 nfds
= php_ares_extract_fds(read
, write
, &R
, &W
);
1277 if (-1 < select(nfds
, &R
, &W
, NULL
, &tv
)) {
1278 zend_hash_clean(Z_ARRVAL_P(read
));
1279 zend_hash_clean(Z_ARRVAL_P(write
));
1280 php_ares_publish_fds(&R
, &W
, read
, write
);
1287 /* proto int ares_timeout(resource ares[, int max_timout_ms])
1288 Get suggested select timeout in ms */
1289 static PHP_FUNCTION(ares_timeout
)
1292 long max_timeout
= -1;
1293 struct timeval tv
, *tvptr
;
1296 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "r|l", &rsrc
, &max_timeout
)) {
1299 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
1301 if ((tvptr
= php_ares_timeout(ares
, max_timeout
, &tv
))) {
1302 RETURN_LONG(tvptr
->tv_sec
* 1000 + tvptr
->tv_usec
/ 1000);
1308 /* {{{ proto int ares_fds(resource ares, array &read, array &write)
1309 Get file descriptors */
1310 static PHP_FUNCTION(ares_fds
)
1312 zval
*rsrc
, *read
, *write
;
1316 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "rzz", &rsrc
, &read
, &write
)) {
1319 ZEND_FETCH_RESOURCE(ares
, php_ares
*, &rsrc
, -1, PHP_ARES_LE_NAME
, le_ares
);
1328 ares_fds(ares
->channel
, &R
, &W
);
1329 RETVAL_LONG(php_ares_publish_fds(&R
, &W
, read
, write
));
1334 /* {{{ proto array ares_parse_a_reply(string reply)
1336 static PHP_FUNCTION(ares_parse_a_reply
)
1340 struct hostent
*hostent
;
1342 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &buf
, &len
)) {
1346 if (ARES_SUCCESS
!= (err
= ares_parse_a_reply((const unsigned char *) buf
, len
, &hostent
))) {
1347 RETURN_ARES_ERROR(err
);
1350 object_init(return_value
);
1351 php_ares_hostent_to_struct(hostent
, HASH_OF(return_value
));
1352 ares_free_hostent(hostent
);
1356 #ifdef HAVE_ARES_PARSE_AAAA_REPLY
1357 /* {{{ proto array ares_parse_aaaa_reply(string reply)
1358 Parse an AAAA reply */
1359 static PHP_FUNCTION(ares_parse_aaaa_reply
)
1363 struct hostent
*hostent
;
1365 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &buf
, &len
)) {
1369 if (ARES_SUCCESS
!= (err
= ares_parse_aaaa_reply((const unsigned char *) buf
, len
, &hostent
))) {
1370 RETURN_ARES_ERROR(err
);
1373 object_init(return_value
);
1374 php_ares_hostent_to_struct(hostent
, HASH_OF(return_value
));
1375 ares_free_hostent(hostent
);
1380 /* {{{ proto array ares_parse_ptr_reply(string reply)
1381 Parse a PTR reply */
1382 static PHP_FUNCTION(ares_parse_ptr_reply
)
1386 struct hostent
*hostent
;
1388 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &buf
, &len
)) {
1392 if (ARES_SUCCESS
!= (err
= ares_parse_ptr_reply((const unsigned char *) buf
, len
, NULL
, 0, 0, &hostent
))) {
1393 RETURN_ARES_ERROR(err
);
1396 object_init(return_value
);
1397 php_ares_hostent_to_struct(hostent
, HASH_OF(return_value
));
1398 ares_free_hostent(hostent
);
1402 /* {{{ proto string ares_expand_name(string name)
1403 Expand a DNS encoded name into a human readable dotted string */
1404 static PHP_FUNCTION(ares_expand_name
)
1406 char *name_str
, *exp_str
;
1408 PHP_ARES_EXPAND_LEN_TYPE exp_len
;
1410 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &name_str
, &name_len
)) {
1414 if (ARES_SUCCESS
!= (err
= ares_expand_name((const unsigned char *) name_str
, (const unsigned char *) name_str
, name_len
, &exp_str
, &exp_len
))) {
1415 RETURN_ARES_ERROR(err
);
1417 RETVAL_STRINGL(exp_str
, exp_len
, 1);
1418 ares_free_string(exp_str
);
1422 #ifdef HAVE_ARES_EXPAND_STRING
1423 /* {{{ proto string ares_expand_string(string buf)
1424 Expand a DNS encoded string into a human readable */
1425 static PHP_FUNCTION(ares_expand_string
)
1427 char *buf_str
, *exp_str
;
1429 PHP_ARES_EXPAND_LEN_TYPE exp_len
;
1431 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &buf_str
, &buf_len
)) {
1435 if (ARES_SUCCESS
!= (err
= ares_expand_string((const unsigned char *) buf_str
, (const unsigned char *) buf_str
, buf_len
, &exp_str
, &exp_len
))) {
1436 RETURN_ARES_ERROR(err
);
1438 RETVAL_STRINGL(exp_str
, exp_len
, 1);
1439 ares_free_string(exp_str
);
1444 static ZEND_RSRC_DTOR_FUNC(php_ares_le_dtor
)
1446 php_ares
*ares
= (php_ares
*) rsrc
->ptr
;
1448 ares_destroy(ares
->channel
);
1449 zend_llist_destroy(&ares
->queries
);
1450 php_ares_options_dtor(&ares
->options
);
1454 static ZEND_RSRC_DTOR_FUNC(php_ares_query_le_dtor
)
1456 php_ares_query
*query
= (php_ares_query
*) rsrc
->ptr
;
1458 php_ares_query_dtor(query
);
1462 /* {{{ PHP_MINIT_FUNCTION */
1463 static PHP_MINIT_FUNCTION(ares
)
1465 #ifdef HAVE_ARES_VERSION
1466 int ares_version_num
;
1467 ares_version(&ares_version_num
);
1469 REGISTER_LONG_CONSTANT("ARES_VERSION", ares_version_num
, CONST_PERSISTENT
|CONST_CS
);
1472 REGISTER_LONG_CONSTANT("ARES_SUCCESS", ARES_SUCCESS
, CONST_PERSISTENT
|CONST_CS
);
1473 REGISTER_LONG_CONSTANT("ARES_ENODATA", ARES_ENODATA
, CONST_PERSISTENT
|CONST_CS
);
1474 REGISTER_LONG_CONSTANT("ARES_EFORMERR", ARES_EFORMERR
, CONST_PERSISTENT
|CONST_CS
);
1475 REGISTER_LONG_CONSTANT("ARES_ESERVFAIL", ARES_ESERVFAIL
, CONST_PERSISTENT
|CONST_CS
);
1476 REGISTER_LONG_CONSTANT("ARES_ENOTFOUND", ARES_ENOTFOUND
, CONST_PERSISTENT
|CONST_CS
);
1477 REGISTER_LONG_CONSTANT("ARES_ENOTIMP", ARES_ENOTIMP
, CONST_PERSISTENT
|CONST_CS
);
1478 REGISTER_LONG_CONSTANT("ARES_EREFUSED", ARES_EREFUSED
, CONST_PERSISTENT
|CONST_CS
);
1479 REGISTER_LONG_CONSTANT("ARES_EBADQUERY", ARES_EBADQUERY
, CONST_PERSISTENT
|CONST_CS
);
1480 REGISTER_LONG_CONSTANT("ARES_EBADNAME", ARES_EBADNAME
, CONST_PERSISTENT
|CONST_CS
);
1481 REGISTER_LONG_CONSTANT("ARES_EBADFAMILY", ARES_EBADFAMILY
, CONST_PERSISTENT
|CONST_CS
);
1482 REGISTER_LONG_CONSTANT("ARES_EBADRESP", ARES_EBADRESP
, CONST_PERSISTENT
|CONST_CS
);
1483 REGISTER_LONG_CONSTANT("ARES_ECONNREFUSED", ARES_ECONNREFUSED
, CONST_PERSISTENT
|CONST_CS
);
1484 REGISTER_LONG_CONSTANT("ARES_ETIMEOUT", ARES_ETIMEOUT
, CONST_PERSISTENT
|CONST_CS
);
1485 REGISTER_LONG_CONSTANT("ARES_EOF", ARES_EOF
, CONST_PERSISTENT
|CONST_CS
);
1486 REGISTER_LONG_CONSTANT("ARES_EFILE", ARES_EFILE
, CONST_PERSISTENT
|CONST_CS
);
1487 REGISTER_LONG_CONSTANT("ARES_ENOMEM", ARES_ENOMEM
, CONST_PERSISTENT
|CONST_CS
);
1488 REGISTER_LONG_CONSTANT("ARES_EDESTRUCTION", ARES_EDESTRUCTION
, CONST_PERSISTENT
|CONST_CS
);
1490 REGISTER_LONG_CONSTANT("ARES_EBADSTR", ARES_EBADSTR
, CONST_PERSISTENT
|CONST_CS
);
1492 #ifdef ARES_EBADFLAGS
1493 REGISTER_LONG_CONSTANT("ARES_EBADFLAGS", ARES_EBADFLAGS
, CONST_PERSISTENT
|CONST_CS
);
1496 REGISTER_LONG_CONSTANT("ARES_ENONAME", ARES_ENONAME
, CONST_PERSISTENT
|CONST_CS
);
1498 #ifdef ARES_EBADHINTS
1499 REGISTER_LONG_CONSTANT("ARES_EBADHINTS", ARES_EBADHINTS
, CONST_PERSISTENT
|CONST_CS
);
1502 REGISTER_LONG_CONSTANT("ARES_FLAG_USEVC", ARES_FLAG_USEVC
, CONST_PERSISTENT
|CONST_CS
);
1503 REGISTER_LONG_CONSTANT("ARES_FLAG_PRIMARY", ARES_FLAG_PRIMARY
, CONST_PERSISTENT
|CONST_CS
);
1504 REGISTER_LONG_CONSTANT("ARES_FLAG_IGNTC", ARES_FLAG_IGNTC
, CONST_PERSISTENT
|CONST_CS
);
1505 REGISTER_LONG_CONSTANT("ARES_FLAG_NORECURSE", ARES_FLAG_NORECURSE
, CONST_PERSISTENT
|CONST_CS
);
1506 REGISTER_LONG_CONSTANT("ARES_FLAG_STAYOPEN", ARES_FLAG_STAYOPEN
, CONST_PERSISTENT
|CONST_CS
);
1507 REGISTER_LONG_CONSTANT("ARES_FLAG_NOSEARCH", ARES_FLAG_NOSEARCH
, CONST_PERSISTENT
|CONST_CS
);
1508 REGISTER_LONG_CONSTANT("ARES_FLAG_NOALIASES", ARES_FLAG_NOALIASES
, CONST_PERSISTENT
|CONST_CS
);
1509 REGISTER_LONG_CONSTANT("ARES_FLAG_NOCHECKRESP", ARES_FLAG_NOCHECKRESP
, CONST_PERSISTENT
|CONST_CS
);
1511 REGISTER_LONG_CONSTANT("ARES_OPT_FLAGS", ARES_OPT_FLAGS
, CONST_PERSISTENT
|CONST_CS
);
1512 REGISTER_LONG_CONSTANT("ARES_OPT_TIMEOUT", ARES_OPT_TIMEOUT
, CONST_PERSISTENT
|CONST_CS
);
1513 REGISTER_LONG_CONSTANT("ARES_OPT_TRIES", ARES_OPT_TRIES
, CONST_PERSISTENT
|CONST_CS
);
1514 REGISTER_LONG_CONSTANT("ARES_OPT_NDOTS", ARES_OPT_NDOTS
, CONST_PERSISTENT
|CONST_CS
);
1515 REGISTER_LONG_CONSTANT("ARES_OPT_UDP_PORT", ARES_OPT_UDP_PORT
, CONST_PERSISTENT
|CONST_CS
);
1516 REGISTER_LONG_CONSTANT("ARES_OPT_TCP_PORT", ARES_OPT_TCP_PORT
, CONST_PERSISTENT
|CONST_CS
);
1517 REGISTER_LONG_CONSTANT("ARES_OPT_SERVERS", ARES_OPT_SERVERS
, CONST_PERSISTENT
|CONST_CS
);
1518 REGISTER_LONG_CONSTANT("ARES_OPT_DOMAINS", ARES_OPT_DOMAINS
, CONST_PERSISTENT
|CONST_CS
);
1519 REGISTER_LONG_CONSTANT("ARES_OPT_LOOKUPS", ARES_OPT_LOOKUPS
, CONST_PERSISTENT
|CONST_CS
);
1522 * Name Info constants
1524 #ifdef ARES_NI_NOFQDN
1525 REGISTER_LONG_CONSTANT("ARES_NI_NOFQDN", ARES_NI_NOFQDN
, CONST_PERSISTENT
|CONST_CS
);
1527 #ifdef ARES_NI_NUMERICHOST
1528 REGISTER_LONG_CONSTANT("ARES_NI_NUMERICHOST", ARES_NI_NUMERICHOST
, CONST_PERSISTENT
|CONST_CS
);
1530 #ifdef ARES_NI_NAMEREQD
1531 REGISTER_LONG_CONSTANT("ARES_NI_NAMEREQD", ARES_NI_NAMEREQD
, CONST_PERSISTENT
|CONST_CS
);
1533 #ifdef ARES_NI_NUMERICSERV
1534 REGISTER_LONG_CONSTANT("ARES_NI_NUMERICSERV", ARES_NI_NUMERICSERV
, CONST_PERSISTENT
|CONST_CS
);
1536 #ifdef ARES_NI_DGRAM
1537 REGISTER_LONG_CONSTANT("ARES_NI_DGRAM", ARES_NI_DGRAM
, CONST_PERSISTENT
|CONST_CS
);
1540 REGISTER_LONG_CONSTANT("ARES_NI_TCP", ARES_NI_TCP
, CONST_PERSISTENT
|CONST_CS
);
1543 REGISTER_LONG_CONSTANT("ARES_NI_UDP", ARES_NI_UDP
, CONST_PERSISTENT
|CONST_CS
);
1546 REGISTER_LONG_CONSTANT("ARES_NI_SCTP", ARES_NI_SCTP
, CONST_PERSISTENT
|CONST_CS
);
1549 REGISTER_LONG_CONSTANT("ARES_NI_DCCP", ARES_NI_DCCP
, CONST_PERSISTENT
|CONST_CS
);
1551 #ifdef ARES_NI_NUMERICSCOPE
1552 REGISTER_LONG_CONSTANT("ARES_NI_NUMERICSCOPE", ARES_NI_NUMERICSCOPE
, CONST_PERSISTENT
|CONST_CS
);
1554 #ifdef ARES_NI_LOOKUPHOST
1555 REGISTER_LONG_CONSTANT("ARES_NI_LOOKUPHOST", ARES_NI_LOOKUPHOST
, CONST_PERSISTENT
|CONST_CS
);
1557 #ifdef ARES_NI_LOOKUPSERVICE
1558 REGISTER_LONG_CONSTANT("ARES_NI_LOOKUPSERVICE", ARES_NI_LOOKUPSERVICE
, CONST_PERSISTENT
|CONST_CS
);
1561 REGISTER_LONG_CONSTANT("ARES_NI_IDN", ARES_NI_IDN
, CONST_PERSISTENT
|CONST_CS
);
1563 #ifdef ARES_NI_IDN_ALLOW_UNASSIGNED
1564 REGISTER_LONG_CONSTANT("ARES_NI_IDN_ALLOW_UNASSIGNED", ARES_NI_IDN_ALLOW_UNASSIGNED
, CONST_PERSISTENT
|CONST_CS
);
1566 #ifdef ARES_NI_IDN_USE_STD
1567 REGISTER_LONG_CONSTANT("ARES_NI_IDN_USE_STD", ARES_NI_IDN_USE_STD
, CONST_PERSISTENT
|CONST_CS
);
1571 * Address Info constants
1573 #ifdef ARES_AI_CANONNAME
1574 REGISTER_LONG_CONSTANT("ARES_AI_CANONNAME", ARES_AI_CANONNAME
, CONST_PERSISTENT
|CONST_CS
);
1576 #ifdef ARES_AI_NUMERICHOST
1577 REGISTER_LONG_CONSTANT("ARES_AI_NUMERICHOST", ARES_AI_NUMERICHOST
, CONST_PERSISTENT
|CONST_CS
);
1579 #ifdef ARES_AI_PASSIVE
1580 REGISTER_LONG_CONSTANT("ARES_AI_PASSIVE", ARES_AI_PASSIVE
, CONST_PERSISTENT
|CONST_CS
);
1582 #ifdef ARES_AI_NUMERICSERV
1583 REGISTER_LONG_CONSTANT("ARES_AI_NUMERICSERV", ARES_AI_NUMERICSERV
, CONST_PERSISTENT
|CONST_CS
);
1586 REGISTER_LONG_CONSTANT("ARES_AI_V", ARES_AI_V
, CONST_PERSISTENT
|CONST_CS
);
1589 REGISTER_LONG_CONSTANT("ARES_AI_ALL", ARES_AI_ALL
, CONST_PERSISTENT
|CONST_CS
);
1591 #ifdef ARES_AI_ADDRCONFIG
1592 REGISTER_LONG_CONSTANT("ARES_AI_ADDRCONFIG", ARES_AI_ADDRCONFIG
, CONST_PERSISTENT
|CONST_CS
);
1595 REGISTER_LONG_CONSTANT("ARES_AI_IDN", ARES_AI_IDN
, CONST_PERSISTENT
|CONST_CS
);
1597 #ifdef ARES_AI_IDN_ALLOW_UNASSIGNED
1598 REGISTER_LONG_CONSTANT("ARES_AI_IDN_ALLOW_UNASSIGNED", ARES_AI_IDN_ALLOW_UNASSIGNED
, CONST_PERSISTENT
|CONST_CS
);
1600 #ifdef ARES_AI_IDN_USE_STD
1601 REGISTER_LONG_CONSTANT("ARES_AI_IDN_USE_STD", ARES_AI_IDN_USE_STD
, CONST_PERSISTENT
|CONST_CS
);
1603 #ifdef ARES_AI_CANONIDN
1604 REGISTER_LONG_CONSTANT("ARES_AI_CANONIDN", ARES_AI_CANONIDN
, CONST_PERSISTENT
|CONST_CS
);
1607 REGISTER_LONG_CONSTANT("ARES_AI_MASK", ARES_AI_MASK
, CONST_PERSISTENT
|CONST_CS
);
1609 #ifdef ARES_GETSOCK_MAXNUM
1610 REGISTER_LONG_CONSTANT("ARES_GETSOCK_MAXNUM", ARES_GETSOCK_MAXNUM
, CONST_PERSISTENT
|CONST_CS
);
1614 * ns_t (type) constants (arpa/nameser.h)
1617 /* (1) Host address. */
1618 REGISTER_LONG_CONSTANT("ARES_T_A", ns_t_a
, CONST_CS
|CONST_PERSISTENT
);
1619 /* (2) Authoritative server. */
1620 REGISTER_LONG_CONSTANT("ARES_T_NS", ns_t_ns
, CONST_CS
|CONST_PERSISTENT
);
1621 /* (3) Mail destination. */
1622 REGISTER_LONG_CONSTANT("ARES_T_MD", ns_t_md
, CONST_CS
|CONST_PERSISTENT
);
1623 /* (4) Mail forwarder. */
1624 REGISTER_LONG_CONSTANT("ARES_T_MF", ns_t_mf
, CONST_CS
|CONST_PERSISTENT
);
1625 /* (5) Canonical name. */
1626 REGISTER_LONG_CONSTANT("ARES_T_CNAME", ns_t_cname
, CONST_CS
|CONST_PERSISTENT
);
1627 /* (6) Start of authority zone. */
1628 REGISTER_LONG_CONSTANT("ARES_T_SOA", ns_t_soa
, CONST_CS
|CONST_PERSISTENT
);
1629 /* (7) Mailbox domain name. */
1630 REGISTER_LONG_CONSTANT("ARES_T_MB", ns_t_mb
, CONST_CS
|CONST_PERSISTENT
);
1631 /* (8) Mail group member. */
1632 REGISTER_LONG_CONSTANT("ARES_T_MG", ns_t_mg
, CONST_CS
|CONST_PERSISTENT
);
1633 /* (9) Mail rename name. */
1634 REGISTER_LONG_CONSTANT("ARES_T_MR", ns_t_mr
, CONST_CS
|CONST_PERSISTENT
);
1635 /* (10) Null resource record. */
1636 REGISTER_LONG_CONSTANT("ARES_T_NULL", ns_t_null
, CONST_CS
|CONST_PERSISTENT
);
1637 /* (11) Well known service. */
1638 REGISTER_LONG_CONSTANT("ARES_T_WKS", ns_t_wks
, CONST_CS
|CONST_PERSISTENT
);
1639 /* (12) Domain name pointer. */
1640 REGISTER_LONG_CONSTANT("ARES_T_PTR", ns_t_ptr
, CONST_CS
|CONST_PERSISTENT
);
1641 /* (13) Host information. */
1642 REGISTER_LONG_CONSTANT("ARES_T_HINFO", ns_t_hinfo
, CONST_CS
|CONST_PERSISTENT
);
1643 /* (14) Mailbox information. */
1644 REGISTER_LONG_CONSTANT("ARES_T_MINFO", ns_t_minfo
, CONST_CS
|CONST_PERSISTENT
);
1645 /* (15) Mail routing information. */
1646 REGISTER_LONG_CONSTANT("ARES_T_MX", ns_t_mx
, CONST_CS
|CONST_PERSISTENT
);
1647 /* (16) Text strings. */
1648 REGISTER_LONG_CONSTANT("ARES_T_TXT", ns_t_txt
, CONST_CS
|CONST_PERSISTENT
);
1649 /* (17) Responsible person. */
1650 REGISTER_LONG_CONSTANT("ARES_T_RP", ns_t_rp
, CONST_CS
|CONST_PERSISTENT
);
1651 /* (18) AFS cell database. */
1652 REGISTER_LONG_CONSTANT("ARES_T_AFSDB", ns_t_afsdb
, CONST_CS
|CONST_PERSISTENT
);
1653 /* (19) X_25 calling address. */
1654 REGISTER_LONG_CONSTANT("ARES_T_X25", ns_t_x25
, CONST_CS
|CONST_PERSISTENT
);
1655 /* (20) ISDN calling address. */
1656 REGISTER_LONG_CONSTANT("ARES_T_ISDN", ns_t_isdn
, CONST_CS
|CONST_PERSISTENT
);
1658 REGISTER_LONG_CONSTANT("ARES_T_RT", ns_t_rt
, CONST_CS
|CONST_PERSISTENT
);
1659 /* (22) NSAP address. */
1660 REGISTER_LONG_CONSTANT("ARES_T_NSAP", ns_t_nsap
, CONST_CS
|CONST_PERSISTENT
);
1661 /* (23) Reverse NSAP lookup (deprecated). */
1662 /* REGISTER_LONG_CONSTANT("ARES_T_NSAP_PTR", ns_t_nsap_ptr, CONST_CS|CONST_PERSISTENT); */
1663 /* (24) Security signature. */
1664 REGISTER_LONG_CONSTANT("ARES_T_SIG", ns_t_sig
, CONST_CS
|CONST_PERSISTENT
);
1665 /* (25) Security key. */
1666 REGISTER_LONG_CONSTANT("ARES_T_KEY", ns_t_key
, CONST_CS
|CONST_PERSISTENT
);
1667 /* (26) X.400 mail mapping. */
1668 REGISTER_LONG_CONSTANT("ARES_T_PX", ns_t_px
, CONST_CS
|CONST_PERSISTENT
);
1669 /* (27) Geographical position (withdrawn). */
1670 /* REGISTER_LONG_CONSTANT("ARES_T_GPOS", ns_t_gpos, CONST_CS|CONST_PERSISTENT); */
1671 /* (28) Ip6 Address. */
1672 REGISTER_LONG_CONSTANT("ARES_T_AAAA", ns_t_aaaa
, CONST_CS
|CONST_PERSISTENT
);
1673 /* (29) Location Information. */
1674 REGISTER_LONG_CONSTANT("ARES_T_LOC", ns_t_loc
, CONST_CS
|CONST_PERSISTENT
);
1675 /* (30) Next domain (security). */
1676 REGISTER_LONG_CONSTANT("ARES_T_NXT", ns_t_nxt
, CONST_CS
|CONST_PERSISTENT
);
1677 /* (31) Endpoint identifier. */
1678 REGISTER_LONG_CONSTANT("ARES_T_EID", ns_t_eid
, CONST_CS
|CONST_PERSISTENT
);
1679 /* (32) Nimrod Locator. */
1680 REGISTER_LONG_CONSTANT("ARES_T_NIMLOC", ns_t_nimloc
, CONST_CS
|CONST_PERSISTENT
);
1681 /* (33) Server Selection. */
1682 REGISTER_LONG_CONSTANT("ARES_T_SRV", ns_t_srv
, CONST_CS
|CONST_PERSISTENT
);
1683 /* (34) ATM Address */
1684 REGISTER_LONG_CONSTANT("ARES_T_ATMA", ns_t_atma
, CONST_CS
|CONST_PERSISTENT
);
1685 /* (35) Naming Authority PoinTeR */
1686 REGISTER_LONG_CONSTANT("ARES_T_NAPTR", ns_t_naptr
, CONST_CS
|CONST_PERSISTENT
);
1687 /* (36) Key Exchange */
1688 REGISTER_LONG_CONSTANT("ARES_T_KX", ns_t_kx
, CONST_CS
|CONST_PERSISTENT
);
1689 /* (37) Certification record */
1690 REGISTER_LONG_CONSTANT("ARES_T_CERT", ns_t_cert
, CONST_CS
|CONST_PERSISTENT
);
1691 /* (38) IPv6 address (deprecates AAAA) */
1692 REGISTER_LONG_CONSTANT("ARES_T_A6", ns_t_a6
, CONST_CS
|CONST_PERSISTENT
);
1693 /* (39) Non-terminal DNAME (for IPv6) */
1694 REGISTER_LONG_CONSTANT("ARES_T_DNAME", ns_t_dname
, CONST_CS
|CONST_PERSISTENT
);
1695 /* (40) Kitchen sink (experimentatl) */
1696 REGISTER_LONG_CONSTANT("ARES_T_SINK", ns_t_sink
, CONST_CS
|CONST_PERSISTENT
);
1697 /* (41) EDNS0 option (meta-RR) */
1698 REGISTER_LONG_CONSTANT("ARES_T_OPT", ns_t_opt
, CONST_CS
|CONST_PERSISTENT
);
1699 /* (250) Transaction signature. */
1700 REGISTER_LONG_CONSTANT("ARES_T_TSIG", ns_t_tsig
, CONST_CS
|CONST_PERSISTENT
);
1701 /* (251) Incremental zone transfer. */
1702 REGISTER_LONG_CONSTANT("ARES_T_IXFR", ns_t_ixfr
, CONST_CS
|CONST_PERSISTENT
);
1703 /* (252) Transfer zone of authority. */
1704 REGISTER_LONG_CONSTANT("ARES_T_AXFR", ns_t_axfr
, CONST_CS
|CONST_PERSISTENT
);
1705 /* (253) Transfer mailbox records. */
1706 REGISTER_LONG_CONSTANT("ARES_T_MAILB", ns_t_mailb
, CONST_CS
|CONST_PERSISTENT
);
1707 /* (254) Transfer mail agent records. */
1708 REGISTER_LONG_CONSTANT("ARES_T_MAILA", ns_t_maila
, CONST_CS
|CONST_PERSISTENT
);
1709 /* (255) Wildcard match. */
1710 REGISTER_LONG_CONSTANT("ARES_T_ANY", ns_t_any
, CONST_CS
|CONST_PERSISTENT
);
1713 * ns_c (dnsclass) constants (arpa/nameser.h)
1717 REGISTER_LONG_CONSTANT("ARES_C_IN", ns_c_in
, CONST_CS
|CONST_PERSISTENT
);
1718 /* (2) unallocated/unsupported. */
1719 /* REGISTER_LONG_CONSTANT("ARES_C_2", ns_c_2, CONST_CS|CONST_PERSISTENT); */
1720 /* (3) MIT Chaos-net. */
1721 REGISTER_LONG_CONSTANT("ARES_C_CHAOS", ns_c_chaos
, CONST_CS
|CONST_PERSISTENT
);
1722 /* (4) MIT Hesiod. */
1723 REGISTER_LONG_CONSTANT("ARES_C_HS", ns_c_hs
, CONST_CS
|CONST_PERSISTENT
);
1724 /* (254) for prereq. sections in update requests */
1725 /* REGISTER_LONG_CONSTANT("ARES_C_NONE", ns_c_none, CONST_CS|CONST_PERSISTENT); */
1726 /* (255) Wildcard match. */
1727 REGISTER_LONG_CONSTANT("ARES_C_ANY", ns_c_any
, CONST_CS
|CONST_PERSISTENT
);
1729 le_ares
= zend_register_list_destructors_ex(php_ares_le_dtor
, NULL
, PHP_ARES_LE_NAME
, module_number
);
1730 le_ares_query
= zend_register_list_destructors_ex(php_ares_query_le_dtor
, NULL
, PHP_ARES_QUERY_LE_NAME
, module_number
);
1736 /* {{{ PHP_MINFO_FUNCTION */
1737 static PHP_MINFO_FUNCTION(ares
)
1739 php_info_print_table_start();
1740 php_info_print_table_header(2, "AsyncResolver support", "enabled");
1741 php_info_print_table_end();
1743 php_info_print_table_start();
1744 php_info_print_table_header(3, "Used Library", "compiled", "linked");
1745 php_info_print_table_row(3,
1747 #ifdef ARES_VERSION_STR
1752 #ifdef HAVE_ARES_VERSION
1758 php_info_print_table_end();
1762 #ifdef ZEND_ENGINE_2
1763 ZEND_BEGIN_ARG_INFO(ai_ares_select
, 0)
1764 ZEND_ARG_PASS_INFO(1)
1765 ZEND_ARG_PASS_INFO(1)
1766 ZEND_ARG_PASS_INFO(0)
1767 ZEND_END_ARG_INFO();
1769 ZEND_BEGIN_ARG_INFO(ai_ares_result
, 0)
1770 ZEND_ARG_PASS_INFO(0)
1771 ZEND_ARG_PASS_INFO(1)
1772 ZEND_ARG_PASS_INFO(1)
1773 ZEND_END_ARG_INFO();
1775 ZEND_BEGIN_ARG_INFO(ai_ares_fds
, 0)
1776 ZEND_ARG_PASS_INFO(0)
1777 ZEND_ARG_PASS_INFO(1)
1778 ZEND_ARG_PASS_INFO(1)
1779 ZEND_END_ARG_INFO();
1781 static unsigned char ai_ares_select
[] = {3, BYREF_FORCE
, BYREF_FORCE
, BYREF_NONE
};
1782 static unsigned char ai_ares_result
[] = {4, BYREF_NONE
, BYREF_FORCE
, BYREF_FORCE
};
1783 static unsigned char ai_ares_fds
[] = {4, BYREF_NONE
, BYREF_FORCE
, BYREF_FORCE
};
1786 /* {{{ ares_functions[] */
1787 zend_function_entry ares_functions
[] = {
1788 #ifdef HAVE_ARES_VERSION
1789 PHP_FE(ares_version
, NULL
)
1791 PHP_FE(ares_init
, NULL
)
1792 PHP_FE(ares_destroy
, NULL
)
1793 PHP_FE(ares_strerror
, NULL
)
1794 #ifdef HAVE_ARES_CANCEL
1795 PHP_FE(ares_cancel
, NULL
)
1797 PHP_FE(ares_search
, NULL
)
1798 PHP_FE(ares_query
, NULL
)
1799 PHP_FE(ares_send
, NULL
)
1800 PHP_FE(ares_mkquery
, NULL
)
1801 PHP_FE(ares_gethostbyname
, NULL
)
1802 PHP_FE(ares_gethostbyaddr
, NULL
)
1803 #ifdef HAVE_ARES_GETNAMEINFO
1804 PHP_FE(ares_getnameinfo
, NULL
)
1806 PHP_FE(ares_result
, ai_ares_result
)
1807 PHP_FE(ares_packet
, NULL
)
1808 PHP_FE(ares_process_all
, NULL
)
1809 PHP_FE(ares_process_once
, NULL
)
1810 PHP_FE(ares_process
, NULL
)
1811 PHP_FE(ares_select
, ai_ares_select
)
1812 PHP_FE(ares_fds
, ai_ares_fds
)
1813 PHP_FE(ares_timeout
, NULL
)
1814 PHP_FE(ares_parse_a_reply
, NULL
)
1815 #ifdef HAVE_ARES_PARSE_AAAA_REPLY
1816 PHP_FE(ares_parse_aaaa_reply
, NULL
)
1818 PHP_FE(ares_parse_ptr_reply
, NULL
)
1819 PHP_FE(ares_expand_name
, NULL
)
1820 #ifdef HAVE_ARES_EXPAND_STRING
1821 PHP_FE(ares_expand_string
, NULL
)
1827 /* {{{ ares_module_entry */
1828 zend_module_entry ares_module_entry
= {
1829 STANDARD_MODULE_HEADER
,
1838 STANDARD_MODULE_PROPERTIES
1842 #ifdef COMPILE_DL_ARES
1843 ZEND_GET_MODULE(ares
)
1851 * vim600: noet sw=4 ts=4 fdm=marker
1852 * vim<600: noet sw=4 ts=4