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 strlcat(char * dst,char const * src,size_t s)17strlcat(char *dst, char const *src, size_t s) { 18 size_t i; 19 size_t j= strnlen(dst, s); 20 21 if (!s) { 22 return j+strlen(src); 23 } 24 25 dst+= j; 26 27 for (i= 0; ((i< s-1) && src[i]); i++) { 28 dst[i]= src[i]; 29 } 30 31 dst[i]= 0; 32 33 return j + i + strlen(src+i); 34 } 35