Class KomodiaDNS::CDNSParser::
ParseName()
Base ClassesConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: GetParsedDomainLengthNext page: Custom Code in Source After Includes    Show member index
Public Function Declared in:
DNSParser.h

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

static std::string ParseName(
    const char* pBuffer,
    const char* pOriginalBuffer,
    unsigned short& rLength);

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

Parse a DNS name

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

try
{
    //Set the length to zero
    rLength=0;

    //Damn shortcuts
    unsigned short usShort;
    usShort=*((unsigned short*)pBuffer);

    //Convert it
    usShort=htons(usShort);

    //Check for shortcuts
    if (usShort & 0xc000)
    {
        //Remove the traling bits
        usShort=usShort & 0x3fff;

        //Get length of the domain
        unsigned short usLength;
        usLength=GetParsedDomainLength(pOriginalBuffer+usShort,
                                       pOriginalBuffer);

        //Check for errors
        if (!usLength)
        {
            //Report it
            ReportStaticError(CDNSParser_Class,"ParseName","Received zero length!");

            //Exit
            return "";
        }
        else
        {
            //Set the length to parsed
            rLength=2;

            //Returned the parsed name
            return ConvertParsedName(pOriginalBuffer+usShort,
                                     pOriginalBuffer);
        }
    }
    else
    {
        //Regular name
        //Get length of the domain
        unsigned short usLength;
        usLength=GetParsedDomainLength(pBuffer,
                                       pOriginalBuffer);

        //Check for errors
        if (!usLength)
        {
            //Report it
            ReportStaticError(CDNSParser_Class,"ParseName","Received zero length!");

            //Exit
            return "";
        }
        else
        {
            //Set the length
            rLength=usLength;

            //Returned the parsed data
            return ConvertParsedName(pBuffer,
                                     pOriginalBuffer);
        }
    }
}
ERROR_HANDLER_STATIC_RETURN(CDNSParser_Class,"ParseName","")

'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.