strlcat.c (374B)
1 /* Written by Kris Maglione <maglione.k at Gmail> */ 2 /* Public domain */ 3 #include "util.h" 4 5 uint 6 strlcat(char *dst, const char *src, uint size) { 7 const char *s; 8 char *d; 9 int n, len; 10 11 d = dst; 12 s = src; 13 n = size; 14 while(n-- > 0 && *d != '\0') 15 d++; 16 len = n; 17 18 while(*s != '\0') { 19 if(n-- > 0) 20 *d++ = *s; 21 s++; 22 } 23 if(len > 0) 24 *d = '\0'; 25 return size - n - 1; 26 }