summaryrefslogtreecommitdiff
path: root/ngircd/src/portab/strtok_r.c
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-10-23 23:44:03 +0800
committerMistivia <i@mistivia.com>2025-10-23 23:44:07 +0800
commitc8aeef18cb46a617b6397b9822263895e97e9048 (patch)
treeebe127e7c194039f315b74a5998b05a271c57b9d /ngircd/src/portab/strtok_r.c
add ircd
Diffstat (limited to 'ngircd/src/portab/strtok_r.c')
-rw-r--r--ngircd/src/portab/strtok_r.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/ngircd/src/portab/strtok_r.c b/ngircd/src/portab/strtok_r.c
new file mode 100644
index 0000000..4d00772
--- /dev/null
+++ b/ngircd/src/portab/strtok_r.c
@@ -0,0 +1,36 @@
+/*
+ * ngIRCd -- The Next Generation IRC Daemon
+ */
+
+#include "portab.h"
+
+/**
+ * @file
+ * Implementation of strtok_r()
+ */
+
+#ifndef HAVE_STRTOK_R
+
+#include <string.h>
+
+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