pop3: minor cleanup.

This commit is contained in:
Axel Dörfler
2015-01-06 15:24:24 +01:00
parent a9de7ece6b
commit d6ce6060b9
2 changed files with 21 additions and 19 deletions
@@ -671,11 +671,13 @@ POP3Protocol::RetrieveInternal(const char* command, int32 message,
testStr = buf + testIndex;
if (testStr[0] == '\r' && testStr[1] == '\n' && testStr[2] == '.') {
if (testStr[3] == '\r' && testStr[4] == '\n') {
// Found the end of the message marker. Ignore remaining data.
if (amountInBuffer > testIndex + 5)
printf ("POP3Protocol::RetrieveInternal Ignoring %d bytes "
"of extra data past message end.\n",
// Found the end of the message marker.
// Ignore remaining data.
if (amountInBuffer > testIndex + 5) {
printf("POP3Protocol::RetrieveInternal Ignoring %d "
"bytes of extra data past message end.\n",
amountInBuffer - (testIndex + 5));
}
amountInBuffer = testIndex + 2; // Don't include ".\r\n".
buf[amountInBuffer] = 0;
cont = false;
@@ -686,7 +688,7 @@ POP3Protocol::RetrieveInternal(const char* command, int32 message,
// lot of double period lines will get processed very
// slowly.
memmove(buf + testIndex + 2, buf + testIndex + 3,
amountInBuffer - (testIndex + 3) + 1 /* for NUL at end */);
amountInBuffer - (testIndex + 3) + 1);
amountInBuffer--;
// Watch out for the end of buffer case, when the POP text
// is "\r\n..X". Don't want to leave the resulting
@@ -728,10 +730,10 @@ POP3Protocol::RetrieveInternal(const char* command, int32 message,
void
POP3Protocol::Delete(int32 num)
POP3Protocol::Delete(int32 index)
{
BString cmd = "DELE ";
cmd << (num+1) << CRLF;
cmd << (index + 1) << CRLF;
if (SendCommand(cmd.String()) != B_OK) {
// Error
}
@@ -38,9 +38,9 @@ public:
status_t FetchBody(const entry_ref& ref);
status_t DeleteMessage(const entry_ref& ref);
status_t Retrieve(int32 message, BPositionIO *write_to);
status_t GetHeader(int32 message, BPositionIO *write_to);
void Delete(int32 num);
status_t Retrieve(int32 message, BPositionIO* to);
status_t GetHeader(int32 message, BPositionIO* to);
void Delete(int32 index);
protected:
// pop3 methods
@@ -56,7 +56,7 @@ protected:
void CheckForDeletedMessages();
status_t RetrieveInternal(const char* command,
int32 message, BPositionIO *writeTo,
int32 message, BPositionIO* to,
bool showProgress);
ssize_t ReceiveLine(BString& line);