AVR-LibC
2.2.0
Standard C library for AVR-GCC
|
AVR-LibC Documentation |
AVR-LibC Development Pages |
||||
Main Page |
User Manual |
Library Reference |
FAQ |
Example Projects |
File List |
Macros | |
#define | _FFS(x) |
Functions | |
int | ffs (int __val) |
int | ffsl (long __val) |
int | ffsll (long long __val) |
void * | memccpy (void *, const void *, int, size_t) |
void * | memchr (const void *, int, size_t) |
int | memcmp (const void *, const void *, size_t) |
void * | memcpy (void *, const void *, size_t) |
void * | memmem (const void *, size_t, const void *, size_t) |
void * | memmove (void *, const void *, size_t) |
void * | memrchr (const void *, int, size_t) |
void * | memset (void *, int, size_t) |
char * | strcat (char *, const char *) |
char * | strchr (const char *, int) |
char * | strchrnul (const char *, int) |
int | strcmp (const char *, const char *) |
char * | strcpy (char *, const char *) |
int | strcasecmp (const char *, const char *) |
char * | strcasestr (const char *, const char *) |
size_t | strcspn (const char *__s, const char *__reject) |
char * | strdup (const char *s1) |
char * | strndup (const char *s, size_t n) |
size_t | strlcat (char *, const char *, size_t) |
size_t | strlcpy (char *, const char *, size_t) |
size_t | strlen (const char *) |
char * | strlwr (char *) |
char * | strncat (char *, const char *, size_t) |
int | strncmp (const char *, const char *, size_t) |
char * | strncpy (char *, const char *, size_t) |
int | strncasecmp (const char *, const char *, size_t) |
size_t | strnlen (const char *, size_t) |
char * | strpbrk (const char *__s, const char *__accept) |
char * | strrchr (const char *, int) |
char * | strrev (char *) |
char * | strsep (char **, const char *) |
size_t | strspn (const char *__s, const char *__accept) |
char * | strstr (const char *, const char *) |
char * | strtok (char *, const char *) |
char * | strtok_r (char *, const char *, char **) |
char * | strupr (char *) |
The string functions perform string operations on NULL
terminated strings.
#define _FFS | ( | x | ) |
This macro finds the first (least significant) bit set in the input value.
This macro is very similar to the function ffs() except that it evaluates its argument at compile-time, so it should only be applied to compile-time constant expressions where it will reduce to a constant itself. Application of this macro to expressions that are not constant at compile-time is not recommended, and might result in a huge amount of code generated.
int ffs | ( | int | val | ) |
This function finds the first (least significant) bit set in the input value.
val
, or 0 if no bits are set. The least significant bit is position 1.int ffsl | ( | long | __val | ) |
Same as ffs(), for an argument of type long.
int ffsll | ( | long long | __val | ) |
Same as ffs(), for an argument of type long long
.
void * memccpy | ( | void * | dest, |
const void * | src, | ||
int | val, | ||
size_t | len | ||
) |
Copy memory area.
The memccpy() function copies no more than len
bytes from memory area src
to memory area dest
, stopping when the character val
is found.
dest
after val
, or NULL
if val
was not found in the first len
characters of src
. void * memchr | ( | const void * | src, |
int | val, | ||
size_t | len | ||
) |
Scan memory for a character.
The memchr() function scans the first len bytes of the memory area pointed to by src for the character val. The first byte to match val (interpreted as an unsigned character) stops the operation.
int memcmp | ( | const void * | s1, |
const void * | s2, | ||
size_t | len | ||
) |
Compare memory areas.
The memcmp() function compares the first len bytes of the memory areas s1 and s2. The comparision is performed using unsigned char operations.
void * memcpy | ( | void * | dest, |
const void * | src, | ||
size_t | len | ||
) |
void * memmem | ( | const void * | s1, |
size_t | len1, | ||
const void * | s2, | ||
size_t | len2 | ||
) |
void * memmove | ( | void * | dest, |
const void * | src, | ||
size_t | len | ||
) |
void * memrchr | ( | const void * | src, |
int | val, | ||
size_t | len | ||
) |
The memrchr() function is like the memchr() function, except that it searches backwards from the end of the len
bytes pointed to by src
instead of forwards from the front. (Glibc, GNU extension.)
NULL
if the character does not occur in the given memory area. void * memset | ( | void * | dest, |
int | val, | ||
size_t | len | ||
) |
int strcasecmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Compare two strings ignoring case.
The strcasecmp() function compares the two strings s1
and s2
, ignoring the case of the characters.
s1
is found, respectively, to be less than, to match, or be greater than s2
. A consequence of the ordering used by strcasecmp() is that if s1
is an initial substring of s2
, then s1
is considered to be "less than" s2
. char * strcasestr | ( | const char * | s1, |
const char * | s2 | ||
) |
The strcasestr() function finds the first occurrence of the substring s2
in the string s1
. This is like strstr(), except that it ignores case of alphabetic symbols in searching for the substring. (Glibc, GNU extension.)
NULL
if the substring is not found. If s2
points to a string of zero length, the function returns s1
. char * strcat | ( | char * | dest, |
const char * | src | ||
) |
Concatenate two strings.
The strcat() function appends the src string to the dest string overwriting the '\0' character at the end of dest, and then adds a terminating '\0' character. The strings may not overlap, and the dest string must have enough space for the result.
char * strchr | ( | const char * | src, |
int | val | ||
) |
Locate character in string.
val
in the string src
, or NULL
if the character is not found. char * strchrnul | ( | const char * | s, |
int | c | ||
) |
The strchrnul() function is like strchr() except that if c
is not found in s
, then it returns a pointer to the null byte at the end of s
, rather than NULL
. (Glibc, GNU extension.)
s
(i.e., s+strlen
(s)) if the character is not found. int strcmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Compare two strings.
The strcmp() function compares the two strings s1
and s2
.
s1
is found, respectively, to be less than, to match, or be greater than s2
. A consequence of the ordering used by strcmp() is that if s1
is an initial substring of s2
, then s1
is considered to be "less than" s2
. char * strcpy | ( | char * | dest, |
const char * | src | ||
) |
Copy a string.
The strcpy() function copies the string pointed to by src (including the terminating '\0' character) to the array pointed to by dest. The strings may not overlap, and the destination string dest must be large enough to receive the copy.
size_t strcspn | ( | const char * | s, |
const char * | reject | ||
) |
The strcspn() function calculates the length of the initial segment of s
which consists entirely of characters not in reject
.
s
which are not in the string reject
. The terminating zero is not considered as a part of string. char * strdup | ( | const char * | s1 | ) |
Duplicate a string.
The strdup() function allocates memory and copies into it the string addressed by s1
, including the terminating null character.
NULL
.size_t strlcat | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Concatenate two strings.
Appends src
to string dst
of size siz
(unlike strncat(), siz
is the full size of dst
, not space left). At most siz-1
characters will be copied. Always '\0'
terminated (unless siz
<= strlen(dst)
).
Appends src to string dst of size siz (unlike strncat(), siz is the full size of dst, not space left). At most siz-1 characters will be copied. Always NULL terminates (unless siz <= strlen(dst)).
size_t strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Copy a string.
Copy src
to string dst
of size siz
. At most siz-1
characters will be copied. Always '\0' terminated (unless siz
== 0).
Copy src to string dst of size siz. At most siz-1 characters will be copied. Always NULL terminates (unless siz == 0).
size_t strlen | ( | const char * | src | ) |
char * strlwr | ( | char * | s | ) |
Convert a string to lower case.
The strlwr() function will convert a string to lower case. Only the upper case alphabetic characters [A .. Z] are converted. Non-alphabetic characters will not be changed.
int strncasecmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | len | ||
) |
Compare two strings ignoring case.
The strncasecmp() function is similar to strcasecmp(), except it only compares the first len
characters of s1
.
s1
(or the first len
bytes thereof) is found, respectively, to be less than, to match, or be greater than s2
. A consequence of the ordering used by strncasecmp() is that if s1
is an initial substring of s2
, then s1
is considered to be "less than" s2
. char * strncat | ( | char * | dest, |
const char * | src, | ||
size_t | len | ||
) |
int strncmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | len | ||
) |
Compare two strings.
The strncmp() function is similar to strcmp(), except it only compares the first (at most) len
characters of s1
and s2
.
s1
(or the first len
bytes thereof) is found, respectively, to be less than, to match, or be greater than s2
. char * strncpy | ( | char * | dest, |
const char * | src, | ||
size_t | len | ||
) |
Copy a string.
The strncpy() function is similar to strcpy(), except that not more than len
bytes of src
are copied. Thus, if there is no null byte among the first len
bytes of src
, the result will not be null-terminated.
In the case where the length of src
is less than that of len
, the remainder of dest
will be padded with nulls ('\0'
).
dest
. char * strndup | ( | const char * | s, |
size_t | len | ||
) |
Duplicate a string.
The strndup() function is similar to strdup(), but copies at most len
bytes. If s
is longer than len
, only len
bytes are copied, and a terminating null byte ('\0'
) is added.
Memory for the new string is obtained with malloc(), and can be freed with free().
NULL
if the allocation failed. size_t strnlen | ( | const char * | src, |
size_t | len | ||
) |
Determine the length of a fixed-size string.
The strnlen() function returns the number of characters in the string pointed to by src
, not including the terminating '\0' character, but at most len
. In doing this, strnlen() looks only at the first len
characters at src
and never beyond src
+ len
.
len
, or len
if there is no '\0' character among the first len
characters pointed to by src
. char * strpbrk | ( | const char * | s, |
const char * | accept | ||
) |
The strpbrk() function locates the first occurrence in the string s
of any of the characters in the string accept
.
s
that matches one of the characters in accept
, or NULL
if no such character is found. The terminating zero is not considered as a part of string: if one or both args are empty, the result will be NULL
. char * strrchr | ( | const char * | src, |
int | val | ||
) |
Locate character in string.
The strrchr() function returns a pointer to the last occurrence of the character val in the string src.
Here "character" means "byte" – these functions do not work with wide or multi-byte characters.
NULL
if the character is not found. char * strrev | ( | char * | s | ) |
char * strsep | ( | char ** | sp, |
const char * | delim | ||
) |
Parse a string into tokens.
The strsep() function locates, in the string referenced by *sp
, the first occurrence of any character in the string delim
(or the terminating '\0' character) and replaces it with a '\0'. The location of the next character after the delimiter character (or NULL
, if the end of the string was reached) is stored in *sp
. An ``empty'' field, i.e. one caused by two adjacent delimiter characters, can be detected by comparing the location referenced by the pointer returned in *sp
to '\0'.
size_t strspn | ( | const char * | s, |
const char * | accept | ||
) |
The strspn() function calculates the length of the initial segment of s
which consists entirely of characters in accept
.
s
which consist only of characters from accept
. The terminating zero is not considered as a part of string. char * strstr | ( | const char * | s1, |
const char * | s2 | ||
) |
Locate a substring.
The strstr() function finds the first occurrence of the substring s2
in the string s1
. The terminating '\0' characters are not compared.
NULL
if the substring is not found. If s2
points to a string of zero length, the function returns s1
. char * strtok | ( | char * | s, |
const char * | delim | ||
) |
Parses the string s into tokens.
strtok parses the string s into tokens. The first call to strtok should have s as its first argument. Subsequent calls should have the first argument set to NULL
. If a token ends with a delimiter, this delimiting character is overwritten with a '\0' and a pointer to the next character is saved for the next call to strtok. The delimiter string delim may be different for each call.
NULL
when no more tokens are found.strtok_r()
. char * strtok_r | ( | char * | string, |
const char * | delim, | ||
char ** | last | ||
) |
Parses string into tokens.
strtok_r parses string into tokens. The first call to strtok_r should have string as its first argument. Subsequent calls should have the first argument set to NULL
. If a token ends with a delimiter, this delimiting character is overwritten with a '\0' and a pointer to the next character is saved for the next call to strtok_r. The delimiter string delim
may be different for each call. last
is a user allocated char* pointer. It must be the same while parsing the same string. strtok_r is a reentrant version of strtok().
NULL
when no more tokens are found. char * strupr | ( | char * | s | ) |
Convert a string to upper case.
The strupr() function will convert a string to upper case. Only the lower case alphabetic characters [a .. z] are converted. Non-alphabetic characters will not be changed.