+/* Copies buffer SRC, of SRC_LEN bytes,
+ to DST, which is in a buffer DST_SIZE bytes long.
+ Truncates DST to DST_SIZE - 1 characters, if necessary. */
+void
+str_copy_buf_trunc (char *dst, size_t dst_size,
+ const char *src, size_t src_size)
+{
+ size_t dst_len;
+ assert (dst_size > 0);
+
+ dst_len = src_size < dst_size ? src_size : dst_size - 1;
+ memcpy (dst, src, dst_len);
+ dst[dst_len] = '\0';
+}
+