123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #if defined(LIBC_SCCS) && !defined(lint)
- static char *rcsid = "$OpenBSD: strlcpy.c,v 1.2 1998/11/06 04:33:16 wvdputte Exp $";
- #endif
- #include <sys/types.h>
- #include <string.h>
- size_t strlcpy(char *dst, const char *src, size_t siz)
- {
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
- if (n == 0)
- return(strlen(s));
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
- *d = '\0';
- return(s - src);
- }
|