mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-18 10:07:12 +00:00
Added aws_error* functions to native extension (#12)
* Added aws_crt_error_str and test, removed awscrt_version test function * Added aws_crt_error_name * Added aws_crt_error_debug_str * Use PHP's own tools to generate arginfo * Only re-generate arginfo on php7+ * Added a definition for ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX for php5 * Ignore generated files for clang-format
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "api.h"
|
||||
|
||||
#include "awscrt_arginfo.h"
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(awscrt);
|
||||
|
||||
PHP_INI_BEGIN()
|
||||
@@ -41,34 +43,48 @@ static PHP_GINIT_FUNCTION(awscrt) {
|
||||
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
|
||||
};
|
||||
/* 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));
|
||||
}
|
||||
|
||||
zend_module_entry awscrt_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"awscrt",
|
||||
awscrt_functions, /* functions */
|
||||
ext_functions, /* functions */
|
||||
PHP_MINIT(awscrt),
|
||||
PHP_MSHUTDOWN(awscrt),
|
||||
NULL, /* RINIT */
|
||||
@@ -79,9 +95,8 @@ zend_module_entry awscrt_module_entry = {
|
||||
PHP_GINIT(awscrt),
|
||||
NULL, /* GSHUTDOWN */
|
||||
NULL, /* RPOSTSHUTDOWN */
|
||||
STANDARD_MODULE_PROPERTIES_EX};
|
||||
|
||||
/* clang-format on */
|
||||
STANDARD_MODULE_PROPERTIES_EX,
|
||||
};
|
||||
|
||||
#ifdef COMPILE_DL_AWSCRT
|
||||
ZEND_GET_MODULE(awscrt)
|
||||
|
||||
Reference in New Issue
Block a user