Signed-off-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
#define HAVE_STRSIGNAL 1
#define HAVE_STRVERSCMP 1
#define HAVE_VASPRINTF 1
+#define HAVE_GETLINE 1
#define HAVE_XTABS 1
#define HAVE_MNTENT_H 1
#define HAVE_NET_ETHERNET_H 1
extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC;
#endif
+#ifndef HAVE_GETLINE
+extern ssize_t getline(char **lineptr, size_t *n, FILE *stream) FAST_FUNC;
+#endif
+
#endif
return p;
}
#endif
+
+#ifndef HAVE_GETLINE
+ssize_t FAST_FUNC getline(char **lineptr, size_t *n, FILE *stream)
+{
+ int ch;
+ char *line = *lineptr;
+ size_t alloced = *n;
+ size_t len = 0;
+
+ do {
+ ch = fgetc(stream);
+ if (ch == EOF)
+ break;
+ if (len + 1 >= alloced) {
+ alloced += alloced/4 + 64;
+ line = xrealloc(line, alloced);
+ }
+ line[len++] = ch;
+ } while (ch != '\n');
+
+ if (len == 0)
+ return -1;
+
+ line[len] = '\0';
+ *lineptr = line;
+ *n = alloced;
+ return len;
+}
+#endif