Class KomodiaDNS::CDNSAnswer::
GetAnswerParsed()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: DeleteBufferNext page: GetAnswerStruct    Show member index
Public Function Declared in:
DNSAnswer.h

'Declaration' icon -- Shortcut to top of page. Declaration

std::string GetAnswerParsed(
    BOOL bWindowsLines=TRUE,
    BOOL bBrief=TRUE) const;

'Description' icon -- Shortcut to top of page. Description

Create a string of the answer

'Function Body' icon -- Shortcut to top of page. Function Body

try
{
    //Line terminator
    //End of line
    char aEndOfLine[3];

    //Which is it
    if (bWindowsLines)
    {
        aEndOfLine[0]=13;
        aEndOfLine[1]=10;
        aEndOfLine[2]=0;
    }
    else
    {
        aEndOfLine[0]='\n';
        aEndOfLine[1]=0;
    }

    //Our answer
    std::string sAnswer;

    //The answer
    //What are we
    if (m_aAnswer.usType==CDNSQuery::SOA)
    {
        //Our name
        sAnswer+=m_aAnswer.sName;
        sAnswer+=aEndOfLine;

        //Dump the soa data
        sAnswer+=GetSOARecord(std::string("    "),
                              aEndOfLine);
    }
    if (m_aAnswer.usType==CDNSQuery::A)
    {
        //Regular address
        //Is it an address
        if (m_aAnswerType==dhAnswer)
        {
            //Our name
            sAnswer+="Name: ";
            sAnswer+=m_aAnswer.sName;
            sAnswer+=aEndOfLine;

            //Address
            sAnswer+="Address: ";
        }
        else if (m_aAnswerType==dhAdditional)
        {
            //Our name
            sAnswer+=m_aAnswer.sName;
            sAnswer+=' ';

            //Address prefix
            sAnswer+="internet address = ";
        }

        //The address
        sAnswer+=CSpoofBase::LongToStdString(atol(m_aAnswer.sData.c_str()));
    }
    else if (m_aAnswer.usType==CDNSQuery::MX)
    {
        //Our name
        sAnswer+=m_aAnswer.sName;
        sAnswer+=' ';

        //Convert the prefrence
        char aTmp[11];
        itoa(m_usMXPriority,aTmp,10);

        //MX prefrence
        sAnswer+="MX preference = ";
        sAnswer+=aTmp;
        sAnswer+=std::string(", ");

        //MX address
        sAnswer+="mail exchanger = ";
        sAnswer+=m_aAnswer.sData;
    }
    else if (m_aAnswer.usType==CDNSQuery::NS)
    {
        //Our name
        sAnswer+=m_aAnswer.sName;
        sAnswer+=' ';

        //The address
        sAnswer+="nameserver = ";
        sAnswer+=m_aAnswer.sData;
    }
    else if (m_aAnswer.usType==CDNSQuery::PTR)
    {
        //Our name
        sAnswer+=m_aAnswer.sName;
        sAnswer+=' ';

        //The address
        sAnswer+="name = ";
        sAnswer+=m_aAnswer.sData;
    }

    //Done
    return sAnswer;
}
ERROR_HANDLER_RETURN("GetAnswerParsed","")

'See Also' icon -- Shortcut to top of page. See Also

Class Overview Class Overview  |  Public base class CErrorHandler  |  Hierarchy Chart Hierarchy Chart


Get Surveyor!This web site was generated using Surveyor V4.50.811.1.  Click here for more information. Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.