Commit c6233808 authored by David Woodhouse's avatar David Woodhouse

Add local getline() for Solaris 10 build

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 77610415
......@@ -111,3 +111,32 @@ int openconnect__asprintf(char **strp, const char *fmt, ...)
return ret;
}
#endif
#ifndef HAVE_GETLINE
ssize_t openconnect__getline(char **lineptr, size_t *n, FILE *stream)
{
int len = 0;
if (!*lineptr) {
*n = 2;
*lineptr = malloc(*n);
if (!*lineptr)
return -1;
}
while (fgets((*lineptr) + len, (*n) - len, stream)) {
len += strlen((*lineptr) + len);
if ((*lineptr)[len-1] == '\n')
break;
*n *= 2;
*lineptr = realloc(*lineptr, *n);
if (!*lineptr)
return -1;
}
if (len)
return len;
return -1;
}
#endif
......@@ -67,6 +67,7 @@ case $host_os in
;;
esac
AC_CHECK_FUNC(getline, [AC_DEFINE(HAVE_GETLINE, 1)], [])
AC_CHECK_FUNC(strcasestr, [AC_DEFINE(HAVE_STRCASESTR, 1)], [])
need_vacopy=no
AC_CHECK_FUNC(asprintf, [AC_DEFINE(HAVE_ASPRINTF, 1)], [need_vacopy=yes])
......
......@@ -248,6 +248,10 @@ time_t openconnect__time(time_t *t);
#define asprintf openconnect__asprintf
int openconnect__asprintf(char **strp, const char *fmt, ...);
#endif
#ifndef HAVE_GETLINE
#define getline openconnect__getline
ssize_t openconnect__getline(char **lineptr, size_t *n, FILE *stream);
#endif
/****************************************************************************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment