-
Notifications
You must be signed in to change notification settings - Fork 26
/
php_xxhash.c
82 lines (67 loc) · 1.41 KB
/
php_xxhash.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_xxhash.h"
#include "xxhash.c"
#ifdef COMPILE_DL_XXHASH
ZEND_GET_MODULE(xxhash)
#endif
PHP_MINIT_FUNCTION(xxhash)
{
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(xxhash)
{
return SUCCESS;
}
PHP_RINIT_FUNCTION(xxhash)
{
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(xxhash)
{
return SUCCESS;
}
PHP_MINFO_FUNCTION(xxhash)
{
php_info_print_table_start();
php_info_print_table_header(2, "xxhash support", "enabled");
php_info_print_table_row(2, "extension version", PHP_XXHASH_VERSION);
php_info_print_table_row(2, "xxhash release", "http://code.google.com/p/xxhash/source/detail?r=6");
php_info_print_table_end();
}
PHP_FUNCTION(xxhash32)
{
char *arg1 = NULL;
char *ret1 = NULL;
int arg1_len;
unsigned int sum;
/* parse the parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg1, &arg1_len) == FAILURE || arg1_len < 1)
{
RETURN_NULL();
}
/* compute the checksum */
sum = XXH32(arg1, arg1_len, 0);
/* return the checksum */
RETURN_LONG((long)sum);
}
zend_function_entry xxhash_functions[] = {
PHP_FE(xxhash32, NULL)
{NULL, NULL, NULL}
};
zend_module_entry xxhash_module_entry = {
STANDARD_MODULE_HEADER,
"xxhash",
xxhash_functions,
PHP_MINIT(xxhash),
PHP_MSHUTDOWN(xxhash),
NULL,
NULL,
PHP_MINFO(xxhash),
PHP_XXHASH_VERSION,
STANDARD_MODULE_PROPERTIES
};