| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include <aws/sdkutils/private/endpoints_types_impl.h> |
| 7 |
#include <aws/sdkutils/sdkutils.h> |
| 8 |
|
| 9 |
|
| 10 |
static struct aws_error_info s_errors[] = { |
| 11 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_GENERAL, "General error in SDK Utility library", "aws-c-sdkutils"), |
| 12 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_PARSE_FATAL, "Parser encountered a fatal error", "aws-c-sdkutils"), |
| 13 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_PARSE_RECOVERABLE, "Parser encountered an error, but recovered", "aws-c-sdkutils"), |
| 14 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_ENDPOINTS_UNSUPPORTED_RULESET, "Ruleset version not supported", "aws-c-sdkutils"), |
| 15 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_ENDPOINTS_PARSE_FAILED, "Ruleset parsing failed", "aws-c-sdkutils"), |
| 16 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_ENDPOINTS_RESOLVE_INIT_FAILED, "Endpoints eval failed to initialize", "aws-c-sdkutils"), |
| 17 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_ENDPOINTS_RESOLVE_FAILED, "Unexpected eval error", "aws-c-sdkutils"), |
| 18 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_ENDPOINTS_EMPTY_RULESET, "Ruleset has no rules", "aws-c-sdkutils"), |
| 19 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_ENDPOINTS_RULESET_EXHAUSTED, "Ruleset was exhausted before finding a matching rule", "aws-c-sdkutils"), |
| 20 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_PARTITIONS_UNSUPPORTED, "Partitions version not supported.", "aws-c-sdkutils"), |
| 21 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_PARTITIONS_PARSE_FAILED, "Partitions parsing failed.", "aws-c-sdkutils"), |
| 22 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_ENDPOINTS_UNSUPPORTED_REGEX, "Unsupported regex feature.", "aws-c-sdkutils"), |
| 23 |
AWS_DEFINE_ERROR_INFO(AWS_ERROR_SDKUTILS_ENDPOINTS_REGEX_NO_MATCH, "Text does not match specified regex", "aws-c-sdkutils"), |
| 24 |
}; |
| 25 |
|
| 26 |
|
| 27 |
static struct aws_error_info_list s_sdkutils_error_info = { |
| 28 |
.error_list = s_errors, |
| 29 |
.count = sizeof(s_errors) / sizeof(struct aws_error_info), |
| 30 |
}; |
| 31 |
|
| 32 |
static struct aws_log_subject_info s_log_subject_infos[] = { |
| 33 |
DEFINE_LOG_SUBJECT_INFO( |
| 34 |
AWS_LS_SDKUTILS_GENERAL, |
| 35 |
"SDKUtils", |
| 36 |
"Subject for SDK utility logging that defies categorization."), |
| 37 |
DEFINE_LOG_SUBJECT_INFO(AWS_LS_SDKUTILS_PROFILE, "AWSProfile", "Subject for AWS Profile parser and utilities"), |
| 38 |
DEFINE_LOG_SUBJECT_INFO( |
| 39 |
AWS_LS_SDKUTILS_ENDPOINTS_PARSING, |
| 40 |
"AWSEndpointsParsing", |
| 41 |
"Subject for AWS Endpoints ruleset parser"), |
| 42 |
DEFINE_LOG_SUBJECT_INFO( |
| 43 |
AWS_LS_SDKUTILS_ENDPOINTS_RESOLVE, |
| 44 |
"AWSEndpointsResolution", |
| 45 |
"Subject for AWS Endpoints Engine resolution"), |
| 46 |
DEFINE_LOG_SUBJECT_INFO( |
| 47 |
AWS_LS_SDKUTILS_ENDPOINTS_GENERAL, |
| 48 |
"AWSEndpoints", |
| 49 |
"Subject for AWS Endpoints Engine general messages"), |
| 50 |
DEFINE_LOG_SUBJECT_INFO(AWS_LS_SDKUTILS_PARTITIONS_PARSING, "AWSEndpoints", "Subject for AWS Partitions parsing"), |
| 51 |
DEFINE_LOG_SUBJECT_INFO(AWS_LS_SDKUTILS_ENDPOINTS_REGEX, "AWSEndpoints", "Subject for AWS Endpoints Regex engine"), |
| 52 |
}; |
| 53 |
|
| 54 |
static struct aws_log_subject_info_list s_sdkutils_log_subjects = { |
| 55 |
.subject_list = s_log_subject_infos, |
| 56 |
.count = AWS_ARRAY_SIZE(s_log_subject_infos), |
| 57 |
}; |
| 58 |
|
| 59 |
static int s_library_init_count = 0; |
| 60 |
|
| 61 |
void aws_sdkutils_library_init(struct aws_allocator *allocator) { |
| 62 |
if (s_library_init_count++ != 0) { |
| 63 |
return; |
| 64 |
} |
| 65 |
|
| 66 |
aws_common_library_init(allocator); |
| 67 |
|
| 68 |
aws_register_error_info(&s_sdkutils_error_info); |
| 69 |
aws_register_log_subject_info_list(&s_sdkutils_log_subjects); |
| 70 |
|
| 71 |
aws_endpoints_rule_engine_init(); |
| 72 |
} |
| 73 |
|
| 74 |
void aws_sdkutils_library_clean_up(void) { |
| 75 |
if (--s_library_init_count != 0) { |
| 76 |
return; |
| 77 |
} |
| 78 |
|
| 79 |
aws_unregister_log_subject_info_list(&s_sdkutils_log_subjects); |
| 80 |
aws_unregister_error_info(&s_sdkutils_error_info); |
| 81 |
|
| 82 |
aws_common_library_clean_up(); |
| 83 |
} |