AVR Libc Home Page |  | 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 1831 2008-12-21 02:27:49Z dmix $ */
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 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 #ifdef __cplusplus
151 }
152 #endif
153
154 #endif /* _STRING_H_ */
155

Automatically generated by Doxygen 1.8.3.1 on Sat Jun 22 2013.