forked from phoenix-rtos/libphoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.h
165 lines (93 loc) · 4.99 KB
/
string.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
* Phoenix-RTOS
*
* libphoenix
*
* string.h
*
* Copyright 2017, 2018 Phoenix Systems
* Author: Pawel Pisarczyk, Aleksander Kaminski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/
#ifndef _LIBPHOENIX_STRING_H_
#define _LIBPHOENIX_STRING_H_
#include <stdint.h>
/*
* Searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string
* pointed to, by the argument str.
*/
extern void *memchr(const void *str, int c, size_t n);
/* Searches backward from the end of the n bytes pointed to by s instead of forward from the beginning. */
extern void *memrchr(const void *s, int c, size_t n);
/* Compares the first n bytes of str1 and str2. */
extern int memcmp(const void *str1, const void *str2, size_t n);
/* Copies n characters from src to dest. - defined in stddef.h */
extern void *memcpy(void *dest, const void *src, size_t n);
/* Copies n characters from src to dest. Return from dest + n. */
extern void *mempcpy(void *dest, const void *src, size_t n);
/* Another function to copy n characters from str2 to str1. */
extern void *memmove(void *dest, const void *src, size_t n);
/* Copies the character c (an unsigned char) to the first n characters of the string pointed to, by the argument str. */
extern void *memset(void *str, int c, size_t n);
/* Copies word v (an unsigned char) to the first n characters of the string pointed to, by the argument str. */
extern void *memsetw(void *str, int v, size_t n);
/* Appends the string pointed to, by src to the end of the string pointed to by dest. */
extern char *strcat(char *dest, const char *src);
/* Appends the string pointed to, by src to the end of the string pointed to, by dest up to n characters long. */
extern char *strncat(char *dest, const char *src, size_t n);
/* Searches for the first occurrence of the character c (an unsigned char) in the string pointed to, by the argument str. */
extern char *strchr(const char *str, int c);
/* Compares the string pointed to, by str1 to the string pointed to by str2. */
extern int strcmp(const char *str1, const char *str2);
/* Compares at most the first n bytes of str1 and str2. */
extern int strncmp(const char *str1, const char *str2, size_t n);
/* Compares string str1 to str2. The result is dependent on the LC_COLLATE setting of the location. */
//extern int strcoll(const char *str1, const char *str2);
#define strcoll strcmp
/* Copies the string pointed to by src to dest. Returns a pointer to the destination string dest */
extern char *strcpy(char *dest, const char *src);
/* Copies the string pointed to by src to dest. Returns a pointer to the end of the string dest */
extern char *stpcpy(char *dest, const char *src);
/* Copies up to n characters from the string pointed to, by src to dest. */
extern char *strncpy(char *dest, const char *src, size_t n);
/* Calculates the length of the initial segment of str1 which consists entirely of characters not in str2. */
extern size_t strcspn(const char *str1, const char *str2);
/* Searches an internal array for the error number errnum and returns a pointer to an error message string. */
extern char *strerror(int errnum);
/* Computes the length of the string str up to but not including the terminating null character. */
extern size_t strlen(const char *str);
/* Computes the length of the string str up to but not including the terminating null character, but checks at most maxlen */
extern size_t strnlen(const char *str, size_t maxlen);
/* Finds the first character in the string str1 that matches any character specified in str2. */
extern char *strpbrk(const char *str1, const char *str2);
/* Searches for the last occurrence of the character c (an unsigned char) in the string pointed to by the argument str. */
extern char *strrchr(const char *str, int c);
/* Calculates the length of the initial segment of str1 which consists entirely of characters in str2. */
extern size_t strspn(const char *str1, const char *str2);
/*
* Finds the first occurrence of the entire string needle (not including the terminating null character)
* which appears in the string haystack.
*/
extern char *strstr(const char *haystack, const char *needle);
/* Like strstr, but ignores case of arguments */
extern char *strcasestr(const char *haystack, const char *needle);
extern char *strsep(char **string_ptr, const char *delimiter);
/* Breaks string str into a series of tokens separated by delim. */
extern char *strtok(char *str, const char *delim);
/* Transforms the first n characters of the string src into corrent locale and places them in the string dest. */
extern size_t strxfrm(char *dest, const char *src, size_t n);
extern char *strchrnul(const char *str, int z);
extern char *strchr(const char *str, int z);
extern char *strdup(const char *s1);
extern int strverscmp(const char *s1, const char *s2);
extern char *strsignal(int sig);
__attribute__((always_inline))
static inline void bzero(void *p, size_t sz)
{
memset(p, 0, sz);
}
extern int strcasecmp(const char *str1, const char *str2);
#endif