Class KomodiaDNS::CDNSParser::
GetParsedDomainLength()
Base ClassesConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: ConvertParsedNameNext page: ParseName    Show member index
Private Function Declared in:
DNSParser.h

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

static unsigned short GetParsedDomainLength(
    const char *pBuffer,
    const char* pOriginalBuffer);

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

Get the size of the string

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

try
{
    //Get the length of the parsed domain
    const unsigned char* pBackupBuffer=(const unsigned char*)pBuffer;

    //Counter
    unsigned short usCounter;
    usCounter=0;

    while (*pBackupBuffer &&
           usCounter<256)
    {
        if (pOriginalBuffer)
        {
            //Damn shortcuts
            unsigned short usShort;
            usShort=*((unsigned short*)pBackupBuffer);

            //Convert it
            usShort=htons(usShort);

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

                //Check the size
                if (usShort>MAX_REPLY)
                {
                    //Report it
                    ReportStaticError(CDNSParser_Class,"GetParsedDomainLength","Size too big!");

                    //Exit
                    return 0;
                }

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

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

                    //Exit
                    return 0;
                }
                else
                {
                    //We are done
                    usCounter+=usLength;

                    //And exit
                    return usCounter+1;
                }
            }
        }

        //Regular
        usCounter+=*pBackupBuffer+1;
        pBackupBuffer+=*pBackupBuffer+1;
    }

    //Check for errors
    if (usCounter>256)
    {
        //Report it
        ReportStaticError(CDNSParser_Class,"GetParsedDomainLength","Recieved length too high!");

        //Exit
        return 0;
    }
    else
        return usCounter+1;
}
ERROR_HANDLER_STATIC_RETURN(CDNSParser_Class,"GetParsedDomainLength",0)

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