Don't just display _all_ the headers after connecting

Determine how many headers we can fit on the screen, using
ioctl/TIOCGWINSZ to get the number of rows in the terminal.

We then just display upto n headers and using the new 'n' and 'p'
commands, all the headers can be cycled through.

Note we don't currently react to subsequent window size changes.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Fix searching for the end of data string

In read_pop_response_sync() we loop around reading from the socket until
we find the string "\r\n.\r\n" which signifies the end of the data we
are looking for.

In commit 3834713 ("Some code optimisation in get_message_hdrs()") we
made a change in that instead of looking in the whole of the data we've
read in, we just looked in the data from the last read() call.

There is a small problem with this in that the string we're looking for
could be split across read() calls. e.g.

    read(3, ".....\r\n.", 5272) = 1460
    read(3, "\r\n", 3812) = 2

we then get stuck in

    read(3,

as we haven't seen "\r\n.\r\n" in a single read() and it's sent all the
data it's going to send.

The simplest fix is to just undo the optimisation and look in the whole
of the buffer we've read. Seeing as this is just the mail headers this
shouldn't generally be more than about 4k or so.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>