Exemple #1
0
CStr8 XMBElement::GetText() const
{
	// Return empty string if there's no text
	if (m_Pointer == NULL || read<int>(m_Pointer + 20) == 0)
		return CStr8();

	return CStr8(m_Pointer + 28);
}
Exemple #2
0
XMBAttribute XMBAttributeList::operator[](size_t id)
{
	ENSURE(id < m_Size && "Attribute ID out of range");
	const char* Pos;
	size_t i;

	if (id < m_CurItemID)
	{
		Pos = m_Pointer;
		i = 0;
	}
	else
	{
		// If access is sequential, don't bother scanning
		// through all the nodes to find the next one
		Pos = m_CurPointer;
		i = m_CurItemID;
	}

	// Skip over each preceding attribute
	for (; i < id; ++i)
		Pos += 8 + read<int>(Pos+4); // skip ID, length, and string data

	// Cache information about this attribute
	m_CurItemID = id;
	m_CurPointer = Pos;

	return XMBAttribute(read<int>(Pos), CStr8(Pos+8));
}
Exemple #3
0
CStr8 XMBAttributeList::GetNamedItem(const int AttributeName) const
{
	const char* Pos = m_Pointer;

	// Maybe not the cleverest algorithm, but it should be
	// fast enough with half a dozen attributes:
	for (size_t i = 0; i < m_Size; ++i)
	{
		if (read<int>(Pos) == AttributeName)
			return CStr8(Pos+8);
		Pos += 8 + read<int>(Pos+4); // Skip over the string
	}

	// Can't find attribute
	return CStr8();
}
oexBOOL CVfsFtpSession::OnRead( oexINT x_nErr )
{
    // Process the incomming data
    if ( !TBufferedPort< CAutoSocket >::OnRead( x_nErr ) )
	    return oexFALSE;

    // Grab the data
    CStr8 sData = Rx().Read();

    // First token should be the command
    CStr8 sCmd = sData.ParseNextToken().ToUpper();

    // USER
    if ( sCmd == "USER" )
    {   m_sUser = sData.ParseNextToken();
        Write( CStr8( "331 Password required for " ) << m_sUser << ".\n" );
    } // end if

    // PASS
    else if ( sCmd == "PASS" )
    {   m_sPassword = sData.ParseNextToken();
        Write( CStr8( "230 User \'" ) << m_sUser << "\' logged in at " << oexStrToStr8( CSysTime( 2 ).FormatTime( oexT( "GMT : %Y/%c/%d - %g:%m:%s.%l" ) ) ) << ".\n" );
    } // end else if

    // SYST
    else if ( sCmd == "SYST" )
        Write( "215 Windows_NT\n" );

    // PWD
    else if ( sCmd == "PWD" )
    {   if ( !m_sCurrent.Length() )
            m_sCurrent = "/";
        Write( CStr8( "257 \"" ) << m_sCurrent << "\" is current directory.\n" );
    } // end else if

    // CWD
    else if ( sCmd == "CWD" )
    {   sData = sData.TrimWhiteSpace();
        if ( *sData != '/' && *sData != '\\' )
            sData = CStr8::BuildPath( m_sCurrent, sData );
        m_sCurrent = sData;
        Write( "250 CWD command successful.\n" );
    } // end else if

    // MKD
    else if ( sCmd == "MKD" )
    {   sData = sData.TrimWhiteSpace();
        if ( *sData != '/' && *sData != '\\' )
            sData = CStr8::BuildPath( m_sCurrent, sData );
        m_vfs.MakeFolder( CStr8::BuildPath( m_sRoot, sData ).Ptr() );
        Write( "250 MKD command successful.\n" );
    } // end else if

    // RMD
    else if ( sCmd == "RMD" )
    {   sData = sData.TrimWhiteSpace();
        if ( *sData != '/' && *sData != '\\' )
            sData = CStr8::BuildPath( m_sCurrent, sData );
        m_vfs.Delete( CStr8::BuildPath( m_sRoot, sData ).Ptr() );
        Write( "250 RMD command successful.\n" );
    } // end else if

    // CDUP
    else if ( sCmd == "CDUP" )
    {   m_sCurrent.RParse( "/\\" );
        Write( "250 CDUP command successful.\n" );
    } // end else if

    // NOOP
    else if ( sCmd == "NOOP" )
        Write( "200 Ok.\n" );

    // NOOP
    else if ( sCmd == "REST" )
    {   m_nsData.Destroy();
        Write( "200 Ok.\n" );
    } // end else if

    // PASV
    else if ( sCmd == "PASV" )
        CmdPasv();

    // TYPE
    else if ( sCmd == "TYPE" )
    {   m_sType = sData.ParseNextToken();
        Write( CStr8( "200 Type set to " ) << m_sType << ".\n" );
    } // end else if

    // LIST
    else if ( sCmd == "LIST" )
        CmdList();

    // RETR
    else if ( sCmd == "RETR" )
        CmdRetr( sData.TrimWhiteSpace().Ptr() );

    // STOR
    else if ( sCmd == "STOR" )
        CmdStor( sData.TrimWhiteSpace().Ptr() );

    // DELE
    else if ( sCmd == "DELE" )
    {   sData = sData.TrimWhiteSpace();
        if ( *sData != '/' && *sData != '\\' )
            sData = CStr8::BuildPath( m_sCurrent, sData );
        m_vfs.Delete( CStr8::BuildPath( m_sRoot, sData ).Ptr() );
        Write( "250 DELE command successful.\n" );
    } // end if

    // QUIT
    else if ( sCmd == "QUIT" )
    {   Write( "221 Goodbye.\n" );
        CloseSession();
    }

    // Error...
    else
        Write( CStr8( "500 \'" ) << sCmd << "\': Huh?\n" );

    return oexTRUE;
}
Exemple #5
0
XMBAttribute XMBAttributeList::iterator::operator*() const
{
	return XMBAttribute(read<int>(m_CurPointer), CStr8(m_CurPointer+8));
}
Exemple #6
0
CStr8 CBin::uncompress()
{_STT();
	return oexUncompress( CStr8( Ptr(), getUsed() ) );
}