xref: /PHP-7.4/ext/standard/php_dns.h (revision 45f52285)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) The PHP Group                                          |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Authors: The typical suspects                                        |
16    |          Marcus Boerger <helly@php.net>                              |
17    |          Pollita <pollita@php.net>                                   |
18    +----------------------------------------------------------------------+
19 */
20 
21 #ifndef PHP_DNS_H
22 #define PHP_DNS_H
23 
24 #if defined(HAVE_DNS_SEARCH)
25 #define php_dns_search(res, dname, class, type, answer, anslen) \
26     	((int)dns_search(res, dname, class, type, (char *) answer, anslen, (struct sockaddr *)&from, &fromsize))
27 #define php_dns_free_handle(res) \
28 		dns_free(res)
29 #define php_dns_errno(handle) h_errno
30 
31 #elif defined(HAVE_RES_NSEARCH)
32 #define php_dns_search(res, dname, class, type, answer, anslen) \
33 			res_nsearch(res, dname, class, type, answer, anslen);
34 #if HAVE_RES_NDESTROY
35 #define php_dns_free_handle(res) \
36 			res_ndestroy(res); \
37 			php_dns_free_res(res)
38 #else
39 #define php_dns_free_handle(res) \
40 			res_nclose(res); \
41 			php_dns_free_res(res)
42 #endif
43 #define php_dns_errno(handle) handle->res_h_errno
44 
45 #elif defined(HAVE_RES_SEARCH)
46 #define php_dns_search(res, dname, class, type, answer, anslen) \
47 			res_search(dname, class, type, answer, anslen)
48 #define php_dns_free_handle(res) /* noop */
49 #define php_dns_errno(handle) h_errno
50 
51 #endif
52 
53 #if defined(HAVE_DNS_SEARCH) || defined(HAVE_RES_NSEARCH) || defined(HAVE_RES_SEARCH)
54 #define HAVE_DNS_SEARCH_FUNC 1
55 #endif
56 
57 #if HAVE_DNS_SEARCH_FUNC && HAVE_DN_EXPAND && HAVE_DN_SKIPNAME
58 #define HAVE_FULL_DNS_FUNCS 1
59 #endif
60 
61 PHP_FUNCTION(gethostbyaddr);
62 PHP_FUNCTION(gethostbyname);
63 PHP_FUNCTION(gethostbynamel);
64 
65 #ifdef HAVE_GETHOSTNAME
66 PHP_FUNCTION(gethostname);
67 #endif
68 
69 #if defined(PHP_WIN32) || HAVE_DNS_SEARCH_FUNC
70 PHP_FUNCTION(dns_check_record);
71 
72 # if defined(PHP_WIN32) || HAVE_FULL_DNS_FUNCS
73 PHP_FUNCTION(dns_get_mx);
74 PHP_FUNCTION(dns_get_record);
75 PHP_MINIT_FUNCTION(dns);
76 # endif
77 
78 #endif /* defined(PHP_WIN32) || HAVE_DNS_SEARCH_FUNC */
79 
80 #ifndef INT16SZ
81 #define INT16SZ		2
82 #endif
83 
84 #ifndef INT32SZ
85 #define INT32SZ		4
86 #endif
87 
88 #endif /* PHP_DNS_H */
89