mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-18 01:57:13 +00:00
HTTP message API (#19)
* HTTP message API * Added MacOS CI * Grabbed fixes for mac from aws-crt-ffi
This commit is contained in:
@@ -61,7 +61,7 @@ PHP_FUNCTION(aws_crt_last_error) {
|
||||
PHP_FUNCTION(aws_crt_error_str) {
|
||||
zend_ulong error_code = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error_code) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &error_code) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ PHP_FUNCTION(aws_crt_error_str) {
|
||||
PHP_FUNCTION(aws_crt_error_name) {
|
||||
zend_ulong error_code = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error_code) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &error_code) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ PHP_FUNCTION(aws_crt_error_name) {
|
||||
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) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &error_code) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ PHP_FUNCTION(aws_crt_event_loop_group_options_new) {
|
||||
PHP_FUNCTION(aws_crt_event_loop_group_options_release) {
|
||||
zend_ulong php_options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ PHP_FUNCTION(aws_crt_event_loop_group_options_set_max_threads) {
|
||||
zend_ulong php_options = 0;
|
||||
zend_ulong num_threads = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &php_options, &num_threads) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &php_options, &num_threads) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ PHP_FUNCTION(aws_crt_event_loop_group_options_set_max_threads) {
|
||||
PHP_FUNCTION(aws_crt_event_loop_group_new) {
|
||||
zend_ulong php_options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ PHP_FUNCTION(aws_crt_event_loop_group_new) {
|
||||
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) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_elg) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ PHP_FUNCTION(aws_crt_input_stream_options_new) {
|
||||
PHP_FUNCTION(aws_crt_input_stream_options_release) {
|
||||
zend_ulong php_options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ PHP_FUNCTION(aws_crt_input_stream_options_set_user_data) {
|
||||
zend_ulong php_options = 0;
|
||||
zval *user_data = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", &php_options, &user_data) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &php_options, &user_data) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ static int s_php_stream_seek(void *user_data, int64_t offset, aws_crt_input_stre
|
||||
|
||||
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, dest, dest_length) != 0;
|
||||
return php_stream_read(stream, (char *)dest, dest_length) != 0;
|
||||
}
|
||||
|
||||
static int s_php_stream_get_length(void *user_data, int64_t *out_length) {
|
||||
@@ -204,7 +204,8 @@ static int s_php_stream_get_status(void *user_data, aws_crt_input_stream_status
|
||||
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 */
|
||||
size_t length = 0, pos = 0;
|
||||
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;
|
||||
@@ -219,7 +220,7 @@ static void s_php_stream_destroy(void *user_data) {
|
||||
PHP_FUNCTION(aws_crt_input_stream_new) {
|
||||
zend_ulong php_options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -236,7 +237,7 @@ PHP_FUNCTION(aws_crt_input_stream_new) {
|
||||
PHP_FUNCTION(aws_crt_input_stream_release) {
|
||||
zend_ulong php_stream = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_stream) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_stream) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -249,7 +250,7 @@ PHP_FUNCTION(aws_crt_input_stream_seek) {
|
||||
zend_ulong offset = 0;
|
||||
zend_ulong basis = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &php_stream, &offset, &basis) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &php_stream, &offset, &basis) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -261,21 +262,21 @@ PHP_FUNCTION(aws_crt_input_stream_read) {
|
||||
zend_ulong php_stream = 0;
|
||||
zend_ulong length = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &php_stream, &length) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &php_stream, &length) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
aws_crt_input_stream *stream = (void *)php_stream;
|
||||
uint8_t *buf = emalloc(length);
|
||||
int ret = aws_crt_input_stream_read(stream, buf, length);
|
||||
AWS_RETURN_STRINGL(buf, length);
|
||||
AWS_RETURN_STRINGL((const char *)buf, length);
|
||||
efree(buf);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(aws_crt_input_stream_eof) {
|
||||
zend_ulong php_stream = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_stream) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_stream) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -288,16 +289,54 @@ PHP_FUNCTION(aws_crt_input_stream_eof) {
|
||||
PHP_FUNCTION(aws_crt_input_stream_get_length) {
|
||||
zend_ulong php_stream = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_stream) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_stream) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
aws_crt_input_stream *stream = (void *)php_stream;
|
||||
size_t length = 0;
|
||||
int64_t length = 0;
|
||||
aws_crt_input_stream_get_length(stream, &length);
|
||||
RETURN_LONG(length);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(aws_crt_http_message_new_from_blob) {
|
||||
const char *blob = NULL;
|
||||
size_t blob_len = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &blob, &blob_len) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_msg) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
aws_crt_http_message *message = (void *)php_msg;
|
||||
uint8_t *blob = NULL;
|
||||
size_t blob_len = 0;
|
||||
aws_crt_http_message_to_blob(message, &blob, &blob_len);
|
||||
AWS_RETURN_STRINGL((const char *)blob, blob_len);
|
||||
aws_crt_mem_release(blob);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(aws_crt_http_message_release) {
|
||||
zend_ulong php_msg = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_msg) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
aws_crt_http_message *message = (void *)php_msg;
|
||||
aws_crt_http_message_release(message);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(aws_crt_credentials_options_new) {
|
||||
aws_crt_credentials_options *options = aws_crt_credentials_options_new();
|
||||
RETURN_LONG((zend_ulong)options);
|
||||
@@ -306,7 +345,7 @@ PHP_FUNCTION(aws_crt_credentials_options_new) {
|
||||
PHP_FUNCTION(aws_crt_credentials_options_release) {
|
||||
zend_ulong php_options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -319,8 +358,7 @@ PHP_FUNCTION(aws_crt_credentials_options_set_access_key_id) {
|
||||
const char *access_key_id = NULL;
|
||||
size_t access_key_id_len = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &access_key_id, &access_key_id_len) ==
|
||||
FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &access_key_id, &access_key_id_len) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -333,8 +371,8 @@ PHP_FUNCTION(aws_crt_credentials_options_set_secret_access_key) {
|
||||
const char *secret_access_key = NULL;
|
||||
size_t secret_access_key_len = 0;
|
||||
|
||||
if (zend_parse_parameters(
|
||||
ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &secret_access_key, &secret_access_key_len) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &secret_access_key, &secret_access_key_len) ==
|
||||
FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -347,8 +385,7 @@ PHP_FUNCTION(aws_crt_credentials_options_set_session_token) {
|
||||
const char *session_token = NULL;
|
||||
size_t session_token_len = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &session_token, &session_token_len) ==
|
||||
FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &session_token, &session_token_len) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -359,8 +396,7 @@ PHP_FUNCTION(aws_crt_credentials_options_set_session_token) {
|
||||
PHP_FUNCTION(aws_crt_credentials_options_set_expiration_timepoint_seconds) {
|
||||
zend_ulong php_options = 0;
|
||||
zend_ulong expiration_timepoint_seconds = 0;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &php_options, &expiration_timepoint_seconds) ==
|
||||
FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &php_options, &expiration_timepoint_seconds) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -371,7 +407,7 @@ PHP_FUNCTION(aws_crt_credentials_options_set_expiration_timepoint_seconds) {
|
||||
PHP_FUNCTION(aws_crt_credentials_new) {
|
||||
zend_ulong php_options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -383,7 +419,7 @@ PHP_FUNCTION(aws_crt_credentials_new) {
|
||||
PHP_FUNCTION(aws_crt_credentials_release) {
|
||||
zend_ulong php_credentials = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_credentials) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_credentials) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -394,7 +430,7 @@ PHP_FUNCTION(aws_crt_credentials_release) {
|
||||
PHP_FUNCTION(aws_crt_credentials_provider_release) {
|
||||
zend_ulong php_creds_provider = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_creds_provider) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_creds_provider) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -410,7 +446,7 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_new) {
|
||||
PHP_FUNCTION(aws_crt_credentials_provider_static_options_release) {
|
||||
zend_ulong php_options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -423,8 +459,7 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_access_key_id) {
|
||||
const char *access_key_id = NULL;
|
||||
size_t access_key_id_len = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &access_key_id, &access_key_id_len) ==
|
||||
FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &access_key_id, &access_key_id_len) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -437,8 +472,8 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_secret_access_key)
|
||||
const char *secret_access_key = NULL;
|
||||
size_t secret_access_key_len = 0;
|
||||
|
||||
if (zend_parse_parameters(
|
||||
ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &secret_access_key, &secret_access_key_len) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &secret_access_key, &secret_access_key_len) ==
|
||||
FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -452,8 +487,7 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_session_token) {
|
||||
const char *session_token = NULL;
|
||||
size_t session_token_len = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &php_options, &session_token, &session_token_len) ==
|
||||
FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &php_options, &session_token, &session_token_len) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -464,7 +498,7 @@ PHP_FUNCTION(aws_crt_credentials_provider_static_options_set_session_token) {
|
||||
PHP_FUNCTION(aws_crt_credentials_provider_static_new) {
|
||||
zend_ulong php_options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &php_options) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &php_options) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user