-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraklib_ipc.cpp
More file actions
106 lines (93 loc) · 2.46 KB
/
Copy pathraklib_ipc.cpp
File metadata and controls
106 lines (93 loc) · 2.46 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
/*
* This file is part of ext-raklib-ipc.
* Native C++23 port of pmmp/raklib-ipc <https://github.com/pmmp/RakLibIpc>
*
* ext-raklib-ipc is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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_raklib_ipc.h" //this one has to be C always, so the engine can understand it
}
#if PHP_VERSION_ID < 80200
# error "ext-raklib-ipc requires PHP 8.2 or later"
#endif
#include "src/PhpChannels.h"
#include "src/PhpUserToRakLib.h"
#include "src/PhpRakLibToUser.h"
/*
* Phase 2: full native port of pmmp/raklib-ipc. Depends on ext-raklib for the shared
* interfaces (ServerInterface/ServerEventSource/ServerEventListener) and EncapsulatedPacket.
* See stubs/ for the exact PHP-visible API contract and lib/ItcProtocol.h for the codec.
*/
static const zend_module_dep raklib_ipc_deps[] = {
ZEND_MOD_REQUIRED("raklib")
ZEND_MOD_END
};
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(raklib_ipc)
{
#if defined(ZTS) && defined(COMPILE_DL_RAKLIB_IPC)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
REGISTER_STRING_CONSTANT("RAKLIB_IPC_EXTENSION_VERSION", (char *) PHP_RAKLIB_IPC_VERSION, CONST_CS | CONST_PERSISTENT);
if (raklib_ipc_register_channels() == FAILURE) {
return FAILURE;
}
raklib_ipc_register_user_to_raklib();
raklib_ipc_register_raklib_to_user();
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(raklib_ipc)
{
#if defined(ZTS) && defined(COMPILE_DL_RAKLIB_IPC)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(raklib_ipc)
{
php_info_print_table_start();
php_info_print_table_header(2, "raklib_ipc support", "enabled");
php_info_print_table_row(2, "raklib_ipc version", PHP_RAKLIB_IPC_VERSION);
php_info_print_table_end();
}
/* }}} */
/* {{{ raklib_ipc_module_entry
*/
zend_module_entry raklib_ipc_module_entry = {
STANDARD_MODULE_HEADER_EX,
NULL,
raklib_ipc_deps,
"raklib_ipc",
NULL,
PHP_MINIT(raklib_ipc),
NULL, /* MSHUTDOWN */
PHP_RINIT(raklib_ipc),
NULL, /* RSHUTDOWN */
PHP_MINFO(raklib_ipc),
PHP_RAKLIB_IPC_VERSION,
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_RAKLIB_IPC
extern "C" {
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(raklib_ipc)
}
#endif