Functions for handling character arrays. More...
Go to the source code of this file.
Macros | |
| #define | QSC_ARRAYTILS_NPOS -1LL |
| The constant return value indicating that a search token was not found. | |
Functions | |
| QSC_EXPORT_API size_t | qsc_arrayutils_find_string (const char *str, size_t slen, const char *token) |
| Find the first instance of a token in a string. | |
| QSC_EXPORT_API uint8_t | qsc_arrayutils_hex_to_uint8 (const char *str, size_t slen) |
| Convert a hexadecimal encoded string to an 8-bit unsigned integer. | |
| QSC_EXPORT_API void | qsc_arrayutils_uint8_to_hex (char *output, size_t otplen, uint8_t value) |
| Convert an 8-bit unsigned integer to a hexadecimal string. | |
| QSC_EXPORT_API void | qsc_arrayutils_uint16_to_hex (char *output, size_t otplen, uint16_t value) |
| Convert a 16-bit unsigned integer to a hexadecimal string. | |
| QSC_EXPORT_API void | qsc_arrayutils_uint32_to_hex (char *output, size_t otplen, uint32_t value) |
| Convert a 32-bit unsigned integer to a hexadecimal string. | |
| QSC_EXPORT_API void | qsc_arrayutils_uint64_to_hex (char *output, size_t otplen, uint64_t value) |
| Convert a 64-bit unsigned integer to a hexadecimal string. | |
| QSC_EXPORT_API uint8_t | qsc_arrayutils_string_to_uint8 (const char *str, size_t slen) |
| Parse an 8-bit unsigned integer from a string. | |
| QSC_EXPORT_API uint16_t | qsc_arrayutils_string_to_uint16 (const char *str, size_t slen) |
| Parse a 16-bit unsigned integer from a string. | |
| QSC_EXPORT_API uint32_t | qsc_arrayutils_string_to_uint32 (const char *str, size_t slen) |
| Parse a 32-bit unsigned integer from a string. | |
| QSC_EXPORT_API uint64_t | qsc_arrayutils_string_to_uint64 (const char *str, size_t slen) |
| Parse a 64-bit unsigned integer from a string. | |
| QSC_EXPORT_API bool | qsc_arrayutils_self_test (void) |
| Perform a self-test of the array utilities. | |
Functions for handling character arrays.
This header provides a collection of utility functions for performing common operations on character arrays. The functions support tasks such as:
These operations are critical for data formatting, debugging, and preparing string data for cryptographic processing.
| #define QSC_ARRAYTILS_NPOS -1LL |
The constant return value indicating that a search token was not found.
This value is returned by qsc_arrayutils_find_string when the token cannot be located.
| QSC_EXPORT_API size_t qsc_arrayutils_find_string | ( | const char * | str, |
| size_t | slen, | ||
| const char * | token ) |
Find the first instance of a token in a string.
Searches for the first occurrence of a given token within a string and returns the zero-based character position. If the token is not found, the function returns QSC_ARRAYTILS_NPOS.
| str | [const char*] Pointer to the constant character string to be searched. |
| slen | [size_t] The length of the string in bytes (excluding the null terminator). |
| token | [const char*] Pointer to the constant token string to search for. |
| QSC_EXPORT_API uint8_t qsc_arrayutils_hex_to_uint8 | ( | const char * | str, |
| size_t | slen ) |
Convert a hexadecimal encoded string to an 8-bit unsigned integer.
Reads up to two hexadecimal characters from the input string and converts them into the corresponding uint8_t value.
| str | [const char*] Pointer to the constant hexadecimal string. |
| slen | [size_t] The length of the string in bytes (excluding the null terminator). |
| QSC_EXPORT_API bool qsc_arrayutils_self_test | ( | void | ) |
Perform a self-test of the array utilities.
Runs a series of tests to validate the correctness of the functions in this module.
true if all tests pass; otherwise false. | QSC_EXPORT_API uint16_t qsc_arrayutils_string_to_uint16 | ( | const char * | str, |
| size_t | slen ) |
Parse a 16-bit unsigned integer from a string.
Reads the input string and converts it to a uint16_t value.
| str | [const char*] Pointer to the constant character string containing the number. |
| slen | [size_t] The length of the string in bytes (excluding the null terminator). |
| QSC_EXPORT_API uint32_t qsc_arrayutils_string_to_uint32 | ( | const char * | str, |
| size_t | slen ) |
Parse a 32-bit unsigned integer from a string.
Reads the input string and converts it to a uint32_t value.
| str | [const char*] Pointer to the constant character string containing the number. |
| slen | [size_t] The length of the string in bytes (excluding the null terminator). |
| QSC_EXPORT_API uint64_t qsc_arrayutils_string_to_uint64 | ( | const char * | str, |
| size_t | slen ) |
Parse a 64-bit unsigned integer from a string.
Reads the input string and converts it to a uint64_t value.
| str | [const char*] Pointer to the constant character string containing the number. |
| slen | [size_t] The length of the string in bytes (excluding the null terminator). |
| QSC_EXPORT_API uint8_t qsc_arrayutils_string_to_uint8 | ( | const char * | str, |
| size_t | slen ) |
Parse an 8-bit unsigned integer from a string.
Reads the input string and converts it to a uint8_t value.
| str | [const char*] Pointer to the constant character string containing the number. |
| slen | [size_t] The length of the string in bytes (excluding the null terminator). |
| QSC_EXPORT_API void qsc_arrayutils_uint16_to_hex | ( | char * | output, |
| size_t | otplen, | ||
| uint16_t | value ) |
Convert a 16-bit unsigned integer to a hexadecimal string.
Converts the given uint16_t value into a four-digit hexadecimal representation, writing the result to the provided output buffer.
| output | [char*] Pointer to the output character array. |
| otplen | [size_t] The length of the output buffer in bytes. |
| value | [uint16_t] The 16-bit unsigned integer to convert. |
| QSC_EXPORT_API void qsc_arrayutils_uint32_to_hex | ( | char * | output, |
| size_t | otplen, | ||
| uint32_t | value ) |
Convert a 32-bit unsigned integer to a hexadecimal string.
Converts the given uint32_t value into an eight-digit hexadecimal representation, writing the result to the provided output buffer.
| output | [char*] Pointer to the output character array. |
| otplen | [size_t] The length of the output buffer in bytes. |
| value | [uint32_t] The 32-bit unsigned integer to convert. |
| QSC_EXPORT_API void qsc_arrayutils_uint64_to_hex | ( | char * | output, |
| size_t | otplen, | ||
| uint64_t | value ) |
Convert a 64-bit unsigned integer to a hexadecimal string.
Converts the given uint64_t value into a sixteen-digit hexadecimal representation, writing the result to the provided output buffer.
| output | [char*] Pointer to the output character array. |
| otplen | [size_t] The length of the output buffer in bytes. |
| value | [uint64_t] The 64-bit unsigned integer to convert. |
| QSC_EXPORT_API void qsc_arrayutils_uint8_to_hex | ( | char * | output, |
| size_t | otplen, | ||
| uint8_t | value ) |
Convert an 8-bit unsigned integer to a hexadecimal string.
Converts the given uint8_t value into a two-digit hexadecimal representation, writing the result to the provided output buffer.
| output | [char*] Pointer to the output character array. |
| otplen | [size_t] The length of the output buffer in bytes. |
| value | [uint8_t] The 8-bit unsigned integer to convert. |