summaryrefslogtreecommitdiff
path: root/vendor/aws/aws-crt-php/ext
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/aws/aws-crt-php/ext')
-rw-r--r--vendor/aws/aws-crt-php/ext/.gitignore2
-rw-r--r--vendor/aws/aws-crt-php/ext/awscrt.c17
-rw-r--r--vendor/aws/aws-crt-php/ext/awscrt.stub.php88
-rw-r--r--vendor/aws/aws-crt-php/ext/awscrt_arginfo.h413
-rw-r--r--vendor/aws/aws-crt-php/ext/crc.c32
-rw-r--r--vendor/aws/aws-crt-php/ext/credentials.c154
-rw-r--r--vendor/aws/aws-crt-php/ext/crt.c314
-rw-r--r--vendor/aws/aws-crt-php/ext/event_loop.c48
-rw-r--r--vendor/aws/aws-crt-php/ext/http.c36
-rw-r--r--vendor/aws/aws-crt-php/ext/logging.c65
-rw-r--r--vendor/aws/aws-crt-php/ext/php_aws_crt.h171
-rw-r--r--vendor/aws/aws-crt-php/ext/php_util.c33
-rw-r--r--vendor/aws/aws-crt-php/ext/signing.c374
-rw-r--r--vendor/aws/aws-crt-php/ext/stream.c148
14 files changed, 1895 insertions, 0 deletions
diff --git a/vendor/aws/aws-crt-php/ext/.gitignore b/vendor/aws/aws-crt-php/ext/.gitignore
new file mode 100644
index 0000000..2973c97
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/.gitignore
@@ -0,0 +1,2 @@
+*.so
+api.h
diff --git a/vendor/aws/aws-crt-php/ext/awscrt.c b/vendor/aws/aws-crt-php/ext/awscrt.c
new file mode 100644
index 0000000..0ee0f74
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/awscrt.c
@@ -0,0 +1,17 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/* This is a unity-build style source file, as PHP's build system is simplest with 1 source file per extension */
+
+#include "credentials.c"
+#include "crt.c"
+#include "event_loop.c"
+#include "http.c"
+#include "signing.c"
+#include "stream.c"
+// #include "hash.c"
+#include "crc.c"
+#include "logging.c"
+#include "php_util.c"
diff --git a/vendor/aws/aws-crt-php/ext/awscrt.stub.php b/vendor/aws/aws-crt-php/ext/awscrt.stub.php
new file mode 100644
index 0000000..5a8d837
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/awscrt.stub.php
@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * @generate-class-entries
+ * @generate-function-entries
+*/
+
+function aws_crt_last_error(): int {}
+function aws_crt_error_name(int $error_code): string {}
+function aws_crt_error_str(int $error_code): string {}
+function aws_crt_error_debug_str(int $error_code): string {}
+
+function aws_crt_log_to_stdout(): void {}
+function aws_crt_log_to_stderr(): void {}
+function aws_crt_log_to_file(string $filename): void {}
+function aws_crt_log_to_stream(object $stream): void {}
+function aws_crt_log_stop(): void {}
+function aws_crt_log_set_level(int $level): void {}
+function aws_crt_log_message(string $message): void {}
+
+function aws_crt_event_loop_group_options_new(): int {}
+function aws_crt_event_loop_group_options_release(int $elg_options): void {}
+function aws_crt_event_loop_group_options_set_max_threads(int $elg_options, int $max_threads): void {}
+function aws_crt_event_loop_group_new(object $options): object {}
+function aws_crt_event_loop_group_release(object $event_loop_group): void {}
+
+function aws_crt_input_stream_options_new(): object {}
+function aws_crt_input_stream_options_release(object $options): void {}
+function aws_crt_input_stream_options_set_user_data(object $options, object $user_data): void {}
+function aws_crt_input_stream_new(object $options): object {}
+function aws_crt_input_stream_release(int $stream): void {}
+function aws_crt_input_stream_seek(int $stream, int $offset, int $basis): int {}
+function aws_crt_input_stream_read(int $stream, int $length): string {}
+function aws_crt_input_stream_eof(int $stream): bool {}
+function aws_crt_input_stream_get_length(int $stream): int {}
+
+function aws_crt_http_message_new_from_blob(string $blob): int {}
+function aws_crt_http_message_to_blob(int $message): string {}
+function aws_crt_http_message_release(int $message): void {}
+
+function aws_crt_credentials_options_new(): object {}
+function aws_crt_credentials_options_release(object $options): void {}
+function aws_crt_credentials_options_set_access_key_id(object $options, string $access_key_id): void {}
+function aws_crt_credentials_options_set_secret_access_key(object $options, string $secret_access_key): void {}
+function aws_crt_credentials_options_set_session_token(object $options, string $session_token): void {}
+function aws_crt_credentials_options_set_expiration_timepoint_seconds(object $options, int $expiration_timepoint_seconds): void {}
+
+function aws_crt_credentials_new(object $options): object {}
+function aws_crt_credentials_release(object $credentials): void {}
+
+function aws_crt_credentials_provider_release(int $credentials): void {}
+
+function aws_crt_credentials_provider_static_options_new(): object {}
+function aws_crt_credentials_provider_static_options_release(object $options): void {}
+function aws_crt_credentials_provider_static_options_set_access_key_id(object $options, string $access_key_id): void {}
+function aws_crt_credentials_provider_static_options_set_secret_access_key(object $options, string $secret_access_key): void {}
+function aws_crt_credentials_provider_static_options_set_session_token(object $options, string $session_token): void {}
+function aws_crt_credentials_provider_static_new(object $options): object {}
+
+function aws_crt_signing_config_aws_new(): int {}
+function aws_crt_signing_config_aws_release(int $config): void {}
+function aws_crt_signing_config_aws_set_algorithm(int $config, int $algorithm): void {}
+function aws_crt_signing_config_aws_set_signature_type(int $config, int $signature_type): void {}
+function aws_crt_signing_config_aws_set_credentials_provider(int $config, int $credentials_provider): void {}
+function aws_crt_signing_config_aws_set_region(int $config, string $region): void {}
+function aws_crt_signing_config_aws_set_service(int $config, string $service): void {}
+function aws_crt_signing_config_aws_set_use_double_uri_encode(int $config, bool $use_double_uri_encode): void {}
+function aws_crt_signing_config_aws_set_should_normalize_uri_path(int $config, bool $should_normalize_uri_path): void {}
+function aws_crt_signing_config_aws_set_omit_session_token(int $config, bool $omit_session_token): void {}
+function aws_crt_signing_config_aws_set_signed_body_value(int $config, string $signed_body_value): void {}
+function aws_crt_signing_config_aws_set_signed_body_header_type(int $config, int $signed_body_header_type): void {}
+function aws_crt_signing_config_aws_set_expiration_in_seconds(int $config, int $expiration_in_seconds): void {}
+function aws_crt_signing_config_aws_set_date(int $config, int $timestamp): void {}
+function aws_crt_signing_config_aws_set_should_sign_header_fn(int $config, object $should_sign_header): void {}
+
+function aws_crt_signable_new_from_http_request(int $http_message): int {}
+function aws_crt_signable_new_from_chunk(int $input_stream, string $previous_signature): int {}
+function aws_crt_signable_new_from_canonical_request(string $request): int {}
+function aws_crt_signable_release(int $signable): void {}
+
+function aws_crt_signing_result_release(int $signing_result): void {}
+function aws_crt_signing_result_apply_to_http_request(object $signing_result, object $http_request): void {}
+
+function aws_crt_sign_request_aws(int $signable, int $signing_config, object $on_complete, object $user_data): int {}
+function aws_crt_test_verify_sigv4a_signing(int $signable, int $signing_config, string $expected_canonical_request, string $signature, string $ecc_key_pub_x, string $ecc_key_pub_y): bool {}
+
+function aws_crt_crc32(string $input, int $prev): int {}
+function aws_crt_crc32c(string $input, int $prev): int {}
diff --git a/vendor/aws/aws-crt-php/ext/awscrt_arginfo.h b/vendor/aws/aws-crt-php/ext/awscrt_arginfo.h
new file mode 100644
index 0000000..53e2559
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/awscrt_arginfo.h
@@ -0,0 +1,413 @@
+/* This is a generated file, edit the .stub.php file instead.
+ * Stub hash: 344f9d59b85697b80bb6808ac7d5eb7c1d07c03f */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_last_error, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_error_name, 0, 0, 1)
+ ZEND_ARG_INFO(0, error_code)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_error_str arginfo_aws_crt_error_name
+
+#define arginfo_aws_crt_error_debug_str arginfo_aws_crt_error_name
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_log_to_stdout, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_log_to_stderr arginfo_aws_crt_log_to_stdout
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_log_to_file, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_log_to_stream, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_log_stop arginfo_aws_crt_log_to_stdout
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_log_set_level, 0, 0, 1)
+ ZEND_ARG_INFO(0, level)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_log_message, 0, 0, 1)
+ ZEND_ARG_INFO(0, message)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_event_loop_group_options_new arginfo_aws_crt_last_error
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_event_loop_group_options_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, elg_options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_event_loop_group_options_set_max_threads, 0, 0, 2)
+ ZEND_ARG_INFO(0, elg_options)
+ ZEND_ARG_INFO(0, max_threads)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_event_loop_group_new, 0, 0, 1)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_event_loop_group_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, event_loop_group)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_input_stream_options_new, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_input_stream_options_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_input_stream_options_set_user_data, 0, 0, 2)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, user_data)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_input_stream_new arginfo_aws_crt_event_loop_group_new
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_input_stream_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_input_stream_seek, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream)
+ ZEND_ARG_INFO(0, offset)
+ ZEND_ARG_INFO(0, basis)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_input_stream_read, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream)
+ ZEND_ARG_INFO(0, length)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_input_stream_eof, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_input_stream_get_length, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_http_message_new_from_blob, 0, 0, 1)
+ ZEND_ARG_INFO(0, blob)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_http_message_to_blob, 0, 0, 1)
+ ZEND_ARG_INFO(0, message)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_http_message_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, message)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_credentials_options_new arginfo_aws_crt_input_stream_options_new
+
+#define arginfo_aws_crt_credentials_options_release arginfo_aws_crt_input_stream_options_release
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_credentials_options_set_access_key_id, 0, 0, 2)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, access_key_id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_credentials_options_set_secret_access_key, 0, 0, 2)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, secret_access_key)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_credentials_options_set_session_token, 0, 0, 2)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, session_token)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_credentials_options_set_expiration_timepoint_seconds, 0, 0, 2)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, expiration_timepoint_seconds)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_credentials_new arginfo_aws_crt_event_loop_group_new
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_credentials_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, credentials)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_credentials_provider_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, credentials)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_credentials_provider_static_options_new arginfo_aws_crt_input_stream_options_new
+
+#define arginfo_aws_crt_credentials_provider_static_options_release arginfo_aws_crt_input_stream_options_release
+
+#define arginfo_aws_crt_credentials_provider_static_options_set_access_key_id arginfo_aws_crt_credentials_options_set_access_key_id
+
+#define arginfo_aws_crt_credentials_provider_static_options_set_secret_access_key arginfo_aws_crt_credentials_options_set_secret_access_key
+
+#define arginfo_aws_crt_credentials_provider_static_options_set_session_token arginfo_aws_crt_credentials_options_set_session_token
+
+#define arginfo_aws_crt_credentials_provider_static_new arginfo_aws_crt_event_loop_group_new
+
+#define arginfo_aws_crt_signing_config_aws_new arginfo_aws_crt_last_error
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, config)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_algorithm, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, algorithm)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_signature_type, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, signature_type)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_credentials_provider, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, credentials_provider)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_region, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, region)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_service, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, service)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_use_double_uri_encode, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, use_double_uri_encode)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_should_normalize_uri_path, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, should_normalize_uri_path)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_omit_session_token, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, omit_session_token)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_signed_body_value, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, signed_body_value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_signed_body_header_type, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, signed_body_header_type)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_expiration_in_seconds, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, expiration_in_seconds)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_date, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, timestamp)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_config_aws_set_should_sign_header_fn, 0, 0, 2)
+ ZEND_ARG_INFO(0, config)
+ ZEND_ARG_INFO(0, should_sign_header)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signable_new_from_http_request, 0, 0, 1)
+ ZEND_ARG_INFO(0, http_message)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signable_new_from_chunk, 0, 0, 2)
+ ZEND_ARG_INFO(0, input_stream)
+ ZEND_ARG_INFO(0, previous_signature)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signable_new_from_canonical_request, 0, 0, 1)
+ ZEND_ARG_INFO(0, request)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signable_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, signable)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_result_release, 0, 0, 1)
+ ZEND_ARG_INFO(0, signing_result)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_signing_result_apply_to_http_request, 0, 0, 2)
+ ZEND_ARG_INFO(0, signing_result)
+ ZEND_ARG_INFO(0, http_request)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_sign_request_aws, 0, 0, 4)
+ ZEND_ARG_INFO(0, signable)
+ ZEND_ARG_INFO(0, signing_config)
+ ZEND_ARG_INFO(0, on_complete)
+ ZEND_ARG_INFO(0, user_data)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_test_verify_sigv4a_signing, 0, 0, 6)
+ ZEND_ARG_INFO(0, signable)
+ ZEND_ARG_INFO(0, signing_config)
+ ZEND_ARG_INFO(0, expected_canonical_request)
+ ZEND_ARG_INFO(0, signature)
+ ZEND_ARG_INFO(0, ecc_key_pub_x)
+ ZEND_ARG_INFO(0, ecc_key_pub_y)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_aws_crt_crc32, 0, 0, 2)
+ ZEND_ARG_INFO(0, input)
+ ZEND_ARG_INFO(0, prev)
+ZEND_END_ARG_INFO()
+
+#define arginfo_aws_crt_crc32c arginfo_aws_crt_crc32
+
+
+ZEND_FUNCTION(aws_crt_last_error);
+ZEND_FUNCTION(aws_crt_error_name);
+ZEND_FUNCTION(aws_crt_error_str);
+ZEND_FUNCTION(aws_crt_error_debug_str);
+ZEND_FUNCTION(aws_crt_log_to_stdout);
+ZEND_FUNCTION(aws_crt_log_to_stderr);
+ZEND_FUNCTION(aws_crt_log_to_file);
+ZEND_FUNCTION(aws_crt_log_to_stream);
+ZEND_FUNCTION(aws_crt_log_stop);
+ZEND_FUNCTION(aws_crt_log_set_level);
+ZEND_FUNCTION(aws_crt_log_message);
+ZEND_FUNCTION(aws_crt_event_loop_group_options_new);
+ZEND_FUNCTION(aws_crt_event_loop_group_options_release);
+ZEND_FUNCTION(aws_crt_event_loop_group_options_set_max_threads);
+ZEND_FUNCTION(aws_crt_event_loop_group_new);
+ZEND_FUNCTION(aws_crt_event_loop_group_release);
+ZEND_FUNCTION(aws_crt_input_stream_options_new);
+ZEND_FUNCTION(aws_crt_input_stream_options_release);
+ZEND_FUNCTION(aws_crt_input_stream_options_set_user_data);
+ZEND_FUNCTION(aws_crt_input_stream_new);
+ZEND_FUNCTION(aws_crt_input_stream_release);
+ZEND_FUNCTION(aws_crt_input_stream_seek);
+ZEND_FUNCTION(aws_crt_input_stream_read);
+ZEND_FUNCTION(aws_crt_input_stream_eof);
+ZEND_FUNCTION(aws_crt_input_stream_get_length);
+ZEND_FUNCTION(aws_crt_http_message_new_from_blob);
+ZEND_FUNCTION(aws_crt_http_message_to_blob);
+ZEND_FUNCTION(aws_crt_http_message_release);
+ZEND_FUNCTION(aws_crt_credentials_options_new);
+ZEND_FUNCTION(aws_crt_credentials_options_release);
+ZEND_FUNCTION(aws_crt_credentials_options_set_access_key_id);
+ZEND_FUNCTION(aws_crt_credentials_options_set_secret_access_key);
+ZEND_FUNCTION(aws_crt_credentials_options_set_session_token);
+ZEND_FUNCTION(aws_crt_credentials_options_set_expiration_timepoint_seconds);
+ZEND_FUNCTION(aws_crt_credentials_new);
+ZEND_FUNCTION(aws_crt_credentials_release);
+ZEND_FUNCTION(aws_crt_credentials_provider_release);
+ZEND_FUNCTION(aws_crt_credentials_provider_static_options_new);
+ZEND_FUNCTION(aws_crt_credentials_provider_static_options_release);
+ZEND_FUNCTION(aws_crt_credentials_provider_static_options_set_access_key_id);
+ZEND_FUNCTION(aws_crt_credentials_provider_static_options_set_secret_access_key);
+ZEND_FUNCTION(aws_crt_credentials_provider_static_options_set_session_token);
+ZEND_FUNCTION(aws_crt_credentials_provider_static_new);
+ZEND_FUNCTION(aws_crt_signing_config_aws_new);
+ZEND_FUNCTION(aws_crt_signing_config_aws_release);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_algorithm);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_signature_type);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_credentials_provider);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_region);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_service);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_use_double_uri_encode);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_should_normalize_uri_path);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_omit_session_token);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_signed_body_value);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_signed_body_header_type);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_expiration_in_seconds);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_date);
+ZEND_FUNCTION(aws_crt_signing_config_aws_set_should_sign_header_fn);
+ZEND_FUNCTION(aws_crt_signable_new_from_http_request);
+ZEND_FUNCTION(aws_crt_signable_new_from_chunk);
+ZEND_FUNCTION(aws_crt_signable_new_from_canonical_request);
+ZEND_FUNCTION(aws_crt_signable_release);
+ZEND_FUNCTION(aws_crt_signing_result_release);
+ZEND_FUNCTION(aws_crt_signing_result_apply_to_http_request);
+ZEND_FUNCTION(aws_crt_sign_request_aws);
+ZEND_FUNCTION(aws_crt_test_verify_sigv4a_signing);
+ZEND_FUNCTION(aws_crt_crc32);
+ZEND_FUNCTION(aws_crt_crc32c);
+
+
+static const zend_function_entry ext_functions[] = {
+ ZEND_FE(aws_crt_last_error, arginfo_aws_crt_last_error)
+ ZEND_FE(aws_crt_error_name, arginfo_aws_crt_error_name)
+ ZEND_FE(aws_crt_error_str, arginfo_aws_crt_error_str)
+ ZEND_FE(aws_crt_error_debug_str, arginfo_aws_crt_error_debug_str)
+ ZEND_FE(aws_crt_log_to_stdout, arginfo_aws_crt_log_to_stdout)
+ ZEND_FE(aws_crt_log_to_stderr, arginfo_aws_crt_log_to_stderr)
+ ZEND_FE(aws_crt_log_to_file, arginfo_aws_crt_log_to_file)
+ ZEND_FE(aws_crt_log_to_stream, arginfo_aws_crt_log_to_stream)
+ ZEND_FE(aws_crt_log_stop, arginfo_aws_crt_log_stop)
+ ZEND_FE(aws_crt_log_set_level, arginfo_aws_crt_log_set_level)
+ ZEND_FE(aws_crt_log_message, arginfo_aws_crt_log_message)
+ ZEND_FE(aws_crt_event_loop_group_options_new, arginfo_aws_crt_event_loop_group_options_new)
+ ZEND_FE(aws_crt_event_loop_group_options_release, arginfo_aws_crt_event_loop_group_options_release)
+ ZEND_FE(aws_crt_event_loop_group_options_set_max_threads, arginfo_aws_crt_event_loop_group_options_set_max_threads)
+ ZEND_FE(aws_crt_event_loop_group_new, arginfo_aws_crt_event_loop_group_new)
+ ZEND_FE(aws_crt_event_loop_group_release, arginfo_aws_crt_event_loop_group_release)
+ ZEND_FE(aws_crt_input_stream_options_new, arginfo_aws_crt_input_stream_options_new)
+ ZEND_FE(aws_crt_input_stream_options_release, arginfo_aws_crt_input_stream_options_release)
+ ZEND_FE(aws_crt_input_stream_options_set_user_data, arginfo_aws_crt_input_stream_options_set_user_data)
+ ZEND_FE(aws_crt_input_stream_new, arginfo_aws_crt_input_stream_new)
+ ZEND_FE(aws_crt_input_stream_release, arginfo_aws_crt_input_stream_release)
+ ZEND_FE(aws_crt_input_stream_seek, arginfo_aws_crt_input_stream_seek)
+ ZEND_FE(aws_crt_input_stream_read, arginfo_aws_crt_input_stream_read)
+ ZEND_FE(aws_crt_input_stream_eof, arginfo_aws_crt_input_stream_eof)
+ ZEND_FE(aws_crt_input_stream_get_length, arginfo_aws_crt_input_stream_get_length)
+ ZEND_FE(aws_crt_http_message_new_from_blob, arginfo_aws_crt_http_message_new_from_blob)
+ ZEND_FE(aws_crt_http_message_to_blob, arginfo_aws_crt_http_message_to_blob)
+ ZEND_FE(aws_crt_http_message_release, arginfo_aws_crt_http_message_release)
+ ZEND_FE(aws_crt_credentials_options_new, arginfo_aws_crt_credentials_options_new)
+ ZEND_FE(aws_crt_credentials_options_release, arginfo_aws_crt_credentials_options_release)
+ ZEND_FE(aws_crt_credentials_options_set_access_key_id, arginfo_aws_crt_credentials_options_set_access_key_id)
+ ZEND_FE(aws_crt_credentials_options_set_secret_access_key, arginfo_aws_crt_credentials_options_set_secret_access_key)
+ ZEND_FE(aws_crt_credentials_options_set_session_token, arginfo_aws_crt_credentials_options_set_session_token)
+ ZEND_FE(aws_crt_credentials_options_set_expiration_timepoint_seconds, arginfo_aws_crt_credentials_options_set_expiration_timepoint_seconds)
+ ZEND_FE(aws_crt_credentials_new, arginfo_aws_crt_credentials_new)
+ ZEND_FE(aws_crt_credentials_release, arginfo_aws_crt_credentials_release)
+ ZEND_FE(aws_crt_credentials_provider_release, arginfo_aws_crt_credentials_provider_release)
+ ZEND_FE(aws_crt_credentials_provider_static_options_new, arginfo_aws_crt_credentials_provider_static_options_new)
+ ZEND_FE(aws_crt_credentials_provider_static_options_release, arginfo_aws_crt_credentials_provider_static_options_release)
+ ZEND_FE(aws_crt_credentials_provider_static_options_set_access_key_id, arginfo_aws_crt_credentials_provider_static_options_set_access_key_id)
+ ZEND_FE(aws_crt_credentials_provider_static_options_set_secret_access_key, arginfo_aws_crt_credentials_provider_static_options_set_secret_access_key)
+ ZEND_FE(aws_crt_credentials_provider_static_options_set_session_token, arginfo_aws_crt_credentials_provider_static_options_set_session_token)
+ ZEND_FE(aws_crt_credentials_provider_static_new, arginfo_aws_crt_credentials_provider_static_new)
+ ZEND_FE(aws_crt_signing_config_aws_new, arginfo_aws_crt_signing_config_aws_new)
+ ZEND_FE(aws_crt_signing_config_aws_release, arginfo_aws_crt_signing_config_aws_release)
+ ZEND_FE(aws_crt_signing_config_aws_set_algorithm, arginfo_aws_crt_signing_config_aws_set_algorithm)
+ ZEND_FE(aws_crt_signing_config_aws_set_signature_type, arginfo_aws_crt_signing_config_aws_set_signature_type)
+ ZEND_FE(aws_crt_signing_config_aws_set_credentials_provider, arginfo_aws_crt_signing_config_aws_set_credentials_provider)
+ ZEND_FE(aws_crt_signing_config_aws_set_region, arginfo_aws_crt_signing_config_aws_set_region)
+ ZEND_FE(aws_crt_signing_config_aws_set_service, arginfo_aws_crt_signing_config_aws_set_service)
+ ZEND_FE(aws_crt_signing_config_aws_set_use_double_uri_encode, arginfo_aws_crt_signing_config_aws_set_use_double_uri_encode)
+ ZEND_FE(aws_crt_signing_config_aws_set_should_normalize_uri_path, arginfo_aws_crt_signing_config_aws_set_should_normalize_uri_path)
+ ZEND_FE(aws_crt_signing_config_aws_set_omit_session_token, arginfo_aws_crt_signing_config_aws_set_omit_session_token)
+ ZEND_FE(aws_crt_signing_config_aws_set_signed_body_value, arginfo_aws_crt_signing_config_aws_set_signed_body_value)
+ ZEND_FE(aws_crt_signing_config_aws_set_signed_body_header_type, arginfo_aws_crt_signing_config_aws_set_signed_body_header_type)
+ ZEND_FE(aws_crt_signing_config_aws_set_expiration_in_seconds, arginfo_aws_crt_signing_config_aws_set_expiration_in_seconds)
+ ZEND_FE(aws_crt_signing_config_aws_set_date, arginfo_aws_crt_signing_config_aws_set_date)
+ ZEND_FE(aws_crt_signing_config_aws_set_should_sign_header_fn, arginfo_aws_crt_signing_config_aws_set_should_sign_header_fn)
+ ZEND_FE(aws_crt_signable_new_from_http_request, arginfo_aws_crt_signable_new_from_http_request)
+ ZEND_FE(aws_crt_signable_new_from_chunk, arginfo_aws_crt_signable_new_from_chunk)
+ ZEND_FE(aws_crt_signable_new_from_canonical_request, arginfo_aws_crt_signable_new_from_canonical_request)
+ ZEND_FE(aws_crt_signable_release, arginfo_aws_crt_signable_release)
+ ZEND_FE(aws_crt_signing_result_release, arginfo_aws_crt_signing_result_release)
+ ZEND_FE(aws_crt_signing_result_apply_to_http_request, arginfo_aws_crt_signing_result_apply_to_http_request)
+ ZEND_FE(aws_crt_sign_request_aws, arginfo_aws_crt_sign_request_aws)
+ ZEND_FE(aws_crt_test_verify_sigv4a_signing, arginfo_aws_crt_test_verify_sigv4a_signing)
+ ZEND_FE(aws_crt_crc32, arginfo_aws_crt_crc32)
+ ZEND_FE(aws_crt_crc32c, arginfo_aws_crt_crc32c)
+ ZEND_FE_END
+};
diff --git a/vendor/aws/aws-crt-php/ext/crc.c b/vendor/aws/aws-crt-php/ext/crc.c
new file mode 100644
index 0000000..8e520f8
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/crc.c
@@ -0,0 +1,32 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+PHP_FUNCTION(aws_crt_crc32) {
+ zend_ulong prev = 0;
+ const char *input = NULL;
+ size_t len = 0;
+
+ aws_php_parse_parameters("sl", &input, &len, &prev);
+
+ if (prev > UINT32_MAX) {
+ aws_php_throw_exception("previous crc cannot be larger than UINT32_MAX");
+ }
+ RETURN_LONG((zend_ulong)aws_crt_crc32((const uint8_t *)input, len, prev));
+}
+
+PHP_FUNCTION(aws_crt_crc32c) {
+ zend_ulong prev = 0;
+ const char *input = NULL;
+ size_t len = 0;
+
+ aws_php_parse_parameters("sl", &input, &len, &prev);
+
+ if (prev > UINT32_MAX) {
+ aws_php_throw_exception("previous crc cannot be larger than UINT32_MAX");
+ }
+ RETURN_LONG((zend_ulong)aws_crt_crc32c((const uint8_t *)input, len, prev));
+}
diff --git a/vendor/aws/aws-crt-php/ext/credentials.c b/vendor/aws/aws-crt-php/ext/credentials.c
new file mode 100644
index 0000000..f361f08
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/credentials.c
@@ -0,0 +1,154 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+PHP_FUNCTION(aws_crt_credentials_options_new) {
+ aws_crt_credentials_options *options = aws_crt_credentials_options_new();
+ RETURN_LONG((zend_ulong)options);
+}
+
+PHP_FUNCTION(aws_crt_credentials_options_release) {
+ zend_ulong php_options = 0;
+
+ aws_php_parse_parameters("l", &php_options);
+
+ aws_crt_credentials_options *options = (void *)php_options;
+ aws_crt_credentials_options_release(options);
+}
+
+PHP_FUNCTION(aws_crt_credentials_options_set_access_key_id) {
+ zend_ulong php_options = 0;
+ const char *access_key_id = NULL;
+ size_t access_key_id_len = 0;
+
+ aws_php_parse_parameters("ls", &php_options, &access_key_id, &access_key_id_len);
+
+ aws_crt_credentials_options *options = (void *)php_options;
+ aws_crt_credentials_options_set_access_key_id(options, (uint8_t *)access_key_id, access_key_id_len);
+}
+
+PHP_FUNCTION(aws_crt_credentials_options_set_secret_access_key) {
+ zend_ulong php_options = 0;
+ const char *secret_access_key = NULL;
+ size_t secret_access_key_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &secret_access_key, &secret_access_key_len) ==
+ FAILURE) {
+ RETURN_NULL();
+ }
+
+ aws_crt_credentials_options *options = (void *)php_options;
+ aws_crt_credentials_options_set_secret_access_key(options, (uint8_t *)secret_access_key, secret_access_key_len);
+}
+
+PHP_FUNCTION(aws_crt_credentials_options_set_session_token) {
+ zend_ulong php_options = 0;
+ const char *session_token = NULL;
+ size_t session_token_len = 0;
+
+ aws_php_parse_parameters("ls", &php_options, &session_token, &session_token_len);
+
+ aws_crt_credentials_options *options = (void *)php_options;
+ aws_crt_credentials_options_set_session_token(options, (uint8_t *)session_token, session_token_len);
+}
+
+PHP_FUNCTION(aws_crt_credentials_options_set_expiration_timepoint_seconds) {
+ zend_ulong php_options = 0;
+ zend_ulong expiration_timepoint_seconds = 0;
+ aws_php_parse_parameters("ll", &php_options, &expiration_timepoint_seconds);
+
+ aws_crt_credentials_options *options = (void *)php_options;
+ aws_crt_credentials_options_set_expiration_timepoint_seconds(options, expiration_timepoint_seconds);
+}
+
+PHP_FUNCTION(aws_crt_credentials_new) {
+ zend_ulong php_options = 0;
+
+ aws_php_parse_parameters("l", &php_options);
+
+ aws_crt_credentials_options *options = (void *)php_options;
+ aws_crt_credentials *credentials = aws_crt_credentials_new(options);
+ RETURN_LONG((zend_ulong)credentials);
+}
+
+PHP_FUNCTION(aws_crt_credentials_release) {
+ zend_ulong php_credentials = 0;
+
+ aws_php_parse_parameters("l", &php_credentials);
+
+ aws_crt_credentials *credentials = (void *)php_credentials;
+ aws_crt_credentials_release(credentials);
+}
+
+PHP_FUNCTION(aws_crt_credentials_provider_release) {
+ zend_ulong php_creds_provider = 0;
+
+ aws_php_parse_parameters("l", &php_creds_provider);
+
+ aws_crt_credentials_provider *provider = (void *)php_creds_provider;
+ aws_crt_credentials_provider_release(provider);
+}
+
+PHP_FUNCTION(aws_crt_credentials_provider_static_options_new) {
+ aws_crt_credentials_provider_static_options *options = aws_crt_credentials_provider_static_options_new();
+ RETURN_LONG((zend_ulong)options);
+}
+
+PHP_FUNCTION(aws_crt_credentials_provider_static_options_release) {
+ zend_ulong php_options = 0;
+
+ aws_php_parse_parameters("l", &php_options);
+
+ aws_crt_credentials_provider_static_options *options = (void *)php_options;
+ aws_crt_credentials_provider_static_options_release(options);
+}
+
+PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_access_key_id) {
+ zend_ulong php_options = 0;
+ const char *access_key_id = NULL;
+ size_t access_key_id_len = 0;
+
+ aws_php_parse_parameters("ls", &php_options, &access_key_id, &access_key_id_len);
+
+ aws_crt_credentials_provider_static_options *options = (void *)php_options;
+ aws_crt_credentials_provider_static_options_set_access_key_id(options, (uint8_t *)access_key_id, access_key_id_len);
+}
+
+PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_secret_access_key) {
+ zend_ulong php_options = 0;
+ const char *secret_access_key = NULL;
+ size_t secret_access_key_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &secret_access_key, &secret_access_key_len) ==
+ FAILURE) {
+ RETURN_NULL();
+ }
+
+ aws_crt_credentials_provider_static_options *options = (void *)php_options;
+ aws_crt_credentials_provider_static_options_set_secret_access_key(
+ options, (uint8_t *)secret_access_key, secret_access_key_len);
+}
+
+PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_session_token) {
+ zend_ulong php_options = 0;
+ const char *session_token = NULL;
+ size_t session_token_len = 0;
+
+ aws_php_parse_parameters("ls", &php_options, &session_token, &session_token_len);
+
+ aws_crt_credentials_provider_static_options *options = (void *)php_options;
+ aws_crt_credentials_provider_static_options_set_session_token(options, (uint8_t *)session_token, session_token_len);
+}
+
+PHP_FUNCTION(aws_crt_credentials_provider_static_new) {
+ zend_ulong php_options = 0;
+
+ aws_php_parse_parameters("l", &php_options);
+
+ aws_crt_credentials_provider_static_options *options = (void *)php_options;
+ aws_crt_credentials_provider *provider = aws_crt_credentials_provider_static_new(options);
+ RETURN_LONG((zend_ulong)provider);
+}
diff --git a/vendor/aws/aws-crt-php/ext/crt.c b/vendor/aws/aws-crt-php/ext/crt.c
new file mode 100644
index 0000000..b71dd79
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/crt.c
@@ -0,0 +1,314 @@
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+/* Helpful references for this extension:
+ * zend_parse_parameters and friends -
+ * https://git.php.net/?p=php-src.git;a=blob;f=docs/parameter-parsing-api.md;h=c962fc6ee58cc756aaac9e65759b7d5ea5c18fc4;hb=HEAD
+ * https://git.php.net/?p=php-src.git;a=blob;f=docs/self-contained-extensions.md;h=47f4c636baca8ca195118e2cc234ac7fd2842c1b;hb=HEAD
+ * Threads:
+ * http://blog.jpauli.tech/2017-01-12-threads-and-php-html/
+ * Examples:
+ * Curl extension: https://github.com/php/php-src/blob/PHP-5.6/ext/curl/interface.c
+ * libuv extension: https://github.com/amphp/ext-uv/blob/master/php_uv.c
+ */
+
+zval aws_php_invoke_callback(zval *callback, const char *arg_types, ...) {
+
+ char *error = NULL;
+ zend_fcall_info fci = {0};
+ zend_fcall_info_cache fcc = empty_fcall_info_cache;
+ if (zend_fcall_info_init(callback, IS_CALLABLE_CHECK_SYNTAX_ONLY, &fci, &fcc, NULL, &error) == FAILURE) {
+ aws_php_throw_exception("Unable to initialize callback from callable via zend_fcall_info_init: %s", error);
+ }
+
+ /* Allocate the stack frame of zval arguments and fill them in */
+ const size_t num_args = strlen(arg_types);
+ zval *stack = alloca(sizeof(zval) * num_args);
+ int arg_idx = 0;
+ va_list va;
+ va_start(va, arg_types);
+ while (arg_idx < num_args) {
+ const char arg_type = arg_types[arg_idx];
+ switch (arg_type) {
+ /* zval types */
+ case 'a':
+ case 'A':
+ case 'n':
+ case 'o':
+ case 'r':
+ case 'z': {
+ zval *zval_val = va_arg(va, zval *);
+ ZVAL_ZVAL(&stack[arg_idx], zval_val, 0, 0);
+ break;
+ }
+ /* buffers/strings (char *, size_t) */
+ case 'p':
+ case 's': {
+ const char *buf = va_arg(va, const char *);
+ const size_t len = va_arg(va, size_t);
+ aws_php_zval_stringl(&stack[arg_idx], buf, len);
+ break;
+ }
+ /* other primitives */
+ case 'b': {
+ zend_bool bool_val = va_arg(va, int);
+ ZVAL_BOOL(&stack[arg_idx], bool_val);
+ break;
+ }
+ case 'd': {
+ double double_val = va_arg(va, double);
+ ZVAL_DOUBLE(&stack[arg_idx], double_val);
+ break;
+ }
+ case 'l': {
+ zend_ulong long_val = va_arg(va, zend_ulong);
+ ZVAL_LONG(&stack[arg_idx], long_val);
+ break;
+ }
+ /* strings (zend_string), not supported in PHP 5.6, therefore not supported */
+ case 'P':
+ case 'S':
+ /* unsupported */
+ case 'C':
+ case 'f':
+ case 'h':
+ case 'H':
+ case 'O':
+ aws_php_throw_exception("Unsupported argument type to aws_php_invoke_callback: %c", arg_type);
+ break;
+ default:
+ aws_php_throw_exception("Unsupported argument type to aws_php_invoke_callback: %c", arg_type);
+ break;
+ }
+ ++arg_idx;
+ }
+ va_end(va);
+
+ /* set up the stack for the call */
+#if AWS_PHP_AT_LEAST_7
+ zend_fcall_info_argp(&fci, num_args, stack);
+#else
+ /* PHP5.6 may mutate the arguments due to coercion */
+ zval **arg_ptrs = alloca(sizeof(zval *) * num_args);
+ zval ***args = alloca(sizeof(zval **) * num_args);
+ for (int arg_idx = 0; arg_idx < num_args; ++arg_idx) {
+ arg_ptrs[arg_idx] = &stack[arg_idx];
+ args[arg_idx] = &arg_ptrs[arg_idx];
+ }
+ fci.param_count = num_args;
+ fci.params = args;
+#endif
+
+ zval retval;
+ /* PHP5 allocates its own return value, 7+ uses an existing one we provide */
+#if !AWS_PHP_AT_LEAST_7
+ zval *retval5 = NULL;
+ fci.retval_ptr_ptr = &retval5;
+#else
+ fci.retval = &retval;
+#endif
+
+ if (zend_call_function(&fci, &fcc) == FAILURE) {
+ aws_php_throw_exception("zend_call_function failed in aws_php_invoke_callback");
+ }
+
+#if !AWS_PHP_AT_LEAST_7
+ /* initialize the local retval from the retval in retval_ptr_ptr above */
+ if (retval5) {
+ ZVAL_ZVAL(&retval, retval5, 1, 1);
+ }
+#endif
+
+ /* Clean up arguments */
+#if AWS_PHP_AT_LEAST_7
+ zend_fcall_info_args_clear(&fci, 1);
+#endif
+
+ return retval;
+}
+
+void aws_php_zval_stringl(zval *val, const char *str, size_t len) {
+ AWS_FATAL_ASSERT(val != NULL);
+#if AWS_PHP_AT_LEAST_7
+ ZVAL_STRINGL(val, str, len);
+#else
+ ZVAL_STRINGL(val, str, len, 1);
+#endif
+}
+
+aws_php_thread_queue s_aws_php_main_thread_queue;
+
+bool aws_php_is_main_thread(void) {
+ return s_aws_php_main_thread_queue.thread_id == aws_thread_current_thread_id();
+}
+
+void aws_php_thread_queue_init(aws_php_thread_queue *queue) {
+ aws_mutex_init(&queue->mutex);
+ memset(queue->queue, 0, sizeof(aws_php_task) * AWS_PHP_THREAD_QUEUE_MAX_DEPTH);
+ queue->write_slot = 0;
+ queue->thread_id = aws_thread_current_thread_id();
+}
+
+void aws_php_thread_queue_clean_up(aws_php_thread_queue *queue) {
+ assert(queue->write_slot == 0 && "aws_php_thread_queue cannot be cleaned up while queue is not empty");
+ aws_mutex_clean_up(&queue->mutex);
+}
+
+void aws_php_thread_queue_push(aws_php_thread_queue *queue, aws_php_task task) {
+ aws_mutex_lock(&queue->mutex);
+ assert(queue->write_slot < AWS_PHP_THREAD_QUEUE_MAX_DEPTH && "thread queue is full");
+ queue->queue[queue->write_slot++] = task;
+ aws_mutex_unlock(&queue->mutex);
+}
+
+bool aws_php_thread_queue_drain(aws_php_thread_queue *queue) {
+ assert(
+ queue->thread_id == aws_thread_current_thread_id() &&
+ "thread queue cannot be drained from a thread other than its home");
+ aws_php_task drain_queue[AWS_PHP_THREAD_QUEUE_MAX_DEPTH];
+ aws_mutex_lock(&queue->mutex);
+ /* copy any queued tasks into the drain queue, then reset the queue */
+ memcpy(drain_queue, queue->queue, sizeof(aws_php_task) * AWS_PHP_THREAD_QUEUE_MAX_DEPTH);
+ memset(queue->queue, 0, sizeof(aws_php_task) * AWS_PHP_THREAD_QUEUE_MAX_DEPTH);
+ queue->write_slot = 0;
+ aws_mutex_unlock(&queue->mutex);
+
+ bool did_work = false;
+ for (int idx = 0; idx < AWS_PHP_THREAD_QUEUE_MAX_DEPTH; ++idx) {
+ aws_php_task *task = &drain_queue[idx];
+ if (!task->callback) {
+ break;
+ }
+ did_work = true;
+ task->callback(task->data);
+ if (task->dtor) {
+ task->dtor(task->data);
+ }
+ }
+
+ return did_work;
+}
+
+/* called on main thread after delivery */
+static void s_thread_queue_complete_promise(void *data) {
+ struct aws_promise *promise = data;
+ aws_promise_complete(promise, NULL, NULL);
+}
+
+/* called from worker thread to wait for the main thread to execute any queued work in PHP */
+void aws_php_thread_queue_yield(aws_php_thread_queue *queue) {
+ /* If on the main thread, then just drain the queue */
+ if (aws_php_is_main_thread()) {
+ aws_php_thread_queue_drain(queue);
+ } else {
+ /* push a task onto the end of the queue, we will return once this task completes our promise */
+ struct aws_promise *queue_drained = aws_promise_new(aws_crt_default_allocator());
+ aws_php_task queue_drained_task = {
+ .callback = s_thread_queue_complete_promise,
+ .data = queue_drained,
+ };
+ aws_php_thread_queue_push(queue, queue_drained_task);
+ aws_promise_wait(queue_drained);
+ aws_promise_release(queue_drained);
+ }
+}
+
+/* called from PHP thread to wait on async queued jobs, one of which should complete the promise */
+void aws_php_thread_queue_wait(aws_php_thread_queue *queue, struct aws_promise *promise) {
+ while (!aws_promise_is_complete(promise)) {
+ aws_php_thread_queue_drain(queue);
+ }
+}
+
+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();
+
+ /* prevent s2n from initializing/de-initializing OpenSSL/libcrypto */
+ aws_crt_crypto_share();
+ aws_crt_init();
+ aws_php_thread_queue_init(&s_aws_php_main_thread_queue);
+ return SUCCESS;
+}
+
+static PHP_MSHUTDOWN_FUNCTION(awscrt) {
+ UNREGISTER_INI_ENTRIES();
+ aws_php_thread_queue_clean_up(&s_aws_php_main_thread_queue);
+ aws_crt_thread_join_all(0);
+ 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;
+}
+
+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
+
+/* 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;
+ aws_php_parse_parameters("l", &error_code);
+
+ XRETURN_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;
+ aws_php_parse_parameters("l", &error_code);
+
+ XRETURN_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;
+ aws_php_parse_parameters("l", &error_code);
+
+ XRETURN_STRING(aws_crt_error_debug_str(error_code));
+}
diff --git a/vendor/aws/aws-crt-php/ext/event_loop.c b/vendor/aws/aws-crt-php/ext/event_loop.c
new file mode 100644
index 0000000..cd8d42f
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/event_loop.c
@@ -0,0 +1,48 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+PHP_FUNCTION(aws_crt_event_loop_group_options_new) {
+ aws_php_parse_parameters_none();
+ aws_crt_event_loop_group_options *options = aws_crt_event_loop_group_options_new();
+ RETURN_LONG((zend_ulong)options);
+}
+
+PHP_FUNCTION(aws_crt_event_loop_group_options_release) {
+ zend_ulong php_options = 0;
+ aws_php_parse_parameters("l", &php_options);
+
+ aws_crt_event_loop_group_options *options = (void *)php_options;
+ aws_crt_event_loop_group_options_release(options);
+}
+
+PHP_FUNCTION(aws_crt_event_loop_group_options_set_max_threads) {
+ zend_ulong php_options = 0;
+ zend_ulong num_threads = 0;
+ aws_php_parse_parameters("ll", &php_options, &num_threads);
+
+ aws_crt_event_loop_group_options *options = (void *)php_options;
+ aws_crt_event_loop_group_options_set_max_threads(options, num_threads);
+}
+
+PHP_FUNCTION(aws_crt_event_loop_group_new) {
+ zend_ulong php_options = 0;
+
+ aws_php_parse_parameters("l", &php_options);
+
+ aws_crt_event_loop_group_options *options = (void *)php_options;
+ aws_crt_event_loop_group *elg = aws_crt_event_loop_group_new(options);
+ RETURN_LONG((zend_ulong)elg);
+}
+
+PHP_FUNCTION(aws_crt_event_loop_group_release) {
+ zend_ulong php_elg = 0;
+
+ aws_php_parse_parameters("l", &php_elg);
+
+ aws_crt_event_loop_group *elg = (void *)php_elg;
+ aws_crt_event_loop_group_release(elg);
+}
diff --git a/vendor/aws/aws-crt-php/ext/http.c b/vendor/aws/aws-crt-php/ext/http.c
new file mode 100644
index 0000000..3f429ae
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/http.c
@@ -0,0 +1,36 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+PHP_FUNCTION(aws_crt_http_message_new_from_blob) {
+ const char *blob = NULL;
+ size_t blob_len = 0;
+
+ aws_php_parse_parameters("s", &blob, &blob_len);
+
+ aws_crt_http_message *message = aws_crt_http_message_new_from_blob((uint8_t *)blob, blob_len);
+ RETURN_LONG((zend_ulong)message);
+}
+
+PHP_FUNCTION(aws_crt_http_message_to_blob) {
+ zend_ulong php_msg = 0;
+
+ aws_php_parse_parameters("l", &php_msg);
+
+ aws_crt_http_message *message = (void *)php_msg;
+ aws_crt_buf blob;
+ aws_crt_http_message_to_blob(message, &blob);
+ XRETURN_STRINGL((const char *)blob.blob, blob.length);
+}
+
+PHP_FUNCTION(aws_crt_http_message_release) {
+ zend_ulong php_msg = 0;
+
+ aws_php_parse_parameters("l", &php_msg);
+
+ aws_crt_http_message *message = (void *)php_msg;
+ aws_crt_http_message_release(message);
+}
diff --git a/vendor/aws/aws-crt-php/ext/logging.c b/vendor/aws/aws-crt-php/ext/logging.c
new file mode 100644
index 0000000..15fdade
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/logging.c
@@ -0,0 +1,65 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+PHP_FUNCTION(aws_crt_log_to_stdout) {
+ aws_php_parse_parameters_none();
+ aws_crt_log_to_stdout();
+}
+
+PHP_FUNCTION(aws_crt_log_to_stderr) {
+ aws_php_parse_parameters_none();
+ aws_crt_log_to_stderr();
+}
+
+PHP_FUNCTION(aws_crt_log_to_file) {
+ const char *filename = NULL;
+ size_t filename_len = 0;
+ /* read the filename as a path, which guarantees no NUL bytes */
+ aws_php_parse_parameters("p", &filename, &filename_len);
+ aws_crt_log_to_file(filename);
+}
+
+static void php_crt_log(const char *message, size_t len, void *user_data) {
+ php_stream *stream = user_data;
+ php_stream_write(stream, message, len);
+ php_stream_flush(stream);
+}
+
+PHP_FUNCTION(aws_crt_log_to_stream) {
+ zval *php_log_stream = NULL;
+ aws_php_parse_parameters("r", &php_log_stream);
+
+ if (php_log_stream) {
+ php_stream *stream = NULL;
+ Z_ADDREF(*php_log_stream);
+ AWS_PHP_STREAM_FROM_ZVAL(stream, php_log_stream);
+ aws_crt_log_to_callback((aws_crt_log_callback *)php_crt_log, stream);
+ } else {
+ aws_crt_log_to_callback(NULL, NULL);
+ }
+}
+
+PHP_FUNCTION(aws_crt_log_set_level) {
+ zend_ulong log_level = 0;
+ aws_php_parse_parameters("l", &log_level);
+ aws_crt_log_set_level((aws_crt_log_level)log_level);
+}
+
+PHP_FUNCTION(aws_crt_log_stop) {
+ aws_php_parse_parameters_none();
+ aws_crt_log_stop();
+}
+
+PHP_FUNCTION(aws_crt_log_message) {
+ zend_ulong log_level = 0;
+ const char *message = NULL;
+ size_t message_len = 0;
+
+ aws_php_parse_parameters("ls", &log_level, &message, &message_len);
+
+ aws_crt_log_message((aws_crt_log_level)log_level, (const uint8_t *)message, message_len);
+}
diff --git a/vendor/aws/aws-crt-php/ext/php_aws_crt.h b/vendor/aws/aws-crt-php/ext/php_aws_crt.h
new file mode 100644
index 0000000..9393a0b
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/php_aws_crt.h
@@ -0,0 +1,171 @@
+
+#ifndef PHP_AWS_CRT_H
+#define PHP_AWS_CRT_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "php.h"
+
+#include "Zend/zend_extensions.h" /* for ZEND_EXTENSION_API_NO */
+
+#include <aws/common/common.h>
+#include <aws/common/mutex.h>
+#include <aws/common/promise.h>
+#include <aws/common/thread.h>
+
+/* ZEND_EXTENSION_API_NO from each branch of the PHP source */
+#define AWS_PHP_EXTENSION_API_5_5 220121212
+#define AWS_PHP_EXTENSION_API_5_6 220131226
+#define AWS_PHP_EXTENSION_API_7_0 320151012
+#define AWS_PHP_EXTENSION_API_7_1 320160303
+#define AWS_PHP_EXTENSION_API_7_2 320170718
+#define AWS_PHP_EXTENSION_API_7_3 320180731
+#define AWS_PHP_EXTENSION_API_7_4 320190902
+#define AWS_PHP_EXTENSION_API_8_0 420200930
+
+#if ZEND_EXTENSION_API_NO < AWS_PHP_EXTENSION_API_5_5
+# error "PHP >= 5.5 is required"
+#endif
+
+#define AWS_PHP_AT_LEAST_7 (ZEND_EXTENSION_API_NO >= AWS_PHP_EXTENSION_API_7_0)
+#define AWS_PHP_AT_LEAST_7_2 (ZEND_EXTENSION_API_NO >= AWS_PHP_EXTENSION_API_7_2)
+
+ZEND_BEGIN_MODULE_GLOBALS(awscrt)
+long log_level;
+ZEND_END_MODULE_GLOBALS(awscrt)
+
+ZEND_EXTERN_MODULE_GLOBALS(awscrt)
+
+#define AWSCRT_GLOBAL(v) ZEND_MODULE_GLOBALS_ACCESSOR(awscrt, v)
+
+#if AWS_PHP_AT_LEAST_7
+/* PHP 7 takes a zval*, PHP5 takes a zval** */
+# define AWS_PHP_STREAM_FROM_ZVAL(s, z) php_stream_from_zval(s, z)
+#define XRETURN_STRINGL RETURN_STRINGL
+#define XRETURN_STRING RETURN_STRING
+#define XRETVAL_STRINGL RETVAL_STRINGL
+#define XRETVAL_STRING RETVAL_STRING
+#else /* PHP 5.5-5.6 */
+# define AWS_PHP_STREAM_FROM_ZVAL(s, z) php_stream_from_zval(s, &z)
+#define XRETURN_STRINGL(s, l) RETURN_STRINGL(s, l, 1)
+#define XRETURN_STRING(s) RETURN_STRING(s, 1)
+#define XRETVAL_STRINGL(s, l) RETVAL_STRINGL(s, l, 1)
+#define XRETVAL_STRING(s) RETVAL_STRING(s, 1)
+#endif /* PHP 5.x */
+
+#include "api.h"
+#include "awscrt_arginfo.h"
+
+/* Utility macros borrowed from common */
+#define GLUE(x, y) x y
+
+#define RETURN_ARG_COUNT(_1_, _2_, _3_, _4_, _5_, count, ...) count
+#define EXPAND_ARGS(args) RETURN_ARG_COUNT args
+#define COUNT_ARGS_MAX5(...) EXPAND_ARGS((__VA_ARGS__, 5, 4, 3, 2, 1, 0))
+
+#define OVERLOAD_MACRO2(name, count) name##count
+#define OVERLOAD_MACRO1(name, count) OVERLOAD_MACRO2(name, count)
+#define OVERLOAD_MACRO(name, count) OVERLOAD_MACRO1(name, count)
+
+#define CALL_OVERLOAD(name, ...) GLUE(OVERLOAD_MACRO(name, COUNT_ARGS_MAX5(__VA_ARGS__)), (__VA_ARGS__))
+
+#define VARIABLE_LENGTH_ARRAY(type, name, length) type *name = alloca(sizeof(type) * (length))
+
+/*
+ * PHP utility APIs for this extension
+ */
+/*
+ * Exception throwing mechanism, will never return
+ */
+#define aws_php_throw_exception(...) CALL_OVERLOAD(_AWS_PHP_THROW_EXCEPTION, __VA_ARGS__);
+#define _AWS_PHP_THROW_EXCEPTION5(format, ...) zend_error_noreturn(E_ERROR, format, __VA_ARGS__)
+#define _AWS_PHP_THROW_EXCEPTION4(format, ...) zend_error_noreturn(E_ERROR, format, __VA_ARGS__)
+#define _AWS_PHP_THROW_EXCEPTION3(format, ...) zend_error_noreturn(E_ERROR, format, __VA_ARGS__)
+#define _AWS_PHP_THROW_EXCEPTION2(format, ...) zend_error_noreturn(E_ERROR, format, __VA_ARGS__)
+#define _AWS_PHP_THROW_EXCEPTION1(format) zend_error_noreturn(E_ERROR, format)
+
+/**
+ * throws an exception resulting from argument parsing, notes the current function name in the exception
+ */
+#define aws_php_argparse_fail() \
+ do { \
+ aws_php_throw_exception("Failed to parse arguments to %s", __func__); \
+ } while (0)
+
+/**
+ * calls zend_parse_parameters() with the arguments and throws an exception if parsing fails
+ */
+#define aws_php_parse_parameters(type_spec, ...) \
+ do { \
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), type_spec, __VA_ARGS__) == FAILURE) { \
+ aws_php_argparse_fail(); \
+ } \
+ } while (0)
+
+/**
+ * calls zend_parse_parameters_none() and throws an exception if parsing fails
+ */
+#define aws_php_parse_parameters_none() \
+ do { \
+ if (zend_parse_parameters_none() == FAILURE) { \
+ aws_php_argparse_fail(); \
+ } \
+ } while (0)
+
+/* PHP/Zend utility functions to work across PHP versions */
+zval *aws_php_zval_new(void);
+void aws_php_zval_dtor(void *zval_ptr);
+bool aws_php_zval_as_bool(zval *z);
+void aws_php_zval_copy(zval *dest, zval *src);
+/**
+ * Replacement for ZVAL_STRINGL that is PHP version agnostic
+ */
+void aws_php_zval_stringl(zval *val, const char *str, size_t len);
+
+/* Thread queue functions for managing PHP's optional threading situation */
+typedef struct _aws_php_task {
+ void (*callback)(void *); /* task function */
+ void (*dtor)(void *); /* deletes task_data, if non-null */
+ void *data;
+} aws_php_task;
+
+/* maximum number of queued callbacks to execute at once. Since this is to support single-threaded usage,
+ * this can be a fairly small number, as how many callbacks could we reasonably be stacking up?! */
+#define AWS_PHP_THREAD_QUEUE_MAX_DEPTH 32
+
+typedef struct _aws_php_thread_queue {
+ struct aws_mutex mutex;
+ aws_php_task queue[AWS_PHP_THREAD_QUEUE_MAX_DEPTH];
+ size_t write_slot;
+ aws_thread_id_t thread_id;
+} aws_php_thread_queue;
+
+extern aws_php_thread_queue s_aws_php_main_thread_queue;
+bool aws_php_is_main_thread(void);
+
+void aws_php_thread_queue_init(aws_php_thread_queue *queue);
+void aws_php_thread_queue_clean_up(aws_php_thread_queue *queue);
+void aws_php_thread_queue_push(aws_php_thread_queue *queue, aws_php_task task);
+bool aws_php_thread_queue_drain(aws_php_thread_queue *queue);
+
+/* called from worker thread to wait for the main thread to execute any queued work in PHP */
+void aws_php_thread_queue_yield(aws_php_thread_queue *queue);
+
+/* called from PHP thread to wait on async queued jobs, one of which MUST complete the promise */
+void aws_php_thread_queue_wait(aws_php_thread_queue *queue, struct aws_promise *promise);
+
+/**
+ * generic dispatch mechanism to call a callback provided as a zval with arguments
+ * that are converted to zvals based on the arg_types format string
+ * Uses the same format string as zend_parse_parameters
+ */
+zval aws_php_invoke_callback(zval *callback, const char *arg_types, ...);
+
+#endif /* PHP_AWS_CRT_H */
diff --git a/vendor/aws/aws-crt-php/ext/php_util.c b/vendor/aws/aws-crt-php/ext/php_util.c
new file mode 100644
index 0000000..8e7bc30
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/php_util.c
@@ -0,0 +1,33 @@
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+zval *aws_php_zval_new(void) {
+ return emalloc(sizeof(zval));
+}
+
+void aws_php_zval_dtor(void *zval_ptr) {
+ zval *z = zval_ptr;
+ zval_dtor(z);
+ efree(z);
+}
+
+bool aws_php_zval_as_bool(zval *z) {
+#if AWS_PHP_AT_LEAST_7
+ return (Z_TYPE_P(z) == IS_TRUE);
+#else
+ return (Z_TYPE_P(z) == IS_BOOL && Z_LVAL_P(z) != 0);
+#endif
+}
+
+void aws_php_zval_copy(zval *dest, zval *src) {
+#if AWS_PHP_AT_LEAST_7
+ ZVAL_COPY(dest, src);
+#else
+ ZVAL_COPY_VALUE(dest, src);
+#endif
+}
diff --git a/vendor/aws/aws-crt-php/ext/signing.c b/vendor/aws/aws-crt-php/ext/signing.c
new file mode 100644
index 0000000..69da25a
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/signing.c
@@ -0,0 +1,374 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+PHP_FUNCTION(aws_crt_signing_config_aws_new) {
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_NULL();
+ }
+
+ aws_crt_signing_config_aws *signing_config = aws_crt_signing_config_aws_new();
+ RETURN_LONG((zend_ulong)signing_config);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_release) {
+ zend_ulong php_signing_config = 0;
+
+ aws_php_parse_parameters("l", &php_signing_config);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_release(signing_config);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_algorithm) {
+ zend_ulong php_signing_config = 0;
+ zend_ulong php_algorithm = 0;
+
+ aws_php_parse_parameters("ll", &php_signing_config, &php_algorithm);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_algorithm algorithm = php_algorithm;
+ aws_crt_signing_config_aws_set_algorithm(signing_config, algorithm);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_signature_type) {
+ zend_ulong php_signing_config = 0;
+ zend_ulong php_signature_type = 0;
+
+ aws_php_parse_parameters("ll", &php_signing_config, &php_signature_type);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signature_type signature_type = php_signature_type;
+ aws_crt_signing_config_aws_set_signature_type(signing_config, signature_type);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_credentials_provider) {
+ zend_ulong php_signing_config = 0;
+ zend_ulong php_credentials_provider = 0;
+
+ aws_php_parse_parameters("ll", &php_signing_config, &php_credentials_provider);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_credentials_provider *credentials_provider = (void *)php_credentials_provider;
+ aws_crt_signing_config_aws_set_credentials_provider(signing_config, credentials_provider);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_region) {
+ zend_ulong php_signing_config = 0;
+ const char *region = NULL;
+ size_t region_len = 0;
+
+ aws_php_parse_parameters("ls", &php_signing_config, &region, &region_len);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_set_region(signing_config, (uint8_t *)region, region_len);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_service) {
+ zend_ulong php_signing_config = 0;
+ const char *service = NULL;
+ size_t service_len = 0;
+
+ aws_php_parse_parameters("ls", &php_signing_config, &service, &service_len);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_set_service(signing_config, (uint8_t *)service, service_len);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_use_double_uri_encode) {
+ zend_ulong php_signing_config = 0;
+ zend_bool php_use_double_uri_encode = 0;
+
+ aws_php_parse_parameters("lb", &php_signing_config, &php_use_double_uri_encode);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_set_use_double_uri_encode(signing_config, php_use_double_uri_encode);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_should_normalize_uri_path) {
+ zend_ulong php_signing_config = 0;
+ zend_bool php_should_normalize_uri_path = 0;
+
+ aws_php_parse_parameters("lb", &php_signing_config, &php_should_normalize_uri_path);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_set_should_normalize_uri_path(signing_config, php_should_normalize_uri_path);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_omit_session_token) {
+ zend_ulong php_signing_config = 0;
+ zend_bool php_omit_session_token = 0;
+
+ aws_php_parse_parameters("lb", &php_signing_config, &php_omit_session_token);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_set_omit_session_token(signing_config, php_omit_session_token);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_signed_body_value) {
+ zend_ulong php_signing_config = 0;
+ const char *signed_body_value = NULL;
+ size_t signed_body_value_len = 0;
+
+ aws_php_parse_parameters("ls", &php_signing_config, &signed_body_value, &signed_body_value_len);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_set_signed_body_value(
+ signing_config, (uint8_t *)signed_body_value, signed_body_value_len);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_signed_body_header_type) {
+ zend_ulong php_signing_config = 0;
+ zend_ulong php_signed_body_header_type = 0;
+
+ aws_php_parse_parameters("ll", &php_signing_config, &php_signed_body_header_type);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signed_body_header_type signed_body_header_type = php_signed_body_header_type;
+ aws_crt_signing_config_aws_set_signed_body_header_type(signing_config, signed_body_header_type);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_expiration_in_seconds) {
+ zend_ulong php_signing_config = 0;
+ zend_ulong php_expiration_in_seconds = 0;
+
+ aws_php_parse_parameters("ll", &php_signing_config, &php_expiration_in_seconds);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_set_expiration_in_seconds(signing_config, php_expiration_in_seconds);
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_date) {
+ zend_ulong php_signing_config = 0;
+ zend_ulong php_timestamp = 0;
+
+ aws_php_parse_parameters("ll", &php_signing_config, &php_timestamp);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+ aws_crt_signing_config_aws_set_date(signing_config, php_timestamp);
+}
+
+typedef struct _should_sign_header_data {
+ zval *should_sign_header;
+ zval *header_name;
+ bool result;
+} should_sign_header_data;
+
+static void should_sign_header_task(void *data) {
+ should_sign_header_data *task = data;
+ zval result = aws_php_invoke_callback(task->should_sign_header, "z", task->header_name);
+ task->result = aws_php_zval_as_bool(&result);
+ zval_dtor(&result);
+}
+
+static bool aws_php_should_sign_header(const char *header_name, size_t header_length, void *user_data) {
+ zval php_header_name;
+ aws_php_zval_stringl(&php_header_name, header_name, header_length);
+
+ should_sign_header_data task_data = {
+ .should_sign_header = user_data,
+ .header_name = &php_header_name,
+ .result = false,
+ };
+
+ aws_php_task task = {
+ .callback = should_sign_header_task,
+ .data = &task_data,
+ };
+
+ aws_php_thread_queue_push(&s_aws_php_main_thread_queue, task);
+ aws_php_thread_queue_yield(&s_aws_php_main_thread_queue);
+
+ zval_dtor(&php_header_name);
+
+ return task_data.result;
+}
+
+PHP_FUNCTION(aws_crt_signing_config_aws_set_should_sign_header_fn) {
+ zend_ulong php_signing_config = 0;
+ zval *php_should_sign_header = NULL;
+
+ aws_php_parse_parameters("lz", &php_signing_config, &php_should_sign_header);
+
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+
+ /* copy/retain PHP callback, add as user data for signing_config resource */
+ zval *should_sign_header = aws_php_zval_new();
+ aws_php_zval_copy(should_sign_header, php_should_sign_header);
+ aws_crt_resource_set_user_data(signing_config, should_sign_header, aws_php_zval_dtor);
+
+ aws_crt_signing_config_aws_set_should_sign_header_fn(
+ signing_config, aws_php_should_sign_header, should_sign_header);
+}
+
+PHP_FUNCTION(aws_crt_signable_new_from_http_request) {
+ zend_ulong php_http_message = 0;
+
+ aws_php_parse_parameters("l", &php_http_message);
+
+ const aws_crt_http_message *http_message = (void *)php_http_message;
+ aws_crt_signable *signable = aws_crt_signable_new_from_http_request(http_message);
+ RETURN_LONG((zend_ulong)signable);
+}
+
+PHP_FUNCTION(aws_crt_signable_new_from_chunk) {
+ zend_ulong php_input_stream = 0;
+ const char *previous_signature = NULL;
+ size_t previous_signature_len = 0;
+
+ aws_php_parse_parameters("ls", &php_input_stream, &previous_signature, &previous_signature_len);
+
+ aws_crt_input_stream *input_stream = (void *)php_input_stream;
+ aws_crt_signable *signable =
+ aws_crt_signable_new_from_chunk(input_stream, (uint8_t *)previous_signature, previous_signature_len);
+ RETURN_LONG((zend_ulong)signable);
+}
+
+PHP_FUNCTION(aws_crt_signable_new_from_canonical_request) {
+ const char *canonical_request = NULL;
+ size_t canonical_request_len = 0;
+
+ aws_crt_signable *signable =
+ aws_crt_signable_new_from_canonical_request((uint8_t *)canonical_request, canonical_request_len);
+ RETURN_LONG((zend_ulong)signable);
+}
+
+PHP_FUNCTION(aws_crt_signable_release) {
+ zend_ulong php_signable = 0;
+
+ aws_php_parse_parameters("l", &php_signable);
+
+ aws_crt_signable *signable = (void *)php_signable;
+ aws_crt_signable_release(signable);
+}
+
+PHP_FUNCTION(aws_crt_signing_result_release) {
+ zend_ulong php_signing_result = 0;
+
+ aws_php_parse_parameters("l", &php_signing_result);
+ aws_crt_signing_result *result = (void *)php_signing_result;
+ aws_crt_signing_result_release(result);
+}
+
+PHP_FUNCTION(aws_crt_signing_result_apply_to_http_request) {
+ zend_ulong php_signing_result = 0;
+ zend_ulong php_http_request = 0;
+
+ aws_php_parse_parameters("ll", &php_signing_result, &php_http_request);
+ aws_crt_signing_result *result = (void *)php_signing_result;
+ aws_crt_http_message *request = (void *)php_http_request;
+
+ if (aws_crt_signing_result_apply_to_http_request(result, request)) {
+ aws_php_throw_exception(
+ "Failed to apply signing result to HTTP request: %s", aws_crt_error_name(aws_crt_last_error()));
+ }
+}
+
+typedef struct _signing_state {
+ struct aws_promise *promise;
+ zval *on_complete;
+ aws_crt_signing_result *signing_result;
+ int error_code;
+} signing_state;
+
+/* called on main thread to deliver result to php */
+static void s_sign_aws_complete(void *data) {
+ signing_state *state = data;
+ zval *on_complete = state->on_complete;
+ aws_php_invoke_callback(on_complete, "ll", (zend_ulong)state->signing_result, (zend_ulong)state->error_code);
+}
+
+/* called from signing process in aws_sign_request_aws */
+static void s_on_sign_request_aws_complete(aws_crt_signing_result *result, int error_code, void *user_data) {
+ signing_state *state = user_data;
+ struct aws_promise *promise = state->promise;
+
+ state->signing_result = result;
+ state->error_code = error_code;
+
+ /*
+ * Must execute PHP callback before this function returns, or signing_result will be killed
+ * so the callback is queued back to the main thread and will have run when yield returns
+ */
+ aws_php_task complete_callback_task = {
+ .callback = s_sign_aws_complete,
+ .data = state,
+ };
+ aws_php_thread_queue_push(&s_aws_php_main_thread_queue, complete_callback_task);
+ aws_php_thread_queue_yield(&s_aws_php_main_thread_queue);
+
+ if (error_code) {
+ aws_promise_fail(promise, error_code);
+ } else {
+ aws_promise_complete(promise, result, NULL);
+ }
+}
+
+PHP_FUNCTION(aws_crt_sign_request_aws) {
+ zend_ulong php_signable = 0;
+ zend_ulong php_signing_config = 0;
+ zval *php_on_complete = 0;
+ zend_ulong php_user_data = 0;
+
+ aws_php_parse_parameters("llzl", &php_signable, &php_signing_config, &php_on_complete, &php_user_data);
+
+ aws_crt_signable *signable = (void *)php_signable;
+ aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
+
+ struct aws_promise *promise = aws_promise_new(aws_crt_default_allocator());
+ signing_state state = {
+ .promise = promise,
+ .on_complete = php_on_complete,
+ };
+ int ret = aws_crt_sign_request_aws(signable, signing_config, s_on_sign_request_aws_complete, &state);
+ if (ret != 0) {
+ int last_error = aws_crt_last_error();
+ aws_promise_fail(promise, last_error);
+ aws_php_throw_exception(
+ "aws_crt_sign_request_aws: error starting signing process: %s", aws_crt_error_name(last_error));
+ }
+
+ aws_php_thread_queue_wait(&s_aws_php_main_thread_queue, promise);
+
+done:
+ aws_promise_release(promise);
+ RETURN_LONG(ret);
+}
+
+PHP_FUNCTION(aws_crt_test_verify_sigv4a_signing) {
+ zend_ulong php_signable = 0;
+ zend_ulong php_signing_config = 0;
+ const char *expected_canonical_request = NULL;
+ size_t expected_canonical_request_len = 0;
+ const char *signature = NULL;
+ size_t signature_len = 0;
+ const char *ecc_key_pub_x = NULL;
+ size_t ecc_key_pub_x_len = 0;
+ const char *ecc_key_pub_y = NULL;
+ size_t ecc_key_pub_y_len = 0;
+
+ aws_php_parse_parameters(
+ "llssss",
+ &php_signable,
+ &php_signing_config,
+ &expected_canonical_request,
+ &expected_canonical_request_len,
+ &signature,
+ &signature_len,
+ &ecc_key_pub_x,
+ &ecc_key_pub_x_len,
+ &ecc_key_pub_y,
+ &ecc_key_pub_y_len);
+
+ const aws_crt_signable *signable = (void *)php_signable;
+ const aws_crt_signing_config *signing_config = (void *)php_signing_config;
+
+ bool result = AWS_OP_SUCCESS ==
+ aws_crt_test_verify_sigv4a_signing(
+ signable, signing_config, expected_canonical_request, signature, ecc_key_pub_x, ecc_key_pub_y);
+
+ RETURN_BOOL(result);
+}
diff --git a/vendor/aws/aws-crt-php/ext/stream.c b/vendor/aws/aws-crt-php/ext/stream.c
new file mode 100644
index 0000000..414146b
--- /dev/null
+++ b/vendor/aws/aws-crt-php/ext/stream.c
@@ -0,0 +1,148 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include "php_aws_crt.h"
+
+/* PHP streams info:
+ * https://git.php.net/?p=php-src.git;a=blob;f=docs/streams.md;h=0ec3846d68bf70067297d8a6c691d2591c49b48a;hb=HEAD
+ * https://github.com/php/php-src/blob/PHP-5.6.0/main/php_streams.h
+ */
+
+PHP_FUNCTION(aws_crt_input_stream_options_new) {
+ if (zend_parse_parameters_none() == FAILURE) {
+ aws_php_argparse_fail();
+ }
+
+ aws_crt_input_stream_options *options = aws_crt_input_stream_options_new();
+ RETURN_LONG((zend_ulong)options);
+}
+
+PHP_FUNCTION(aws_crt_input_stream_options_release) {
+ zend_ulong php_options = 0;
+
+ aws_php_parse_parameters("l", &php_options);
+
+ aws_crt_input_stream_options *options = (void *)php_options;
+ aws_crt_input_stream_options_release(options);
+}
+
+PHP_FUNCTION(aws_crt_input_stream_options_set_user_data) {
+ zend_ulong php_options = 0;
+ zval *user_data = NULL;
+
+ aws_php_parse_parameters("lz", &php_options, &user_data);
+
+ aws_crt_input_stream_options *options = (void *)php_options;
+ php_stream *stream = NULL;
+ AWS_PHP_STREAM_FROM_ZVAL(stream, user_data);
+ aws_crt_input_stream_options_set_user_data(options, stream);
+}
+
+static int s_php_stream_seek(void *user_data, int64_t offset, aws_crt_input_stream_seek_basis basis) {
+ php_stream *stream = user_data;
+ return php_stream_seek(stream, offset, basis);
+}
+
+static int s_php_stream_read(void *user_data, uint8_t *dest, size_t dest_length) {
+ php_stream *stream = user_data;
+ return php_stream_read(stream, (char *)dest, dest_length) != 0;
+}
+
+static int s_php_stream_get_length(void *user_data, int64_t *out_length) {
+ php_stream *stream = user_data;
+ size_t pos = php_stream_tell(stream);
+ php_stream_seek(stream, 0, SEEK_END);
+ *out_length = php_stream_tell(stream);
+ php_stream_seek(stream, pos, SEEK_SET);
+ return 0;
+}
+
+static int s_php_stream_get_status(void *user_data, aws_crt_input_stream_status *out_status) {
+ php_stream *stream = user_data;
+ out_status->is_valid = stream != NULL;
+ /* We would like to use php_stream_eof here, but certain streams (notably php://memory)
+ * are not actually capable of EOF, so we get to do it the hard way */
+ int64_t length = 0;
+ int64_t pos = 0;
+ s_php_stream_get_length(stream, &length);
+ pos = php_stream_tell(stream);
+ out_status->is_end_of_stream = pos == length;
+ return 0;
+}
+
+static void s_php_stream_destroy(void *user_data) {
+ (void)user_data;
+ /* no op, stream will be freed by PHP refcount dropping from InputStream::stream */
+}
+
+PHP_FUNCTION(aws_crt_input_stream_new) {
+ zend_ulong php_options = 0;
+
+ aws_php_parse_parameters("l", &php_options);
+
+ aws_crt_input_stream_options *options = (void *)php_options;
+ aws_crt_input_stream_options_set_seek(options, s_php_stream_seek);
+ aws_crt_input_stream_options_set_read(options, s_php_stream_read);
+ aws_crt_input_stream_options_set_get_status(options, s_php_stream_get_status);
+ aws_crt_input_stream_options_set_get_length(options, s_php_stream_get_length);
+ aws_crt_input_stream_options_set_destroy(options, s_php_stream_destroy);
+ aws_crt_input_stream *stream = aws_crt_input_stream_new(options);
+ RETURN_LONG((zend_ulong)stream);
+}
+
+PHP_FUNCTION(aws_crt_input_stream_release) {
+ zend_ulong php_stream = 0;
+
+ aws_php_parse_parameters("l", &php_stream);
+
+ aws_crt_input_stream *stream = (void *)php_stream;
+ aws_crt_input_stream_release(stream);
+}
+
+PHP_FUNCTION(aws_crt_input_stream_seek) {
+ zend_ulong php_stream = 0;
+ zend_ulong offset = 0;
+ zend_ulong basis = 0;
+
+ aws_php_parse_parameters("lll", &php_stream, &offset, &basis);
+
+ aws_crt_input_stream *stream = (void *)php_stream;
+ RETURN_LONG(aws_crt_input_stream_seek(stream, offset, basis));
+}
+
+PHP_FUNCTION(aws_crt_input_stream_read) {
+ zend_ulong php_stream = 0;
+ zend_ulong length = 0;
+
+ aws_php_parse_parameters("ll", &php_stream, &length);
+
+ aws_crt_input_stream *stream = (void *)php_stream;
+ uint8_t *buf = emalloc(length);
+ int ret = aws_crt_input_stream_read(stream, buf, length);
+ XRETVAL_STRINGL((const char *)buf, length);
+ efree(buf);
+}
+
+PHP_FUNCTION(aws_crt_input_stream_eof) {
+ zend_ulong php_stream = 0;
+
+ aws_php_parse_parameters("l", &php_stream);
+
+ aws_crt_input_stream *stream = (void *)php_stream;
+ aws_crt_input_stream_status status = {0};
+ aws_crt_input_stream_get_status(stream, &status);
+ RETURN_BOOL(status.is_end_of_stream);
+}
+
+PHP_FUNCTION(aws_crt_input_stream_get_length) {
+ zend_ulong php_stream = 0;
+
+ aws_php_parse_parameters("l", &php_stream);
+
+ aws_crt_input_stream *stream = (void *)php_stream;
+ int64_t length = 0;
+ aws_crt_input_stream_get_length(stream, &length);
+ RETURN_LONG(length);
+}