aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/c-ares/src/lib/include
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-10-19 17:59:18 +0000
committerAlexander Smirnov <alex@ydb.tech>2024-10-19 17:59:18 +0000
commitceddbfe68f6ec7949a4062716c8f9840a59c6888 (patch)
treeabfecadbb9c1e5aea40701dd20d902cb7bccd962 /contrib/libs/c-ares/src/lib/include
parent07f2e60d02d95eab14a86a4b9469db1af7795001 (diff)
parentd920c750e476fa2dc80c45f990d9456b1afeadd1 (diff)
downloadydb-ceddbfe68f6ec7949a4062716c8f9840a59c6888.tar.gz
Merge branch 'rightlib' into mergelibs-241019-1758
Diffstat (limited to 'contrib/libs/c-ares/src/lib/include')
-rw-r--r--contrib/libs/c-ares/src/lib/include/README.md8
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_array.h276
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_buf.h712
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_htable_asvp.h130
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_htable_dict.h123
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_htable_strvp.h130
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_htable_szvp.h118
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_htable_vpstr.h111
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_htable_vpvp.h128
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_llist.h239
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_mem.h38
-rw-r--r--contrib/libs/c-ares/src/lib/include/ares_str.h230
12 files changed, 2243 insertions, 0 deletions
diff --git a/contrib/libs/c-ares/src/lib/include/README.md b/contrib/libs/c-ares/src/lib/include/README.md
new file mode 100644
index 0000000000..f08021ba79
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/README.md
@@ -0,0 +1,8 @@
+# Semi-public headers
+The headers listed here all export symbols into the ares namespace as public
+symbols, but these headers are NOT included in the distribution. They are
+meant to be used by other tools such as `adig` and `ahost`.
+
+These are most likely going to be general purpose library functions such
+as data structures and algorithms.
+
diff --git a/contrib/libs/c-ares/src/lib/include/ares_array.h b/contrib/libs/c-ares/src/lib/include/ares_array.h
new file mode 100644
index 0000000000..f1a2e155f3
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_array.h
@@ -0,0 +1,276 @@
+/* MIT License
+ *
+ * Copyright (c) 2024 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__ARRAY_H
+#define __ARES__ARRAY_H
+
+#include "ares.h"
+
+/*! \addtogroup ares_array Array Data Structure
+ *
+ * This is an array with helpers. It is meant to have as little overhead
+ * as possible over direct array management by applications but to provide
+ * safety and some optimization features. It can also return the array in
+ * native form once all manipulation has been performed.
+ *
+ * @{
+ */
+
+struct ares_array;
+
+/*! Opaque data structure for array */
+typedef struct ares_array ares_array_t;
+
+/*! Callback to free user-defined member data
+ *
+ * \param[in] data pointer to member of array to be destroyed. The pointer
+ * itself must not be destroyed, just the data it contains.
+ */
+typedef void (*ares_array_destructor_t)(void *data);
+
+/*! Callback to compare two array elements used for sorting
+ *
+ * \param[in] data1 array member 1
+ * \param[in] data2 array member 2
+ * \return < 0 if data1 < data2, > 0 if data1 > data2, 0 if data1 == data2
+ */
+typedef int (*ares_array_cmp_t)(const void *data1, const void *data2);
+
+/*! Create an array object
+ *
+ * NOTE: members of the array are typically going to be an going to be a
+ * struct with compiler/ABI specific padding to ensure proper alignment.
+ * Care needs to be taken if using primitive types, especially floating
+ * point numbers which size may not indicate the required alignment.
+ * For example, a double may be 80 bits (10 bytes), but required
+ * alignment of 16 bytes. In such a case, a member_size of 16 would be
+ * required to be used.
+ *
+ * \param[in] destruct Optional. Destructor to call on a removed member
+ * \param[in] member_size Size of array member, usually determined using
+ * sizeof() for the member such as a struct.
+ *
+ * \return array object or NULL on out of memory
+ */
+CARES_EXTERN ares_array_t *ares_array_create(size_t member_size,
+ ares_array_destructor_t destruct);
+
+
+/*! Request the array be at least the requested size. Useful if the desired
+ * array size is known prior to populating the array to prevent reallocations.
+ *
+ * \param[in] arr Initialized array object.
+ * \param[in] size Minimum number of members
+ * \return ARES_SUCCESS on success, ARES_EFORMERR on misuse,
+ * ARES_ENOMEM on out of memory */
+CARES_EXTERN ares_status_t ares_array_set_size(ares_array_t *arr, size_t size);
+
+/*! Sort the array using the given comparison function. This is not
+ * persistent, any future elements inserted will not maintain this sort.
+ *
+ * \param[in] arr Initialized array object.
+ * \param[in] cb Sort callback
+ * \return ARES_SUCCESS on success
+ */
+CARES_EXTERN ares_status_t ares_array_sort(ares_array_t *arr,
+ ares_array_cmp_t cmp);
+
+/*! Destroy an array object. If a destructor is set, will be called on each
+ * member of the array.
+ *
+ * \param[in] arr Initialized array object.
+ */
+CARES_EXTERN void ares_array_destroy(ares_array_t *arr);
+
+/*! Retrieve the array in the native format. This will also destroy the
+ * container. It is the responsibility of the caller to free the returned
+ * pointer and also any data within each array element.
+ *
+ * \param[in] arr Initialized array object
+ * \param[out] num_members the number of members in the returned array
+ * \return pointer to native array on success, NULL on failure.
+ */
+CARES_EXTERN void *ares_array_finish(ares_array_t *arr, size_t *num_members);
+
+/*! Retrieve the number of members in the array
+ *
+ * \param[in] arr Initialized array object.
+ * \return numbrer of members
+ */
+CARES_EXTERN size_t ares_array_len(const ares_array_t *arr);
+
+/*! Insert a new array member at the given index
+ *
+ * \param[out] elem_ptr Optional. Pointer to the returned array element.
+ * \param[in] arr Initialized array object.
+ * \param[in] idx Index in array to place new element, will shift any
+ * elements down that exist after this point.
+ * \return ARES_SUCCESS on success, ARES_EFORMERR on bad index,
+ * ARES_ENOMEM on out of memory.
+ */
+CARES_EXTERN ares_status_t ares_array_insert_at(void **elem_ptr,
+ ares_array_t *arr, size_t idx);
+
+/*! Insert a new array member at the end of the array
+ *
+ * \param[out] elem_ptr Optional. Pointer to the returned array element.
+ * \param[in] arr Initialized array object.
+ * \return ARES_SUCCESS on success, ARES_ENOMEM on out of memory.
+ */
+CARES_EXTERN ares_status_t ares_array_insert_last(void **elem_ptr,
+ ares_array_t *arr);
+
+/*! Insert a new array member at the beginning of the array
+ *
+ * \param[out] elem_ptr Optional. Pointer to the returned array element.
+ * \param[in] arr Initialized array object.
+ * \return ARES_SUCCESS on success, ARES_ENOMEM on out of memory.
+ */
+CARES_EXTERN ares_status_t ares_array_insert_first(void **elem_ptr,
+ ares_array_t *arr);
+
+
+/*! Insert a new array member at the given index and copy the data pointed
+ * to by the data pointer into the array. This will copy member_size bytes
+ * from the provided pointer, this may not be safe for some data types
+ * that may have a smaller size than the provided member_size which includes
+ * padding as discussed in ares_array_create().
+ *
+ * \param[in] arr Initialized array object.
+ * \param[in] idx Index in array to place new element, will shift any
+ * elements down that exist after this point.
+ * \param[in] data_ptr Pointer to data to copy into array.
+ * \return ARES_SUCCESS on success, ARES_EFORMERR on bad index or null data
+ * ptr, ARES_ENOMEM on out of memory.
+ */
+CARES_EXTERN ares_status_t ares_array_insertdata_at(ares_array_t *arr,
+ size_t idx,
+ const void *data_ptr);
+
+/*! Insert a new array member at the end of the array and copy the data pointed
+ * to by the data pointer into the array. This will copy member_size bytes
+ * from the provided pointer, this may not be safe for some data types
+ * that may have a smaller size than the provided member_size which includes
+ * padding as discussed in ares_array_create().
+ *
+ * \param[in] arr Initialized array object.
+ * \param[in] data_ptr Pointer to data to copy into array.
+ * \return ARES_SUCCESS on success, ARES_EFORMERR on bad index or null data
+ * ptr, ARES_ENOMEM on out of memory.
+ */
+CARES_EXTERN ares_status_t ares_array_insertdata_last(ares_array_t *arr,
+ const void *data_ptr);
+
+/*! Insert a new array member at the beginning of the array and copy the data
+ * pointed to by the data pointer into the array. This will copy member_size
+ * bytes from the provided pointer, this may not be safe for some data types
+ * that may have a smaller size than the provided member_size which includes
+ * padding as discussed in ares_array_create().
+ *
+ * \param[in] arr Initialized array object.
+ * \param[in] data_ptr Pointer to data to copy into array.
+ * \return ARES_SUCCESS on success, ARES_EFORMERR on bad index or null data
+ * ptr, ARES_ENOMEM on out of memory.
+ */
+CARES_EXTERN ares_status_t ares_array_insertdata_first(ares_array_t *arr,
+ const void *data_ptr);
+
+/*! Fetch a pointer to the given element in the array
+ * \param[in] array Initialized array object
+ * \param[in] idx Index to fetch
+ * \return pointer on success, NULL on failure */
+CARES_EXTERN void *ares_array_at(ares_array_t *arr, size_t idx);
+
+/*! Fetch a pointer to the first element in the array
+ * \param[in] array Initialized array object
+ * \return pointer on success, NULL on failure */
+CARES_EXTERN void *ares_array_first(ares_array_t *arr);
+
+/*! Fetch a pointer to the last element in the array
+ * \param[in] array Initialized array object
+ * \return pointer on success, NULL on failure */
+CARES_EXTERN void *ares_array_last(ares_array_t *arr);
+
+/*! Fetch a constant pointer to the given element in the array
+ * \param[in] array Initialized array object
+ * \param[in] idx Index to fetch
+ * \return pointer on success, NULL on failure */
+CARES_EXTERN const void *ares_array_at_const(const ares_array_t *arr,
+ size_t idx);
+
+/*! Fetch a constant pointer to the first element in the array
+ * \param[in] array Initialized array object
+ * \return pointer on success, NULL on failure */
+CARES_EXTERN const void *ares_array_first_const(const ares_array_t *arr);
+
+/*! Fetch a constant pointer to the last element in the array
+ * \param[in] array Initialized array object
+ * \return pointer on success, NULL on failure */
+CARES_EXTERN const void *ares_array_last_const(const ares_array_t *arr);
+
+/*! Claim the data from the specified array index, copying it to the buffer
+ * provided by the caller. The index specified in the array will then be
+ * removed (without calling any possible destructor)
+ *
+ * \param[in,out] dest Optional. Buffer to hold array member. Pass NULL
+ * if not needed. This could leak memory if array
+ * member needs destructor if not provided.
+ * \param[in] dest_size Size of buffer provided, used as a sanity check.
+ * Must match member_size provided to
+ * ares_array_create() if dest_size specified.
+ * \param[in] arr Initialized array object
+ * \param[in] idx Index to claim
+ * \return ARES_SUCCESS on success, ARES_EFORMERR on usage failure.
+ */
+CARES_EXTERN ares_status_t ares_array_claim_at(void *dest, size_t dest_size,
+ ares_array_t *arr, size_t idx);
+
+/*! Remove the member at the specified array index. The destructor will be
+ * called.
+ *
+ * \param[in] arr Initialized array object
+ * \param[in] idx Index to remove
+ * \return ARES_SUCCESS if removed, ARES_EFORMERR on invalid use
+ */
+CARES_EXTERN ares_status_t ares_array_remove_at(ares_array_t *arr, size_t idx);
+
+/*! Remove the first member of the array.
+ *
+ * \param[in] arr Initialized array object
+ * \return ARES_SUCCESS if removed, ARES_EFORMERR on invalid use
+ */
+CARES_EXTERN ares_status_t ares_array_remove_first(ares_array_t *arr);
+
+/*! Remove the last member of the array.
+ *
+ * \param[in] arr Initialized array object
+ * \return ARES_SUCCESS if removed, ARES_EFORMERR on invalid use
+ */
+CARES_EXTERN ares_status_t ares_array_remove_last(ares_array_t *arr);
+
+
+/*! @} */
+
+#endif /* __ARES__ARRAY_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_buf.h b/contrib/libs/c-ares/src/lib/include/ares_buf.h
new file mode 100644
index 0000000000..7836a313e0
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_buf.h
@@ -0,0 +1,712 @@
+/* MIT License
+ *
+ * Copyright (c) 2023 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__BUF_H
+#define __ARES__BUF_H
+
+#include "ares.h"
+#include "ares_array.h"
+
+/*! \addtogroup ares_buf Safe Data Builder and buffer
+ *
+ * This is a buffer building and parsing framework with a focus on security over
+ * performance. All data to be read from the buffer will perform explicit length
+ * validation and return a success/fail result. There are also various helpers
+ * for writing data to the buffer which dynamically grows.
+ *
+ * All operations that fetch or consume data from the buffer will move forward
+ * the internal pointer, thus marking the data as processed which may no longer
+ * be accessible after certain operations (such as append).
+ *
+ * The helpers for this object are meant to be added as needed. If you can't
+ * find it, write it!
+ *
+ * @{
+ */
+struct ares_buf;
+
+/*! Opaque data type for generic hash table implementation */
+typedef struct ares_buf ares_buf_t;
+
+/*! Create a new buffer object that dynamically allocates buffers for data.
+ *
+ * \return initialized buffer object or NULL if out of memory.
+ */
+CARES_EXTERN ares_buf_t *ares_buf_create(void);
+
+/*! Create a new buffer object that uses a user-provided data pointer. The
+ * data provided will not be manipulated, and cannot be appended to. This
+ * is strictly used for parsing.
+ *
+ * \param[in] data Data to provide to buffer, must not be NULL.
+ * \param[in] data_len Size of buffer provided, must be > 0
+ *
+ * \return initialized buffer object or NULL if out of memory or misuse.
+ */
+CARES_EXTERN ares_buf_t *ares_buf_create_const(const unsigned char *data,
+ size_t data_len);
+
+
+/*! Destroy an initialized buffer object.
+ *
+ * \param[in] buf Initialized buf object
+ */
+CARES_EXTERN void ares_buf_destroy(ares_buf_t *buf);
+
+
+/*! Append multiple bytes to a dynamic buffer object
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] data Data to copy to buffer object
+ * \param[in] data_len Length of data to copy to buffer object.
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_append(ares_buf_t *buf,
+ const unsigned char *data,
+ size_t data_len);
+
+/*! Append a single byte to the dynamic buffer object
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] b Single byte to append to buffer object.
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_append_byte(ares_buf_t *buf,
+ unsigned char b);
+
+/*! Append a null-terminated string to the dynamic buffer object
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] str String to append to buffer object.
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_append_str(ares_buf_t *buf,
+ const char *str);
+
+/*! Append a 16bit Big Endian number to the buffer.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] u16 16bit integer
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_append_be16(ares_buf_t *buf,
+ unsigned short u16);
+
+/*! Append a 32bit Big Endian number to the buffer.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] u32 32bit integer
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_append_be32(ares_buf_t *buf,
+ unsigned int u32);
+
+/*! Append a number in ASCII decimal form.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] num Number to print
+ * \param[in] len Length to output, use 0 for no padding
+ * \return ARES_SUCCESS on success
+ */
+CARES_EXTERN ares_status_t ares_buf_append_num_dec(ares_buf_t *buf, size_t num,
+ size_t len);
+
+/*! Append a number in ASCII hexadecimal form.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] num Number to print
+ * \param[in] len Length to output, use 0 for no padding
+ * \return ARES_SUCCESS on success
+ */
+CARES_EXTERN ares_status_t ares_buf_append_num_hex(ares_buf_t *buf, size_t num,
+ size_t len);
+
+/*! Sets the current buffer length. This *may* be used if there is a need to
+ * override a prior position in the buffer, such as if there is a length
+ * prefix that isn't easily predictable, and you must go back and overwrite
+ * that position.
+ *
+ * Only valid on non-const buffers. Length provided must not exceed current
+ * allocated buffer size, but otherwise there are very few protections on
+ * this function. Use cautiously.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] len Length to set
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_set_length(ares_buf_t *buf, size_t len);
+
+
+/*! Start a dynamic append operation that returns a buffer suitable for
+ * writing. A desired minimum length is passed in, and the actual allocated
+ * buffer size is returned which may be greater than the requested size.
+ * No operation other than ares_buf_append_finish() is allowed on the
+ * buffer after this request.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in,out] len Desired non-zero length passed in, actual buffer size
+ * returned.
+ * \return Pointer to writable buffer or NULL on failure (usage, out of mem)
+ */
+CARES_EXTERN unsigned char *ares_buf_append_start(ares_buf_t *buf, size_t *len);
+
+/*! Finish a dynamic append operation. Called after
+ * ares_buf_append_start() once desired data is written.
+ *
+ * \param[in] buf Initialized buffer object.
+ * \param[in] len Length of data written. May be zero to terminate
+ * operation. Must not be greater than returned from
+ * ares_buf_append_start().
+ */
+CARES_EXTERN void ares_buf_append_finish(ares_buf_t *buf, size_t len);
+
+/*! Write the data provided to the buffer in a hexdump format.
+ *
+ * \param[in] buf Initialized buffer object.
+ * \param[in] data Data to hex dump
+ * \param[in] len Length of data to hexdump
+ * \return ARES_SUCCESS on success.
+ */
+CARES_EXTERN ares_status_t ares_buf_hexdump(ares_buf_t *buf,
+ const unsigned char *data,
+ size_t len);
+
+/*! Clean up ares_buf_t and return allocated pointer to unprocessed data. It
+ * is the responsibility of the caller to ares_free() the returned buffer.
+ * The passed in buf parameter is invalidated by this call.
+ *
+ * \param[in] buf Initialized buffer object. Can not be a "const" buffer.
+ * \param[out] len Length of data returned
+ * \return pointer to unprocessed data (may be zero length) or NULL on error.
+ */
+CARES_EXTERN unsigned char *ares_buf_finish_bin(ares_buf_t *buf, size_t *len);
+
+/*! Clean up ares_buf_t and return allocated pointer to unprocessed data and
+ * return it as a string (null terminated). It is the responsibility of the
+ * caller to ares_free() the returned buffer. The passed in buf parameter is
+ * invalidated by this call.
+ *
+ * This function in no way validates the data in this buffer is actually
+ * a string, that characters are printable, or that there aren't multiple
+ * NULL terminators. It is assumed that the caller will either validate that
+ * themselves or has built this buffer with only a valid character set.
+ *
+ * \param[in] buf Initialized buffer object. Can not be a "const" buffer.
+ * \param[out] len Optional. Length of data returned, or NULL if not needed.
+ * \return pointer to unprocessed data or NULL on error.
+ */
+CARES_EXTERN char *ares_buf_finish_str(ares_buf_t *buf, size_t *len);
+
+/*! Tag a position to save in the buffer in case parsing needs to rollback,
+ * such as if insufficient data is available, but more data may be added in
+ * the future. Only a single tag can be set per buffer object. Setting a
+ * tag will override any pre-existing tag.
+ *
+ * \param[in] buf Initialized buffer object
+ */
+CARES_EXTERN void ares_buf_tag(ares_buf_t *buf);
+
+/*! Rollback to a tagged position. Will automatically clear the tag.
+ *
+ * \param[in] buf Initialized buffer object
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_tag_rollback(ares_buf_t *buf);
+
+/*! Clear the tagged position without rolling back. You should do this any
+ * time a tag is no longer needed as future append operations can reclaim
+ * buffer space.
+ *
+ * \param[in] buf Initialized buffer object
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_tag_clear(ares_buf_t *buf);
+
+/*! Fetch the buffer and length of data starting from the tagged position up
+ * to the _current_ position. It will not unset the tagged position. The
+ * data may be invalidated by any future ares_buf_*() calls.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] len Length between tag and current offset in buffer
+ * \return NULL on failure (such as no tag), otherwise pointer to start of
+ * buffer
+ */
+CARES_EXTERN const unsigned char *ares_buf_tag_fetch(const ares_buf_t *buf,
+ size_t *len);
+
+/*! Get the length of the current tag offset to the current position.
+ *
+ * \param[in] buf Initialized buffer object
+ * \return length
+ */
+CARES_EXTERN size_t ares_buf_tag_length(const ares_buf_t *buf);
+
+/*! Fetch the bytes starting from the tagged position up to the _current_
+ * position using the provided buffer. It will not unset the tagged position.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in,out] bytes Buffer to hold data
+ * \param[in,out] len On input, buffer size, on output, bytes place in
+ * buffer.
+ * \return ARES_SUCCESS if fetched, ARES_EFORMERR if insufficient buffer size
+ */
+CARES_EXTERN ares_status_t ares_buf_tag_fetch_bytes(const ares_buf_t *buf,
+ unsigned char *bytes,
+ size_t *len);
+
+/*! Fetch the bytes starting from the tagged position up to the _current_
+ * position as a NULL-terminated string using the provided buffer. The data
+ * is validated to be ASCII-printable data. It will not unset the tagged
+ * position.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in,out] str Buffer to hold data
+ * \param[in] len buffer size
+ * \return ARES_SUCCESS if fetched, ARES_EFORMERR if insufficient buffer size,
+ * ARES_EBADSTR if not printable ASCII
+ */
+CARES_EXTERN ares_status_t ares_buf_tag_fetch_string(const ares_buf_t *buf,
+ char *str, size_t len);
+
+/*! Fetch the bytes starting from the tagged position up to the _current_
+ * position as a NULL-terminated string and placed into a newly allocated
+ * buffer. The data is validated to be ASCII-printable data. It will not
+ * unset the tagged position.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] str New buffer to hold output, free with ares_free()
+ *
+ * \return ARES_SUCCESS if fetched, ARES_EFORMERR if insufficient buffer size,
+ * ARES_EBADSTR if not printable ASCII
+ */
+CARES_EXTERN ares_status_t ares_buf_tag_fetch_strdup(const ares_buf_t *buf,
+ char **str);
+
+/*! Fetch the bytes starting from the tagged position up to the _current_
+ * position as const buffer. Care must be taken to not append or destroy the
+ * passed in buffer until the newly fetched buffer is no longer needed since
+ * it points to memory inside the passed in buffer which could be invalidated.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] newbuf New const buffer object, must be destroyed when done.
+
+ * \return ARES_SUCCESS if fetched
+ */
+CARES_EXTERN ares_status_t ares_buf_tag_fetch_constbuf(const ares_buf_t *buf,
+ ares_buf_t **newbuf);
+
+/*! Consume the given number of bytes without reading them.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] len Length to consume
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_consume(ares_buf_t *buf, size_t len);
+
+/*! Fetch a 16bit Big Endian number from the buffer.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] u16 Buffer to hold 16bit integer
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_fetch_be16(ares_buf_t *buf,
+ unsigned short *u16);
+
+/*! Fetch a 32bit Big Endian number from the buffer.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] u32 Buffer to hold 32bit integer
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_fetch_be32(ares_buf_t *buf,
+ unsigned int *u32);
+
+
+/*! Fetch the requested number of bytes into the provided buffer
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] bytes Buffer to hold data
+ * \param[in] len Requested number of bytes (must be > 0)
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_fetch_bytes(ares_buf_t *buf,
+ unsigned char *bytes,
+ size_t len);
+
+
+/*! Fetch the requested number of bytes and return a new buffer that must be
+ * ares_free()'d by the caller.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] len Requested number of bytes (must be > 0)
+ * \param[in] null_term Even though this is considered binary data, the user
+ * knows it may be a vald string, so add a null
+ * terminator.
+ * \param[out] bytes Pointer passed by reference. Will be allocated.
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_fetch_bytes_dup(ares_buf_t *buf, size_t len,
+ ares_bool_t null_term,
+ unsigned char **bytes);
+
+/*! Fetch the requested number of bytes and place them into the provided
+ * dest buffer object.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] dest Buffer object to append bytes.
+ * \param[in] len Requested number of bytes (must be > 0)
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_fetch_bytes_into_buf(ares_buf_t *buf,
+ ares_buf_t *dest,
+ size_t len);
+
+/*! Fetch the requested number of bytes and return a new buffer that must be
+ * ares_free()'d by the caller. The returned buffer is a null terminated
+ * string. The data is validated to be ASCII-printable.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] len Requested number of bytes (must be > 0)
+ * \param[out] str Pointer passed by reference. Will be allocated.
+ * \return ARES_SUCCESS or one of the c-ares error codes
+ */
+CARES_EXTERN ares_status_t ares_buf_fetch_str_dup(ares_buf_t *buf, size_t len,
+ char **str);
+
+/*! Consume whitespace characters (0x09, 0x0B, 0x0C, 0x0D, 0x20, and optionally
+ * 0x0A).
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] include_linefeed ARES_TRUE to include consuming 0x0A,
+ * ARES_FALSE otherwise.
+ * \return number of whitespace characters consumed
+ */
+CARES_EXTERN size_t ares_buf_consume_whitespace(ares_buf_t *buf,
+ ares_bool_t include_linefeed);
+
+
+/*! Consume any non-whitespace character (anything other than 0x09, 0x0B, 0x0C,
+ * 0x0D, 0x20, and 0x0A).
+ *
+ * \param[in] buf Initialized buffer object
+ * \return number of characters consumed
+ */
+CARES_EXTERN size_t ares_buf_consume_nonwhitespace(ares_buf_t *buf);
+
+
+/*! Consume until a character in the character set provided is reached. Does
+ * not include the character from the charset at the end.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] charset character set
+ * \param[in] len length of character set
+ * \param[in] require_charset require we find a character from the charset.
+ * if ARES_FALSE it will simply consume the
+ * rest of the buffer. If ARES_TRUE will return
+ * SIZE_MAX if not found.
+ * \return number of characters consumed
+ */
+CARES_EXTERN size_t ares_buf_consume_until_charset(ares_buf_t *buf,
+ const unsigned char *charset,
+ size_t len,
+ ares_bool_t require_charset);
+
+
+/*! Consume until a sequence of bytes is encountered. Does not include the
+ * sequence of characters itself.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] seq sequence of bytes
+ * \param[in] len length of sequence
+ * \param[in] require_charset require we find the sequence.
+ * if ARES_FALSE it will simply consume the
+ * rest of the buffer. If ARES_TRUE will return
+ * SIZE_MAX if not found.
+ * \return number of characters consumed
+ */
+CARES_EXTERN size_t ares_buf_consume_until_seq(ares_buf_t *buf,
+ const unsigned char *seq,
+ size_t len,
+ ares_bool_t require_seq);
+
+/*! Consume while the characters match the characters in the provided set.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] charset character set
+ * \param[in] len length of character set
+ * \return number of characters consumed
+ */
+CARES_EXTERN size_t ares_buf_consume_charset(ares_buf_t *buf,
+ const unsigned char *charset,
+ size_t len);
+
+
+/*! Consume from the current position until the end of the line, and optionally
+ * the end of line character (0x0A) itself.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] include_linefeed ARES_TRUE to include consuming 0x0A,
+ * ARES_FALSE otherwise.
+ * \return number of characters consumed
+ */
+CARES_EXTERN size_t ares_buf_consume_line(ares_buf_t *buf,
+ ares_bool_t include_linefeed);
+
+typedef enum {
+ /*! No flags */
+ ARES_BUF_SPLIT_NONE = 0,
+ /*! The delimiter will be the first character in the buffer, except the
+ * first buffer since the start doesn't have a delimiter. This option is
+ * incompatible with ARES_BUF_SPLIT_LTRIM since the delimiter is always
+ * the first character.
+ */
+ ARES_BUF_SPLIT_KEEP_DELIMS = 1 << 0,
+ /*! Allow blank sections, by default blank sections are not emitted. If using
+ * ARES_BUF_SPLIT_KEEP_DELIMS, the delimiter is not counted as part
+ * of the section */
+ ARES_BUF_SPLIT_ALLOW_BLANK = 1 << 1,
+ /*! Remove duplicate entries */
+ ARES_BUF_SPLIT_NO_DUPLICATES = 1 << 2,
+ /*! Perform case-insensitive matching when comparing values */
+ ARES_BUF_SPLIT_CASE_INSENSITIVE = 1 << 3,
+ /*! Trim leading whitespace from buffer */
+ ARES_BUF_SPLIT_LTRIM = 1 << 4,
+ /*! Trim trailing whitespace from buffer */
+ ARES_BUF_SPLIT_RTRIM = 1 << 5,
+ /*! Trim leading and trailing whitespace from buffer */
+ ARES_BUF_SPLIT_TRIM = (ARES_BUF_SPLIT_LTRIM | ARES_BUF_SPLIT_RTRIM)
+} ares_buf_split_t;
+
+/*! Split the provided buffer into multiple sub-buffers stored in the variable
+ * pointed to by the linked list. The sub buffers are const buffers pointing
+ * into the buf provided.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] delims Possible delimiters
+ * \param[in] delims_len Length of possible delimiters
+ * \param[in] flags One more more flags
+ * \param[in] max_sections Maximum number of sections. Use 0 for
+ * unlimited. Useful for splitting key/value
+ * pairs where the delimiter may be a valid
+ * character in the value. A value of 1 would
+ * have little usefulness and would effectively
+ * ignore the delimiter itself.
+ * \param[out] arr Result. Depending on flags, this may be a
+ * valid array with no elements. Use
+ * ares_array_destroy() to free the memory which
+ * will also free the contained ares_buf_t *
+ * objects. Each buf object returned by
+ * ares_array_at() or similar is a pointer to
+ * an ares_buf_t * object, meaning you need to
+ * accept it as "ares_buf_t **" then dereference.
+ * \return ARES_SUCCESS on success, or error like ARES_ENOMEM.
+ */
+CARES_EXTERN ares_status_t ares_buf_split(
+ ares_buf_t *buf, const unsigned char *delims, size_t delims_len,
+ ares_buf_split_t flags, size_t max_sections, ares_array_t **arr);
+
+/*! Split the provided buffer into an ares_array_t of C strings.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] delims Possible delimiters
+ * \param[in] delims_len Length of possible delimiters
+ * \param[in] flags One more more flags
+ * \param[in] max_sections Maximum number of sections. Use 0 for
+ * unlimited. Useful for splitting key/value
+ * pairs where the delimiter may be a valid
+ * character in the value. A value of 1 would
+ * have little usefulness and would effectively
+ * ignore the delimiter itself.
+ * \param[out] arr Array of strings. Free using
+ * ares_array_destroy().
+ * \return ARES_SUCCESS on success, or error like ARES_ENOMEM.
+ */
+CARES_EXTERN ares_status_t ares_buf_split_str_array(
+ ares_buf_t *buf, const unsigned char *delims, size_t delims_len,
+ ares_buf_split_t flags, size_t max_sections, ares_array_t **arr);
+
+/*! Split the provided buffer into a C array of C strings.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] delims Possible delimiters
+ * \param[in] delims_len Length of possible delimiters
+ * \param[in] flags One more more flags
+ * \param[in] max_sections Maximum number of sections. Use 0 for
+ * unlimited. Useful for splitting key/value
+ * pairs where the delimiter may be a valid
+ * character in the value. A value of 1 would
+ * have little usefulness and would effectively
+ * ignore the delimiter itself.
+ * \param[out] strs Array of strings. Free using
+ * ares_free_array(strs, nstrs, ares_free)
+ * \param[out] nstrs Number of elements in the array.
+ * \return ARES_SUCCESS on success, or error like ARES_ENOMEM.
+ */
+CARES_EXTERN ares_status_t ares_buf_split_str(
+ ares_buf_t *buf, const unsigned char *delims, size_t delims_len,
+ ares_buf_split_t flags, size_t max_sections, char ***strs, size_t *nstrs);
+
+/*! Check the unprocessed buffer to see if it begins with the sequence of
+ * characters provided.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] data Bytes of data to compare.
+ * \param[in] data_len Length of data to compare.
+ * \return ARES_TRUE on match, ARES_FALSE otherwise.
+ */
+CARES_EXTERN ares_bool_t ares_buf_begins_with(const ares_buf_t *buf,
+ const unsigned char *data,
+ size_t data_len);
+
+
+/*! Size of unprocessed remaining data length
+ *
+ * \param[in] buf Initialized buffer object
+ * \return length remaining
+ */
+CARES_EXTERN size_t ares_buf_len(const ares_buf_t *buf);
+
+/*! Retrieve a pointer to the currently unprocessed data. Generally this isn't
+ * recommended to be used in practice. The returned pointer may be invalidated
+ * by any future ares_buf_*() calls.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] len Length of available data
+ * \return Pointer to buffer of unprocessed data
+ */
+CARES_EXTERN const unsigned char *ares_buf_peek(const ares_buf_t *buf,
+ size_t *len);
+
+/*! Retrieve the next byte in the buffer without moving forward.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[out] b Single byte
+ * \return \return ARES_SUCCESS on success, or error
+ */
+CARES_EXTERN ares_status_t ares_buf_peek_byte(const ares_buf_t *buf,
+ unsigned char *b);
+
+/*! Wipe any processed data from the beginning of the buffer. This will
+ * move any remaining data to the front of the internally allocated buffer.
+ *
+ * Can not be used on const buffer objects.
+ *
+ * Typically not needed to call, as any new append operation will automatically
+ * call this function if there is insufficient space to append the data in
+ * order to try to avoid another memory allocation.
+ *
+ * It may be useful to call in order to ensure the current message being
+ * processed is in the beginning of the buffer if there is an intent to use
+ * ares_buf_set_position() and ares_buf_get_position() as may be necessary
+ * when processing DNS compressed names.
+ *
+ * If there is an active tag, it will NOT clear the tag, it will use the tag
+ * as the start of the unprocessed data rather than the current offset. If
+ * a prior tag is no longer needed, may be wise to call ares_buf_tag_clear().
+ *
+ * \param[in] buf Initialized buffer object
+ */
+CARES_EXTERN void ares_buf_reclaim(ares_buf_t *buf);
+
+/*! Set the current offset within the internal buffer.
+ *
+ * Typically this should not be used, if possible, use the ares_buf_tag*()
+ * operations instead.
+ *
+ * One exception is DNS name compression which may backwards reference to
+ * an index in the message. It may be necessary in such a case to call
+ * ares_buf_reclaim() if using a dynamic (non-const) buffer before processing
+ * such a message.
+ *
+ * \param[in] buf Initialized buffer object
+ * \param[in] idx Index to set position
+ * \return ARES_SUCCESS if valid index
+ */
+CARES_EXTERN ares_status_t ares_buf_set_position(ares_buf_t *buf, size_t idx);
+
+/*! Get the current offset within the internal buffer.
+ *
+ * Typically this should not be used, if possible, use the ares_buf_tag*()
+ * operations instead.
+ *
+ * This can be used to get the current position, useful for saving if a
+ * jump via ares_buf_set_position() is performed and need to restore the
+ * current position for future operations.
+ *
+ * \param[in] buf Initialized buffer object
+ * \return index of current position
+ */
+CARES_EXTERN size_t ares_buf_get_position(const ares_buf_t *buf);
+
+/*! Parse a character-string as defined in RFC1035, as a null-terminated
+ * string.
+ *
+ * \param[in] buf initialized buffer object
+ * \param[in] remaining_len maximum length that should be used for parsing
+ * the string, this is often less than the remaining
+ * buffer and is based on the RR record length.
+ * \param[out] name Pointer passed by reference to be filled in with
+ * allocated string of the parsed that must be
+ * ares_free()'d by the caller.
+ * \return ARES_SUCCESS on success
+ */
+CARES_EXTERN ares_status_t ares_buf_parse_dns_str(ares_buf_t *buf,
+ size_t remaining_len,
+ char **name);
+
+/*! Parse a character-string as defined in RFC1035, as binary, however for
+ * convenience this does guarantee a NULL terminator (that is not included
+ * in the returned length).
+ *
+ * \param[in] buf initialized buffer object
+ * \param[in] remaining_len maximum length that should be used for parsing
+ * the string, this is often less than the remaining
+ * buffer and is based on the RR record length.
+ * \param[out] bin Pointer passed by reference to be filled in with
+ * allocated string of the parsed that must be
+ * ares_free()'d by the caller.
+ * \param[out] bin_len Length of returned string.
+ * \return ARES_SUCCESS on success
+ */
+CARES_EXTERN ares_status_t ares_buf_parse_dns_binstr(ares_buf_t *buf,
+ size_t remaining_len,
+ unsigned char **bin,
+ size_t *bin_len);
+
+/*! Load data from specified file path into provided buffer. The entire file
+ * is loaded into memory.
+ *
+ * \param[in] filename complete path to file
+ * \param[in,out] buf Initialized (non-const) buffer object to load data
+ * into
+ * \return ARES_ENOTFOUND if file not found, ARES_EFILE if issues reading
+ * file, ARES_ENOMEM if out of memory, ARES_SUCCESS on success.
+ */
+CARES_EXTERN ares_status_t ares_buf_load_file(const char *filename,
+ ares_buf_t *buf);
+
+/*! @} */
+
+#endif /* __ARES__BUF_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_htable_asvp.h b/contrib/libs/c-ares/src/lib/include/ares_htable_asvp.h
new file mode 100644
index 0000000000..89a99fc9ee
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_htable_asvp.h
@@ -0,0 +1,130 @@
+/* MIT License
+ *
+ * Copyright (c) 2023 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__HTABLE_ASVP_H
+#define __ARES__HTABLE_ASVP_H
+
+/*! \addtogroup ares_htable_asvp HashTable with ares_socket_t Key and
+ * void pointer Value
+ *
+ * This data structure wraps the base ares_htable data structure in order to
+ * split the key and value data types as ares_socket_t and void pointer,
+ * respectively.
+ *
+ * Average time complexity:
+ * - Insert: O(1)
+ * - Search: O(1)
+ * - Delete: O(1)
+ *
+ * @{
+ */
+
+struct ares_htable_asvp;
+
+/*! Opaque data type for ares_socket_t key, void pointer hash table
+ * implementation */
+typedef struct ares_htable_asvp ares_htable_asvp_t;
+
+/*! Callback to free value stored in hashtable
+ *
+ * \param[in] val user-supplied value
+ */
+typedef void (*ares_htable_asvp_val_free_t)(void *val);
+
+/*! Destroy hashtable
+ *
+ * \param[in] htable Initialized hashtable
+ */
+CARES_EXTERN void ares_htable_asvp_destroy(ares_htable_asvp_t *htable);
+
+/*! Create size_t key, void pointer value hash table
+ *
+ * \param[in] val_free Optional. Call back to free user-supplied value. If
+ * NULL it is expected the caller will clean up any user
+ * supplied values.
+ */
+CARES_EXTERN ares_htable_asvp_t *
+ ares_htable_asvp_create(ares_htable_asvp_val_free_t val_free);
+
+/*! Retrieve an array of keys from the hashtable.
+ *
+ * \param[in] htable Initialized hashtable
+ * \param[out] num Count of returned keys
+ * \return Array of keys in the hashtable. Must be free'd with ares_free().
+ */
+CARES_EXTERN ares_socket_t *
+ ares_htable_asvp_keys(const ares_htable_asvp_t *htable, size_t *num);
+
+
+/*! Insert key/value into hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to associate with value
+ * \param[in] val value to store (takes ownership). May be NULL.
+ * \return ARES_TRUE on success, ARES_FALSE on out of memory or misuse
+ */
+CARES_EXTERN ares_bool_t ares_htable_asvp_insert(ares_htable_asvp_t *htable,
+ ares_socket_t key, void *val);
+
+/*! Retrieve value from hashtable based on key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \param[out] val Optional. Pointer to store value.
+ * \return ARES_TRUE on success, ARES_FALSE on failure
+ */
+CARES_EXTERN ares_bool_t ares_htable_asvp_get(const ares_htable_asvp_t *htable,
+ ares_socket_t key, void **val);
+
+/*! Retrieve value from hashtable directly as return value. Caveat to this
+ * function over ares_htable_asvp_get() is that if a NULL value is stored
+ * you cannot determine if the key is not found or the value is NULL.
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return value associated with key in hashtable or NULL
+ */
+CARES_EXTERN void *ares_htable_asvp_get_direct(const ares_htable_asvp_t *htable,
+ ares_socket_t key);
+
+/*! Remove a value from the hashtable by key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return ARES_TRUE if found, ARES_FALSE if not found
+ */
+CARES_EXTERN ares_bool_t ares_htable_asvp_remove(ares_htable_asvp_t *htable,
+ ares_socket_t key);
+
+/*! Retrieve the number of keys stored in the hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \return count
+ */
+CARES_EXTERN size_t ares_htable_asvp_num_keys(const ares_htable_asvp_t *htable);
+
+/*! @} */
+
+#endif /* __ARES__HTABLE_ASVP_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_htable_dict.h b/contrib/libs/c-ares/src/lib/include/ares_htable_dict.h
new file mode 100644
index 0000000000..cb6f1f048c
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_htable_dict.h
@@ -0,0 +1,123 @@
+/* MIT License
+ *
+ * Copyright (c) 2024 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__HTABLE_DICT_H
+#define __ARES__HTABLE_DICT_H
+
+/*! \addtogroup ares_htable_dict HashTable with case-insensitive string Key and
+ * string value
+ *
+ * This data structure wraps the base ares_htable data structure in order to
+ * split the key and value data types as string and string, respectively.
+ *
+ * Average time complexity:
+ * - Insert: O(1)
+ * - Search: O(1)
+ * - Delete: O(1)
+ *
+ * @{
+ */
+
+struct ares_htable_dict;
+
+/*! Opaque data type for string key, string value hash table
+ * implementation */
+typedef struct ares_htable_dict ares_htable_dict_t;
+
+/*! Destroy hashtable
+ *
+ * \param[in] htable Initialized hashtable
+ */
+CARES_EXTERN void ares_htable_dict_destroy(ares_htable_dict_t *htable);
+
+/*! Create void pointer key, string value hash table
+ *
+ */
+CARES_EXTERN ares_htable_dict_t *ares_htable_dict_create(void);
+
+/*! Insert key/value into hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to associate with value
+ * \param[in] val value to store (duplicates).
+ * \return ARES_TRUE on success, ARES_FALSE on failure or out of memory
+ */
+CARES_EXTERN ares_bool_t ares_htable_dict_insert(ares_htable_dict_t *htable,
+ const char *key,
+ const char *val);
+
+/*! Retrieve value from hashtable based on key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \param[out] val Optional. Pointer to store value.
+ * \return ARES_TRUE on success, ARES_FALSE on failure
+ */
+CARES_EXTERN ares_bool_t ares_htable_dict_get(const ares_htable_dict_t *htable,
+ const char *key,
+ const char **val);
+
+/*! Retrieve value from hashtable directly as return value. Caveat to this
+ * function over ares_htable_dict_get() is that if a NULL value is stored
+ * you cannot determine if the key is not found or the value is NULL.
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return value associated with key in hashtable or NULL
+ */
+CARES_EXTERN const char *
+ ares_htable_dict_get_direct(const ares_htable_dict_t *htable,
+ const char *key);
+
+/*! Remove a value from the hashtable by key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return ARES_TRUE if found, ARES_FALSE if not
+ */
+CARES_EXTERN ares_bool_t ares_htable_dict_remove(ares_htable_dict_t *htable,
+ const char *key);
+
+/*! Retrieve the number of keys stored in the hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \return count
+ */
+CARES_EXTERN size_t ares_htable_dict_num_keys(const ares_htable_dict_t *htable);
+
+/*! Retrieve an array of keys from the hashtable.
+ *
+ * \param[in] htable Initialized hashtable
+ * \param[out] num Count of returned keys
+ * \return Array of keys in the hashtable. Must be free'd with
+ * ares_free_array(strs, num, ares_free);
+ */
+CARES_EXTERN char **ares_htable_dict_keys(const ares_htable_dict_t *htable,
+ size_t *num);
+
+
+/*! @} */
+
+#endif /* __ARES__HTABLE_DICT_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_htable_strvp.h b/contrib/libs/c-ares/src/lib/include/ares_htable_strvp.h
new file mode 100644
index 0000000000..eaaf6d3be0
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_htable_strvp.h
@@ -0,0 +1,130 @@
+/* MIT License
+ *
+ * Copyright (c) 2023 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__HTABLE_STRVP_H
+#define __ARES__HTABLE_STRVP_H
+
+/*! \addtogroup ares_htable_strvp HashTable with string Key and void pointer
+ * Value
+ *
+ * This data structure wraps the base ares_htable data structure in order to
+ * split the key and value data types as string and void pointer, respectively.
+ *
+ * Average time complexity:
+ * - Insert: O(1)
+ * - Search: O(1)
+ * - Delete: O(1)
+ *
+ * @{
+ */
+
+struct ares_htable_strvp;
+
+/*! Opaque data type for size_t key, void pointer hash table implementation */
+typedef struct ares_htable_strvp ares_htable_strvp_t;
+
+/*! Callback to free value stored in hashtable
+ *
+ * \param[in] val user-supplied value
+ */
+typedef void (*ares_htable_strvp_val_free_t)(void *val);
+
+/*! Destroy hashtable
+ *
+ * \param[in] htable Initialized hashtable
+ */
+CARES_EXTERN void ares_htable_strvp_destroy(ares_htable_strvp_t *htable);
+
+/*! Create string, void pointer value hash table
+ *
+ * \param[in] val_free Optional. Call back to free user-supplied value. If
+ * NULL it is expected the caller will clean up any user
+ * supplied values.
+ */
+CARES_EXTERN ares_htable_strvp_t *
+ ares_htable_strvp_create(ares_htable_strvp_val_free_t val_free);
+
+/*! Insert key/value into hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to associate with value
+ * \param[in] val value to store (takes ownership). May be NULL.
+ * \return ARES_TRUE on success, ARES_FALSE on failure or out of memory
+ */
+CARES_EXTERN ares_bool_t ares_htable_strvp_insert(ares_htable_strvp_t *htable,
+ const char *key, void *val);
+
+/*! Retrieve value from hashtable based on key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \param[out] val Optional. Pointer to store value.
+ * \return ARES_TRUE on success, ARES_FALSE on failure
+ */
+CARES_EXTERN ares_bool_t ares_htable_strvp_get(
+ const ares_htable_strvp_t *htable, const char *key, void **val);
+
+/*! Retrieve value from hashtable directly as return value. Caveat to this
+ * function over ares_htable_strvp_get() is that if a NULL value is stored
+ * you cannot determine if the key is not found or the value is NULL.
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return value associated with key in hashtable or NULL
+ */
+CARES_EXTERN void *
+ ares_htable_strvp_get_direct(const ares_htable_strvp_t *htable,
+ const char *key);
+
+/*! Remove a value from the hashtable by key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return ARES_TRUE if found, ARES_FALSE if not
+ */
+CARES_EXTERN ares_bool_t ares_htable_strvp_remove(ares_htable_strvp_t *htable,
+ const char *key);
+
+/*! Remove the value from the hashtable, and return the value instead of
+ * calling the val_free passed to ares_htable_strvp_create().
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return value in hashtable or NULL on error
+ */
+CARES_EXTERN void *ares_htable_strvp_claim(ares_htable_strvp_t *htable,
+ const char *key);
+
+/*! Retrieve the number of keys stored in the hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \return count
+ */
+CARES_EXTERN size_t
+ ares_htable_strvp_num_keys(const ares_htable_strvp_t *htable);
+
+/*! @} */
+
+#endif /* __ARES__HTABLE_STRVP_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_htable_szvp.h b/contrib/libs/c-ares/src/lib/include/ares_htable_szvp.h
new file mode 100644
index 0000000000..927b9a5ec9
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_htable_szvp.h
@@ -0,0 +1,118 @@
+/* MIT License
+ *
+ * Copyright (c) 2023 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__HTABLE_STVP_H
+#define __ARES__HTABLE_STVP_H
+
+/*! \addtogroup ares_htable_szvp HashTable with size_t Key and void pointer
+ * Value
+ *
+ * This data structure wraps the base ares_htable data structure in order to
+ * split the key and value data types as size_t and void pointer, respectively.
+ *
+ * Average time complexity:
+ * - Insert: O(1)
+ * - Search: O(1)
+ * - Delete: O(1)
+ *
+ * @{
+ */
+
+struct ares_htable_szvp;
+
+/*! Opaque data type for size_t key, void pointer hash table implementation */
+typedef struct ares_htable_szvp ares_htable_szvp_t;
+
+/*! Callback to free value stored in hashtable
+ *
+ * \param[in] val user-supplied value
+ */
+typedef void (*ares_htable_szvp_val_free_t)(void *val);
+
+/*! Destroy hashtable
+ *
+ * \param[in] htable Initialized hashtable
+ */
+CARES_EXTERN void ares_htable_szvp_destroy(ares_htable_szvp_t *htable);
+
+/*! Create size_t key, void pointer value hash table
+ *
+ * \param[in] val_free Optional. Call back to free user-supplied value. If
+ * NULL it is expected the caller will clean up any user
+ * supplied values.
+ */
+CARES_EXTERN ares_htable_szvp_t *
+ ares_htable_szvp_create(ares_htable_szvp_val_free_t val_free);
+
+/*! Insert key/value into hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to associate with value
+ * \param[in] val value to store (takes ownership). May be NULL.
+ * \return ARES_TRUE on success, ARES_FALSE on failure or out of memory
+ */
+CARES_EXTERN ares_bool_t ares_htable_szvp_insert(ares_htable_szvp_t *htable,
+ size_t key, void *val);
+
+/*! Retrieve value from hashtable based on key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \param[out] val Optional. Pointer to store value.
+ * \return ARES_TRUE on success, ARES_FALSE on failure
+ */
+CARES_EXTERN ares_bool_t ares_htable_szvp_get(const ares_htable_szvp_t *htable,
+ size_t key, void **val);
+
+/*! Retrieve value from hashtable directly as return value. Caveat to this
+ * function over ares_htable_szvp_get() is that if a NULL value is stored
+ * you cannot determine if the key is not found or the value is NULL.
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return value associated with key in hashtable or NULL
+ */
+CARES_EXTERN void *ares_htable_szvp_get_direct(const ares_htable_szvp_t *htable,
+ size_t key);
+
+/*! Remove a value from the hashtable by key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return ARES_TRUE if found, ARES_FALSE if not
+ */
+CARES_EXTERN ares_bool_t ares_htable_szvp_remove(ares_htable_szvp_t *htable,
+ size_t key);
+
+/*! Retrieve the number of keys stored in the hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \return count
+ */
+CARES_EXTERN size_t ares_htable_szvp_num_keys(const ares_htable_szvp_t *htable);
+
+/*! @} */
+
+#endif /* __ARES__HTABLE_STVP_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_htable_vpstr.h b/contrib/libs/c-ares/src/lib/include/ares_htable_vpstr.h
new file mode 100644
index 0000000000..9f51b87745
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_htable_vpstr.h
@@ -0,0 +1,111 @@
+/* MIT License
+ *
+ * Copyright (c) 2024 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__HTABLE_VPSTR_H
+#define __ARES__HTABLE_VPSTR_H
+
+/*! \addtogroup ares_htable_vpstr HashTable with void pointer Key and string
+ * value
+ *
+ * This data structure wraps the base ares_htable data structure in order to
+ * split the key and value data types as void pointer and string, respectively.
+ *
+ * Average time complexity:
+ * - Insert: O(1)
+ * - Search: O(1)
+ * - Delete: O(1)
+ *
+ * @{
+ */
+
+struct ares_htable_vpstr;
+
+/*! Opaque data type for void pointer key, string value hash table
+ * implementation */
+typedef struct ares_htable_vpstr ares_htable_vpstr_t;
+
+/*! Destroy hashtable
+ *
+ * \param[in] htable Initialized hashtable
+ */
+CARES_EXTERN void ares_htable_vpstr_destroy(ares_htable_vpstr_t *htable);
+
+/*! Create void pointer key, string value hash table
+ *
+ */
+CARES_EXTERN ares_htable_vpstr_t *ares_htable_vpstr_create(void);
+
+/*! Insert key/value into hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to associate with value
+ * \param[in] val value to store (duplicates).
+ * \return ARES_TRUE on success, ARES_FALSE on failure or out of memory
+ */
+CARES_EXTERN ares_bool_t ares_htable_vpstr_insert(ares_htable_vpstr_t *htable,
+ void *key, const char *val);
+
+/*! Retrieve value from hashtable based on key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \param[out] val Optional. Pointer to store value.
+ * \return ARES_TRUE on success, ARES_FALSE on failure
+ */
+CARES_EXTERN ares_bool_t ares_htable_vpstr_get(
+ const ares_htable_vpstr_t *htable, const void *key, const char **val);
+
+/*! Retrieve value from hashtable directly as return value. Caveat to this
+ * function over ares_htable_vpstr_get() is that if a NULL value is stored
+ * you cannot determine if the key is not found or the value is NULL.
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return value associated with key in hashtable or NULL
+ */
+CARES_EXTERN const char *
+ ares_htable_vpstr_get_direct(const ares_htable_vpstr_t *htable,
+ const void *key);
+
+/*! Remove a value from the hashtable by key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return ARES_TRUE if found, ARES_FALSE if not
+ */
+CARES_EXTERN ares_bool_t ares_htable_vpstr_remove(ares_htable_vpstr_t *htable,
+ const void *key);
+
+/*! Retrieve the number of keys stored in the hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \return count
+ */
+CARES_EXTERN size_t
+ ares_htable_vpstr_num_keys(const ares_htable_vpstr_t *htable);
+
+/*! @} */
+
+#endif /* __ARES__HTABLE_VPSTR_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_htable_vpvp.h b/contrib/libs/c-ares/src/lib/include/ares_htable_vpvp.h
new file mode 100644
index 0000000000..1ebe614576
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_htable_vpvp.h
@@ -0,0 +1,128 @@
+/* MIT License
+ *
+ * Copyright (c) 2024 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__HTABLE_VPVP_H
+#define __ARES__HTABLE_VPVP_H
+
+/*! \addtogroup ares_htable_vpvp HashTable with void pointer Key and void
+ * pointer Value
+ *
+ * This data structure wraps the base ares_htable data structure in order to
+ * split the key and value data types as size_t and void pointer, respectively.
+ *
+ * Average time complexity:
+ * - Insert: O(1)
+ * - Search: O(1)
+ * - Delete: O(1)
+ *
+ * @{
+ */
+
+struct ares_htable_vpvp;
+
+/*! Opaque data type for size_t key, void pointer hash table implementation */
+typedef struct ares_htable_vpvp ares_htable_vpvp_t;
+
+/*! Callback to free key stored in hashtable
+ *
+ * \param[in] key user-supplied key
+ */
+typedef void (*ares_htable_vpvp_key_free_t)(void *key);
+
+/*! Callback to free value stored in hashtable
+ *
+ * \param[in] val user-supplied value
+ */
+typedef void (*ares_htable_vpvp_val_free_t)(void *val);
+
+/*! Destroy hashtable
+ *
+ * \param[in] htable Initialized hashtable
+ */
+CARES_EXTERN void ares_htable_vpvp_destroy(ares_htable_vpvp_t *htable);
+
+/*! Create size_t key, void pointer value hash table
+ *
+ * \param[in] key_free Optional. Call back to free user-supplied key. If
+ * NULL it is expected the caller will clean up any user
+ * supplied keys.
+ * \param[in] val_free Optional. Call back to free user-supplied value. If
+ * NULL it is expected the caller will clean up any user
+ * supplied values.
+ */
+CARES_EXTERN ares_htable_vpvp_t *
+ ares_htable_vpvp_create(ares_htable_vpvp_key_free_t key_free,
+ ares_htable_vpvp_val_free_t val_free);
+
+/*! Insert key/value into hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to associate with value
+ * \param[in] val value to store (takes ownership). May be NULL.
+ * \return ARES_TRUE on success, ARES_FALSE on failure or out of memory
+ */
+CARES_EXTERN ares_bool_t ares_htable_vpvp_insert(ares_htable_vpvp_t *htable,
+ void *key, void *val);
+
+/*! Retrieve value from hashtable based on key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \param[out] val Optional. Pointer to store value.
+ * \return ARES_TRUE on success, ARES_FALSE on failure
+ */
+CARES_EXTERN ares_bool_t ares_htable_vpvp_get(const ares_htable_vpvp_t *htable,
+ const void *key, void **val);
+
+/*! Retrieve value from hashtable directly as return value. Caveat to this
+ * function over ares_htable_vpvp_get() is that if a NULL value is stored
+ * you cannot determine if the key is not found or the value is NULL.
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return value associated with key in hashtable or NULL
+ */
+CARES_EXTERN void *ares_htable_vpvp_get_direct(const ares_htable_vpvp_t *htable,
+ const void *key);
+
+/*! Remove a value from the hashtable by key
+ *
+ * \param[in] htable Initialized hash table
+ * \param[in] key key to use to search
+ * \return ARES_TRUE if found, ARES_FALSE if not
+ */
+CARES_EXTERN ares_bool_t ares_htable_vpvp_remove(ares_htable_vpvp_t *htable,
+ const void *key);
+
+/*! Retrieve the number of keys stored in the hash table
+ *
+ * \param[in] htable Initialized hash table
+ * \return count
+ */
+CARES_EXTERN size_t ares_htable_vpvp_num_keys(const ares_htable_vpvp_t *htable);
+
+/*! @} */
+
+#endif /* __ARES__HTABLE_VPVP_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_llist.h b/contrib/libs/c-ares/src/lib/include/ares_llist.h
new file mode 100644
index 0000000000..6aa0c78370
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_llist.h
@@ -0,0 +1,239 @@
+/* MIT License
+ *
+ * Copyright (c) 2023 Brad House
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES__LLIST_H
+#define __ARES__LLIST_H
+
+/*! \addtogroup ares_llist LinkedList Data Structure
+ *
+ * This is a doubly-linked list data structure.
+ *
+ * Average time complexity:
+ * - Insert: O(1) -- head or tail
+ * - Search: O(n)
+ * - Delete: O(1) -- delete assumes you hold a node pointer
+ *
+ * @{
+ */
+
+struct ares_llist;
+
+/*! Opaque data structure for linked list */
+typedef struct ares_llist ares_llist_t;
+
+struct ares_llist_node;
+
+/*! Opaque data structure for a node in a linked list */
+typedef struct ares_llist_node ares_llist_node_t;
+
+/*! Callback to free user-defined node data
+ *
+ * \param[in] data user supplied data
+ */
+typedef void (*ares_llist_destructor_t)(void *data);
+
+/*! Create a linked list object
+ *
+ * \param[in] destruct Optional. Destructor to call on all removed nodes
+ * \return linked list object or NULL on out of memory
+ */
+CARES_EXTERN ares_llist_t *ares_llist_create(ares_llist_destructor_t destruct);
+
+/*! Replace destructor for linked list nodes. Typically this is used
+ * when wanting to disable the destructor by using NULL.
+ *
+ * \param[in] list Initialized linked list object
+ * \param[in] destruct replacement destructor, NULL is allowed
+ */
+CARES_EXTERN void
+ ares_llist_replace_destructor(ares_llist_t *list,
+ ares_llist_destructor_t destruct);
+
+/*! Insert value as the first node in the linked list
+ *
+ * \param[in] list Initialized linked list object
+ * \param[in] val user-supplied value.
+ * \return node object referencing place in list, or null if out of memory or
+ * misuse
+ */
+CARES_EXTERN ares_llist_node_t *ares_llist_insert_first(ares_llist_t *list,
+ void *val);
+
+/*! Insert value as the last node in the linked list
+ *
+ * \param[in] list Initialized linked list object
+ * \param[in] val user-supplied value.
+ * \return node object referencing place in list, or null if out of memory or
+ * misuse
+ */
+CARES_EXTERN ares_llist_node_t *ares_llist_insert_last(ares_llist_t *list,
+ void *val);
+
+/*! Insert value before specified node in the linked list
+ *
+ * \param[in] node node referenced to insert before
+ * \param[in] val user-supplied value.
+ * \return node object referencing place in list, or null if out of memory or
+ * misuse
+ */
+CARES_EXTERN ares_llist_node_t *
+ ares_llist_insert_before(ares_llist_node_t *node, void *val);
+
+/*! Insert value after specified node in the linked list
+ *
+ * \param[in] node node referenced to insert after
+ * \param[in] val user-supplied value.
+ * \return node object referencing place in list, or null if out of memory or
+ * misuse
+ */
+CARES_EXTERN ares_llist_node_t *ares_llist_insert_after(ares_llist_node_t *node,
+ void *val);
+
+/*! Obtain first node in list
+ *
+ * \param[in] list Initialized list object
+ * \return first node in list or NULL if none
+ */
+CARES_EXTERN ares_llist_node_t *ares_llist_node_first(ares_llist_t *list);
+
+/*! Obtain last node in list
+ *
+ * \param[in] list Initialized list object
+ * \return last node in list or NULL if none
+ */
+CARES_EXTERN ares_llist_node_t *ares_llist_node_last(ares_llist_t *list);
+
+/*! Obtain a node based on its index. This is an O(n) operation.
+ *
+ * \param[in] list Initialized list object
+ * \param[in] idx Index of node to retrieve
+ * \return node at index or NULL if invalid index
+ */
+CARES_EXTERN ares_llist_node_t *ares_llist_node_idx(ares_llist_t *list,
+ size_t idx);
+
+/*! Obtain next node in respect to specified node
+ *
+ * \param[in] node Node referenced
+ * \return node or NULL if none
+ */
+CARES_EXTERN ares_llist_node_t *ares_llist_node_next(ares_llist_node_t *node);
+
+/*! Obtain previous node in respect to specified node
+ *
+ * \param[in] node Node referenced
+ * \return node or NULL if none
+ */
+CARES_EXTERN ares_llist_node_t *ares_llist_node_prev(ares_llist_node_t *node);
+
+
+/*! Obtain value from node
+ *
+ * \param[in] node Node referenced
+ * \return user provided value from node
+ */
+CARES_EXTERN void *ares_llist_node_val(ares_llist_node_t *node);
+
+/*! Obtain the number of entries in the list
+ *
+ * \param[in] list Initialized list object
+ * \return count
+ */
+CARES_EXTERN size_t ares_llist_len(const ares_llist_t *list);
+
+/*! Clear all entries in the list, but don't destroy the list object.
+ *
+ * \param[in] list Initialized list object
+ */
+CARES_EXTERN void ares_llist_clear(ares_llist_t *list);
+
+/*! Obtain list object from referenced node
+ *
+ * \param[in] node Node referenced
+ * \return list object node belongs to
+ */
+CARES_EXTERN ares_llist_t *ares_llist_node_parent(ares_llist_node_t *node);
+
+/*! Obtain the first user-supplied value in the list
+ *
+ * \param[in] list Initialized list object
+ * \return first user supplied value or NULL if none
+ */
+CARES_EXTERN void *ares_llist_first_val(ares_llist_t *list);
+
+/*! Obtain the last user-supplied value in the list
+ *
+ * \param[in] list Initialized list object
+ * \return last user supplied value or NULL if none
+ */
+CARES_EXTERN void *ares_llist_last_val(ares_llist_t *list);
+
+/*! Take ownership of user-supplied value in list without calling destructor.
+ * Will unchain entry from list.
+ *
+ * \param[in] node Node referenced
+ * \return user supplied value
+ */
+CARES_EXTERN void *ares_llist_node_claim(ares_llist_node_t *node);
+
+/*! Replace user-supplied value for node
+ *
+ * \param[in] node Node referenced
+ * \param[in] val new user-supplied value
+ */
+CARES_EXTERN void ares_llist_node_replace(ares_llist_node_t *node, void *val);
+
+/*! Destroy the node, removing it from the list and calling destructor.
+ *
+ * \param[in] node Node referenced
+ */
+CARES_EXTERN void ares_llist_node_destroy(ares_llist_node_t *node);
+
+/*! Destroy the list object and all nodes in the list.
+ *
+ * \param[in] list Initialized list object
+ */
+CARES_EXTERN void ares_llist_destroy(ares_llist_t *list);
+
+/*! Detach node from the current list and re-attach it to the new list as the
+ * last entry.
+ *
+ * \param[in] node node to move
+ * \param[in] new_parent new list
+ */
+CARES_EXTERN void ares_llist_node_mvparent_last(ares_llist_node_t *node,
+ ares_llist_t *new_parent);
+
+/*! Detach node from the current list and re-attach it to the new list as the
+ * first entry.
+ *
+ * \param[in] node node to move
+ * \param[in] new_parent new list
+ */
+CARES_EXTERN void ares_llist_node_mvparent_first(ares_llist_node_t *node,
+ ares_llist_t *new_parent);
+/*! @} */
+
+#endif /* __ARES__LLIST_H */
diff --git a/contrib/libs/c-ares/src/lib/include/ares_mem.h b/contrib/libs/c-ares/src/lib/include/ares_mem.h
new file mode 100644
index 0000000000..371cd4266d
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_mem.h
@@ -0,0 +1,38 @@
+/* MIT License
+ *
+ * Copyright (c) The c-ares project and its contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef __ARES_MEM_H
+#define __ARES_MEM_H
+
+/* Memory management functions */
+CARES_EXTERN void *ares_malloc(size_t size);
+CARES_EXTERN void *ares_realloc(void *ptr, size_t size);
+CARES_EXTERN void ares_free(void *ptr);
+CARES_EXTERN void *ares_malloc_zero(size_t size);
+CARES_EXTERN void *ares_realloc_zero(void *ptr, size_t orig_size,
+ size_t new_size);
+
+#endif
diff --git a/contrib/libs/c-ares/src/lib/include/ares_str.h b/contrib/libs/c-ares/src/lib/include/ares_str.h
new file mode 100644
index 0000000000..ea75b3b3e7
--- /dev/null
+++ b/contrib/libs/c-ares/src/lib/include/ares_str.h
@@ -0,0 +1,230 @@
+/* MIT License
+ *
+ * Copyright (c) 1998 Massachusetts Institute of Technology
+ * Copyright (c) The c-ares project and its contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef __ARES_STR_H
+#define __ARES_STR_H
+
+CARES_EXTERN char *ares_strdup(const char *s1);
+
+CARES_EXTERN size_t ares_strlen(const char *str);
+
+/*! Copy string from source to destination with destination buffer size
+ * provided. The destination is guaranteed to be null terminated, if the
+ * provided buffer isn't large enough, only those bytes from the source that
+ * will fit will be copied.
+ *
+ * \param[out] dest Destination buffer
+ * \param[in] src Source to copy
+ * \param[in] dest_size Size of destination buffer
+ * \return String length. Will be at most dest_size-1
+ */
+CARES_EXTERN size_t ares_strcpy(char *dest, const char *src, size_t dest_size);
+
+CARES_EXTERN ares_bool_t ares_str_isnum(const char *str);
+CARES_EXTERN ares_bool_t ares_str_isalnum(const char *str);
+
+CARES_EXTERN void ares_str_ltrim(char *str);
+CARES_EXTERN void ares_str_rtrim(char *str);
+CARES_EXTERN void ares_str_trim(char *str);
+CARES_EXTERN void ares_str_lower(char *str);
+
+CARES_EXTERN unsigned char ares_tolower(unsigned char c);
+CARES_EXTERN unsigned char *ares_memmem(const unsigned char *big,
+ size_t big_len,
+ const unsigned char *little,
+ size_t little_len);
+CARES_EXTERN ares_bool_t ares_memeq(const unsigned char *ptr,
+ const unsigned char *val, size_t len);
+CARES_EXTERN ares_bool_t ares_memeq_ci(const unsigned char *ptr,
+ const unsigned char *val, size_t len);
+CARES_EXTERN ares_bool_t ares_is_hostname(const char *str);
+
+/*! Validate the string provided is printable. The length specified must be
+ * at least the size of the buffer provided. If a NULL-terminator is hit
+ * before the length provided is hit, this will not be considered a valid
+ * printable string. This does not validate that the string is actually
+ * NULL terminated.
+ *
+ * \param[in] str Buffer containing string to evaluate.
+ * \param[in] len Number of characters to evaluate within provided buffer.
+ * If 0, will return TRUE since it did not hit an exception.
+ * \return ARES_TRUE if the entire string is printable, ARES_FALSE if not.
+ */
+CARES_EXTERN ares_bool_t ares_str_isprint(const char *str, size_t len);
+
+/* We only care about ASCII rules */
+#define ares_isascii(x) (((unsigned char)x) <= 127)
+
+#define ares_isdigit(x) (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9')
+
+#define ares_isxdigit(x) \
+ (ares_isdigit(x) || \
+ (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'f') || \
+ (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'F'))
+
+#define ares_isupper(x) (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'Z')
+
+#define ares_islower(x) (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'z')
+
+#define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
+
+#define ares_isspace(x) \
+ (((unsigned char)(x)) == '\r' || ((unsigned char)(x)) == '\t' || \
+ ((unsigned char)(x)) == ' ' || ((unsigned char)(x)) == '\v' || \
+ ((unsigned char)(x)) == '\f' || ((unsigned char)(x)) == '\n')
+
+#define ares_isprint(x) \
+ (((unsigned char)(x)) >= 0x20 && ((unsigned char)(x)) <= 0x7E)
+
+/* Character set allowed by hostnames. This is to include the normal
+ * domain name character set plus:
+ * - underscores which are used in SRV records.
+ * - Forward slashes such as are used for classless in-addr.arpa
+ * delegation (CNAMEs)
+ * - Asterisks may be used for wildcard domains in CNAMEs as seen in the
+ * real world.
+ * While RFC 2181 section 11 does state not to do validation,
+ * that applies to servers, not clients. Vulnerabilities have been
+ * reported when this validation is not performed. Security is more
+ * important than edge-case compatibility (which is probably invalid
+ * anyhow).
+ * [A-Za-z0-9-*._/]
+ */
+#define ares_is_hostnamech(x) \
+ (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
+ ((unsigned char)(x)) == '.' || ((unsigned char)(x)) == '_' || \
+ ((unsigned char)(x)) == '/' || ((unsigned char)(x)) == '*')
+
+
+/*! Compare two strings (for sorting)
+ *
+ * Treats NULL and "" strings as equivalent
+ *
+ * \param[in] a First String
+ * \param[in] b Second String
+ * \return < 0 if First String less than Second String,
+ * 0 if First String equal to Second String,
+ * > 0 if First String greater than Second String
+ */
+CARES_EXTERN int ares_strcmp(const char *a, const char *b);
+
+/*! Compare two strings up to specified length (for sorting)
+ *
+ * Treats NULL and "" strings as equivalent
+ *
+ * \param[in] a First String
+ * \param[in] b Second String
+ * \param[in] n Length
+ * \return < 0 if First String less than Second String,
+ * 0 if First String equal to Second String,
+ * > 0 if First String greater than Second String
+ */
+CARES_EXTERN int ares_strncmp(const char *a, const char *b, size_t n);
+
+
+/*! Compare two strings in a case-insensitive manner (for sorting)
+ *
+ * Treats NULL and "" strings as equivalent
+ *
+ * \param[in] a First String
+ * \param[in] b Second String
+ * \return < 0 if First String less than Second String,
+ * 0 if First String equal to Second String,
+ * > 0 if First String greater than Second String
+ */
+CARES_EXTERN int ares_strcasecmp(const char *a, const char *b);
+
+/*! Compare two strings in a case-insensitive manner up to specified length
+ * (for sorting)
+ *
+ * Treats NULL and "" strings as equivalent
+ *
+ * \param[in] a First String
+ * \param[in] b Second String
+ * \param[in] n Length
+ * \return < 0 if First String less than Second String,
+ * 0 if First String equal to Second String,
+ * > 0 if First String greater than Second String
+ */
+CARES_EXTERN int ares_strncasecmp(const char *a, const char *b, size_t n);
+
+/*! Compare two strings for equality
+ *
+ * Treats NULL and "" strings as equivalent
+ *
+ * \param[in] a First String
+ * \param[in] b Second String
+ * \return ARES_TRUE on match, or ARES_FALSE if no match
+ */
+CARES_EXTERN ares_bool_t ares_streq(const char *a, const char *b);
+
+/*! Compare two strings for equality up to specified length
+ *
+ * Treats NULL and "" strings as equivalent
+ *
+ * \param[in] a First String
+ * \param[in] b Second String
+ * \param[in] n Length
+ * \return ARES_TRUE on match, or ARES_FALSE if no match
+ */
+CARES_EXTERN ares_bool_t ares_streq_max(const char *a, const char *b, size_t n);
+
+/*! Compare two strings for equality in a case insensitive manner
+ *
+ * Treats NULL and "" strings as equivalent
+ *
+ * \param[in] a First String
+ * \param[in] b Second String
+ * \return ARES_TRUE on match, or ARES_FALSE if no match
+ */
+CARES_EXTERN ares_bool_t ares_strcaseeq(const char *a, const char *b);
+
+/*! Compare two strings for equality up to specified length in a case
+ * insensitive manner
+ *
+ * Treats NULL and "" strings as equivalent
+ *
+ * \param[in] a First String
+ * \param[in] b Second String
+ * \param[in] n Length
+ * \return ARES_TRUE on match, or ARES_FALSE if no match
+ */
+CARES_EXTERN ares_bool_t ares_strcaseeq_max(const char *a, const char *b,
+ size_t n);
+
+/*! Free a C array, each element in the array will be freed by the provided
+ * free function. Both NULL-terminated arrays and known length arrays are
+ * supported.
+ *
+ * \param[in] arr Array to be freed.
+ * \param[in] nmembers Number of members in the array, or SIZE_MAX for
+ * NULL-terminated arrays
+ * \param[in] freefunc Function to call on each array member (e.g. ares_free)
+ */
+CARES_EXTERN void ares_free_array(void *arr, size_t nmembers,
+ void (*freefunc)(void *));
+
+#endif /* __ARES_STR_H */