void nsEudoraAddress::ExtractNoteField( nsCString& note, nsCString& value, const char *pFieldName)
{
  value.Truncate();
  nsCString field("<");
  field.Append( pFieldName);
  field.Append( ':');

/*
    this is a bit of a cheat, but there's no reason it won't work
    fine for us, even better than Eudora in some cases!
*/

  PRInt32 idx = note.Find( field);
  if (idx != -1) {
    idx += field.Length();
    PRInt32 endIdx = note.FindChar( '>', idx);
    if (endIdx == -1)
      endIdx = note.Length() - 1;
    note.Mid( value, idx, endIdx - idx);
    idx -= field.Length();
    nsCString tempL;
    if (idx)
      note.Left( tempL, idx);
    nsCString tempR;
    note.Right( tempR, note.Length() - endIdx - 1);
    note = tempL;
    note.Append( tempR);
  }
}
nsNullPrincipalURI::nsNullPrincipalURI(const nsCString &aSpec)
{
    int32_t dividerPosition = aSpec.FindChar(':');
    NS_ASSERTION(dividerPosition != -1, "Malformed URI!");

    int32_t n = aSpec.Left(mScheme, dividerPosition);
    NS_ASSERTION(n == dividerPosition, "Storing the scheme failed!");

    int32_t count = aSpec.Length() - dividerPosition - 1;
    n = aSpec.Mid(mPath, dividerPosition + 1, count);
    NS_ASSERTION(n == count, "Storing the path failed!");

    ToLowerCase(mScheme);
}
void nsEudoraWin32::ConvertPath( nsCString& str)
{
  nsCString  temp;
  nsCString  path;
  PRInt32    idx = 0;
  PRInt32    start = 0;
  nsCString  search;

  idx = str.FindChar( '\\', idx);
  if ((idx == 2) && (str.CharAt( 1) == ':'))
  {
    str.Left( path, 3);
    idx++;
    idx = str.FindChar( '\\', idx);
    start = 3;
    if ((idx == -1) && (str.Length() > 3))
    {
      str.Right( temp, str.Length() - start);
      path.Append( temp);
    }
  }

  WIN32_FIND_DATA findFileData;
  while (idx != -1)
  {
    str.Mid( temp, start, idx - start);
    search = path;
    search.Append( temp);
    HANDLE h = FindFirstFile( search.get(), &findFileData);
    if (h == INVALID_HANDLE_VALUE)
      return;
    path.Append( findFileData.cFileName);
    idx++;
    start = idx;
    idx = str.FindChar( '\\', idx);
    FindClose( h);
    if (idx != -1)
      path.Append( '\\');
    else
    {
      str.Right( temp, str.Length() - start);
      path.Append( '\\');
      path.Append( temp);
    }
  }

  str = path;
}
Exemple #4
0
void CMapiMessage::ProcessHeaderLine( nsCString& line)
{
  PRUint32 len, start;
  nsCString tStr;
  nsCString left13;
  nsCString left26;
  nsCString left8;
  nsCString left5;

  line.Left( left13, 13);
  line.Left( left26, 26);
  line.Left( left8, 8);
  line.Left( left5, 5);

  if (left13.Equals(NS_LITERAL_CSTRING("Mime-Version:"), nsCaseInsensitiveCStringComparator()))
    m_bMimeVersion = TRUE;
  else if (left13.Equals(NS_LITERAL_CSTRING("Content-Type:"), nsCaseInsensitiveCStringComparator())) {
    // Note: this isn't a complete parser, the content type
    // we extract could have rfc822 comments in it
    len = 13;
    while ((len < line.Length()) && IsSpace( line.CharAt( len)))
      len++;
    start = len;
    while ((len < line.Length()) && (line.CharAt( len) != ';'))
      len++;
    line.Mid( m_mimeContentType, start, len - start);
    len++;
    // look for "boundary="
    BOOL haveB;
    BOOL haveC;
    while (len < line.Length()) {
      haveB = FALSE;
      haveC = FALSE;
      while ((len < line.Length()) && IsSpace( line.CharAt( len)))
        len++;
      start = len;
      while ((len < line.Length()) && (line.CharAt( len) != '='))
        len++;
      if (len - start) {
        line.Mid( tStr, start, len - start);
        if (tStr.Equals(NS_LITERAL_CSTRING("boundary"), nsCaseInsensitiveCStringComparator()))
          haveB = TRUE;
        else if (tStr.Equals(NS_LITERAL_CSTRING("charset"), nsCaseInsensitiveCStringComparator()))
          haveC = TRUE;
      }
      len++;
      while ((len < line.Length()) && IsSpace( line.CharAt( len)))
        len++;
      if ((len < line.Length()) && (line.CharAt( len) == '"')) {
        len++;
        BOOL slash = FALSE;
        tStr.Truncate();
        while (len < line.Length()) {
          if (slash) {
            slash = FALSE;
            tStr.Append(line.CharAt( len));
          }
          else if (line.CharAt( len) == '"')
            break;
          else if (line.CharAt( len) != '\\')
            tStr.Append(line.CharAt( len));
          else
            slash = TRUE;
          len++;
        }
        len++;
        if (haveB) {
          m_mimeBoundary = tStr;
          haveB = FALSE;
        }
        if (haveC) {
          m_mimeCharset = tStr;
          haveC = FALSE;
        }
      }
      tStr.Truncate();
      while ((len < line.Length()) && (line.CharAt( len) != ';')) {
        tStr.Append(line.CharAt( len));
        len++;
      }
      len++;
      if (haveB) {
        tStr.Trim( kWhitespace);
        m_mimeBoundary = tStr;
      }
      if (haveC) {
        tStr.Trim( kWhitespace);
        m_mimeCharset = tStr;
      }

    }
  }
  else if (left26.Equals(NS_LITERAL_CSTRING("Content-Transfer-Encoding:"), nsCaseInsensitiveCStringComparator())) {
    m_bMimeEncoding = TRUE;
  }
  else if (left8.Equals(NS_LITERAL_CSTRING("Subject:"), nsCaseInsensitiveCStringComparator()))
    m_bHasSubject = TRUE;
  else if (left5.Equals(NS_LITERAL_CSTRING("From:"), nsCaseInsensitiveCStringComparator()))
    m_bHasFrom = TRUE;
  else if (left5.Equals(NS_LITERAL_CSTRING("Date:"), nsCaseInsensitiveCStringComparator()))
    m_bHasDate = TRUE;
}