]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ESIExpatParser.cc
Bug #988: src/fs/aufs/store_io_aufs.c fails to compile with ASYNC_WRITE set
[thirdparty/squid.git] / src / ESIExpatParser.cc
CommitLineData
43ae1d95 1
2/*
00d77d6b 3 * $Id: ESIExpatParser.cc,v 1.2 2003/08/04 22:14:40 robertc Exp $
43ae1d95 4 *
5 * DEBUG: section 86 ESI processing
6 * AUTHOR: Robert Collins
7 *
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
10 *
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.
19 *
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.
24 *
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.
29 *
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.
33 *
34 */
35
36#include "squid.h"
37#include "ESIExpatParser.h"
38
43ae1d95 39ESIExpatParser::ESIExpatParser(ESIParserClient *aClient) : theClient (aClient)
40{
41 /* TODO: grab the document encoding from the headers */
42 p = XML_ParserCreateNS(NULL,'|');
43 XML_SetUserData (myParser(), static_cast<void *>(this));
44 XML_SetElementHandler(myParser(), Start, End);
45 XML_SetDefaultHandler(myParser(), Default);
46 XML_SetCommentHandler(myParser(), Comment);
47 XML_UseParserAsHandlerArg(myParser());
48}
49
50ESIExpatParser::~ESIExpatParser()
51{
52 XML_ParserFree (myParser());
53 p = NULL;
54}
55
56void
57ESIExpatParser::Start(void *data,const XML_Char *el, const char **attr)
58{
59 XML_Parser parser = static_cast<XML_Parser>(data);
60 ESIExpatParser *me = (ESIExpatParser *)XML_GetUserData(parser);
61 me->theClient->start (el, attr, XML_GetSpecifiedAttributeCount (parser));
62}
63
64void
65ESIExpatParser::End(void *data,const XML_Char *el)
66{
67 XML_Parser parser = static_cast<XML_Parser>(data);
68 ESIExpatParser *me = (ESIExpatParser *)XML_GetUserData(parser);
69 me->theClient->end (el);
70}
71
72void
73ESIExpatParser::Default(void *data, const XML_Char *s, int len)
74{
75 XML_Parser parser = static_cast<XML_Parser>(data);
76 ESIExpatParser *me = (ESIExpatParser *)XML_GetUserData(parser);
77 me->theClient->parserDefault (s, len);
78}
79
80void
81ESIExpatParser::Comment(void *data, const XML_Char *s)
82{
83 XML_Parser parser = static_cast<XML_Parser>(data);
84 ESIExpatParser *me = (ESIExpatParser *)XML_GetUserData(parser);
85 me->theClient->parserComment (s);
86}
87
88bool
89ESIExpatParser::parse(char const *dataToParse, size_t const lengthOfData, bool const endOfStream)
90{
91 return XML_Parse(myParser(), dataToParse, lengthOfData, endOfStream);
92}
93
94size_t
95ESIExpatParser::lineNumber() const
96{
97 return XML_GetCurrentLineNumber(myParser());
98}
99
100char const *
101ESIExpatParser::errorString() const
102{
103 return XML_ErrorString(XML_GetErrorCode(myParser()));
104}