xref: /haiku/src/system/libroot/posix/string/strlcpy.c (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2 ** Copyright 2002, Manuel J. Petit. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 
6 #include <sys/types.h>
7 #include <string.h>
8 
9 
10 size_t
11 strlcpy(char *dst, char const *src, size_t s)
12 {
13 	size_t i= 0;
14 
15 	if (!s)
16 		return strlen(src);
17 
18 	for (i = 0; ((i < s - 1) && src[i]); i++) {
19 		dst[i] = src[i];
20 	}
21 
22 	dst[i] = 0;
23 
24 	return i + strlen(src + i);
25 }
26