Ruslan Osmanov avatar Ruslan Osmanov committed c410ada

Add: some new evdns functions

Comments (0)

Files changed (3)

 }
 /* }}} */
 
+/* {{{ proto bool evdns_base_nameserver_ip_add(resource dns_base, string ip);
+ * Adds a nameserver to an existing evdns_base. It takes the nameserver in a
+ * text string, either as an IPv4 address, an IPv6 address, an IPv4 address
+ * with a port (IPv4:Port), or an IPv6 address with a port ([IPv6]:Port).
+ */
+PHP_FUNCTION(evdns_base_nameserver_ip_add)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base;
+	char                 *ip;
+	int                   ip_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs",
+				&zdns_base, &ip, &ip_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	if (evdns_base_nameserver_ip_add(dnsb->dns_base, ip)) {
+		RETURN_FALSE;
+	}
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool evdns_base_load_hosts(resource dns_base, string hosts);
+ *  Loads a hosts file (in the same format as /etc/hosts) from hosts file
+ */
+PHP_FUNCTION(evdns_base_load_hosts)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base;
+	char                 *hosts;
+	int                   hosts_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs",
+				&zdns_base, &hosts, &hosts_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	if (evdns_base_load_hosts(dnsb->dns_base, hosts)) {
+		RETURN_FALSE;
+	}
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto void evdns_base_search_clear(resource dns_base);
+ * Removes all current search suffixes (as configured by the search option)
+ * from the evdns_base; the evdns_base_search_add() function adds a suffix
+ */
+PHP_FUNCTION(evdns_base_search_clear)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r",
+				&zdns_base) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	evdns_base_search_clear(dnsb->dns_base);
+}
+/* }}} */
+
+/* {{{ proto void evdns_base_search_add(resource dns_base, string domain);
+ */
+PHP_FUNCTION(evdns_base_search_add)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base;
+	char                 *domain;
+	int                   domain_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs",
+				&zdns_base, &domain, &domain_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	evdns_base_search_add(dnsb->dns_base, domain);
+}
+/* }}} */
+
+/* {{{ proto void evdns_base_search_ndots_set(resource dns_base, int ndots);
+ */
+PHP_FUNCTION(evdns_base_search_ndots_set)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base;
+	long                  ndots;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs",
+				&zdns_base, &ndots) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	evdns_base_search_ndots_set(dnsb->dns_base, ndots);
+}
+/* }}} */
+
+/* {{{ proto bool evdns_base_set_option(resource dns_base, string option, string value);
+ */
+PHP_FUNCTION(evdns_base_set_option)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base;
+	char                 *option;
+	int                   option_len;
+	char                 *value;
+	int                   value_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss",
+				&zdns_base, &option, &option_len, &value, &value_len) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	if (evdns_base_set_option(dnsb->dns_base, option, value)) {
+		RETURN_FALSE;
+	}
+	RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int evdns_base_count_nameservers(resource dns_base);
+ */
+PHP_FUNCTION(evdns_base_count_nameservers)
+{
+	php_event_dns_base_t *dnsb;
+	zval                 *zdns_base;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r",
+				&zdns_base) == FAILURE) {
+		return;
+	}
+
+	PHP_EVENT_FETCH_DNS_BASE(dnsb, zdns_base);
+
+	RETURN_LONG(evdns_base_count_nameservers(dnsb->dns_base));
+}
+/* }}} */
 
 
 /* {{{ proto resource evconnlistener_new_bind(resource base, callable cb, mixed data, int flags, int backlog, string addr);
 	ZEND_ARG_INFO(0, initialize)
 ZEND_END_ARG_INFO();
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_resolv_conf_parse, 0, 0, 3)
+	ZEND_ARG_INFO(0, dns_base)
+	ZEND_ARG_INFO(0, flags)
+	ZEND_ARG_INFO(0, filename)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_nameserver_ip_add, 0, 0, 2)
+	ZEND_ARG_INFO(0, dns_base)
+	ZEND_ARG_INFO(0, ip)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_load_hosts, 0, 0, 2)
+	ZEND_ARG_INFO(0, dns_base)
+	ZEND_ARG_INFO(0, hosts)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_search_add, 0, 0, 2)
+	ZEND_ARG_INFO(0, dns_base)
+	ZEND_ARG_INFO(0, domain)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_search_ndots_set, 0, 0, 2)
+	ZEND_ARG_INFO(0, dns_base)
+	ZEND_ARG_INFO(0, ndots)
+ZEND_END_ARG_INFO();
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_evdns_base_set_option, 0, 0, 3)
+	ZEND_ARG_INFO(0, dns_base)
+	ZEND_ARG_INFO(0, option)
+	ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO();
+
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener_1, 0, 0, 1)
 	ZEND_ARG_INFO(0, listener)
 ZEND_END_ARG_INFO();
 #if HAVE_EVENT_EXTRA_LIB
 /* {{{ Extra API */
 
-	PHP_FE(evdns_base_new,  arginfo_evdns_base_new)
-	PHP_FE(evdns_base_free, arginfo_evdns_base_1)
+	PHP_FE(evdns_base_new,               arginfo_evdns_base_new)
+	PHP_FE(evdns_base_free,              arginfo_evdns_base_1)
+	PHP_FE(evdns_base_resolv_conf_parse, arginfo_evdns_resolv_conf_parse)
+	PHP_FE(evdns_base_nameserver_ip_add, arginfo_evdns_base_nameserver_ip_add)
+	PHP_FE(evdns_base_load_hosts,        arginfo_evdns_base_load_hosts)
+	PHP_FE(evdns_base_search_clear,      arginfo_evdns_base_1)
+	PHP_FE(evdns_base_search_add,        arginfo_evdns_base_search_add)
+	PHP_FE(evdns_base_search_ndots_set,  arginfo_evdns_base_search_ndots_set)
+	PHP_FE(evdns_base_set_option,        arginfo_evdns_base_set_option)
+	PHP_FE(evdns_base_count_nameservers, arginfo_evdns_base_1)
 
 	PHP_FE(evconnlistener_new,          arginfo_evconnlistener_new)
 	PHP_FE(evconnlistener_new_bind,     arginfo_evconnlistener_new_bind)
 
 PHP_FUNCTION(evdns_base_new);
 PHP_FUNCTION(evdns_base_free);
+PHP_FUNCTION(evdns_base_resolv_conf_parse);
+PHP_FUNCTION(evdns_base_nameserver_ip_add);
+PHP_FUNCTION(evdns_base_load_hosts);
+PHP_FUNCTION(evdns_base_search_clear);
+PHP_FUNCTION(evdns_base_search_add);
+PHP_FUNCTION(evdns_base_search_ndots_set);
+PHP_FUNCTION(evdns_base_set_option);
+PHP_FUNCTION(evdns_base_count_nameservers);
 
 PHP_FUNCTION(evconnlistener_new);
 PHP_FUNCTION(evconnlistener_new_bind);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.