X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;f=tools%2Finclude%2Fgetline.h;h=7b320f77cefd2e798b90c8216813025d4e7ff883;hb=eec0c413759d360775df7419dec1bf46f6b63483;hp=219be752049fa9f8e15287782f4b38cbd7c01e63;hpb=60c1f0f64d23003a19a07d6b9638542130f6641d;p=lede-git%2F.git diff --git a/tools/include/getline.h b/tools/include/getline.h index 219be75204..7b320f77ce 100644 --- a/tools/include/getline.h +++ b/tools/include/getline.h @@ -27,12 +27,16 @@ * SUCH DAMAGE. */ -#ifndef __linux__ #include #include #include #include +#ifdef __FreeBSD__ +#include +#endif + +#if !defined(__linux__) && !defined(__OpenBSD__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L) && !(defined(__FreeBSD__) && __FreeBSD_version >= 800000) /* * Emulate glibc getline() via BSD fgetln(). * Note that outsize is not changed unless memory is allocated. @@ -40,10 +44,16 @@ static inline ssize_t getline(char **outbuf, size_t *outsize, FILE *fp) { - char *buf; size_t len; +#ifndef __CYGWIN__ + char *buf; buf = fgetln(fp, &len); +#else + char buf[512]; + fgets(buf, sizeof(buf), fp); + len = strlen(buf); +#endif if (buf == NULL) return (-1);