string_util.h File Reference

String utility module implementation file. More...

#include "mcl/mcl_common.h"
Include dependency graph for string_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

mcl_size_t string_util_strlen (const char *buffer)
 Standard library strlen wrapper. More...
 
mcl_size_t string_util_strnlen (const char *buffer, mcl_size_t maximum_length)
 Standard library strnlen wrapper. More...
 
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. More...
 
void string_util_strncat (char *destination, const char *source, mcl_size_t count)
 Standard library strncat wrapper. More...
 
E_MCL_ERROR_CODE string_util_strncmp (const char *string_1, const char *string_2, mcl_size_t count)
 Standard library strncmp wrapper. More...
 
E_MCL_ERROR_CODE string_util_snprintf (char *string, mcl_size_t length, const char *format,...)
 Standard library snprintf wrapper. More...
 
mcl_bool_t string_util_memcmp (const void *block_1, const void *block_2, mcl_size_t count)
 Standard library memcmp wrapper. More...
 
void string_util_memcpy (void *destination, const void *source, mcl_size_t count)
 Standard library memcpy wrapper. More...
 
char * string_util_strdup (const char *string)
 Standard library strdup wrapper. More...
 
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. More...
 
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. More...
 
mcl_bool_t string_util_is_space (char character)
 Checks if a character is whitespace. More...
 
long string_util_strtol (const char *source, int base, char **end_pointer)
 Returns the first occurrence of an integral value in source string. More...
 

Detailed Description

String utility module implementation file.


Date
Aug 12, 2016 This module implements utility functions for basic string operations.

Definition in file string_util.h.

Function Documentation

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.

Parameters
[in]sourceNull terminated string to be searched in.
[in]targetNull terminated string to be searched for.
[out]start_indexIndex of the first character of target if source contains it.
Returns
If target is found then MCL_TRUE, otherwise MCL_FALSE.

Definition at line 156 of file string_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_FALSE, MCL_TRUE, and string_util_strlen().

Referenced by _is_valid_version(), _process_registration_response_rsa_3072(), and string_replace().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
[in]sourceNull terminated string to be searched in.
[in]targetNull terminated string to be searched for.
[out]start_indexIndex of the first character of target if source contains it.
Returns
If target is found then MCL_TRUE, otherwise MCL_FALSE.

Definition at line 189 of file string_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, LOWERCASE, MCL_FALSE, MCL_TRUE, and string_util_strlen().

Referenced by http_response_get_header().

Here is the call graph for this function:

Here is the caller graph for this function:

mcl_bool_t string_util_is_space ( char  character)

Checks if a character is whitespace.

Parameters
[in]characterCharacter to be checked.
Returns
If character is whitespace returns MCL_TRUE. Otherwise, MCL_FALSE.

Definition at line 222 of file string_util.c.

References DEBUG_ENTRY, and DEBUG_LEAVE.

mcl_bool_t string_util_memcmp ( const void *  block_1,
const void *  block_2,
mcl_size_t  count 
)

Standard library memcmp wrapper.

Parameters
[in]block_1Fist memory block to compare.
[in]block_2Second memory block to compare.
[in]countSize of first memory block.
Returns

Definition at line 121 of file string_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_FALSE, and MCL_TRUE.

void string_util_memcpy ( void *  destination,
const void *  source,
mcl_size_t  count 
)

Standard library memcpy wrapper.

Parameters
[in]destinationDestination memory block.
[in]sourceSource memory block.
[in]countCount of bytes to be copied. Destination should have space for at least count bytes.

Definition at line 131 of file string_util.c.

References DEBUG_ENTRY, and DEBUG_LEAVE.

Referenced by _add_blank_line(), _add_meta(), _get_payload_from_buffer(), _request_payload_callback_for_put(), _response_payload_callback(), hmac_sha256(), http_processor_get_access_token(), http_processor_register(), and http_request_finalize().

Here is the caller graph for this function:

E_MCL_ERROR_CODE string_util_snprintf ( char *  string,
mcl_size_t  length,
const char *  format,
  ... 
)

Standard library snprintf wrapper.

Parameters
[out]stringString to be set. Must be a zero terminated C string.
[in]lengthSpecifies how many chars should be processed.
[in]formatFormat string followed by format parameters.
Returns

Definition at line 95 of file string_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_ERROR_RETURN, MCL_FAIL, and MCL_OK.

Referenced by _add_boundary(), _add_content_info(), _concatenate_host_and_endpoint(), _generate_correlation_id_string(), _process_registration_response_rsa_3072(), http_client_initialize(), http_processor_register(), http_request_add_header(), mcl_communication_get_last_access_token(), mcl_communication_get_last_token_time(), mcl_communication_initialize(), random_generate_guid(), string_concatenate(), and string_concatenate_cstr().

Here is the caller graph for this function:

char* string_util_strdup ( const char *  string)

Standard library strdup wrapper.

Parameters
[in]stringString to duplicate.
Returns
A duplicate of the input string.

Definition at line 140 of file string_util.c.

References DEBUG_ENTRY, and DEBUG_LEAVE.

Referenced by http_client_initialize(), and storage_load_rsa_registration_information().

Here is the caller graph for this function:

mcl_size_t string_util_strlen ( const char *  buffer)
void string_util_strncat ( char *  destination,
const char *  source,
mcl_size_t  count 
)

Standard library strncat wrapper.

Parameters
[out]destinationDestination string. Must be a zero terminated C string.
[in]sourceSource string. Must be a zero terminated C string.
[in]countSpecifies how many chars from source will be added at the end of destination.

Definition at line 61 of file string_util.c.

References DEBUG_ENTRY, and DEBUG_LEAVE.

Referenced by string_array_to_string(), and string_replace().

Here is the caller graph for this function:

E_MCL_ERROR_CODE string_util_strncmp ( const char *  string_1,
const char *  string_2,
mcl_size_t  count 
)

Standard library strncmp wrapper.

Parameters
[in]string_1Fist string to be compared. Must be a zero terminated C string.
[in]string_2Second string to be compared. Must be a zero terminated C string.
[in]countSpecifies how many chars should be compared.
Returns

Definition at line 74 of file string_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_FAIL, and MCL_OK.

Referenced by _get_private_key(), _get_public_key(), http_processor_update_security_information(), and string_compare_with_cstr().

Here is the caller graph for this function:

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.

Parameters
[out]destinationDestination string. Must be a zero terminated C string.
[in]sourceSource string. Must be a zero terminated C string.
[in]countSpecifies how many chars from source will be copied into the destination.

Definition at line 48 of file string_util.c.

References DEBUG_ENTRY, and DEBUG_LEAVE.

Referenced by _initialize(), and _process_registration_response_rsa_3072().

Here is the caller graph for this function:

mcl_size_t string_util_strnlen ( const char *  buffer,
mcl_size_t  maximum_length 
)

Standard library strnlen wrapper.

Parameters
[in]bufferBuffer which length to be calculated. Must be a zero terminated C string.
[in]maximum_lengthThe maximum length to return. If string is not zero terminated this guarantees not accessing unwanted memory.
Returns
the calculated length of buffer.

Definition at line 34 of file string_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, and MCL_NULL_CHAR.

Referenced by mcl_communication_initialize().

Here is the caller graph for this function:

long string_util_strtol ( const char *  source,
int  base,
char **  end_pointer 
)

Returns the first occurrence of an integral value in source string.

Parameters
[in]sourceString that contains the integral value as string.
[in]baseThe base that the number will be interpreted.
[out]end_pointerThe pointer that points to the one past the last index of integral value.
Returns
If a number if found it's value is returned. Otherwise it returns 0.

Definition at line 232 of file string_util.c.

References DEBUG_ENTRY, and DEBUG_LEAVE.

Referenced by _process_registration_response_rsa_3072(), and time_util_validate_timestamp().

Here is the caller graph for this function: