export php function: fastcommon_get_next_local_ip
parent
3a3abaf148
commit
0452a1a3e6
1
HISTORY
1
HISTORY
|
|
@ -3,6 +3,7 @@ Version 1.22 2015-10-09
|
||||||
* export php function: fastcommon_get_first_local_ip
|
* export php function: fastcommon_get_first_local_ip
|
||||||
* add function is_private_ip
|
* add function is_private_ip
|
||||||
* add function get_next_local_ip
|
* add function get_next_local_ip
|
||||||
|
* export php function: fastcommon_get_next_local_ip
|
||||||
|
|
||||||
Version 1.21 2015-09-14
|
Version 1.21 2015-09-14
|
||||||
* ini_file_reader support annotation function
|
* ini_file_reader support annotation function
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ const zend_fcall_info empty_fcall_info = { 0, NULL, NULL, NULL, NULL, 0, NULL, N
|
||||||
ZEND_FE(fastcommon_simple_hash, NULL)
|
ZEND_FE(fastcommon_simple_hash, NULL)
|
||||||
ZEND_FE(fastcommon_get_line_distance_km, NULL)
|
ZEND_FE(fastcommon_get_line_distance_km, NULL)
|
||||||
ZEND_FE(fastcommon_get_first_local_ip, NULL)
|
ZEND_FE(fastcommon_get_first_local_ip, NULL)
|
||||||
|
ZEND_FE(fastcommon_get_next_local_ip, NULL)
|
||||||
{NULL, NULL, NULL} /* Must be the last line */
|
{NULL, NULL, NULL} /* Must be the last line */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -294,3 +295,43 @@ ZEND_FUNCTION(fastcommon_get_first_local_ip)
|
||||||
RETURN_STRING(get_first_local_ip(), 1);
|
RETURN_STRING(get_first_local_ip(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
string fastcommon_get_next_local_ip(string previous_ip)
|
||||||
|
return the next local ip, false for fail
|
||||||
|
*/
|
||||||
|
ZEND_FUNCTION(fastcommon_get_next_local_ip)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
int previous_len;
|
||||||
|
char *previous_ip;
|
||||||
|
const char *next_ip;
|
||||||
|
|
||||||
|
argc = ZEND_NUM_ARGS();
|
||||||
|
if (argc != 1) {
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"fastcommon_get_next_local_ip parameters count: %d is invalid",
|
||||||
|
__LINE__, argc);
|
||||||
|
RETURN_BOOL(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zend_parse_parameters(argc TSRMLS_CC, "s", &previous_ip,
|
||||||
|
&previous_len) == FAILURE)
|
||||||
|
{
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"zend_parse_parameters fail!", __LINE__);
|
||||||
|
RETURN_BOOL(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous_len == 0)
|
||||||
|
{
|
||||||
|
previous_ip = NULL;
|
||||||
|
}
|
||||||
|
next_ip = get_next_local_ip(previous_ip);
|
||||||
|
if (next_ip == NULL)
|
||||||
|
{
|
||||||
|
RETURN_BOOL(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_STRING(next_ip , 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ ZEND_FUNCTION(fastcommon_time33_hash);
|
||||||
ZEND_FUNCTION(fastcommon_simple_hash);
|
ZEND_FUNCTION(fastcommon_simple_hash);
|
||||||
ZEND_FUNCTION(fastcommon_get_line_distance_km);
|
ZEND_FUNCTION(fastcommon_get_line_distance_km);
|
||||||
ZEND_FUNCTION(fastcommon_get_first_local_ip);
|
ZEND_FUNCTION(fastcommon_get_first_local_ip);
|
||||||
|
ZEND_FUNCTION(fastcommon_get_next_local_ip);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Name: php-fastcommon
|
Name: php-fastcommon
|
||||||
Version: 1.0.2
|
Version: 1.0.3
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: The php extension for libfastcommon
|
Summary: The php extension for libfastcommon
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
@ -9,8 +9,8 @@ Source: http://perso.orange.fr/sebastien.godard/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
|
|
||||||
BuildRequires: libfastcommon >= 1.0.21
|
BuildRequires: libfastcommon-devel >= 1.0.22
|
||||||
Requires: libfastcommon >= 1.0.21
|
Requires: libfastcommon >= 1.0.22
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This package provides the php extension for libfastcommon
|
This package provides the php extension for libfastcommon
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,10 @@ $s = 'this is a test.';
|
||||||
echo 'simple_hash: ' . fastcommon_simple_hash($s) . "\n";
|
echo 'simple_hash: ' . fastcommon_simple_hash($s) . "\n";
|
||||||
echo 'time33_hash: ' . fastcommon_time33_hash($s) . "\n";
|
echo 'time33_hash: ' . fastcommon_time33_hash($s) . "\n";
|
||||||
|
|
||||||
|
echo 'first local ip: ' . fastcommon_get_first_local_ip() . "\n";
|
||||||
|
|
||||||
|
$next_ip = null;
|
||||||
|
while (($next_ip=fastcommon_get_next_local_ip($next_ip)))
|
||||||
|
{
|
||||||
|
echo "next local ip: $next_ip\n";
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue