26 VERBOSE_ENTRY(
"const string_t *other = <%p>, string_t **string = <%p>", other,
string)
38 MCL_ERROR(
"_initialize_with_option() failed!. Freeing the string_t!");
48 VERBOSE_ENTRY(
"const char *value = <%s>, mcl_size_t value_length = <%u>, string_t **string = <%p>", value, value_length,
string)
60 MCL_ERROR(
"_initialize_with_option() failed!. Freeing the string_t!");
70 VERBOSE_ENTRY(
"const char *value = <%s>, mcl_size_t value_length = <%u>, string_t **string = <%p>", value, value_length,
string)
82 MCL_ERROR(
"_initialize_with_option() failed!. Freeing the string_t!");
92 VERBOSE_ENTRY(
"const char *value = <%s>, mcl_size_t value_length = <%u>, string_t **string = <%p>", value, value_length,
string)
100 result =
_initialize(*
string, value, value_length);
104 MCL_ERROR(
"_initialize_with_option() failed!. Freeing the string_t!");
114 VERBOSE_ENTRY(
"string_t *string = <%p>, const char *value = <%s>, mcl_size_t value_length = <%u>",
string, value, value_length)
123 ASSERT_CODE_MESSAGE(
MCL_OK == result, result,
"initialize_with_option failed! Not freeing the string but it's buffer has already been freed!");
131 DEBUG_ENTRY(
"const string_t *string = <%p>, const string_t *other = <%p>",
string, other)
141 DEBUG_ENTRY(
"const string_t *string = <%p>, const char *other = <%s>",
string, other)
151 if (string->
buffer == other)
153 MCL_DEBUG(
"string->buffer and other are pointing to the same memory space");
159 if (length == string->
length)
167 MCL_DEBUG(
"Received compare string (other) is NULL.");
172 MCL_DEBUG(
"Received string object or it's buffer is NULL");
181 DEBUG_ENTRY(
"string_t *string = <%p>, const char token = <%c>, list_t **string_list = <%p>",
string, token, string_list)
187 char *temp_buffer =
string->buffer;
197 for (index = 0; index <
string->length; index++)
199 if (string->
buffer[index] != token)
210 MCL_ERROR(
"string_initialize_new failed!");
218 MCL_ERROR(
"Current split part of the string couldn't be added to the list!");
225 MCL_DEBUG(
"Current split part has been added to the list = <%s>", current_part->
buffer);
228 temp_buffer += temp_length + 1;
245 MCL_ERROR(
"string_initialize_new failed!");
251 MCL_ERROR(
"Last split part of the string couldn't be added to the list!");
256 MCL_DEBUG(
"Last split part has been added to the list = <%s>", current_part->
buffer);
264 MCL_DEBUG(
"Result is NOT successful. Clearing the content of the list if there is any");
274 VERBOSE_ENTRY(
"const mcl_uint8_t *buffer = <%p>, mcl_size_t buffer_size = <%u>, string_t **hex_data = <%p>", buffer, buffer_size, hex_data)
282 (*hex_data)->length = 2 * buffer_size;
283 (*hex_data)->buffer =
MCL_CALLOC(1, (*hex_data)->length + 1);
287 for (i = 0; i < buffer_size; i++)
289 ((*hex_data)->buffer)[i * 2 + 0] =
hex_table[(buffer[i] >> 4) & 0x0F];
290 ((*hex_data)->buffer)[i * 2 + 1] =
hex_table[buffer[i] & 0x0F];
307 MCL_VERBOSE(
"Type is MCL_STRING_COPY_DESTROY or MCL_STRING_NOT_COPY_DESTROY. Freeing the buffer.");
312 MCL_VERBOSE(
"Type is MCL_STRING_NOT_COPY_NOT_DESTROY. Not freeing the buffer.");
341 VERBOSE_ENTRY(
"string_t *string = <%p>, const char *value = <%s>, mcl_size_t value_length = <%u>",
string, value, value_length)
348 MCL_VERBOSE(
"Not NULL value received. String will be initialized with it.");
350 if (value_length > 0)
352 length = value_length;
363 MCL_VERBOSE(
"Copy Flag is TRUE : Given value parameter will be copied into the buffer");
380 MCL_VERBOSE(
"Copy Flag is FALSE : Given value parameters address will be assigned to the buffer");
383 string->buffer = (
char *)value;
387 string->length = length;
393 MCL_VERBOSE(
"NULL value received, but new string with given length (> 0) requested. Buffer for string will be allocated and zero-terminated. Buffer remains uninitialized.");
395 string->buffer =
MCL_MALLOC(value_length + 1);
398 string->length = value_length;
405 MCL_VERBOSE(
"NULL value received. String will be initialized as empty.");
418 VERBOSE_ENTRY(
"string_t *string_1 = <%p>, string_t *string_2 = <%p>, string_t **result = <%p>", string_1, string_2, result)
435 VERBOSE_ENTRY(
"string_t *source = <%p>, const char *old_string = <%p>, const char *new_string = <%p>, string_t **result = <%p>", source, old_string, new_string, result)
447 target_string_length = source->
length - old_string_length + new_string_length;
449 target_string =
MCL_CALLOC(target_string_length + 1, 1);
467 VERBOSE_ENTRY(
"string_t *string = <%p>, char *cstring = <%p>, string_t **result = <%p>",
string, c_string, result)
474 result_length =
string->length + c_string_length;
void string_util_strncat(char *destination, const char *source, mcl_size_t count)
Standard library strncat wrapper.
void string_destroy(string_t **string)
Destroys the allocated resources of the string.
E_MCL_ERROR_CODE string_replace(string_t *source, const char *old_string, const char *new_string, string_t **result)
Replaces old_string with new_string.
Memory module header file.
#define VERBOSE_LEAVE(...)
E_MCL_ERROR_CODE string_initialize_new(const char *value, mcl_size_t value_length, string_t **string)
Initializes a new string_t object with the given value and length.
char * buffer
Buffer of string handle.
E_MCL_ERROR_CODE string_split(string_t *string, const char token, list_t **string_list)
Splits the string with the given char and returns the result as an list_t of string_t's.
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.
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 lon...
E_MCL_ERROR_CODE string_compare_with_cstr(const string_t *string, const char *other)
Compare the contents of string_t with a C string.
#define MCL_MALLOC(bytes)
Log utility module header file.
E_MCL_ERROR_CODE list_initialize(list_t **list)
Initializes the list.
E_MCL_ERROR_CODE
MCL Error code definitions. Every function returning an error code uses this enum values...
E_MCL_ERROR_CODE string_util_snprintf(char *string, mcl_size_t length, const char *format,...)
Standard library snprintf wrapper.
Strings with this type will NOT allocate its buffer during initialization (buffer only points of the ...
E_MCL_STRING_TYPE type
Type of copy and destroy.
#define VERBOSE_ENTRY(...)
#define ASSERT_STATEMENT_CODE_MESSAGE(condition, statement, return_code,...)
E_MCL_ERROR_CODE string_compare(const string_t *string, const string_t *other)
Compare the contents of two string_t's.
Strings with this type will allocates its buffer during initialization (copies the initial value to i...
#define MCL_CALLOC(count, bytes)
#define ASSERT_CODE_MESSAGE(condition, return_code,...)
Definitions module header file.
E_MCL_ERROR_CODE string_initialize_dynamic(const char *value, mcl_size_t value_length, string_t **string)
Initializes a dynamic string_t object with the given value and length.
E_MCL_ERROR_CODE string_convert_binary_to_hex(const mcl_uint8_t *buffer, mcl_size_t buffer_size, string_t **hex_data)
E_MCL_ERROR_CODE string_concatenate_cstr(string_t *string, char *c_string, string_t **result)
Concatenates two strings of type string_t into a string_t.
E_MCL_ERROR_CODE string_initialize(const string_t *other, string_t **string)
Initializes an string_t object with another one.
mcl_size_t length
Length of buffer.
void string_release(string_t *string)
Clears the content of the string. And deallocates the memory.
E_MCL_ERROR_CODE string_util_strncmp(const char *string_1, const char *string_2, mcl_size_t count)
Standard library strncmp wrapper.
E_MCL_ERROR_CODE string_set(string_t *string, const char *value, mcl_size_t value_length)
Sets the buffer of the string with a new value.
void list_destroy_with_content(list_t **list, list_item_destroy_callback callback)
To destroy the list and its items with a given callback function.
E_MCL_ERROR_CODE string_initialize_static(const char *value, mcl_size_t value_length, string_t **string)
Initializes a static string_t object with the given value and length.
E_MCL_ERROR_CODE _initialize(string_t *string, const char *value, mcl_size_t value_length)
Private Function Prototypes:
String type module header file.
E_MCL_ERROR_CODE list_add(list_t *list, void *data)
Adds a new list item.
mcl_list_item_destroy_callback list_item_destroy_callback
E_MCL_ERROR_CODE string_concatenate(string_t *string_1, string_t *string_2, string_t **result)
Concatenates a C string (i.e. a char array)
mcl_size_t string_util_strlen(const char *buffer)
Standard library strlen wrapper.
Strings with this type will NOT allocate its buffer during initialization (buffer only points of the ...