1 /* 2 ** Copyright 2002, Manuel J. Petit. All rights reserved. 3 ** Distributed under the terms of the NewOS License. 4 */ 5 /* 6 * Copyright (c) 2008 Travis Geiselbrecht 7 * 8 * Use of this source code is governed by a MIT-style 9 * license that can be found in the LICENSE file or at 10 * https://opensource.org/licenses/MIT 11 */ 12 13 #include <string.h> 14 #include <sys/types.h> 15 16 size_t strlcpy(char * dst,char const * src,size_t s)17strlcpy(char *dst, char const *src, size_t s) { 18 size_t i= 0; 19 20 if (!s) { 21 return strlen(src); 22 } 23 24 for (i= 0; ((i< s-1) && src[i]); i++) { 25 dst[i]= src[i]; 26 } 27 28 dst[i]= 0; 29 30 return i + strlen(src+i); 31 } 32