diff dcclib/strlcat.c @ 0:c7f6b056b673

First import of vendor version
author Peter Gervai <grin@grin.hu>
date Tue, 10 Mar 2009 13:49:58 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dcclib/strlcat.c	Tue Mar 10 13:49:58 2009 +0100
@@ -0,0 +1,24 @@
+/* compatibility hack */
+
+#include "dcc_defs.h"
+
+int
+dcc_strlcat(char *dst, const char *src, int lim)
+{
+	int dlen, slen, delta;
+
+	dlen = strlen(dst);
+	delta = lim - dlen;
+	if (delta <= 0)
+		return lim;
+
+	slen = strlen(src);
+	if (slen >= delta)
+		slen = delta-1;
+	if (slen <= 0)
+		return dlen;
+	memcpy(dst+dlen, src, slen);
+	dlen += slen;
+	dst[dlen] = '\0';
+	return dlen;
+}