Move conditional lib files to oslib/
[fio.git] / oslib / strsep.c
diff --git a/oslib/strsep.c b/oslib/strsep.c
new file mode 100644 (file)
index 0000000..b71e9f7
--- /dev/null
@@ -0,0 +1,29 @@
+#include <stdio.h>
+
+char *strsep(char **stringp, const char *delim)
+{
+       char *s, *tok;
+       const char *spanp;
+       int c, sc;
+
+       s = *stringp;
+       if (!s)
+               return NULL;
+
+       tok = s;
+       do {
+               c = *s++;
+               spanp = delim;
+               do {
+                       sc = *spanp++;
+                       if (sc == c) {
+                               if (c == 0)
+                                       s = NULL;
+                               else
+                                       s[-1] = 0;
+                               *stringp = s;
+                               return tok;
+                       }
+               } while (sc != 0);
+       } while (1);
+}