Defined in string.h, the
strlcpy() function copies up to
characters from the
strlcpy() takes the full size
of the buffer, not only the length, and terminates the result with
size is greater than 0. Include a byte for
NUL in your
strlcpy() function returns the total
length of the string that would have been copied
if there was unlimited space. This might or might not be equal to
the length of the string actually copied, depending
on whether there was enough space. This means that you can call
to find out how much space is required, then allocate it if you
do not have enough, and finally call
second time to do the required copy.
This function is a common BSD-derived extension to many C libraries.