AVR-LibC  2.3.0git
Standard C library for AVR-GCC
 

AVR-LibC Documen­tation

AVR-LibC Development Pages

Main Page

User Manual

Library Refe­rence

FAQ

Example Projects

File List

Index

Loading...
Searching...
No Matches
string.h
Go to the documentation of this file.
1/* Copyright (c) 2002,2007 Marek Michalkiewicz
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in
12 the documentation and/or other materials provided with the
13 distribution.
14
15 * Neither the name of the copyright holders nor the names of
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 POSSIBILITY OF SUCH DAMAGE. */
30
31/*
32 string.h
33
34 Contributors:
35 Created by Marek Michalkiewicz <marekm@linux.org.pl>
36 */
37
38#ifndef _STRING_H_
39#define _STRING_H_ 1
40
41#ifndef __DOXYGEN__
42#define __need_NULL
43#define __need_size_t
44#include <stddef.h>
45#include <bits/attribs.h>
46
47#endif /* !__DOXYGEN__ */
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53/** \file */
54/** \defgroup avr_string <string.h>: Strings
55 \code #include <string.h> \endcode
56
57 The string functions perform string operations on \c NULL terminated
58 strings.
59
60 \note If the strings you are working on resident in program space (flash),
61 you will need to use the string functions described in \ref avr_pgmspace. */
62
63
64/** \ingroup avr_string
65
66 This macro finds the first (least significant) bit set in the
67 input value.
68
69 This macro is very similar to the function ffs() except that
70 it evaluates its argument at compile-time, so it should only
71 be applied to compile-time constant expressions where it will
72 reduce to a constant itself.
73 Application of this macro to expressions that are not constant
74 at compile-time is not recommended, and might result in a huge
75 amount of code generated.
76
77 \returns The _FFS() macro returns the position of the first
78 (least significant) bit set in the word val, or 0 if no bits are set.
79 The least significant bit is position 1. Only 16 bits of argument
80 are evaluated.
81*/
82#if defined(__DOXYGEN__)
83#define _FFS(x)
84#else /* !DOXYGEN */
85#define _FFS(x) \
86 (1 \
87 + (((x) & 1) == 0) \
88 + (((x) & 3) == 0) \
89 + (((x) & 7) == 0) \
90 + (((x) & 017) == 0) \
91 + (((x) & 037) == 0) \
92 + (((x) & 077) == 0) \
93 + (((x) & 0177) == 0) \
94 + (((x) & 0377) == 0) \
95 + (((x) & 0777) == 0) \
96 + (((x) & 01777) == 0) \
97 + (((x) & 03777) == 0) \
98 + (((x) & 07777) == 0) \
99 + (((x) & 017777) == 0) \
100 + (((x) & 037777) == 0) \
101 + (((x) & 077777) == 0) \
102 - (((x) & 0177777) == 0) * 16)
103#endif /* DOXYGEN */
104
105/** \ingroup avr_string
106 \fn int ffs(int val);
107
108 \brief This function finds the first (least significant) bit set in the input value.
109
110 \returns The ffs() function returns the position of the first
111 (least significant) bit set in the word \p val, or 0 if no bits are set.
112 The least significant bit is position 1.
113
114 \note For expressions that are constant at compile time, consider
115 using the \ref _FFS macro instead.
116*/
117extern int ffs(int __val) __ATTR_CONST__;
118
119/** \ingroup avr_string
120 \fn int ffsl(long val);
121
122 \brief Same as ffs(), for an argument of type long. */
123extern int ffsl(long __val) __ATTR_CONST__;
124
125/** \ingroup avr_string
126 \fn int ffsll(long long val);
127
128 \brief Same as ffs(), for an argument of type <tt>long long</tt>. */
129__extension__ extern int ffsll(long long __val) __ATTR_CONST__;
130
131/** \ingroup avr_string
132 \fn void *memccpy(void *dest, const void *src, int val, size_t len)
133 \brief Copy memory area.
134
135 The memccpy() function copies no more than \p len bytes from memory
136 area \p src to memory area \p dest, stopping when the character \p val
137 is found.
138
139 \returns The memccpy() function returns a pointer to the next character
140 in \p dest after \p val, or \c NULL if \p val was not found in the first
141 \p len characters of \p src. */
142extern void *memccpy(void *, const void *, int, size_t);
143
144/** \ingroup avr_string
145 \fn void *memchr(const void *src, int val, size_t len)
146 \brief Scan memory for a character.
147
148 The memchr() function scans the first len bytes of the memory area pointed
149 to by src for the character val. The first byte to match val (interpreted
150 as an unsigned character) stops the operation.
151
152 \returns The memchr() function returns a pointer to the matching byte or
153 NULL if the character does not occur in the given memory area. */
154extern void *memchr(const void *, int, size_t) __ATTR_PURE__;
155
156/** \ingroup avr_string
157 \fn int memcmp(const void *s1, const void *s2, size_t len)
158 \brief Compare memory areas
159
160 The memcmp() function compares the first len bytes of the memory areas s1
161 and s2. The comparision is performed using unsigned char operations.
162
163 \returns The memcmp() function returns an integer less than, equal to, or
164 greater than zero if the first len bytes of s1 is found, respectively, to be
165 less than, to match, or be greater than the first len bytes of s2.
166
167 \note Be sure to store the result in a 16 bit variable since you may get
168 incorrect results if you use an unsigned char or char due to truncation.
169
170 \warning This function is not -mint8 compatible, although if you only care
171 about testing for equality, this function should be safe to use. */
172extern int memcmp(const void *, const void *, size_t) __ATTR_PURE__;
173
174/** \ingroup avr_string
175 \fn void *memcpy(void *dest, const void *src, size_t len)
176 \brief Copy a memory area.
177
178 The memcpy() function copies len bytes from memory area src to memory area
179 dest. The memory areas may not overlap. Use memmove() if the memory
180 areas do overlap.
181
182 \returns The memcpy() function returns a pointer to dest. */
183extern void *memcpy(void *, const void *, size_t);
184
185/** \ingroup avr_string
186 \fn void *memmem(const void *s1, size_t len1, const void *s2, size_t len2)
187
188 The memmem() function finds the start of the first occurrence of the
189 substring \p s2 of length \p len2 in the memory area \p s1 of length
190 \p len1.
191
192 \return The memmem() function returns a pointer to the beginning of
193 the substring, or \c NULL if the substring is not found. If \p len2
194 is zero, the function returns \p s1. */
195extern void *memmem(const void *, size_t, const void *, size_t) __ATTR_PURE__;
196
197/** \ingroup avr_string
198 \fn void *memmove(void *dest, const void *src, size_t len)
199 \brief Copy memory area.
200
201 The memmove() function copies len bytes from memory area src to memory area
202 dest. The memory areas may overlap.
203
204 \returns The memmove() function returns a pointer to dest. */
205extern void *memmove(void *, const void *, size_t);
206
207/** \ingroup avr_string
208 \fn void *memrchr(const void *src, int val, size_t len)
209
210 The memrchr() function is like the memchr() function, except that it
211 searches backwards from the end of the \p len bytes pointed to by \p
212 src instead of forwards from the front. (Glibc, GNU extension.)
213
214 \return The memrchr() function returns a pointer to the matching
215 byte or \c NULL if the character does not occur in the given memory
216 area. */
217extern void *memrchr(const void *, int, size_t) __ATTR_PURE__;
218
219/** \ingroup avr_string
220 \fn void *memset(void *dest, int val, size_t len)
221 \brief Fill memory with a constant byte.
222
223 The memset() function fills the first len bytes of the memory area pointed
224 to by dest with the constant byte val.
225
226 \returns The memset() function returns a pointer to the memory area dest. */
227extern void *memset(void *, int, size_t);
228
229/** \ingroup avr_string
230 \fn char *strcat(char *dest, const char *src)
231 \brief Concatenate two strings.
232
233 The strcat() function appends the src string to the dest string
234 overwriting the '\\0' character at the end of dest, and then adds a
235 terminating '\\0' character. The strings may not overlap, and the dest
236 string must have enough space for the result.
237
238 \returns The strcat() function returns a pointer to the resulting string
239 dest. */
240extern char *strcat(char *, const char *);
241
242/** \ingroup avr_string
243 \fn char *strchr(const char *src, int val)
244 \brief Locate character in string.
245
246 \returns The strchr() function returns a pointer to the first occurrence of
247 the character \p val in the string \p src, or \c NULL if the character
248 is not found.
249 <br><br>
250 Here "character" means "byte" -- these functions do not work with
251 wide or multi-byte characters. */
252#ifdef __DOXYGEN__
253extern char *strchr(const char *, int) __ATTR_PURE__;
254#else
255extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
256char * strchr(const char *__hay, int __val)
257{
258 register char *__r24 __asm("24");
259 register int __r22 __asm("22") = __val;
260 __asm ("%~call strchr"
261 : "=r" (__r24) : "0" (__hay), "r" (__r22) : "30", "31");
262 return __r24;
263}
264#endif /* DOXYGEN */
265
266/** \ingroup avr_string
267 \fn char *strchrnul(const char *s, int c)
268
269 The strchrnul() function is like strchr() except that if \p c is not
270 found in \p s, then it returns a pointer to the null byte at the end
271 of \p s, rather than \c NULL. (Glibc, GNU extension.)
272
273 \return The strchrnul() function returns a pointer to the matched
274 character, or a pointer to the null byte at the end of \p s (i.e.,
275 \c s+strlen(s)) if the character is not found. */
276extern char *strchrnul(const char *, int) __ATTR_PURE__;
277
278/** \ingroup avr_string
279 \fn int strcmp(const char *s1, const char *s2)
280 \brief Compare two strings.
281
282 The strcmp() function compares the two strings \p s1 and \p s2.
283
284 \returns The strcmp() function returns an integer less than, equal
285 to, or greater than zero if \p s1 is found, respectively, to be less
286 than, to match, or be greater than \p s2. A consequence of the
287 ordering used by strcmp() is that if \p s1 is an initial substring
288 of \p s2, then \p s1 is considered to be "less than" \p s2. */
289extern int strcmp(const char *, const char *) __ATTR_PURE__;
290
291/** \ingroup avr_string
292 \fn char *strcpy(char *dest, const char *src)
293 \brief Copy a string.
294
295 The strcpy() function copies the string pointed to by src (including the
296 terminating '\\0' character) to the array pointed to by dest. The strings
297 may not overlap, and the destination string dest must be large enough to
298 receive the copy.
299
300 \returns The strcpy() function returns a pointer to the destination
301 string dest.
302
303 \see strncpy(), stpcpy(), strcpy_P(), strcpy_F(). */
304extern char *strcpy(char *, const char *);
305
306/** \ingroup avr_string
307 \fn char *stpcpy(char *dest, const char *src)
308 \brief Copy a string.
309
310 The stpcpy() function copies the string pointed to by \p src
311 (including the terminating '\\0' character) to the array pointed
312 to by \p dest.
313 The strings may not overlap, and the destination string \p dest must
314 be large enough to receive the copy.
315
316 \returns The stpcpy() function returns a pointer to the <b>end</b> of
317 the string \p dest (that is, the address of the terminating null byte)
318 rather than the beginning.
319
320 \since AVR-LibC v2.3 */
321extern char *stpcpy(char *, const char *);
322
323/** \ingroup avr_string
324 \fn int strcasecmp(const char *s1, const char *s2)
325 \brief Compare two strings ignoring case.
326
327 The strcasecmp() function compares the two strings \p s1 and \p s2,
328 ignoring the case of the characters.
329
330 \returns The strcasecmp() function returns an integer less than,
331 equal to, or greater than zero if \p s1 is found, respectively, to
332 be less than, to match, or be greater than \p s2. A consequence of
333 the ordering used by strcasecmp() is that if \p s1 is an initial
334 substring of \p s2, then \p s1 is considered to be "less than"
335 \p s2. */
336extern int strcasecmp(const char *, const char *) __ATTR_PURE__;
337
338/** \ingroup avr_string
339 \fn char *strcasestr(const char *s1, const char *s2)
340
341 The strcasestr() function finds the first occurrence of the
342 substring \p s2 in the string \p s1. This is like strstr(), except
343 that it ignores case of alphabetic symbols in searching for the
344 substring. (Glibc, GNU extension.)
345
346 \return The strcasestr() function returns a pointer to the beginning
347 of the substring, or \c NULL if the substring is not found. If \p s2
348 points to a string of zero length, the function returns \p s1. */
349extern char *strcasestr(const char *, const char *) __ATTR_PURE__;
350
351/** \ingroup avr_string
352 \fn size_t strcspn(const char *s, const char *reject)
353
354 The strcspn() function calculates the length of the initial segment
355 of \p s which consists entirely of characters not in \p reject.
356
357 \return The strcspn() function returns the number of characters in
358 the initial segment of \p s which are not in the string \p reject.
359 The terminating zero is not considered as a part of string. */
360extern size_t strcspn(const char *__s, const char *__reject) __ATTR_PURE__;
361
362/** \ingroup avr_string
363 \fn char *strdup(const char *s1)
364 \brief Duplicate a string.
365
366 The strdup() function allocates memory and copies into it the string
367 addressed by \p s1, including the terminating null character.
368
369 \warning The strdup() function calls malloc() to allocate the memory
370 for the duplicated string! The user is responsible for freeing the
371 memory by calling free().
372
373 \returns The strdup() function returns a pointer to the resulting string
374 dest. If malloc() cannot allocate enough storage for the string, strdup()
375 will return \c NULL.
376
377 \warning Be sure to check the return value of the strdup() function to
378 make sure that the function has succeeded in allocating the memory!
379*/
380extern char *strdup(const char *s1);
381
382/** \ingroup avr_string
383 \fn char *strndup(const char *s, size_t len)
384 \brief Duplicate a string.
385
386 The strndup() function is similar to strdup(), but copies at most
387 \p len bytes. If \p s is longer than \p len, only \p len bytes are copied,
388 and a terminating null byte (<tt>'\0'</tt>) is added.
389
390 Memory for the new string is obtained with malloc(), and can be freed
391 with free().
392
393 \returns The strndup() function returns the location of the newly malloc'ed
394 memory, or \c NULL if the allocation failed.
395*/
396extern char *strndup(const char *s, size_t n);
397
398/** \ingroup avr_string
399 \fn size_t strlcat(char *dst, const char *src, size_t siz)
400 \brief Concatenate two strings.
401
402 Appends \p src to string \p dst of size \p siz (unlike strncat(),
403 \p siz is the full size of \p dst, not space left). At most \p siz-1
404 characters will be copied. Always \p '\\0' terminated (unless \p siz <=
405 \p strlen(dst)).
406
407 \returns The strlcat() function returns strlen(src) + MIN(siz,
408 strlen(initial dst)). If retval >= siz, truncation occurred. */
409extern size_t strlcat(char *, const char *, size_t);
410
411/** \ingroup avr_string
412 \fn size_t strlcpy(char *dst, const char *src, size_t siz)
413 \brief Copy a string.
414
415 Copy \p src to string \p dst of size \p siz. At most \p siz-1
416 characters will be copied. Always '\\0' terminated (unless \p siz == 0).
417
418 \returns The strlcpy() function returns strlen(src). If retval >= siz,
419 truncation occurred. */
420extern size_t strlcpy(char *, const char *, size_t);
421
422/** \ingroup avr_string
423 \fn size_t strlen(const char *src)
424 \brief Calculate the length of a string.
425
426 The strlen() function calculates the length of the string \p src, not
427 including the terminating '\\0' character.
428
429 \returns The strlen() function returns the number of characters in
430 \p src. */
431extern size_t strlen(const char *) __ATTR_PURE__;
432
433/** \ingroup avr_string
434 \fn char *strlwr(char *s)
435 \brief Convert a string to lower case.
436
437 The strlwr() function will convert a string to lower case. Only the upper
438 case alphabetic characters [A .. Z] are converted. Non-alphabetic
439 characters will not be changed.
440
441 \returns The strlwr() function returns a pointer to the converted
442 string. Conversion is perfomed in-place. */
443extern char *strlwr(char *);
444
445/** \ingroup avr_string
446 \fn char *strncat(char *dest, const char *src, size_t len)
447 \brief Concatenate two strings.
448
449 The strncat() function is similar to strcat(), except that only the first
450 \p len characters of \p src are appended to \p dest.
451
452 \returns The strncat() function returns a pointer to the resulting string
453 \p dest. */
454extern char *strncat(char *, const char *, size_t);
455
456/** \ingroup avr_string
457 \fn int strncmp(const char *s1, const char *s2, size_t len)
458 \brief Compare two strings.
459
460 The strncmp() function is similar to strcmp(), except it only compares the
461 first (at most) \p len characters of \p s1 and \p s2.
462
463 \returns The strncmp() function returns an integer less than, equal to, or
464 greater than zero if \p s1 (or the first \p len bytes thereof) is found,
465 respectively, to be less than, to match, or be greater than \p s2. */
466extern int strncmp(const char *, const char *, size_t) __ATTR_PURE__;
467
468/** \ingroup avr_string
469 \fn char *strncpy(char *dest, const char *src, size_t len)
470 \brief Copy a string.
471
472 The strncpy() function is similar to strcpy(), except that not more than
473 \p len bytes of \p src are copied. Thus, if there is no null byte among
474 the first \p len bytes of \p src, the result will not be null-terminated.
475
476 In the case where the length of \p src is less than that of \p len,
477 the remainder of \p dest will be padded with nulls (<tt>'\0'</tt>).
478
479 \returns The strncpy() function returns a pointer to the destination
480 string \p dest. */
481extern char *strncpy(char *, const char *, size_t);
482
483/** \ingroup avr_string
484 \fn int strncasecmp(const char *s1, const char *s2, size_t len)
485 \brief Compare two strings ignoring case.
486
487 The strncasecmp() function is similar to strcasecmp(), except it
488 only compares the first \p len characters of \p s1.
489
490 \returns The strncasecmp() function returns an integer less than,
491 equal to, or greater than zero if \p s1 (or the first \p len bytes
492 thereof) is found, respectively, to be less than, to match, or be
493 greater than \p s2. A consequence of the ordering used by
494 strncasecmp() is that if \p s1 is an initial substring of \p s2,
495 then \p s1 is considered to be "less than" \p s2. */
496extern int strncasecmp(const char *, const char *, size_t) __ATTR_PURE__;
497
498/** \ingroup avr_string
499 \fn size_t strnlen(const char *src, size_t len)
500 \brief Determine the length of a fixed-size string.
501
502 The strnlen() function returns the number of characters in the string
503 pointed to by \p src, not including the terminating '\\0' character, but at
504 most \p len. In doing this, strnlen() looks only at the first \p len
505 characters at \p src and never beyond \p src + \p len.
506
507 \returns The strnlen function returns strlen(src), if that is less than
508 \p len, or \p len if there is no '\\0' character among the first \p len
509 characters pointed to by \p src. */
510extern size_t strnlen(const char *, size_t) __ATTR_PURE__;
511
512/** \ingroup avr_string
513 \fn char *strpbrk(const char *s, const char *accept)
514
515 The strpbrk() function locates the first occurrence in the string
516 \p s of any of the characters in the string \p accept.
517
518 \return The strpbrk() function returns a pointer to the character
519 in \p s that matches one of the characters in \p accept, or \c NULL
520 if no such character is found. The terminating zero is not
521 considered as a part of string: if one or both args are empty, the
522 result will be \c NULL. */
523extern char *strpbrk(const char *__s, const char *__accept) __ATTR_PURE__;
524
525/** \ingroup avr_string
526 \fn char *strrchr(const char *src, int val)
527 \brief Locate character in string.
528
529 The strrchr() function returns a pointer to the last occurrence of the
530 character val in the string src.
531
532 Here "character" means "byte" -- these functions do not work with wide or
533 multi-byte characters.
534
535 \returns The strrchr() function returns a pointer to the matched character
536 or \c NULL if the character is not found. */
537extern char *strrchr(const char *, int) __ATTR_PURE__;
538
539/** \ingroup avr_string
540 \fn char *strrev(char *s)
541 \brief Reverse a string.
542
543 The strrev() function reverses the order of the string.
544
545 \returns The strrev() function returns a pointer to the beginning of the
546 reversed string. */
547extern char *strrev(char *);
548
549/** \ingroup avr_string
550 \fn char *strsep(char **sp, const char *delim)
551 \brief Parse a string into tokens.
552
553 The strsep() function locates, in the string referenced by \p *sp,
554 the first occurrence of any character in the string \p delim (or the
555 terminating '\\0' character) and replaces it with a '\\0'. The
556 location of the next character after the delimiter character (or \c
557 NULL, if the end of the string was reached) is stored in \p *sp. An
558 ``empty'' field, i.e. one caused by two adjacent delimiter
559 characters, can be detected by comparing the location referenced by
560 the pointer returned in \p *sp to '\\0'.
561
562 \return The strsep() function returns a pointer to the original
563 value of \p *sp. If \p *sp is initially \c NULL, strsep() returns
564 \c NULL. */
565extern char *strsep(char **, const char *);
566
567/** \ingroup avr_string
568 \fn size_t strspn(const char *s, const char *accept)
569
570 The strspn() function calculates the length of the initial segment
571 of \p s which consists entirely of characters in \p accept.
572
573 \return The strspn() function returns the number of characters in
574 the initial segment of \p s which consist only of characters from \p
575 accept. The terminating zero is not considered as a part of string. */
576extern size_t strspn(const char *__s, const char *__accept) __ATTR_PURE__;
577
578/** \ingroup avr_string
579 \fn char *strstr(const char *s1, const char *s2)
580 \brief Locate a substring.
581
582 The strstr() function finds the first occurrence of the substring \p
583 s2 in the string \p s1. The terminating '\\0' characters are not
584 compared.
585
586 \returns The strstr() function returns a pointer to the beginning of
587 the substring, or \c NULL if the substring is not found. If \p s2
588 points to a string of zero length, the function returns \p s1. */
589extern char *strstr(const char *, const char *) __ATTR_PURE__;
590
591/** \ingroup avr_string
592 \fn char *strtok(char *s, const char *delim)
593 \brief Parses the string s into tokens.
594
595 strtok parses the string s into tokens. The first call to strtok
596 should have s as its first argument. Subsequent calls should have
597 the first argument set to \c NULL. If a token ends with a delimiter, this
598 delimiting character is overwritten with a '\\0' and a pointer to the next
599 character is saved for the next call to strtok. The delimiter string
600 delim may be different for each call.
601
602 \returns The strtok() function returns a pointer to the next token or
603 \c NULL when no more tokens are found.
604
605 \note strtok() is NOT reentrant. For a reentrant version of this function
606 see \c strtok_r().
607*/
608extern char *strtok(char *, const char *);
609
610/** \ingroup avr_string
611 \fn char *strtok_r(char *string, const char *delim, char **last)
612 \brief Parses string into tokens.
613
614 strtok_r parses string into tokens. The first call to strtok_r
615 should have string as its first argument. Subsequent calls should have
616 the first argument set to \c NULL. If a token ends with a delimiter, this
617 delimiting character is overwritten with a '\\0' and a pointer to the next
618 character is saved for the next call to strtok_r. The delimiter string
619 \p delim may be different for each call. \p last is a user allocated char*
620 pointer. It must be the same while parsing the same string. strtok_r is
621 a reentrant version of strtok().
622
623 \returns The strtok_r() function returns a pointer to the next token or
624 \c NULL when no more tokens are found. */
625extern char *strtok_r(char *, const char *, char **);
626
627/** \ingroup avr_string
628 \fn char *strupr(char *s)
629 \brief Convert a string to upper case.
630
631 The strupr() function will convert a string to upper case. Only the lower
632 case alphabetic characters [a .. z] are converted. Non-alphabetic
633 characters will not be changed.
634
635 \returns The strupr() function returns a pointer to the converted
636 string. The pointer is the same as that passed in since the operation is
637 perform in place. */
638extern char *strupr(char *);
639
640#ifndef __DOXYGEN__
641/* libstdc++ compatibility, dummy declarations */
642extern int strcoll(const char *s1, const char *s2);
643extern char *strerror(int errnum);
644extern size_t strxfrm(char *dest, const char *src, size_t n);
645
646/* strlen is common so we model its GPR footprint. */
647extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
648size_t strlen(const char *__s)
649{
650 if (__builtin_constant_p (__builtin_strlen (__s)))
651 {
652 return __builtin_strlen (__s);
653 }
654 else
655 {
656 register const char *__r24 __asm("24") = __s;
657 register size_t __res __asm("24");
658 __asm ("%~call %x2" : "=r" (__res) : "r" (__r24), "i" (strlen)
659 : "30", "31", "memory");
660 return __res;
661 }
662}
663
664/* strcpy is common so we model its GPR footprint. */
665extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
666char* strcpy(char *__x, const char *__z)
667{
668 char *__ret = __x;
669 __asm volatile ("%~call __strcpy"
670 : "+x" (__x), "+z" (__z) :: "memory");
671 return __ret;
672}
673
674extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
675char* stpcpy(char *__x, const char *__z)
676{
677 __asm volatile ("%~call __strcpy"
678 : "+x" (__x), "+z" (__z) :: "memory");
679 return __x - 1;
680}
681
682/* strcmp is common so we model its GPR footprint. */
683extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
684int strcmp(const char *__x, const char *__z)
685{
686 register int __ret __asm("24");
687 __asm ("%~call __strcmp"
688 : "=r" (__ret), "+x" (__x), "+z" (__z) :: "memory");
689 return __ret;
690}
691
692#endif /* !__DOXYGEN__ */
693
694#ifdef __cplusplus
695}
696#endif
697
698#endif /* _STRING_H_ */
699
int strncasecmp(const char *, const char *, size_t)
Compare two strings ignoring case.
void * memchr(const void *, int, size_t)
Scan memory for a character.
int memcmp(const void *, const void *, size_t)
Compare memory areas.
char * strlwr(char *)
Convert a string to lower case.
char * strstr(const char *, const char *)
Locate a substring.
char * strcat(char *, const char *)
Concatenate two strings.
size_t strlen(const char *)
Calculate the length of a string.
int strcmp(const char *, const char *)
Compare two strings.
char * strchrnul(const char *, int)
char * strpbrk(const char *__s, const char *__accept)
char * strrchr(const char *, int)
Locate character in string.
char * strcpy(char *, const char *)
Copy a string.
void * memcpy(void *, const void *, size_t)
Copy a memory area.
size_t strlcat(char *, const char *, size_t)
Concatenate two strings.
Definition: strlcat.c:49
size_t strlcpy(char *, const char *, size_t)
Copy a string.
Definition: strlcpy.c:48
char * strtok(char *, const char *)
Parses the string s into tokens.
Definition: strtok.c:39
int strncmp(const char *, const char *, size_t)
Compare two strings.
char * strncpy(char *, const char *, size_t)
Copy a string.
char * strdup(const char *s1)
Duplicate a string.
Definition: strdup.c:35
void * memmove(void *, const void *, size_t)
Copy memory area.
void * memccpy(void *, const void *, int, size_t)
Copy memory area.
void * memset(void *, int, size_t)
Fill memory with a constant byte.
int strcasecmp(const char *, const char *)
Compare two strings ignoring case.
char * strchr(const char *, int)
Locate character in string.
char * strupr(char *)
Convert a string to upper case.
int ffs(int __val)
This function finds the first (least significant) bit set in the input value.
char * strtok_r(char *, const char *, char **)
Parses string into tokens.
void * memrchr(const void *, int, size_t)
char * stpcpy(char *, const char *)
Copy a string.
void * memmem(const void *, size_t, const void *, size_t)
char * strcasestr(const char *, const char *)
int ffsl(long __val)
Same as ffs(), for an argument of type long.
char * strrev(char *)
Reverse a string.
size_t strcspn(const char *__s, const char *__reject)
int ffsll(long long __val)
Same as ffs(), for an argument of type long long.
size_t strnlen(const char *, size_t)
Determine the length of a fixed-size string.
size_t strspn(const char *__s, const char *__accept)
char * strndup(const char *s, size_t n)
Duplicate a string.
Definition: strndup.c:32
char * strncat(char *, const char *, size_t)
Concatenate two strings.
char * strsep(char **, const char *)
Parse a string into tokens.