Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"analyzeSourceFiles": true
}
},
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default-tasks-runner"
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
Expand Down
28 changes: 27 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"fs-extra": "11.1.1",
"ini": "4.1.2",
"jsonc-parser": "3.3.1",
"node-machine-id": "1.1.12",
"octokit": "3.1.2",
"pako": "1.0.10",
"ps-man": "1.1.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ PHP_FUNCTION(post_message_to_js)
char *data;
int data_len;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &data, &data_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) {
return;
}

char *response;
size_t response_len = js_module_onMessage(data, &response);
if (response_len != -1) {
if (response_len != (size_t)-1) {
#if PHP_MAJOR_VERSION >= 7
zend_string *return_string = zend_string_init(response, response_len, 0);
free(response);
RETURN_NEW_STR(return_string);
#else
RETVAL_STRINGL(response, response_len, 1);
free(response);
return;
#endif
} else {
RETURN_NULL();
}
Expand Down
33 changes: 27 additions & 6 deletions packages/php-wasm/compile/php-wasm-dns-polyfill/dns_polyfill.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,27 @@ PHP_FUNCTION(dns_check_record)
HEADER *hp;
querybuf answer = {0};
char *hostname;
#if PHP_MAJOR_VERSION >= 7
size_t hostname_len;
size_t rectype_len = 0;
zend_string *rectype = NULL;
#else
int hostname_len;
int rectype_len = 0;
char *rectype = NULL;
#endif
int type = DNS_T_MX, i;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &hostname, &hostname_len, &rectype, &rectype_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &hostname, &hostname_len, &rectype, &rectype_len) == FAILURE) {
return;
}

if (hostname_len == 0) {
php_error_docref(NULL, E_WARNING, "Host cannot be empty");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host cannot be empty");
RETURN_FALSE;
}

php_error_docref(NULL, E_WARNING, "dns_check_record() always returns false in PHP.wasm.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "dns_check_record() always returns false in PHP.wasm.");

RETURN_FALSE;
}
Expand All @@ -143,8 +149,13 @@ PHP_FUNCTION(dns_check_record)
PHP_FUNCTION(dns_get_record)
{
char *hostname;
#if PHP_MAJOR_VERSION >= 7
size_t hostname_len;
zend_long type_param = PHP_DNS_ANY;
#else
int hostname_len;
long type_param = PHP_DNS_ANY;
#endif
zval *authns = NULL, *addtl = NULL;
int type_to_fetch;
int dns_errno;
Expand All @@ -155,7 +166,7 @@ PHP_FUNCTION(dns_get_record)
int type, first_query = 1, store_results = 1;
zend_bool raw = 0;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lz!z!b",
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz!z!b",
&hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) {
return;
}
Expand All @@ -173,7 +184,7 @@ PHP_FUNCTION(dns_get_record)
}
}

php_error_docref(NULL, E_WARNING, "dns_get_record() always returns an empty array in PHP.wasm.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "dns_get_record() always returns an empty array in PHP.wasm.");

/* Initialize the return array */
array_init(return_value);
Expand All @@ -186,7 +197,11 @@ PHP_FUNCTION(dns_get_record)
PHP_FUNCTION(dns_get_mx)
{
char *hostname;
#if PHP_MAJOR_VERSION >= 7
size_t hostname_len;
#else
int hostname_len;
#endif
zval *mx_list, *weight_list = NULL;
int count, qdc;
u_short type, weight;
Expand All @@ -196,12 +211,18 @@ PHP_FUNCTION(dns_get_mx)
uint8_t *cp, *end;
int i;

#if PHP_MAJOR_VERSION >= 7
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STRING(hostname, hostname_len)
Z_PARAM_ZVAL(mx_list)
Z_PARAM_OPTIONAL
Z_PARAM_ZVAL(weight_list)
ZEND_PARSE_PARAMETERS_END();
#else
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) {
return;
}
#endif

array_init(mx_list);
if (!mx_list) {
Expand All @@ -215,7 +236,7 @@ PHP_FUNCTION(dns_get_mx)
}
}

php_error_docref(NULL, E_WARNING, "dns_get_mx() always returns an empty array in PHP.wasm.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "dns_get_mx() always returns an empty array in PHP.wasm.");

RETURN_FALSE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "Zend/zend_alloc.h"
#include "php_wasm_memory_storage.h"

#if PHP_MAJOR_VERSION >= 7

/**
* Allocate a chunk of memory.
*
Expand Down Expand Up @@ -112,6 +114,22 @@ PHP_MSHUTDOWN_FUNCTION(wasm_memory_storage)
return SUCCESS;
}

#else /* PHP < 7 */

/* Custom memory storage is not available in PHP 5.x.
* Provide no-op MINIT/MSHUTDOWN. */
PHP_MINIT_FUNCTION(wasm_memory_storage)
{
return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(wasm_memory_storage)
{
return SUCCESS;
}

#endif /* PHP_MAJOR_VERSION >= 7 */

/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(wasm_memory_storage)
{
Expand Down
Loading
Loading