DictViewInstance::DictViewInstance(FarRegistry &init_reg, const FarString &init_reg_key, SpellFactory *init_spell_factory ) : reg(init_reg) , reg_key(init_reg_key) { far_assert(init_spell_factory); spell_factory = init_spell_factory; name = reg.GetRegStr(reg_key.c_str(), dict_view_name_key, FarString(reg_key + ": <noname>").c_str() ); logic.SetContext(this); FarString dt(reg.GetFarString(reg_key.c_str(), dict_view_logic_key, FarString(""))); if (!dt.IsEmpty()) logic.FromString(dt); }
FarString FarString::Mid (int nFirst, int nCount) const { if (nFirst < 0) nFirst = 0; if (nCount < 0) nCount = 0; if (nFirst + nCount > fData->fLength) { nCount = fData->fLength - nFirst; } if (nFirst > fData->fLength) { nCount = 0; } far_assert (nFirst >= 0 ); far_assert (nFirst + nCount <= fData->fLength); if (nFirst == 0 && nFirst + nCount == fData->fLength) return *this; return FarString (fData->fText + nFirst, nCount); }
FarString DictViewFactory::GetDictViewIdStr(const FarString &name) { int id = GetDictViewId(name); if (id!=-1) { return prefix+itoa(id, 10); } else return FarString(""); }
void CMessageTemplate::processMacro( LPCSTR str, int len, int fill, IWriteSink & f ) { if ( FarSF::LStricmp( str, M_SUBJECT ) == 0 ) processSubject( len, fill, f ); else if ( FarSF::LStricmp( str, M_FROM ) == 0 ) processFrom( len, fill, f ); else if ( FarSF::LStricmp( str, M_TO ) == 0 ) processTo( len, fill, f ); else if ( FarSF::LStricmp( str, M_DATE ) == 0 ) processDate( len, fill, f ); else if ( FarSF::LStricmp( str, M_ORGANIZATION ) == 0 ) processOrganization( len, fill, f ); else if ( FarSF::LStricmp( str, M_MAILER ) == 0 ) processMailer( len, fill, f ); else if ( FarSF::LStricmp( str, M_OSUBJECT ) == 0 ) processOSubject( len, fill, f ); else if ( FarSF::LStricmp( str, M_MESSAGEID ) == 0 ) processMessageId( len, fill, f ); else if ( FarSF::LStricmp( str, M_FROM_NAME ) == 0 ) processFromName( len, fill, f ); else if ( FarSF::LStricmp( str, M_FROM_ADDR ) == 0 ) processFromAddr( len, fill, f ); else if ( FarSF::LStricmp( str, M_TO_NAME ) == 0 ) processToName( len, fill, f ); else if ( FarSF::LStricmp( str, M_TO_ADDR ) == 0 ) processToAddr( len, fill, f ); else if ( FarSF::LStricmp( str, M_SENT_DATE ) == 0 ) processSentDate( len, fill, f ); else if ( FarSF::LStricmp( str, M_SENT_TIME ) == 0 ) processSentTime( len, fill, f ); else if ( FarSF::LStricmp( str, M_RECEIVED_DATE ) == 0 ) processReceivedDate( len, fill, f ); else if ( FarSF::LStricmp( str, M_RECEIVED_TIME ) == 0 ) processReceivedTime( len, fill, f ); else if ( FarSF::LStricmp( str, M_TEXT ) == 0 ) processText( len, f ); else if ( FarSF::LStricmp( str, M_HEADERS ) == 0 ) processHeaders( f ); else if ( FarSF::LStrnicmp( str, M_KLUDGE, strlen(M_KLUDGE) ) == 0 ) { str += _countof(M_KLUDGE); while ( *str && ( isspace( (unsigned char)*str ) || *str == '(' || *str == '\"' || *str == '\'' ) ) str ++; if ( *str ) { LPCSTR end = str + 1; while ( *end && !isspace( (unsigned char)*end ) && *end != ')' && *end != '\"' && *end != '\'' ) end ++; processKludge( FarString( str, end - str ), f ); } } }
FarFileName CTemplatesCfg::FixTpl( const FarFileName& name ) const { FarFileName result = FarString(name).Expand(); //if (result.IsEmpty()) // result.SetPath(m_root); if (name.IsEmpty()) result.SetName("MailView.tpl"); if (!IsNotRelativePath(result)) result.SetPath(m_root); return result; }
FarString FarXMLScanner::NextName() { if (!IsNameStart (*fBufPos)) { if (fErrorSink) fErrorSink->ReportError (fCurLine, GetCurColumn(), "name"); return FarString(); } int nameLength = 1; while (IsNameChar (fBufPos [nameLength])) nameLength++; FarString result (fBufPos, nameLength); fBufPos += nameLength; return result; }
void CMailViewTpl::processText( int len, IWriteSink & f ) { // TODO: check File FarFileName bodyFile = FarFileName::MakeTemp( "mvb" ); File::mkdirs( bodyFile.GetPath() ); PMsgPart TextPart = m_origMsg->GetTextPart(); if ( TextPart ) { long Encoding = GetMsgEncoding( m_origMsg, TextPart, m_defaultEncoding ); if ( len > 20 ) { FarStringArray Src; StrPtr sp = { NULL, 0, (LPSTR)TextPart->GetContentData() }; LPCSTR Last = sp.Nxt + TextPart->GetContentSize(); while ( sp.Nxt ) { GetStrPtr( sp.Nxt, &sp, Last ); Src.Add( ToOEMString( FarString( sp.Str, sp.Len ), Encoding ) ); } FarStringArray * Dst = WordWrapLines( Src, len, true ); for ( int i = 0; i < Dst->Count(); i ++ ) { f.write( Dst->At( i ), strlen( Dst->At( i ) ) ); f.write( "\r\n", 2 ); } delete Dst; } else { FarString s = (LPCSTR)TextPart->GetContentData(); s.SetLength( TextPart->GetContentSize() ); s = ToOEMString( s, Encoding ); f.write( s.c_str(), s.Length() ); } File::deleteit( bodyFile ); } }
FarString FarStringTokenizer::GetToken (int index) const { // it is not allowed to call GetToken() for a non-attached tokenizer far_assert (fText != NULL); far_assert (index >= 0); const char *curPos = GetTokenStart (fText); for (int i=0; i<index; i++) { curPos = GetTokenEnd (curPos); curPos = GetTokenStart (curPos); if (*curPos == '\0') return FarString(); } const char *tokenEnd = GetTokenEnd (curPos); FarString result (curPos, tokenEnd-curPos); if (fIgnoreWhitespace) result.TrimRight(); return result; }
FarString UnMimeHeader( LPCSTR header, int FarEncoding ) { char enc[ 256 ], tmp[ 256 ]; FarString res; CBase64Decoder b64; CQuotedPrintableSubjectDecoder qp; LPCSTR ps = header, pe = ps, pb, pm; while ( ( pb = strstr( ps, "=?" ) ) != NULL ) { if ( pb - ps > 0 ) res += ToOEMString( FarString( ps, pb - ps ), FarEncoding ); pb += 2; if ( ( pm = strchr( pb, '?' ) ) != NULL ) { int dc = FarSF::LUpper( *++pm ); if ( dc == 'B' || dc == 'Q' ) { if ( ( pe = strstr( pm + 2, "?=" ) ) != NULL ) { strxcpy( enc, pb, pm - pb ); strxcpy( tmp, pm + 2, pe - pm - 1 ); CMimeDecoder * d; if ( dc == 'B' ) d = &b64; else d = &qp; dc = d->decode( (PBYTE)tmp, strlen( tmp ) ); if ( dc > 0 ) tmp[ dc ] = '\0'; long d_enc = getCharacterTableNoDefault( enc ); if ( d_enc == FCT__INVALID ) d_enc = FarEncoding; res += ToOEMString( tmp, d_enc ); pe += 2; pb = pe; while ( *pe && isspace( (unsigned char)*pe ) ) pe ++; if ( pe[ 0 ] == '=' && pe[ 1 ] == '?' ) pb = pe; } else pb = pm; } } ps = pb; } if ( *ps != '\0' ) res += ToOEMString( ps, FarEncoding ); return res; }