[tools] host/include/getline.h - Mac OS X 10.7 (Lion) fix
[openwrt/svn-archive/archive.git] / tools / include / getline.h
index 219be752049fa9f8e15287782f4b38cbd7c01e63..02df6c2f7900734aa9798c3eeef0cc6e9607ae88 100644 (file)
  * SUCH DAMAGE.
  */
 
-#ifndef __linux__
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#if !defined(__linux__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L)
 /*
  * Emulate glibc getline() via BSD fgetln().
  * Note that outsize is not changed unless memory is allocated.
 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);