strcpy, strlcat, strlcpy, strncat, strncpy, strspn - String operations.
#include <sys/ddi.h> char *strcpy(char *dst, const char *src);
size_t strlcat(char *dst, const char *src, size_t dstsize);
size_t strlcpy(char *dst, const char *src, size_t dstsize);
char *strncat(char *restrict s1, const char *restrict s2, size_t n);
char *strncpy(char *dst, const char *src, size_t n);
size_t strspn(const char *s1, const char *s2);
Solaris DDI specific (Solaris DDI).
dst, src
s1, s2
n
The arguments dst, src, s1 and s2 point to strings. The strcpy(), strlcpy(), strncpy(), strlcat() and strncat() functions all alter their first argument. These functions do not check for overflow of the array pointed to by the first argument.
The strcpy() function copies characters in the string src to dst, terminating at the first null character in src, and returns dst to the caller. No bounds checking is done.
The strncpy() function copies src to dst, null-padding or truncating at n bytes, and returns dst. No bounds checking is done.
The strlcpy() function copies a maximum of dstsize-1 characters (where dstsize represents the size of the string buffer dst) from src to dst, truncating src if necessary. The result is always null-terminated. The function returns strlen(src). Buffer overflow can be checked as follows:
if (strlcpy(dst, src, dstsize) >= dstsize) return (-1);
The strncat() function appends a maximum of n characters. The initial character of s2 overrides the null character at the end of s1.
The strlcat() function appends a maximum of (dstsize-strlen(dst)-1) characters of src to dst (where dstsize represents the size of the string buffer dst). If the string pointed to by dst contains a null-terminated string that fits into dstsize bytes when strlcat() is called, the string pointed to by dst is a null-terminated string that fits in dstsize bytes (including the terminating null character) when it completes, and the initial character of src overrides the null character at the end of dst. If the string pointed to by dst is longer than dstsize bytes when strlcat() is called, the string pointed to by dst is not changed. The function returns min{dstsize, strlen(dst)}+strlen(src). Buffer overflow can be checked as follows:
if (strlcat(dst, src, dstsize) >= dstsize) return -1;
The strspn() function returns the length of the initial segment of string s1 that consists entirely of characters from string s2.
The strcpy(), strncat() and strncpy() functions return dst.
For strlcat(), strlcpy() and strspn() functions, see the Description section.
These functions can be called from user, interrupt, or kernel context.
strlen(9F), strcmp(9F), bcopy(9F), ddi_copyin(9F)
If copying takes place between objects that overlap, the behavior of strcpy(), strlcat(), strlcpy(), strncat(), strncpy(), strspn() is undefined.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |