-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.c
More file actions
98 lines (82 loc) · 2.11 KB
/
Copy pathhello.c
File metadata and controls
98 lines (82 loc) · 2.11 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "ext/standard/info.h"
#include "php_hello.h"
#include "hello_arginfo.h"
/* MACRO: For compatibility with older PHP versions */
#ifndef ZEND_PARSE_PARAMETERS_NONE
#define ZEND_PARSE_PARAMETERS_NONE() \
ZEND_PARSE_PARAMETERS_START(0, 0) \
ZEND_PARSE_PARAMETERS_END()
#endif
PHP_METHOD(Hello, __construct)
{
// ...
}
PHP_METHOD(Hello, message)
{
RETURN_STRING("Hello, World!");
}
PHP_METHOD(Hello, write)
{
char* message;
size_t message_length = sizeof(message) - 1;
zend_string* result;
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(message, message_length)
ZEND_PARSE_PARAMETERS_END();
result = strpprintf(0, "%s", message);
RETURN_STR(result);
}
PHP_METHOD(Hello, version)
{
RETURN_STRING(PHP_HELLO_VERSION);
}
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(hello)
{
register_class_Hello();
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RINIT_FUNCTION */
PHP_RINIT_FUNCTION(hello)
{
#if defined(ZTS) && defined(COMPILE_DL_HELLO)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(hello)
{
php_info_print_table_start();
php_info_print_table_header(2, "hello support", "enabled");
php_info_print_table_row(2, "version", PHP_HELLO_VERSION);
php_info_print_table_end();
}
/* }}} */
/* {{{ hello_module_entry */
zend_module_entry hello_module_entry = {
STANDARD_MODULE_HEADER, // Core: This MACRO fills in everything up to the 'deps' field
"hello", // Extension: Name
class_Hello_methods, // Core: Struct 'zend_function_entry'
PHP_MINIT(hello), // Core: PHP_MINIT (module initialization)
NULL, // Core: PHP_MSHUTDOWN (module shutdown)
PHP_RINIT(hello), // Core: PHP_RINIT (request initialization)
NULL, // Core: PHP_RSHUTDOWN (request shutdown0
PHP_MINFO(hello), // Core: PHP_MINFO (Module info)
PHP_HELLO_VERSION, // Extension: Version
STANDARD_MODULE_PROPERTIES // Core: This MACRO will fill in the rest of the structure
};
/* }}} */
#ifdef COMPILE_DL_HELLO
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(hello)
#endif