1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include "nbcompat.h" size_t strlcpy(char *dst, const char *src, size_t size) { char *d; const char *s; for (d = dst, s = src; (s - src) < size; d++, s++) { *d = *s; if (*s == '\0') return s - src; } dst[size - 1] = '\0'; return size; }