in source/s3_list_objects.c [199:289]
static bool s_on_list_bucket_result_node_encountered(
struct aws_xml_parser *parser,
struct aws_xml_node *node,
void *user_data) {
struct aws_s3_paginator *paginator = user_data;
struct aws_byte_cursor node_name;
aws_xml_node_get_name(node, &node_name);
struct fs_parser_wrapper fs_wrapper;
AWS_ZERO_STRUCT(fs_wrapper);
if (aws_byte_cursor_eq_c_str_ignore_case(&node_name, "Contents")) {
fs_wrapper.allocator = paginator->allocator;
/* this will traverse the current Contents node, get the metadata necessary to construct
* an instance of fs_info so we can invoke the callback on it. This happens once per object. */
bool ret_val = aws_xml_node_traverse(parser, node, s_on_contents_node, &fs_wrapper) == AWS_OP_SUCCESS;
if (paginator->prefix && !fs_wrapper.fs_info.prefix.len) {
fs_wrapper.fs_info.prefix = aws_byte_cursor_from_string(paginator->prefix);
}
struct aws_byte_buf trimmed_etag;
AWS_ZERO_STRUCT(trimmed_etag);
if (fs_wrapper.fs_info.e_tag.len) {
struct aws_string *quoted_etag_str =
aws_string_new_from_cursor(fs_wrapper.allocator, &fs_wrapper.fs_info.e_tag);
replace_quote_entities(fs_wrapper.allocator, quoted_etag_str, &trimmed_etag);
fs_wrapper.fs_info.e_tag = aws_byte_cursor_from_buf(&trimmed_etag);
aws_string_destroy(quoted_etag_str);
}
if (ret_val && paginator->on_object) {
ret_val |= paginator->on_object(&fs_wrapper.fs_info, paginator->user_data);
}
if (trimmed_etag.len) {
aws_byte_buf_clean_up(&trimmed_etag);
}
return ret_val;
}
if (aws_byte_cursor_eq_c_str_ignore_case(&node_name, "CommonPrefixes")) {
/* this will traverse the current CommonPrefixes node, get the metadata necessary to construct
* an instance of fs_info so we can invoke the callback on it. This happens once per prefix. */
bool ret_val = aws_xml_node_traverse(parser, node, s_on_common_prefixes_node, &fs_wrapper) == AWS_OP_SUCCESS;
if (ret_val && paginator->on_object) {
ret_val |= paginator->on_object(&fs_wrapper.fs_info, paginator->user_data);
}
return ret_val;
}
if (aws_byte_cursor_eq_c_str_ignore_case(&node_name, "NextContinuationToken")) {
struct aws_byte_cursor continuation_token_cur;
bool ret_val = aws_xml_node_as_body(parser, node, &continuation_token_cur) == AWS_OP_SUCCESS;
if (ret_val) {
aws_mutex_lock(&paginator->shared_mt_state.lock);
if (paginator->shared_mt_state.continuation_token) {
aws_string_destroy(paginator->shared_mt_state.continuation_token);
}
paginator->shared_mt_state.continuation_token =
aws_string_new_from_cursor(paginator->allocator, &continuation_token_cur);
aws_mutex_unlock(&paginator->shared_mt_state.lock);
}
return ret_val;
}
if (aws_byte_cursor_eq_c_str_ignore_case(&node_name, "IsTruncated")) {
struct aws_byte_cursor truncated_cur;
bool ret_val = aws_xml_node_as_body(parser, node, &truncated_cur) == AWS_OP_SUCCESS;
if (ret_val) {
if (aws_byte_cursor_eq_c_str_ignore_case(&truncated_cur, "true")) {
aws_mutex_lock(&paginator->shared_mt_state.lock);
paginator->shared_mt_state.has_more_results = true;
aws_mutex_unlock(&paginator->shared_mt_state.lock);
}
}
return ret_val;
}
return true;
}