nsCRT::memcpy(m_dataBuffer, start,
memcpy(m_dataBuffer, start,
NS_IMETHODIMP nsImapSaveAsListener::OnDataAvailable(nsIRequest* request,                                   nsISupports* aSupport,                                  nsIInputStream* inStream,                                   PRUint32 srcOffset,                                  PRUint32 count){  nsresult rv;  PRUint32 available;  rv = inStream->Available(&available);  if (!m_writtenData)  {    m_writtenData = PR_TRUE;    rv = SetupMsgWriteStream(m_outputFile, m_addDummyEnvelope);    NS_ENSURE_SUCCESS(rv, rv);  }  PRUint32 readCount, maxReadCount = SAVE_BUF_SIZE - m_leftOver;  PRUint32 writeCount;  char *start, *end;  PRUint32 linebreak_len = 0;  while (count > 0)  {      if (count < (PRInt32) maxReadCount)          maxReadCount = count;      rv = inStream->Read(m_dataBuffer + m_leftOver,                          maxReadCount,                          &readCount);      if (NS_FAILED(rv)) return rv;      m_leftOver += readCount;      m_dataBuffer[m_leftOver] = '\0';      start = m_dataBuffer;      end = PL_strstr(start, "\r");      if (!end)          end = PL_strstr(start, "\n");      else if (*(end+1) == nsCRT::LF && linebreak_len == 0)          linebreak_len = 2;      if (linebreak_len == 0) // not initialize yet          linebreak_len = 1;      count -= readCount;      maxReadCount = SAVE_BUF_SIZE - m_leftOver;      if (!end && count > (PRInt32) maxReadCount)          // must be a very very long line; sorry cannot handle it          return NS_ERROR_FAILURE;      while (start && end)      {          if (PL_strncasecmp(start, "X-Mozilla-Status:", 17) &&              PL_strncasecmp(start, "X-Mozilla-Status2:", 18) &&              PL_strncmp(start, "From - ", 7))          {              rv = m_outputStream->Write(start, end-start, &writeCount);              rv = m_outputStream->Write(CRLF, 2, &writeCount);          }          start = end+linebreak_len;          if (start >= m_dataBuffer + m_leftOver)          {              maxReadCount = SAVE_BUF_SIZE;              m_leftOver = 0;              break;          }          end = PL_strstr(start, "\r");          if (!end)              end = PL_strstr(start, "\n");          if (start && !end)          {              m_leftOver -= (start - m_dataBuffer);              nsCRT::memcpy(m_dataBuffer, start,                            m_leftOver+1); // including null              maxReadCount = SAVE_BUF_SIZE - m_leftOver;          }      }      if (NS_FAILED(rv)) return rv;  }  return rv;    //  rv = m_outputStream->WriteFrom(inStream, PR_MIN(available, count), &bytesWritten);}