diff options
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | src/common.c | 17 | ||||
-rw-r--r-- | src/common.h | 8 |
3 files changed, 32 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index d36cc67..2b31499 100644 --- a/configure.ac +++ b/configure.ac @@ -59,6 +59,13 @@ case "$host_os" in ;; esac +AC_CHECK_FUNCS([strsep strcspn]) +if test x$ac_cv_func_strsep != xyes; then + if test x$ac_cv_func_strcspn != xyes; then + AC_MSG_ERROR([You need either strsep or strcspn to build $PACKAGE]) + fi +fi + AC_SUBST(GLOBAL_CFLAGS) AC_SUBST(AC_LDFLAGS) AC_SUBST(AC_LDADD) 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 <config.h> +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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 diff --git a/src/common.h b/src/common.h index 8340d03..5f1d763 100644 --- a/src/common.h +++ b/src/common.h @@ -28,6 +28,10 @@ extern "C" { #endif +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #include <plist/plist.h> #include <libirecovery.h> @@ -131,6 +135,10 @@ int mkdir_with_parents(const char *dir, int mode); void idevicerestore_progress(struct idevicerestore_client_t* client, int step, double progress); +#ifndef HAVE_STRSEP +char* strsep(char** strp, const char* delim); +#endif + #ifdef __cplusplus } #endif |