AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Library Reference FAQ Alphabetical Index Example Projects

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 /* $Id: string.h 2427 2014-05-01 14:06:03Z amylaar $ */
32 
33 /*
34  string.h
35 
36  Contributors:
37  Created by Marek Michalkiewicz <marekm@linux.org.pl>
38  */
39 
40 #ifndef _STRING_H_
41 #define _STRING_H_ 1
42 
43 #define __need_NULL
44 #define __need_size_t
45 #include <stddef.h>
46 
47 #ifndef __ATTR_PURE__
48 #define __ATTR_PURE__ __attribute__((__pure__))
49 #endif
50 
51 #ifndef __ATTR_CONST__
52 # define __ATTR_CONST__ __attribute__((__const__))
53 #endif
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /** \file */
60 /** \defgroup avr_string <string.h>: Strings
61  \code #include <string.h> \endcode
62 
63  The string functions perform string operations on NULL terminated
64  strings.
65 
66  \note If the strings you are working on resident in program space (flash),
67  you will need to use the string functions described in \ref avr_pgmspace. */
68 
69 
70 /** \ingroup avr_string
71 
72  This macro finds the first (least significant) bit set in the
73  input value.
74 
75  This macro is very similar to the function ffs() except that
76  it evaluates its argument at compile-time, so it should only
77  be applied to compile-time constant expressions where it will
78  reduce to a constant itself.
79  Application of this macro to expressions that are not constant
80  at compile-time is not recommended, and might result in a huge
81  amount of code generated.
82 
83  \returns The _FFS() macro returns the position of the first
84  (least significant) bit set in the word val, or 0 if no bits are set.
85  The least significant bit is position 1. Only 16 bits of argument
86  are evaluted.
87 */
88 #if defined(__DOXYGEN__)
89 #define _FFS(x)
90 #else /* !DOXYGEN */
91 #define _FFS(x) \
92  (1 \
93  + (((x) & 1) == 0) \
94  + (((x) & 3) == 0) \
95  + (((x) & 7) == 0) \
96  + (((x) & 017) == 0) \
97  + (((x) & 037) == 0) \
98  + (((x) & 077) == 0) \
99  + (((x) & 0177) == 0) \
100  + (((x) & 0377) == 0) \
101  + (((x) & 0777) == 0) \
102  + (((x) & 01777) == 0) \
103  + (((x) & 03777) == 0) \
104  + (((x) & 07777) == 0) \
105  + (((x) & 017777) == 0) \
106  + (((x) & 037777) == 0) \
107  + (((x) & 077777) == 0) \
108  - (((x) & 0177777) == 0) * 16)
109 #endif /* DOXYGEN */
110 
111 extern int ffs (int __val) __ATTR_CONST__;
112 extern int ffsl (long __val) __ATTR_CONST__;
113 __extension__ extern int ffsll (long long __val) __ATTR_CONST__;
114 extern void *memccpy(void *, const void *, int, size_t);
115 extern void *memchr(const void *, int, size_t) __ATTR_PURE__;
116 extern int memcmp(const void *, const void *, size_t) __ATTR_PURE__;
117 extern void *memcpy(void *, const void *, size_t);
118 extern void *memmem(const void *, size_t, const void *, size_t) __ATTR_PURE__;
119 extern void *memmove(void *, const void *, size_t);
120 extern void *memrchr(const void *, int, size_t) __ATTR_PURE__;
121 extern void *memset(void *, int, size_t);
122 extern char *strcat(char *, const char *);
123 extern char *strchr(const char *, int) __ATTR_PURE__;
124 extern char *strchrnul(const char *, int) __ATTR_PURE__;
125 extern int strcmp(const char *, const char *) __ATTR_PURE__;
126 extern char *strcpy(char *, const char *);
127 extern int strcasecmp(const char *, const char *) __ATTR_PURE__;
128 extern char *strcasestr(const char *, const char *) __ATTR_PURE__;
129 extern size_t strcspn(const char *__s, const char *__reject) __ATTR_PURE__;
130 extern char *strdup(const char *s1);
131 extern size_t strlcat(char *, const char *, size_t);
132 extern size_t strlcpy(char *, const char *, size_t);
133 extern size_t strlen(const char *) __ATTR_PURE__;
134 extern char *strlwr(char *);
135 extern char *strncat(char *, const char *, size_t);
136 extern int strncmp(const char *, const char *, size_t) __ATTR_PURE__;
137 extern char *strncpy(char *, const char *, size_t);
138 extern int strncasecmp(const char *, const char *, size_t) __ATTR_PURE__;
139 extern size_t strnlen(const char *, size_t) __ATTR_PURE__;
140 extern char *strpbrk(const char *__s, const char *__accept) __ATTR_PURE__;
141 extern char *strrchr(const char *, int) __ATTR_PURE__;
142 extern char *strrev(char *);
143 extern char *strsep(char **, const char *);
144 extern size_t strspn(const char *__s, const char *__accept) __ATTR_PURE__;
145 extern char *strstr(const char *, const char *) __ATTR_PURE__;
146 extern char *strtok(char *, const char *);
147 extern char *strtok_r(char *, const char *, char **);
148 extern char *strupr(char *);
149 
150 #if 1 /* ??? unimplemented */
151 extern int strcoll(const char *s1, const char *s2);
152 extern char *strerror(int errnum);
153 extern size_t strxfrm(char *dest, const char *src, size_t n);
154 #endif
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* _STRING_H_ */
161 
void * memmem(const void *, size_t, const void *, size_t) __ATTR_PURE__
void * memmove(void *, const void *, size_t)
Copy memory area.
char * strsep(char **, const char *)
Parse a string into tokens.
char * strstr(const char *, const char *) __ATTR_PURE__
Locate a substring.
char * strlwr(char *)
Convert a string to lower case.
void * memcpy(void *, const void *, size_t)
Copy a memory area.
size_t strnlen(const char *, size_t) __ATTR_PURE__
Determine the length of a fixed-size string.
char * strpbrk(const char *__s, const char *__accept) __ATTR_PURE__
int strncmp(const char *, const char *, size_t) __ATTR_PURE__
Compare two strings.
int strncasecmp(const char *, const char *, size_t) __ATTR_PURE__
Compare two strings ignoring case.
void * memset(void *, int, size_t)
Fill memory with a constant byte.
int strcasecmp(const char *, const char *) __ATTR_PURE__
Compare two strings ignoring case.
char * strncat(char *, const char *, size_t)
Concatenate two strings.
size_t strlcpy(char *, const char *, size_t)
Copy a string.
Definition: strlcpy.c:49
char * strtok(char *, const char *)
Parses the string s into tokens.
Definition: strtok.c:57
char * strchr(const char *, int) __ATTR_PURE__
Locate character in string.
int memcmp(const void *, const void *, size_t) __ATTR_PURE__
Compare memory areas.
void * memchr(const void *, int, size_t) __ATTR_PURE__
Scan memory for a character.
char * strchrnul(const char *, int) __ATTR_PURE__
size_t strlen(const char *) __ATTR_PURE__
Calculate the length of a string.
char * strrev(char *)
Reverse a string.
int ffs(int __val)
This function finds the first (least significant) bit set in the input value.
size_t strcspn(const char *__s, const char *__reject) __ATTR_PURE__
int ffsl(long __val)
Same as ffs(), for an argument of type long.
void * memccpy(void *, const void *, int, size_t)
Copy memory area.
char * strdup(const char *s1)
Duplicate a string.
Definition: strdup.c:57
char * strcasestr(const char *, const char *) __ATTR_PURE__
__extension__ int ffsll(long long __val)
Same as ffs(), for an argument of type long long.
int strcmp(const char *, const char *) __ATTR_PURE__
Compare two strings.
char * strupr(char *)
Convert a string to upper case.
void * memrchr(const void *, int, size_t) __ATTR_PURE__
char * strrchr(const char *, int) __ATTR_PURE__
Locate character in string.
char * strtok_r(char *, const char *, char **)
Parses string into tokens.
char * strcat(char *, const char *)
Concatenate two strings.
size_t strspn(const char *__s, const char *__accept) __ATTR_PURE__
char * strcpy(char *, const char *)
Copy a string.
size_t strlcat(char *, const char *, size_t)
Concatenate two strings.
Definition: strlcat.c:50
char * strncpy(char *, const char *, size_t)
Copy a string.

Automatically generated by Doxygen 1.8.7 on Tue Aug 12 2014.