WMII Reforge  Artifact [d89a87cce7]

Artifact d89a87cce7d57a7af4eb8f41d095e61fcc114d3cc2ea9f87cab3118e1739b9ae:

  • File lib/libstuff/util/strlcat.c — part of check-in [15eae1e8e6] at 2019-06-20 16:42:23 on branch trunk — Import sources to have something to work with (user: KhazAkar size: 374)

/* Written by Kris Maglione <maglione.k at Gmail> */
/* Public domain */
#include "util.h"

uint
strlcat(char *dst, const char *src, uint size) {
	const char *s;
	char *d;
	int n, len;

	d = dst;
	s = src;
	n = size;
	while(n-- > 0 && *d != '\0')
		d++;
	len = n;

	while(*s != '\0') {
		if(n-- > 0)
			*d++ = *s;
		s++;
	}
	if(len > 0)
		*d = '\0';
	return size - n - 1;
}