or longer, uses a passed 'buflen' parameter to determine the truncation point.
Using memset() inplace of non-standard strset().