mirror of
https://github.com/diegocr/libnix.git
synced 2026-09-11 19:25:43 +00:00
29 lines
423 B
C
29 lines
423 B
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
size_t strlcat(char *dst, const char *src, size_t siz)
|
|
{
|
|
char *d = dst;
|
|
const char *s = src;
|
|
size_t n = siz;
|
|
size_t dlen;
|
|
|
|
while(n-- != 0 && *d != '\0')
|
|
d++;
|
|
dlen = d - dst;
|
|
n = siz - dlen;
|
|
|
|
if(n == 0)
|
|
return(dlen + strlen(s));
|
|
while(*s != '\0') {
|
|
if(n != 1) {
|
|
*d++ = *s;
|
|
n--;
|
|
}
|
|
s++;
|
|
}
|
|
*d = '\0';
|
|
|
|
return(dlen + (s - src));
|
|
}
|