12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #include "php.h"
- #ifdef USE_STRLCPY_PHP_IMPL
- #if defined(LIBC_SCCS) && !defined(lint)
- static const char *rcsid = "$OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker 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;
- {
- const char *s = src;
- size_t n = siz;
-
- if (n != 0) {
- while (--n != 0) {
- if ((*dst++ = *src++) == 0)
- break;
- }
- }
-
- if (n == 0) {
- if (siz != 0)
- *dst = '\0';
- while (*src++)
- ;
- }
-
- return((uintptr_t)src - (uintptr_t)s - 1);
- }
- #endif
|