imap: Introduced the mailbox variable

Added the mailbox variable to the per-connection structure in
preparation for checking for an already selected mailbox.
imap: Added skipping of SELECT command if already in the same mailbox

Added storage and checking of the last mailbox userd to prevent
unnecessary switching.
imap: Added processing of more than one response when sent in same packet

Added a loop to imap_statemach_act() in which Curl_pp_readresp() is
called until the cache is drained. Without this multiple responses
received in a single packet could result in a hang or delay.
imap: Corrected char* references with char *

Corrected char* references made in commit: 709b3506cd9b.
imap: Reversed the logic of the (un)successful tagged CAPABILITY response

Reversed the logic of the unsuccessful vs successful tagged CAPABILITY
response in imap_state_capability_resp() to be more logical to read.
imap: Reversed the logic of the (un)successful tagged SELECT response

Reversed the logic of the unsuccessful vs successful tagged SELECT
response in imap_state_select_resp() to be more logical to read.
imap: Updated the coding style of imap_state_servergreet_resp()

Updated the coding style, in this function, to be consistant with other
response functions rather then performing a hard return on failure.
imap: Re-factored final IMAP_AUTHENTICATE constant

Changed the final IMAP_AUTHENTICATE constant to IMAP_AUTHENTICATE_FINAL
for consistency with the response function.
pop3: Re-factored the final POP3_AUTH constant

Changed the final POP3_AUTH constant to POP3_AUTH_FINAL for consistency
with the response function.
smtp: Re-factored the final SMTP_AUTH constant

Changed the final SMTP_AUTH constant to SMTP_AUTH_FINAL for consistency
with the response function.
Merge remote-tracking branch 'bagder/master'
imap: fix compiler warning

error: declaration of 'imap' shadows a previous local
imap: fix autobuild warning

Removed whitespace from imap_perform()
imap: Introduced FETCH_FINAL state for processing final fetch responses

A typical FETCH response can be broken down into four parts:

  1) "* <uid> FETCH (<what> {<size>}\r\n", using continuation syntax
  2) <size> bytes of the actual message
  3) ")\r\n", finishing the untagged response
  4) "<tag> OK ...", finishing the command

Part 1 is read in imap_fetch_resp(), part 2 is consumed in the PERFORM
phase by the transfer subsystem, parts 3 and 4 are currently ignored.
imap: Added processing of the final FETCH responses

Not processing the final FETCH responses was not optimal, not only
because the response code would be ignored but it would also leave data
unread on the socket which would prohibit connection reuse.
imap: Fixed error code returned for invalid FETCH response

If the FETCH command does not result in an untagged response the the
UID is probably invalid. As such do not return CURLE_OK.
imap: Corrected debug message for IMAP_AUTHENTICATE_FINAL constant

Following commit 13006f3de9ec corrected the debug message in state()
from AUTHENTICATE to AUTHENTICATE_FINAL.
pop3: Corrected debug message for POP3_AUTH_FINAL constant

Following commit afad1ce753a1 corrected the debug message in state()
from AUTH to AUTH_FINAL.
smtp: Corrected debug message for POP3_AUTH_FINAL constant

Following commit ad3177da24b8 corrected the debug message in state()
from AUTH to AUTH_FINAL.
imap: Small tidy up of function arguments