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