1// Copyright 2016 The Fuchsia Authors 2// Copyright 2002, Manuel J. Petit 3// Copyright (c) 2008 Travis Geiselbrecht 4// 5// Use of this source code is governed by a MIT-style 6// license that can be found in the LICENSE file or at 7// https://opensource.org/licenses/MIT 8 9#include <string.h> 10#include <sys/types.h> 11 12size_t 13strlcat(char *dst, char const *src, size_t s) 14{ 15 size_t i; 16 size_t j= strnlen(dst, s); 17 18 if (!s) { 19 return j+strlen(src); 20 } 21 22 dst+= j; 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 j + i + strlen(src+i); 31} 32