BA / Mbed OS BaBoRo1
Embed: (wiki syntax)

« Back to documentation index

Fnet_stdlib

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_tfnet_strrchr (const fnet_char_t *str, fnet_char_t chr)
 Locates last occurrence of a character in a string.
fnet_char_tfnet_strchr (const fnet_char_t *str, fnet_char_t chr)
 Locates first occurrence of a character in a string.
fnet_char_tfnet_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_tfnet_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

Boolean type.

Enumerator:
FNET_FALSE 

FALSE Boolean value.

FNET_TRUE 

TRUE Boolean value.

Definition at line 79 of file fnet_stdlib.h.

General return codes, used by most of API functions.

Enumerator:
FNET_OK 

No error.

FNET_ERR 

There is error.

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:
src1Pointer to the memory buffer to compare.
src2Pointer to the memory buffer to compare.
countNumber 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_ptrPointer to the memory location to copy to.
from_ptrPointer to the memory location to copy from.
number_of_bytesNumber 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_ptrPointer to the memory location to copy to.
from_func_ptrPointer to the function to be relocated
to_buf_sizeNumber 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:
destPointer to the buffer to be set.
valueValue to be set.
The value is passed as an int, but the function converts it to fnet_uint8_t.
nNumber 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:
destPointer to the buffer to be set.
nNumber 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:
seedSeed 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:
str1Pointer to the null-terminated string to be compared.
str2Pointer 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 than str2.

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:
destPointer to the null-terminated string to append to.
srcPointer 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:
strPointer to the null-terminated string to be analyzed.
chrCharacter 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:
str1Pointer to the null-terminated string to be compared.
str2Pointer 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_strPointer to the null or splitter terminated string to be compared.
namePointer to the null-terminated string to be compared.
splitterAdditional 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:
destPointer to the destination buffer where the content is to be copied.
srcPointer 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:
strPointer 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:
destPointer to the null-terminated string to append to.
srcPointer to the null-terminated string to copy to the end of dest.
nMaximum 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:
str1Pointer to the null-terminated string to be compared.
str2Pointer to the null-terminated string to be compared.
nMaximum 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:
destPointer to the destination buffer where the content is to be copied.
srcPointer to the null-terminated string to be copied.
nMaximum 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:
strPointer to the null-terminated string to be analyzed.
chrCharacter 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:
strPointer to the null-terminated string to be analyzed.
substrPointer 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 in substr.

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:
strThe string from which to extract tokens (null-terminated).
delimiterThe string that contains a set of delimiter characters (null-terminated).
lastReturn 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:
strPointer to the null-terminated string to be interpreted .
ptrPointer 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.
baseBase 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_lowerLetter 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.