YAMI4Industry
utils.h
Go to the documentation of this file.
1 /* Copyright Inspirel Sp. z o.o. 2013-2015.
2  * This file is part of YAMI4.
3  *
4  * YAMI4 is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * YAMI4 is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef YAMI4INDUSTRY_UTILS_H
19 #define YAMI4INDUSTRY_UTILS_H
20 
21 #include <stddef.h>
22 #include <stdint.h>
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif /* __cplusplus */
28 
35 size_t yami_round_up_to_4(size_t v);
36 
43 size_t yami_round_up_to_8(size_t v);
44 
47 size_t yami_strlen(const char s[]);
48 
51 int32_t yami_strcmp(const char s1[], const char s2[]);
52 
55 int32_t yami_strncmp(const char s1[], const char s2[], size_t n);
56 
59 void yami_strncpy(char dest[], const char src[], size_t n);
60 
70 int32_t yami_strfind(const char s[], char c, size_t from, size_t to);
71 
74 void yami_memcpy(uint8_t dest[], size_t dest_from,
75  const uint8_t src[], size_t src_from, size_t n);
76 
79 void yami_bzero(uint8_t dest[], size_t n);
80 
90 int32_t yami_uint32_to_string(uint32_t v, char buf[], size_t buf_from,
91  size_t buf_size);
92 
102 int32_t yami_string_to_uint32(const char buf[],
103  size_t from, size_t to, uint32_t * out_value);
104 
114 int32_t yami_string_to_uint8(const char buf[],
115  size_t from, size_t to, uint8_t * out_value);
116 
117 #ifdef __cplusplus
118 }
119 #endif /* __cplusplus */
120 
121 #endif /* YAMI4INDUSTRY_UTILS_H */
int32_t yami_string_to_uint8(const char buf[], size_t from, size_t to, uint8_t *out_value)
Converts nul-terminated string to uint8_t.
Definition: utils.c:340
int32_t yami_string_to_uint32(const char buf[], size_t from, size_t to, uint32_t *out_value)
Converts nul-terminated string to uint32_t.
Definition: utils.c:297
void yami_memcpy(uint8_t dest[], size_t dest_from, const uint8_t src[], size_t src_from, size_t n)
Replacement for standard memcpy.
Definition: utils.c:200
size_t yami_round_up_to_8(size_t v)
Rounds the given value to the nearest 8 (for alignment).
Definition: utils.c:50
int32_t yami_strfind(const char s[], char c, size_t from, size_t to)
Finds the given character in nul-terminated string.
Definition: utils.c:179
int32_t yami_uint32_to_string(uint32_t v, char buf[], size_t buf_from, size_t buf_size)
Converts uint32_t to string format.
Definition: utils.c:223
int32_t yami_strcmp(const char s1[], const char s2[])
Replacement for standard strcmp.
Definition: utils.c:106
void yami_strncpy(char dest[], const char src[], size_t n)
Replacement for standard strncpy.
Definition: utils.c:158
size_t yami_strlen(const char s[])
Replacement for standard strlen.
Definition: utils.c:93
void yami_bzero(uint8_t dest[], size_t n)
Replacement for standard bzero.
Definition: utils.c:212
int32_t yami_strncmp(const char s1[], const char s2[], size_t n)
Replacement for standard strncmp.
Definition: utils.c:134
size_t yami_round_up_to_4(size_t v)
Rounds the given value to the nearest 4 (for alignment).
Definition: utils.c:23