This repository has been archived by the owner on Jun 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kiyoshi.c
70 lines (59 loc) · 1.46 KB
/
kiyoshi.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
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "ext/standard/php_rand.h"
#include "php_kiyoshi.h"
PHP_FUNCTION(zundoko_kiyoshi)
{
zend_long required_zun = 4;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &required_zun) == FAILURE) {
return;
}
if (required_zun < 1) {
php_error_docref(NULL, E_WARNING,
"The first parameter must be a positive number, zero or negative given"
);
return;
}
if (!BG(mt_rand_is_seeded)) {
php_mt_srand(GENERATE_SEED());
}
size_t sum_zun = 0, is_zun = 0;
do {
sum_zun = is_zun ? sum_zun + 1 : 0;
is_zun = php_mt_rand() & 1;
php_printf("%s ", is_zun ? "ズン" : "ドコ");
} while (sum_zun < required_zun || is_zun);
php_printf("キ・ヨ・シ!\n");
}
PHP_MINFO_FUNCTION(kiyoshi)
{
php_info_print_table_start();
php_info_print_table_header(2, "kiyoshi support", "enabled");
php_info_print_table_end();
}
const zend_function_entry kiyoshi_functions[] = {
PHP_FE(zundoko_kiyoshi, NULL)
PHP_FE_END
};
zend_module_entry kiyoshi_module_entry = {
STANDARD_MODULE_HEADER,
"kiyoshi",
kiyoshi_functions,
NULL,
NULL,
NULL,
NULL,
PHP_MINFO(kiyoshi),
PHP_KIYOSHI_VERSION,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_KIYOSHI
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(kiyoshi)
#endif