Files
awslabs_aws-crt-php/ext/crt.c
T
Justin Boswell 778eafcf05 Initial skeleton to make extension support CRT FFI API (#11)
* Fixed build issues with static CRT, separated ffi target

* Fixed makefile for test-ffi target
2021-02-22 15:55:15 -08:00

89 lines
1.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"
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;
}
/* awscrt_version */
ZEND_BEGIN_ARG_INFO(awscrt_version_arginfo, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(awscrt_version) {
static const char *version = "1.0.0-dev";
AWS_RETURN_STRING(version);
}
/* aws_crt_last_error() */
ZEND_BEGIN_ARG_INFO(aws_crt_last_error_arginfo, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(aws_crt_last_error) {
RETURN_LONG(aws_crt_last_error());
}
/* clang-format off */
const zend_function_entry awscrt_functions[] = {
PHP_FE(awscrt_version, awscrt_version_arginfo)
PHP_FE(aws_crt_last_error, aws_crt_last_error_arginfo)
PHP_FE_END
};
zend_module_entry awscrt_module_entry = {
STANDARD_MODULE_HEADER,
"awscrt",
awscrt_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};
/* clang-format on */
#ifdef COMPILE_DL_AWSCRT
ZEND_GET_MODULE(awscrt)
#endif