export php function: fastcommon_is_private_ip

pull/5/head
yuqing 2015-10-10 11:30:35 +08:00
parent 0452a1a3e6
commit 21b1a0fae6
3 changed files with 33 additions and 1 deletions

View File

@ -1,9 +1,10 @@
Version 1.22 2015-10-09
Version 1.22 2015-10-10
* export php function: fastcommon_get_first_local_ip
* add function is_private_ip
* add function get_next_local_ip
* export php function: fastcommon_get_next_local_ip
* export php function: fastcommon_is_private_ip
Version 1.21 2015-09-14
* ini_file_reader support annotation function

View File

@ -44,6 +44,7 @@ const zend_fcall_info empty_fcall_info = { 0, NULL, NULL, NULL, NULL, 0, NULL, N
ZEND_FE(fastcommon_get_line_distance_km, NULL)
ZEND_FE(fastcommon_get_first_local_ip, NULL)
ZEND_FE(fastcommon_get_next_local_ip, NULL)
ZEND_FE(fastcommon_is_private_ip, NULL)
{NULL, NULL, NULL} /* Must be the last line */
};
@ -335,3 +336,32 @@ ZEND_FUNCTION(fastcommon_get_next_local_ip)
RETURN_STRING(next_ip , 1);
}
/*
string fastcommon_is_private_ip(string ip)
return true for private ip, otherwise false
*/
ZEND_FUNCTION(fastcommon_is_private_ip)
{
int argc;
int ip_len;
char *ip;
argc = ZEND_NUM_ARGS();
if (argc != 1) {
logError("file: "__FILE__", line: %d, "
"fastcommon_is_private_ip parameters count: %d is invalid",
__LINE__, argc);
RETURN_BOOL(false);
}
if (zend_parse_parameters(argc TSRMLS_CC, "s", &ip,
&ip_len) == FAILURE)
{
logError("file: "__FILE__", line: %d, "
"zend_parse_parameters fail!", __LINE__);
RETURN_BOOL(false);
}
RETURN_BOOL(is_private_ip(ip));
}

View File

@ -24,6 +24,7 @@ ZEND_FUNCTION(fastcommon_simple_hash);
ZEND_FUNCTION(fastcommon_get_line_distance_km);
ZEND_FUNCTION(fastcommon_get_first_local_ip);
ZEND_FUNCTION(fastcommon_get_next_local_ip);
ZEND_FUNCTION(fastcommon_is_private_ip);
#ifdef __cplusplus
}