static int dname_copy (u_char *from, u_char *to, int tolen) {
	int skip, llen, written_len;

	written_len = 0;
	while (*from) {
		llen = labellen(from);
		if (llen == -1) 
			return -1;
		skip = llen + 1;
		written_len += skip;
		if (written_len >= tolen)
			return -1;

		memcpy (to, from, skip);
		from += skip;
		to += skip;
	}
	*to = '\0';
	written_len++;

	return written_len;
}
static int dname_copy (u_char *from, u_char *to, int tolen) {
	int skip, llen, written_len;

	written_len = 0;
	while (*from) {
		llen = labellen(from);
		if (llen == -1) 
			return -1;
		skip = llen + 1;
		written_len += skip;
		if (written_len >= tolen)
			return -1;

		memcpy (to, from, skip);
		from += skip;
		to += skip;
	}
	*to = '\0';
	written_len++;

	return written_len;
}