]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/esi/ExpatParser.cc
5 * DEBUG: section 86 ESI processing
6 * AUTHOR: Robert Collins
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
40 #include "esi/ExpatParser.h"
42 EsiParserDefinition(ESIExpatParser
);
44 ESIExpatParser::ESIExpatParser(ESIParserClient
*aClient
) : theClient (aClient
)
46 /* TODO: grab the document encoding from the headers */
47 p
= XML_ParserCreateNS(NULL
,'|');
48 XML_SetUserData (myParser(), static_cast<void *>(this));
49 XML_SetElementHandler(myParser(), Start
, End
);
50 XML_SetDefaultHandler(myParser(), Default
);
51 XML_SetCommentHandler(myParser(), Comment
);
52 XML_UseParserAsHandlerArg(myParser());
55 ESIExpatParser::~ESIExpatParser()
57 XML_ParserFree (myParser());
62 ESIExpatParser::Start(void *data
,const XML_Char
*el
, const char **attr
)
64 XML_Parser parser
= static_cast<XML_Parser
>(data
);
65 ESIExpatParser
*me
= (ESIExpatParser
*)XML_GetUserData(parser
);
66 me
->theClient
->start (el
, attr
, XML_GetSpecifiedAttributeCount (parser
));
70 ESIExpatParser::End(void *data
,const XML_Char
*el
)
72 XML_Parser parser
= static_cast<XML_Parser
>(data
);
73 ESIExpatParser
*me
= (ESIExpatParser
*)XML_GetUserData(parser
);
74 me
->theClient
->end (el
);
78 ESIExpatParser::Default(void *data
, const XML_Char
*s
, int len
)
80 XML_Parser parser
= static_cast<XML_Parser
>(data
);
81 ESIExpatParser
*me
= (ESIExpatParser
*)XML_GetUserData(parser
);
82 me
->theClient
->parserDefault (s
, len
);
86 ESIExpatParser::Comment(void *data
, const XML_Char
*s
)
88 XML_Parser parser
= static_cast<XML_Parser
>(data
);
89 ESIExpatParser
*me
= (ESIExpatParser
*)XML_GetUserData(parser
);
90 me
->theClient
->parserComment (s
);
94 ESIExpatParser::parse(char const *dataToParse
, size_t const lengthOfData
, bool const endOfStream
)
96 return XML_Parse(myParser(), dataToParse
, lengthOfData
, endOfStream
);
100 ESIExpatParser::lineNumber() const
102 return (long int)XML_GetCurrentLineNumber(myParser());
106 ESIExpatParser::errorString() const
108 return XML_ErrorString(XML_GetErrorCode(myParser()));
111 #endif /* USE_SQUID_ESI */