String utility module header file. More...
#include "mcl_core/mcl_core_common.h"
Go to the source code of this file.
Functions | |
MCL_LOCAL mcl_size_t | string_util_strlen (const char *buffer) |
MCL_LOCAL mcl_size_t | string_util_strnlen (const char *buffer, mcl_size_t maximum_length) |
MCL_LOCAL void | string_util_strncpy (char *destination, const char *source, mcl_size_t count) |
MCL_LOCAL void | string_util_strncat (char *destination, const char *source, mcl_size_t count) |
MCL_LOCAL mcl_error_t | string_util_strncmp (const char *string_1, const char *string_2, mcl_size_t count) |
MCL_LOCAL mcl_error_t | string_util_snprintf (char *string, mcl_size_t length, const char *format,...) |
MCL_LOCAL mcl_bool_t | string_util_memcmp (const void *block_1, const void *block_2, mcl_size_t count) |
MCL_LOCAL void | string_util_memcpy (void *destination, const void *source, mcl_size_t count) |
MCL_LOCAL void | string_util_memset (void *destination, mcl_uint8_t value, mcl_size_t count) |
MCL_LOCAL char * | string_util_strdup (const char *string) |
MCL_LOCAL mcl_bool_t | string_util_find (const char *source, const char *target, mcl_size_t *start_index) |
MCL_LOCAL mcl_bool_t | string_util_find_case_insensitive (const char *source, const char *target, mcl_size_t *start_index) |
MCL_LOCAL long | string_util_strtol (const char *source, int base, char **end_pointer) |
MCL_LOCAL mcl_error_t | string_util_reset (const void *value, char **target) |
MCL_LOCAL mcl_error_t | string_util_concatenate (const char *string_1, const char *string_2, char **result) |
String utility module header file.
Definition in file string_util.h.
MCL_LOCAL mcl_error_t string_util_concatenate | ( | const char * | string_1, |
const char * | string_2, | ||
char ** | result | ||
) |
Initializes a new result
by concatenating the given string_1
and string_2.
[in] | string_1 | Char array to which the string_2 will be concatenated. |
[in] | string_2 | Char array which will be concatenated to string_1 . |
[out] | result | The string that is result of the concatenation. |
Definition at line 467 of file string_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR_SIZE, MCL_OK, MCL_OUT_OF_MEMORY, string_util_memcpy(), and string_util_strlen().
Referenced by _compose_access_token_request_payload(), core_processor_initialize(), and mcl_string_util_concatenate().
MCL_LOCAL mcl_bool_t string_util_find | ( | const char * | source, |
const char * | target, | ||
mcl_size_t * | start_index | ||
) |
Finds the first occurence of target
in source
and puts it's first index to start_index
.
[in] | source | Null terminated string to be searched in. |
[in] | target | Null terminated string to be searched for. |
[out] | start_index | Index of the first character of target if source contains it. |
target
is found then MCL_TRUE, otherwise MCL_FALSE. Definition at line 308 of file string_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FALSE, MCL_TRUE, and string_util_strlen().
Referenced by mcl_http_response_get_header(), and mcl_string_util_find().
MCL_LOCAL mcl_bool_t string_util_find_case_insensitive | ( | const char * | source, |
const char * | target, | ||
mcl_size_t * | start_index | ||
) |
Finds the first occurence of target
in source
and puts it's first index to start_index
.
[in] | source | Null terminated string to be searched in. |
[in] | target | Null terminated string to be searched for. |
[out] | start_index | Index of the first character of target if source contains it. |
target
is found then MCL_TRUE, otherwise MCL_FALSE. Definition at line 357 of file string_util.c.
References LOWERCASE, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FALSE, MCL_TRUE, and string_util_strlen().
Referenced by mcl_http_response_get_header(), and mcl_string_util_find_case_insensitive().
MCL_LOCAL mcl_bool_t string_util_memcmp | ( | const void * | block_1, |
const void * | block_2, | ||
mcl_size_t | count | ||
) |
Standard library memcmp wrapper.
[in] | block_1 | Fist memory block to compare. |
[in] | block_2 | Second memory block to compare. |
[in] | count | Size of first memory block. |
Definition at line 208 of file string_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FALSE, and MCL_TRUE.
Referenced by mcl_string_util_memcmp().
MCL_LOCAL void string_util_memcpy | ( | void * | destination, |
const void * | source, | ||
mcl_size_t | count | ||
) |
Standard library memcpy wrapper.
[in] | destination | Destination memory block. |
[in] | source | Source memory block. |
[in] | count | Count of bytes to be copied. Destination should have space for at least count bytes. |
Definition at line 229 of file string_util.c.
References MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
Referenced by _join_with_dot(), _request_payload_callback_for_put(), _response_header_callback(), _response_payload_callback(), hmac_sha256(), json_util_get_string(), mcl_core_get_last_access_token(), mcl_core_get_last_token_time(), mcl_http_client_initialize(), mcl_string_util_memcpy(), string_util_concatenate(), and string_util_strdup().
MCL_LOCAL void string_util_memset | ( | void * | destination, |
mcl_uint8_t | value, | ||
mcl_size_t | count | ||
) |
Standard library memset wrapper.
[in] | destination | Destination memory block. |
[in] | value | Value to be set. |
[in] | count | Count of bytes to be set to the value . Destination should have space for at least count bytes. |
Definition at line 250 of file string_util.c.
References MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
Referenced by mcl_string_util_memset().
MCL_LOCAL mcl_error_t string_util_reset | ( | const void * | value, |
char ** | target | ||
) |
Initializes a new target
with the given value
.
value
must be a zero-terminated C string.[in] | value | The content to initialize target with. |
[out] | target | Will point to the initialized object. |
Definition at line 431 of file string_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, and string_util_strdup().
Referenced by mcl_http_request_set_parameter(), and mcl_string_util_reset().
MCL_LOCAL mcl_error_t string_util_snprintf | ( | char * | string, |
mcl_size_t | length, | ||
const char * | format, | ||
... | |||
) |
Standard library snprintf wrapper.
[out] | string | String to be set. Must be a zero terminated C string. |
[in] | length | Specifies how many chars should be processed. |
[in] | format | Format string followed by format parameters. |
Definition at line 177 of file string_util.c.
References _print_formatted_string(), MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
Referenced by _generate_correlation_id_string(), core_processor_register(), mcl_http_request_add_header(), and random_generate_guid().
MCL_LOCAL char* string_util_strdup | ( | const char * | string | ) |
Standard library strdup wrapper.
[in] | string | String to duplicate. |
string
. Definition at line 274 of file string_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR_SIZE, string_util_memcpy(), and string_util_strlen().
Referenced by mcl_http_client_add_certificate(), mcl_http_client_initialize(), mcl_string_util_strdup(), and string_util_reset().
MCL_LOCAL mcl_size_t string_util_strlen | ( | const char * | buffer | ) |
Standard library strlen wrapper.
[in] | buffer | Buffer which length to be calculated. Must be a zero terminated C string. |
Definition at line 35 of file string_util.c.
References MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
Referenced by _calculate_signature(), _check_client_secret(), _check_rsa_private_key(), _get_header_and_payload_encoded_base64_url(), _join_with_dot(), _ssl_context_callback(), core_processor_get_access_token(), core_processor_register(), core_processor_update_credentials(), json_util_get_string(), mcl_core_get_last_access_token(), mcl_core_get_last_token_time(), mcl_http_client_initialize(), mcl_http_request_add_header(), mcl_http_response_get_header(), mcl_string_util_strlen(), mcl_time_util_validate_timestamp(), security_handler_base64_encode(), security_handler_base64_url_encode(), security_handler_hmac_sha256(), security_rsa_get_modulus_and_exponent(), security_rsa_sign(), string_util_concatenate(), string_util_find(), string_util_find_case_insensitive(), and string_util_strdup().
MCL_LOCAL void string_util_strncat | ( | char * | destination, |
const char * | source, | ||
mcl_size_t | count | ||
) |
Standard library strncat wrapper.
[out] | destination | Destination string. Must be a zero terminated C string. |
[in] | source | Source string. Must be a zero terminated C string. |
[in] | count | Specifies how many chars from source will be added at the end of destination . |
Definition at line 105 of file string_util.c.
References MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
Referenced by mcl_string_util_strncat().
MCL_LOCAL mcl_error_t string_util_strncmp | ( | const char * | string_1, |
const char * | string_2, | ||
mcl_size_t | count | ||
) |
Standard library strncmp wrapper.
[in] | string_1 | Fist string to be compared. Must be a zero terminated C string. |
[in] | string_2 | Second string to be compared. Must be a zero terminated C string. |
[in] | count | Specifies how many chars should be compared. |
Definition at line 135 of file string_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, and MCL_OK.
Referenced by _check_client_secret(), _check_rsa_private_key(), core_processor_update_credentials(), and mcl_string_util_strncmp().
MCL_LOCAL void string_util_strncpy | ( | char * | destination, |
const char * | source, | ||
mcl_size_t | count | ||
) |
Standard library strncpy wrapper. Also sets the terminating null char at the end if source
is not longer than count
.
[out] | destination | Destination string. Must be a zero terminated C string. |
[in] | source | Source string. Must be a zero terminated C string. |
[in] | count | Specifies how many chars from source will be copied into the destination . |
Definition at line 83 of file string_util.c.
References MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
Referenced by mcl_http_response_get_header(), and mcl_string_util_strncpy().
MCL_LOCAL mcl_size_t string_util_strnlen | ( | const char * | buffer, |
mcl_size_t | maximum_length | ||
) |
Standard library strnlen wrapper.
[in] | buffer | Buffer which length to be calculated. Must be a zero terminated C string. |
[in] | maximum_length | The maximum length to return. If string is not zero terminated this guarantees not accessing unwanted memory. |
Definition at line 59 of file string_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_NULL_CHAR.
Referenced by core_configuration_validate(), and mcl_string_util_strnlen().
MCL_LOCAL long string_util_strtol | ( | const char * | source, |
int | base, | ||
char ** | end_pointer | ||
) |
Returns the first occurrence of an integral value in source
string.
[in] | source | String that contains the integral value as string. |
[in] | base | The base that the number will be interpreted. |
[out] | end_pointer | The pointer that points to the one past the last index of integral value. |
Definition at line 402 of file string_util.c.
References MCL_DEBUG_ENTRY, and MCL_DEBUG_LEAVE.
Referenced by mcl_string_util_strtol(), and mcl_time_util_validate_timestamp().