![]() |
ConvertParsedName() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Private Function |
Declared in: DNSParser.h |
static std::string ConvertParsedName( const char* pBuffer, const char* pOriginalBuffer);
Convert a name
try { //Our string std::string sParsedName; //Counter unsigned short usCounter; usCounter=0; while (*pBuffer && usCounter<MAX_DOMAIN_SIZE) { if (pOriginalBuffer) { //Damn shortcuts unsigned short usShort; usShort=*((const unsigned short*)pBuffer); //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,"ConvertParsedName","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,"ConvertParsedName","Recieved zero length!"); //Exit return ""; } else //Continue parsing pBuffer=pOriginalBuffer+usShort; } } //Get the section length unsigned short usLength; usLength=*pBuffer; //Point it to the next byte ++pBuffer; //Copy it to tmp variable CArray_ptr<char> pTmpData(new char[usLength+1]); memcpy(pTmpData.Get(), pBuffer, usLength); //Terminate it pTmpData.Get()[usLength]=0; //Add it to our string sParsedName+=pTmpData.Get(); //Increment the buffer pBuffer+=usLength; //Check if not the latest byte if (*pBuffer) //Add the dot sParsedName+='.'; } //Check for errors if (usCounter>MAX_DOMAIN_SIZE) { //Report it ReportStaticError(CDNSParser_Class,"ConvertParsedName","Recieved size too large!"); //Exit return ""; } else //Done return sParsedName; } ERROR_HANDLER_STATIC_RETURN(CDNSParser_Class,"ConvertParsedName","")
![]() |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |