mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-17 17:47:12 +00:00
126 lines
2.8 KiB
C
126 lines
2.8 KiB
C
|
|
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include "php_aws_crt.h"
|
|
|
|
#include "api.h"
|
|
|
|
#include "awscrt_arginfo.h"
|
|
|
|
ZEND_DECLARE_MODULE_GLOBALS(awscrt);
|
|
|
|
PHP_INI_BEGIN()
|
|
STD_PHP_INI_ENTRY(
|
|
"awscrt.log_level",
|
|
"",
|
|
PHP_INI_ALL,
|
|
OnUpdateLongGEZero,
|
|
log_level,
|
|
zend_awscrt_globals,
|
|
awscrt_globals)
|
|
PHP_INI_END()
|
|
|
|
static PHP_MINIT_FUNCTION(awscrt) {
|
|
REGISTER_INI_ENTRIES();
|
|
|
|
aws_crt_init();
|
|
return SUCCESS;
|
|
}
|
|
|
|
static PHP_MSHUTDOWN_FUNCTION(awscrt) {
|
|
UNREGISTER_INI_ENTRIES();
|
|
aws_crt_clean_up();
|
|
return SUCCESS;
|
|
}
|
|
|
|
static PHP_GINIT_FUNCTION(awscrt) {
|
|
#if defined(COMPILE_DL_ASTKIT) && defined(ZTS)
|
|
ZEND_TSRMLS_CACHE_UPDATE();
|
|
#endif
|
|
awscrt_globals->log_level = 0;
|
|
}
|
|
|
|
/* aws_crt_last_error() */
|
|
PHP_FUNCTION(aws_crt_last_error) {
|
|
RETURN_LONG(aws_crt_last_error());
|
|
}
|
|
|
|
/* aws_crt_error_str(int error_code) */
|
|
PHP_FUNCTION(aws_crt_error_str) {
|
|
zend_ulong error_code = 0;
|
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error_code) == FAILURE) {
|
|
RETURN_NULL();
|
|
}
|
|
|
|
AWS_RETURN_STRING(aws_crt_error_str(error_code));
|
|
}
|
|
|
|
/* aws_crt_error_name(int error_code) */
|
|
PHP_FUNCTION(aws_crt_error_name) {
|
|
zend_ulong error_code = 0;
|
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error_code) == FAILURE) {
|
|
RETURN_NULL();
|
|
}
|
|
|
|
AWS_RETURN_STRING(aws_crt_error_name(error_code));
|
|
}
|
|
|
|
/* aws_crt_error_debug_str(int error_code) */
|
|
PHP_FUNCTION(aws_crt_error_debug_str) {
|
|
zend_ulong error_code = 0;
|
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error_code) == FAILURE) {
|
|
RETURN_NULL();
|
|
}
|
|
|
|
AWS_RETURN_STRING(aws_crt_error_debug_str(error_code));
|
|
}
|
|
|
|
PHP_FUNCTION(aws_crt_event_loop_group_new) {
|
|
zend_ulong num_threads = 0;
|
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num_threads) == FAILURE) {
|
|
RETURN_NULL();
|
|
}
|
|
|
|
struct aws_event_loop_group *elg = aws_crt_event_loop_group_new(num_threads);
|
|
RETURN_LONG((zend_ulong)elg);
|
|
}
|
|
|
|
PHP_FUNCTION(aws_crt_event_loop_group_release) {
|
|
zend_ulong php_elg = 0;
|
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_elg) == FAILURE) {
|
|
return;
|
|
}
|
|
|
|
struct aws_event_loop_group *elg = (void *)php_elg;
|
|
aws_crt_event_loop_group_release(elg);
|
|
}
|
|
|
|
zend_module_entry awscrt_module_entry = {
|
|
STANDARD_MODULE_HEADER,
|
|
"awscrt",
|
|
ext_functions, /* functions */
|
|
PHP_MINIT(awscrt),
|
|
PHP_MSHUTDOWN(awscrt),
|
|
NULL, /* RINIT */
|
|
NULL, /* RSHUTDOWN */
|
|
NULL, /* MINFO */
|
|
NO_VERSION_YET,
|
|
PHP_MODULE_GLOBALS(awscrt),
|
|
PHP_GINIT(awscrt),
|
|
NULL, /* GSHUTDOWN */
|
|
NULL, /* RPOSTSHUTDOWN */
|
|
STANDARD_MODULE_PROPERTIES_EX,
|
|
};
|
|
|
|
#ifdef COMPILE_DL_AWSCRT
|
|
ZEND_GET_MODULE(awscrt)
|
|
#endif
|