22 #define LOWERCASE(n) ((n >= 'A' && n <= 'Z') ? (n + ('a' - 'A')) : n) 36 DEBUG_ENTRY(
"const char *buffer = <%s>, mcl_size_t maximum_length = <%u>", buffer, maximum_length)
39 while ((count < maximum_length) && (
MCL_NULL_CHAR != buffer[count]))
50 DEBUG_ENTRY(
"char *destination = <%s>, const char *source = <%s>, mcl_size_t count = <%u>", destination, source, count)
52 #if defined(WIN32) || defined(WIN64) 53 strncpy_s(destination, count + 1, source, count);
55 strncpy(destination, source, count);
63 DEBUG_ENTRY(
"char *destination = <%s>, const char *source = <%s>, mcl_size_t count = <%u>", destination, source, count)
65 #if defined(WIN32) || defined(WIN64) 66 strncat_s(destination, strlen(destination) + count + 1, source, count);
68 strncat(destination, source, count);
76 DEBUG_ENTRY(
"const char *string_1 = <%s>, const char *string_2 = <%s>, mcl_size_t count = <%u>", string_1, string_2, count)
79 int result = strncmp(string_1, string_2, count);
97 DEBUG_ENTRY(
"char *string = <%p>, mcl_size_t length = <%u>, const char *format = <%s>",
string, length, format)
104 va_start(args, format);
106 count = vsnprintf(
string, length, format, args);
109 if ((count > 0) && (((
mcl_size_t)count) <= length))
123 DEBUG_ENTRY(
"const void *block_1 = <%p>, const void *block_2 = <%p>, mcl_size_t count = <%u>", block_1, block_2, count)
127 DEBUG_LEAVE(
"retVal = <%s>", result ?
"MCL_TRUE" :
"MCL_FALSE");
133 DEBUG_ENTRY(
"void *destination = <%p>, const void *source = <%p>, mcl_size_t count = <%u>", destination, source, count)
135 memcpy(destination, source, count);
146 #if defined(WIN32) || defined(WIN64) 147 result = _strdup(
string);
149 result = strdup(
string);
158 DEBUG_ENTRY(
"char *src = <%p>, char *target = <%p>, mcl_size_t *start_index = <%p>", source, target, start_index)
167 if (!(0 == target_length) && !(target_length > source_length))
171 for (index = 0; index < source_length; index++)
173 state = (source[index] == target[state]) ? state + 1 : 0;
175 if (state == target_length)
177 *start_index = index - (target_length - 1);
185 DEBUG_LEAVE(
"retVal = <%s>", is_found ?
"MCL_TRUE" :
"MCL_FALSE");
191 DEBUG_ENTRY(
"char *src = <%p>, char *target = <%p>, mcl_size_t *start_index = <%p>", source, target, start_index)
200 if ((0 != target_length) && (target_length <= source_length))
204 for (index = 0; index < source_length; index++)
206 state = (source[index] == target[state] ||
LOWERCASE(source[index]) ==
LOWERCASE(target[state])) ? state + 1 : 0;
208 if (state == target_length)
210 *start_index = index - (target_length - 1);
218 DEBUG_LEAVE(
"retVal = <%s>", is_found ?
"MCL_TRUE" :
"MCL_FALSE");
226 mcl_bool_t result = (character ==
' ') || (character ==
'\t') || (character ==
'\n') || (character ==
'\v') || (character ==
'\f') || (character ==
'\r');
228 DEBUG_LEAVE(
"retVal = <%s>", result ?
"MCL_TRUE" :
"MCL_FALSE");
234 DEBUG_ENTRY(
"char* source = <%p>, int base = <%p>, char *end_pointer = <%p>", source, end_pointer, base)
236 long result = strtol(source, end_pointer, base);
void string_util_strncat(char *destination, const char *source, mcl_size_t count)
Standard library strncat wrapper.
mcl_size_t string_util_strnlen(const char *buffer, mcl_size_t maximum_length)
Standard library strnlen wrapper.
char * string_util_strdup(const char *string)
Standard library strdup wrapper.
long string_util_strtol(const char *source, int base, char **end_pointer)
Returns the first occurrence of an integral value in source string.
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...
#define MCL_FALSE
MCL bool type.
Log utility module header file.
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.
String utility module implementation file.
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.
void string_util_memcpy(void *destination, const void *source, mcl_size_t count)
Standard library memcpy wrapper.
Definitions module header file.
E_MCL_ERROR_CODE string_util_strncmp(const char *string_1, const char *string_2, mcl_size_t count)
Standard library strncmp wrapper.
mcl_bool_t string_util_memcmp(const void *block_1, const void *block_2, mcl_size_t count)
Standard library memcmp wrapper.
mcl_bool_t string_util_is_space(char character)
Checks if a character is whitespace.
mcl_size_t string_util_strlen(const char *buffer)
Standard library strlen wrapper.
#define MCL_ERROR_RETURN(return_value,...)