php extention export simple_hash and time33_hash
parent
6bd2bc08ff
commit
83d45dde99
3
HISTORY
3
HISTORY
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
Version 1.13 2015-01-14
|
Version 1.13 2015-01-22
|
||||||
* support php extension
|
* support php extension
|
||||||
|
* php extention export simple_hash and time33_hash
|
||||||
|
|
||||||
Version 1.12 2014-12-05
|
Version 1.12 2014-12-05
|
||||||
* bug fixed: must check the return value of vsnprintf
|
* bug fixed: must check the return value of vsnprintf
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Name: libfastcommon
|
Name: libfastcommon
|
||||||
Version: 1.0.12
|
Version: 1.0.13
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: c common functions library extracted from my open source projects FastDFS
|
Summary: c common functions library extracted from my open source projects FastDFS
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "local_ip_func.h"
|
#include "local_ip_func.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "hash.h"
|
||||||
#include "sockopt.h"
|
#include "sockopt.h"
|
||||||
#include "fastcommon.h"
|
#include "fastcommon.h"
|
||||||
|
|
||||||
|
|
@ -37,6 +38,8 @@ const zend_fcall_info empty_fcall_info = { 0, NULL, NULL, NULL, NULL, 0, NULL, N
|
||||||
zend_function_entry fastcommon_functions[] = {
|
zend_function_entry fastcommon_functions[] = {
|
||||||
ZEND_FE(fastcommon_version, NULL)
|
ZEND_FE(fastcommon_version, NULL)
|
||||||
ZEND_FE(fastcommon_gethostaddrs, NULL)
|
ZEND_FE(fastcommon_gethostaddrs, NULL)
|
||||||
|
ZEND_FE(fastcommon_time33_hash, NULL)
|
||||||
|
ZEND_FE(fastcommon_simple_hash, NULL)
|
||||||
{NULL, NULL, NULL} /* Must be the last line */
|
{NULL, NULL, NULL} /* Must be the last line */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -177,3 +180,63 @@ ZEND_FUNCTION(fastcommon_gethostaddrs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
array fastcommon_time33_hash(string str)
|
||||||
|
return unsigned hash code
|
||||||
|
*/
|
||||||
|
ZEND_FUNCTION(fastcommon_time33_hash)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
char *str;
|
||||||
|
int str_len;
|
||||||
|
|
||||||
|
argc = ZEND_NUM_ARGS();
|
||||||
|
if (argc != 1) {
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"fastcommon_time33_hash parameters count: %d is invalid",
|
||||||
|
__LINE__, argc);
|
||||||
|
RETURN_BOOL(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = NULL;
|
||||||
|
if (zend_parse_parameters(argc TSRMLS_CC, "s", &str,
|
||||||
|
&str_len) == FAILURE)
|
||||||
|
{
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"zend_parse_parameters fail!", __LINE__);
|
||||||
|
RETURN_BOOL(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_LONG(Time33Hash(str, str_len));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
array fastcommon_simple_hash(string str)
|
||||||
|
return unsigned hash code
|
||||||
|
*/
|
||||||
|
ZEND_FUNCTION(fastcommon_simple_hash)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
char *str;
|
||||||
|
int str_len;
|
||||||
|
|
||||||
|
argc = ZEND_NUM_ARGS();
|
||||||
|
if (argc != 1) {
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"fastcommon_simple_hash parameters count: %d is invalid",
|
||||||
|
__LINE__, argc);
|
||||||
|
RETURN_BOOL(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = NULL;
|
||||||
|
if (zend_parse_parameters(argc TSRMLS_CC, "s", &str,
|
||||||
|
&str_len) == FAILURE)
|
||||||
|
{
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"zend_parse_parameters fail!", __LINE__);
|
||||||
|
RETURN_BOOL(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_LONG(simple_hash(str, str_len));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ PHP_MINFO_FUNCTION(fastcommon);
|
||||||
|
|
||||||
ZEND_FUNCTION(fastcommon_version);
|
ZEND_FUNCTION(fastcommon_version);
|
||||||
ZEND_FUNCTION(fastcommon_gethostaddrs);
|
ZEND_FUNCTION(fastcommon_gethostaddrs);
|
||||||
|
ZEND_FUNCTION(fastcommon_time33_hash);
|
||||||
|
ZEND_FUNCTION(fastcommon_simple_hash);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,7 @@
|
||||||
echo 'version: ' . fastcommon_version() . "\n";
|
echo 'version: ' . fastcommon_version() . "\n";
|
||||||
var_dump(fastcommon_gethostaddrs());
|
var_dump(fastcommon_gethostaddrs());
|
||||||
|
|
||||||
|
$s = 'this is a test.';
|
||||||
|
echo 'simple_hash: ' . fastcommon_simple_hash($s) . "\n";
|
||||||
|
echo 'time33_hash: ' . fastcommon_time33_hash($s) . "\n";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue