-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathext_nbt.cpp
More file actions
138 lines (124 loc) · 3.31 KB
/
Copy pathext_nbt.cpp
File metadata and controls
138 lines (124 loc) · 3.31 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* This file is part of ext-nbt.
* Native C++23 port of pmmp/nbt <https://github.com/pmmp/NBT> @ 7817474
*
* ext-nbt is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
extern "C" {
#include "php.h"
#include "ext/standard/info.h"
#include "php_ext_nbt.h" //this one has to be C always, so the engine can understand it
}
#if PHP_VERSION_ID < 80200
# error "ext-nbt requires PHP 8.2 or later"
#endif
#include "src/PhpClasses.h"
ZEND_DECLARE_MODULE_GLOBALS(ext_nbt)
static PHP_GINIT_FUNCTION(ext_nbt)
{
#if defined(ZTS) && defined(COMPILE_DL_EXT_NBT)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
ext_nbt_globals->ce_BinaryStream = NULL;
ext_nbt_globals->ce_BinaryDataException = NULL;
ext_nbt_globals->lookups_done_BinaryStream = false;
ext_nbt_globals->lookups_done_BinaryDataException = false;
ext_nbt_globals->stream_fns_cache_inited = false;
}
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(ext_nbt)
{
#if defined(ZTS) && defined(COMPILE_DL_EXT_NBT)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
REGISTER_STRING_CONSTANT("EXT_NBT_VERSION", (char *) PHP_EXT_NBT_VERSION, CONST_CS | CONST_PERSISTENT);
nbt_register_exceptions();
nbt_register_interfaces();
nbt_register_tag();
nbt_register_int_tags();
nbt_register_float_tags();
nbt_register_string_tags();
nbt_register_list_tag();
nbt_register_compound_tag();
nbt_register_nbt();
nbt_register_tree_root();
nbt_register_reader_tracker();
nbt_register_serializers();
nbt_register_network_serializer();
nbt_register_json_nbt_parser();
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(ext_nbt)
{
#if defined(ZTS) && defined(COMPILE_DL_EXT_NBT)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
/* userland CE pointers and dispatch tables are only valid within one
* request (ZTS: within one thread) — reset the lazy caches */
NBT_G(ce_BinaryStream) = NULL;
NBT_G(ce_BinaryDataException) = NULL;
NBT_G(lookups_done_BinaryStream) = false;
NBT_G(lookups_done_BinaryDataException) = false;
NBT_G(stream_fns_cache_inited) = false;
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(ext_nbt)
{
if (NBT_G(stream_fns_cache_inited)) {
zend_hash_destroy(&NBT_G(stream_fns_cache));
NBT_G(stream_fns_cache_inited) = false;
}
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(ext_nbt)
{
php_info_print_table_start();
php_info_print_table_header(2, "ext_nbt support", "enabled");
php_info_print_table_row(2, "ext_nbt version", PHP_EXT_NBT_VERSION);
php_info_print_table_row(2, "provides", "pocketmine\\nbt (native port of pmmp/nbt)");
php_info_print_table_end();
}
/* }}} */
/* {{{ ext_nbt_module_entry
*/
zend_module_entry ext_nbt_module_entry = {
STANDARD_MODULE_HEADER,
"ext_nbt",
NULL,
PHP_MINIT(ext_nbt),
NULL, /* MSHUTDOWN */
PHP_RINIT(ext_nbt),
PHP_RSHUTDOWN(ext_nbt),
PHP_MINFO(ext_nbt),
PHP_EXT_NBT_VERSION,
PHP_MODULE_GLOBALS(ext_nbt),
PHP_GINIT(ext_nbt),
NULL, /* GSHUTDOWN */
NULL, /* post deactivate */
STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
#ifdef COMPILE_DL_EXT_NBT
extern "C" {
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(ext_nbt)
}
#endif