/**
* PROJECT - HTML Reader Class Library
*
* LiteHTMLReader.cpp - CLiteHTMLReader implementation
*
* Written By Gurmeet S. Kochar
* Copyright (c) 2004. All rights reserved.
*
* This code may be used in compiled form in any way you desire
* (including commercial use). The code may be redistributed
* unmodified by any means PROVIDING it is not sold for profit
* without the authors written consent, and providing that this
* notice and the authors name and all copyright notices remains
* intact. However, this file and the accompanying source code may
* not be hosted on a website or bulletin board without the authors
* written permission.
*
* This file is provided "AS IS" with no expressed or implied warranty.
* The author accepts no liability for any damage/loss of business that
* this product may cause.
*
* Although it is not necessary, but if you use this code in any of
* your application (commercial or non-commercial), please INFORM me
* so that I may know how useful this library is. This will encourage
* me to keep updating it.
*/
//#include "stdafx.h"
#include "LiteHTMLReader.h"
#ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif // _DEBUG
#ifndef __LITEHTMLENTITYRESOLVER_H__
# include "LiteHTMLEntityResolver.h"
#endif // !__LITEHTMLENTITYRESOLVER_H__
#pragma warning(push, 4)
UINT CLiteHTMLReader::parseDocument(void)
{
ASSERT(m_lpszBuffer != NULL);
bool bAbort = false; // continue parsing or abort?
bool bIsClosingTag = false; // tag parsed is a closing tag?
bool bIsOpeningTag = false; // tag parsed is an opening tag?
bool bInsideScript = false;
CString strCharacters; // character data
CString strComment; // comment data
CString strT; // temporary storage
DWORD dwCharDataStart = 0L; // starting position of character data
DWORD dwCharDataLen = 0L; // length of character data
LONG lTemp = 0L; // temporary storage
TCHAR ch = 0; // character at current buffer position
CLiteHTMLTag oTag; // tag information
if ( (!m_lpszBuffer) || (!m_dwBufLen) )
return (0U);
// reset seek pointer to beginning
ResetSeekPointer();
// notify event handler about parsing startup
if (getEventNotify(notifyStartStop))
{
bAbort = false;
m_pEventHandler->BeginParse(m_dwAppData, bAbort);
if (bAbort) goto LEndParse;
}
// skip leading white-space characters
while (isWhiteSpace(ReadChar()))
;
ch = UngetChar();
while ((ch = ReadChar()) != NULL)
{
switch (ch)
{
// tag starting delimeter?
case _T('<'):
{
UngetChar();
strComment.Empty();
if (!parseComment(strComment))
{
bIsOpeningTag = false;
bIsClosingTag = false;
bInsideScript = false;
if (!parseTag(oTag, bIsOpeningTag, bIsClosingTag, bInsideScript))
{
++dwCharDataLen;
// manually advance buffer position
// because the last call to UngetChar()
// moved it back one character
ch = ReadChar();
break;
}
else
{
// check