Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fnet_stdlib
Typedefs | |
typedef unsigned long | fnet_size_t |
Unsigned integer type representing the size in bytes. | |
typedef unsigned int | fnet_flag_t |
Unsigned integer type representing the bit flag. | |
typedef unsigned int | fnet_index_t |
Unsigned integer type representing the index. | |
typedef char | fnet_char_t |
Type representing the charecter. | |
Enumerations | |
enum | fnet_bool_t { FNET_FALSE = 0, FNET_TRUE = 1 } |
Boolean type. More... | |
enum | fnet_return_t { FNET_OK = (0), FNET_ERR = (-1) } |
General return codes, used by most of API functions. More... | |
Functions | |
void | fnet_memcpy (FNET_COMP_PACKED_VAR void *to_ptr, FNET_COMP_PACKED_VAR const void *from_ptr, fnet_size_t number_of_bytes) |
Copies bytes in memory. | |
void * | fnet_memcpy_func (void *to_buf_ptr, const void *from_func_ptr, fnet_size_t to_buf_size) |
Relocates function in memory. | |
void | fnet_memset (void *dest, fnet_uint8_t value, fnet_size_t n) |
Sets bytes in memory. | |
void | fnet_memset_zero (void *dest, fnet_size_t n) |
Sets bytes in memory to zeros. | |
fnet_int32_t | fnet_memcmp (const void *src1, const void *src2, fnet_size_t count) |
Compares memory areas. | |
fnet_size_t | fnet_strlen (const fnet_char_t *str) |
Calculates the length of a string. | |
void | fnet_strcat (fnet_char_t *dest, const fnet_char_t *src) |
Concatenates two strings. | |
void | fnet_strncat (fnet_char_t *dest, const fnet_char_t *src, fnet_size_t n) |
Concatenates a string with part of another. | |
void | fnet_strcpy (fnet_char_t *dest, const fnet_char_t *src) |
Copies a string. | |
void | fnet_strncpy (fnet_char_t *dest, const fnet_char_t *src, fnet_size_t n) |
Copies part of a string. | |
fnet_char_t * | fnet_strrchr (const fnet_char_t *str, fnet_char_t chr) |
Locates last occurrence of a character in a string. | |
fnet_char_t * | fnet_strchr (const fnet_char_t *str, fnet_char_t chr) |
Locates first occurrence of a character in a string. | |
fnet_char_t * | fnet_strstr (const fnet_char_t *str, const fnet_char_t *substr) |
Locates a substring. | |
fnet_int32_t | fnet_strcmp (const fnet_char_t *str1, const fnet_char_t *str2) |
Compares two strings. | |
fnet_int32_t | fnet_strncmp (const fnet_char_t *str1, const fnet_char_t *str2, fnet_size_t n) |
Compares part of two strings. | |
fnet_int32_t | fnet_strcasecmp (const fnet_char_t *str1, const fnet_char_t *str2) |
Compares two strings ignoring case. | |
fnet_int32_t | fnet_strcmp_splitter (const fnet_char_t *in_str, const fnet_char_t *name, fnet_char_t splitter) |
Compares two strings, with additional terminator. | |
fnet_uint32_t | fnet_strtoul (const fnet_char_t *str, fnet_char_t **ptr, fnet_size_t base) |
Converts string to unsigned long integer. | |
fnet_char_t * | fnet_strtok_r (fnet_char_t *str, const fnet_char_t *delimiter, fnet_char_t **last) |
Breaks a string into a sequence of tokens. | |
fnet_char_t | fnet_tolower (fnet_char_t to_lower) |
Converts letter to lower case. | |
fnet_uint32_t | fnet_rand (void) |
Generates a pseudo-random number. | |
void | fnet_srand (fnet_uint32_t seed) |
Initializes the pseudo-random number generator. |
Detailed Description
The standard library defines general purpose functions, including string converting, searching and other data manipulations.
Typedef Documentation
typedef char fnet_char_t |
Type representing the charecter.
Definition at line 74 of file fnet_stdlib.h.
typedef unsigned int fnet_flag_t |
Unsigned integer type representing the bit flag.
Definition at line 64 of file fnet_stdlib.h.
typedef unsigned int fnet_index_t |
Unsigned integer type representing the index.
Definition at line 69 of file fnet_stdlib.h.
typedef unsigned long fnet_size_t |
Unsigned integer type representing the size in bytes.
Definition at line 59 of file fnet_stdlib.h.
Enumeration Type Documentation
enum fnet_bool_t |
Boolean type.
Definition at line 79 of file fnet_stdlib.h.
enum fnet_return_t |
General return codes, used by most of API functions.
Definition at line 88 of file fnet_stdlib.h.
Function Documentation
fnet_int32_t fnet_memcmp | ( | const void * | src1, |
const void * | src2, | ||
fnet_size_t | count | ||
) |
Compares memory areas.
- Parameters:
-
src1 Pointer to the memory buffer to compare. src2 Pointer to the memory buffer to compare. count Number of bytes to compare.
- Returns:
- This function returns zero if two buffers are identical, otherwise returns
1
.
This function compares the first n
bytes of the memory buffer pointed by src1
to the first count
bytes pointed by src2
, returning zero if they all match, otherwise returns 1
.
Definition at line 225 of file fnet_stdlib.c.
void fnet_memcpy | ( | FNET_COMP_PACKED_VAR void * | to_ptr, |
FNET_COMP_PACKED_VAR const void * | from_ptr, | ||
fnet_size_t | number_of_bytes | ||
) |
Copies bytes in memory.
- Parameters:
-
to_ptr Pointer to the memory location to copy to. from_ptr Pointer to the memory location to copy from. number_of_bytes Number of bytes to copy.
- See also:
- FNET_CFG_OVERLOAD_MEMCPY
This function copies number_of_bytes
bytes from memory area pointed by from_ptr
to memory area pointed by to_ptr
.
You may overload it by own implementation, using FNET_CFG_OVERLOAD_MEMCPY.
Definition at line 41 of file fnet_stdlib.c.
void* fnet_memcpy_func | ( | void * | to_buf_ptr, |
const void * | from_func_ptr, | ||
fnet_size_t | to_buf_size | ||
) |
Relocates function in memory.
- Parameters:
-
to_buf_ptr Pointer to the memory location to copy to. from_func_ptr Pointer to the function to be relocated to_buf_size Number of bytes to copy.
- Returns:
- This function returns new pointer to the relocated function.
This function copies to_buf_size
bytes from memory area pointed by from_func_ptr
to memory area pointed by to_buf_ptr
.
It is used for a function relocation from Flash to RAM.
Definition at line 183 of file fnet_stdlib.c.
void fnet_memset | ( | void * | dest, |
fnet_uint8_t | value, | ||
fnet_size_t | n | ||
) |
Sets bytes in memory.
- Parameters:
-
dest Pointer to the buffer to be set. value Value to be set.
The value is passed as anint
, but the function converts it tofnet_uint8_t
.n Number of bytes to be set.
- See also:
- fnet_memset_zero()
This function sets the first n
bytes of the memory area pointed to by dest
with the constant byte value
.
Definition at line 194 of file fnet_stdlib.c.
void fnet_memset_zero | ( | void * | dest, |
fnet_size_t | n | ||
) |
Sets bytes in memory to zeros.
- Parameters:
-
dest Pointer to the buffer to be set. n Number of bytes to be set.
- See also:
- fnet_memset()
This function sets the first n
bytes of the memory area pointed to by dest
with zeros.
Definition at line 209 of file fnet_stdlib.c.
fnet_uint32_t fnet_rand | ( | void | ) |
Generates a pseudo-random number.
- Returns:
- Pseudo-random number in the range betwenn 0 to FNET_RAND_MAX
This function generates a pseudo-random number in the range betwenn 0 to FNET_RAND_MAX
Definition at line 767 of file fnet_stdlib.c.
void fnet_srand | ( | fnet_uint32_t | seed ) |
Initializes the pseudo-random number generator.
- Parameters:
-
seed Seed for the pseudo-random number generator
This function initializes the pseudo-random generator with the seed argument
Definition at line 776 of file fnet_stdlib.c.
fnet_int32_t fnet_strcasecmp | ( | const fnet_char_t * | str1, |
const fnet_char_t * | str2 | ||
) |
Compares two strings ignoring case.
- Parameters:
-
str1 Pointer to the null-terminated string to be compared. str2 Pointer to the null-terminated string to be compared.
- Returns:
- This function returns an integer less than, equal to, or greater than zero if
str1
is found, respectively, to be less than, to match, or be greater thanstr2
.
This function compares the two strings str1
and str2
, ignoring the case of the characters. It returns an integer less than, equal to, or greater than zero if str1
is found, respectively, to be less than, to match, or be greater than str2
.
Definition at line 631 of file fnet_stdlib.c.
void fnet_strcat | ( | fnet_char_t * | dest, |
const fnet_char_t * | src | ||
) |
Concatenates two strings.
- Parameters:
-
dest Pointer to the null-terminated string to append to. src Pointer to the null-terminated string to copy to the end of dest
.
This function appends a copy of the string pointed to by src
to the end of the string pointed to by dest
.
The resulting string is null-terminated.
Definition at line 289 of file fnet_stdlib.c.
fnet_char_t* fnet_strchr | ( | const fnet_char_t * | str, |
fnet_char_t | chr | ||
) |
Locates first occurrence of a character in a string.
- Parameters:
-
str Pointer to the null-terminated string to be analyzed. chr Character to search for.
- Returns:
- This function returns the pointer to the found character in
str
, or FNET_NULL if no such character is found.
This function finds the first occurrence of the character
chr in the string pointed to by str
.
Definition at line 396 of file fnet_stdlib.c.
fnet_int32_t fnet_strcmp | ( | const fnet_char_t * | str1, |
const fnet_char_t * | str2 | ||
) |
Compares two strings.
- Parameters:
-
str1 Pointer to the null-terminated string to be compared. str2 Pointer to the null-terminated string to be compared.
- Returns:
- This function returns zero if two strings are identical, otherwise returns the difference between the first two differing characters.
This function compares the two strings str1
and str2
, returning zero if they all match or the difference between the first two differing characters.
Definition at line 245 of file fnet_stdlib.c.
fnet_int32_t fnet_strcmp_splitter | ( | const fnet_char_t * | in_str, |
const fnet_char_t * | name, | ||
fnet_char_t | splitter | ||
) |
Compares two strings, with additional terminator.
- Parameters:
-
in_str Pointer to the null or splitter
terminated string to be compared.name Pointer to the null-terminated string to be compared. splitter Additional terminator that can be used in str
.
- Returns:
- This function returns zero if two strings are identical, otherwise returns the difference between the first two differing characters.
This function compares the two strings in_str
and name
, returning zero if they all match or the difference between the first two differing characters.
The name
string can be terminated by null or splitter
character.
Definition at line 660 of file fnet_stdlib.c.
void fnet_strcpy | ( | fnet_char_t * | dest, |
const fnet_char_t * | src | ||
) |
Copies a string.
- Parameters:
-
dest Pointer to the destination buffer where the content is to be copied. src Pointer to the null-terminated string to be copied.
This function copies the string pointed by src
into the buffer pointed by dest
, including the terminating null character.
Definition at line 330 of file fnet_stdlib.c.
fnet_size_t fnet_strlen | ( | const fnet_char_t * | str ) |
Calculates the length of a string.
- Parameters:
-
str Pointer to the null-terminated string to be examined.
- Returns:
- This function returns the number of characters in
str
.
This function computes the number of bytes in the string to which str
points, not including the terminating null byte.
Definition at line 268 of file fnet_stdlib.c.
void fnet_strncat | ( | fnet_char_t * | dest, |
const fnet_char_t * | src, | ||
fnet_size_t | n | ||
) |
Concatenates a string with part of another.
- Parameters:
-
dest Pointer to the null-terminated string to append to. src Pointer to the null-terminated string to copy to the end of dest
.n Maximum number of characters to be appended.
This function appends a copy of the string pointed to by src
to the end of the string pointed to by dest
. If the length of the src
string is less than n
, only the content up to the terminating null-character is copied.
The resulting string is null-terminated.
Definition at line 309 of file fnet_stdlib.c.
fnet_int32_t fnet_strncmp | ( | const fnet_char_t * | str1, |
const fnet_char_t * | str2, | ||
fnet_size_t | n | ||
) |
Compares part of two strings.
- Parameters:
-
str1 Pointer to the null-terminated string to be compared. str2 Pointer to the null-terminated string to be compared. n Maximum number of characters to compare.
- Returns:
- This function returns zero if
n
characters of two strings are identical, otherwise returns the difference between the first two differing characters.
This function compares not more than n
characters (characters that follow a null byte are not compared) from the two strings str1
and str2
, returning zero if they all match or the difference between the first two differing characters.
Definition at line 460 of file fnet_stdlib.c.
void fnet_strncpy | ( | fnet_char_t * | dest, |
const fnet_char_t * | src, | ||
fnet_size_t | n | ||
) |
Copies part of a string.
- Parameters:
-
dest Pointer to the destination buffer where the content is to be copied. src Pointer to the null-terminated string to be copied. n Maximum number of characters to be copied.
This function copies the first n
characters of the string pointed by src
into the buffer pointed by dest
.
The result string is null-terminated.
Definition at line 348 of file fnet_stdlib.c.
fnet_char_t* fnet_strrchr | ( | const fnet_char_t * | str, |
fnet_char_t | chr | ||
) |
Locates last occurrence of a character in a string.
- Parameters:
-
str Pointer to the null-terminated string to be analyzed. chr Character to search for.
- Returns:
- This function returns the pointer to the found character in
str
, or FNET_NULL if no such character is found.
This function finds the last occurrence of the character
chr in the string pointed to by str
..
Definition at line 368 of file fnet_stdlib.c.
fnet_char_t* fnet_strstr | ( | const fnet_char_t * | str, |
const fnet_char_t * | substr | ||
) |
Locates a substring.
- Parameters:
-
str Pointer to the null-terminated string to be analyzed. substr Pointer to the null-terminated string to search for.
- Returns:
- This function returns pointer to the first occurrence in
str
of the entire sequence of characters specified insubstr
.
This function finds the first occurrence of the substring substr
(excluding the terminating null byte) in the string str
.
Definition at line 421 of file fnet_stdlib.c.
fnet_char_t* fnet_strtok_r | ( | fnet_char_t * | str, |
const fnet_char_t * | delimiter, | ||
fnet_char_t ** | last | ||
) |
Breaks a string into a sequence of tokens.
- Parameters:
-
str The string from which to extract tokens (null-terminated). delimiter The string that contains a set of delimiter characters (null-terminated). last Return parameter used by fnet_strtok_r() to record its progress through str
.
This pointer, must be the same while parsing the same string.
- Returns:
- This function returns a pointer to the next token in
str
. If there are no remaining tokens, it returns a FNET_NULL pointer.
This function parses the string str
into tokens.
The first function call should have str
as its first argument. Subse- quent calls should have the first argument set to FNET_NULL. Each call returns a pointer to the next token, or FNET_NULL when no more tokens are found.
The function also updates the last
parameter with the starting address of the token following the first occurrence of the delimiter
parameter.
The delimiter
string may be different for each call.
Definition at line 703 of file fnet_stdlib.c.
fnet_uint32_t fnet_strtoul | ( | const fnet_char_t * | str, |
fnet_char_t ** | ptr, | ||
fnet_size_t | base | ||
) |
Converts string to unsigned long integer.
- Parameters:
-
str Pointer to the null-terminated string to be interpreted . ptr Pointer to a pointer to character that will be set to the character immediately following the unsigned long integer in the string. If no integer can be formed, it points to the first wrong character. base Base of the interpreted integer value. If it equals to 0, it will be set to the default value 10.
- Returns:
- This function returns integer value corresponding to the contents of
str
on success. If no conversion can be performed,0
is returned.
This function converts a string to an unsigned long integer.
The string to be converted can contain the digits '0' to '9'. Depending on the base, the string can also contain letters representing digits greater than 9.
Definition at line 488 of file fnet_stdlib.c.
fnet_char_t fnet_tolower | ( | fnet_char_t | to_lower ) |
Converts letter to lower case.
- Parameters:
-
to_lower Letter to be converted to lower case, if possible.
- Returns:
- This function returns converted letter.
This function converts an uppercase letter to the corresponding lowercase letter.
Definition at line 615 of file fnet_stdlib.c.
Generated on Tue Jul 12 2022 12:22:40 by
