From c024a78dbaa9b42db7f18b0fea1894c41e2b0d67 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sat, 4 May 2019 12:41:11 -0600 Subject: * Initial release of XOAUTH2 authentication support in Alpine for Gmail. --- imap/src/osdep/unix/ssl_unix.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'imap/src/osdep/unix/ssl_unix.c') diff --git a/imap/src/osdep/unix/ssl_unix.c b/imap/src/osdep/unix/ssl_unix.c index 53c5d05a..21bf55ee 100644 --- a/imap/src/osdep/unix/ssl_unix.c +++ b/imap/src/osdep/unix/ssl_unix.c @@ -107,7 +107,8 @@ static struct ssl_driver ssldriver = { ssl_host, /* return host name */ ssl_remotehost, /* return remote host name */ ssl_port, /* return port number */ - ssl_localhost /* return local host name */ + ssl_localhost, /* return local host name */ + ssl_getsize /* return needed number of bytes */ }; /* non-NIL if doing SSL primary I/O */ static SSLSTDIOSTREAM *sslstdio = NIL; @@ -546,7 +547,28 @@ char *ssl_getline (SSLSTREAM *stream) } return ret; } - + +char *ssl_getsize (SSLSTREAM *stream, unsigned long size) +{ + char *ret = NIL; + unsigned long got = 0L, need = size, n; + int done = 0; + + while(!done){ + if(!ssl_getdata (stream)) return ret; /* return what we have */ + n = stream->ictr < need ? stream->ictr : need; + fs_resize((void **) &ret, got + n + 1); + memcpy(ret + got, stream->iptr, n); + ret[got+n] = '\0'; + got += n; + need -= n; + stream->iptr += n; + stream->ictr -= n; + if(need == 0L) done++; + } + + return ret; +} /* SSL receive line or partial line * Accepts: SSL stream * pointer to return size -- cgit v1.2.3-54-g00ecf