From e9c805ffdec34c66fdc751ea222fa40678c71351 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 24 Feb 2017 22:10:56 +0100 Subject: common: Add strsep() implementation for platforms lacking it --- src/common.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/common.c') diff --git a/src/common.c b/src/common.c index 691137d..7bbe33a 100644 --- a/src/common.c +++ b/src/common.c @@ -21,6 +21,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -282,3 +286,16 @@ void idevicerestore_progress(struct idevicerestore_client_t* client, int step, d } } } + +#ifndef HAVE_STRSEP +char* strsep(char** strp, const char* delim) +{ + char *p, *s; + if (strp == NULL || *strp == NULL || **strp == '\0') return NULL; + s = *strp; + p = s + strcspn(s, delim); + if (*p != '\0') *p++ = '\0'; + *strp = p; + return s; +} +#endif -- cgit v1.1-32-gdbae