123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #include "php.h"
- #ifndef HAVE_STRLCPY
- #if defined(LIBC_SCCS) && !defined(lint)
- static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
- #endif
- #include <sys/types.h>
- #include <string.h>
- PHPAPI size_t php_strlcpy(dst, src, siz)
- 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 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- if (n == 0) {
- if (siz != 0)
- *d = '\0';
- while (*s++)
- ;
- }
- return(s - src - 1);
- }
- #endif
|