summary refs log tree commit diff
path: root/src/portab
diff options
context:
space:
mode:
Diffstat (limited to 'src/portab')
-rw-r--r--src/portab/Makefile.am4
-rw-r--r--src/portab/portab.h4
-rw-r--r--src/portab/strtok_r.c27
3 files changed, 32 insertions, 3 deletions
diff --git a/src/portab/Makefile.am b/src/portab/Makefile.am
index 06c6bae4..c48e67ad 100644
--- a/src/portab/Makefile.am
+++ b/src/portab/Makefile.am
@@ -9,14 +9,12 @@
 # Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
 # der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
 #
-# $Id: Makefile.am,v 1.8 2005/04/16 09:23:01 fw Exp $
-#
 
 AUTOMAKE_OPTIONS = ansi2knr
 
 noinst_LIBRARIES = libngportab.a
 
-libngportab_a_SOURCES = strlcpy.c strdup.c vsnprintf.c
+libngportab_a_SOURCES = strdup.c strlcpy.c strtok_r.c vsnprintf.c
 
 check_PROGRAMS = portabtest
 
diff --git a/src/portab/portab.h b/src/portab/portab.h
index 2a133efc..83e11313 100644
--- a/src/portab/portab.h
+++ b/src/portab/portab.h
@@ -148,6 +148,10 @@ extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
 extern char * strdup PARAMS(( const char *s ));
 #endif
 
+#ifndef HAVE_STRTOK_R
+extern char * strtok_r PARAMS((char *str, const char *delim, char **saveptr));
+#endif
+
 #ifndef HAVE_VSNPRINTF
 #include <stdarg.h>
 extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
diff --git a/src/portab/strtok_r.c b/src/portab/strtok_r.c
new file mode 100644
index 00000000..852c8f70
--- /dev/null
+++ b/src/portab/strtok_r.c
@@ -0,0 +1,27 @@
+#include "portab.h"
+#include <string.h>
+
+#ifndef HAVE_STRTOK_R
+
+char *
+strtok_r(char *str, const char *delim, char **saveptr)
+{
+	char *tmp;
+
+	if (!str)
+		str = *saveptr;
+	str += strspn(str, delim);
+	if (*str == 0)
+		return NULL;
+
+	tmp = str + strcspn(str, delim); /* get end of token */
+	if (*tmp) { /* another delimiter */
+		*tmp = 0;
+		tmp++;
+	}
+	*saveptr = tmp;
+	return str;
+}
+
+#endif
+