Embedded TCP/IP stack: fnet_stdlib.h Source File

FNET

fnet_stdlib.h
1 /**************************************************************************
2 *
3 * Copyright 2011-2016 by Andrey Butok. FNET Community.
4 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 ***************************************************************************
21 *
22 * Standard functions API.
23 *
24 ***************************************************************************/
25 
26 #ifndef _FNET_STDLIB_H_
27 
28 #define _FNET_STDLIB_H_
29 
36 #include <stdarg.h> /* For va_list etc.*/
37 #include <string.h> /* In case of alternative functions */
38 
39 /**************************************************************************/
44 #define FNET_NULL (0)
45 
46 /**************************************************************************/
51 #define FNET_RAND_MAX (32767u)
52 
53 /**************************************************************************/
56 typedef unsigned long fnet_size_t;
57 
58 /**************************************************************************/
61 typedef long fnet_ssize_t;
62 
63 /**************************************************************************/
66 typedef unsigned int fnet_flag_t;
67 
68 /**************************************************************************/
71 typedef unsigned int fnet_index_t;
72 
73 /**************************************************************************/
76 typedef char fnet_char_t;
77 
78 /**************************************************************************/
81 typedef enum
82 {
83  FNET_FALSE = 0,
84  FNET_TRUE = 1
85 } fnet_bool_t;
86 
87 /**************************************************************************/
90 typedef enum
91 {
92  FNET_OK = (0),
93  FNET_ERR = (-1)
95 
96 #if defined(__cplusplus)
97 extern "C" {
98 #endif
99 
100 /***************************************************************************/
118 #if !FNET_CFG_OVERLOAD_MEMCPY
119 void fnet_memcpy(FNET_COMP_PACKED_VAR void *to_ptr, FNET_COMP_PACKED_VAR const void *from_ptr, fnet_size_t number_of_bytes);
120 #endif
121 
122 /***************************************************************************/
140 void *fnet_memcpy_func(void *to_buf_ptr, const void *from_func_ptr, fnet_size_t to_buf_size);
141 
142 /***************************************************************************/
162 void fnet_memset(void *dest, fnet_uint8_t value, fnet_size_t n);
163 
164 /***************************************************************************/
180 void fnet_memset_zero(void *dest, fnet_size_t n );
181 
182 /***************************************************************************/
202 fnet_int32_t fnet_memcmp(const void *src1, const void *src2, fnet_size_t count );
203 
204 /***************************************************************************/
218 fnet_size_t fnet_strlen (const fnet_char_t *str);
219 
220 /***************************************************************************/
236 void fnet_strcat (fnet_char_t *dest, const fnet_char_t *src);
237 
238 /***************************************************************************/
258 void fnet_strncat (fnet_char_t *dest, const fnet_char_t *src, fnet_size_t n);
259 
260 /***************************************************************************/
275 void fnet_strcpy (fnet_char_t *dest, const fnet_char_t *src);
276 
277 /***************************************************************************/
295 void fnet_strncpy( fnet_char_t *dest, const fnet_char_t *src, fnet_size_t n );
296 
297 /***************************************************************************/
314 fnet_char_t *fnet_strrchr( const fnet_char_t *str, fnet_char_t chr );
315 
316 /***************************************************************************/
334 
335 /***************************************************************************/
353 fnet_char_t *fnet_strstr( const fnet_char_t *str, const fnet_char_t *substr );
354 
355 /***************************************************************************/
373 fnet_int32_t fnet_strcmp( const fnet_char_t *str1, const fnet_char_t *str2 );
374 
375 /***************************************************************************/
398 fnet_int32_t fnet_strncmp( const fnet_char_t *str1, const fnet_char_t *str2, fnet_size_t n );
399 
400 /***************************************************************************/
421 fnet_int32_t fnet_strcasecmp( const fnet_char_t *str1, const fnet_char_t *str2 );
422 
423 /***************************************************************************/
444 fnet_int32_t fnet_strcmp_splitter( const fnet_char_t *in_str, const fnet_char_t *name, fnet_char_t splitter);
445 
446 /***************************************************************************/
472 fnet_uint32_t fnet_strtoul (const fnet_char_t *str, fnet_char_t **ptr, fnet_size_t base);
473 
474 /***************************************************************************/
504 fnet_char_t *fnet_strtok_r(fnet_char_t *str, const fnet_char_t *delimiter, fnet_char_t **last);
505 
506 /***************************************************************************/
521 
522 /***************************************************************************/
533 fnet_uint32_t fnet_rand( void );
534 
535 /***************************************************************************/
546 void fnet_srand( fnet_uint32_t seed );
547 
548 #if defined(__cplusplus)
549 }
550 #endif
551 
554 #endif /* _FNET_STDLIB_H_ */
fnet_char_t * fnet_strchr(const fnet_char_t *str, fnet_char_t chr)
Locates first occurrence of a character in a string.
void fnet_strncpy(fnet_char_t *dest, const fnet_char_t *src, fnet_size_t n)
Copies part of a string.
fnet_int32_t fnet_strncmp(const fnet_char_t *str1, const fnet_char_t *str2, fnet_size_t n)
Compares part of two strings.
unsigned int fnet_flag_t
Unsigned integer type representing the bit flag.
Definition: fnet_stdlib.h:66
fnet_int32_t fnet_strcmp(const fnet_char_t *str1, const fnet_char_t *str2)
Compares two strings.
fnet_return_t
General return codes, used by most of API functions.
Definition: fnet_stdlib.h:90
fnet_char_t * fnet_strrchr(const fnet_char_t *str, fnet_char_t chr)
Locates last occurrence of a character in a string.
fnet_uint32_t fnet_strtoul(const fnet_char_t *str, fnet_char_t **ptr, fnet_size_t base)
Converts string to unsigned long integer.
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
Definition: fnet_stdlib.h:56
fnet_int32_t fnet_memcmp(const void *src1, const void *src2, fnet_size_t count)
Compares memory areas.
fnet_uint32_t fnet_rand(void)
Generates a pseudo-random number.
void fnet_strcat(fnet_char_t *dest, const fnet_char_t *src)
Concatenates two strings.
void fnet_srand(fnet_uint32_t seed)
Initializes the pseudo-random number generator.
fnet_char_t * fnet_strstr(const fnet_char_t *str, const fnet_char_t *substr)
Locates a substring.
fnet_int32_t fnet_strcasecmp(const fnet_char_t *str1, const fnet_char_t *str2)
Compares two strings ignoring case.
fnet_bool_t
Boolean type.
Definition: fnet_stdlib.h:81
fnet_char_t fnet_tolower(fnet_char_t to_lower)
Converts letter to lower case.
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.
void fnet_memset_zero(void *dest, fnet_size_t n)
Sets bytes in memory to zeros.
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.
unsigned int fnet_index_t
Unsigned integer type representing the index.
Definition: fnet_stdlib.h:71
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:76
void fnet_memset(void *dest, fnet_uint8_t value, fnet_size_t n)
Sets bytes in memory.
fnet_size_t fnet_strlen(const fnet_char_t *str)
Calculates the length of a string.
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_strncat(fnet_char_t *dest, const fnet_char_t *src, fnet_size_t n)
Concatenates a string with part of another.
long fnet_ssize_t
Signed integer type representing the size in bytes.
Definition: fnet_stdlib.h:61
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.
void fnet_strcpy(fnet_char_t *dest, const fnet_char_t *src)
Copies a string.

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net