.TH "avr_string" 3avr "Sun Dec 13 2015" "Version 1.8.0svn" "avr-libc" \" -*- nroff -*- .ad l .nh .SH NAME avr_string \- : Strings .SS "Macros" .in +1c .ti -1c .RI "#define \fB_FFS\fP(x)" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "char * \fBstrdup\fP (const char *s1)" .br .ti -1c .RI "size_t \fBstrlcat\fP (char *, const char *, size_t)" .br .ti -1c .RI "size_t \fBstrlcpy\fP (char *, const char *, size_t)" .br .ti -1c .RI "char * \fBstrtok\fP (char *, const char *)" .br .in -1c .SH "Detailed Description" .PP .PP .nf #include .fi .PP .PP The string functions perform string operations on NULL terminated strings\&. .PP \fBNote:\fP .RS 4 If the strings you are working on resident in program space (flash), you will need to use the string functions described in \fB: Program Space Utilities\fP\&. .RE .PP .SH "Macro Definition Documentation" .PP .SS "#define _FFS(x)" This macro finds the first (least significant) bit set in the input value\&. .PP 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\&. .PP \fBReturns:\fP .RS 4 The \fB_FFS()\fP macro returns the position of the first (least significant) bit set in the word val, or 0 if no bits are set\&. The least significant bit is position 1\&. Only 16 bits of argument are evaluted\&. .RE .PP .SH "Function Documentation" .PP .SS "char * strdup (const char * s1)" .PP Duplicate a string\&. The \fBstrdup()\fP function allocates memory and copies into it the string addressed by s1, including the terminating null character\&. .PP \fBWarning:\fP .RS 4 The \fBstrdup()\fP function calls \fBmalloc()\fP to allocate the memory for the duplicated string! The user is responsible for freeing the memory by calling \fBfree()\fP\&. .RE .PP \fBReturns:\fP .RS 4 The \fBstrdup()\fP function returns a pointer to the resulting string dest\&. If \fBmalloc()\fP cannot allocate enough storage for the string, \fBstrdup()\fP will return NULL\&. .RE .PP \fBWarning:\fP .RS 4 Be sure to check the return value of the \fBstrdup()\fP function to make sure that the function has succeeded in allocating the memory! .RE .PP .SS "size_t strlcat (char * dst, const char * src, size_t siz)" .PP 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 NULL terminates (unless siz <= strlen(dst))\&. .PP \fBReturns:\fP .RS 4 The \fBstrlcat()\fP function returns strlen(src) + MIN(siz, strlen(initial dst))\&. If retval >= siz, truncation occurred\&. .RE .PP .SS "size_t strlcpy (char * dst, const char * src, size_t siz)" .PP Copy a string\&. Copy src to string dst of size siz\&. At most siz-1 characters will be copied\&. Always NULL terminates (unless siz == 0)\&. .PP \fBReturns:\fP .RS 4 The \fBstrlcpy()\fP function returns strlen(src)\&. If retval >= siz, truncation occurred\&. .RE .PP .SS "char * strtok (char * s, const char * delim)" .PP 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\&. .PP \fBReturns:\fP .RS 4 The \fBstrtok()\fP function returns a pointer to the next token or NULL when no more tokens are found\&. .RE .PP \fBNote:\fP .RS 4 \fBstrtok()\fP is NOT reentrant\&. For a reentrant version of this function see \fCstrtok_r()\fP\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for avr-libc from the source code\&.