LibAwsCommon

Documentation for LibAwsCommon.

LibAwsCommon.__itt_relationType
__itt_relation

relations

The kind of relation between two instances is specified by the enumerated type __itt_relation. Relations between instances can be added with an API call. The relation API uses instance IDs. Relations can be added before or after the actual instances are created and persist independently of the instances. This is the motivation for having different lifetimes for instance IDs and the actual instances.

source
LibAwsCommon.aws_array_list_comparator_fnType

Prototype for a comparator function for sorting elements.

a and b should be cast to pointers to the element type held in the list before being dereferenced. The function should compare the elements and return a positive number if a > b, zero if a = b, and a negative number if a < b.

source
LibAwsCommon.aws_atomic_varType
aws_atomic_var

struct aws_atomic_var represents an atomic variable - a value which can hold an integer or pointer that can be manipulated atomically. struct aws_atomic_vars should normally only be manipulated with atomics methods defined in this header.

source
LibAwsCommon.aws_byte_bufType
aws_byte_buf

Represents a length-delimited binary string or buffer. If byte buffer points to constant memory or memory that should otherwise not be freed by this struct, set allocator to NULL and free function will be a no-op.

This structure used to define the output for all functions that write to a buffer.

Note that this structure allocates memory at the buffer pointer only. The struct itself does not get dynamically allocated and must be either maintained or copied to avoid losing access to the memory.

source
LibAwsCommon.aws_byte_cursorType
aws_byte_cursor

Represents a movable pointer within a larger binary string or buffer.

This structure is used to define buffers for reading.

source
LibAwsCommon.aws_cli_optionType
aws_cli_option

Ignoring padding since we're trying to maintain getopt.h compatibility

NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)

source
LibAwsCommon.aws_crt_common_statistics_categoryType
aws_crt_common_statistics_category

The common-specific range of the aws_crt_statistics_category cross-library enum.

This enum functions as an RTTI value that lets statistics handler's interpret (via cast) a specific statistics structure if the RTTI value is understood.

Common doesn't have any statistics structures presently, so its range is essentially empty.

source
LibAwsCommon.aws_crt_statistics_baseType
aws_crt_statistics_base

Pattern-struct that functions as a base "class" for all statistics structures. To conform to the pattern, a statistics structure must have its first member be the category. In that case it becomes "safe" to cast from aws_crt_statistics_base to the specific statistics structure based on the category value.

source
LibAwsCommon.aws_crt_statistics_handlerType
aws_crt_statistics_handler

Base structure for all statistics handler implementations.

A statistics handler is an object that listens to a stream of polymorphic (via the category RTTI enum) statistics structures emitted from some arbitrary source. In the initial implementation, statistics handlers are primarily attached to channels, where they monitor IO throughput and state data (from channel handlers) to determine a connection's health.

Statistics handlers are a generalization of the timeout and bandwidth filters that are often associated with SDK network connections. Configurable, default implementations are defined at the protocol level (http, etc...) where they can be attached at connection (channel) creation time.

source
LibAwsCommon.aws_hash_callback_destroy_fnType

Prototype for a hash table key or value destructor function pointer.

This function is used to destroy elements in the hash table when the table is cleared or cleaned up.

Note that functions which remove individual elements from the hash table provide options of whether or not to invoke the destructors on the key and value of a removed element.

source
LibAwsCommon.aws_hash_callback_eq_fnType

Prototype for a hash table equality check function pointer.

This type is usually used for a function that compares two hash table keys, but note that the same type is used for a function that compares two hash table values in aws_hash_table_eq.

Equality functions used in a hash table must be be reflexive (a == a), symmetric (a == b => b == a), transitive (a == b, b == c => a == c) and consistent (result does not change with time).

source
LibAwsCommon.aws_hash_elementType
aws_hash_element

Represents an element in the hash table. Various operations on the hash table may provide pointers to elements stored within the hash table; generally, calling code may alter value, but must not alter key (or any information used to compute key's hash code).

Pointers to elements within the hash are invalidated whenever an operation which may change the number of elements in the hash is invoked (i.e. put, delete, clear, and clean_up), regardless of whether the number of elements actually changes.

source
LibAwsCommon.aws_linked_hash_tableType
aws_linked_hash_table

Simple linked hash table. Preserves insertion order, and can be iterated in insertion order.

You can also change the order safely without altering the shape of the underlying hash table.

source
LibAwsCommon.aws_log_channelType
aws_log_channel

Log channel interface and default implementations

A log channel is an abstraction for the transfer of formatted log data between a source (formatter) and a sink (writer).

source
LibAwsCommon.aws_log_formatterType
aws_log_formatter

Log formatter interface and default implementation

Log formatters are invoked by the LOGF_* macros to transform a set of arguments into one or more lines of text to be output to a logging sink (writer).

source
LibAwsCommon.aws_log_levelType
aws_log_level

Controls what log calls pass through the logger and what log calls get filtered out. If a log level has a value of X, then all log calls using a level <= X will appear, while those using a value > X will not occur.

You can filter both dynamically (by setting the log level on the logger object) or statically (by defining AWS_STATIC_LOG_LEVEL to be an appropriate integer module-wide). Statically filtered log calls will be completely compiled out but require a rebuild if you want to get more detail about what's happening.

source
LibAwsCommon.aws_log_subject_tType

Log subject is a way of designating the topic of logging.

The general idea is to support a finer-grained approach to log level control. The primary use case is for situations that require more detailed logging within a specific domain, where enabling that detail globally leads to an untenable flood of information.

For example, enable TRACE logging for tls-related log statements (handshake binary payloads), but only WARN logging everywhere else (because http payloads would blow up the log files).

Log subject is an enum similar to aws error: each library has its own value-space and someone is responsible for registering the value <-> string connections.

source
LibAwsCommon.aws_log_writerType
aws_log_writer

Log writer interface and default implementation(s)

A log writer functions as a sink for formatted log lines. We provide default implementations that go to stdout, stderr, and a specified file.

source
LibAwsCommon.aws_logger_pipelineType
aws_logger_pipeline

Standard logger implementation composing three sub-components:

The formatter takes var args input from the user and produces a formatted log line The writer takes a formatted log line and outputs it somewhere The channel is the transport between the two

source
LibAwsCommon.aws_logger_vtableType
aws_logger_vtable

We separate the log level function from the log call itself so that we can do the filter check in the macros (see below)

By doing so, we make it so that the variadic format arguments are not even evaluated if the filter check does not succeed.

source
LibAwsCommon.aws_mem_trace_levelType
aws_mem_trace_level

Maintainer note: The above function doesn't return the pointer (as with standard C realloc) as this pattern becomes error-prone when OOMs occur. In particular, we want to avoid losing the old pointer when an OOM condition occurs, so we prefer to take the old pointer as an in/out reference argument that we can leave unchanged on failure.

source
LibAwsCommon.aws_memory_orderType
aws_memory_order

This enumeration specifies the memory ordering properties requested for a particular atomic operation. The atomic operation may provide stricter ordering than requested. Note that, within a single thread, all operations are still sequenced (that is, a thread sees its own atomic writes and reads happening in program order, but other threads may disagree on this ordering).

The behavior of these memory orderings are the same as in the C11 atomics API; however, we only implement a subset that can be portably implemented on the compilers we target.

source
LibAwsCommon.aws_priority_queue_compare_fnType

The comparator should return a positive value if the second argument has a higher priority than the first; Otherwise, it should return a negative value or zero. NOTE: priority_queue pops its highest priority element first. For example: int cmp(const void *a, const void *b) { return a < b; } would result in a max heap, while: int cmp(const void *a, const void *b) { return a > b; } would result in a min heap.

source
LibAwsCommon.aws_promiseType

Standard promise interface. Promise can be waited on by multiple threads, and as long as it is ref-counted correctly, will provide the resultant value/error code to all waiters. All promise API calls are internally thread-safe.

source
LibAwsCommon.aws_ring_bufferType
aws_ring_buffer

Lockless ring buffer implementation that is thread safe assuming a single thread acquires and a single thread releases. For any other use case (other than the single-threaded use-case), you must manage thread-safety manually.

Also, a very important note: release must happen in the same order as acquire. If you do not your application, and possibly computers within a thousand mile radius, may die terrible deaths, and the local drinking water will be poisoned for generations with fragments of what is left of your radioactive corrupted memory.

source
LibAwsCommon.aws_taskType
aws_task

A task object. Once added to the scheduler, a task must remain in memory until its function is executed.

source
LibAwsCommon.aws_thread_join_strategyType
aws_thread_join_strategy

Specifies the join strategy used on an aws_thread, which in turn controls whether or not a thread participates in the managed thread system. The managed thread system provides logic to guarantee a join on all participating threads at the cost of laziness (the user cannot control when joins happen).

Manual - thread does not participate in the managed thread system; any joins must be done by the user. This is the default. The user must call aws_thread_clean_up(), but only after any desired join operation has completed. Not doing so will cause the windows handle to leak.

Managed - the managed thread system will automatically perform a join some time after the thread's run function has completed. It is an error to call aws_thread_join on a thread configured with the managed join strategy. The managed thread system will call aws_thread_clean_up() on the thread after the background join has completed.

Additionally, an API exists, aws_thread_join_all_managed(), which blocks and returns when all outstanding threads with the managed strategy have fully joined. This API is useful for tests (rather than waiting for many individual signals) and program shutdown or DLL unload. This API is automatically invoked by the common library clean up function. If the common library clean up is called from a managed thread, this will cause deadlock.

Lazy thread joining is done only when threads finish their run function or when the user calls aws_thread_join_all_managed(). This means it may be a long time between thread function completion and the join being applied, but the queue of unjoined threads is always one or fewer so there is no critical resource backlog.

Currently, only event loop group async cleanup and host resolver threads participate in the managed thread system. Additionally, event loop threads will increment and decrement the pending join count (they are manually joined internally) in order to have an accurate view of internal thread usage and also to prevent failure to release an event loop group fully from allowing aws_thread_join_all_managed() from running to completion when its intent is such that it should block instead.

source
LibAwsCommon.aws_uriType
aws_uri

Data representing a URI. uri_str is always allocated and filled in. The other portions are merely storing offsets into uri_str.

source
LibAwsCommon.aws_uri_builder_optionsType
aws_uri_builder_options

Arguments for building a URI instance. All members must be initialized before passing them to aws_uri_init().

query_string and query_params are exclusive to each other. If you set query_string, do not prepend it with '?'

source
LibAwsCommon.aws_uri_paramType
aws_uri_param

key/value pairs for a query string. If the query fragment was not in format key=value, the fragment value will be stored in key

source
LibAwsCommon.aws_xml_parser_on_node_encountered_fnType

Callback for when an xml node is encountered in the document. As a user you have a few options:

  1. fail the parse by returning AWS_OP_ERR (after an error has been raised). This will stop any further parsing. 2. call aws_xml_node_traverse() on the node to descend into the node with a new callback and user_data. 3. call aws_xml_node_as_body() to retrieve the contents of the node as text.

You MUST NOT call both aws_xml_node_traverse() and aws_xml_node_as_body() on the same node.

return true to continue the parsing operation.

source
LibAwsCommon.hash_table_stateType

Hash table data structure. This module provides an automatically resizing hash table implementation for general purpose use. The hash table stores a mapping between void * keys and values; it is expected that in most cases, these will point to a structure elsewhere in the heap, instead of inlining a key or value into the hash table element itself.

Currently, this hash table implements a variant of robin hood hashing, but we do not guarantee that this won't change in the future.

Associated with each hash function are four callbacks:

hash_fn - A hash function from the keys to a uint64_t. It is critical that the hash function for a key does not change while the key is in the hash table; violating this results in undefined behavior. Collisions are tolerated, though naturally with reduced performance.

equals_fn - An equality comparison function. This function must be reflexive and consistent with hash_fn.

destroy_key_fn, destroy_value_fn - Optional callbacks invoked when the table is cleared or cleaned up and at the caller's option when an element is removed from the table. Either or both may be set to NULL, which has the same effect as a no-op destroy function.

This datastructure can be safely moved between threads, subject to the requirements of the underlying allocator. It is also safe to invoke non-mutating operations on the hash table from multiple threads. A suitable memory barrier must be used when transitioning from single-threaded mutating usage to multithreaded usage.

source
LibAwsCommon.aws_add_size_saturatingMethod
aws_add_size_saturating(a, b)

Adds a + b. If the result overflows returns SIZE_MAX.

Prototype

AWS_STATIC_IMPL size_t aws_add_size_saturating(size_t a, size_t b);
source
LibAwsCommon.aws_add_u32_saturatingMethod
aws_add_u32_saturating(a, b)

Adds a + b. If the result overflows, returns 2^32 - 1.

Prototype

AWS_STATIC_IMPL uint32_t aws_add_u32_saturating(uint32_t a, uint32_t b);
source
LibAwsCommon.aws_add_u64_saturatingMethod
aws_add_u64_saturating(a, b)

Adds a + b. If the result overflows, returns 2^64 - 1.

Prototype

AWS_STATIC_IMPL uint64_t aws_add_u64_saturating(uint64_t a, uint64_t b);
source
LibAwsCommon.aws_aligned_allocatorMethod
aws_aligned_allocator()

Allocator that align small allocations on 8 byte boundary and big allocations on 32/64 byte boundary.

Prototype

struct aws_allocator *aws_aligned_allocator(void);
source
LibAwsCommon.aws_allocator_is_validMethod
aws_allocator_is_valid(alloc)

Inexpensive (constant time) check of data-structure invariants.

Prototype

bool aws_allocator_is_valid(const struct aws_allocator *alloc);
source
LibAwsCommon.aws_array_eqMethod
aws_array_eq(array_a, len_a, array_b, len_b)

Compare two arrays. Return whether their contents are equivalent. NULL may be passed as the array pointer if its length is declared to be 0.

Prototype

bool aws_array_eq(const void *const array_a, const size_t len_a, const void *array_b, const size_t len_b);
source
LibAwsCommon.aws_array_eq_c_strMethod
aws_array_eq_c_str(array, array_len, c_str)

Compare an array and a null-terminated string. Returns true if their contents are equivalent. The array should NOT contain a null-terminator, or the comparison will always return false. NULL may be passed as the array pointer if its length is declared to be 0.

Prototype

bool aws_array_eq_c_str(const void *const array, const size_t array_len, const char *const c_str);
source
LibAwsCommon.aws_array_eq_c_str_ignore_caseMethod
aws_array_eq_c_str_ignore_case(array, array_len, c_str)

Perform a case-insensitive string comparison of an array and a null-terminated string. Return whether their contents are equivalent. The array should NOT contain a null-terminator, or the comparison will always return false. NULL may be passed as the array pointer if its length is declared to be 0. The "C" locale is used for comparing upper and lowercase letters. Data is assumed to be ASCII text, UTF-8 will work fine too.

Prototype

bool aws_array_eq_c_str_ignore_case(const void *const array, const size_t array_len, const char *const c_str);
source
LibAwsCommon.aws_array_eq_ignore_caseMethod
aws_array_eq_ignore_case(array_a, len_a, array_b, len_b)

Perform a case-insensitive string comparison of two arrays. Return whether their contents are equivalent. NULL may be passed as the array pointer if its length is declared to be 0. The "C" locale is used for comparing upper and lowercase letters. Data is assumed to be ASCII text, UTF-8 will work fine too.

Prototype

bool aws_array_eq_ignore_case( const void *const array_a, const size_t len_a, const void *const array_b, const size_t len_b);
source
LibAwsCommon.aws_array_list_backMethod
aws_array_list_back(list, val)

Copies the element at the end of the list if it exists. If list is empty, AWS_ERROR_LIST_EMPTY will be raised.

Prototype

AWS_STATIC_IMPL int aws_array_list_back(const struct aws_array_list *AWS_RESTRICT list, void *val);
source
LibAwsCommon.aws_array_list_capacityMethod
aws_array_list_capacity(list)

Returns the number of elements that can fit in the internal array. If list is initialized in dynamic mode, the capacity changes over time.

Prototype

AWS_STATIC_IMPL size_t aws_array_list_capacity(const struct aws_array_list *AWS_RESTRICT list);
source
LibAwsCommon.aws_array_list_clean_upMethod
aws_array_list_clean_up(list)

Deallocates any memory that was allocated for this list, and resets list for reuse or deletion.

Prototype

AWS_STATIC_IMPL void aws_array_list_clean_up(struct aws_array_list *AWS_RESTRICT list);
source
LibAwsCommon.aws_array_list_clean_up_secureMethod
aws_array_list_clean_up_secure(list)

Erases and then deallocates any memory that was allocated for this list, and resets list for reuse or deletion.

Prototype

AWS_STATIC_IMPL void aws_array_list_clean_up_secure(struct aws_array_list *AWS_RESTRICT list);
source
LibAwsCommon.aws_array_list_clearMethod
aws_array_list_clear(list)

Clears all elements in the array and resets length to zero. Size does not change in this operation.

Prototype

AWS_STATIC_IMPL void aws_array_list_clear(struct aws_array_list *AWS_RESTRICT list);
source
LibAwsCommon.aws_array_list_copyMethod
aws_array_list_copy(from, to)

Copies the elements from from to to. If to is in static mode, it must at least be the same length as from. Any data in to will be overwritten in this copy.

Prototype

int aws_array_list_copy(const struct aws_array_list *AWS_RESTRICT from, struct aws_array_list *AWS_RESTRICT to);
source
LibAwsCommon.aws_array_list_ensure_capacityMethod
aws_array_list_ensure_capacity(list, index)

Ensures that the array list has enough capacity to store a value at the specified index. If there is not already enough capacity, and the list is in dynamic mode, this function will attempt to allocate more memory, expanding the list. In static mode, if 'index' is beyond the maximum index, AWS_ERROR_INVALID_INDEX will be raised.

Prototype

int aws_array_list_ensure_capacity(struct aws_array_list *AWS_RESTRICT list, size_t index);
source
LibAwsCommon.aws_array_list_eraseMethod
aws_array_list_erase(list, index)

Deletes the element this index in the list if it exists. If element does not exist, AWS_ERROR_INVALID_INDEX will be raised. This call results in shifting all remaining elements towards the front. Avoid this call unless that is intended behavior.

Prototype

AWS_STATIC_IMPL int aws_array_list_erase(struct aws_array_list *AWS_RESTRICT list, size_t index);
source
LibAwsCommon.aws_array_list_frontMethod
aws_array_list_front(list, val)

Copies the element at the front of the list if it exists. If list is empty, AWS_ERROR_LIST_EMPTY will be raised

Prototype

AWS_STATIC_IMPL int aws_array_list_front(const struct aws_array_list *AWS_RESTRICT list, void *val);
source
LibAwsCommon.aws_array_list_get_atMethod
aws_array_list_get_at(list, val, index)

Copies the memory at index to val. If element does not exist, AWS_ERROR_INVALID_INDEX will be raised.

Prototype

AWS_STATIC_IMPL int aws_array_list_get_at(const struct aws_array_list *AWS_RESTRICT list, void *val, size_t index);
source
LibAwsCommon.aws_array_list_get_at_ptrMethod
aws_array_list_get_at_ptr(list, val, index)

Copies the memory address of the element at index to *val. If element does not exist, AWS_ERROR_INVALID_INDEX will be raised.

Prototype

AWS_STATIC_IMPL int aws_array_list_get_at_ptr(const struct aws_array_list *AWS_RESTRICT list, void **val, size_t index);
source
LibAwsCommon.aws_array_list_init_dynamicMethod
aws_array_list_init_dynamic(list, alloc, initial_item_allocation, item_size)

Initializes an array list with an array of size initial_item_allocation * item_size. In this mode, the array size will grow by a factor of 2 upon insertion if space is not available. initial_item_allocation is the number of elements you want space allocated for. item_size is the size of each element in bytes. Mixing items types is not supported by this API.

Prototype

AWS_STATIC_IMPL int aws_array_list_init_dynamic( struct aws_array_list *AWS_RESTRICT list, struct aws_allocator *alloc, size_t initial_item_allocation, size_t item_size);
source
LibAwsCommon.aws_array_list_init_staticMethod
aws_array_list_init_static(list, raw_array, item_count, item_size)

Initializes an array list with a preallocated array of void *. item_count is the number of elements in the array, and item_size is the size in bytes of each element. Mixing items types is not supported by this API. Once this list is full, new items will be rejected.

Prototype

AWS_STATIC_IMPL void aws_array_list_init_static( struct aws_array_list *AWS_RESTRICT list, void *raw_array, size_t item_count, size_t item_size);
source
LibAwsCommon.aws_array_list_init_static_from_initializedMethod
aws_array_list_init_static_from_initialized(list, raw_array, item_count, item_size)

Initializes an array list with a preallocated array of already-initialized elements. item_count is the number of elements in the array, and item_size is the size in bytes of each element.

Once initialized, nothing further can be added to the list, since it will be full and cannot resize.

Primary use case is to treat an already-initialized C array as an array list.

Prototype

AWS_STATIC_IMPL void aws_array_list_init_static_from_initialized( struct aws_array_list *AWS_RESTRICT list, void *raw_array, size_t item_count, size_t item_size);
source
LibAwsCommon.aws_array_list_lengthMethod
aws_array_list_length(list)

Returns the number of elements in the internal array.

Prototype

AWS_STATIC_IMPL size_t aws_array_list_length(const struct aws_array_list *AWS_RESTRICT list);
source
LibAwsCommon.aws_array_list_pop_backMethod
aws_array_list_pop_back(list)

Deletes the element at the end of the list if it exists. If list is empty, AWS_ERROR_LIST_EMPTY will be raised.

Prototype

AWS_STATIC_IMPL int aws_array_list_pop_back(struct aws_array_list *AWS_RESTRICT list);
source
LibAwsCommon.aws_array_list_pop_frontMethod
aws_array_list_pop_front(list)

Deletes the element at the front of the list if it exists. If list is empty, AWS_ERROR_LIST_EMPTY will be raised. This call results in shifting all of the elements at the end of the array to the front. Avoid this call unless that is intended behavior.

Prototype

AWS_STATIC_IMPL int aws_array_list_pop_front(struct aws_array_list *AWS_RESTRICT list);
source
LibAwsCommon.aws_array_list_pop_front_nMethod
aws_array_list_pop_front_n(list, n)

Delete N elements from the front of the list. Remaining elements are shifted to the front of the list. If the list has less than N elements, the list is cleared. This call is more efficient than calling aws_array_list_pop_front() N times.

Prototype

AWS_STATIC_IMPL void aws_array_list_pop_front_n(struct aws_array_list *AWS_RESTRICT list, size_t n);
source
LibAwsCommon.aws_array_list_push_backMethod
aws_array_list_push_back(list, val)

Pushes the memory pointed to by val onto the end of internal list

Prototype

AWS_STATIC_IMPL int aws_array_list_push_back(struct aws_array_list *AWS_RESTRICT list, const void *val);
source
LibAwsCommon.aws_array_list_push_frontMethod
aws_array_list_push_front(list, val)

Pushes the memory pointed to by val onto the front of internal list. This call results in shifting all of the elements in the list. Avoid this call unless that is intended behavior.

Prototype

AWS_STATIC_IMPL int aws_array_list_push_front(struct aws_array_list *AWS_RESTRICT list, const void *val);
source
LibAwsCommon.aws_array_list_set_atMethod
aws_array_list_set_at(list, val, index)

Copies the the memory pointed to by val into the array at index. If in dynamic mode, the size will grow by a factor of two when the array is full. In static mode, AWS_ERROR_INVALID_INDEX will be raised if the index is past the bounds of the array.

Prototype

AWS_STATIC_IMPL int aws_array_list_set_at(struct aws_array_list *AWS_RESTRICT list, const void *val, size_t index);
source
LibAwsCommon.aws_array_list_shrink_to_fitMethod
aws_array_list_shrink_to_fit(list)

If in dynamic mode, shrinks the allocated array size to the minimum amount necessary to store its elements.

Prototype

int aws_array_list_shrink_to_fit(struct aws_array_list *AWS_RESTRICT list);
source
LibAwsCommon.aws_array_list_sortMethod
aws_array_list_sort(list, compare_fn)

Sort elements in the list in-place according to the comparator function.

Prototype

void aws_array_list_sort(struct aws_array_list *AWS_RESTRICT list, aws_array_list_comparator_fn *compare_fn);
source
LibAwsCommon.aws_array_list_swapMethod
aws_array_list_swap(list, a, b)

Swap elements at the specified indices, which must be within the bounds of the array.

Prototype

void aws_array_list_swap(struct aws_array_list *AWS_RESTRICT list, size_t a, size_t b);
source
LibAwsCommon.aws_array_list_swap_contentsMethod
aws_array_list_swap_contents(list_a, list_b)

Swap contents between two dynamic lists. Both lists must use the same allocator.

Prototype

AWS_STATIC_IMPL void aws_array_list_swap_contents( struct aws_array_list *AWS_RESTRICT list_a, struct aws_array_list *AWS_RESTRICT list_b);
source
LibAwsCommon.aws_atomic_compare_exchange_intMethod
aws_atomic_compare_exchange_int(var, expected, desired)

Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set to the value in *var. Uses sequentially consistent memory ordering, regardless of success or failure. Returns true if the compare was successful and the variable updated to desired.

Prototype

AWS_STATIC_IMPL bool aws_atomic_compare_exchange_int(volatile struct aws_atomic_var *var, size_t *expected, size_t desired);
source
LibAwsCommon.aws_atomic_compare_exchange_int_explicitMethod
aws_atomic_compare_exchange_int_explicit(var, expected, desired, order_success, order_failure)

Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set to the value in *var. On success, the memory ordering used was order_success; otherwise, it was order_failure. order_failure must be no stronger than order_success, and must not be release or acq_rel. Returns true if the compare was successful and the variable updated to desired.

Prototype

AWS_STATIC_IMPL bool aws_atomic_compare_exchange_int_explicit( volatile struct aws_atomic_var *var, size_t *expected, size_t desired, enum aws_memory_order order_success, enum aws_memory_order order_failure);
source
LibAwsCommon.aws_atomic_compare_exchange_ptrMethod
aws_atomic_compare_exchange_ptr(var, expected, desired)

Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set to the value in *var. Uses sequentially consistent memory ordering, regardless of success or failure. Returns true if the compare was successful and the variable updated to desired.

Prototype

AWS_STATIC_IMPL bool aws_atomic_compare_exchange_ptr(volatile struct aws_atomic_var *var, void **expected, void *desired);
source
LibAwsCommon.aws_atomic_compare_exchange_ptr_explicitMethod
aws_atomic_compare_exchange_ptr_explicit(var, expected, desired, order_success, order_failure)

Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set to the value in *var. On success, the memory ordering used was order_success; otherwise, it was order_failure. order_failure must be no stronger than order_success, and must not be release or acq_rel. Returns true if the compare was successful and the variable updated to desired.

Prototype

AWS_STATIC_IMPL bool aws_atomic_compare_exchange_ptr_explicit( volatile struct aws_atomic_var *var, void **expected, void *desired, enum aws_memory_order order_success, enum aws_memory_order order_failure);
source
LibAwsCommon.aws_atomic_exchange_intMethod
aws_atomic_exchange_int(var, n)

Exchanges an integer with the value in an atomic_var, using sequentially consistent ordering. Returns the value that was previously in the atomic_var.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_exchange_int(volatile struct aws_atomic_var *var, size_t n);
source
LibAwsCommon.aws_atomic_exchange_int_explicitMethod
aws_atomic_exchange_int_explicit(var, n, memory_order)

Exchanges an integer with the value in an atomic_var, using the specified ordering. Returns the value that was previously in the atomic_var.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_exchange_int_explicit( volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order memory_order);
source
LibAwsCommon.aws_atomic_exchange_ptrMethod
aws_atomic_exchange_ptr(var, p)

Exchanges an integer with the value in an atomic_var, using sequentially consistent ordering. Returns the value that was previously in the atomic_var.

Prototype

AWS_STATIC_IMPL void *aws_atomic_exchange_ptr(volatile struct aws_atomic_var *var, void *p);
source
LibAwsCommon.aws_atomic_exchange_ptr_explicitMethod
aws_atomic_exchange_ptr_explicit(var, p, memory_order)

Exchanges a pointer with the value in an atomic_var, using the specified ordering. Returns the value that was previously in the atomic_var.

Prototype

AWS_STATIC_IMPL void *aws_atomic_exchange_ptr_explicit( volatile struct aws_atomic_var *var, void *p, enum aws_memory_order memory_order);
source
LibAwsCommon.aws_atomic_fetch_addMethod
aws_atomic_fetch_add(var, n)

Atomically adds n to *var, and returns the previous value of *var. Uses sequentially consistent ordering.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_add(volatile struct aws_atomic_var *var, size_t n);
source
LibAwsCommon.aws_atomic_fetch_add_explicitMethod
aws_atomic_fetch_add_explicit(var, n, order)

Atomically adds n to *var, and returns the previous value of *var.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_add_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
source
LibAwsCommon.aws_atomic_fetch_andMethod
aws_atomic_fetch_and(var, n)

Atomically ands n into *var, and returns the previous value of *var. Uses sequentially consistent ordering.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_and(volatile struct aws_atomic_var *var, size_t n);
source
LibAwsCommon.aws_atomic_fetch_and_explicitMethod
aws_atomic_fetch_and_explicit(var, n, order)

Atomically ANDs n with *var, and returns the previous value of *var.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_and_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
source
LibAwsCommon.aws_atomic_fetch_orMethod
aws_atomic_fetch_or(var, n)

Atomically ors n into *var, and returns the previous value of *var. Uses sequentially consistent ordering.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_or(volatile struct aws_atomic_var *var, size_t n);
source
LibAwsCommon.aws_atomic_fetch_or_explicitMethod
aws_atomic_fetch_or_explicit(var, n, order)

Atomically ORs n with *var, and returns the previous value of *var.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_or_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
source
LibAwsCommon.aws_atomic_fetch_subMethod
aws_atomic_fetch_sub(var, n)

Atomically subtracts n from *var, and returns the previous value of *var. Uses sequentially consistent ordering.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_sub(volatile struct aws_atomic_var *var, size_t n);
source
LibAwsCommon.aws_atomic_fetch_sub_explicitMethod
aws_atomic_fetch_sub_explicit(var, n, order)

Atomically subtracts n from *var, and returns the previous value of *var.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_sub_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
source
LibAwsCommon.aws_atomic_fetch_xorMethod
aws_atomic_fetch_xor(var, n)

Atomically xors n into *var, and returns the previous value of *var. Uses sequentially consistent ordering.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_xor(volatile struct aws_atomic_var *var, size_t n);
source
LibAwsCommon.aws_atomic_fetch_xor_explicitMethod
aws_atomic_fetch_xor_explicit(var, n, order)

Atomically XORs n with *var, and returns the previous value of *var.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_fetch_xor_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
source
LibAwsCommon.aws_atomic_init_intMethod
aws_atomic_init_int(var, n)

Initializes an atomic variable with an integer value. This operation should be done before any other operations on this atomic variable, and must be done before attempting any parallel operations.

This operation does not imply a barrier. Ensure that you use an acquire-release barrier (or stronger) when communicating the fact that initialization is complete to the other thread. Launching the thread implies a sufficiently strong barrier.

Prototype

AWS_STATIC_IMPL void aws_atomic_init_int(volatile struct aws_atomic_var *var, size_t n);
source
LibAwsCommon.aws_atomic_init_ptrMethod
aws_atomic_init_ptr(var, p)

Initializes an atomic variable with a pointer value. This operation should be done before any other operations on this atomic variable, and must be done before attempting any parallel operations.

This operation does not imply a barrier. Ensure that you use an acquire-release barrier (or stronger) when communicating the fact that initialization is complete to the other thread. Launching the thread implies a sufficiently strong barrier.

Prototype

AWS_STATIC_IMPL void aws_atomic_init_ptr(volatile struct aws_atomic_var *var, void *p);
source
LibAwsCommon.aws_atomic_load_intMethod
aws_atomic_load_int(var)

Reads an atomic var as an integer, using sequentially consistent ordering, and returns the result.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_load_int(volatile const struct aws_atomic_var *var);
source
LibAwsCommon.aws_atomic_load_int_explicitMethod
aws_atomic_load_int_explicit(var, memory_order)

Reads an atomic var as an integer, using the specified ordering, and returns the result.

Prototype

AWS_STATIC_IMPL size_t aws_atomic_load_int_explicit(volatile const struct aws_atomic_var *var, enum aws_memory_order memory_order);
source
LibAwsCommon.aws_atomic_load_ptrMethod
aws_atomic_load_ptr(var)

Reads an atomic var as a pointer, using sequentially consistent ordering, and returns the result.

Prototype

AWS_STATIC_IMPL void *aws_atomic_load_ptr(volatile const struct aws_atomic_var *var);
source
LibAwsCommon.aws_atomic_load_ptr_explicitMethod
aws_atomic_load_ptr_explicit(var, memory_order)

Reads an atomic var as a pointer, using the specified ordering, and returns the result.

Prototype

AWS_STATIC_IMPL void *aws_atomic_load_ptr_explicit(volatile const struct aws_atomic_var *var, enum aws_memory_order memory_order);
source
LibAwsCommon.aws_atomic_store_intMethod
aws_atomic_store_int(var, n)

Stores an integer into an atomic var, using sequentially consistent ordering.

Prototype

AWS_STATIC_IMPL void aws_atomic_store_int(volatile struct aws_atomic_var *var, size_t n);
source
LibAwsCommon.aws_atomic_store_int_explicitMethod
aws_atomic_store_int_explicit(var, n, memory_order)

Stores an integer into an atomic var, using the specified ordering.

Prototype

AWS_STATIC_IMPL void aws_atomic_store_int_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order memory_order);
source
LibAwsCommon.aws_atomic_store_ptrMethod
aws_atomic_store_ptr(var, p)

Stores a pointer into an atomic var, using sequentially consistent ordering.

Prototype

AWS_STATIC_IMPL void aws_atomic_store_ptr(volatile struct aws_atomic_var *var, void *p);
source
LibAwsCommon.aws_atomic_store_ptr_explicitMethod
aws_atomic_store_ptr_explicit(var, p, memory_order)

Stores a pointer into an atomic var, using the specified ordering.

Prototype

AWS_STATIC_IMPL void aws_atomic_store_ptr_explicit(volatile struct aws_atomic_var *var, void *p, enum aws_memory_order memory_order);
source
LibAwsCommon.aws_atomic_thread_fenceMethod
aws_atomic_thread_fence(order)

Provides the same reordering guarantees as an atomic operation with the specified memory order, without needing to actually perform an atomic operation.

Prototype

AWS_STATIC_IMPL void aws_atomic_thread_fence(enum aws_memory_order order);
source
LibAwsCommon.aws_backtraceMethod
aws_backtrace(stack_frames, num_frames)

Records a stack trace from the call site. Returns the number of stack entries/stack depth captured, or 0 if the operation is not supported on this platform

Prototype

size_t aws_backtrace(void **stack_frames, size_t num_frames);
source
LibAwsCommon.aws_backtrace_addr2lineMethod
aws_backtrace_addr2line(stack_frames, stack_depth)

Converts stack frame pointers to symbols, using all available system tools to try to produce a human readable result. This call will not be quick, as it shells out to addr2line or similar tools. On Windows, this is the same as aws_backtrace_symbols() Returns an array up to stack_depth long that needs to be free()ed. Missing frames will be NULL. Returns NULL if the platform does not support stack frame translation or an error occurs

Prototype

char **aws_backtrace_addr2line(void *const *stack_frames, size_t stack_depth);
source
LibAwsCommon.aws_backtrace_printMethod
aws_backtrace_print(fp, call_site_data)

Print a backtrace from either the current stack, or (if provided) the current exception/signal call_site_data is siginfo_t* on POSIX, and LPEXCEPTION_POINTERS on Windows, and can be null

Prototype

void aws_backtrace_print(FILE *fp, void *call_site_data);
source
LibAwsCommon.aws_backtrace_symbolsMethod
aws_backtrace_symbols(stack_frames, stack_depth)

Converts stack frame pointers to symbols, if symbols are available Returns an array up to stack_depth long, that needs to be free()ed. stack_depth should be the length of frames. Returns NULL if the platform does not support stack frame translation or an error occurs

Prototype

char **aws_backtrace_symbols(void *const *stack_frames, size_t stack_depth);
source
LibAwsCommon.aws_base64_compute_decoded_lenMethod
aws_base64_compute_decoded_len(to_decode, decoded_len)

Computes the length necessary to store the output of aws_base64_decode call. returns -1 on failure, and 0 on success. decoded_len will be set on success.

Prototype

int aws_base64_compute_decoded_len(const struct aws_byte_cursor *AWS_RESTRICT to_decode, size_t *decoded_len);
source
LibAwsCommon.aws_base64_compute_encoded_lenMethod
aws_base64_compute_encoded_len(to_encode_len, encoded_len)

Computes the length necessary to store the output of aws_base64_encode call. returns -1 on failure, and 0 on success. encoded_length will be set on success.

Prototype

int aws_base64_compute_encoded_len(size_t to_encode_len, size_t *encoded_len);
source
LibAwsCommon.aws_base64_decodeMethod
aws_base64_decode(to_decode, output)

Base 64 decodes the contents of to_decode and stores the result in output.

Prototype

int aws_base64_decode(const struct aws_byte_cursor *AWS_RESTRICT to_decode, struct aws_byte_buf *AWS_RESTRICT output);
source
LibAwsCommon.aws_base64_encodeMethod
aws_base64_encode(to_encode, output)

Base 64 encodes the contents of to_encode and stores the result in output.

Prototype

int aws_base64_encode(const struct aws_byte_cursor *AWS_RESTRICT to_encode, struct aws_byte_buf *AWS_RESTRICT output);
source
LibAwsCommon.aws_byte_buf_advanceMethod
aws_byte_buf_advance(buffer, output, len)

Appends a sub-buffer to the specified buffer.

If the buffer has at least len' bytes remaining (buffer->capacity - buffer->len >= len), then buffer->len is incremented by len, and an [awsbytebuf](@ref) is assigned to *output corresponding to the last len bytes of the input buffer. The [awsbytebuf`](@ref) at *output will have a null allocator, a zero initial length, and a capacity of 'len'. The function then returns true.

If there is insufficient space, then this function nulls all fields in *output and returns false.

Prototype

bool aws_byte_buf_advance( struct aws_byte_buf *const AWS_RESTRICT buffer, struct aws_byte_buf *const AWS_RESTRICT output, const size_t len);
source
LibAwsCommon.aws_byte_buf_appendMethod
aws_byte_buf_append(to, from)

Copies from to to. If to is too small, AWS_ERROR_DEST_COPY_TOO_SMALL will be returned. dest->len will contain the amount of data actually copied to dest.

from and to may be the same buffer, permitting copying a buffer into itself.

Prototype

int aws_byte_buf_append(struct aws_byte_buf *to, const struct aws_byte_cursor *from);
source
LibAwsCommon.aws_byte_buf_append_and_updateMethod
aws_byte_buf_append_and_update(to, from_and_update)

Copy contents of cursor to buffer, then update cursor to reference the memory stored in the buffer. If buffer is too small, AWS_ERROR_DEST_COPY_TOO_SMALL will be returned.

The cursor is permitted to reference memory from earlier in the buffer.

Prototype

int aws_byte_buf_append_and_update(struct aws_byte_buf *to, struct aws_byte_cursor *from_and_update);
source
LibAwsCommon.aws_byte_buf_append_byte_dynamicMethod
aws_byte_buf_append_byte_dynamic(buffer, value)

Copies a single byte into to. If to is too small, the buffer will be grown appropriately and the old contents copied over, before the byte is appended.

If the grow fails (overflow or OOM), then an error will be returned.

Prototype

int aws_byte_buf_append_byte_dynamic(struct aws_byte_buf *buffer, uint8_t value);
source
LibAwsCommon.aws_byte_buf_append_byte_dynamic_secureMethod
aws_byte_buf_append_byte_dynamic_secure(buffer, value)

Copies a single byte into to. If to is too small, the buffer will be grown appropriately and the old contents copied over, before the byte is appended.

If the grow fails (overflow or OOM), then an error will be returned.

If the buffer is grown, the old buffer will be securely cleared before getting freed.

Prototype

int aws_byte_buf_append_byte_dynamic_secure(struct aws_byte_buf *buffer, uint8_t value);
source
LibAwsCommon.aws_byte_buf_append_decoding_uriMethod
aws_byte_buf_append_decoding_uri(buffer, cursor)

Writes the uri decoding of a UTF-8 cursor to a buffer, replacing xx escapes by their single byte equivalent. For example, reading "a20b_c" would write "a b_c".

Prototype

int aws_byte_buf_append_decoding_uri(struct aws_byte_buf *buffer, const struct aws_byte_cursor *cursor);
source
LibAwsCommon.aws_byte_buf_append_dynamicMethod
aws_byte_buf_append_dynamic(to, from)

Copies from to to. If to is too small, the buffer will be grown appropriately and the old contents copied to, before the new contents are appended.

If the grow fails (overflow or OOM), then an error will be returned.

from and to may be the same buffer, permitting copying a buffer into itself.

Prototype

int aws_byte_buf_append_dynamic(struct aws_byte_buf *to, const struct aws_byte_cursor *from);
source
LibAwsCommon.aws_byte_buf_append_dynamic_secureMethod
aws_byte_buf_append_dynamic_secure(to, from)

Copies from to to. If to is too small, the buffer will be grown appropriately and the old contents copied over, before the new contents are appended.

If the grow fails (overflow or OOM), then an error will be returned.

If the buffer is grown, the old buffer will be securely cleared before getting freed.

from and to may be the same buffer, permitting copying a buffer into itself.

Prototype

int aws_byte_buf_append_dynamic_secure(struct aws_byte_buf *to, const struct aws_byte_cursor *from);
source
LibAwsCommon.aws_byte_buf_append_encoding_uri_paramMethod
aws_byte_buf_append_encoding_uri_param(buffer, cursor)

Writes the uri query param encoding (passthrough alnum + '-' '_' '~' '.') of a UTF-8 cursor to a buffer For example, reading "a b_c" would write "a20b_c".

Prototype

int aws_byte_buf_append_encoding_uri_param( struct aws_byte_buf *buffer, const struct aws_byte_cursor *cursor);
source
LibAwsCommon.aws_byte_buf_append_encoding_uri_pathMethod
aws_byte_buf_append_encoding_uri_path(buffer, cursor)

Writes the uri path encoding of a cursor to a buffer. This is the modified version of rfc3986 used by sigv4 signing.

Prototype

int aws_byte_buf_append_encoding_uri_path( struct aws_byte_buf *buffer, const struct aws_byte_cursor *cursor);
source
LibAwsCommon.aws_byte_buf_append_json_stringMethod
aws_byte_buf_append_json_string(value, output)

Appends a unformatted JSON string representation of the aws_json_value into the passed byte buffer. The byte buffer is expected to be already initialized so the function can append the JSON into it.

Note: The byte buffer will automatically have its size extended if the JSON string is over the byte buffer capacity AND the byte buffer has an allocator associated with it. If the byte buffer does not have an allocator associated and the JSON string is over capacity, AWS_OP_ERR will be returned.

Note: When you are finished with the aws_byte_buf, you must call "aws_byte_buf_clean_up_secure" to free the memory used, as it will NOT be called automatically.

Arguments

  • value: The aws_json_value to format.
  • output: The destination for the JSON string

Returns

AWS_OP_SUCCESS if the JSON string was allocated to output without any errors Will return AWS_OP_ERR if the value passed is not an aws_json_value or if there was an error appending the JSON into the byte buffer.

Prototype

int aws_byte_buf_append_json_string(const struct aws_json_value *value, struct aws_byte_buf *output);
source
LibAwsCommon.aws_byte_buf_append_json_string_formattedMethod
aws_byte_buf_append_json_string_formatted(value, output)

Appends a formatted JSON string representation of the aws_json_value into the passed byte buffer. The byte buffer is expected to already be initialized so the function can append the JSON into it.

Note: The byte buffer will automatically have its size extended if the JSON string is over the byte buffer capacity AND the byte buffer has an allocator associated with it. If the byte buffer does not have an allocator associated and the JSON string is over capacity, AWS_OP_ERR will be returned.

Note: When you are finished with the aws_byte_buf, you must call "aws_byte_buf_clean_up_secure" to free the memory used, as it will NOT be called automatically.

Arguments

  • value: The aws_json_value to format.
  • output: The destination for the JSON string

Returns

AWS_OP_SUCCESS if the JSON string was allocated to output without any errors Will return AWS_OP_ERR if the value passed is not an aws_json_value or if there aws an error appending the JSON into the byte buffer.

Prototype

int aws_byte_buf_append_json_string_formatted(const struct aws_json_value *value, struct aws_byte_buf *output);
source
LibAwsCommon.aws_byte_buf_append_with_lookupMethod
aws_byte_buf_append_with_lookup(to, from, lookup_table)

Copies from to to while converting bytes via the passed in lookup table. If to is too small, AWS_ERROR_DEST_COPY_TOO_SMALL will be returned. to->len will contain its original size plus the amount of data actually copied to to.

from and to should not be the same buffer (overlap is not handled) lookup_table must be at least 256 bytes

Prototype

int aws_byte_buf_append_with_lookup( struct aws_byte_buf *AWS_RESTRICT to, const struct aws_byte_cursor *AWS_RESTRICT from, const uint8_t *lookup_table);
source
LibAwsCommon.aws_byte_buf_eqMethod
aws_byte_buf_eq(a, b)

Compare two aws_byte_buf structures. Return whether their contents are equivalent.

Prototype

bool aws_byte_buf_eq(const struct aws_byte_buf *const a, const struct aws_byte_buf *const b);
source
LibAwsCommon.aws_byte_buf_eq_c_strMethod
aws_byte_buf_eq_c_str(buf, c_str)

Compare an aws_byte_buf and a null-terminated string. Returns true if their contents are equivalent. The buffer should NOT contain a null-terminator, or the comparison will always return false.

Prototype

bool aws_byte_buf_eq_c_str(const struct aws_byte_buf *const buf, const char *const c_str);
source
LibAwsCommon.aws_byte_buf_eq_c_str_ignore_caseMethod
aws_byte_buf_eq_c_str_ignore_case(buf, c_str)

Perform a case-insensitive string comparison of an aws_byte_buf and a null-terminated string. Return whether their contents are equivalent. The buffer should NOT contain a null-terminator, or the comparison will always return false. The "C" locale is used for comparing upper and lowercase letters. Data is assumed to be ASCII text, UTF-8 will work fine too.

Prototype

bool aws_byte_buf_eq_c_str_ignore_case(const struct aws_byte_buf *const buf, const char *const c_str);
source
LibAwsCommon.aws_byte_buf_eq_ignore_caseMethod
aws_byte_buf_eq_ignore_case(a, b)

Perform a case-insensitive string comparison of two aws_byte_buf structures. Return whether their contents are equivalent. The "C" locale is used for comparing upper and lowercase letters. Data is assumed to be ASCII text, UTF-8 will work fine too.

Prototype

bool aws_byte_buf_eq_ignore_case(const struct aws_byte_buf *const a, const struct aws_byte_buf *const b);
source
LibAwsCommon.aws_byte_buf_from_c_strMethod
aws_byte_buf_from_c_str(c_str)

For creating a byte buffer from a null-terminated string literal.

Prototype

struct aws_byte_buf aws_byte_buf_from_c_str(const char *c_str);
source
LibAwsCommon.aws_byte_buf_initMethod
aws_byte_buf_init(buf, allocator, capacity)

Documentation not found.

Prototype

int aws_byte_buf_init(struct aws_byte_buf *buf, struct aws_allocator *allocator, size_t capacity);
source
LibAwsCommon.aws_byte_buf_init_copyMethod
aws_byte_buf_init_copy(dest, allocator, src)

Initializes an aws_byte_buf structure base on another valid one. Requires: *src and *allocator are valid objects. Ensures: *dest is a valid aws_byte_buf with a new backing array dest->buffer which is a copy of the elements from src->buffer.

Prototype

int aws_byte_buf_init_copy( struct aws_byte_buf *dest, struct aws_allocator *allocator, const struct aws_byte_buf *src);
source
LibAwsCommon.aws_byte_buf_init_copy_from_cursorMethod
aws_byte_buf_init_copy_from_cursor(dest, allocator, src)

Copies src buffer into dest and sets the correct len and capacity. A new memory zone is allocated for dest->buffer. When dest is no longer needed it will have to be cleaned-up using aws_byte_buf_clean_up(dest). Dest capacity and len will be equal to the src len. Allocator of the dest will be identical with parameter allocator. If src buffer is null the dest will have a null buffer with a len and a capacity of 0 Returns AWS_OP_SUCCESS in case of success or AWS_OP_ERR when memory can't be allocated.

Prototype

int aws_byte_buf_init_copy_from_cursor( struct aws_byte_buf *dest, struct aws_allocator *allocator, struct aws_byte_cursor src);
source
LibAwsCommon.aws_byte_buf_init_from_fileMethod
aws_byte_buf_init_from_file(out_buf, alloc, filename)

Reads 'filename' into 'out_buf'. If successful, 'out_buf' is allocated and filled with the data; It is your responsibility to call 'aws_byte_buf_clean_up()' on it. Otherwise, 'out_buf' remains unused. In the very unfortunate case where some API needs to treat out_buf as a c_string, a null terminator is appended, but is not included as part of the length field.

Prototype

int aws_byte_buf_init_from_file(struct aws_byte_buf *out_buf, struct aws_allocator *alloc, const char *filename);
source
LibAwsCommon.aws_byte_buf_init_from_file_with_size_hintMethod
aws_byte_buf_init_from_file_with_size_hint(out_buf, alloc, filename, size_hint)

Same as aws_byte_buf_init_from_file(), but for reading "special files" like /proc/cpuinfo. These files don't accurately report their size, so size_hint is used as initial buffer size, and the buffer grows until the while file is read.

Prototype

int aws_byte_buf_init_from_file_with_size_hint( struct aws_byte_buf *out_buf, struct aws_allocator *alloc, const char *filename, size_t size_hint);
source
LibAwsCommon.aws_byte_buf_is_validMethod
aws_byte_buf_is_valid(buf)

Evaluates the set of properties that define the shape of all valid aws_byte_buf structures. It is also a cheap check, in the sense it run in constant time (i.e., no loops or recursion).

Prototype

bool aws_byte_buf_is_valid(const struct aws_byte_buf *const buf);
source
LibAwsCommon.aws_byte_buf_reserveMethod
aws_byte_buf_reserve(buffer, requested_capacity)

Attempts to increase the capacity of a buffer to the requested capacity

If the the buffer's capacity is currently larger than the request capacity, the function does nothing (no shrink is performed).

Prototype

int aws_byte_buf_reserve(struct aws_byte_buf *buffer, size_t requested_capacity);
source
LibAwsCommon.aws_byte_buf_resetMethod
aws_byte_buf_reset(buf, zero_contents)

Resets the len of the buffer to 0, but does not free the memory. The buffer can then be reused. Optionally zeroes the contents, if the "zero_contents" flag is true.

Prototype

void aws_byte_buf_reset(struct aws_byte_buf *buf, bool zero_contents);
source
LibAwsCommon.aws_byte_buf_writeMethod
aws_byte_buf_write(buf, src, len)

Write specified number of bytes from array to byte buffer.

On success, returns true and updates the buffer length accordingly. If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write( struct aws_byte_buf *AWS_RESTRICT buf, const uint8_t *AWS_RESTRICT src, size_t len);
source
LibAwsCommon.aws_byte_buf_write_be16Method
aws_byte_buf_write_be16(buf, x)

Writes a 16-bit integer in network byte order (big endian) to buffer.

On success, returns true and updates the buffer /length accordingly. If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_be16(struct aws_byte_buf *buf, uint16_t x);
source
LibAwsCommon.aws_byte_buf_write_be24Method
aws_byte_buf_write_be24(buf, x)

Writes low 24-bits (3 bytes) of an unsigned integer in network byte order (big endian) to buffer. Ex: If x is 0x00AABBCC then {0xAA, 0xBB, 0xCC} is written to buffer.

On success, returns true and updates the buffer /length accordingly. If there is insufficient space in the buffer, or x's value cannot fit in 3 bytes, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_be24(struct aws_byte_buf *buf, uint32_t x);
source
LibAwsCommon.aws_byte_buf_write_be32Method
aws_byte_buf_write_be32(buf, x)

Writes a 32-bit integer in network byte order (big endian) to buffer.

On success, returns true and updates the buffer /length accordingly. If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_be32(struct aws_byte_buf *buf, uint32_t x);
source
LibAwsCommon.aws_byte_buf_write_be64Method
aws_byte_buf_write_be64(buf, x)

Writes a 64-bit integer in network byte order (big endian) to buffer.

On success, returns true and updates the buffer /length accordingly. If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_be64(struct aws_byte_buf *buf, uint64_t x);
source
LibAwsCommon.aws_byte_buf_write_float_be32Method
aws_byte_buf_write_float_be32(buf, x)

Writes a 32-bit float in network byte order (big endian) to buffer.

On success, returns true and updates the buffer /length accordingly. If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_float_be32(struct aws_byte_buf *buf, float x);
source
LibAwsCommon.aws_byte_buf_write_float_be64Method
aws_byte_buf_write_float_be64(buf, x)

Writes a 64-bit float in network byte order (big endian) to buffer.

On success, returns true and updates the buffer /length accordingly. If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_float_be64(struct aws_byte_buf *buf, double x);
source
LibAwsCommon.aws_byte_buf_write_from_whole_bufferMethod
aws_byte_buf_write_from_whole_buffer(buf, src)

Copies all bytes from buffer to buffer.

On success, returns true and updates the buffer /length accordingly. If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_from_whole_buffer( struct aws_byte_buf *AWS_RESTRICT buf, struct aws_byte_buf src);
source
LibAwsCommon.aws_byte_buf_write_from_whole_cursorMethod
aws_byte_buf_write_from_whole_cursor(buf, src)

Copies all bytes from buffer to buffer.

On success, returns true and updates the buffer /length accordingly. If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_from_whole_cursor( struct aws_byte_buf *AWS_RESTRICT buf, struct aws_byte_cursor src);
source
LibAwsCommon.aws_byte_buf_write_from_whole_stringMethod
aws_byte_buf_write_from_whole_string(buf, src)

Copies all bytes from string to buf.

On success, returns true and updates the buf pointer/length accordingly. If there is insufficient space in the buf, returns false, leaving the buf unchanged.

Prototype

bool aws_byte_buf_write_from_whole_string( struct aws_byte_buf *AWS_RESTRICT buf, const struct aws_string *AWS_RESTRICT src);
source
LibAwsCommon.aws_byte_buf_write_to_capacityMethod
aws_byte_buf_write_to_capacity(buf, advancing_cursor)

Without increasing buf's capacity, write as much as possible from advancing_cursor into buf.

buf's len is updated accordingly. advancing_cursor is advanced so it contains the remaining unwritten parts. Returns the section of advancing_cursor which was written.

This function cannot fail. If buf is full (len == capacity) or advancing_len has 0 length, then buf and advancing_cursor are not altered and a cursor with 0 length is returned.

Example: Given a buf with 2 bytes of space available and advancing_cursor with contents "abc". "ab" will be written to buf and buf->len will increase 2 and become equal to buf->capacity. advancing_cursor will advance so its contents become the unwritten "c". The returned cursor's contents will be the "ab" from the original advancing_cursor.

Prototype

struct aws_byte_cursor aws_byte_buf_write_to_capacity( struct aws_byte_buf *buf, struct aws_byte_cursor *advancing_cursor);
source
LibAwsCommon.aws_byte_buf_write_u8Method
aws_byte_buf_write_u8(buf, c)

Copies one byte to buffer.

On success, returns true and updates the cursor /length accordingly.

If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_u8(struct aws_byte_buf *AWS_RESTRICT buf, uint8_t c);
source
LibAwsCommon.aws_byte_buf_write_u8_nMethod
aws_byte_buf_write_u8_n(buf, c, count)

Writes one byte repeatedly to buffer (like memset)

If there is insufficient space in the buffer, returns false, leaving the buffer unchanged.

Prototype

bool aws_byte_buf_write_u8_n(struct aws_byte_buf *buf, uint8_t c, size_t count);
source
LibAwsCommon.aws_byte_cursor_advanceMethod
aws_byte_cursor_advance(cursor, len)

Tests if the given aws_byte_cursor has at least len bytes remaining. If so, *buf is advanced by len bytes (incrementing ->ptr and decrementing ->len), and an aws_byte_cursor referring to the first len bytes of the original *buf is returned. Otherwise, an aws_byte_cursor with ->ptr = NULL, ->len = 0 is returned.

Note that if len is above (SIZE_MAX / 2), this function will also treat it as a buffer overflow, and return NULL without changing *buf.

Prototype

struct aws_byte_cursor aws_byte_cursor_advance(struct aws_byte_cursor *const cursor, const size_t len);
source
LibAwsCommon.aws_byte_cursor_advance_nospecMethod
aws_byte_cursor_advance_nospec(cursor, len)

Behaves identically to aws_byte_cursor_advance, but avoids speculative execution potentially reading out-of-bounds pointers (by returning an empty ptr in such speculated paths).

This should generally be done when using an untrusted or data-dependent value for 'len', to avoid speculating into a path where cursor->ptr points outside the true ptr length.

Prototype

struct aws_byte_cursor aws_byte_cursor_advance_nospec(struct aws_byte_cursor *const cursor, size_t len);
source
LibAwsCommon.aws_byte_cursor_compare_lexicalMethod
aws_byte_cursor_compare_lexical(lhs, rhs)

Lexical (byte value) comparison of two byte cursors

Prototype

int aws_byte_cursor_compare_lexical(const struct aws_byte_cursor *lhs, const struct aws_byte_cursor *rhs);
source
LibAwsCommon.aws_byte_cursor_compare_lookupMethod
aws_byte_cursor_compare_lookup(lhs, rhs, lookup_table)

Lexical (byte value) comparison of two byte cursors where the raw values are sent through a lookup table first

Prototype

int aws_byte_cursor_compare_lookup( const struct aws_byte_cursor *lhs, const struct aws_byte_cursor *rhs, const uint8_t *lookup_table);
source
LibAwsCommon.aws_byte_cursor_eq_byte_buf_ignore_caseMethod
aws_byte_cursor_eq_byte_buf_ignore_case(a, b)

Perform a case-insensitive string comparison of an aws_byte_cursor and an aws_byte_buf. Return whether their contents are equivalent. The "C" locale is used for comparing upper and lowercase letters. Data is assumed to be ASCII text, UTF-8 will work fine too.

Prototype

bool aws_byte_cursor_eq_byte_buf_ignore_case(const struct aws_byte_cursor *const a, const struct aws_byte_buf *const b);
source
LibAwsCommon.aws_byte_cursor_eq_c_strMethod
aws_byte_cursor_eq_c_str(cursor, c_str)

Compare an aws_byte_cursor and a null-terminated string. Returns true if their contents are equivalent. The cursor should NOT contain a null-terminator, or the comparison will always return false.

Prototype

bool aws_byte_cursor_eq_c_str(const struct aws_byte_cursor *const cursor, const char *const c_str);
source
LibAwsCommon.aws_byte_cursor_eq_c_str_ignore_caseMethod
aws_byte_cursor_eq_c_str_ignore_case(cursor, c_str)

Perform a case-insensitive string comparison of an aws_byte_cursor and a null-terminated string. Return whether their contents are equivalent. The cursor should NOT contain a null-terminator, or the comparison will always return false. The "C" locale is used for comparing upper and lowercase letters. Data is assumed to be ASCII text, UTF-8 will work fine too.

Prototype

bool aws_byte_cursor_eq_c_str_ignore_case(const struct aws_byte_cursor *const cursor, const char *const c_str);
source
LibAwsCommon.aws_byte_cursor_eq_ignore_caseMethod
aws_byte_cursor_eq_ignore_case(a, b)

Perform a case-insensitive string comparison of two aws_byte_cursor structures. Return whether their contents are equivalent. The "C" locale is used for comparing upper and lowercase letters. Data is assumed to be ASCII text, UTF-8 will work fine too.

Prototype

bool aws_byte_cursor_eq_ignore_case(const struct aws_byte_cursor *a, const struct aws_byte_cursor *b);
source
LibAwsCommon.aws_byte_cursor_find_exactMethod
aws_byte_cursor_find_exact(input_str, to_find, first_find)

Search for an exact byte match inside a cursor. The first match will be returned. Returns AWS_OP_SUCCESS on successful match and first_find will be set to the offset in input_str, and length will be the remaining length from input_str past the returned offset. If the match was not found, AWS_OP_ERR will be returned and AWS_ERROR_STRING_MATCH_NOT_FOUND will be raised.

Prototype

int aws_byte_cursor_find_exact( const struct aws_byte_cursor *AWS_RESTRICT input_str, const struct aws_byte_cursor *AWS_RESTRICT to_find, struct aws_byte_cursor *first_find);
source
LibAwsCommon.aws_byte_cursor_is_validMethod
aws_byte_cursor_is_valid(cursor)

Evaluates the set of properties that define the shape of all valid aws_byte_cursor structures. It is also a cheap check, in the sense it runs in constant time (i.e., no loops or recursion).

Prototype

bool aws_byte_cursor_is_valid(const struct aws_byte_cursor *cursor);
source
LibAwsCommon.aws_byte_cursor_left_trim_predMethod
aws_byte_cursor_left_trim_pred(source, predicate)

Shrinks a byte cursor from the left for as long as the supplied predicate is true

Prototype

struct aws_byte_cursor aws_byte_cursor_left_trim_pred( const struct aws_byte_cursor *source, aws_byte_predicate_fn *predicate);
source
LibAwsCommon.aws_byte_cursor_next_splitMethod
aws_byte_cursor_next_split(input_str, split_on, substr)

No copies, no buffer allocations. Iterates over input_str, and returns the next substring between split_on instances relative to previous substr. Behaves similar to strtok with substr being used as state for next split.

Returns true each time substr is set and false when there is no more splits (substr is set to empty in that case).

Example usage. struct aws_byte_cursor substr = {0}; while (aws_byte_cursor_next_split(&input_str, ';', &substr)) { // ...use substr... }

Note: It is the user's responsibility zero-initialize substr before the first call.

Edge case rules are as follows: empty input will have single empty split. ex. "" splits into "" if input starts with split_on then first split is empty. ex ";A" splits into "", "A" adjacent split tokens result in empty split. ex "A;;B" splits into "A", "", "B" If the input ends with split_on, last split is empty. ex. "A;" splits into "A", ""

It is the user's responsibility to make sure the input buffer stays in memory long enough to use the results.

Prototype

bool aws_byte_cursor_next_split( const struct aws_byte_cursor *AWS_RESTRICT input_str, char split_on, struct aws_byte_cursor *AWS_RESTRICT substr);
source
LibAwsCommon.aws_byte_cursor_readMethod
aws_byte_cursor_read(cur, dest, len)

Reads specified length of data from byte cursor and copies it to the destination array.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read( struct aws_byte_cursor *AWS_RESTRICT cur, void *AWS_RESTRICT dest, const size_t len);
source
LibAwsCommon.aws_byte_cursor_read_and_fill_bufferMethod
aws_byte_cursor_read_and_fill_buffer(cur, dest)

Reads as many bytes from cursor as size of buffer, and copies them to buffer.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_and_fill_buffer( struct aws_byte_cursor *AWS_RESTRICT cur, struct aws_byte_buf *AWS_RESTRICT dest);
source
LibAwsCommon.aws_byte_cursor_read_be16Method
aws_byte_cursor_read_be16(cur, var)

Reads a 16-bit value in network byte order from cur, and places it in host byte order into var.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_be16(struct aws_byte_cursor *cur, uint16_t *var);
source
LibAwsCommon.aws_byte_cursor_read_be24Method
aws_byte_cursor_read_be24(cur, var)

Reads an unsigned 24-bit value (3 bytes) in network byte order from cur, and places it in host byte order into 32-bit var. Ex: if cur's next 3 bytes are {0xAA, 0xBB, 0xCC}, then var becomes 0x00AABBCC.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_be24(struct aws_byte_cursor *cur, uint32_t *var);
source
LibAwsCommon.aws_byte_cursor_read_be32Method
aws_byte_cursor_read_be32(cur, var)

Reads a 32-bit value in network byte order from cur, and places it in host byte order into var.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_be32(struct aws_byte_cursor *cur, uint32_t *var);
source
LibAwsCommon.aws_byte_cursor_read_be64Method
aws_byte_cursor_read_be64(cur, var)

Reads a 64-bit value in network byte order from cur, and places it in host byte order into var.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_be64(struct aws_byte_cursor *cur, uint64_t *var);
source
LibAwsCommon.aws_byte_cursor_read_float_be32Method
aws_byte_cursor_read_float_be32(cur, var)

Reads a 32-bit value in network byte order from cur, and places it in host byte order into var.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_float_be32(struct aws_byte_cursor *cur, float *var);
source
LibAwsCommon.aws_byte_cursor_read_float_be64Method
aws_byte_cursor_read_float_be64(cur, var)

Reads a 64-bit value in network byte order from cur, and places it in host byte order into var.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_float_be64(struct aws_byte_cursor *cur, double *var);
source
LibAwsCommon.aws_byte_cursor_read_hex_u8Method
aws_byte_cursor_read_hex_u8(cur, var)

Reads 2 hex characters from ASCII/UTF-8 text to produce an 8-bit number. Accepts both lowercase 'a'-'f' and uppercase 'A'-'F'. For example: "0F" produces 15.

On success, returns true and advances the cursor by 2. If there is insufficient space in the cursor or an invalid character is encountered, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_hex_u8(struct aws_byte_cursor *cur, uint8_t *var);
source
LibAwsCommon.aws_byte_cursor_read_u8Method
aws_byte_cursor_read_u8(cur, var)

Reads a single byte from cursor, placing it in *var.

On success, returns true and updates the cursor pointer/length accordingly. If there is insufficient space in the cursor, returns false, leaving the cursor unchanged.

Prototype

bool aws_byte_cursor_read_u8(struct aws_byte_cursor *AWS_RESTRICT cur, uint8_t *AWS_RESTRICT var);
source
LibAwsCommon.aws_byte_cursor_right_trim_predMethod
aws_byte_cursor_right_trim_pred(source, predicate)

Shrinks a byte cursor from the right for as long as the supplied predicate is true

Prototype

struct aws_byte_cursor aws_byte_cursor_right_trim_pred( const struct aws_byte_cursor *source, aws_byte_predicate_fn *predicate);
source
LibAwsCommon.aws_byte_cursor_satisfies_predMethod
aws_byte_cursor_satisfies_pred(source, predicate)

Returns true if the byte cursor's range of bytes all satisfy the predicate

Prototype

bool aws_byte_cursor_satisfies_pred(const struct aws_byte_cursor *source, aws_byte_predicate_fn *predicate);
source
LibAwsCommon.aws_byte_cursor_split_on_charMethod
aws_byte_cursor_split_on_char(input_str, split_on, output)

No copies, no buffer allocations. Fills in output with a list of aws_byte_cursor instances where buffer is an offset into the input_str and len is the length of that string in the original buffer.

Edge case rules are as follows: if the input begins with split_on, an empty cursor will be the first entry in output. if the input has two adjacent split_on tokens, an empty cursor will be inserted into the output. if the input ends with split_on, an empty cursor will be appended to the output.

It is the user's responsibility to properly initialize output. Recommended number of preallocated elements from output is your most likely guess for the upper bound of the number of elements resulting from the split.

The type that will be stored in output is struct aws_byte_cursor (you'll need this for the item size param).

It is the user's responsibility to make sure the input buffer stays in memory long enough to use the results.

Prototype

int aws_byte_cursor_split_on_char( const struct aws_byte_cursor *AWS_RESTRICT input_str, char split_on, struct aws_array_list *AWS_RESTRICT output);
source
LibAwsCommon.aws_byte_cursor_split_on_char_nMethod
aws_byte_cursor_split_on_char_n(input_str, split_on, n, output)

No copies, no buffer allocations. Fills in output with a list of aws_byte_cursor instances where buffer is an offset into the input_str and len is the length of that string in the original buffer. N is the max number of splits, if this value is zero, it will add all splits to the output.

Edge case rules are as follows: if the input begins with split_on, an empty cursor will be the first entry in output if the input has two adjacent split_on tokens, an empty cursor will be inserted into the output. if the input ends with split_on, an empty cursor will be appended to the output.

It is the user's responsibility to properly initialize output. Recommended number of preallocated elements from output is your most likely guess for the upper bound of the number of elements resulting from the split.

If the output array is not large enough, input_str will be updated to point to the first character after the last processed split_on instance.

The type that will be stored in output is struct aws_byte_cursor (you'll need this for the item size param).

It is the user's responsibility to make sure the input buffer stays in memory long enough to use the results.

Prototype

int aws_byte_cursor_split_on_char_n( const struct aws_byte_cursor *AWS_RESTRICT input_str, char split_on, size_t n, struct aws_array_list *AWS_RESTRICT output);
source
LibAwsCommon.aws_byte_cursor_starts_withMethod
aws_byte_cursor_starts_with(input, prefix)

Return true if the input starts with the prefix (exact byte comparison).

Prototype

bool aws_byte_cursor_starts_with(const struct aws_byte_cursor *input, const struct aws_byte_cursor *prefix);
source
LibAwsCommon.aws_byte_cursor_starts_with_ignore_caseMethod
aws_byte_cursor_starts_with_ignore_case(input, prefix)

Return true if the input starts with the prefix (case-insensitive). The "C" locale is used for comparing upper and lowercase letters. Data is assumed to be ASCII text, UTF-8 will work fine too.

Prototype

bool aws_byte_cursor_starts_with_ignore_case(const struct aws_byte_cursor *input, const struct aws_byte_cursor *prefix);
source
LibAwsCommon.aws_byte_cursor_trim_predMethod
aws_byte_cursor_trim_pred(source, predicate)

Shrinks a byte cursor from both sides for as long as the supplied predicate is true

Prototype

struct aws_byte_cursor aws_byte_cursor_trim_pred( const struct aws_byte_cursor *source, aws_byte_predicate_fn *predicate);
source
LibAwsCommon.aws_byte_cursor_utf8_parse_u64Method
aws_byte_cursor_utf8_parse_u64(cursor, dst)

Read entire cursor as ASCII/UTF-8 unsigned base-10 number. Stricter than strtoull(), which allows whitespace and inputs that start with "0x"

Examples: "0" -> 0 "123" -> 123 "00004" -> 4 // leading zeros ok

Rejects things like: "-1" // negative numbers not allowed "1,000" // only characters 0-9 allowed "" // blank string not allowed " 0 " // whitespace not allowed "0x0" // hex not allowed "FF" // hex not allowed "999999999999999999999999999999999999999999" // larger than max u64

Prototype

int aws_byte_cursor_utf8_parse_u64(struct aws_byte_cursor cursor, uint64_t *dst);
source
LibAwsCommon.aws_byte_cursor_utf8_parse_u64_hexMethod
aws_byte_cursor_utf8_parse_u64_hex(cursor, dst)

Read entire cursor as ASCII/UTF-8 unsigned base-16 number with NO "0x" prefix.

Examples: "F" -> 15 "000000ff" -> 255 // leading zeros ok "Ff" -> 255 // mixed case ok "123" -> 291 "FFFFFFFFFFFFFFFF" -> 18446744073709551616 // max u64

Rejects things like: "0x0" // 0x prefix not allowed "" // blank string not allowed " F " // whitespace not allowed "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" // larger than max u64

Prototype

int aws_byte_cursor_utf8_parse_u64_hex(struct aws_byte_cursor cursor, uint64_t *dst);
source
LibAwsCommon.aws_cache_destroyMethod
aws_cache_destroy(cache)

Cleans up the cache. Elements in the cache will be evicted and cleanup callbacks will be invoked.

Prototype

void aws_cache_destroy(struct aws_cache *cache);
source
LibAwsCommon.aws_cache_findMethod
aws_cache_find(cache, key, p_value)

Finds element in the cache by key. If found, *p_value will hold the stored value, and AWS_OP_SUCCESS will be returned. If not found, AWS_OP_SUCCESS will be returned and *p_value will be NULL.

If any errors occur AWS_OP_ERR will be returned.

Prototype

int aws_cache_find(struct aws_cache *cache, const void *key, void **p_value);
source
LibAwsCommon.aws_cache_new_fifoMethod
aws_cache_new_fifo(allocator, hash_fn, equals_fn, destroy_key_fn, destroy_value_fn, max_items)

Initializes the first-in-first-out cache. Sets up the underlying linked hash table. Once max_items elements have been added, the oldest(first-in) item will be removed. For the other parameters, see aws/common/hash_table.h. Hash table semantics of these arguments are preserved.

Prototype

struct aws_cache *aws_cache_new_fifo( struct aws_allocator *allocator, aws_hash_fn *hash_fn, aws_hash_callback_eq_fn *equals_fn, aws_hash_callback_destroy_fn *destroy_key_fn, aws_hash_callback_destroy_fn *destroy_value_fn, size_t max_items);
source
LibAwsCommon.aws_cache_new_lifoMethod
aws_cache_new_lifo(allocator, hash_fn, equals_fn, destroy_key_fn, destroy_value_fn, max_items)

Initializes the last-in-first-out cache. Sets up the underlying linked hash table. Once max_items elements have been added, the latest(last-in) item will be removed. For the other parameters, see aws/common/hash_table.h. Hash table semantics of these arguments are preserved.

Prototype

struct aws_cache *aws_cache_new_lifo( struct aws_allocator *allocator, aws_hash_fn *hash_fn, aws_hash_callback_eq_fn *equals_fn, aws_hash_callback_destroy_fn *destroy_key_fn, aws_hash_callback_destroy_fn *destroy_value_fn, size_t max_items);
source
LibAwsCommon.aws_cache_new_lruMethod
aws_cache_new_lru(allocator, hash_fn, equals_fn, destroy_key_fn, destroy_value_fn, max_items)

Initializes the Least-recently-used cache. Sets up the underlying linked hash table. Once max_items elements have been added, the least recently used item will be removed. For the other parameters, see aws/common/hash_table.h. Hash table semantics of these arguments are preserved.(Yes the one that was the answer to that interview question that one time).

Prototype

struct aws_cache *aws_cache_new_lru( struct aws_allocator *allocator, aws_hash_fn *hash_fn, aws_hash_callback_eq_fn *equals_fn, aws_hash_callback_destroy_fn *destroy_key_fn, aws_hash_callback_destroy_fn *destroy_value_fn, size_t max_items);
source
LibAwsCommon.aws_cache_putMethod
aws_cache_put(cache, key, p_value)

Puts p_value at key. If an element is already stored at key it will be replaced. If the cache is already full, an item will be removed based on the cache policy.

Prototype

int aws_cache_put(struct aws_cache *cache, const void *key, void *p_value);
source
LibAwsCommon.aws_cache_removeMethod
aws_cache_remove(cache, key)

Removes item at key from the cache.

Prototype

int aws_cache_remove(struct aws_cache *cache, const void *key);
source
LibAwsCommon.aws_cli_dispatch_on_subcommandMethod
aws_cli_dispatch_on_subcommand(argc, argv, dispatch_table, table_length, user_data)

Dispatches the current command line arguments with a subcommand from the second input argument in argv[], if dispatch table contains a command that matches the argument. When the command is dispatched, argc and argv will be updated to reflect the new argument count. The cli options are required to come after the subcommand. If either, no dispatch was found or there was no argument passed to the program, this function will return AWS_OP_ERR. Check aws_last_error() for details on the error.

Arguments

  • argc: number of arguments passed to int main()
  • argv: the arguments passed to int main()
  • parse_cb,: optional, specify NULL if you don't want to handle this. This argument is for parsing "meta" commands from the command line options prior to dispatch occurring.
  • dispatch_table: table containing functions and command name to dispatch on.
  • table_length: number of entries in dispatch_table.

Returns

AWS_OP_SUCCESS(0) on success, AWS_OP_ERR(-1) on failure

Prototype

int aws_cli_dispatch_on_subcommand( int argc, char *const argv[], struct aws_cli_subcommand_dispatch *dispatch_table, int table_length, void *user_data);
source
LibAwsCommon.aws_cli_getopt_longMethod
aws_cli_getopt_long(argc, argv, optstring, longopts, longindex)

A mostly compliant implementation of posix getopt_long(). Parses command-line arguments. argc is the number of command line arguments passed in argv. optstring contains the legitimate option characters. The option characters correspond to aws_cli_option::val. If the character is followed by a :, the option requires an argument. If it is followed by '::', the argument is optional (not implemented yet).

longopts, is an array of struct aws_cli_option. These are the allowed options for the program. The last member of the array must be zero initialized.

If longindex is non-null, it will be set to the index in longopts, for the found option.

Returns option val if it was found, '?' if an option was encountered that was not specified in the option string, 0x02 (START_OF_TEXT) will be returned if a positional argument was encountered. returns -1 when all arguments that can be parsed have been parsed.

Prototype

int aws_cli_getopt_long( int argc, char *const argv[], const char *optstring, const struct aws_cli_option *longopts, int *longindex);
source
LibAwsCommon.aws_clz_u32Method
aws_clz_u32(n)

Search from the MSB to LSB, looking for a 1

Prototype

AWS_STATIC_IMPL size_t aws_clz_u32(uint32_t n);
source
LibAwsCommon.aws_common_library_initMethod
aws_common_library_init(allocator)

Initializes internal data structures used by aws-c-common. Must be called before using any functionality in aws-c-common.

Prototype

void aws_common_library_init(struct aws_allocator *allocator);
source
LibAwsCommon.aws_condition_variable_waitMethod
aws_condition_variable_wait(condition_variable, mutex)

Waits the calling thread on a notification from another thread.

Prototype

int aws_condition_variable_wait(struct aws_condition_variable *condition_variable, struct aws_mutex *mutex);
source
LibAwsCommon.aws_condition_variable_wait_forMethod
aws_condition_variable_wait_for(condition_variable, mutex, time_to_wait)

Waits the calling thread on a notification from another thread. Times out after time_to_wait. time_to_wait is in nanoseconds.

Prototype

int aws_condition_variable_wait_for( struct aws_condition_variable *condition_variable, struct aws_mutex *mutex, int64_t time_to_wait);
source
LibAwsCommon.aws_condition_variable_wait_for_predMethod
aws_condition_variable_wait_for_pred(condition_variable, mutex, time_to_wait, pred, pred_ctx)

Waits the calling thread on a notification from another thread. Times out after time_to_wait. time_to_wait is in nanoseconds. If predicate returns false, the wait is reentered, otherwise control returns to the caller.

Prototype

int aws_condition_variable_wait_for_pred( struct aws_condition_variable *condition_variable, struct aws_mutex *mutex, int64_t time_to_wait, aws_condition_predicate_fn *pred, void *pred_ctx);
source
LibAwsCommon.aws_condition_variable_wait_predMethod
aws_condition_variable_wait_pred(condition_variable, mutex, pred, pred_ctx)

Waits the calling thread on a notification from another thread. If predicate returns false, the wait is reentered, otherwise control returns to the caller.

Prototype

int aws_condition_variable_wait_pred( struct aws_condition_variable *condition_variable, struct aws_mutex *mutex, aws_condition_predicate_fn *pred, void *pred_ctx);
source
LibAwsCommon.aws_cpu_has_featureMethod
aws_cpu_has_feature(feature_name)

Returns true if a cpu feature is supported, false otherwise.

Prototype

bool aws_cpu_has_feature(enum aws_cpu_feature_name feature_name);
source
LibAwsCommon.aws_cross_process_lock_releaseMethod
aws_cross_process_lock_release(instance_lock)

Releases the lock so the next caller (may be another process) can get an instance of the lock.

Prototype

void aws_cross_process_lock_release(struct aws_cross_process_lock *instance_lock);
source
LibAwsCommon.aws_cross_process_lock_try_acquireMethod
aws_cross_process_lock_try_acquire(allocator, instance_nonce)

Attempts to acquire a system-wide (not per process or per user) lock scoped by instance_nonce. For any given unique nonce, a lock will be returned by the first caller. Subsequent calls will return NULL and raise AWS_ERROR_MUTEX_CALLER_NOT_OWNER until the either the process owning the lock exits or the program owning the lock calls aws_cross_process_lock_release() explicitly.

If the process exits before the lock is released, the kernel will unlock it for the next consumer.

Prototype

struct aws_cross_process_lock *aws_cross_process_lock_try_acquire( struct aws_allocator *allocator, struct aws_byte_cursor instance_nonce);
source
LibAwsCommon.aws_crt_statistics_handler_destroyMethod
aws_crt_statistics_handler_destroy(handler)

completely destroys a statistics handler. The handler's cleanup function must clean up the impl portion completely (including its allocation, if done separately).

Prototype

void aws_crt_statistics_handler_destroy(struct aws_crt_statistics_handler *handler);
source
LibAwsCommon.aws_crt_statistics_handler_get_report_interval_msMethod
aws_crt_statistics_handler_get_report_interval_ms(handler)

Queries the frequency (via an interval in milliseconds) which a statistics handler would like to be informed of statistics.

Prototype

uint64_t aws_crt_statistics_handler_get_report_interval_ms(struct aws_crt_statistics_handler *handler);
source
LibAwsCommon.aws_crt_statistics_handler_process_statisticsMethod
aws_crt_statistics_handler_process_statistics(handler, interval, stats, context)

Submits a list of statistics objects to a statistics handler for processing

handler - the statistics handler that will process the statistics objects interval - time period over which the statistics were gathered stats - list of pointers to structures that can be case to aws_crt_statistics_base (i.e. have category as a first member) context - (optional) additional context specific to where the statistics handler has been attached

Prototype

void aws_crt_statistics_handler_process_statistics( struct aws_crt_statistics_handler *handler, struct aws_crt_statistics_sample_interval *interval, struct aws_array_list *stats, void *context);
source
LibAwsCommon.aws_ctz_u32Method
aws_ctz_u32(n)

Search from the LSB to MSB, looking for a 1

Prototype

AWS_STATIC_IMPL size_t aws_ctz_u32(uint32_t n);
source
LibAwsCommon.aws_date_time_day_of_weekMethod
aws_date_time_day_of_week(dt, local_time)

Documentation not found.

Prototype

enum aws_date_day_of_week aws_date_time_day_of_week(const struct aws_date_time *dt, bool local_time);
source
LibAwsCommon.aws_date_time_diffMethod
aws_date_time_diff(a, b)

returns the difference of a and b (a - b) in seconds.

Prototype

time_t aws_date_time_diff(const struct aws_date_time *a, const struct aws_date_time *b);
source
LibAwsCommon.aws_date_time_dstMethod
aws_date_time_dst(dt, local_time)

Documentation not found.

Prototype

bool aws_date_time_dst(const struct aws_date_time *dt, bool local_time);
source
LibAwsCommon.aws_date_time_hourMethod
aws_date_time_hour(dt, local_time)

Documentation not found.

Prototype

uint8_t aws_date_time_hour(const struct aws_date_time *dt, bool local_time);
source
LibAwsCommon.aws_date_time_init_epoch_millisMethod
aws_date_time_init_epoch_millis(dt, ms_since_epoch)

Initializes dt to be the time represented in milliseconds since unix epoch.

Prototype

void aws_date_time_init_epoch_millis(struct aws_date_time *dt, uint64_t ms_since_epoch);
source
LibAwsCommon.aws_date_time_init_epoch_secsMethod
aws_date_time_init_epoch_secs(dt, sec_ms)

Initializes dt to be the time represented in seconds.millis since unix epoch.

Prototype

void aws_date_time_init_epoch_secs(struct aws_date_time *dt, double sec_ms);
source
LibAwsCommon.aws_date_time_init_from_strMethod
aws_date_time_init_from_str(dt, date_str, fmt)

Initializes dt to be the time represented by date_str in format 'fmt'. Returns AWS_OP_SUCCESS if the string was successfully parsed, returns AWS_OP_ERR if parsing failed.

The parser is lenient regarding AWS_DATE_FORMAT_ISO_8601 vs AWS_DATE_FORMAT_ISO_8601_BASIC. Regardless of which you pass in, both "2002-10-02T08:05:09Z" and "20021002T080509Z" would be accepted.

Notes for AWS_DATE_FORMAT_RFC822: If no time zone information is provided, it is assumed to be local time (please don't do this).

Only time zones indicating Universal Time (e.g. Z, UT, UTC, or GMT), or offsets from UTC (e.g. +0100, -0700), are accepted.

Really, it's just better if you always use Universal Time.

Prototype

int aws_date_time_init_from_str( struct aws_date_time *dt, const struct aws_byte_buf *date_str, enum aws_date_format fmt);
source
LibAwsCommon.aws_date_time_init_from_str_cursorMethod
aws_date_time_init_from_str_cursor(dt, date_str_cursor, fmt)

aws_date_time_init variant that takes a byte_cursor rather than a byte_buf

Prototype

int aws_date_time_init_from_str_cursor( struct aws_date_time *dt, const struct aws_byte_cursor *date_str_cursor, enum aws_date_format fmt);
source
LibAwsCommon.aws_date_time_minuteMethod
aws_date_time_minute(dt, local_time)

Documentation not found.

Prototype

uint8_t aws_date_time_minute(const struct aws_date_time *dt, bool local_time);
source
LibAwsCommon.aws_date_time_monthMethod
aws_date_time_month(dt, local_time)

Documentation not found.

Prototype

enum aws_date_month aws_date_time_month(const struct aws_date_time *dt, bool local_time);
source
LibAwsCommon.aws_date_time_secondMethod
aws_date_time_second(dt, local_time)

Documentation not found.

Prototype

uint8_t aws_date_time_second(const struct aws_date_time *dt, bool local_time);
source
LibAwsCommon.aws_date_time_to_local_time_short_strMethod
aws_date_time_to_local_time_short_str(dt, fmt, output_buf)

Copies the current time as a formatted short date string in local time into output_buf. If buffer is too small, it will return AWS_OP_ERR. A good size suggestion is AWS_DATE_TIME_STR_MAX_LEN bytes. AWS_DATE_FORMAT_AUTO_DETECT is not allowed.

Prototype

int aws_date_time_to_local_time_short_str( const struct aws_date_time *dt, enum aws_date_format fmt, struct aws_byte_buf *output_buf);
source
LibAwsCommon.aws_date_time_to_local_time_strMethod
aws_date_time_to_local_time_str(dt, fmt, output_buf)

Copies the current time as a formatted date string in local time into output_buf. If buffer is too small, it will return AWS_OP_ERR. A good size suggestion is AWS_DATE_TIME_STR_MAX_LEN bytes. AWS_DATE_FORMAT_AUTO_DETECT is not allowed.

Prototype

int aws_date_time_to_local_time_str( const struct aws_date_time *dt, enum aws_date_format fmt, struct aws_byte_buf *output_buf);
source
LibAwsCommon.aws_date_time_to_utc_time_short_strMethod
aws_date_time_to_utc_time_short_str(dt, fmt, output_buf)

Copies the current time as a formatted short date string in utc time into output_buf. If buffer is too small, it will return AWS_OP_ERR. A good size suggestion is AWS_DATE_TIME_STR_MAX_LEN bytes. AWS_DATE_FORMAT_AUTO_DETECT is not allowed.

Prototype

int aws_date_time_to_utc_time_short_str( const struct aws_date_time *dt, enum aws_date_format fmt, struct aws_byte_buf *output_buf);
source
LibAwsCommon.aws_date_time_to_utc_time_strMethod
aws_date_time_to_utc_time_str(dt, fmt, output_buf)

Copies the current time as a formatted date string in utc time into output_buf. If buffer is too small, it will return AWS_OP_ERR. A good size suggestion is AWS_DATE_TIME_STR_MAX_LEN bytes. AWS_DATE_FORMAT_AUTO_DETECT is not allowed.

Prototype

int aws_date_time_to_utc_time_str( const struct aws_date_time *dt, enum aws_date_format fmt, struct aws_byte_buf *output_buf);
source
LibAwsCommon.aws_date_time_yearMethod
aws_date_time_year(dt, local_time)

Documentation not found.

Prototype

uint16_t aws_date_time_year(const struct aws_date_time *dt, bool local_time);
source
LibAwsCommon.aws_decode_utf8Method
aws_decode_utf8(bytes, options)

Decode a complete string of UTF8/ASCII text. Text is always validated according to RFC-3629 (you may perform additional validation in the on_codepoint callback). The text does not need to begin with a UTF8 BOM. If you need to decode text incrementally as you receive it, use aws_utf8_decoder_new() instead.

Arguments

  • bytes: Text to decode.
  • options: Options for decoding. If NULL is passed, the text is simply validated.

Returns

AWS_OP_SUCCESS if successful. An error is raised if the text is not valid, or the on_codepoint callback raises an error.

Prototype

int aws_decode_utf8(struct aws_byte_cursor bytes, const struct aws_utf8_decoder_options *options);
source
LibAwsCommon.aws_device_random_bufferMethod
aws_device_random_buffer(output)

Fill the rest of a buffer with unpredictably random bytes, suitable for cryptographic use.

Prototype

int aws_device_random_buffer(struct aws_byte_buf *output);
source
LibAwsCommon.aws_device_random_buffer_appendMethod
aws_device_random_buffer_append(output, n)

Write N unpredictably random bytes to a buffer, suitable for cryptographic use. If there is insufficient space in the buffer, AWS_ERROR_SHORT_BUFFER is raised and the buffer will be unchanged.

Prototype

int aws_device_random_buffer_append(struct aws_byte_buf *output, size_t n);
source
LibAwsCommon.aws_device_random_u16Method
aws_device_random_u16(output)

Get an unpredictably random 16bit number, suitable for cryptographic use.

Prototype

int aws_device_random_u16(uint16_t *output);
source
LibAwsCommon.aws_device_random_u32Method
aws_device_random_u32(output)

Get an unpredictably random 32bit number, suitable for cryptographic use.

Prototype

int aws_device_random_u32(uint32_t *output);
source
LibAwsCommon.aws_device_random_u64Method
aws_device_random_u64(output)

Get an unpredictably random 64bit number, suitable for cryptographic use.

Prototype

int aws_device_random_u64(uint64_t *output);
source
LibAwsCommon.aws_device_random_u8Method
aws_device_random_u8(output)

Get an unpredictably random 8bit number, suitable for cryptographic use.

Prototype

int aws_device_random_u8(uint8_t *output);
source
LibAwsCommon.aws_directory_createMethod
aws_directory_create(dir_path)

Creates a directory if it doesn't currently exist. If the directory already exists, it's ignored and assumed successful.

Returns AWS_OP_SUCCESS on success. Otherwise, check aws_last_error().

Prototype

int aws_directory_create(const struct aws_string *dir_path);
source
LibAwsCommon.aws_directory_deleteMethod
aws_directory_delete(dir_path, recursive)

Deletes a directory. If the directory is not empty, this will fail unless the recursive parameter is set to true. If recursive is true then the entire directory and all of its contents will be deleted. If it is set to false, the directory will be deleted only if it is empty. Returns AWS_OP_SUCCESS if the operation was successful. Otherwise, aws_last_error() will contain the error that occurred. If the directory doesn't exist, AWS_OP_SUCCESS is still returned.

Prototype

int aws_directory_delete(const struct aws_string *dir_path, bool recursive);
source
LibAwsCommon.aws_directory_entry_iterator_newMethod
aws_directory_entry_iterator_new(allocator, path)

Creates a read-only iterator of a directory starting at path. If path is invalid or there's any other error condition, NULL will be returned. Call aws_last_error() for the exact error in that case.

Prototype

struct aws_directory_iterator *aws_directory_entry_iterator_new( struct aws_allocator *allocator, const struct aws_string *path);
source
LibAwsCommon.aws_directory_existsMethod
aws_directory_exists(dir_path)

Returns true if the directory currently exists. Otherwise, it returns false.

Prototype

bool aws_directory_exists(const struct aws_string *dir_path);
source
LibAwsCommon.aws_directory_traverseMethod
aws_directory_traverse(allocator, path, recursive, on_entry, user_data)

Traverse a directory starting at path.

If you want the traversal to recurse the entire directory, pass recursive as true. Passing false for this parameter will only iterate the contents of the directory, but will not descend into any directories it encounters.

If recursive is set to true, the traversal is performed post-order, depth-first (for practical reasons such as deleting a directory that contains subdirectories or files).

returns AWS_OP_SUCCESS(0) on success.

Prototype

int aws_directory_traverse( struct aws_allocator *allocator, const struct aws_string *path, bool recursive, aws_on_directory_entry *on_entry, void *user_data);
source
LibAwsCommon.aws_fatal_assertMethod
aws_fatal_assert(cond_str, file, line)

Documentation not found.

Prototype

void aws_fatal_assert(const char *cond_str, const char *file, int line) AWS_ATTRIBUTE_NORETURN;
source
LibAwsCommon.aws_file_get_lengthMethod
aws_file_get_length(file, length)

Wrapper for os-specific file length query. We can't use fseek(END, 0) because support for it is not technically required.

Unix flavors call fstat, while Windows variants use GetFileSize on a HANDLE queried from the libc FILE pointer.

Prototype

int aws_file_get_length(FILE *file, int64_t *length);
source
LibAwsCommon.aws_fopenMethod
aws_fopen(file_path, mode)

Deprecated - Use aws_fopen_safe() instead, avoid const char * in public APIs. Opens file at file_path using mode. Returns the FILE pointer if successful. Otherwise, aws_last_error() will contain the error that occurred

Prototype

FILE *aws_fopen(const char *file_path, const char *mode);
source
LibAwsCommon.aws_fopen_safeMethod
aws_fopen_safe(file_path, mode)

Opens file at file_path using mode. Returns the FILE pointer if successful. Otherwise, aws_last_error() will contain the error that occurred

Prototype

FILE *aws_fopen_safe(const struct aws_string *file_path, const struct aws_string *mode);
source
LibAwsCommon.aws_fseekMethod
aws_fseek(file, offset, whence)

Wrapper for highest-resolution platform-dependent seek implementation. Maps to:

_fseeki64() on windows fseeko() on linux

whence can either be SEEK_SET or SEEK_END

Returns AWS_OP_SUCCESS, or AWS_OP_ERR (after an error has been raised).

Prototype

int aws_fseek(FILE *file, int64_t offset, int whence);
source
LibAwsCommon.aws_get_cpu_group_countMethod
aws_get_cpu_group_count()

Returns the logical processor groupings on the system (such as multiple numa nodes).

Prototype

uint16_t aws_get_cpu_group_count(void);
source
LibAwsCommon.aws_get_cpu_ids_for_groupMethod
aws_get_cpu_ids_for_group(group_idx, cpu_ids_array, cpu_ids_array_length)

Fills in cpu_ids_array with the cpu_id's for the group. To obtain the size to allocate for cpu_ids_array and the value for argument for cpu_ids_array_length, call aws_get_cpu_count_for_group().

Prototype

void aws_get_cpu_ids_for_group(uint16_t group_idx, struct aws_cpu_info *cpu_ids_array, size_t cpu_ids_array_length);
source
LibAwsCommon.aws_get_environment_valueMethod
aws_get_environment_value(allocator, variable_name, value_out)

Get the value of an environment variable. If the variable is not set, the output string will be set to NULL. Not thread-safe

Prototype

int aws_get_environment_value( struct aws_allocator *allocator, const struct aws_string *variable_name, struct aws_string **value_out);
source
LibAwsCommon.aws_get_hard_limit_io_handlesMethod
aws_get_hard_limit_io_handles()

Returns the hard limit for max io handles (max fds in unix terminology). This limit is one more than the actual limit. This limit cannot be increased without sudo permissions.

Prototype

size_t aws_get_hard_limit_io_handles(void);
source
LibAwsCommon.aws_get_home_directoryMethod
aws_get_home_directory(allocator)

Returns the current user's home directory.

Prototype

struct aws_string *aws_get_home_directory(struct aws_allocator *allocator);
source
LibAwsCommon.aws_get_soft_limit_io_handlesMethod
aws_get_soft_limit_io_handles()

Returns the soft limit for max io handles (max fds in unix terminology). This limit is one more than the actual limit. The soft limit can be changed up to the hard limit by any process regardless of permissions.

Prototype

size_t aws_get_soft_limit_io_handles(void);
source
LibAwsCommon.aws_gmtimeMethod
aws_gmtime(time, t)

Cross platform friendly version of gmtime_r

Prototype

void aws_gmtime(time_t time, struct tm *t);
source
LibAwsCommon.aws_hash_array_ignore_caseMethod
aws_hash_array_ignore_case(array, len)

Case-insensitive hash function for array containing ASCII or UTF-8 text.

Prototype

uint64_t aws_hash_array_ignore_case(const void *array, const size_t len);
source
LibAwsCommon.aws_hash_iter_beginMethod
aws_hash_iter_begin(map)

Returns an iterator to be used for iterating through a hash table. Iterator will already point to the first element of the table it finds, which can be accessed as iter.element.

This function cannot fail, but if there are no elements in the table, the returned iterator will return true for aws_hash_iter_done(&iter).

Prototype

struct aws_hash_iter aws_hash_iter_begin(const struct aws_hash_table *map);
source
LibAwsCommon.aws_hash_iter_deleteMethod
aws_hash_iter_delete(iter, destroy_contents)

Deletes the element currently pointed-to by the hash iterator. After calling this method, the element member of the iterator should not be accessed until the next call to aws_hash_iter_next.

Arguments

  • destroy_contents: If true, the destructors for the key and value will be called.

Prototype

void aws_hash_iter_delete(struct aws_hash_iter *iter, bool destroy_contents);
source
LibAwsCommon.aws_hash_iter_doneMethod
aws_hash_iter_done(iter)

Returns true if iterator is done iterating through table, false otherwise. If this is true, the iterator will not include an element of the table.

Prototype

bool aws_hash_iter_done(const struct aws_hash_iter *iter);
source
LibAwsCommon.aws_hash_iter_is_validMethod
aws_hash_iter_is_valid(iter)

Given a pointer to a hash_iter, checks that it is well-formed, with all data-structure invariants.

Prototype

bool aws_hash_iter_is_valid(const struct aws_hash_iter *iter);
source
LibAwsCommon.aws_hash_iter_nextMethod
aws_hash_iter_next(iter)

Updates iterator so that it points to next element of hash table.

This and the two previous functions are designed to be used together with the following idiom:

for (struct aws_hash_iter iter = aws_hash_iter_begin(&map); !aws_hash_iter_done(&iter); aws_hash_iter_next(&iter)) { const key\_type key = *(const key\_type *)iter.element.key; value\_type value = *(value\_type *)iter.element.value; // etc. }

Note that calling this on an iter which is "done" is idempotent: i.e. it will return another iter which is "done".

Prototype

void aws_hash_iter_next(struct aws_hash_iter *iter);
source
LibAwsCommon.aws_hash_ptrMethod
aws_hash_ptr(item)

Convenience hash function which hashes the pointer value directly, without dereferencing. This can be used in cases where pointer identity is desired, or where a uintptr_t is encoded into a const void *.

Prototype

uint64_t aws_hash_ptr(const void *item);
source
LibAwsCommon.aws_hash_table_clean_upMethod
aws_hash_table_clean_up(map)

Deletes every element from map and frees all associated memory. destroy_fn will be called for each element. aws_hash_table_init must be called before reusing the hash table.

This method is idempotent.

Prototype

void aws_hash_table_clean_up(struct aws_hash_table *map);
source
LibAwsCommon.aws_hash_table_clearMethod
aws_hash_table_clear(map)

Removes every element from the hash map. destroy_fn will be called for each element.

Prototype

void aws_hash_table_clear(struct aws_hash_table *map);
source
LibAwsCommon.aws_hash_table_createMethod
aws_hash_table_create(map, key, p_elem, was_created)

Attempts to locate an element at key. If no such element was found, creates a new element, with value initialized to NULL. In either case, a pointer to the element is placed in *p_elem.

If was_created is non-NULL, *was_created is set to 0 if an existing element was found, or 1 is a new element was created.

Returns AWS_OP_SUCCESS if an item was found or created. Raises AWS_ERROR_OOM if hash table expansion was required and memory allocation failed.

Prototype

int aws_hash_table_create( struct aws_hash_table *map, const void *key, struct aws_hash_element **p_elem, int *was_created);
source
LibAwsCommon.aws_hash_table_eqMethod
aws_hash_table_eq(a, b, value_eq)

Compares two hash tables for equality. Both hash tables must have equivalent key comparators; values will be compared using the comparator passed into this function. The key hash function does not need to be equivalent between the two hash tables.

Prototype

bool aws_hash_table_eq( const struct aws_hash_table *a, const struct aws_hash_table *b, aws_hash_callback_eq_fn *value_eq);
source
LibAwsCommon.aws_hash_table_findMethod
aws_hash_table_find(map, key, p_elem)

Attempts to locate an element at key. If the element is found, a pointer to the value is placed in *p_elem; if it is not found, *pElem is set to NULL. Either way, AWS_OP_SUCCESS is returned.

This method does not change the state of the hash table. Therefore, it is safe to call _find from multiple threads on the same hash table, provided no mutating operations happen in parallel.

Calling code may update the value in the hash table by modifying **pElem after a successful find. However, this pointer is not guaranteed to remain usable after a subsequent call to _put, _delete, _clear, or _clean_up.

Prototype

int aws_hash_table_find(const struct aws_hash_table *map, const void *key, struct aws_hash_element **p_elem);
source
LibAwsCommon.aws_hash_table_foreachMethod
aws_hash_table_foreach(map, callback, context)

Iterates through every element in the map and invokes the callback on that item. Iteration is performed in an arbitrary, implementation-defined order, and is not guaranteed to be consistent across invocations.

The callback may change the value associated with the key by overwriting the value pointed-to by value. In this case, the on_element_removed callback will not be invoked, unless the callback invokes AWS_COMMON_HASH_TABLE_ITER_DELETE (in which case the on_element_removed is given the updated value).

The callback must return a bitmask of zero or more of the following values ORed together:

AWS_COMMON_HASH_TABLE_ITER_CONTINUE - Continues iteration to the next element (if not set, iteration stops) # AWS_COMMON_HASH_TABLE_ITER_DELETE - Deletes the current value and continues iteration. destroy_fn will NOT be invoked. # AWS_COMMON_HASH_TABLE_ITER_ERROR - Stop iteration with error. No action will be taken for the current value and the value before this. No rolling back. The deleted value before will NOT be back. aws_hash_table_foreach returns AWS_OP_ERR after stropping the iteration.

Invoking any method which may change the contents of the hashtable during iteration results in undefined behavior. However, you may safely invoke non-mutating operations during an iteration.

This operation is mutating only if AWS_COMMON_HASH_TABLE_ITER_DELETE is returned at some point during iteration. Otherwise, it is non-mutating and is safe to invoke in parallel with other non-mutating operations.

Prototype

int aws_hash_table_foreach( struct aws_hash_table *map, int (*callback)(void *context, struct aws_hash_element *p_element), void *context);
source
LibAwsCommon.aws_hash_table_initMethod
aws_hash_table_init(map, alloc, size, hash_fn, equals_fn, destroy_key_fn, destroy_value_fn)

Initializes a hash map with initial capacity for 'size' elements without resizing. Uses hash_fn to compute the hash of each element. equals_fn to compute equality of two keys. Whenever an element is removed without being returned, destroy_key_fn is run on the pointer to the key and destroy_value_fn is run on the pointer to the value. Either or both may be NULL if a callback is not desired in this case.

Prototype

int aws_hash_table_init( struct aws_hash_table *map, struct aws_allocator *alloc, size_t size, aws_hash_fn *hash_fn, aws_hash_callback_eq_fn *equals_fn, aws_hash_callback_destroy_fn *destroy_key_fn, aws_hash_callback_destroy_fn *destroy_value_fn);
source
LibAwsCommon.aws_hash_table_moveMethod
aws_hash_table_move(to, from)

Moves the hash table in 'from' to 'to'. After this move, 'from' will be identical to the state of the original 'to' hash table, and 'to' will be in the same state as if it had been passed to aws_hash_table_clean_up (that is, it will have no memory allocated, and it will be safe to either discard it or call aws_hash_table_clean_up again).

Note that 'to' will not be cleaned up. You should make sure that 'to' is either uninitialized or cleaned up before moving a hashtable into it.

Prototype

void aws_hash_table_move(struct aws_hash_table *AWS_RESTRICT to, struct aws_hash_table *AWS_RESTRICT from);
source
LibAwsCommon.aws_hash_table_putMethod
aws_hash_table_put(map, key, value, was_created)

Inserts a new element at key, with the given value. If another element exists at that key, the old element will be overwritten; both old key and value objects will be destroyed.

If was_created is non-NULL, *was_created is set to 0 if an existing element was found, or 1 is a new element was created.

Returns AWS_OP_SUCCESS if an item was found or created. Raises AWS_ERROR_OOM if hash table expansion was required and memory allocation failed.

Prototype

int aws_hash_table_put(struct aws_hash_table *map, const void *key, void *value, int *was_created);
source
LibAwsCommon.aws_hash_table_removeMethod
aws_hash_table_remove(map, key, p_value, was_present)

Removes element at key. Always returns AWS_OP_SUCCESS.

If pValue is non-NULL, the existing value (if any) is moved into (*value) before removing from the table, and destroy_fn is _not_ invoked. If pValue is NULL, then (if the element existed) destroy_fn will be invoked on the element being removed.

If was_present is non-NULL, it is set to 0 if the element was not present, or 1 if it was present (and is now removed).

Prototype

int aws_hash_table_remove( struct aws_hash_table *map, const void *key, struct aws_hash_element *p_value, int *was_present);
source
LibAwsCommon.aws_hash_table_remove_elementMethod
aws_hash_table_remove_element(map, p_value)

Removes element already known (typically by find()).

p_value should point to a valid element returned by create() or find().

NOTE: DO NOT call this method from inside of a aws_hash_table_foreach callback, return AWS_COMMON_HASH_TABLE_ITER_DELETE instead.

Prototype

int aws_hash_table_remove_element(struct aws_hash_table *map, struct aws_hash_element *p_value);
source
LibAwsCommon.aws_hash_table_swapMethod
aws_hash_table_swap(a, b)

Safely swaps two hash tables. Note that we swap the entirety of the hash table, including which allocator is associated.

Neither hash table is required to be initialized; if one or both is uninitialized, then the uninitialized state is also swapped.

Prototype

void aws_hash_table_swap(struct aws_hash_table *AWS_RESTRICT a, struct aws_hash_table *AWS_RESTRICT b);
source
LibAwsCommon.aws_hex_compute_decoded_lenMethod
aws_hex_compute_decoded_len(to_decode_len, decoded_len)

computes the length necessary to store the result of aws_hex_decode(). returns -1 on failure, and 0 on success. decoded_len will be set on success.

Prototype

int aws_hex_compute_decoded_len(size_t to_decode_len, size_t *decoded_len);
source
LibAwsCommon.aws_hex_compute_encoded_lenMethod
aws_hex_compute_encoded_len(to_encode_len, encoded_length)

computes the length necessary to store the result of aws_hex_encode(). returns -1 on failure, and 0 on success. encoded_length will be set on success.

Prototype

int aws_hex_compute_encoded_len(size_t to_encode_len, size_t *encoded_length);
source
LibAwsCommon.aws_hex_decodeMethod
aws_hex_decode(to_decode, output)

Base 16 (hex) decodes the contents of to_decode and stores the result in output. If output is NULL, output_size will be set to what the output_size should be.

Prototype

int aws_hex_decode(const struct aws_byte_cursor *AWS_RESTRICT to_decode, struct aws_byte_buf *AWS_RESTRICT output);
source
LibAwsCommon.aws_hex_encodeMethod
aws_hex_encode(to_encode, output)

Base 16 (hex) encodes the contents of to_encode and stores the result in output. 0 terminates the result. Assumes the buffer is empty and does not resize on insufficient capacity.

Prototype

int aws_hex_encode(const struct aws_byte_cursor *AWS_RESTRICT to_encode, struct aws_byte_buf *AWS_RESTRICT output);
source
LibAwsCommon.aws_hex_encode_append_dynamicMethod
aws_hex_encode_append_dynamic(to_encode, output)

Base 16 (hex) encodes the contents of to_encode and appends the result in output. Does not 0-terminate. Grows the destination buffer dynamically if necessary.

Prototype

int aws_hex_encode_append_dynamic( const struct aws_byte_cursor *AWS_RESTRICT to_encode, struct aws_byte_buf *AWS_RESTRICT output);
source
LibAwsCommon.aws_high_res_clock_get_ticksMethod
aws_high_res_clock_get_ticks(timestamp)

Get ticks in nanoseconds (usually 100 nanosecond precision) on the high resolution clock (most-likely TSC). This clock has no bearing on the actual system time. On success, timestamp will be set.

Prototype

int aws_high_res_clock_get_ticks(uint64_t *timestamp);
source
LibAwsCommon.aws_hton16Method
aws_hton16(x)

Convert 16 bit integer from host to network byte order.

Prototype

AWS_STATIC_IMPL uint16_t aws_hton16(uint16_t x);
source
LibAwsCommon.aws_hton32Method
aws_hton32(x)

Convert 32 bit integer from host to network byte order.

Prototype

AWS_STATIC_IMPL uint32_t aws_hton32(uint32_t x);
source
LibAwsCommon.aws_hton64Method
aws_hton64(x)

Convert 64 bit integer from host to network byte order.

Prototype

AWS_STATIC_IMPL uint64_t aws_hton64(uint64_t x);
source
LibAwsCommon.aws_htonf32Method
aws_htonf32(x)

Convert 32 bit float from host to network byte order.

Prototype

AWS_STATIC_IMPL float aws_htonf32(float x);
source
LibAwsCommon.aws_htonf64Method
aws_htonf64(x)

Convert 64 bit double from host to network byte order.

Prototype

AWS_STATIC_IMPL double aws_htonf64(double x);
source
LibAwsCommon.aws_init_memory_usage_for_current_processMethod
aws_init_memory_usage_for_current_process(memory_usage)

Get memory usage for current process. Raises AWS_ERROR_SYS_CALL_FAILURE on failure.

Prototype

int aws_init_memory_usage_for_current_process(struct aws_memory_usage_stats *memory_usage);
source
LibAwsCommon.aws_is_big_endianMethod
aws_is_big_endian()

Returns 1 if machine is big endian, 0 if little endian. If you compile with even -O1 optimization, this check is completely optimized out at compile time and code which calls "if (aws_is_big_endian())" will do the right thing without branching.

Prototype

AWS_STATIC_IMPL int aws_is_big_endian(void);
source
LibAwsCommon.aws_is_mem_zeroedMethod
aws_is_mem_zeroed(buf, bufsize)

Returns whether each byte is zero.

Prototype

AWS_STATIC_IMPL bool aws_is_mem_zeroed(const void *buf, size_t bufsize);
source
LibAwsCommon.aws_isalnumMethod
aws_isalnum(ch)

Like isalnum(), but ignores C locale. Returns true if ch has the value of ASCII/UTF-8: 'a'-'z', 'A'-'Z', or '0'-'9'.

Prototype

bool aws_isalnum(uint8_t ch);
source
LibAwsCommon.aws_isalphaMethod
aws_isalpha(ch)

Like isalpha(), but ignores C locale. Returns true if ch has the value of ASCII/UTF-8: 'a'-'z' or 'A'-'Z'.

Prototype

bool aws_isalpha(uint8_t ch);
source
LibAwsCommon.aws_isdigitMethod
aws_isdigit(ch)

Like isdigit(). Returns true if ch has the value of ASCII/UTF-8: '0'-'9'.

Note: C's built-in isdigit() is also supposed to ignore the C locale, but cppreference.com claims "some implementations (e.g. Microsoft in 1252 codepage) may classify additional single-byte characters as digits"

Prototype

bool aws_isdigit(uint8_t ch);
source
LibAwsCommon.aws_isspaceMethod
aws_isspace(ch)

Like isspace(), but ignores C locale. Return true if ch has the value of ASCII/UTF-8: space (0x20), form feed (0x0C), line feed (0x0A), carriage return (0x0D), horizontal tab (0x09), or vertical tab (0x0B).

Prototype

bool aws_isspace(uint8_t ch);
source
LibAwsCommon.aws_isxdigitMethod
aws_isxdigit(ch)

Like isxdigit(). Returns true if ch has the value of ASCII/UTF-8: '0'-'9', 'a'-'f', or 'A'-'F'.

Note: C's built-in isxdigit() is also supposed to ignore the C locale, but cppreference.com claims "some implementations (e.g. Microsoft in 1252 codepage) may classify additional single-byte characters as digits"

Prototype

bool aws_isxdigit(uint8_t ch);
source
LibAwsCommon.aws_json_const_iterate_arrayMethod
aws_json_const_iterate_array(array, on_value, user_data)

iterates through values of an array. iteration is sequential starting with 0th element.

Arguments

  • array: array to iterate over.
  • on_value: callback for when value is encountered.
  • user_data: user data to pass back in callback.

Returns

AWS_OP_SUCCESS when iteration finishes completely or exits early, AWS_OP_ERR if value is not an array.

Prototype

int aws_json_const_iterate_array( const struct aws_json_value *array, aws_json_on_value_encountered_const_fn *on_value, void *user_data);
source
LibAwsCommon.aws_json_const_iterate_objectMethod
aws_json_const_iterate_object(object, on_member, user_data)

iterates through members of the object. iteration is sequential in order fields were initially parsed.

Arguments

  • object: object to iterate over.
  • on_member: callback for when member is encountered.
  • user_data: user data to pass back in callback.

Returns

AWS_OP_SUCCESS when iteration finishes completely or exits early, AWS_OP_ERR if value is not an object.

Prototype

int aws_json_const_iterate_object( const struct aws_json_value *object, aws_json_on_member_encountered_const_fn *on_member, void *user_data);
source
LibAwsCommon.aws_json_value_add_array_elementMethod
aws_json_value_add_array_element(array, value)

Adds a aws_json_value to the given array aws_json_value.

Note that the aws_json_value will be destroyed when the aws_json_value array is destroyed by calling "aws_json_destroy()"

Arguments

Returns

AWS_OP_SUCCESS if adding the aws_json_value was successful. Will return AWS_OP_ERR if the array passed is invalid.

Prototype

int aws_json_value_add_array_element(struct aws_json_value *array, const struct aws_json_value *value);
source
LibAwsCommon.aws_json_value_add_to_objectMethod
aws_json_value_add_to_object(object, key, value)

Adds a aws_json_value to a object aws_json_value.

Note that the aws_json_value will be destroyed when the aws_json_value object is destroyed by calling "aws_json_destroy()"

Arguments

Returns

AWS_OP_SUCCESS if adding was successful. Will return AWS_OP_ERROR if the object passed is invalid or if the passed key is already in use in the object.

Prototype

int aws_json_value_add_to_object( struct aws_json_value *object, struct aws_byte_cursor key, struct aws_json_value *value);
source
LibAwsCommon.aws_json_value_compareMethod
aws_json_value_compare(a, b, is_case_sensitive)

Checks whether two json values are equivalent.

Arguments

  • a: first value to compare.
  • b: second value to compare.
  • is_case_sensitive: case sensitive compare or not.

Returns

True is values are equal, false otherwise

Prototype

bool aws_json_value_compare(const struct aws_json_value *a, const struct aws_json_value *b, bool is_case_sensitive);
source
LibAwsCommon.aws_json_value_destroyMethod
aws_json_value_destroy(value)

Removes the aws_json_value from memory. If the aws_json_value is a object or array, it will also destroy attached aws_json_values as well.

For example, if you called "aws_json_array_add(b, a)" to add an object "a" to an array "b", if you call "aws_json_destroy(b)" then it will also free "a" automatically. All children/attached aws_json_values are freed when the parent/root aws_json_value is destroyed.

Arguments

Prototype

void aws_json_value_destroy(struct aws_json_value *value);
source
LibAwsCommon.aws_json_value_duplicateMethod
aws_json_value_duplicate(value)

Duplicates json value.

Arguments

  • value: first value to compare.

Returns

duplicated value. NULL and last error set if value cannot be duplicated.

Prototype

struct aws_json_value *aws_json_value_duplicate(const struct aws_json_value *value);
source
LibAwsCommon.aws_json_value_new_arrayMethod
aws_json_value_new_array(allocator)

Creates a new array aws_json_value and returns a pointer to it.

Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or on the object/array containing the aws_json_value. Deleting this array will also destroy any aws_json_values it contains.

Arguments

  • allocator: The allocator to use when creating the value

Returns

A new array aws_json_value

Prototype

struct aws_json_value *aws_json_value_new_array(struct aws_allocator *allocator);
source
LibAwsCommon.aws_json_value_new_booleanMethod
aws_json_value_new_boolean(allocator, boolean)

Creates a new boolean aws_json_value with the given boolean and returns a pointer to it.

Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or on the object/array containing the aws_json_value.

Arguments

  • boolean: The boolean you want to store in the aws_json_value
  • allocator: The allocator to use when creating the value

Returns

A new boolean aws_json_value

Prototype

struct aws_json_value *aws_json_value_new_boolean(struct aws_allocator *allocator, bool boolean);
source
LibAwsCommon.aws_json_value_new_from_stringMethod
aws_json_value_new_from_string(allocator, string)

Parses the JSON string and returns a aws_json_value containing the root of the JSON.

Arguments

  • allocator: The allocator used to create the value
  • string: The string containing the JSON.

Returns

The root aws_json_value of the JSON.

Prototype

struct aws_json_value *aws_json_value_new_from_string(struct aws_allocator *allocator, struct aws_byte_cursor string);
source
LibAwsCommon.aws_json_value_new_numberMethod
aws_json_value_new_number(allocator, number)

Creates a new number aws_json_value with the given number and returns a pointer to it.

Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or on the object/array containing the aws_json_value.

Arguments

  • number: The number you want to store in the aws_json_value
  • allocator: The allocator to use when creating the value

Returns

A new number aws_json_value

Prototype

struct aws_json_value *aws_json_value_new_number(struct aws_allocator *allocator, double number);
source
LibAwsCommon.aws_json_value_new_objectMethod
aws_json_value_new_object(allocator)

Creates a new object aws_json_value and returns a pointer to it.

Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or on the object/array containing the aws_json_value. Deleting this object will also destroy any aws_json_values it contains.

Arguments

  • allocator: The allocator to use when creating the value

Returns

A new object aws_json_value

Prototype

struct aws_json_value *aws_json_value_new_object(struct aws_allocator *allocator);
source
LibAwsCommon.aws_json_value_new_stringMethod
aws_json_value_new_string(allocator, string)

Creates a new string aws_json_value with the given string and returns a pointer to it.

Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or on the object/array containing the aws_json_value.

Arguments

  • string: A byte pointer to the string you want to store in the aws_json_value
  • allocator: The allocator to use when creating the value

Returns

A new string aws_json_value

Prototype

struct aws_json_value *aws_json_value_new_string(struct aws_allocator *allocator, struct aws_byte_cursor string);
source
LibAwsCommon.aws_json_value_remove_array_elementMethod
aws_json_value_remove_array_element(array, index)

Removes the aws_json_value at the given index in the array aws_json_value.

Arguments

Returns

AWS_OP_SUCCESS if the aws_json_value at the index was removed. Will return AWS_OP_ERR if the array passed is invalid or if the index passed is out of range.

Prototype

int aws_json_value_remove_array_element(struct aws_json_value *array, size_t index);
source
LibAwsCommon.aws_json_value_remove_from_objectMethod
aws_json_value_remove_from_object(object, key)

Removes the aws_json_value at the given key.

Arguments

Returns

AWS_OP_SUCCESS if the aws_json_value was removed. Will return AWS_OP_ERR if the object passed is invalid or if the value at the key cannot be found.

Prototype

int aws_json_value_remove_from_object(struct aws_json_value *object, struct aws_byte_cursor key);
source
LibAwsCommon.aws_last_errorMethod
aws_last_error()

Returns the latest error code on the current thread, or 0 if none have occurred.

Prototype

int aws_last_error(void);
source
LibAwsCommon.aws_linked_hash_table_clean_upMethod
aws_linked_hash_table_clean_up(table)

Cleans up the table. Elements in the table will be evicted and cleanup callbacks will be invoked.

Prototype

void aws_linked_hash_table_clean_up(struct aws_linked_hash_table *table);
source
LibAwsCommon.aws_linked_hash_table_find_and_move_to_backMethod
aws_linked_hash_table_find_and_move_to_back(table, key, p_value)

Finds element in the table by key. If found, AWS_OP_SUCCESS will be returned and the item will be moved to the back of the list. If not found, AWS_OP_SUCCESS will be returned and *p_value will be NULL.

Note: this will change the order of elements

Prototype

int aws_linked_hash_table_find_and_move_to_back(struct aws_linked_hash_table *table, const void *key, void **p_value);
source
LibAwsCommon.aws_linked_hash_table_initMethod
aws_linked_hash_table_init(table, allocator, hash_fn, equals_fn, destroy_key_fn, destroy_value_fn, initial_item_count)

Initializes the table. Sets up the underlying hash table and linked list. For the other parameters, see aws/common/hash_table.h. Hash table semantics of these arguments are preserved.

Prototype

int aws_linked_hash_table_init( struct aws_linked_hash_table *table, struct aws_allocator *allocator, aws_hash_fn *hash_fn, aws_hash_callback_eq_fn *equals_fn, aws_hash_callback_destroy_fn *destroy_key_fn, aws_hash_callback_destroy_fn *destroy_value_fn, size_t initial_item_count);
source
LibAwsCommon.aws_linked_hash_table_putMethod
aws_linked_hash_table_put(table, key, p_value)

Puts p_value at key. If an element is already stored at key it will be replaced.

Prototype

int aws_linked_hash_table_put(struct aws_linked_hash_table *table, const void *key, void *p_value);
source
LibAwsCommon.aws_linked_list_backMethod
aws_linked_list_back(list)

Returns the element in the back of the list.

Prototype

AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_back(const struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_beginMethod
aws_linked_list_begin(list)

Returns an iteration pointer for the first element in the list.

Prototype

AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_begin(const struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_endMethod
aws_linked_list_end(list)

Returns an iteration pointer for one past the last element in the list.

Prototype

AWS_STATIC_IMPL const struct aws_linked_list_node *aws_linked_list_end(const struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_frontMethod
aws_linked_list_front(list)

Returns the element in the front of the list.

Prototype

AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_front(const struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_initMethod
aws_linked_list_init(list)

Initializes the list. List will be empty after this call.

Prototype

AWS_STATIC_IMPL void aws_linked_list_init(struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_insert_afterMethod
aws_linked_list_insert_after(after, to_add)

Inserts to_add immediately after after.

Prototype

AWS_STATIC_IMPL void aws_linked_list_insert_after( struct aws_linked_list_node *after, struct aws_linked_list_node *to_add);
source
LibAwsCommon.aws_linked_list_insert_beforeMethod
aws_linked_list_insert_before(before, to_add)

Inserts to_add immediately before before.

Prototype

AWS_STATIC_IMPL void aws_linked_list_insert_before( struct aws_linked_list_node *before, struct aws_linked_list_node *to_add);
source
LibAwsCommon.aws_linked_list_is_valid_deepMethod
aws_linked_list_is_valid_deep(list)

Checks that a linked list satisfies double linked list connectivity constraints. This check is O(n) as it traverses the whole linked list to ensure that tail is reachable from head (and vice versa) and that every connection is bidirectional.

Note: This check cannot go into an infinite loop, because we ensure that the connection to the next node is bidirectional. Therefore, if a node's [a] a.next is a previous node [b] in the list, b.prev != &a and so this check would fail, thus terminating the loop.

Prototype

AWS_STATIC_IMPL bool aws_linked_list_is_valid_deep(const struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_move_all_backMethod
aws_linked_list_move_all_back(dst, src)

Remove all nodes from one list, and add them to the back of another.

Example: if dst={1,2} and src={3,4}, they become dst={1,2,3,4} and src={}

Prototype

AWS_STATIC_IMPL void aws_linked_list_move_all_back( struct aws_linked_list *AWS_RESTRICT dst, struct aws_linked_list *AWS_RESTRICT src);
source
LibAwsCommon.aws_linked_list_move_all_frontMethod
aws_linked_list_move_all_front(dst, src)

Remove all nodes from one list, and add them to the front of another.

Example: if dst={2,1} and src={4,3}, they become dst={4,3,2,1} and src={}

Prototype

AWS_STATIC_IMPL void aws_linked_list_move_all_front( struct aws_linked_list *AWS_RESTRICT dst, struct aws_linked_list *AWS_RESTRICT src);
source
LibAwsCommon.aws_linked_list_nextMethod
aws_linked_list_next(node)

Returns the next element in the list.

Prototype

AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_next(const struct aws_linked_list_node *node);
source
LibAwsCommon.aws_linked_list_node_next_is_validMethod
aws_linked_list_node_next_is_valid(node)

Checks that the prev of the next pointer of a node points to the node. As this checks whether the [next] connection of a node is bidirectional, it returns false if used for the list tail.

Prototype

AWS_STATIC_IMPL bool aws_linked_list_node_next_is_valid(const struct aws_linked_list_node *node);
source
LibAwsCommon.aws_linked_list_node_prev_is_validMethod
aws_linked_list_node_prev_is_valid(node)

Checks that the next of the prev pointer of a node points to the node. Similarly to the above, this returns false if used for the head of a list.

Prototype

AWS_STATIC_IMPL bool aws_linked_list_node_prev_is_valid(const struct aws_linked_list_node *node);
source
LibAwsCommon.aws_linked_list_pop_backMethod
aws_linked_list_pop_back(list)

Returns the element in the back of the list and removes it

Prototype

AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_pop_back(struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_pop_frontMethod
aws_linked_list_pop_front(list)

Returns the element in the front of the list and removes it

Prototype

AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_pop_front(struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_prevMethod
aws_linked_list_prev(node)

Returns the previous element in the list.

Prototype

AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_prev(const struct aws_linked_list_node *node);
source
LibAwsCommon.aws_linked_list_push_backMethod
aws_linked_list_push_back(list, node)

Append new_node.

Prototype

AWS_STATIC_IMPL void aws_linked_list_push_back(struct aws_linked_list *list, struct aws_linked_list_node *node);
source
LibAwsCommon.aws_linked_list_push_frontMethod
aws_linked_list_push_front(list, node)

Prepend new_node.

Prototype

AWS_STATIC_IMPL void aws_linked_list_push_front(struct aws_linked_list *list, struct aws_linked_list_node *node);
source
LibAwsCommon.aws_linked_list_removeMethod
aws_linked_list_remove(node)

Removes the specified node from the list (prev/next point to each other) and returns the next node in the list.

Prototype

AWS_STATIC_IMPL void aws_linked_list_remove(struct aws_linked_list_node *node);
source
LibAwsCommon.aws_linked_list_rendMethod
aws_linked_list_rend(list)

Returns the pointer to one before the first element in the list. Used to end iterating the list in reverse.

Prototype

AWS_STATIC_IMPL const struct aws_linked_list_node *aws_linked_list_rend(const struct aws_linked_list *list);
source
LibAwsCommon.aws_linked_list_swap_contentsMethod
aws_linked_list_swap_contents(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL void aws_linked_list_swap_contents( struct aws_linked_list *AWS_RESTRICT a, struct aws_linked_list *AWS_RESTRICT b);
source
LibAwsCommon.aws_linked_list_swap_nodesMethod
aws_linked_list_swap_nodes(a, b)

Swaps the order two nodes in the linked list.

Prototype

AWS_STATIC_IMPL void aws_linked_list_swap_nodes(struct aws_linked_list_node *a, struct aws_linked_list_node *b);
source
LibAwsCommon.aws_localtimeMethod
aws_localtime(time, t)

Cross platform friendly version of localtime_r

Prototype

void aws_localtime(time_t time, struct tm *t);
source
LibAwsCommon.aws_log_channel_init_backgroundMethod
aws_log_channel_init_background(channel, allocator, writer)

Simple channel that sends log lines to a background thread.

The passed in log writer is not an ownership transfer. The log channel does not clean up the writer.

Prototype

int aws_log_channel_init_background( struct aws_log_channel *channel, struct aws_allocator *allocator, struct aws_log_writer *writer);
source
LibAwsCommon.aws_log_channel_init_foregroundMethod
aws_log_channel_init_foreground(channel, allocator, writer)

Simple channel that results in log lines being written in the same thread they were generated in.

The passed in log writer is not an ownership transfer. The log channel does not clean up the writer.

Prototype

int aws_log_channel_init_foreground( struct aws_log_channel *channel, struct aws_allocator *allocator, struct aws_log_writer *writer);
source
LibAwsCommon.aws_log_formatter_clean_upMethod
aws_log_formatter_clean_up(formatter)

Cleans up a log formatter (minus the base structure memory) by calling the formatter's clean_up function via the vtable.

Prototype

void aws_log_formatter_clean_up(struct aws_log_formatter *formatter);
source
LibAwsCommon.aws_log_formatter_init_defaultMethod
aws_log_formatter_init_default(formatter, allocator, options)

Initializes the default log formatter which outputs lines in the format:

[<LogLevel>] [<Timestamp>] [<ThreadId>] - <User content>

Prototype

int aws_log_formatter_init_default( struct aws_log_formatter *formatter, struct aws_allocator *allocator, struct aws_log_formatter_standard_options *options);
source
LibAwsCommon.aws_log_level_to_stringMethod
aws_log_level_to_string(log_level, level_string)

Converts a log level to a c-string constant. Intended primarily to support building log lines that include the level in them, i.e.

[ERROR] 10:34:54.642 01-31-19 - Json parse error....

Prototype

int aws_log_level_to_string(enum aws_log_level log_level, const char **level_string);
source
LibAwsCommon.aws_log_writer_clean_upMethod
aws_log_writer_clean_up(writer)

Frees all resources used by a log writer with the exception of the base structure memory

Prototype

void aws_log_writer_clean_up(struct aws_log_writer *writer);
source
LibAwsCommon.aws_log_writer_init_fileMethod
aws_log_writer_init_file(writer, allocator, options)

Initialize a log writer that sends log lines to a file. Uses C library IO.

Prototype

int aws_log_writer_init_file( struct aws_log_writer *writer, struct aws_allocator *allocator, struct aws_log_writer_file_options *options);
source
LibAwsCommon.aws_log_writer_init_stderrMethod
aws_log_writer_init_stderr(writer, allocator)

Initialize a log writer that sends log lines to stderr. Uses C library IO.

Prototype

int aws_log_writer_init_stderr(struct aws_log_writer *writer, struct aws_allocator *allocator);
source
LibAwsCommon.aws_log_writer_init_stdoutMethod
aws_log_writer_init_stdout(writer, allocator)

Initialize a log writer that sends log lines to stdout. Uses C library IO.

Prototype

int aws_log_writer_init_stdout(struct aws_log_writer *writer, struct aws_allocator *allocator);
source
LibAwsCommon.aws_logger_clean_upMethod
aws_logger_clean_up(logger)

Cleans up all resources used by the logger; simply invokes the clean_up v-function

Prototype

void aws_logger_clean_up(struct aws_logger *logger);
source
LibAwsCommon.aws_logger_get_conditionalMethod
aws_logger_get_conditional(subject, level)

Gets the aws logger used globally across the process if the logging level is at least the inputted level.

Arguments

  • subject: log subject to perform the level check versus, not currently used
  • level: logging level to check against in order to return the logger

Returns

the current logger if the current logging level is at or more detailed then the supplied logging level

Prototype

struct aws_logger *aws_logger_get_conditional(aws_log_subject_t subject, enum aws_log_level level);
source
LibAwsCommon.aws_logger_init_from_externalMethod
aws_logger_init_from_external(logger, allocator, formatter, channel, writer, level)

Initializes a pipeline logger from components that have already been initialized. This is not an ownership transfer. After the pipeline logger is cleaned up, the components will have to manually be cleaned up by the user.

Prototype

int aws_logger_init_from_external( struct aws_logger *logger, struct aws_allocator *allocator, struct aws_log_formatter *formatter, struct aws_log_channel *channel, struct aws_log_writer *writer, enum aws_log_level level);
source
LibAwsCommon.aws_logger_init_noallocMethod
aws_logger_init_noalloc(logger, allocator, options)

Initializes a logger that does not perform any allocation during logging. Log lines larger than the internal constant are truncated. Formatting matches the standard logger. Used for memory tracing logging. If no file or filename is set in the aws_logger_standard_options, then it will use stderr.

Prototype

int aws_logger_init_noalloc( struct aws_logger *logger, struct aws_allocator *allocator, struct aws_logger_standard_options *options);
source
LibAwsCommon.aws_logger_init_standardMethod
aws_logger_init_standard(logger, allocator, options)

Initializes a pipeline logger that is built from the default formatter, a background thread-based channel, and a file writer. The default logger in almost all circumstances.

Prototype

int aws_logger_init_standard( struct aws_logger *logger, struct aws_allocator *allocator, struct aws_logger_standard_options *options);
source
LibAwsCommon.aws_logger_setMethod
aws_logger_set(logger)

Sets the aws logger used globally across the process. Not thread-safe. Must only be called once.

Prototype

void aws_logger_set(struct aws_logger *logger);
source
LibAwsCommon.aws_logger_set_log_levelMethod
aws_logger_set_log_level(logger, level)

Sets the current logging level for the logger. Loggers are not require to support this.

Arguments

  • logger: logger to set the log level for
  • level: new log level for the logger

Returns

AWS_OP_SUCCESS if the level was successfully set, AWS_OP_ERR otherwise

Prototype

int aws_logger_set_log_level(struct aws_logger *logger, enum aws_log_level level);
source
LibAwsCommon.aws_lookup_table_hex_to_num_getMethod
aws_lookup_table_hex_to_num_get()

Returns lookup table to go from ASCII/UTF-8 hex character to a number (0-15). Non-hex characters map to 255. Valid examples: '0' -> 0 'F' -> 15 'f' -> 15 Invalid examples: ' ' -> 255 'Z' -> 255 '\0' -> 255

Prototype

const uint8_t *aws_lookup_table_hex_to_num_get(void);
source
LibAwsCommon.aws_lookup_table_to_lower_getMethod
aws_lookup_table_to_lower_get()

Returns a lookup table for bytes that is the identity transformation with the exception of uppercase ascii characters getting replaced with lowercase characters. Used in caseless comparisons.

Prototype

const uint8_t *aws_lookup_table_to_lower_get(void);
source
LibAwsCommon.aws_lru_cache_use_lru_elementMethod
aws_lru_cache_use_lru_element(cache)

Accesses the least-recently-used element, sets it to most-recently-used element, and returns the value.

Prototype

void *aws_lru_cache_use_lru_element(struct aws_cache *cache);
source
LibAwsCommon.aws_max_u16Method
aws_max_u16(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL uint16_t aws_max_u16(uint16_t a, uint16_t b);
source
LibAwsCommon.aws_max_u32Method
aws_max_u32(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL uint32_t aws_max_u32(uint32_t a, uint32_t b);
source
LibAwsCommon.aws_max_u64Method
aws_max_u64(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL uint64_t aws_max_u64(uint64_t a, uint64_t b);
source
LibAwsCommon.aws_max_u8Method
aws_max_u8(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL uint8_t aws_max_u8(uint8_t a, uint8_t b);
source
LibAwsCommon.aws_mem_acquireMethod
aws_mem_acquire(allocator, size)

Returns at least size of memory ready for usage. In versions v0.6.8 and prior, this function was allowed to return NULL. In later versions, if allocator->mem_acquire() returns NULL, this function will assert and exit. To handle conditions where OOM is not a fatal error, allocator->mem_acquire() is responsible for finding/reclaiming/running a GC etc...before returning.

Prototype

void *aws_mem_acquire(struct aws_allocator *allocator, size_t size);
source
LibAwsCommon.aws_mem_callocMethod
aws_mem_calloc(allocator, num, size)

Allocates a block of memory for an array of num elements, each of them size bytes long, and initializes all its bits to zero. In versions v0.6.8 and prior, this function was allowed to return NULL. In later versions, if allocator->mem_calloc() returns NULL, this function will assert and exit. To handle conditions where OOM is not a fatal error, allocator->mem_calloc() is responsible for finding/reclaiming/running a GC etc...before returning.

Prototype

void *aws_mem_calloc(struct aws_allocator *allocator, size_t num, size_t size);
source
LibAwsCommon.aws_mem_reallocMethod
aws_mem_realloc(allocator, ptr, oldsize, newsize)

Attempts to adjust the size of the pointed-to memory buffer from oldsize to newsize. The pointer (*ptr) may be changed if the memory needs to be reallocated.

In versions v0.6.8 and prior, this function was allowed to return NULL. In later versions, if allocator->mem_realloc() returns NULL, this function will assert and exit. To handle conditions where OOM is not a fatal error, allocator->mem_realloc() is responsible for finding/reclaiming/running a GC etc...before returning.

Prototype

int aws_mem_realloc(struct aws_allocator *allocator, void **ptr, size_t oldsize, size_t newsize);
source
LibAwsCommon.aws_mem_releaseMethod
aws_mem_release(allocator, ptr)

Releases ptr back to whatever allocated it. Nothing happens if ptr is NULL.

Prototype

void aws_mem_release(struct aws_allocator *allocator, void *ptr);
source
LibAwsCommon.aws_mem_tracer_bytesMethod
aws_mem_tracer_bytes(trace_allocator)

Returns the current number of bytes in outstanding allocations

Prototype

size_t aws_mem_tracer_bytes(struct aws_allocator *trace_allocator);
source
LibAwsCommon.aws_mem_tracer_countMethod
aws_mem_tracer_count(trace_allocator)

Returns the current number of outstanding allocations

Prototype

size_t aws_mem_tracer_count(struct aws_allocator *trace_allocator);
source
LibAwsCommon.aws_mem_tracer_destroyMethod
aws_mem_tracer_destroy(trace_allocator)

Unwraps the traced allocator and cleans up the tracer. Returns the original allocator

Prototype

struct aws_allocator *aws_mem_tracer_destroy(struct aws_allocator *trace_allocator);
source
LibAwsCommon.aws_mem_tracer_dumpMethod
aws_mem_tracer_dump(trace_allocator)

If there are outstanding allocations, dumps them to log, along with any information gathered based on the trace level set when aws_mem_trace() was called. Should be passed the tracer allocator returned from aws_mem_trace().

Prototype

void aws_mem_tracer_dump(struct aws_allocator *trace_allocator);
source
LibAwsCommon.aws_mem_tracer_newMethod
aws_mem_tracer_new(allocator, deprecated, level, frames_per_stack)

Wraps an allocator and tracks all external allocations. If aws_mem_trace_dump() is called and there are still allocations active, they will be reported to the aws_logger at TRACE level. allocator - The allocator to wrap deprecated - Deprecated arg, ignored. level - The level to track allocations at frames_per_stack is how many frames to store per callstack if AWS_MEMTRACE_STACKS is in use, otherwise it is ignored. 8 tends to be a pretty good number balancing storage space vs useful stacks. Returns the tracer allocator, which should be used for all allocations that should be tracked.

Prototype

struct aws_allocator *aws_mem_tracer_new( struct aws_allocator *allocator, struct aws_allocator *deprecated, enum aws_mem_trace_level level, size_t frames_per_stack);
source
LibAwsCommon.aws_min_u16Method
aws_min_u16(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL uint16_t aws_min_u16(uint16_t a, uint16_t b);
source
LibAwsCommon.aws_min_u32Method
aws_min_u32(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL uint32_t aws_min_u32(uint32_t a, uint32_t b);
source
LibAwsCommon.aws_min_u64Method
aws_min_u64(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL uint64_t aws_min_u64(uint64_t a, uint64_t b);
source
LibAwsCommon.aws_min_u8Method
aws_min_u8(a, b)

Documentation not found.

Prototype

AWS_STATIC_IMPL uint8_t aws_min_u8(uint8_t a, uint8_t b);
source
LibAwsCommon.aws_mul_size_saturatingMethod
aws_mul_size_saturating(a, b)

Multiplies a * b. If the result overflows, returns SIZE_MAX.

Prototype

AWS_STATIC_IMPL size_t aws_mul_size_saturating(size_t a, size_t b);
source
LibAwsCommon.aws_mul_u32_saturatingMethod
aws_mul_u32_saturating(a, b)

Multiplies a * b. If the result overflows, returns 2^32 - 1.

Prototype

AWS_STATIC_IMPL uint32_t aws_mul_u32_saturating(uint32_t a, uint32_t b);
source
LibAwsCommon.aws_mul_u64_saturatingMethod
aws_mul_u64_saturating(a, b)

Multiplies a * b. If the result overflows, returns 2^64 - 1.

Prototype

AWS_STATIC_IMPL uint64_t aws_mul_u64_saturating(uint64_t a, uint64_t b);
source
LibAwsCommon.aws_mutex_lockMethod
aws_mutex_lock(mutex)

Blocks until it acquires the lock. While on some platforms such as Windows, this may behave as a reentrant mutex, you should not treat it like one. On platforms it is possible for it to be non-reentrant, it will be.

Prototype

int aws_mutex_lock(struct aws_mutex *mutex);
source
LibAwsCommon.aws_mutex_try_lockMethod
aws_mutex_try_lock(mutex)

Attempts to acquire the lock but returns immediately if it can not. While on some platforms such as Windows, this may behave as a reentrant mutex, you should not treat it like one. On platforms it is possible for it to be non-reentrant, it will be. Note: For windows, minimum support server version is Windows Server 2008 R2 [desktop apps | UWP apps]

Prototype

int aws_mutex_try_lock(struct aws_mutex *mutex);
source
LibAwsCommon.aws_normalize_directory_separatorMethod
aws_normalize_directory_separator(path)

Normalizes the path by replacing any directory separator with the local platform's directory separator.

Arguments

  • path: path to normalize. Must be writeable.

Prototype

void aws_normalize_directory_separator(struct aws_byte_buf *path);
source
LibAwsCommon.aws_ntoh16Method
aws_ntoh16(x)

Convert 16 bit integer from network to host byte order.

Prototype

AWS_STATIC_IMPL uint16_t aws_ntoh16(uint16_t x);
source
LibAwsCommon.aws_ntoh32Method
aws_ntoh32(x)

Convert 32 bit integer from network to host byte order.

Prototype

AWS_STATIC_IMPL uint32_t aws_ntoh32(uint32_t x);
source
LibAwsCommon.aws_ntoh64Method
aws_ntoh64(x)

Convert 64 bit integer from network to host byte order.

Prototype

AWS_STATIC_IMPL uint64_t aws_ntoh64(uint64_t x);
source
LibAwsCommon.aws_ntohf32Method
aws_ntohf32(x)

Convert 32 bit float from network to host byte order.

Prototype

AWS_STATIC_IMPL float aws_ntohf32(float x);
source
LibAwsCommon.aws_ntohf64Method
aws_ntohf64(x)

Convert 32 bit float from network to host byte order.

Prototype

AWS_STATIC_IMPL double aws_ntohf64(double x);
source
LibAwsCommon.aws_path_existsMethod
aws_path_exists(path)

Returns true if a file or path exists, otherwise, false.

Prototype

bool aws_path_exists(const struct aws_string *path);
source
LibAwsCommon.aws_priority_queue_backpointers_validMethod
aws_priority_queue_backpointers_valid(queue)

Checks that the backpointers of the priority queue satisfy validity constraints.

Prototype

bool aws_priority_queue_backpointers_valid(const struct aws_priority_queue *const queue);
source
LibAwsCommon.aws_priority_queue_backpointers_valid_deepMethod
aws_priority_queue_backpointers_valid_deep(queue)

Checks that the backpointers of the priority queue are either NULL or correctly allocated to point at aws_priority_queue_nodes. This check is O(n), as it accesses every backpointer in a loop, and thus shouldn't be used carelessly.

Prototype

bool aws_priority_queue_backpointers_valid_deep(const struct aws_priority_queue *const queue);
source
LibAwsCommon.aws_priority_queue_capacityMethod
aws_priority_queue_capacity(queue)

Current allocated capacity for the queue, in dynamic mode this grows over time, in static mode, this will never change.

Prototype

size_t aws_priority_queue_capacity(const struct aws_priority_queue *queue);
source
LibAwsCommon.aws_priority_queue_clean_upMethod
aws_priority_queue_clean_up(queue)

Cleans up any internally allocated memory and resets the struct for reuse or deletion.

Prototype

void aws_priority_queue_clean_up(struct aws_priority_queue *queue);
source
LibAwsCommon.aws_priority_queue_clearMethod
aws_priority_queue_clear(queue)

Removes all elements from the queue, but does not free internal memory.

Prototype

void aws_priority_queue_clear(struct aws_priority_queue *queue);
source
LibAwsCommon.aws_priority_queue_init_dynamicMethod
aws_priority_queue_init_dynamic(queue, alloc, default_size, item_size, pred)

Initializes a priority queue struct for use. This mode will grow memory automatically (exponential model) Default size is the inital size of the queue item_size is the size of each element in bytes. Mixing items types is not supported by this API. pred is the function that will be used to determine priority.

Prototype

int aws_priority_queue_init_dynamic( struct aws_priority_queue *queue, struct aws_allocator *alloc, size_t default_size, size_t item_size, aws_priority_queue_compare_fn *pred);
source
LibAwsCommon.aws_priority_queue_init_staticMethod
aws_priority_queue_init_static(queue, heap, item_count, item_size, pred)

Initializes a priority queue struct for use. This mode will not allocate any additional memory. When the heap fills new enqueue operations will fail with AWS_ERROR_PRIORITY_QUEUE_FULL.

Heaps initialized using this call do not support the aws_priority_queue_push_ref call with a non-NULL backpointer parameter.

heap is the raw memory allocated for this priority_queue item_count is the maximum number of elements the raw heap can contain item_size is the size of each element in bytes. Mixing items types is not supported by this API. pred is the function that will be used to determine priority.

Prototype

void aws_priority_queue_init_static( struct aws_priority_queue *queue, void *heap, size_t item_count, size_t item_size, aws_priority_queue_compare_fn *pred);
source
LibAwsCommon.aws_priority_queue_node_initMethod
aws_priority_queue_node_init(node)

Initializes a queue node to a default value that indicates the node is not in the queue.

Arguments

  • node: priority queue node to initialize with a default value

Prototype

void aws_priority_queue_node_init(struct aws_priority_queue_node *node);
source
LibAwsCommon.aws_priority_queue_node_is_in_queueMethod
aws_priority_queue_node_is_in_queue(node)

Checks if a priority queue node is currently in a priority queue.

Arguments

  • node: priority queue node to check usage for

Returns

true if the node is in a queue, false otherwise

Prototype

bool aws_priority_queue_node_is_in_queue(const struct aws_priority_queue_node *node);
source
LibAwsCommon.aws_priority_queue_popMethod
aws_priority_queue_pop(queue, item)

Copies the element of the highest priority, and removes it from the queue.. Complexity: O(log(n)). If queue is empty, AWS_ERROR_PRIORITY_QUEUE_EMPTY will be raised.

Prototype

int aws_priority_queue_pop(struct aws_priority_queue *queue, void *item);
source
LibAwsCommon.aws_priority_queue_pushMethod
aws_priority_queue_push(queue, item)

Copies item into the queue and places it in the proper priority order. Complexity: O(log(n)).

Prototype

int aws_priority_queue_push(struct aws_priority_queue *queue, void *item);
source
LibAwsCommon.aws_priority_queue_push_refMethod
aws_priority_queue_push_ref(queue, item, backpointer)

Copies item into the queue and places it in the proper priority order. Complexity: O(log(n)).

If the backpointer parameter is non-null, the heap will continually update the pointed-to field with information needed to remove the node later on. *backpointer must remain valid until the node is removed from the heap, and may be updated on any mutating operation on the priority queue.

If the node is removed, the backpointer will be set to a sentinel value that indicates that the node has already been removed. It is safe (and a no-op) to call aws_priority_queue_remove with such a sentinel value.

Prototype

int aws_priority_queue_push_ref( struct aws_priority_queue *queue, void *item, struct aws_priority_queue_node *backpointer);
source
LibAwsCommon.aws_priority_queue_removeMethod
aws_priority_queue_remove(queue, item, node)

Removes a specific node from the priority queue. Complexity: O(log(n)) After removing a node (using either _remove or _pop), the backpointer set at push_ref time is set to a sentinel value. If this sentinel value is passed to aws_priority_queue_remove, AWS_ERROR_PRIORITY_QUEUE_BAD_NODE will be raised. Note, however, that passing uninitialized aws_priority_queue_nodes, or ones from different priority queues, results in undefined behavior.

Prototype

int aws_priority_queue_remove(struct aws_priority_queue *queue, void *item, const struct aws_priority_queue_node *node);
source
LibAwsCommon.aws_priority_queue_topMethod
aws_priority_queue_top(queue, item)

Obtains a pointer to the element of the highest priority. Complexity: constant time. If queue is empty, AWS_ERROR_PRIORITY_QUEUE_EMPTY will be raised.

Prototype

int aws_priority_queue_top(const struct aws_priority_queue *queue, void **item);
source
LibAwsCommon.aws_promise_acquireMethod
aws_promise_acquire(promise)

Indicate a new reference to a promise. At minimum, each new thread making use of the promise should acquire it.

Prototype

struct aws_promise *aws_promise_acquire(struct aws_promise *promise);
source
LibAwsCommon.aws_promise_completeMethod
aws_promise_complete(promise, value, dtor)

Completes the promise and stores the result along with an optional destructor. If the value is not taken via aws_promise_take_value, it will be destroyed when the promise's reference count reaches zero. NOTE: Promise cannot be completed twice

Prototype

void aws_promise_complete(struct aws_promise *promise, void *value, void (*dtor)(void *));
source
LibAwsCommon.aws_promise_error_codeMethod
aws_promise_error_code(promise)

Returns the error code recorded if the promise failed, or 0 if it succeeded NOTE: It is fatal to attempt to retrieve the error code before the promise is completed

Prototype

int aws_promise_error_code(struct aws_promise *promise);
source
LibAwsCommon.aws_promise_failMethod
aws_promise_fail(promise, error_code)

Completes the promise and stores the error code NOTE: Promise cannot be completed twice

Prototype

void aws_promise_fail(struct aws_promise *promise, int error_code);
source
LibAwsCommon.aws_promise_is_completeMethod
aws_promise_is_complete(promise)

Returns whether or not the promise has completed (regardless of success or failure)

Prototype

bool aws_promise_is_complete(struct aws_promise *promise);
source
LibAwsCommon.aws_promise_newMethod
aws_promise_new(allocator)

Creates a new promise

Prototype

struct aws_promise *aws_promise_new(struct aws_allocator *allocator);
source
LibAwsCommon.aws_promise_releaseMethod
aws_promise_release(promise)

Releases a reference on the promise. When the refcount hits 0, the promise is cleaned up and freed.

Prototype

void aws_promise_release(struct aws_promise *promise);
source
LibAwsCommon.aws_promise_take_valueMethod
aws_promise_take_value(promise)

Returns the value provided to the promise if it succeeded, or NULL if none was provided or the promise failed. Check aws_promise_error_code to be sure. NOTE: The promise relinquishes ownership of the value, the caller is now responsible for freeing any resources associated with the value NOTE: It is fatal to attempt to take the value before the promise is completed

Prototype

void *aws_promise_take_value(struct aws_promise *promise);
source
LibAwsCommon.aws_promise_valueMethod
aws_promise_value(promise)

Returns the value provided to the promise if it succeeded, or NULL if none was provided or the promise failed. Check aws_promise_error_code to be sure. NOTE: The ownership of the value is retained by the promise. NOTE: It is fatal to attempt to retrieve the value before the promise is completed

Prototype

void *aws_promise_value(struct aws_promise *promise);
source
LibAwsCommon.aws_promise_waitMethod
aws_promise_wait(promise)

Waits infinitely for the promise to be completed

Prototype

void aws_promise_wait(struct aws_promise *promise);
source
LibAwsCommon.aws_promise_wait_forMethod
aws_promise_wait_for(promise, nanoseconds)

Waits for the requested time in nanoseconds. Returns true if the promise was completed.

Prototype

bool aws_promise_wait_for(struct aws_promise *promise, size_t nanoseconds);
source
LibAwsCommon.aws_ptr_eqMethod
aws_ptr_eq(a, b)

Equality function which compares pointer equality.

Prototype

bool aws_ptr_eq(const void *a, const void *b);
source
LibAwsCommon.aws_query_string_next_paramMethod
aws_query_string_next_param(query_string, param)

For iterating over the params in the query string. param is an in/out argument used to track progress, it MUST be zeroed out to start. If true is returned, param contains the value of the next param. If false is returned, there are no further params.

Edge cases: 1) Entries without '=' sign are treated as having a key and no value. Example: First param in query string "a&b=c" has key="a" value=""

  1. Blank entries are skipped. Example: The only param in query string "&&a=b" is key="a" value="b"

Prototype

bool aws_query_string_next_param(struct aws_byte_cursor query_string, struct aws_uri_param *param);
source
LibAwsCommon.aws_query_string_paramsMethod
aws_query_string_params(query_string, out_params)

Parses query string and stores the parameters in 'out_params'. Returns AWS_OP_SUCCESS on success and AWS_OP_ERR on failure. The user is responsible for initializing out_params with item size of struct aws_query_param. The user is also responsible for cleaning up out_params when finished.

Prototype

int aws_query_string_params(struct aws_byte_cursor query_string, struct aws_array_list *out_params);
source
LibAwsCommon.aws_raise_errorMethod
aws_raise_error(err)

Raises err to the installed callbacks, and sets the thread's error.

Prototype

AWS_STATIC_IMPL int aws_raise_error(int err);
source
LibAwsCommon.aws_read_u16Method
aws_read_u16(buffer)

Extracts a 16 bit unsigned integer from buffer. Ensures conversion from network byte order to host byte order. Assumes buffer is at least 2 bytes long.

Prototype

AWS_STATIC_IMPL uint16_t aws_read_u16(const uint8_t *buffer);
source
LibAwsCommon.aws_read_u24Method
aws_read_u24(buffer)

Extracts a 24 bit unsigned integer from buffer. Ensures conversion from network byte order to host byte order. Assumes buffer is at least 3 bytes long.

Prototype

AWS_STATIC_IMPL uint32_t aws_read_u24(const uint8_t *buffer);
source
LibAwsCommon.aws_read_u32Method
aws_read_u32(buffer)

Extracts a 32 bit unsigned integer from buffer. Ensures conversion from network byte order to host byte order. Assumes the buffer size is at least 4 bytes.

Prototype

AWS_STATIC_IMPL uint32_t aws_read_u32(const uint8_t *buffer);
source
LibAwsCommon.aws_read_u64Method
aws_read_u64(buffer)

Extracts a 64 bit unsigned integer from buffer. Ensures conversion from network byte order to host byte order. Assumes buffer size is at least 8 bytes.

Prototype

AWS_STATIC_IMPL uint64_t aws_read_u64(const uint8_t *buffer);
source
LibAwsCommon.aws_ref_count_acquireMethod
aws_ref_count_acquire(ref_count)

Increments a ref-counter's ref count

Arguments

  • ref_count: ref-counter to increment the count for

Returns

the object being ref-counted

Prototype

void *aws_ref_count_acquire(struct aws_ref_count *ref_count);
source
LibAwsCommon.aws_ref_count_initMethod
aws_ref_count_init(ref_count, object, on_zero_fn)

Initializes a ref-counter structure. After initialization, the ref count will be 1.

Arguments

  • ref_count: ref-counter to initialize
  • object: object being ref counted
  • on_zero_fn: function to invoke when the ref count reaches zero

Prototype

void aws_ref_count_init( struct aws_ref_count *ref_count, void *object, aws_simple_completion_callback *on_zero_fn);
source
LibAwsCommon.aws_ref_count_releaseMethod
aws_ref_count_release(ref_count)

Decrements a ref-counter's ref count. Invokes the on_zero callback if the ref count drops to zero

Arguments

  • ref_count: ref-counter to decrement the count for

Returns

the value of the decremented ref count

Prototype

size_t aws_ref_count_release(struct aws_ref_count *ref_count);
source
LibAwsCommon.aws_register_error_infoMethod
aws_register_error_info(error_info)

TODO: this needs to be a private function (wait till we have the cmake story better before moving it though). It should be external for the purpose of other libs we own, but customers should not be able to hit it without going out of their way to do so.

Prototype

void aws_register_error_info(const struct aws_error_info_list *error_info);
source
LibAwsCommon.aws_register_log_subject_info_listMethod
aws_register_log_subject_info_list(log_subject_list)

Connects log subject strings with log subject integer values

Prototype

void aws_register_log_subject_info_list(struct aws_log_subject_info_list *log_subject_list);
source
LibAwsCommon.aws_ring_buffer_acquireMethod
aws_ring_buffer_acquire(ring_buf, requested_size, dest)

Attempts to acquire requested_size buffer and stores the result in dest if successful. Returns AWS_OP_SUCCESS if the requested size was available for use, AWS_OP_ERR otherwise.

Prototype

int aws_ring_buffer_acquire( struct aws_ring_buffer *ring_buf, size_t requested_size, struct aws_byte_buf *dest);
source
LibAwsCommon.aws_ring_buffer_acquire_up_toMethod
aws_ring_buffer_acquire_up_to(ring_buf, minimum_size, requested_size, dest)

Attempts to acquire requested_size buffer and stores the result in dest if successful. If not available, it will attempt to acquire anywhere from 1 byte to requested_size. Returns AWS_OP_SUCCESS if some buffer space is available for use, AWS_OP_ERR otherwise.

Prototype

int aws_ring_buffer_acquire_up_to( struct aws_ring_buffer *ring_buf, size_t minimum_size, size_t requested_size, struct aws_byte_buf *dest);
source
LibAwsCommon.aws_ring_buffer_buf_belongs_to_poolMethod
aws_ring_buffer_buf_belongs_to_pool(ring_buffer, buf)

Returns true if the memory in buf was vended by this ring buffer, false otherwise. Make sure buf->buffer and ring\_buffer->allocation refer to the same memory region.

Prototype

bool aws_ring_buffer_buf_belongs_to_pool( const struct aws_ring_buffer *ring_buffer, const struct aws_byte_buf *buf);
source
LibAwsCommon.aws_ring_buffer_check_atomic_ptrMethod
aws_ring_buffer_check_atomic_ptr(ring_buf, atomic_ptr)

Checks whether atomic_ptr correctly points to a memory location within the bounds of the aws_ring_buffer

Prototype

AWS_STATIC_IMPL bool aws_ring_buffer_check_atomic_ptr( const struct aws_ring_buffer *ring_buf, const uint8_t *atomic_ptr);
source
LibAwsCommon.aws_ring_buffer_initMethod
aws_ring_buffer_init(ring_buf, allocator, size)

Initializes a ring buffer with an allocation of size size. Returns AWS_OP_SUCCESS on a successful initialization, AWS_OP_ERR otherwise.

Prototype

int aws_ring_buffer_init(struct aws_ring_buffer *ring_buf, struct aws_allocator *allocator, size_t size);
source
LibAwsCommon.aws_ring_buffer_is_emptyMethod
aws_ring_buffer_is_empty(ring_buf)

Checks whether the ring buffer is empty

Prototype

AWS_STATIC_IMPL bool aws_ring_buffer_is_empty(const struct aws_ring_buffer *ring_buf);
source
LibAwsCommon.aws_ring_buffer_is_validMethod
aws_ring_buffer_is_valid(ring_buf)

Evaluates the set of properties that define the shape of all valid aws_ring_buffer structures. It is also a cheap check, in the sense it run in constant time (i.e., no loops or recursion).

Prototype

AWS_STATIC_IMPL bool aws_ring_buffer_is_valid(const struct aws_ring_buffer *ring_buf);
source
LibAwsCommon.aws_ring_buffer_releaseMethod
aws_ring_buffer_release(ring_buffer, buf)

Releases buf back to the ring buffer for further use. RELEASE MUST HAPPEN in the SAME ORDER AS ACQUIRE. If you do not, your application, and possibly computers within a thousand mile radius, may die terrible deaths, and the local drinking water will be poisoned for generations with fragments of what is left of your radioactive corrupted memory.

Prototype

void aws_ring_buffer_release(struct aws_ring_buffer *ring_buffer, struct aws_byte_buf *buf);
source
LibAwsCommon.aws_round_up_to_power_of_twoMethod
aws_round_up_to_power_of_two(n, result)

Function to find the smallest result that is power of 2 >= n. Returns AWS_OP_ERR if this cannot be done without overflow

Prototype

AWS_STATIC_IMPL int aws_round_up_to_power_of_two(size_t n, size_t *result);
source
LibAwsCommon.aws_run_commandMethod
aws_run_command(allocator, options, result)

Currently this API is implemented using popen on Posix system and _popen on Windows to capture output from running a command. Note that popen only captures stdout, and doesn't provide an option to capture stderr. We will add more options, such as acquire stderr in the future so probably will alter the underlying implementation as well.

Prototype

int aws_run_command( struct aws_allocator *allocator, struct aws_run_command_options *options, struct aws_run_command_result *result);
source
LibAwsCommon.aws_run_command_result_initMethod
aws_run_command_result_init(allocator, result)

Documentation not found.

Prototype

int aws_run_command_result_init(struct aws_allocator *allocator, struct aws_run_command_result *result);
source
LibAwsCommon.aws_rw_lock_rlockMethod
aws_rw_lock_rlock(lock)

Blocks until it acquires the lock. While on some platforms such as Windows, this may behave as a reentrant mutex, you should not treat it like one. On platforms it is possible for it to be non-reentrant, it will be.

Prototype

int aws_rw_lock_rlock(struct aws_rw_lock *lock);
source
LibAwsCommon.aws_rw_lock_try_rlockMethod
aws_rw_lock_try_rlock(lock)

Attempts to acquire the lock but returns immediately if it can not. While on some platforms such as Windows, this may behave as a reentrant mutex, you should not treat it like one. On platforms it is possible for it to be non-reentrant, it will be. Note: For windows, minimum support server version is Windows Server 2008 R2 [desktop apps | UWP apps]

Prototype

int aws_rw_lock_try_rlock(struct aws_rw_lock *lock);
source
LibAwsCommon.aws_secure_strlenMethod
aws_secure_strlen(str, max_read_len, str_len)

Computes the length of a c string in bytes assuming the character set is either ASCII or UTF-8. If no NULL character is found within max_read_len of str, AWS_ERROR_C_STRING_BUFFER_NOT_NULL_TERMINATED is raised. Otherwise, str_len will contain the string length minus the NULL character, and AWS_OP_SUCCESS will be returned.

Prototype

int aws_secure_strlen(const char *str, size_t max_read_len, size_t *str_len);
source
LibAwsCommon.aws_secure_zeroMethod
aws_secure_zero(pBuf, bufsize)

Securely zeroes a memory buffer. This function will attempt to ensure that the compiler will not optimize away this zeroing operation.

Prototype

void aws_secure_zero(void *pBuf, size_t bufsize);
source
LibAwsCommon.aws_set_environment_valueMethod
aws_set_environment_value(variable_name, value)

Set the value of an environment variable. On Windows, setting a variable to the empty string will actually unset it. Not thread-safe

Prototype

int aws_set_environment_value(const struct aws_string *variable_name, const struct aws_string *value);
source
LibAwsCommon.aws_set_global_error_handler_fnMethod
aws_set_global_error_handler_fn(handler, ctx)

Sets an application wide error handler function. This will be overridden by the thread local handler. The previous handler is returned, this can be used for restoring an error handler if it needs to be overridden temporarily. Setting this to NULL will turn off this error callback after it has been enabled.

Prototype

aws_error_handler_fn *aws_set_global_error_handler_fn(aws_error_handler_fn *handler, void *ctx);
source
LibAwsCommon.aws_set_soft_limit_io_handlesMethod
aws_set_soft_limit_io_handles(max_handles)

Sets the new soft limit for io_handles (max fds). This can be up to the hard limit but may not exceed it.

This operation will always fail with AWS_ERROR_UNIMPLEMENTED error code on Windows.

Prototype

int aws_set_soft_limit_io_handles(size_t max_handles);
source
LibAwsCommon.aws_set_thread_local_error_handler_fnMethod
aws_set_thread_local_error_handler_fn(handler, ctx)

Sets a thread-local error handler function. This will override the global handler. The previous handler is returned, this can be used for restoring an error handler if it needs to be overridden temporarily. Setting this to NULL will turn off this error callback after it has been enabled.

Prototype

aws_error_handler_fn *aws_set_thread_local_error_handler_fn(aws_error_handler_fn *handler, void *ctx);
source
LibAwsCommon.aws_small_block_allocator_bytes_reservedMethod
aws_small_block_allocator_bytes_reserved(sba_allocator)

Returns the number of bytes reserved in pages/bins inside the SBA, e.g. the current system memory used by the SBA

Prototype

size_t aws_small_block_allocator_bytes_reserved(struct aws_allocator *sba_allocator);
source
LibAwsCommon.aws_small_block_allocator_destroyMethod
aws_small_block_allocator_destroy(sba_allocator)

Destroys a Small Block Allocator instance and frees its memory to the parent allocator. The parent allocator will otherwise be unaffected.

Prototype

void aws_small_block_allocator_destroy(struct aws_allocator *sba_allocator);
source
LibAwsCommon.aws_small_block_allocator_newMethod
aws_small_block_allocator_new(allocator, multi_threaded)

Creates a new Small Block Allocator which fronts the supplied parent allocator. The SBA will intercept and handle small allocs, and will forward anything larger to the parent allocator. If multi_threaded is true, the internal allocator will protect its internal data structures with a mutex

Prototype

struct aws_allocator *aws_small_block_allocator_new(struct aws_allocator *allocator, bool multi_threaded);
source
LibAwsCommon.aws_string_bytesMethod
aws_string_bytes(str)

Equivalent to str->bytes.

Prototype

AWS_STATIC_IMPL const uint8_t *aws_string_bytes(const struct aws_string *str);
source
LibAwsCommon.aws_string_c_strMethod
aws_string_c_str(str)

Equivalent to (const char *)str->bytes.

Prototype

AWS_STATIC_IMPL const char *aws_string_c_str(const struct aws_string *str);
source
LibAwsCommon.aws_string_clone_or_reuseMethod
aws_string_clone_or_reuse(allocator, str)

If the string was dynamically allocated, clones it. If the string was statically allocated (i.e. has no allocator), returns the original string.

Prototype

struct aws_string *aws_string_clone_or_reuse(struct aws_allocator *allocator, const struct aws_string *str);
source
LibAwsCommon.aws_string_compareMethod
aws_string_compare(a, b)

Compares lexicographical ordering of two strings. This is a binary byte-by-byte comparison, treating bytes as unsigned integers. It is suitable for either textual or binary data and is unaware of unicode or any other byte encoding. If both strings are identical in the bytes of the shorter string, then the longer string is lexicographically after the shorter.

Returns a positive number if string a > string b. (i.e., string a is lexicographically after string b.) Returns zero if string a = string b. Returns negative number if string a < string b.

Prototype

int aws_string_compare(const struct aws_string *a, const struct aws_string *b);
source
LibAwsCommon.aws_string_destroy_secureMethod
aws_string_destroy_secure(str)

Zeroes out the data bytes of string and then deallocates the memory. Not safe to run on a string created with AWS_STATIC_STRING_FROM_LITERAL.

Prototype

void aws_string_destroy_secure(struct aws_string *str);
source
LibAwsCommon.aws_string_eqMethod
aws_string_eq(a, b)

Returns true if bytes of string are the same, false otherwise.

Prototype

bool aws_string_eq(const struct aws_string *a, const struct aws_string *b);
source
LibAwsCommon.aws_string_eq_byte_bufMethod
aws_string_eq_byte_buf(str, buf)

Returns true if bytes of string and buffer are the same, false otherwise.

Prototype

bool aws_string_eq_byte_buf(const struct aws_string *str, const struct aws_byte_buf *buf);
source
LibAwsCommon.aws_string_eq_byte_buf_ignore_caseMethod
aws_string_eq_byte_buf_ignore_case(str, buf)

Returns true if bytes of string and buffer are equivalent, using a case-insensitive comparison.

Prototype

bool aws_string_eq_byte_buf_ignore_case(const struct aws_string *str, const struct aws_byte_buf *buf);
source
LibAwsCommon.aws_string_eq_byte_cursorMethod
aws_string_eq_byte_cursor(str, cur)

Returns true if bytes of string and cursor are the same, false otherwise.

Prototype

bool aws_string_eq_byte_cursor(const struct aws_string *str, const struct aws_byte_cursor *cur);
source
LibAwsCommon.aws_string_eq_byte_cursor_ignore_caseMethod
aws_string_eq_byte_cursor_ignore_case(str, cur)

Returns true if bytes of string and cursor are equivalent, using a case-insensitive comparison.

Prototype

bool aws_string_eq_byte_cursor_ignore_case(const struct aws_string *str, const struct aws_byte_cursor *cur);
source
LibAwsCommon.aws_string_eq_c_str_ignore_caseMethod
aws_string_eq_c_str_ignore_case(str, c_str)

Returns true if bytes of strings are equivalent, using a case-insensitive comparison.

Prototype

bool aws_string_eq_c_str_ignore_case(const struct aws_string *str, const char *c_str);
source
LibAwsCommon.aws_string_eq_ignore_caseMethod
aws_string_eq_ignore_case(a, b)

Returns true if bytes of string are equivalent, using a case-insensitive comparison.

Prototype

bool aws_string_eq_ignore_case(const struct aws_string *a, const struct aws_string *b);
source
LibAwsCommon.aws_string_is_validMethod
aws_string_is_valid(str)

Evaluates the set of properties that define the shape of all valid aws_string structures. It is also a cheap check, in the sense it run in constant time (i.e., no loops or recursion).

Prototype

AWS_STATIC_IMPL bool aws_string_is_valid(const struct aws_string *str);
source
LibAwsCommon.aws_string_new_from_arrayMethod
aws_string_new_from_array(allocator, bytes, len)

Allocate a new string with the same contents as array.

Prototype

struct aws_string *aws_string_new_from_array(struct aws_allocator *allocator, const uint8_t *bytes, size_t len);
source
LibAwsCommon.aws_string_new_from_bufMethod
aws_string_new_from_buf(allocator, buf)

Allocate a new string with the same contents as buf.

Prototype

struct aws_string *aws_string_new_from_buf(struct aws_allocator *allocator, const struct aws_byte_buf *buf);
source
LibAwsCommon.aws_string_new_from_c_strMethod
aws_string_new_from_c_str(allocator, c_str)

Constructor functions which copy data from null-terminated C-string or array of bytes.

Prototype

struct aws_string *aws_string_new_from_c_str(struct aws_allocator *allocator, const char *c_str);
source
LibAwsCommon.aws_string_new_from_cursorMethod
aws_string_new_from_cursor(allocator, cursor)

Allocate a new string with the same contents as cursor.

Prototype

struct aws_string *aws_string_new_from_cursor(struct aws_allocator *allocator, const struct aws_byte_cursor *cursor);
source
LibAwsCommon.aws_string_new_from_stringMethod
aws_string_new_from_string(allocator, str)

Allocate a new string with the same contents as another string.

Prototype

struct aws_string *aws_string_new_from_string(struct aws_allocator *allocator, const struct aws_string *str);
source
LibAwsCommon.aws_string_to_log_levelMethod
aws_string_to_log_level(level_string, log_level)

Converts a c-string constant to a log level value. Uses case-insensitive comparison and simply iterates all possibilities until a match or nothing remains. If no match is found, AWS_OP_ERR is returned.

Prototype

int aws_string_to_log_level(const char *level_string, enum aws_log_level *log_level);
source
LibAwsCommon.aws_sub_u32_saturatingMethod
aws_sub_u32_saturating(a, b)

Subtracts a - b. If the result overflows returns 0.

Prototype

AWS_STATIC_IMPL uint32_t aws_sub_u32_saturating(uint32_t a, uint32_t b);
source
LibAwsCommon.aws_sub_u64_saturatingMethod
aws_sub_u64_saturating(a, b)

Subtracts a - b. If the result overflows returns 0.

Prototype

AWS_STATIC_IMPL uint64_t aws_sub_u64_saturating(uint64_t a, uint64_t b);
source
LibAwsCommon.aws_sys_clock_get_ticksMethod
aws_sys_clock_get_ticks(timestamp)

Get ticks in nanoseconds (usually 100 nanosecond precision) on the system clock. Reflects actual system time via nanoseconds since unix epoch. Use with care since an inaccurately set clock will probably cause bugs. On success, timestamp will be set.

Prototype

int aws_sys_clock_get_ticks(uint64_t *timestamp);
source
LibAwsCommon.aws_system_environment_get_virtualization_product_nameMethod
aws_system_environment_get_virtualization_product_name(env)

Returns the product name for the specified compute environment. For example, the Amazon EC2 Instance type.

The return value may be empty and in that case no vendor was detected.

Prototype

struct aws_byte_cursor aws_system_environment_get_virtualization_product_name(const struct aws_system_environment *env);
source
LibAwsCommon.aws_system_environment_get_virtualization_vendorMethod
aws_system_environment_get_virtualization_vendor(env)

Returns the virtualization vendor for the specified compute environment, e.g. "Xen, Amazon EC2, etc..."

The return value may be empty and in that case no vendor was detected.

Prototype

struct aws_byte_cursor aws_system_environment_get_virtualization_vendor(const struct aws_system_environment *env);
source
LibAwsCommon.aws_system_environment_loadMethod
aws_system_environment_load(allocator)

Allocates and initializes information about the system the current process is executing on. If successful returns an instance of aws_system_environment. If it fails, it will return NULL.

Note: This api is used internally and is still early in its evolution. It may change in incompatible ways in the future.

Prototype

struct aws_system_environment *aws_system_environment_load(struct aws_allocator *allocator);
source
LibAwsCommon.aws_task_runMethod
aws_task_run(task, status)

Runs or cancels a task

Prototype

void aws_task_run(struct aws_task *task, enum aws_task_status status);
source
LibAwsCommon.aws_task_scheduler_cancel_taskMethod
aws_task_scheduler_cancel_task(scheduler, task)

Removes task from the scheduler and invokes the task with the AWS_TASK_STATUS_CANCELED status.

Prototype

void aws_task_scheduler_cancel_task(struct aws_task_scheduler *scheduler, struct aws_task *task);
source
LibAwsCommon.aws_task_scheduler_clean_upMethod
aws_task_scheduler_clean_up(scheduler)

Empties and executes all queued tasks, passing the AWS_TASK_STATUS_CANCELED status to the task function. Cleans up any memory allocated, and prepares the instance for reuse or deletion.

Prototype

void aws_task_scheduler_clean_up(struct aws_task_scheduler *scheduler);
source
LibAwsCommon.aws_task_scheduler_has_tasksMethod
aws_task_scheduler_has_tasks(scheduler, next_task_time)

Returns whether the scheduler has any scheduled tasks. next_task_time (optional) will be set to time of the next task, note that 0 will be set if tasks were added via aws_task_scheduler_schedule_now() and UINT64_MAX will be set if no tasks are scheduled at all.

Prototype

bool aws_task_scheduler_has_tasks(const struct aws_task_scheduler *scheduler, uint64_t *next_task_time);
source
LibAwsCommon.aws_task_scheduler_initMethod
aws_task_scheduler_init(scheduler, alloc)

Initializes a task scheduler instance.

Prototype

int aws_task_scheduler_init(struct aws_task_scheduler *scheduler, struct aws_allocator *alloc);
source
LibAwsCommon.aws_task_scheduler_run_allMethod
aws_task_scheduler_run_all(scheduler, current_time)

Sequentially execute all tasks scheduled to run at, or before current_time. AWS_TASK_STATUS_RUN_READY will be passed to the task function as the task status.

If a task schedules another task, the new task will not be executed until the next call to this function.

Prototype

void aws_task_scheduler_run_all(struct aws_task_scheduler *scheduler, uint64_t current_time);
source
LibAwsCommon.aws_task_scheduler_schedule_futureMethod
aws_task_scheduler_schedule_future(scheduler, task, time_to_run)

Schedules a task to run at time_to_run. The task should not be cleaned up or modified until its function is executed.

Prototype

void aws_task_scheduler_schedule_future( struct aws_task_scheduler *scheduler, struct aws_task *task, uint64_t time_to_run);
source
LibAwsCommon.aws_task_scheduler_schedule_nowMethod
aws_task_scheduler_schedule_now(scheduler, task)

Schedules a task to run immediately. The task should not be cleaned up or modified until its function is executed.

Prototype

void aws_task_scheduler_schedule_now(struct aws_task_scheduler *scheduler, struct aws_task *task);
source
LibAwsCommon.aws_task_status_to_c_strMethod
aws_task_status_to_c_str(status)

Convert a status value to a c-string suitable for logging

Prototype

const char *aws_task_status_to_c_str(enum aws_task_status status);
source
LibAwsCommon.aws_text_detect_encodingMethod
aws_text_detect_encoding(bytes, size)

Checks the BOM in the buffer to see if encoding can be determined. If there is no BOM or it is unrecognizable, then AWS_TEXT_UNKNOWN will be returned.

Prototype

AWS_STATIC_IMPL enum aws_text_encoding aws_text_detect_encoding(const uint8_t *bytes, size_t size);
source
LibAwsCommon.aws_thread_call_onceMethod
aws_thread_call_once(flag, call_once, user_data)

Documentation not found.

Prototype

void aws_thread_call_once(aws_thread_once *flag, void (*call_once)(void *), void *user_data);
source
LibAwsCommon.aws_thread_clean_upMethod
aws_thread_clean_up(thread)

Cleans up the thread handle. Don't call this on a managed thread. If you wish to join the thread, you must join before calling this function.

Prototype

void aws_thread_clean_up(struct aws_thread *thread);
source
LibAwsCommon.aws_thread_current_at_exitMethod
aws_thread_current_at_exit(callback, user_data)

Adds a callback to the chain to be called when the current thread joins. Callbacks are called from the current thread, in the reverse order they were added, after the thread function returns. If not called from within an aws_thread, has no effect.

Prototype

int aws_thread_current_at_exit(aws_thread_atexit_fn *callback, void *user_data);
source
LibAwsCommon.aws_thread_current_nameMethod
aws_thread_current_name(allocator, out_name)

Gets name of the current thread. Caller is responsible for destroying returned string. If thread does not have a name, AWS_OP_SUCCESS is returned and out_name is set to NULL. If underlying OS call fails, AWS_ERROR_SYS_CALL_FAILURE will be raised If OS does not support getting thread name, AWS_ERROR_PLATFORM_NOT_SUPPORTED will be raised

Prototype

int aws_thread_current_name(struct aws_allocator *allocator, struct aws_string **out_name);
source
LibAwsCommon.aws_thread_decrement_unjoined_countMethod
aws_thread_decrement_unjoined_count()

Decrements the count of unjoined threads in the managed thread system. Used by managed threads and event loop threads. Additional usage requires the user to join corresponding threads themselves and correctly increment/decrement even in the face of launch/join errors.

aws_thread_join_all_managed() will not return until this count has gone to zero.

Prototype

void aws_thread_decrement_unjoined_count(void);
source
LibAwsCommon.aws_thread_get_detach_stateMethod
aws_thread_get_detach_state(thread)

Gets the detach state of the thread. For example, is it safe to call join on this thread? Has it been detached()?

Prototype

enum aws_thread_detach_state aws_thread_get_detach_state(struct aws_thread *thread);
source
LibAwsCommon.aws_thread_id_t_to_stringMethod
aws_thread_id_t_to_string(thread_id, buffer, bufsz)

Converts an aws_thread_id_t to a c-string. For portability, aws_thread_id_t must not be printed directly. Intended primarily to support building log lines that include the thread id in them. The parameter buffer must point-to a char buffer of length bufsz == [AWSTHREADIDTREPR_BUFSZ](@ref). The thread id representation is returned in buffer.

Prototype

int aws_thread_id_t_to_string(aws_thread_id_t thread_id, char *buffer, size_t bufsz);
source
LibAwsCommon.aws_thread_increment_unjoined_countMethod
aws_thread_increment_unjoined_count()

Increments the count of unjoined threads in the managed thread system. Used by managed threads and event loop threads. Additional usage requires the user to join corresponding threads themselves and correctly increment/decrement even in the face of launch/join errors.

aws_thread_join_all_managed() will not return until this count has gone to zero.

Prototype

void aws_thread_increment_unjoined_count(void);
source
LibAwsCommon.aws_thread_initMethod
aws_thread_init(thread, allocator)

Initializes a new platform specific thread object struct (not the os-level thread itself).

Prototype

int aws_thread_init(struct aws_thread *thread, struct aws_allocator *allocator);
source
LibAwsCommon.aws_thread_joinMethod
aws_thread_join(thread)

Joins the calling thread to a thread instance. Returns when thread is finished. Calling this from the associated OS thread will cause a deadlock.

Prototype

int aws_thread_join(struct aws_thread *thread);
source
LibAwsCommon.aws_thread_join_all_managedMethod
aws_thread_join_all_managed()

Blocking call that waits for all managed threads to complete their join call. This can only be called from the main thread or a non-managed thread.

This gets called automatically from library cleanup.

By default the wait is unbounded, but that default can be overridden via aws_thread_set_managed_join_timeout_ns()

Prototype

int aws_thread_join_all_managed(void);
source
LibAwsCommon.aws_thread_launchMethod
aws_thread_launch(thread, func, arg, options)

Creates an OS level thread and associates it with func. context will be passed to func when it is executed. options will be applied to the thread if they are applicable for the platform.

After launch, you may join on the thread. A successfully launched thread must have clean_up called on it in order to avoid a handle leak. If you do not join before calling clean_up, the thread will become detached.

Managed threads must not have join or clean_up called on them by external code.

Prototype

int aws_thread_launch( struct aws_thread *thread, void (*func)(void *arg), void *arg, const struct aws_thread_options *options);
source
LibAwsCommon.aws_thread_nameMethod
aws_thread_name(allocator, thread_id, out_name)

Gets name of the thread. Caller is responsible for destroying returned string. If thread does not have a name, AWS_OP_SUCCESS is returned and out_name is set to NULL. If underlying OS call fails, AWS_ERROR_SYS_CALL_FAILURE will be raised If OS does not support getting thread name, AWS_ERROR_PLATFORM_NOT_SUPPORTED will be raised

Prototype

int aws_thread_name( struct aws_allocator *allocator, aws_thread_id_t thread_id, struct aws_string **out_name);
source
LibAwsCommon.aws_thread_scheduler_cancel_taskMethod
aws_thread_scheduler_cancel_task(scheduler, task)

Cancel a task that has been scheduled. The cancellation callback will be invoked in the background thread. This function is slow, so please don't do it in the hot path for your code.

Prototype

void aws_thread_scheduler_cancel_task(struct aws_thread_scheduler *scheduler, struct aws_task *task);
source
LibAwsCommon.aws_thread_scheduler_newMethod
aws_thread_scheduler_new(allocator, thread_options)

Creates a new instance of a thread scheduler. This object receives scheduled tasks and executes them inside a background thread. On success, this function returns an instance with a ref-count of 1. On failure it returns NULL.

thread_options are optional.

The semantics of this interface conform to the semantics of aws_task_scheduler.

Prototype

struct aws_thread_scheduler *aws_thread_scheduler_new( struct aws_allocator *allocator, const struct aws_thread_options *thread_options);
source
LibAwsCommon.aws_thread_scheduler_schedule_futureMethod
aws_thread_scheduler_schedule_future(scheduler, task, time_to_run)

Schedules a task to run in the future. time_to_run is the absolute time from the system hw_clock.

Prototype

void aws_thread_scheduler_schedule_future( struct aws_thread_scheduler *scheduler, struct aws_task *task, uint64_t time_to_run);
source
LibAwsCommon.aws_thread_scheduler_schedule_nowMethod
aws_thread_scheduler_schedule_now(scheduler, task)

Schedules a task to run as soon as possible.

Prototype

void aws_thread_scheduler_schedule_now(struct aws_thread_scheduler *scheduler, struct aws_task *task);
source
LibAwsCommon.aws_timestamp_convertMethod
aws_timestamp_convert(timestamp, convert_from, convert_to, remainder)

Converts 'timestamp' from unit 'convert_from' to unit 'convert_to', if the units are the same then 'timestamp' is returned. If 'remainder' is NOT NULL, it will be set to the remainder if convert_from is a more precise unit than convert_to. To avoid unnecessary branching, 'remainder' is not zero initialized in this function, be sure to set it to 0 first if you care about that kind of thing. If conversion would lead to integer overflow, the timestamp returned will be the highest possible time that is representable, i.e. UINT64_MAX.

Prototype

AWS_STATIC_IMPL uint64_t aws_timestamp_convert( uint64_t timestamp, enum aws_timestamp_unit convert_from, enum aws_timestamp_unit convert_to, uint64_t *remainder);
source
LibAwsCommon.aws_timestamp_convert_u64Method
aws_timestamp_convert_u64(ticks, old_frequency, new_frequency, remainder)

More general form of aws_timestamp_convert that takes arbitrary frequencies rather than the timestamp enum.

Prototype

AWS_STATIC_IMPL uint64_t aws_timestamp_convert_u64(uint64_t ticks, uint64_t old_frequency, uint64_t new_frequency, uint64_t *remainder);
source
LibAwsCommon.aws_translate_and_raise_io_errorMethod
aws_translate_and_raise_io_error(error_no)

Convert a c library io error into an aws error, and raise it. If no conversion is found, AWS_ERROR_SYS_CALL_FAILURE is raised. Always returns AWS_OP_ERR.

Prototype

int aws_translate_and_raise_io_error(int error_no);
source
LibAwsCommon.aws_translate_and_raise_io_error_orMethod
aws_translate_and_raise_io_error_or(error_no, fallback_aws_error_code)

Convert a c library io error into an aws error, and raise it. If no conversion is found, fallback_aws_error_code is raised. Always returns AWS_OP_ERR.

Prototype

int aws_translate_and_raise_io_error_or(int error_no, int fallback_aws_error_code);
source
LibAwsCommon.aws_unregister_log_subject_info_listMethod
aws_unregister_log_subject_info_list(log_subject_list)

Disconnects log subject strings with log subject integer values

Prototype

void aws_unregister_log_subject_info_list(struct aws_log_subject_info_list *log_subject_list);
source
LibAwsCommon.aws_uri_authorityMethod
aws_uri_authority(uri)

Returns the authority portion of the uri (host[:port]). If it was not present, this was a request uri. In that case, the value will be empty.

Prototype

const struct aws_byte_cursor *aws_uri_authority(const struct aws_uri *uri);
source
LibAwsCommon.aws_uri_host_nameMethod
aws_uri_host_name(uri)

Returns the 'host_name' portion of the authority. If no authority was present, this value will be empty.

Prototype

const struct aws_byte_cursor *aws_uri_host_name(const struct aws_uri *uri);
source
LibAwsCommon.aws_uri_init_from_builder_optionsMethod
aws_uri_init_from_builder_options(uri, allocator, options)

Initializes uri to values specified in options. Returns AWS_OP_SUCCESS, on success, AWS_OP_ERR on failure. After calling this function, the parts can be accessed.

Prototype

int aws_uri_init_from_builder_options( struct aws_uri *uri, struct aws_allocator *allocator, struct aws_uri_builder_options *options);
source
LibAwsCommon.aws_uri_init_parseMethod
aws_uri_init_parse(uri, allocator, uri_str)

Parses 'uri_str' and initializes uri. Returns AWS_OP_SUCCESS, on success, AWS_OP_ERR on failure. After calling this function, the parts can be accessed.

Prototype

int aws_uri_init_parse( struct aws_uri *uri, struct aws_allocator *allocator, const struct aws_byte_cursor *uri_str);
source
LibAwsCommon.aws_uri_pathMethod
aws_uri_path(uri)

Returns the path portion of the uri, including any leading '/'. If not present, this value will be empty.

Prototype

const struct aws_byte_cursor *aws_uri_path(const struct aws_uri *uri);
source
LibAwsCommon.aws_uri_path_and_queryMethod
aws_uri_path_and_query(uri)

Returns the path and query portion of the uri (i.e., the thing you send across the wire).

Prototype

const struct aws_byte_cursor *aws_uri_path_and_query(const struct aws_uri *uri);
source
LibAwsCommon.aws_uri_portMethod
aws_uri_port(uri)

Returns the port portion of the authority if it was present, otherwise, returns 0. If this is 0, it is the users job to determine the correct port based on scheme and protocol.

Prototype

uint32_t aws_uri_port(const struct aws_uri *uri);
source
LibAwsCommon.aws_uri_query_stringMethod
aws_uri_query_string(uri)

Returns the query string portion of the uri, minus the '?'. If not present, this value will be empty.

Prototype

const struct aws_byte_cursor *aws_uri_query_string(const struct aws_uri *uri);
source
LibAwsCommon.aws_uri_query_string_next_paramMethod
aws_uri_query_string_next_param(uri, param)

For iterating over the params in the uri query string. param is an in/out argument used to track progress, it MUST be zeroed out to start. If true is returned, param contains the value of the next param. If false is returned, there are no further params.

Edge cases: 1) Entries without '=' sign are treated as having a key and no value. Example: First param in query string "a&b=c" has key="a" value=""

  1. Blank entries are skipped. Example: The only param in query string "&&a=b" is key="a" value="b"

Prototype

bool aws_uri_query_string_next_param(const struct aws_uri *uri, struct aws_uri_param *param);
source
LibAwsCommon.aws_uri_query_string_paramsMethod
aws_uri_query_string_params(uri, out_params)

Parses query string and stores the parameters in 'out_params'. Returns AWS_OP_SUCCESS on success and AWS_OP_ERR on failure. The user is responsible for initializing out_params with item size of struct aws_query_param. The user is also responsible for cleaning up out_params when finished.

Prototype

int aws_uri_query_string_params(const struct aws_uri *uri, struct aws_array_list *out_params);
source
LibAwsCommon.aws_uri_schemeMethod
aws_uri_scheme(uri)

Returns the scheme portion of the uri (e.g. http, https, ftp, ftps, etc...). If the scheme was not present in the uri, the returned value will be empty. It is the users job to determine the appropriate defaults if this field is empty, based on protocol, port, etc...

Prototype

const struct aws_byte_cursor *aws_uri_scheme(const struct aws_uri *uri);
source
LibAwsCommon.aws_utf8_decoder_finalizeMethod
aws_utf8_decoder_finalize(decoder)

Tell the decoder that you've reached the end of your text. Raises AWS_ERROR_INVALID_UTF8 if the text did not end with a complete UTF8 codepoint. This also resets the decoder.

Prototype

int aws_utf8_decoder_finalize(struct aws_utf8_decoder *decoder);
source
LibAwsCommon.aws_utf8_decoder_newMethod
aws_utf8_decoder_new(allocator, options)

Create a UTF8/ASCII decoder, which can process text incrementally as you receive it. Text is always validated according to RFC-3629 (you may perform additional validation in the on_codepoint callback). The text does not need to begin with a UTF8 BOM. To decode text all at once, simply use aws_decode_utf8().

Feed bytes into the decoder with aws_utf8_decoder_update(), and call aws_utf8_decoder_finalize() when the text is complete.

Arguments

  • allocator: Allocator
  • options: Options for decoder. If NULL is passed, the text is simply validated.

Prototype

struct aws_utf8_decoder *aws_utf8_decoder_new( struct aws_allocator *allocator, const struct aws_utf8_decoder_options *options);
source
LibAwsCommon.aws_utf8_decoder_updateMethod
aws_utf8_decoder_update(decoder, bytes)

Update the decoder with more bytes of text. The on_codepoint callback will be invoked for each codepoint encountered. Raises an error if invalid UTF8 is encountered or the on_codepoint callback reports an error.

Note: You must call aws_utf8_decoder_finalize() when the text is 100% complete, to ensure the input was completely valid.

Prototype

int aws_utf8_decoder_update(struct aws_utf8_decoder *decoder, struct aws_byte_cursor bytes);
source
LibAwsCommon.aws_uuid_equalsMethod
aws_uuid_equals(a, b)

Documentation not found.

Prototype

bool aws_uuid_equals(const struct aws_uuid *a, const struct aws_uuid *b);
source
LibAwsCommon.aws_uuid_init_from_strMethod
aws_uuid_init_from_str(uuid, uuid_str)

Documentation not found.

Prototype

int aws_uuid_init_from_str(struct aws_uuid *uuid, const struct aws_byte_cursor *uuid_str);
source
LibAwsCommon.aws_uuid_to_strMethod
aws_uuid_to_str(uuid, output)

Documentation not found.

Prototype

int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output);
source
LibAwsCommon.aws_write_u16Method
aws_write_u16(value, buffer)

Add a 16 bit unsigned integer to the buffer, ensuring network-byte order return the new position in the buffer for the next operation. Assumes buffer is at least 2 bytes long.

Prototype

AWS_STATIC_IMPL void aws_write_u16(uint16_t value, uint8_t *buffer);
source
LibAwsCommon.aws_write_u24Method
aws_write_u24(value, buffer)

Add a 24 bit unsigned integer to the buffer, ensuring network - byte order return the new position in the buffer for the next operation. Note, since this uses uint32_t for storage, the 3 least significant bytes will be used. Assumes buffer is at least 3 bytes long.

Prototype

AWS_STATIC_IMPL void aws_write_u24(uint32_t value, uint8_t *buffer);
source
LibAwsCommon.aws_write_u32Method
aws_write_u32(value, buffer)

Add a 32 bit unsigned integer to the buffer, ensuring network - byte order Assumes the buffer size is at least 4 bytes.

Prototype

AWS_STATIC_IMPL void aws_write_u32(uint32_t value, uint8_t *buffer);
source
LibAwsCommon.aws_write_u64Method
aws_write_u64(value, buffer)

Add a 64 bit unsigned integer to the buffer, ensuring network - byte order Assumes the buffer size is at least 8 bytes.

Prototype

AWS_STATIC_IMPL void aws_write_u64(uint64_t value, uint8_t *buffer);
source
LibAwsCommon.aws_xml_node_as_bodyMethod
aws_xml_node_as_body(node, out_body)

Writes the contents of the body of node into out_body. out_body is an output parameter in this case. Upon success, out_body will contain the body of the node.

Prototype

int aws_xml_node_as_body(struct aws_xml_node *node, struct aws_byte_cursor *out_body);
source
LibAwsCommon.aws_xml_node_get_attributeMethod
aws_xml_node_get_attribute(node, attribute_index)

Get an attribute for an xml node by its index.

Prototype

struct aws_xml_attribute aws_xml_node_get_attribute(const struct aws_xml_node *node, size_t attribute_index);
source
LibAwsCommon.aws_xml_node_traverseMethod
aws_xml_node_traverse(node, on_node_encountered, user_data)

Traverse node and invoke on_node_encountered when a nested node is encountered.

Prototype

int aws_xml_node_traverse( struct aws_xml_node *node, aws_xml_parser_on_node_encountered_fn *on_node_encountered, void *user_data);
source
LibAwsCommon.aws_xml_parseMethod
aws_xml_parse(allocator, options)

Parse an XML document. WARNING: This is not a public API. It is only intended for use within the aws-c libraries.

Prototype

int aws_xml_parse(struct aws_allocator *allocator, const struct aws_xml_parser_options *options);
source
LibAwsCommon.s_print_stack_traceMethod
s_print_stack_trace(sig, sig_info, user_data)

Documentation not found.

Prototype

static void s_print_stack_trace(int sig, siginfo_t *sig_info, void *user_data);
source