#include <stdint.h>
Go to the source code of this file.
|
int16_t | GEN_get_index_of_substring_in_array (const char *haystack_arr, int16_t haystack_arr_len, const char *needle_str) |
| Returns the index of the first character of the first occurrence of a substring in an array.
|
|
int16_t | GEN_get_index_of_subarray_in_array (const uint8_t *haystack_arr, int16_t haystack_arr_len, const uint8_t *needle_arr, int16_t needle_arr_len) |
| Returns the index of the first element of the first occurrence of a sub-array in an array.
|
|
void | GEN_uint64_to_str (uint64_t value, char *buffer) |
| Converts a uint64_t to a string.
|
|
void | GEN_uint64_to_padded_str (uint64_t value, uint8_t padding_len, char *buffer) |
| Converts a uint64_t to a string, with leading zeros.
|
|
void | GEN_int64_to_str (int64_t value, char *buffer) |
| Converts an int64_t to a string.
|
|
uint8_t | GEN_hex_str_to_byte_array (const char *hex_str, uint8_t output_byte_array[], uint16_t output_byte_array_size, uint16_t *output_byte_array_len) |
| Converts a hex string to a byte array.
|
|
void | GEN_byte_array_to_hex_str (const uint8_t *byte_array, uint32_t byte_array_len, char *dest_str, uint32_t dest_str_size) |
| Writes a byte array to a hex string (no spaces between bytes).
|
|
◆ GEN_byte_array_to_hex_str()
void GEN_byte_array_to_hex_str |
( |
const uint8_t * | byte_array, |
|
|
uint32_t | byte_array_len, |
|
|
char * | dest_str, |
|
|
uint32_t | dest_str_size ) |
Writes a byte array to a hex string (no spaces between bytes).
- Parameters
-
byte_array | Input byte array. |
byte_array_len | Length of input byte_array . |
dest_str | The destination to write a C-string to. |
dest_str_size | The size of the dest_str array, allocated before calling. Must be at least byte_array_len * 3 + 1 to fit the entire string. |
◆ GEN_get_index_of_subarray_in_array()
int16_t GEN_get_index_of_subarray_in_array |
( |
const uint8_t * | haystack_arr, |
|
|
int16_t | haystack_arr_len, |
|
|
const uint8_t * | needle_arr, |
|
|
int16_t | needle_arr_len ) |
Returns the index of the first element of the first occurrence of a sub-array in an array.
- Parameters
-
haystack_arr | The array to search within. |
haystack_arr_len | The length of the array to search within. |
needle_arr | The substring/sub-array to search for. |
needle_arr_len | The length of the substring/sub-array to search for. |
- Returns
- The index of the start of the first occurrence of the substring in the array, or -1 if not found
◆ GEN_get_index_of_substring_in_array()
int16_t GEN_get_index_of_substring_in_array |
( |
const char * | haystack_arr, |
|
|
int16_t | haystack_arr_len, |
|
|
const char * | needle_str ) |
Returns the index of the first character of the first occurrence of a substring in an array.
- Parameters
-
haystack_arr | The array to search within. |
haystack_arr_len | The length of the array to search within. |
needle_str | The substring to search for. Must be a null-terminated C-string. |
- Returns
- The index of the start of the first occurrence of the needle_str in the array, or -1 if not found
◆ GEN_hex_str_to_byte_array()
uint8_t GEN_hex_str_to_byte_array |
( |
const char * | hex_str, |
|
|
uint8_t | output_byte_array[], |
|
|
uint16_t | output_byte_array_size, |
|
|
uint16_t * | output_byte_array_len ) |
Converts a hex string to a byte array.
- Parameters
-
hex_str | The input hex string. Can be upper or lower case. Can contain spaces and underscores between bytes. |
output_byte_array | Pointer to the output destination byte array. |
output_byte_array_size | Maximum size of the output byte array. |
output_byte_array_len | Pointer to the output variable that will be set to the length of the output byte array. |
- Returns
- 0 if successful, >0 for error
- Note
- Delimiters between bytes are ignored, but delimiters within a byte are not allowed.
◆ GEN_int64_to_str()
void GEN_int64_to_str |
( |
int64_t | value, |
|
|
char * | buffer ) |
Converts an int64_t to a string.
- Parameters
-
value | The input value to convert. |
buffer | The output buffer to write the string to. MUST BE AT LEAST 21 BYTES LONG. |
◆ GEN_uint64_to_padded_str()
void GEN_uint64_to_padded_str |
( |
uint64_t | value, |
|
|
uint8_t | padding_len, |
|
|
char * | buffer ) |
Converts a uint64_t to a string, with leading zeros.
- Parameters
-
value | The input value to convert. |
padding_len | The expected length of the output string. |
buffer | The output buffer to write the string to. Must be padding_len bytes long. |
◆ GEN_uint64_to_str()
void GEN_uint64_to_str |
( |
uint64_t | value, |
|
|
char * | buffer ) |
Converts a uint64_t to a string.
- Parameters
-
value | The input value to convert. |
buffer | The output buffer to write the string to. MUST BE AT LEAST 21 BYTES LONG. |