2008-03-25 04:19:10 +01:00
|
|
|
/*
|
|
|
|
* SAX Reader implementation
|
|
|
|
*
|
|
|
|
* Copyright 2008 Alistair Leslie-Hughes
|
2008-07-17 00:40:32 +02:00
|
|
|
* Copyright 2008 Piotr Caban
|
2008-03-25 04:19:10 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2011-02-24 13:11:53 +01:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/xmlerror.h>
|
|
|
|
# include <libxml/SAX2.h>
|
|
|
|
# include <libxml/parserInternals.h>
|
|
|
|
#endif
|
|
|
|
|
2008-03-25 04:19:10 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "ole2.h"
|
2010-08-29 23:31:49 +02:00
|
|
|
#include "msxml6.h"
|
2008-03-25 04:19:10 +01:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "urlmon.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2011-12-24 14:10:33 +01:00
|
|
|
#include "wine/list.h"
|
2008-03-25 04:19:10 +01:00
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2011-12-16 12:33:32 +01:00
|
|
|
typedef enum
|
2011-10-04 23:27:39 +02:00
|
|
|
{
|
|
|
|
ExhaustiveErrors = 1 << 1,
|
|
|
|
ExternalGeneralEntities = 1 << 2,
|
|
|
|
ExternalParameterEntities = 1 << 3,
|
|
|
|
ForcedResync = 1 << 4,
|
|
|
|
NamespacePrefixes = 1 << 5,
|
2011-10-05 20:29:37 +02:00
|
|
|
Namespaces = 1 << 6,
|
2011-10-04 23:27:39 +02:00
|
|
|
ParameterEntities = 1 << 7,
|
|
|
|
PreserveSystemIndentifiers = 1 << 8,
|
|
|
|
ProhibitDTD = 1 << 9,
|
|
|
|
SchemaValidation = 1 << 10,
|
|
|
|
ServerHttpRequest = 1 << 11,
|
|
|
|
SuppressValidationfatalError = 1 << 12,
|
|
|
|
UseInlineSchema = 1 << 13,
|
2011-10-05 16:37:40 +02:00
|
|
|
UseSchemaLocation = 1 << 14,
|
|
|
|
LexicalHandlerParEntities = 1 << 15
|
2011-12-16 12:33:32 +01:00
|
|
|
} saxreader_features;
|
2011-10-04 23:27:39 +02:00
|
|
|
|
2011-07-15 14:38:07 +02:00
|
|
|
struct bstrpool
|
|
|
|
{
|
|
|
|
BSTR *pool;
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int len;
|
|
|
|
};
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BSTR prefix;
|
|
|
|
BSTR uri;
|
|
|
|
} ns;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
BSTR prefix;
|
|
|
|
BSTR local;
|
|
|
|
BSTR qname;
|
|
|
|
ns *ns; /* namespaces defined in this particular element */
|
|
|
|
int ns_count;
|
|
|
|
} element_entry;
|
|
|
|
|
2011-12-16 12:33:32 +01:00
|
|
|
typedef struct
|
2008-03-25 04:19:10 +01:00
|
|
|
{
|
2011-11-21 10:23:25 +01:00
|
|
|
DispatchEx dispex;
|
2010-12-27 23:12:06 +01:00
|
|
|
IVBSAXXMLReader IVBSAXXMLReader_iface;
|
|
|
|
ISAXXMLReader ISAXXMLReader_iface;
|
2008-03-25 04:19:10 +01:00
|
|
|
LONG ref;
|
2011-12-16 12:33:32 +01:00
|
|
|
ISAXContentHandler *contentHandler;
|
|
|
|
IVBSAXContentHandler *vbcontentHandler;
|
|
|
|
ISAXErrorHandler *errorHandler;
|
|
|
|
IVBSAXErrorHandler *vberrorHandler;
|
|
|
|
ISAXLexicalHandler *lexicalHandler;
|
|
|
|
IVBSAXLexicalHandler *vblexicalHandler;
|
|
|
|
ISAXDeclHandler *declHandler;
|
|
|
|
IVBSAXDeclHandler *vbdeclHandler;
|
2008-03-25 04:19:10 +01:00
|
|
|
xmlSAXHandler sax;
|
2008-10-01 19:52:36 +02:00
|
|
|
BOOL isParsing;
|
2011-07-15 14:38:07 +02:00
|
|
|
struct bstrpool pool;
|
2011-12-16 12:33:32 +01:00
|
|
|
saxreader_features features;
|
2011-10-24 20:08:46 +02:00
|
|
|
MSXML_VERSION version;
|
2008-03-25 04:19:10 +01:00
|
|
|
} saxreader;
|
|
|
|
|
2011-12-16 12:33:32 +01:00
|
|
|
typedef struct
|
2008-07-17 00:40:32 +02:00
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
IVBSAXLocator IVBSAXLocator_iface;
|
|
|
|
ISAXLocator ISAXLocator_iface;
|
2011-10-31 12:32:39 +01:00
|
|
|
IVBSAXAttributes IVBSAXAttributes_iface;
|
|
|
|
ISAXAttributes ISAXAttributes_iface;
|
2008-07-17 00:40:32 +02:00
|
|
|
LONG ref;
|
|
|
|
saxreader *saxreader;
|
2008-07-17 00:40:53 +02:00
|
|
|
HRESULT ret;
|
|
|
|
xmlParserCtxtPtr pParserCtxt;
|
2008-07-17 00:42:01 +02:00
|
|
|
WCHAR *publicId;
|
2008-07-17 00:42:07 +02:00
|
|
|
WCHAR *systemId;
|
2008-07-23 16:39:04 +02:00
|
|
|
int line;
|
|
|
|
int column;
|
2008-07-31 16:48:03 +02:00
|
|
|
BOOL vbInterface;
|
2011-12-24 14:10:33 +01:00
|
|
|
struct list elements;
|
2008-07-17 00:40:32 +02:00
|
|
|
|
2011-10-31 12:33:18 +01:00
|
|
|
BSTR namespaceUri;
|
2011-10-31 12:32:39 +01:00
|
|
|
int attributesSize;
|
2008-07-30 20:24:12 +02:00
|
|
|
int nb_attributes;
|
2011-10-31 12:32:39 +01:00
|
|
|
struct _attributes
|
|
|
|
{
|
|
|
|
BSTR szLocalname;
|
|
|
|
BSTR szURI;
|
|
|
|
BSTR szValue;
|
|
|
|
BSTR szQName;
|
|
|
|
} *attributes;
|
|
|
|
} saxlocator;
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2008-03-25 04:19:10 +01:00
|
|
|
static inline saxreader *impl_from_IVBSAXXMLReader( IVBSAXXMLReader *iface )
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
return CONTAINING_RECORD(iface, saxreader, IVBSAXXMLReader_iface);
|
2008-03-31 21:42:18 +02:00
|
|
|
}
|
2008-03-25 04:19:10 +01:00
|
|
|
|
2008-07-08 20:52:04 +02:00
|
|
|
static inline saxreader *impl_from_ISAXXMLReader( ISAXXMLReader *iface )
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
return CONTAINING_RECORD(iface, saxreader, ISAXXMLReader_iface);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
2008-07-31 16:47:26 +02:00
|
|
|
static inline saxlocator *impl_from_IVBSAXLocator( IVBSAXLocator *iface )
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
return CONTAINING_RECORD(iface, saxlocator, IVBSAXLocator_iface);
|
2008-07-31 16:47:26 +02:00
|
|
|
}
|
|
|
|
|
2008-07-17 00:40:32 +02:00
|
|
|
static inline saxlocator *impl_from_ISAXLocator( ISAXLocator *iface )
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
return CONTAINING_RECORD(iface, saxlocator, ISAXLocator_iface);
|
2008-07-17 00:40:32 +02:00
|
|
|
}
|
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
static inline saxlocator *impl_from_IVBSAXAttributes( IVBSAXAttributes *iface )
|
2008-07-31 16:47:26 +02:00
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
return CONTAINING_RECORD(iface, saxlocator, IVBSAXAttributes_iface);
|
2008-07-31 16:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
static inline saxlocator *impl_from_ISAXAttributes( ISAXAttributes *iface )
|
2008-07-27 19:55:05 +02:00
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
return CONTAINING_RECORD(iface, saxlocator, ISAXAttributes_iface);
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
/* property names */
|
|
|
|
static const WCHAR PropertyCharsetW[] = {
|
|
|
|
'c','h','a','r','s','e','t',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyDeclHandlerW[] = {
|
|
|
|
'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
|
|
|
|
's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
|
|
|
|
'd','e','c','l','a','r','a','t','i','o','n',
|
|
|
|
'-','h','a','n','d','l','e','r',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyDomNodeW[] = {
|
|
|
|
'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
|
|
|
|
's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
|
|
|
|
'd','o','m','-','n','o','d','e',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyInputSourceW[] = {
|
|
|
|
'i','n','p','u','t','-','s','o','u','r','c','e',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyLexicalHandlerW[] = {
|
|
|
|
'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
|
|
|
|
's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
|
|
|
|
'l','e','x','i','c','a','l','-','h','a','n','d','l','e','r',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyMaxElementDepthW[] = {
|
|
|
|
'm','a','x','-','e','l','e','m','e','n','t','-','d','e','p','t','h',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyMaxXMLSizeW[] = {
|
|
|
|
'm','a','x','-','x','m','l','-','s','i','z','e',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertySchemaDeclHandlerW[] = {
|
|
|
|
's','c','h','e','m','a','-','d','e','c','l','a','r','a','t','i','o','n','-',
|
|
|
|
'h','a','n','d','l','e','r',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyXMLDeclEncodingW[] = {
|
|
|
|
'x','m','l','d','e','c','l','-','e','n','c','o','d','i','n','g',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyXMLDeclStandaloneW[] = {
|
|
|
|
'x','m','l','d','e','c','l','-','s','t','a','n','d','a','l','o','n','e',0
|
|
|
|
};
|
|
|
|
static const WCHAR PropertyXMLDeclVersionW[] = {
|
|
|
|
'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
|
|
|
|
};
|
|
|
|
|
2011-10-04 23:27:39 +02:00
|
|
|
/* feature names */
|
|
|
|
static const WCHAR FeatureExternalGeneralEntitiesW[] = {
|
|
|
|
'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/',
|
|
|
|
'f','e','a','t','u','r','e','s','/','e','x','t','e','r','n','a','l','-','g','e','n','e','r','a','l',
|
|
|
|
'-','e','n','t','i','t','i','e','s',0
|
|
|
|
};
|
|
|
|
|
2011-10-05 16:20:32 +02:00
|
|
|
static const WCHAR FeatureExternalParameterEntitiesW[] = {
|
|
|
|
'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
|
|
|
|
'/','e','x','t','e','r','n','a','l','-','p','a','r','a','m','e','t','e','r','-','e','n','t','i','t','i','e','s',0
|
|
|
|
};
|
|
|
|
|
2011-10-05 16:37:40 +02:00
|
|
|
static const WCHAR FeatureLexicalHandlerParEntitiesW[] = {
|
|
|
|
'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
|
|
|
|
'/','l','e','x','i','c','a','l','-','h','a','n','d','l','e','r','/','p','a','r','a','m','e','t','e','r','-','e','n','t','i','t','i','e','s',0
|
|
|
|
};
|
|
|
|
|
2011-10-05 18:09:28 +02:00
|
|
|
static const WCHAR FeatureProhibitDTDW[] = {
|
|
|
|
'p','r','o','h','i','b','i','t','-','d','t','d',0
|
|
|
|
};
|
|
|
|
|
2011-10-05 20:29:37 +02:00
|
|
|
static const WCHAR FeatureNamespacesW[] = {
|
|
|
|
'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
|
|
|
|
'/','n','a','m','e','s','p','a','c','e','s',0
|
|
|
|
};
|
|
|
|
|
2011-12-16 12:33:32 +01:00
|
|
|
static inline HRESULT set_feature_value(saxreader *reader, saxreader_features feature, VARIANT_BOOL value)
|
2011-10-04 23:27:39 +02:00
|
|
|
{
|
|
|
|
if (value == VARIANT_TRUE)
|
|
|
|
reader->features |= feature;
|
|
|
|
else
|
|
|
|
reader->features &= ~feature;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-16 12:33:32 +01:00
|
|
|
static inline HRESULT get_feature_value(const saxreader *reader, saxreader_features feature, VARIANT_BOOL *value)
|
2011-10-05 20:29:37 +02:00
|
|
|
{
|
|
|
|
*value = reader->features & feature ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-18 21:30:50 +01:00
|
|
|
static inline BOOL has_content_handler(const saxlocator *locator)
|
|
|
|
{
|
|
|
|
return (locator->vbInterface && locator->saxreader->vbcontentHandler) ||
|
|
|
|
(!locator->vbInterface && locator->saxreader->contentHandler);
|
|
|
|
}
|
2008-07-23 16:39:04 +02:00
|
|
|
|
2010-10-28 23:04:44 +02:00
|
|
|
static inline BOOL has_error_handler(const saxlocator *locator)
|
|
|
|
{
|
|
|
|
return (locator->vbInterface && locator->saxreader->vberrorHandler) ||
|
|
|
|
(!locator->vbInterface && locator->saxreader->errorHandler);
|
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
static BSTR build_qname(BSTR prefix, BSTR local)
|
2008-08-20 18:20:50 +02:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
if (prefix && *prefix)
|
2008-08-20 18:20:50 +02:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
BSTR qname = SysAllocStringLen(NULL, SysStringLen(prefix) + SysStringLen(local) + 1);
|
|
|
|
WCHAR *ptr;
|
2008-08-20 18:20:50 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
ptr = qname;
|
|
|
|
strcpyW(ptr, prefix);
|
|
|
|
ptr += SysStringLen(prefix);
|
|
|
|
*ptr++ = ':';
|
|
|
|
strcpyW(ptr, local);
|
|
|
|
return qname;
|
2008-08-20 18:20:50 +02:00
|
|
|
}
|
2011-12-24 14:10:33 +01:00
|
|
|
else
|
|
|
|
return SysAllocString(local);
|
|
|
|
}
|
|
|
|
|
|
|
|
static element_entry* alloc_element_entry(const xmlChar *local, const xmlChar *prefix, int nb_ns,
|
|
|
|
const xmlChar **namespaces)
|
|
|
|
{
|
|
|
|
element_entry *ret;
|
|
|
|
int i;
|
2011-10-31 12:32:59 +01:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
ret = heap_alloc(sizeof(*ret));
|
|
|
|
if (!ret) return ret;
|
|
|
|
|
|
|
|
ret->local = bstr_from_xmlChar(local);
|
|
|
|
ret->prefix = bstr_from_xmlChar(prefix);
|
|
|
|
ret->qname = build_qname(ret->prefix, ret->local);
|
|
|
|
ret->ns = nb_ns ? heap_alloc(nb_ns*sizeof(ns)) : NULL;
|
|
|
|
ret->ns_count = nb_ns;
|
|
|
|
|
|
|
|
for (i=0; i < nb_ns; i++)
|
2011-10-31 12:32:59 +01:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
ret->ns[i].prefix = bstr_from_xmlChar(namespaces[2*i]);
|
|
|
|
ret->ns[i].uri = bstr_from_xmlChar(namespaces[2*i+1]);
|
2011-10-31 12:32:59 +01:00
|
|
|
}
|
2011-12-24 14:10:33 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_element_entry(element_entry *element)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<element->ns_count;i++)
|
2011-10-31 12:32:59 +01:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
SysFreeString(element->ns[i].prefix);
|
|
|
|
SysFreeString(element->ns[i].uri);
|
2011-10-31 12:32:59 +01:00
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
SysFreeString(element->prefix);
|
|
|
|
SysFreeString(element->local);
|
2008-08-20 18:20:50 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
heap_free(element->ns);
|
|
|
|
heap_free(element);
|
2008-08-20 18:20:50 +02:00
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
static void push_element_ns(saxlocator *locator, element_entry *element)
|
2008-08-20 18:20:50 +02:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
list_add_head(&locator->elements, &element->entry);
|
|
|
|
}
|
2011-10-31 12:32:59 +01:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
static element_entry * pop_element_ns(saxlocator *locator)
|
|
|
|
{
|
|
|
|
element_entry *element = LIST_ENTRY(list_head(&locator->elements), element_entry, entry);
|
|
|
|
|
|
|
|
if (element)
|
|
|
|
list_remove(&element->entry);
|
|
|
|
|
|
|
|
return element;
|
2008-08-20 18:20:50 +02:00
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
static BSTR find_element_uri(saxlocator *locator, const xmlChar *uri)
|
2011-10-31 12:33:08 +01:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
element_entry *element;
|
|
|
|
BSTR uriW;
|
2011-10-31 12:33:08 +01:00
|
|
|
int i;
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (!uri) return NULL;
|
|
|
|
|
|
|
|
uriW = bstr_from_xmlChar(uri);
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(element, &locator->elements, element_entry, entry)
|
2011-10-31 12:33:08 +01:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
for (i=0; i < element->ns_count; i++)
|
|
|
|
if (!strcmpW(uriW, element->ns[i].uri))
|
|
|
|
{
|
|
|
|
SysFreeString(uriW);
|
|
|
|
return element->ns[i].uri;
|
|
|
|
}
|
2011-10-31 12:33:08 +01:00
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
SysFreeString(uriW);
|
|
|
|
ERR("namespace uri not found, %s\n", debugstr_a((char*)uri));
|
2011-10-31 12:33:08 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
/* used to localize version dependent error check behaviour */
|
|
|
|
static inline BOOL sax_callback_failed(saxlocator *This, HRESULT hr)
|
|
|
|
{
|
|
|
|
return This->saxreader->version >= MSXML6 ? FAILED(hr) : hr != S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* index value -1 means it tries to loop for a first time */
|
|
|
|
static inline BOOL iterate_endprefix_index(saxlocator *This, const element_entry *element, int *i)
|
|
|
|
{
|
|
|
|
if (This->saxreader->version >= MSXML6)
|
|
|
|
{
|
|
|
|
if (*i == -1) *i = 0; else ++*i;
|
|
|
|
return *i < element->ns_count;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*i == -1) *i = element->ns_count-1; else --*i;
|
|
|
|
return *i >= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 14:38:07 +02:00
|
|
|
static BOOL bstr_pool_insert(struct bstrpool *pool, BSTR pool_entry)
|
|
|
|
{
|
|
|
|
if (!pool->pool)
|
|
|
|
{
|
|
|
|
pool->pool = HeapAlloc(GetProcessHeap(), 0, 16 * sizeof(*pool->pool));
|
|
|
|
if (!pool->pool)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pool->index = 0;
|
|
|
|
pool->len = 16;
|
|
|
|
}
|
|
|
|
else if (pool->index == pool->len)
|
|
|
|
{
|
|
|
|
BSTR *realloc = HeapReAlloc(GetProcessHeap(), 0, pool->pool, pool->len * 2 * sizeof(*realloc));
|
|
|
|
|
|
|
|
if (!realloc)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pool->pool = realloc;
|
|
|
|
pool->len *= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
pool->pool[pool->index++] = pool_entry;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_bstr_pool(struct bstrpool *pool)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < pool->index; i++)
|
|
|
|
SysFreeString(pool->pool[i]);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pool->pool);
|
|
|
|
|
|
|
|
pool->pool = NULL;
|
|
|
|
pool->index = pool->len = 0;
|
|
|
|
}
|
|
|
|
|
2008-08-03 14:37:37 +02:00
|
|
|
static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len)
|
2008-07-30 20:24:12 +02:00
|
|
|
{
|
|
|
|
DWORD dLen;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
if (!buf)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0);
|
|
|
|
if(len != -1) dLen++;
|
2010-07-17 14:06:53 +02:00
|
|
|
bstr = SysAllocStringLen(NULL, dLen-1);
|
|
|
|
if (!bstr)
|
2008-07-30 20:24:12 +02:00
|
|
|
return NULL;
|
2010-07-17 14:06:53 +02:00
|
|
|
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, bstr, dLen);
|
|
|
|
if(len != -1) bstr[dLen-1] = '\0';
|
2008-07-30 20:24:12 +02:00
|
|
|
|
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
2008-08-03 14:37:37 +02:00
|
|
|
static BSTR QName_from_xmlChar(const xmlChar *prefix, const xmlChar *name)
|
|
|
|
{
|
2010-10-28 23:14:08 +02:00
|
|
|
xmlChar *qname;
|
2008-08-03 14:37:37 +02:00
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
if(!name) return NULL;
|
|
|
|
|
2010-10-28 23:14:08 +02:00
|
|
|
if(!prefix || !*prefix)
|
2008-08-03 14:37:37 +02:00
|
|
|
return bstr_from_xmlChar(name);
|
|
|
|
|
2010-10-28 23:14:08 +02:00
|
|
|
qname = xmlBuildQName(name, prefix, NULL, 0);
|
|
|
|
bstr = bstr_from_xmlChar(qname);
|
|
|
|
xmlFree(qname);
|
2008-08-03 14:37:37 +02:00
|
|
|
|
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
2011-07-15 14:38:07 +02:00
|
|
|
static BSTR pooled_bstr_from_xmlChar(struct bstrpool *pool, const xmlChar *buf)
|
|
|
|
{
|
|
|
|
BSTR pool_entry = bstr_from_xmlChar(buf);
|
|
|
|
|
|
|
|
if (pool_entry && !bstr_pool_insert(pool, pool_entry))
|
|
|
|
{
|
|
|
|
SysFreeString(pool_entry);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pool_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BSTR pooled_bstr_from_xmlCharN(struct bstrpool *pool, const xmlChar *buf, int len)
|
|
|
|
{
|
|
|
|
BSTR pool_entry = bstr_from_xmlCharN(buf, len);
|
|
|
|
|
|
|
|
if (pool_entry && !bstr_pool_insert(pool, pool_entry))
|
|
|
|
{
|
|
|
|
SysFreeString(pool_entry);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pool_entry;
|
|
|
|
}
|
|
|
|
|
2008-07-19 22:32:10 +02:00
|
|
|
static void format_error_message_from_id(saxlocator *This, HRESULT hr)
|
|
|
|
{
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
|
|
|
This->ret = hr;
|
|
|
|
|
2010-10-28 23:04:44 +02:00
|
|
|
if(has_error_handler(This))
|
2008-07-19 22:32:10 +02:00
|
|
|
{
|
|
|
|
WCHAR msg[1024];
|
|
|
|
if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL, hr, 0, msg, sizeof(msg), NULL))
|
|
|
|
{
|
|
|
|
FIXME("MSXML errors not yet supported.\n");
|
|
|
|
msg[0] = '\0';
|
|
|
|
}
|
|
|
|
|
2008-07-31 16:48:03 +02:00
|
|
|
if(This->vbInterface)
|
|
|
|
{
|
|
|
|
BSTR bstrMsg = SysAllocString(msg);
|
|
|
|
IVBSAXErrorHandler_fatalError(This->saxreader->vberrorHandler,
|
2010-12-27 23:12:06 +01:00
|
|
|
&This->IVBSAXLocator_iface, &bstrMsg, hr);
|
2010-10-26 23:15:38 +02:00
|
|
|
SysFreeString(bstrMsg);
|
2008-07-31 16:48:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ISAXErrorHandler_fatalError(This->saxreader->errorHandler,
|
2010-12-27 23:12:06 +01:00
|
|
|
&This->ISAXLocator_iface, msg, hr);
|
2008-07-19 22:32:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
static void update_position(saxlocator *This, BOOL fix_column)
|
2008-07-23 16:39:04 +02:00
|
|
|
{
|
2011-11-28 15:05:25 +01:00
|
|
|
const xmlChar *p = This->pParserCtxt->input->cur-1;
|
2008-10-07 22:10:43 +02:00
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
This->line = xmlSAX2GetLineNumber(This->pParserCtxt);
|
|
|
|
if(fix_column)
|
2008-10-07 22:10:43 +02:00
|
|
|
{
|
2011-11-28 15:05:25 +01:00
|
|
|
This->column = 1;
|
|
|
|
for(; *p!='\n' && *p!='\r' && p>=This->pParserCtxt->input->base; p--)
|
|
|
|
This->column++;
|
2008-07-31 16:45:30 +02:00
|
|
|
}
|
2011-11-28 15:05:25 +01:00
|
|
|
else
|
2008-07-23 16:39:04 +02:00
|
|
|
{
|
2011-11-28 15:05:25 +01:00
|
|
|
This->column = xmlSAX2GetColumnNumber(This->pParserCtxt);
|
2008-07-23 16:39:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-31 16:47:41 +02:00
|
|
|
/*** IVBSAXAttributes interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_QueryInterface(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes(iface);
|
2008-07-31 16:47:41 +02:00
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
|
2011-10-31 12:32:39 +01:00
|
|
|
return IVBSAXLocator_QueryInterface(&This->IVBSAXLocator_iface, riid, ppvObject);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxattributes_AddRef(IVBSAXAttributes* iface)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes(iface);
|
|
|
|
return ISAXLocator_AddRef(&This->ISAXLocator_iface);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxattributes_Release(IVBSAXAttributes* iface)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes(iface);
|
|
|
|
return ISAXLocator_Release(&This->ISAXLocator_iface);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDispatch methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes *iface, UINT* pctinfo )
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2008-07-31 16:47:41 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetTypeInfo(
|
|
|
|
IVBSAXAttributes *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2008-07-31 16:47:41 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXAttributes_tid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetIDsOfNames(
|
|
|
|
IVBSAXAttributes *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2008-07-31 16:47:41 +02:00
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_Invoke(
|
|
|
|
IVBSAXAttributes *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2008-07-31 16:47:41 +02:00
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &This->IVBSAXAttributes_iface, dispIdMember, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-07-31 16:47:41 +02:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXAttributes methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_get_length(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int *nLength)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getLength(&This->ISAXAttributes_iface, nLength);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getURI(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *uri)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getURI(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)uri, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getLocalName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *localName)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getLocalName(&This->ISAXAttributes_iface, nIndex,
|
|
|
|
(const WCHAR**)localName, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *QName)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getQName(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)QName, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getIndexFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
int *index)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getIndexFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
|
2009-01-26 11:01:02 +01:00
|
|
|
localName, SysStringLen(localName), index);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getIndexFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
int *index)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getIndexFromQName(&This->ISAXAttributes_iface, QName,
|
2009-01-26 11:01:02 +01:00
|
|
|
SysStringLen(QName), index);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getType(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *type)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getType(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)type, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getTypeFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
BSTR *type)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getTypeFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
|
2009-01-26 11:01:02 +01:00
|
|
|
localName, SysStringLen(localName), (const WCHAR**)type, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getTypeFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
BSTR *type)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getTypeFromQName(&This->ISAXAttributes_iface, QName, SysStringLen(QName),
|
|
|
|
(const WCHAR**)type, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValue(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *value)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getValue(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)value, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValueFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
BSTR *value)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getValueFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
|
2009-01-26 11:01:02 +01:00
|
|
|
localName, SysStringLen(localName), (const WCHAR**)value, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValueFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
BSTR *value)
|
|
|
|
{
|
|
|
|
int len;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXAttributes_getValueFromQName(&This->ISAXAttributes_iface, QName,
|
2009-01-26 11:01:02 +01:00
|
|
|
SysStringLen(QName), (const WCHAR**)value, &len);
|
2008-07-31 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl =
|
|
|
|
{
|
|
|
|
ivbsaxattributes_QueryInterface,
|
|
|
|
ivbsaxattributes_AddRef,
|
|
|
|
ivbsaxattributes_Release,
|
|
|
|
ivbsaxattributes_GetTypeInfoCount,
|
|
|
|
ivbsaxattributes_GetTypeInfo,
|
|
|
|
ivbsaxattributes_GetIDsOfNames,
|
|
|
|
ivbsaxattributes_Invoke,
|
|
|
|
ivbsaxattributes_get_length,
|
|
|
|
ivbsaxattributes_getURI,
|
|
|
|
ivbsaxattributes_getLocalName,
|
|
|
|
ivbsaxattributes_getQName,
|
|
|
|
ivbsaxattributes_getIndexFromName,
|
|
|
|
ivbsaxattributes_getIndexFromQName,
|
|
|
|
ivbsaxattributes_getType,
|
|
|
|
ivbsaxattributes_getTypeFromName,
|
|
|
|
ivbsaxattributes_getTypeFromQName,
|
|
|
|
ivbsaxattributes_getValue,
|
|
|
|
ivbsaxattributes_getValueFromName,
|
|
|
|
ivbsaxattributes_getValueFromQName
|
|
|
|
};
|
|
|
|
|
2008-07-27 19:55:05 +02:00
|
|
|
/*** ISAXAttributes interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxattributes_QueryInterface(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes(iface);
|
2008-07-27 19:55:05 +02:00
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
|
2011-10-31 12:32:39 +01:00
|
|
|
return ISAXLocator_QueryInterface(&This->ISAXLocator_iface, riid, ppvObject);
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxattributes_AddRef(ISAXAttributes* iface)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes(iface);
|
2008-07-27 19:55:05 +02:00
|
|
|
TRACE("%p\n", This);
|
2011-10-31 12:32:39 +01:00
|
|
|
return ISAXLocator_AddRef(&This->ISAXLocator_iface);
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxattributes_Release(ISAXAttributes* iface)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes(iface);
|
2008-07-27 19:55:05 +02:00
|
|
|
|
|
|
|
TRACE("%p\n", This);
|
2011-10-31 12:32:39 +01:00
|
|
|
return ISAXLocator_Release(&This->ISAXLocator_iface);
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXAttributes methods ***/
|
|
|
|
static HRESULT WINAPI isaxattributes_getLength(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int *length)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2008-07-30 20:26:50 +02:00
|
|
|
*length = This->nb_attributes;
|
|
|
|
TRACE("Length set to %d\n", *length);
|
|
|
|
return S_OK;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getURI(
|
|
|
|
ISAXAttributes* iface,
|
2011-10-05 21:19:29 +02:00
|
|
|
int index,
|
|
|
|
const WCHAR **url,
|
|
|
|
int *size)
|
2008-07-27 19:55:05 +02:00
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2011-10-05 21:19:29 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, index);
|
2008-08-03 14:37:52 +02:00
|
|
|
|
2011-10-05 21:19:29 +02:00
|
|
|
if(index >= This->nb_attributes || index < 0) return E_INVALIDARG;
|
|
|
|
if(!url || !size) return E_POINTER;
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
*size = SysStringLen(This->attributes[index].szURI);
|
|
|
|
*url = This->attributes[index].szURI;
|
2011-10-05 21:19:29 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
TRACE("(%s:%d)\n", debugstr_w(This->attributes[index].szURI), *size);
|
2008-08-03 14:37:52 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getLocalName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pLocalName,
|
|
|
|
int *pLocalNameLength)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-07-30 20:27:07 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, nIndex);
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2008-08-03 14:37:45 +02:00
|
|
|
if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
|
|
|
|
if(!pLocalName || !pLocalNameLength) return E_POINTER;
|
2008-07-30 20:27:07 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
*pLocalNameLength = SysStringLen(This->attributes[nIndex].szLocalname);
|
|
|
|
*pLocalName = This->attributes[nIndex].szLocalname;
|
2008-07-30 20:27:07 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pQName,
|
|
|
|
int *pQNameLength)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-07-31 16:45:42 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, nIndex);
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2008-08-03 14:37:45 +02:00
|
|
|
if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
|
|
|
|
if(!pQName || !pQNameLength) return E_POINTER;
|
2008-07-31 16:45:42 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
*pQNameLength = SysStringLen(This->attributes[nIndex].szQName);
|
|
|
|
*pQName = This->attributes[nIndex].szQName;
|
2008-07-31 16:45:42 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getName(
|
|
|
|
ISAXAttributes* iface,
|
2011-10-05 21:19:29 +02:00
|
|
|
int index,
|
|
|
|
const WCHAR **uri,
|
2008-07-27 19:55:05 +02:00
|
|
|
int *pUriLength,
|
2011-10-05 21:19:29 +02:00
|
|
|
const WCHAR **localName,
|
2008-07-27 19:55:05 +02:00
|
|
|
int *pLocalNameSize,
|
2011-10-05 21:19:29 +02:00
|
|
|
const WCHAR **QName,
|
2008-07-27 19:55:05 +02:00
|
|
|
int *pQNameLength)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2011-10-05 21:19:29 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, index);
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2011-10-05 21:19:29 +02:00
|
|
|
if(index>=This->nb_attributes || index<0) return E_INVALIDARG;
|
|
|
|
if(!uri || !pUriLength || !localName || !pLocalNameSize
|
|
|
|
|| !QName || !pQNameLength) return E_POINTER;
|
2008-08-20 18:30:16 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
*pUriLength = SysStringLen(This->attributes[index].szURI);
|
|
|
|
*uri = This->attributes[index].szURI;
|
|
|
|
*pLocalNameSize = SysStringLen(This->attributes[index].szLocalname);
|
|
|
|
*localName = This->attributes[index].szLocalname;
|
|
|
|
*pQNameLength = SysStringLen(This->attributes[index].szQName);
|
|
|
|
*QName = This->attributes[index].szQName;
|
2011-10-05 21:19:29 +02:00
|
|
|
|
|
|
|
TRACE("(%s, %s, %s)\n", debugstr_w(*uri), debugstr_w(*localName), debugstr_w(*QName));
|
2008-08-20 18:30:16 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getIndexFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int cUriLength,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int cocalNameLength,
|
|
|
|
int *index)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-08-20 18:30:34 +02:00
|
|
|
int i;
|
|
|
|
TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), cUriLength,
|
2008-07-27 19:55:05 +02:00
|
|
|
debugstr_w(pLocalName), cocalNameLength);
|
2008-08-20 18:30:34 +02:00
|
|
|
|
|
|
|
if(!pUri || !pLocalName || !index) return E_POINTER;
|
|
|
|
|
|
|
|
for(i=0; i<This->nb_attributes; i++)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
if(cUriLength!=SysStringLen(This->attributes[i].szURI)
|
|
|
|
|| cocalNameLength!=SysStringLen(This->attributes[i].szLocalname))
|
2008-08-20 18:30:34 +02:00
|
|
|
continue;
|
2011-10-31 12:32:39 +01:00
|
|
|
if(cUriLength && memcmp(pUri, This->attributes[i].szURI,
|
2008-08-20 18:30:34 +02:00
|
|
|
sizeof(WCHAR)*cUriLength))
|
|
|
|
continue;
|
2011-10-31 12:32:39 +01:00
|
|
|
if(cocalNameLength && memcmp(pLocalName, This->attributes[i].szLocalname,
|
2008-08-20 18:30:34 +02:00
|
|
|
sizeof(WCHAR)*cocalNameLength))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getIndexFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQNameLength,
|
|
|
|
int *index)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-08-20 18:30:58 +02:00
|
|
|
int i;
|
|
|
|
TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQNameLength);
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2008-08-20 18:30:58 +02:00
|
|
|
if(!pQName || !index) return E_POINTER;
|
|
|
|
if(!nQNameLength) return E_INVALIDARG;
|
|
|
|
|
|
|
|
for(i=0; i<This->nb_attributes; i++)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
if(nQNameLength!=SysStringLen(This->attributes[i].szQName)) continue;
|
|
|
|
if(memcmp(pQName, This->attributes[i].szQName, sizeof(WCHAR)*nQNameLength)) continue;
|
2008-08-20 18:30:58 +02:00
|
|
|
|
|
|
|
*index = i;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getType(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *pTypeLength)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-07-27 19:55:05 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%d) stub\n", This, nIndex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getTypeFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int nUri,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int nLocalName,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *nType)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-07-27 19:55:05 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d, %s, %d) stub\n", This, debugstr_w(pUri), nUri,
|
|
|
|
debugstr_w(pLocalName), nLocalName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getTypeFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQName,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *nType)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-07-27 19:55:05 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d) stub\n", This, debugstr_w(pQName), nQName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getValue(
|
|
|
|
ISAXAttributes* iface,
|
2011-10-05 21:19:29 +02:00
|
|
|
int index,
|
|
|
|
const WCHAR **value,
|
2008-07-27 19:55:05 +02:00
|
|
|
int *nValue)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2011-10-05 21:19:29 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, index);
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2011-10-05 21:19:29 +02:00
|
|
|
if(index>=This->nb_attributes || index<0) return E_INVALIDARG;
|
|
|
|
if(!value || !nValue) return E_POINTER;
|
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
*nValue = SysStringLen(This->attributes[index].szValue);
|
|
|
|
*value = This->attributes[index].szValue;
|
2008-07-30 20:27:25 +02:00
|
|
|
|
2011-10-05 21:19:29 +02:00
|
|
|
TRACE("(%s:%d)\n", debugstr_w(*value), *nValue);
|
2008-07-30 20:27:25 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getValueFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int nUri,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int nLocalName,
|
|
|
|
const WCHAR **pValue,
|
|
|
|
int *nValue)
|
|
|
|
{
|
2008-08-20 18:31:17 +02:00
|
|
|
HRESULT hr;
|
|
|
|
int index;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-08-20 18:31:17 +02:00
|
|
|
TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), nUri,
|
2008-07-27 19:55:05 +02:00
|
|
|
debugstr_w(pLocalName), nLocalName);
|
2008-08-20 18:31:17 +02:00
|
|
|
|
|
|
|
hr = ISAXAttributes_getIndexFromName(iface,
|
|
|
|
pUri, nUri, pLocalName, nLocalName, &index);
|
|
|
|
if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
|
|
|
|
|
|
|
|
return hr;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getValueFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQName,
|
|
|
|
const WCHAR **pValue,
|
|
|
|
int *nValue)
|
|
|
|
{
|
2008-08-20 18:31:39 +02:00
|
|
|
HRESULT hr;
|
|
|
|
int index;
|
2011-10-31 12:32:39 +01:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2008-08-20 18:31:39 +02:00
|
|
|
TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQName);
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2008-08-20 18:31:39 +02:00
|
|
|
hr = ISAXAttributes_getIndexFromQName(iface, pQName, nQName, &index);
|
|
|
|
if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
|
|
|
|
|
|
|
|
return hr;
|
2008-07-27 19:55:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ISAXAttributesVtbl isaxattributes_vtbl =
|
|
|
|
{
|
|
|
|
isaxattributes_QueryInterface,
|
|
|
|
isaxattributes_AddRef,
|
|
|
|
isaxattributes_Release,
|
|
|
|
isaxattributes_getLength,
|
|
|
|
isaxattributes_getURI,
|
|
|
|
isaxattributes_getLocalName,
|
|
|
|
isaxattributes_getQName,
|
|
|
|
isaxattributes_getName,
|
|
|
|
isaxattributes_getIndexFromName,
|
|
|
|
isaxattributes_getIndexFromQName,
|
|
|
|
isaxattributes_getType,
|
|
|
|
isaxattributes_getTypeFromName,
|
|
|
|
isaxattributes_getTypeFromQName,
|
|
|
|
isaxattributes_getValue,
|
|
|
|
isaxattributes_getValueFromName,
|
|
|
|
isaxattributes_getValueFromQName
|
|
|
|
};
|
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
static HRESULT SAXAttributes_populate(saxlocator *locator,
|
2008-08-03 14:38:10 +02:00
|
|
|
int nb_namespaces, const xmlChar **xmlNamespaces,
|
2008-07-30 20:24:12 +02:00
|
|
|
int nb_attributes, const xmlChar **xmlAttributes)
|
2008-07-27 19:55:05 +02:00
|
|
|
{
|
2008-08-03 14:38:10 +02:00
|
|
|
static const xmlChar xmlns[] = "xmlns";
|
2011-10-26 13:25:27 +02:00
|
|
|
static const WCHAR xmlnsW[] = { 'x','m','l','n','s',0 };
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
struct _attributes *attrs;
|
|
|
|
int index;
|
2008-07-27 19:55:05 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
locator->nb_attributes = nb_namespaces+nb_attributes;
|
|
|
|
if(locator->nb_attributes > locator->attributesSize)
|
|
|
|
{
|
|
|
|
attrs = heap_realloc(locator->attributes, sizeof(struct _attributes)*locator->nb_attributes*2);
|
|
|
|
if(!attrs)
|
|
|
|
{
|
|
|
|
locator->nb_attributes = 0;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
locator->attributes = attrs;
|
|
|
|
}
|
|
|
|
else
|
2008-07-30 20:24:12 +02:00
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
attrs = locator->attributes;
|
2008-07-30 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2008-08-03 14:38:10 +02:00
|
|
|
for(index=0; index<nb_namespaces; index++)
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
attrs[nb_attributes+index].szLocalname = SysAllocStringLen(NULL, 0);
|
2011-10-31 12:33:18 +01:00
|
|
|
attrs[nb_attributes+index].szURI = locator->namespaceUri;
|
2011-10-31 12:32:39 +01:00
|
|
|
attrs[nb_attributes+index].szValue = bstr_from_xmlChar(xmlNamespaces[2*index+1]);
|
2011-10-26 13:25:27 +02:00
|
|
|
if(!xmlNamespaces[2*index])
|
2011-10-31 12:32:39 +01:00
|
|
|
attrs[nb_attributes+index].szQName = SysAllocString(xmlnsW);
|
2011-10-26 13:25:27 +02:00
|
|
|
else
|
2011-10-31 12:32:39 +01:00
|
|
|
attrs[nb_attributes+index].szQName = QName_from_xmlChar(xmlns, xmlNamespaces[2*index]);
|
2008-08-03 14:38:10 +02:00
|
|
|
}
|
|
|
|
|
2008-07-30 20:24:12 +02:00
|
|
|
for(index=0; index<nb_attributes; index++)
|
|
|
|
{
|
2012-03-01 19:06:39 +01:00
|
|
|
static const xmlChar xmlA[] = "xml";
|
|
|
|
|
|
|
|
if (xmlStrEqual(xmlAttributes[index*5+1], xmlA))
|
|
|
|
attrs[index].szURI = bstr_from_xmlChar(xmlAttributes[index*5+2]);
|
|
|
|
else
|
|
|
|
attrs[index].szURI = find_element_uri(locator, xmlAttributes[index*5+2]);
|
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
attrs[index].szLocalname = bstr_from_xmlChar(xmlAttributes[index*5]);
|
|
|
|
attrs[index].szValue = bstr_from_xmlCharN(xmlAttributes[index*5+3],
|
2011-10-26 13:25:27 +02:00
|
|
|
xmlAttributes[index*5+4]-xmlAttributes[index*5+3]);
|
2011-10-31 12:32:39 +01:00
|
|
|
attrs[index].szQName = QName_from_xmlChar(xmlAttributes[index*5+1],
|
2011-10-26 13:25:27 +02:00
|
|
|
xmlAttributes[index*5]);
|
2008-07-30 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2008-07-27 19:55:05 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-17 00:41:01 +02:00
|
|
|
/*** LibXML callbacks ***/
|
|
|
|
static void libxmlStartDocument(void *ctx)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
if(This->saxreader->version >= MSXML6)
|
|
|
|
{
|
|
|
|
const xmlChar *p = This->pParserCtxt->input->cur-1;
|
|
|
|
update_position(This, FALSE);
|
|
|
|
while(p>This->pParserCtxt->input->base && *p!='>')
|
|
|
|
{
|
|
|
|
if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
|
|
|
|
This->line--;
|
|
|
|
p--;
|
|
|
|
}
|
|
|
|
This->column = 0;
|
|
|
|
for(; p>=This->pParserCtxt->input->base && *p!='\n' && *p!='\r'; p--)
|
|
|
|
This->column++;
|
2011-10-24 20:08:46 +02:00
|
|
|
}
|
|
|
|
|
2010-01-18 21:30:50 +01:00
|
|
|
if(has_content_handler(This))
|
2008-07-17 00:41:01 +02:00
|
|
|
{
|
2008-07-31 16:48:03 +02:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_startDocument(This->saxreader->vbcontentHandler);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_startDocument(This->saxreader->contentHandler);
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-07-19 22:32:10 +02:00
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-17 00:41:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-17 00:41:19 +02:00
|
|
|
static void libxmlEndDocument(void *ctx)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-10-24 20:08:46 +02:00
|
|
|
if(This->saxreader->version >= MSXML6) {
|
2011-11-28 15:05:25 +01:00
|
|
|
update_position(This, FALSE);
|
2011-10-24 20:08:46 +02:00
|
|
|
if(This->column > 1)
|
|
|
|
This->line++;
|
|
|
|
This->column = 0;
|
|
|
|
} else {
|
|
|
|
This->column = 0;
|
|
|
|
This->line = 0;
|
|
|
|
}
|
2008-07-17 00:41:19 +02:00
|
|
|
|
2008-07-19 22:31:56 +02:00
|
|
|
if(This->ret != S_OK) return;
|
|
|
|
|
2010-01-18 21:30:50 +01:00
|
|
|
if(has_content_handler(This))
|
2008-07-17 00:41:19 +02:00
|
|
|
{
|
2008-07-31 16:48:03 +02:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_endDocument(This->saxreader->vbcontentHandler);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_endDocument(This->saxreader->contentHandler);
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-07-19 22:32:10 +02:00
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-17 00:41:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-17 00:41:27 +02:00
|
|
|
static void libxmlStartElementNS(
|
|
|
|
void *ctx,
|
|
|
|
const xmlChar *localname,
|
|
|
|
const xmlChar *prefix,
|
|
|
|
const xmlChar *URI,
|
|
|
|
int nb_namespaces,
|
|
|
|
const xmlChar **namespaces,
|
|
|
|
int nb_attributes,
|
|
|
|
int nb_defaulted,
|
|
|
|
const xmlChar **attributes)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2011-12-24 14:10:33 +01:00
|
|
|
element_entry *element;
|
|
|
|
HRESULT hr = S_OK;
|
2008-07-17 00:41:27 +02:00
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
update_position(This, TRUE);
|
2011-10-31 12:32:22 +01:00
|
|
|
if(*(This->pParserCtxt->input->cur) == '/')
|
2011-11-28 15:05:25 +01:00
|
|
|
This->column++;
|
2011-10-31 12:32:22 +01:00
|
|
|
if(This->saxreader->version < MSXML6)
|
2011-11-28 15:05:25 +01:00
|
|
|
This->column++;
|
2008-07-17 00:41:27 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
element = alloc_element_entry(localname, prefix, nb_namespaces, namespaces);
|
|
|
|
push_element_ns(This, element);
|
2011-10-31 12:32:59 +01:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (has_content_handler(This))
|
2008-07-17 00:41:27 +02:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
BSTR uri;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nb_namespaces; i++)
|
2008-08-03 17:03:28 +02:00
|
|
|
{
|
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_startPrefixMapping(
|
|
|
|
This->saxreader->vbcontentHandler,
|
2011-12-24 14:10:33 +01:00
|
|
|
&element->ns[i].prefix,
|
|
|
|
&element->ns[i].uri);
|
2008-08-03 17:03:28 +02:00
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_startPrefixMapping(
|
|
|
|
This->saxreader->contentHandler,
|
2011-12-24 14:10:33 +01:00
|
|
|
element->ns[i].prefix,
|
|
|
|
SysStringLen(element->ns[i].prefix),
|
|
|
|
element->ns[i].uri,
|
|
|
|
SysStringLen(element->ns[i].uri));
|
2008-08-03 17:03:28 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-08-03 17:03:28 +02:00
|
|
|
{
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
uri = find_element_uri(This, URI);
|
2008-07-17 00:41:27 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
hr = SAXAttributes_populate(This, nb_namespaces, namespaces, nb_attributes, attributes);
|
2008-07-30 20:24:12 +02:00
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
2008-07-31 16:48:03 +02:00
|
|
|
if(This->vbInterface)
|
2010-12-27 23:12:06 +01:00
|
|
|
hr = IVBSAXContentHandler_startElement(This->saxreader->vbcontentHandler,
|
2011-12-24 14:10:33 +01:00
|
|
|
&uri, &element->local, &element->qname, &This->IVBSAXAttributes_iface);
|
2008-07-31 16:48:03 +02:00
|
|
|
else
|
2011-12-24 14:10:33 +01:00
|
|
|
hr = ISAXContentHandler_startElement(This->saxreader->contentHandler,
|
|
|
|
uri, SysStringLen(uri),
|
|
|
|
element->local, SysStringLen(element->local),
|
|
|
|
element->qname, SysStringLen(element->qname),
|
|
|
|
&This->ISAXAttributes_iface);
|
2008-07-30 20:24:12 +02:00
|
|
|
}
|
2008-07-17 00:41:27 +02:00
|
|
|
}
|
2008-08-20 18:20:50 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-08-20 18:20:50 +02:00
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-17 00:41:27 +02:00
|
|
|
}
|
|
|
|
|
2008-07-17 00:41:34 +02:00
|
|
|
static void libxmlEndElementNS(
|
|
|
|
void *ctx,
|
|
|
|
const xmlChar *localname,
|
|
|
|
const xmlChar *prefix,
|
|
|
|
const xmlChar *URI)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2011-12-24 14:10:33 +01:00
|
|
|
element_entry *element;
|
2011-11-28 15:05:25 +01:00
|
|
|
const xmlChar *p;
|
2011-12-24 14:10:33 +01:00
|
|
|
HRESULT hr;
|
|
|
|
BSTR uri;
|
|
|
|
int i;
|
2008-07-17 00:41:34 +02:00
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
update_position(This, FALSE);
|
|
|
|
p = This->pParserCtxt->input->cur;
|
|
|
|
if(This->saxreader->version >= MSXML6)
|
|
|
|
{
|
|
|
|
p--;
|
|
|
|
while(p>This->pParserCtxt->input->base && *p!='>')
|
|
|
|
{
|
|
|
|
if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
|
|
|
|
This->line--;
|
|
|
|
p--;
|
|
|
|
}
|
2011-10-24 20:08:46 +02:00
|
|
|
}
|
2011-11-28 15:05:25 +01:00
|
|
|
else if(*(p-1)!='>' || *(p-2)!='/')
|
|
|
|
{
|
|
|
|
p--;
|
|
|
|
while(p-2>=This->pParserCtxt->input->base
|
|
|
|
&& *(p-2)!='<' && *(p-1)!='/')
|
|
|
|
{
|
|
|
|
if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
|
|
|
|
This->line--;
|
|
|
|
p--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
This->column = 0;
|
|
|
|
for(; p>=This->pParserCtxt->input->base && *p!='\n' && *p!='\r'; p--)
|
|
|
|
This->column++;
|
2008-07-17 00:41:34 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
uri = find_element_uri(This, URI);
|
|
|
|
element = pop_element_ns(This);
|
2008-07-17 00:41:34 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (!has_content_handler(This))
|
|
|
|
{
|
2011-10-31 12:32:39 +01:00
|
|
|
This->nb_attributes = 0;
|
2011-12-24 14:10:33 +01:00
|
|
|
free_element_entry(element);
|
|
|
|
return;
|
|
|
|
}
|
2011-10-31 12:32:39 +01:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_endElement(
|
|
|
|
This->saxreader->vbcontentHandler,
|
|
|
|
&uri, &element->local, &element->qname);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_endElement(
|
|
|
|
This->saxreader->contentHandler,
|
|
|
|
uri, SysStringLen(uri),
|
|
|
|
element->local, SysStringLen(element->local),
|
|
|
|
element->qname, SysStringLen(element->qname));
|
2011-10-26 13:25:27 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
This->nb_attributes = 0;
|
2011-10-31 12:32:59 +01:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (sax_callback_failed(This, hr))
|
|
|
|
{
|
|
|
|
format_error_message_from_id(This, hr);
|
2012-02-05 20:44:44 +01:00
|
|
|
free_element_entry(element);
|
2011-12-24 14:10:33 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-10-31 12:32:59 +01:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
i = -1;
|
|
|
|
while (iterate_endprefix_index(This, element, &i))
|
|
|
|
{
|
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_endPrefixMapping(
|
|
|
|
This->saxreader->vbcontentHandler, &element->ns[i].prefix);
|
2011-10-26 13:25:27 +02:00
|
|
|
else
|
2011-12-24 14:10:33 +01:00
|
|
|
hr = ISAXContentHandler_endPrefixMapping(
|
|
|
|
This->saxreader->contentHandler,
|
|
|
|
element->ns[i].prefix, SysStringLen(element->ns[i].prefix));
|
2011-10-26 13:25:27 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (sax_callback_failed(This, hr)) break;
|
|
|
|
}
|
2011-10-26 13:25:27 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (sax_callback_failed(This, hr))
|
|
|
|
format_error_message_from_id(This, hr);
|
2011-10-31 12:32:59 +01:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
free_element_entry(element);
|
2008-07-17 00:41:34 +02:00
|
|
|
}
|
|
|
|
|
2008-07-17 00:41:40 +02:00
|
|
|
static void libxmlCharacters(
|
|
|
|
void *ctx,
|
|
|
|
const xmlChar *ch,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2008-10-07 22:10:43 +02:00
|
|
|
BSTR Chars;
|
2008-07-17 00:41:40 +02:00
|
|
|
HRESULT hr;
|
2011-11-28 15:05:25 +01:00
|
|
|
xmlChar *cur, *end;
|
2008-10-07 22:10:43 +02:00
|
|
|
BOOL lastEvent = FALSE;
|
2008-07-17 00:41:40 +02:00
|
|
|
|
2010-01-18 21:30:50 +01:00
|
|
|
if(!(has_content_handler(This))) return;
|
2008-07-17 00:41:40 +02:00
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
update_position(This, FALSE);
|
|
|
|
cur = (xmlChar*)This->pParserCtxt->input->cur;
|
|
|
|
while(cur>=This->pParserCtxt->input->base && *cur!='>')
|
|
|
|
{
|
|
|
|
if(*cur=='\n' || (*cur=='\r' && *(cur+1)!='\n'))
|
|
|
|
This->line--;
|
|
|
|
cur--;
|
|
|
|
}
|
|
|
|
This->column = 1;
|
|
|
|
for(; cur>=This->pParserCtxt->input->base && *cur!='\n' && *cur!='\r'; cur--)
|
|
|
|
This->column++;
|
|
|
|
|
2008-10-07 22:10:43 +02:00
|
|
|
cur = (xmlChar*)ch;
|
|
|
|
if(*(ch-1)=='\r') cur--;
|
|
|
|
end = cur;
|
2008-07-23 16:39:12 +02:00
|
|
|
|
2008-10-07 22:10:43 +02:00
|
|
|
while(1)
|
2008-07-17 00:41:40 +02:00
|
|
|
{
|
2008-10-07 22:10:43 +02:00
|
|
|
while(end-ch<len && *end!='\r') end++;
|
|
|
|
if(end-ch==len)
|
2008-07-23 16:39:12 +02:00
|
|
|
{
|
2008-10-07 22:10:43 +02:00
|
|
|
lastEvent = TRUE;
|
|
|
|
}
|
2011-11-28 15:05:25 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*end = '\n';
|
|
|
|
end++;
|
|
|
|
}
|
2008-07-23 16:39:12 +02:00
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
if(This->saxreader->version >= MSXML6)
|
|
|
|
{
|
|
|
|
xmlChar *p;
|
2008-07-23 16:39:12 +02:00
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
for(p=cur; p!=end; p++)
|
|
|
|
{
|
|
|
|
if(*p=='\n')
|
|
|
|
{
|
|
|
|
This->line++;
|
|
|
|
This->column = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->column++;
|
|
|
|
}
|
|
|
|
}
|
2011-10-24 20:08:46 +02:00
|
|
|
|
|
|
|
if(!lastEvent)
|
|
|
|
This->column = 0;
|
|
|
|
}
|
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
Chars = pooled_bstr_from_xmlCharN(&This->saxreader->pool, cur, end-cur);
|
2008-10-07 22:10:43 +02:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_characters(
|
|
|
|
This->saxreader->vbcontentHandler, &Chars);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_characters(
|
|
|
|
This->saxreader->contentHandler,
|
|
|
|
Chars, SysStringLen(Chars));
|
2008-07-31 16:48:03 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-11-13 14:33:27 +01:00
|
|
|
{
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
if(This->saxreader->version < MSXML6)
|
|
|
|
This->column += end-cur;
|
2008-07-23 16:39:12 +02:00
|
|
|
|
2008-10-07 22:10:43 +02:00
|
|
|
if(lastEvent)
|
|
|
|
break;
|
2008-07-23 16:39:12 +02:00
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
*(end-1) = '\r';
|
2008-10-07 22:10:43 +02:00
|
|
|
if(*end == '\n')
|
|
|
|
{
|
|
|
|
end++;
|
|
|
|
This->column++;
|
2008-07-23 16:39:12 +02:00
|
|
|
}
|
2008-10-07 22:10:43 +02:00
|
|
|
cur = end;
|
2008-07-17 00:41:40 +02:00
|
|
|
|
2008-10-07 22:10:43 +02:00
|
|
|
if(end-ch == len) break;
|
2008-07-17 00:41:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-17 00:41:52 +02:00
|
|
|
static void libxmlSetDocumentLocator(
|
|
|
|
void *ctx,
|
|
|
|
xmlSAXLocatorPtr loc)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2010-10-28 23:00:44 +02:00
|
|
|
HRESULT hr = S_OK;
|
2008-07-17 00:41:52 +02:00
|
|
|
|
2010-10-28 23:00:44 +02:00
|
|
|
if(has_content_handler(This))
|
|
|
|
{
|
|
|
|
if(This->vbInterface)
|
2010-12-27 23:12:06 +01:00
|
|
|
hr = IVBSAXContentHandler_putref_documentLocator(This->saxreader->vbcontentHandler,
|
|
|
|
&This->IVBSAXLocator_iface);
|
2010-10-28 23:00:44 +02:00
|
|
|
else
|
2010-12-27 23:12:06 +01:00
|
|
|
hr = ISAXContentHandler_putDocumentLocator(This->saxreader->contentHandler,
|
|
|
|
&This->ISAXLocator_iface);
|
2010-10-28 23:00:44 +02:00
|
|
|
}
|
2008-07-17 00:41:52 +02:00
|
|
|
|
|
|
|
if(FAILED(hr))
|
2008-07-19 22:32:10 +02:00
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
}
|
|
|
|
|
2008-10-07 22:11:04 +02:00
|
|
|
static void libxmlComment(void *ctx, const xmlChar *value)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
BSTR bValue;
|
|
|
|
HRESULT hr;
|
2011-11-28 15:05:25 +01:00
|
|
|
const xmlChar *p = This->pParserCtxt->input->cur;
|
2008-10-07 22:11:04 +02:00
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
update_position(This, FALSE);
|
|
|
|
while(p-4>=This->pParserCtxt->input->base
|
|
|
|
&& memcmp(p-4, "<!--", sizeof(char[4])))
|
|
|
|
{
|
|
|
|
if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
|
|
|
|
This->line--;
|
|
|
|
p--;
|
|
|
|
}
|
|
|
|
This->column = 0;
|
|
|
|
for(; p>=This->pParserCtxt->input->base && *p!='\n' && *p!='\r'; p--)
|
|
|
|
This->column++;
|
2008-10-07 22:11:04 +02:00
|
|
|
|
|
|
|
if(!This->vbInterface && !This->saxreader->lexicalHandler) return;
|
|
|
|
if(This->vbInterface && !This->saxreader->vblexicalHandler) return;
|
|
|
|
|
2011-07-15 14:38:07 +02:00
|
|
|
bValue = pooled_bstr_from_xmlChar(&This->saxreader->pool, value);
|
2008-10-07 22:11:04 +02:00
|
|
|
|
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXLexicalHandler_comment(
|
|
|
|
This->saxreader->vblexicalHandler, &bValue);
|
|
|
|
else
|
|
|
|
hr = ISAXLexicalHandler_comment(
|
|
|
|
This->saxreader->lexicalHandler,
|
|
|
|
bValue, SysStringLen(bValue));
|
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
}
|
|
|
|
|
2008-10-07 22:10:43 +02:00
|
|
|
static void libxmlFatalError(void *ctx, const char *msg, ...)
|
2008-07-19 22:32:10 +02:00
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
char message[1024];
|
2010-10-26 23:25:26 +02:00
|
|
|
WCHAR *error;
|
2008-07-19 22:32:10 +02:00
|
|
|
DWORD len;
|
|
|
|
va_list args;
|
|
|
|
|
2011-10-24 12:55:13 +02:00
|
|
|
if(This->ret != S_OK) {
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
2011-10-24 12:54:47 +02:00
|
|
|
return;
|
2011-10-24 12:55:13 +02:00
|
|
|
}
|
2011-10-24 12:54:47 +02:00
|
|
|
|
2008-07-19 22:32:10 +02:00
|
|
|
va_start(args, msg);
|
|
|
|
vsprintf(message, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
|
2008-08-26 21:06:09 +02:00
|
|
|
len = MultiByteToWideChar(CP_UNIXCP, 0, message, -1, NULL, 0);
|
2010-10-26 23:25:26 +02:00
|
|
|
error = heap_alloc(sizeof(WCHAR)*len);
|
|
|
|
if(error)
|
|
|
|
{
|
|
|
|
MultiByteToWideChar(CP_UNIXCP, 0, message, -1, error, len);
|
|
|
|
TRACE("fatal error for %p: %s\n", This, debugstr_w(error));
|
|
|
|
}
|
2008-07-19 22:32:10 +02:00
|
|
|
|
2010-10-29 00:06:33 +02:00
|
|
|
if(!has_error_handler(This))
|
|
|
|
{
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
|
|
|
This->ret = E_FAIL;
|
|
|
|
heap_free(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Error handling is not compatible.\n");
|
|
|
|
|
2008-07-31 16:48:03 +02:00
|
|
|
if(This->vbInterface)
|
|
|
|
{
|
2010-10-26 23:25:26 +02:00
|
|
|
BSTR bstrError = SysAllocString(error);
|
2010-12-27 23:12:06 +01:00
|
|
|
IVBSAXErrorHandler_fatalError(This->saxreader->vberrorHandler, &This->IVBSAXLocator_iface,
|
|
|
|
&bstrError, E_FAIL);
|
2010-10-26 23:15:38 +02:00
|
|
|
SysFreeString(bstrError);
|
2008-07-31 16:48:03 +02:00
|
|
|
}
|
|
|
|
else
|
2010-12-27 23:12:06 +01:00
|
|
|
ISAXErrorHandler_fatalError(This->saxreader->errorHandler, &This->ISAXLocator_iface,
|
|
|
|
error, E_FAIL);
|
2008-07-19 22:32:10 +02:00
|
|
|
|
2010-10-26 23:25:26 +02:00
|
|
|
heap_free(error);
|
2008-07-19 22:32:10 +02:00
|
|
|
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
|
|
|
This->ret = E_FAIL;
|
2008-07-17 00:41:52 +02:00
|
|
|
}
|
|
|
|
|
2008-10-07 22:11:11 +02:00
|
|
|
static void libxmlCDataBlock(void *ctx, const xmlChar *value, int len)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
xmlChar *beg = (xmlChar*)This->pParserCtxt->input->cur-len;
|
|
|
|
xmlChar *cur, *end;
|
|
|
|
int realLen;
|
|
|
|
BSTR Chars;
|
|
|
|
BOOL lastEvent = FALSE, change;
|
|
|
|
|
2011-11-28 15:05:25 +01:00
|
|
|
update_position(This, FALSE);
|
2010-06-27 15:21:28 +02:00
|
|
|
while(beg-9>=This->pParserCtxt->input->base
|
2011-11-28 15:05:25 +01:00
|
|
|
&& memcmp(beg-9, "<![CDATA[", sizeof(char[9])))
|
|
|
|
{
|
|
|
|
if(*beg=='\n' || (*beg=='\r' && *(beg+1)!='\n'))
|
|
|
|
This->line--;
|
|
|
|
beg--;
|
|
|
|
}
|
|
|
|
This->column = 0;
|
|
|
|
for(; beg>=This->pParserCtxt->input->base && *beg!='\n' && *beg!='\r'; beg--)
|
|
|
|
This->column++;
|
2008-10-07 22:11:11 +02:00
|
|
|
|
|
|
|
if(This->vbInterface && This->saxreader->vblexicalHandler)
|
|
|
|
hr = IVBSAXLexicalHandler_startCDATA(This->saxreader->vblexicalHandler);
|
|
|
|
if(!This->vbInterface && This->saxreader->lexicalHandler)
|
|
|
|
hr = ISAXLexicalHandler_startCDATA(This->saxreader->lexicalHandler);
|
|
|
|
|
|
|
|
if(FAILED(hr))
|
2008-11-13 23:20:52 +01:00
|
|
|
{
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
return;
|
|
|
|
}
|
2008-10-07 22:11:11 +02:00
|
|
|
|
|
|
|
realLen = This->pParserCtxt->input->cur-beg-3;
|
|
|
|
cur = beg;
|
|
|
|
end = beg;
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
while(end-beg<realLen && *end!='\r') end++;
|
|
|
|
if(end-beg==realLen)
|
|
|
|
{
|
|
|
|
end--;
|
|
|
|
lastEvent = TRUE;
|
|
|
|
}
|
|
|
|
else if(end-beg==realLen-1 && *end=='\r' && *(end+1)=='\n')
|
|
|
|
lastEvent = TRUE;
|
|
|
|
|
|
|
|
if(*end == '\r') change = TRUE;
|
|
|
|
else change = FALSE;
|
|
|
|
|
|
|
|
if(change) *end = '\n';
|
|
|
|
|
2010-01-18 21:30:50 +01:00
|
|
|
if(has_content_handler(This))
|
2008-10-07 22:11:11 +02:00
|
|
|
{
|
2011-07-15 14:38:07 +02:00
|
|
|
Chars = pooled_bstr_from_xmlCharN(&This->saxreader->pool, cur, end-cur+1);
|
2008-10-07 22:11:11 +02:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_characters(
|
|
|
|
This->saxreader->vbcontentHandler, &Chars);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_characters(
|
|
|
|
This->saxreader->contentHandler,
|
|
|
|
Chars, SysStringLen(Chars));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(change) *end = '\r';
|
|
|
|
|
|
|
|
if(lastEvent)
|
|
|
|
break;
|
|
|
|
|
|
|
|
This->column += end-cur+2;
|
|
|
|
end += 2;
|
|
|
|
cur = end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->vbInterface && This->saxreader->vblexicalHandler)
|
|
|
|
hr = IVBSAXLexicalHandler_endCDATA(This->saxreader->vblexicalHandler);
|
|
|
|
if(!This->vbInterface && This->saxreader->lexicalHandler)
|
|
|
|
hr = ISAXLexicalHandler_endCDATA(This->saxreader->lexicalHandler);
|
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
|
|
|
|
This->column += 4+end-cur;
|
|
|
|
}
|
|
|
|
|
2008-07-31 16:48:11 +02:00
|
|
|
/*** IVBSAXLocator interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_QueryInterface(IVBSAXLocator* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject);
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IDispatch) ||
|
|
|
|
IsEqualGUID( riid, &IID_IVBSAXLocator ))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2011-10-31 12:32:39 +01:00
|
|
|
else if ( IsEqualGUID( riid, &IID_IVBSAXAttributes ))
|
|
|
|
{
|
|
|
|
*ppvObject = &This->IVBSAXAttributes_iface;
|
|
|
|
}
|
2008-07-31 16:48:11 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IVBSAXLocator_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxlocator_AddRef(IVBSAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxlocator_Release(
|
|
|
|
IVBSAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXLocator_Release((ISAXLocator*)&This->IVBSAXLocator_iface);
|
2008-07-31 16:48:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDispatch methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator *iface, UINT* pctinfo )
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_GetTypeInfo(
|
|
|
|
IVBSAXLocator *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXLocator_tid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_GetIDsOfNames(
|
|
|
|
IVBSAXLocator *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_Invoke(
|
|
|
|
IVBSAXLocator *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &This->IVBSAXLocator_iface, dispIdMember, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-07-31 16:48:11 +02:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXLocator methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_columnNumber(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
int *pnColumn)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXLocator_getColumnNumber((ISAXLocator*)&This->IVBSAXLocator_iface, pnColumn);
|
2008-07-31 16:48:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_lineNumber(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
int *pnLine)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXLocator_getLineNumber((ISAXLocator*)&This->IVBSAXLocator_iface, pnLine);
|
2008-07-31 16:48:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_publicId(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
BSTR* publicId)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXLocator_getPublicId((ISAXLocator*)&This->IVBSAXLocator_iface,
|
2008-07-31 16:48:11 +02:00
|
|
|
(const WCHAR**)publicId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_systemId(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
BSTR* systemId)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return ISAXLocator_getSystemId((ISAXLocator*)&This->IVBSAXLocator_iface,
|
2008-07-31 16:48:11 +02:00
|
|
|
(const WCHAR**)systemId);
|
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
static const struct IVBSAXLocatorVtbl VBSAXLocatorVtbl =
|
2008-07-31 16:48:11 +02:00
|
|
|
{
|
|
|
|
ivbsaxlocator_QueryInterface,
|
|
|
|
ivbsaxlocator_AddRef,
|
|
|
|
ivbsaxlocator_Release,
|
|
|
|
ivbsaxlocator_GetTypeInfoCount,
|
|
|
|
ivbsaxlocator_GetTypeInfo,
|
|
|
|
ivbsaxlocator_GetIDsOfNames,
|
|
|
|
ivbsaxlocator_Invoke,
|
|
|
|
ivbsaxlocator_get_columnNumber,
|
|
|
|
ivbsaxlocator_get_lineNumber,
|
|
|
|
ivbsaxlocator_get_publicId,
|
|
|
|
ivbsaxlocator_get_systemId
|
|
|
|
};
|
|
|
|
|
2008-07-17 00:40:32 +02:00
|
|
|
/*** ISAXLocator interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxlocator_QueryInterface(ISAXLocator* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_ISAXLocator ))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2011-10-31 12:32:39 +01:00
|
|
|
else if ( IsEqualGUID( riid, &IID_ISAXAttributes ))
|
|
|
|
{
|
|
|
|
*ppvObject = &This->ISAXAttributes_iface;
|
|
|
|
}
|
2008-07-17 00:40:32 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ISAXLocator_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxlocator_AddRef(ISAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
2011-12-24 14:10:33 +01:00
|
|
|
ULONG ref = InterlockedIncrement( &This->ref );
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
2008-07-17 00:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxlocator_Release(
|
|
|
|
ISAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
2011-12-24 14:10:33 +01:00
|
|
|
LONG ref = InterlockedDecrement( &This->ref );
|
2008-07-17 00:40:32 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, ref );
|
2008-07-17 00:40:32 +02:00
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
if (ref == 0)
|
2008-07-17 00:40:32 +02:00
|
|
|
{
|
2011-12-24 14:10:33 +01:00
|
|
|
element_entry *element, *element2;
|
2011-10-31 12:32:39 +01:00
|
|
|
int index;
|
|
|
|
|
2008-09-21 15:56:18 +02:00
|
|
|
SysFreeString(This->publicId);
|
|
|
|
SysFreeString(This->systemId);
|
2011-10-31 12:33:18 +01:00
|
|
|
SysFreeString(This->namespaceUri);
|
2008-07-17 00:42:01 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
for(index=0; index<This->nb_attributes; index++)
|
|
|
|
{
|
|
|
|
SysFreeString(This->attributes[index].szLocalname);
|
|
|
|
SysFreeString(This->attributes[index].szValue);
|
|
|
|
SysFreeString(This->attributes[index].szQName);
|
|
|
|
}
|
|
|
|
heap_free(This->attributes);
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
/* element stack */
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(element, element2, &This->elements, element_entry, entry)
|
|
|
|
{
|
|
|
|
list_remove(&element->entry);
|
|
|
|
free_element_entry(element);
|
|
|
|
}
|
|
|
|
|
2010-12-27 23:12:06 +01:00
|
|
|
ISAXXMLReader_Release(&This->saxreader->ISAXXMLReader_iface);
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free( This );
|
2008-07-17 00:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXLocator methods ***/
|
|
|
|
static HRESULT WINAPI isaxlocator_getColumnNumber(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
int *pnColumn)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-07-23 16:39:04 +02:00
|
|
|
*pnColumn = This->column;
|
2008-07-17 00:41:11 +02:00
|
|
|
return S_OK;
|
2008-07-17 00:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getLineNumber(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
int *pnLine)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-07-23 16:39:04 +02:00
|
|
|
*pnLine = This->line;
|
2008-07-17 00:41:11 +02:00
|
|
|
return S_OK;
|
2008-07-17 00:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getPublicId(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
const WCHAR ** ppwchPublicId)
|
|
|
|
{
|
2008-07-17 00:42:01 +02:00
|
|
|
BSTR publicId;
|
2008-07-17 00:40:32 +02:00
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-09-21 15:56:18 +02:00
|
|
|
SysFreeString(This->publicId);
|
2008-07-17 00:42:01 +02:00
|
|
|
|
|
|
|
publicId = bstr_from_xmlChar(xmlSAX2GetPublicId(This->pParserCtxt));
|
|
|
|
if(SysStringLen(publicId))
|
|
|
|
This->publicId = (WCHAR*)&publicId;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SysFreeString(publicId);
|
|
|
|
This->publicId = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppwchPublicId = This->publicId;
|
|
|
|
return S_OK;
|
2008-07-17 00:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getSystemId(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
const WCHAR ** ppwchSystemId)
|
|
|
|
{
|
2008-07-17 00:42:07 +02:00
|
|
|
BSTR systemId;
|
2008-07-17 00:40:32 +02:00
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-09-21 15:56:18 +02:00
|
|
|
SysFreeString(This->systemId);
|
2008-07-17 00:42:07 +02:00
|
|
|
|
|
|
|
systemId = bstr_from_xmlChar(xmlSAX2GetSystemId(This->pParserCtxt));
|
|
|
|
if(SysStringLen(systemId))
|
|
|
|
This->systemId = (WCHAR*)&systemId;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SysFreeString(systemId);
|
|
|
|
This->systemId = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppwchSystemId = This->systemId;
|
|
|
|
return S_OK;
|
2008-07-17 00:40:32 +02:00
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
static const struct ISAXLocatorVtbl SAXLocatorVtbl =
|
2008-07-17 00:40:32 +02:00
|
|
|
{
|
|
|
|
isaxlocator_QueryInterface,
|
|
|
|
isaxlocator_AddRef,
|
|
|
|
isaxlocator_Release,
|
|
|
|
isaxlocator_getColumnNumber,
|
|
|
|
isaxlocator_getLineNumber,
|
|
|
|
isaxlocator_getPublicId,
|
|
|
|
isaxlocator_getSystemId
|
|
|
|
};
|
|
|
|
|
2008-07-31 16:48:03 +02:00
|
|
|
static HRESULT SAXLocator_create(saxreader *reader, saxlocator **ppsaxlocator, BOOL vbInterface)
|
2008-07-17 00:40:32 +02:00
|
|
|
{
|
2011-10-31 12:33:18 +01:00
|
|
|
static const WCHAR w3xmlns[] = { 'h','t','t','p',':','/','/', 'w','w','w','.','w','3','.',
|
|
|
|
'o','r','g','/','2','0','0','0','/','x','m','l','n','s','/',0 };
|
|
|
|
|
2008-07-17 00:40:32 +02:00
|
|
|
saxlocator *locator;
|
|
|
|
|
2010-02-03 20:47:53 +01:00
|
|
|
locator = heap_alloc( sizeof (*locator) );
|
2008-07-17 00:40:32 +02:00
|
|
|
if( !locator )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
locator->IVBSAXLocator_iface.lpVtbl = &VBSAXLocatorVtbl;
|
|
|
|
locator->ISAXLocator_iface.lpVtbl = &SAXLocatorVtbl;
|
2011-10-31 12:32:39 +01:00
|
|
|
locator->IVBSAXAttributes_iface.lpVtbl = &ivbsaxattributes_vtbl;
|
|
|
|
locator->ISAXAttributes_iface.lpVtbl = &isaxattributes_vtbl;
|
2008-07-17 00:40:32 +02:00
|
|
|
locator->ref = 1;
|
2008-07-31 16:48:03 +02:00
|
|
|
locator->vbInterface = vbInterface;
|
2008-07-17 00:40:32 +02:00
|
|
|
|
|
|
|
locator->saxreader = reader;
|
2010-12-27 23:12:06 +01:00
|
|
|
ISAXXMLReader_AddRef(&reader->ISAXXMLReader_iface);
|
2008-07-17 00:40:32 +02:00
|
|
|
|
2008-07-17 00:40:53 +02:00
|
|
|
locator->pParserCtxt = NULL;
|
2008-07-17 00:42:01 +02:00
|
|
|
locator->publicId = NULL;
|
2008-07-17 00:42:07 +02:00
|
|
|
locator->systemId = NULL;
|
2011-10-24 20:08:46 +02:00
|
|
|
locator->line = (reader->version>=MSXML6 ? 1 : 0);
|
2008-07-23 16:39:04 +02:00
|
|
|
locator->column = 0;
|
2008-07-17 00:40:53 +02:00
|
|
|
locator->ret = S_OK;
|
2011-10-31 12:33:18 +01:00
|
|
|
if(locator->saxreader->version >= MSXML6)
|
|
|
|
locator->namespaceUri = SysAllocString(w3xmlns);
|
|
|
|
else
|
|
|
|
locator->namespaceUri = SysAllocStringLen(NULL, 0);
|
|
|
|
if(!locator->namespaceUri)
|
|
|
|
{
|
|
|
|
ISAXXMLReader_Release(&reader->ISAXXMLReader_iface);
|
|
|
|
heap_free(locator);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2008-07-17 00:40:53 +02:00
|
|
|
|
2011-10-31 12:32:39 +01:00
|
|
|
locator->attributesSize = 8;
|
|
|
|
locator->nb_attributes = 0;
|
|
|
|
locator->attributes = heap_alloc(sizeof(struct _attributes)*locator->attributesSize);
|
|
|
|
if(!locator->attributes)
|
|
|
|
{
|
|
|
|
ISAXXMLReader_Release(&reader->ISAXXMLReader_iface);
|
2011-10-31 12:33:18 +01:00
|
|
|
SysFreeString(locator->namespaceUri);
|
2011-10-31 12:32:39 +01:00
|
|
|
heap_free(locator);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
list_init(&locator->elements);
|
|
|
|
|
2008-07-17 00:40:32 +02:00
|
|
|
*ppsaxlocator = locator;
|
|
|
|
|
|
|
|
TRACE("returning %p\n", *ppsaxlocator);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-31 16:48:20 +02:00
|
|
|
/*** SAXXMLReader internal functions ***/
|
|
|
|
static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int size, BOOL vbInterface)
|
|
|
|
{
|
2010-10-30 16:49:43 +02:00
|
|
|
xmlCharEncoding encoding = XML_CHAR_ENCODING_NONE;
|
|
|
|
xmlChar *enc_name = NULL;
|
2008-07-31 16:48:20 +02:00
|
|
|
saxlocator *locator;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = SAXLocator_create(This, &locator, vbInterface);
|
|
|
|
if(FAILED(hr))
|
2008-11-13 14:33:27 +01:00
|
|
|
return hr;
|
2008-07-31 16:48:20 +02:00
|
|
|
|
2010-10-30 16:49:43 +02:00
|
|
|
if (size >= 4)
|
|
|
|
{
|
|
|
|
const unsigned char *buff = (unsigned char*)buffer;
|
|
|
|
|
|
|
|
encoding = xmlDetectCharEncoding((xmlChar*)buffer, 4);
|
|
|
|
enc_name = (xmlChar*)xmlGetCharEncodingName(encoding);
|
|
|
|
TRACE("detected encoding: %s\n", enc_name);
|
|
|
|
/* skip BOM, parser won't switch encodings and so won't skip it on its own */
|
|
|
|
if ((encoding == XML_CHAR_ENCODING_UTF8) &&
|
|
|
|
buff[0] == 0xEF && buff[1] == 0xBB && buff[2] == 0xBF)
|
|
|
|
{
|
|
|
|
buffer += 3;
|
|
|
|
size -= 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-31 16:48:20 +02:00
|
|
|
locator->pParserCtxt = xmlCreateMemoryParserCtxt(buffer, size);
|
|
|
|
if(!locator->pParserCtxt)
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
ISAXLocator_Release(&locator->ISAXLocator_iface);
|
2008-07-31 16:48:20 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-10-30 16:49:43 +02:00
|
|
|
if (encoding == XML_CHAR_ENCODING_UTF8)
|
|
|
|
locator->pParserCtxt->encoding = xmlStrdup(enc_name);
|
|
|
|
|
2010-01-10 16:17:37 +01:00
|
|
|
xmlFree(locator->pParserCtxt->sax);
|
2008-07-31 16:48:20 +02:00
|
|
|
locator->pParserCtxt->sax = &locator->saxreader->sax;
|
|
|
|
locator->pParserCtxt->userData = locator;
|
|
|
|
|
2008-10-01 19:52:36 +02:00
|
|
|
This->isParsing = TRUE;
|
2011-10-24 12:55:13 +02:00
|
|
|
if(xmlParseDocument(locator->pParserCtxt)==-1 && locator->ret==S_OK)
|
|
|
|
hr = E_FAIL;
|
|
|
|
else
|
|
|
|
hr = locator->ret;
|
2008-10-01 19:52:36 +02:00
|
|
|
This->isParsing = FALSE;
|
2008-07-31 16:48:20 +02:00
|
|
|
|
|
|
|
if(locator->pParserCtxt)
|
|
|
|
{
|
|
|
|
locator->pParserCtxt->sax = NULL;
|
|
|
|
xmlFreeParserCtxt(locator->pParserCtxt);
|
|
|
|
locator->pParserCtxt = NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-27 23:12:06 +01:00
|
|
|
ISAXLocator_Release(&locator->ISAXLocator_iface);
|
2008-11-13 14:33:27 +01:00
|
|
|
return hr;
|
2008-07-31 16:48:20 +02:00
|
|
|
}
|
|
|
|
|
2008-09-08 15:07:46 +02:00
|
|
|
static HRESULT internal_parseStream(saxreader *This, IStream *stream, BOOL vbInterface)
|
|
|
|
{
|
|
|
|
saxlocator *locator;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG dataRead;
|
|
|
|
char data[1024];
|
2011-09-21 11:48:17 +02:00
|
|
|
int ret;
|
2008-09-08 15:07:46 +02:00
|
|
|
|
2011-09-21 11:48:17 +02:00
|
|
|
dataRead = 0;
|
2008-09-08 15:07:46 +02:00
|
|
|
hr = IStream_Read(stream, data, sizeof(data), &dataRead);
|
2011-09-21 11:48:17 +02:00
|
|
|
if(FAILED(hr)) return hr;
|
2008-09-08 15:07:46 +02:00
|
|
|
|
|
|
|
hr = SAXLocator_create(This, &locator, vbInterface);
|
2011-09-21 11:48:17 +02:00
|
|
|
if(FAILED(hr)) return hr;
|
2008-09-08 15:07:46 +02:00
|
|
|
|
|
|
|
locator->pParserCtxt = xmlCreatePushParserCtxt(
|
|
|
|
&locator->saxreader->sax, locator,
|
|
|
|
data, dataRead, NULL);
|
|
|
|
if(!locator->pParserCtxt)
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
ISAXLocator_Release(&locator->ISAXLocator_iface);
|
2008-09-08 15:07:46 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2008-10-01 19:52:36 +02:00
|
|
|
This->isParsing = TRUE;
|
2008-09-08 15:07:46 +02:00
|
|
|
|
2011-09-21 11:48:17 +02:00
|
|
|
if(dataRead != sizeof(data))
|
|
|
|
{
|
|
|
|
ret = xmlParseChunk(locator->pParserCtxt, data, 0, 1);
|
2011-10-24 12:55:13 +02:00
|
|
|
hr = ret!=XML_ERR_OK && locator->ret==S_OK ? E_FAIL : locator->ret;
|
2011-09-21 11:48:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
dataRead = 0;
|
|
|
|
hr = IStream_Read(stream, data, sizeof(data), &dataRead);
|
|
|
|
if (FAILED(hr)) break;
|
2008-09-08 15:07:46 +02:00
|
|
|
|
2011-09-21 11:48:17 +02:00
|
|
|
ret = xmlParseChunk(locator->pParserCtxt, data, dataRead, 0);
|
2011-10-24 12:55:13 +02:00
|
|
|
hr = ret!=XML_ERR_OK && locator->ret==S_OK ? E_FAIL : locator->ret;
|
2008-09-08 15:07:46 +02:00
|
|
|
|
2011-09-21 11:48:17 +02:00
|
|
|
if (hr != S_OK) break;
|
2008-09-08 15:07:46 +02:00
|
|
|
|
2011-09-21 11:48:17 +02:00
|
|
|
if (dataRead != sizeof(data))
|
|
|
|
{
|
|
|
|
ret = xmlParseChunk(locator->pParserCtxt, data, 0, 1);
|
2011-10-24 12:55:13 +02:00
|
|
|
hr = ret!=XML_ERR_OK && locator->ret==S_OK ? E_FAIL : locator->ret;
|
2011-09-21 11:48:17 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-09-08 15:07:46 +02:00
|
|
|
}
|
|
|
|
}
|
2011-09-21 11:48:17 +02:00
|
|
|
|
2008-10-01 19:52:36 +02:00
|
|
|
This->isParsing = FALSE;
|
2008-09-08 15:07:46 +02:00
|
|
|
|
|
|
|
xmlFreeParserCtxt(locator->pParserCtxt);
|
|
|
|
locator->pParserCtxt = NULL;
|
2010-12-27 23:12:06 +01:00
|
|
|
ISAXLocator_Release(&locator->ISAXLocator_iface);
|
2008-09-08 15:07:46 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_getEntityResolver(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader *This,
|
|
|
|
void *pEntityResolver,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_putEntityResolver(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader *This,
|
|
|
|
void *pEntityResolver,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_getContentHandler(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader* This,
|
|
|
|
void *pContentHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n", This, pContentHandler);
|
|
|
|
if(pContentHandler == NULL)
|
|
|
|
return E_POINTER;
|
2008-08-20 18:26:25 +02:00
|
|
|
if((vbInterface && This->vbcontentHandler)
|
|
|
|
|| (!vbInterface && This->contentHandler))
|
2008-07-31 16:48:20 +02:00
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXContentHandler_AddRef(This->vbcontentHandler);
|
|
|
|
else
|
|
|
|
ISAXContentHandler_AddRef(This->contentHandler);
|
|
|
|
}
|
|
|
|
if(vbInterface) *(IVBSAXContentHandler**)pContentHandler =
|
|
|
|
This->vbcontentHandler;
|
|
|
|
else *(ISAXContentHandler**)pContentHandler = This->contentHandler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_putContentHandler(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader* This,
|
|
|
|
void *contentHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n", This, contentHandler);
|
|
|
|
if(contentHandler)
|
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXContentHandler_AddRef((IVBSAXContentHandler*)contentHandler);
|
|
|
|
else
|
|
|
|
ISAXContentHandler_AddRef((ISAXContentHandler*)contentHandler);
|
|
|
|
}
|
2008-08-20 18:26:25 +02:00
|
|
|
if((vbInterface && This->vbcontentHandler)
|
|
|
|
|| (!vbInterface && This->contentHandler))
|
2008-07-31 16:48:20 +02:00
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXContentHandler_Release(This->vbcontentHandler);
|
|
|
|
else
|
|
|
|
ISAXContentHandler_Release(This->contentHandler);
|
|
|
|
}
|
|
|
|
if(vbInterface)
|
|
|
|
This->vbcontentHandler = contentHandler;
|
|
|
|
else
|
|
|
|
This->contentHandler = contentHandler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_getDTDHandler(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader* This,
|
|
|
|
void *pDTDHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_putDTDHandler(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader* This,
|
|
|
|
void *pDTDHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_getErrorHandler(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader* This,
|
|
|
|
void *pErrorHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n", This, pErrorHandler);
|
|
|
|
if(pErrorHandler == NULL)
|
|
|
|
return E_POINTER;
|
2008-08-20 18:32:23 +02:00
|
|
|
|
|
|
|
if(vbInterface && This->vberrorHandler)
|
|
|
|
IVBSAXErrorHandler_AddRef(This->vberrorHandler);
|
|
|
|
else if(!vbInterface && This->errorHandler)
|
|
|
|
ISAXErrorHandler_AddRef(This->errorHandler);
|
|
|
|
|
2008-07-31 16:48:20 +02:00
|
|
|
if(vbInterface)
|
|
|
|
*(IVBSAXErrorHandler**)pErrorHandler = This->vberrorHandler;
|
|
|
|
else
|
|
|
|
*(ISAXErrorHandler**)pErrorHandler = This->errorHandler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_putErrorHandler(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader* This,
|
|
|
|
void *errorHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n", This, errorHandler);
|
|
|
|
if(errorHandler)
|
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler*)errorHandler);
|
|
|
|
else
|
|
|
|
ISAXErrorHandler_AddRef((ISAXErrorHandler*)errorHandler);
|
|
|
|
}
|
2008-08-20 18:32:23 +02:00
|
|
|
|
|
|
|
if(vbInterface && This->vberrorHandler)
|
|
|
|
IVBSAXErrorHandler_Release(This->vberrorHandler);
|
|
|
|
else if(!vbInterface && This->errorHandler)
|
|
|
|
ISAXErrorHandler_Release(This->errorHandler);
|
|
|
|
|
2008-07-31 16:48:20 +02:00
|
|
|
if(vbInterface)
|
|
|
|
This->vberrorHandler = errorHandler;
|
|
|
|
else
|
|
|
|
This->errorHandler = errorHandler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_parse(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader* This,
|
|
|
|
VARIANT varInput,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-02-22 00:04:02 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&varInput));
|
2008-07-31 16:48:20 +02:00
|
|
|
|
2011-07-15 14:38:07 +02:00
|
|
|
/* Dispose of the BSTRs in the pool from a prior run, if any. */
|
|
|
|
free_bstr_pool(&This->pool);
|
|
|
|
|
2008-07-31 16:48:20 +02:00
|
|
|
switch(V_VT(&varInput))
|
|
|
|
{
|
|
|
|
case VT_BSTR:
|
|
|
|
hr = internal_parseBuffer(This, (const char*)V_BSTR(&varInput),
|
|
|
|
SysStringByteLen(V_BSTR(&varInput)), vbInterface);
|
|
|
|
break;
|
|
|
|
case VT_ARRAY|VT_UI1: {
|
|
|
|
void *pSAData;
|
|
|
|
LONG lBound, uBound;
|
|
|
|
ULONG dataRead;
|
|
|
|
|
|
|
|
hr = SafeArrayGetLBound(V_ARRAY(&varInput), 1, &lBound);
|
|
|
|
if(hr != S_OK) break;
|
|
|
|
hr = SafeArrayGetUBound(V_ARRAY(&varInput), 1, &uBound);
|
|
|
|
if(hr != S_OK) break;
|
|
|
|
dataRead = (uBound-lBound)*SafeArrayGetElemsize(V_ARRAY(&varInput));
|
2009-01-26 11:01:02 +01:00
|
|
|
hr = SafeArrayAccessData(V_ARRAY(&varInput), &pSAData);
|
2008-07-31 16:48:20 +02:00
|
|
|
if(hr != S_OK) break;
|
|
|
|
hr = internal_parseBuffer(This, pSAData, dataRead, vbInterface);
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(&varInput));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
case VT_DISPATCH: {
|
|
|
|
IPersistStream *persistStream;
|
|
|
|
IStream *stream = NULL;
|
|
|
|
IXMLDOMDocument *xmlDoc;
|
|
|
|
|
2008-09-19 16:01:03 +02:00
|
|
|
if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
|
|
|
|
&IID_IXMLDOMDocument, (void**)&xmlDoc) == S_OK)
|
|
|
|
{
|
|
|
|
BSTR bstrData;
|
|
|
|
|
|
|
|
IXMLDOMDocument_get_xml(xmlDoc, &bstrData);
|
|
|
|
hr = internal_parseBuffer(This, (const char*)bstrData,
|
|
|
|
SysStringByteLen(bstrData), vbInterface);
|
|
|
|
IXMLDOMDocument_Release(xmlDoc);
|
2010-01-10 16:46:30 +01:00
|
|
|
SysFreeString(bstrData);
|
2008-09-19 16:01:03 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-10-27 23:27:06 +02:00
|
|
|
|
2008-07-31 16:48:20 +02:00
|
|
|
if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
|
|
|
|
&IID_IPersistStream, (void**)&persistStream) == S_OK)
|
|
|
|
{
|
2010-10-27 23:27:06 +02:00
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
|
|
|
if(hr != S_OK)
|
|
|
|
{
|
|
|
|
IPersistStream_Release(persistStream);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-07-31 16:48:20 +02:00
|
|
|
hr = IPersistStream_Save(persistStream, stream, TRUE);
|
|
|
|
IPersistStream_Release(persistStream);
|
2010-10-27 23:27:06 +02:00
|
|
|
if(hr != S_OK)
|
|
|
|
{
|
|
|
|
IStream_Release(stream);
|
2012-01-23 08:31:55 +01:00
|
|
|
stream = NULL;
|
2010-10-27 23:27:06 +02:00
|
|
|
}
|
2008-07-31 16:48:20 +02:00
|
|
|
}
|
2012-01-23 08:31:55 +01:00
|
|
|
|
2008-07-31 16:48:20 +02:00
|
|
|
if(stream || IUnknown_QueryInterface(V_UNKNOWN(&varInput),
|
|
|
|
&IID_IStream, (void**)&stream) == S_OK)
|
|
|
|
{
|
2008-09-08 15:07:46 +02:00
|
|
|
hr = internal_parseStream(This, stream, vbInterface);
|
2008-07-31 16:48:20 +02:00
|
|
|
IStream_Release(stream);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
WARN("vt %d not implemented\n", V_VT(&varInput));
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT internal_vbonDataAvailable(void *obj, char *ptr, DWORD len)
|
|
|
|
{
|
|
|
|
saxreader *This = obj;
|
|
|
|
|
|
|
|
return internal_parseBuffer(This, ptr, len, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT internal_onDataAvailable(void *obj, char *ptr, DWORD len)
|
|
|
|
{
|
|
|
|
saxreader *This = obj;
|
|
|
|
|
|
|
|
return internal_parseBuffer(This, ptr, len, FALSE);
|
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_parseURL(
|
2008-07-31 16:48:20 +02:00
|
|
|
saxreader* This,
|
|
|
|
const WCHAR *url,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
2012-03-12 10:56:59 +01:00
|
|
|
IMoniker *mon;
|
2008-07-31 16:48:20 +02:00
|
|
|
bsc_t *bsc;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(url));
|
|
|
|
|
2012-03-12 10:56:59 +01:00
|
|
|
hr = create_moniker_from_url(url, &mon);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if(vbInterface) hr = bind_url(mon, internal_vbonDataAvailable, This, &bsc);
|
|
|
|
else hr = bind_url(mon, internal_onDataAvailable, This, &bsc);
|
|
|
|
IMoniker_Release(mon);
|
2008-07-31 16:48:20 +02:00
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-10-24 12:55:00 +02:00
|
|
|
return detach_bsc(bsc);
|
2008-07-31 16:48:20 +02:00
|
|
|
}
|
|
|
|
|
2008-11-24 17:23:59 +01:00
|
|
|
static HRESULT internal_putProperty(
|
2008-10-01 19:52:36 +02:00
|
|
|
saxreader* This,
|
2011-09-21 19:01:10 +02:00
|
|
|
const WCHAR *prop,
|
2008-10-01 19:52:36 +02:00
|
|
|
VARIANT value,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
2011-09-21 19:01:10 +02:00
|
|
|
TRACE("(%p)->(%s %s)\n", This, debugstr_w(prop), debugstr_variant(&value));
|
|
|
|
|
|
|
|
if(!memcmp(prop, PropertyDeclHandlerW, sizeof(PropertyDeclHandlerW)))
|
2008-10-01 19:52:36 +02:00
|
|
|
{
|
|
|
|
if(This->isParsing) return E_FAIL;
|
|
|
|
|
2011-09-22 08:50:41 +02:00
|
|
|
switch (V_VT(&value))
|
2008-10-01 19:52:36 +02:00
|
|
|
{
|
2011-09-22 08:50:41 +02:00
|
|
|
case VT_EMPTY:
|
|
|
|
if (vbInterface)
|
|
|
|
{
|
|
|
|
if (This->vbdeclHandler)
|
|
|
|
{
|
|
|
|
IVBSAXDeclHandler_Release(This->vbdeclHandler);
|
|
|
|
This->vbdeclHandler = NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-10-01 19:52:36 +02:00
|
|
|
else
|
2011-09-22 08:50:41 +02:00
|
|
|
if (This->declHandler)
|
|
|
|
{
|
|
|
|
ISAXDeclHandler_Release(This->declHandler);
|
|
|
|
This->declHandler = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
if (V_UNKNOWN(&value)) IUnknown_AddRef(V_UNKNOWN(&value));
|
|
|
|
|
|
|
|
if ((vbInterface && This->vbdeclHandler) ||
|
|
|
|
(!vbInterface && This->declHandler))
|
|
|
|
{
|
|
|
|
if (vbInterface)
|
|
|
|
IVBSAXDeclHandler_Release(This->vbdeclHandler);
|
|
|
|
else
|
|
|
|
ISAXDeclHandler_Release(This->declHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vbInterface)
|
|
|
|
This->vbdeclHandler = (IVBSAXDeclHandler*)V_UNKNOWN(&value);
|
2008-10-01 19:52:36 +02:00
|
|
|
else
|
2011-09-22 08:50:41 +02:00
|
|
|
This->declHandler = (ISAXDeclHandler*)V_UNKNOWN(&value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return E_INVALIDARG;
|
2008-10-01 19:52:36 +02:00
|
|
|
}
|
2011-09-22 08:50:41 +02:00
|
|
|
|
2008-10-01 19:52:36 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
if(!memcmp(prop, PropertyLexicalHandlerW, sizeof(PropertyLexicalHandlerW)))
|
2008-10-01 19:52:36 +02:00
|
|
|
{
|
|
|
|
if(This->isParsing) return E_FAIL;
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
switch (V_VT(&value))
|
2008-10-01 19:52:36 +02:00
|
|
|
{
|
2011-09-21 19:01:10 +02:00
|
|
|
case VT_EMPTY:
|
|
|
|
if (vbInterface)
|
|
|
|
{
|
|
|
|
if (This->vblexicalHandler)
|
|
|
|
{
|
|
|
|
IVBSAXLexicalHandler_Release(This->vblexicalHandler);
|
|
|
|
This->vblexicalHandler = NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-10-01 19:52:36 +02:00
|
|
|
else
|
2011-09-21 19:01:10 +02:00
|
|
|
if (This->lexicalHandler)
|
|
|
|
{
|
|
|
|
ISAXLexicalHandler_Release(This->lexicalHandler);
|
|
|
|
This->lexicalHandler = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
if (V_UNKNOWN(&value)) IUnknown_AddRef(V_UNKNOWN(&value));
|
|
|
|
|
|
|
|
if ((vbInterface && This->vblexicalHandler) ||
|
|
|
|
(!vbInterface && This->lexicalHandler))
|
|
|
|
{
|
|
|
|
if (vbInterface)
|
|
|
|
IVBSAXLexicalHandler_Release(This->vblexicalHandler);
|
|
|
|
else
|
|
|
|
ISAXLexicalHandler_Release(This->lexicalHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vbInterface)
|
|
|
|
This->vblexicalHandler = (IVBSAXLexicalHandler*)V_UNKNOWN(&value);
|
2008-10-01 19:52:36 +02:00
|
|
|
else
|
2011-09-21 19:01:10 +02:00
|
|
|
This->lexicalHandler = (ISAXLexicalHandler*)V_UNKNOWN(&value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return E_INVALIDARG;
|
2008-10-01 19:52:36 +02:00
|
|
|
}
|
2011-09-21 19:01:10 +02:00
|
|
|
|
2008-10-01 19:52:36 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-05 18:19:43 +02:00
|
|
|
if(!memcmp(prop, PropertyMaxXMLSizeW, sizeof(PropertyMaxXMLSizeW)))
|
|
|
|
{
|
|
|
|
if (V_VT(&value) == VT_I4 && V_I4(&value) == 0) return S_OK;
|
|
|
|
FIXME("(%p)->(%s): max-xml-size unsupported\n", This, debugstr_variant(&value));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-10-05 18:23:56 +02:00
|
|
|
if(!memcmp(prop, PropertyMaxElementDepthW, sizeof(PropertyMaxElementDepthW)))
|
|
|
|
{
|
|
|
|
if (V_VT(&value) == VT_I4 && V_I4(&value) == 0) return S_OK;
|
|
|
|
FIXME("(%p)->(%s): max-element-depth unsupported\n", This, debugstr_variant(&value));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-10-05 18:19:43 +02:00
|
|
|
FIXME("(%p)->(%s:%s): unsupported property\n", This, debugstr_w(prop), debugstr_variant(&value));
|
2010-08-29 23:33:28 +02:00
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
if(!memcmp(prop, PropertyCharsetW, sizeof(PropertyCharsetW)))
|
2010-08-29 23:33:28 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
if(!memcmp(prop, PropertyDomNodeW, sizeof(PropertyDomNodeW)))
|
2010-08-29 23:33:28 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
if(!memcmp(prop, PropertyInputSourceW, sizeof(PropertyInputSourceW)))
|
2010-08-29 23:33:28 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
if(!memcmp(prop, PropertySchemaDeclHandlerW, sizeof(PropertySchemaDeclHandlerW)))
|
2008-10-01 19:52:36 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
if(!memcmp(prop, PropertyXMLDeclEncodingW, sizeof(PropertyXMLDeclEncodingW)))
|
2008-10-01 19:52:36 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
if(!memcmp(prop, PropertyXMLDeclStandaloneW, sizeof(PropertyXMLDeclStandaloneW)))
|
2008-10-01 19:52:36 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
if(!memcmp(prop, PropertyXMLDeclVersionW, sizeof(PropertyXMLDeclVersionW)))
|
2008-10-01 19:52:36 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2011-09-21 19:01:10 +02:00
|
|
|
static HRESULT internal_getProperty(const saxreader* This, const WCHAR *prop, VARIANT *value, BOOL vb)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(prop));
|
|
|
|
|
|
|
|
if (!value) return E_POINTER;
|
|
|
|
|
|
|
|
if (!memcmp(PropertyLexicalHandlerW, prop, sizeof(PropertyLexicalHandlerW)))
|
|
|
|
{
|
|
|
|
V_VT(value) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(value) = vb ? (IUnknown*)This->vblexicalHandler : (IUnknown*)This->lexicalHandler;
|
|
|
|
if (V_UNKNOWN(value)) IUnknown_AddRef(V_UNKNOWN(value));
|
2011-09-22 08:50:41 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!memcmp(PropertyDeclHandlerW, prop, sizeof(PropertyDeclHandlerW)))
|
|
|
|
{
|
|
|
|
V_VT(value) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(value) = vb ? (IUnknown*)This->vbdeclHandler : (IUnknown*)This->declHandler;
|
|
|
|
if (V_UNKNOWN(value)) IUnknown_AddRef(V_UNKNOWN(value));
|
2011-09-21 19:01:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s) unsupported property\n", This, debugstr_w(prop));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-07-08 20:52:04 +02:00
|
|
|
/*** IVBSAXXMLReader interface ***/
|
2008-03-25 04:19:10 +01:00
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_QueryInterface(IVBSAXXMLReader* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IDispatch ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IVBSAXXMLReader ))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2008-07-08 20:52:04 +02:00
|
|
|
else if( IsEqualGUID( riid, &IID_ISAXXMLReader ))
|
|
|
|
{
|
2010-12-27 23:12:06 +01:00
|
|
|
*ppvObject = &This->ISAXXMLReader_iface;
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
2011-11-21 10:23:25 +01:00
|
|
|
else if (dispex_query_interface(&This->dispex, riid, ppvObject))
|
|
|
|
{
|
|
|
|
return *ppvObject ? S_OK : E_NOINTERFACE;
|
|
|
|
}
|
2008-03-25 04:19:10 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IVBSAXXMLReader_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI saxxmlreader_AddRef(IVBSAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI saxxmlreader_Release(
|
|
|
|
IVBSAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
ref = InterlockedDecrement( &This->ref );
|
|
|
|
if ( ref == 0 )
|
|
|
|
{
|
2008-07-08 21:00:20 +02:00
|
|
|
if(This->contentHandler)
|
|
|
|
ISAXContentHandler_Release(This->contentHandler);
|
|
|
|
|
2008-08-20 18:32:23 +02:00
|
|
|
if(This->vbcontentHandler)
|
|
|
|
IVBSAXContentHandler_Release(This->vbcontentHandler);
|
|
|
|
|
2008-07-08 20:52:41 +02:00
|
|
|
if(This->errorHandler)
|
|
|
|
ISAXErrorHandler_Release(This->errorHandler);
|
|
|
|
|
2008-08-20 18:32:23 +02:00
|
|
|
if(This->vberrorHandler)
|
|
|
|
IVBSAXErrorHandler_Release(This->vberrorHandler);
|
|
|
|
|
2008-10-01 19:52:36 +02:00
|
|
|
if(This->lexicalHandler)
|
|
|
|
ISAXLexicalHandler_Release(This->lexicalHandler);
|
|
|
|
|
|
|
|
if(This->vblexicalHandler)
|
|
|
|
IVBSAXLexicalHandler_Release(This->vblexicalHandler);
|
|
|
|
|
|
|
|
if(This->declHandler)
|
|
|
|
ISAXDeclHandler_Release(This->declHandler);
|
|
|
|
|
|
|
|
if(This->vbdeclHandler)
|
|
|
|
IVBSAXDeclHandler_Release(This->vbdeclHandler);
|
|
|
|
|
2011-07-15 14:38:07 +02:00
|
|
|
free_bstr_pool(&This->pool);
|
|
|
|
|
2011-11-21 10:23:25 +01:00
|
|
|
release_dispex(&This->dispex);
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free( This );
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
/*** IDispatch ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader *iface, UINT* pctinfo )
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2011-11-21 10:23:25 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_GetTypeInfo(
|
|
|
|
IVBSAXXMLReader *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2011-11-21 10:23:25 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
|
|
|
|
iTInfo, lcid, ppTInfo);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_GetIDsOfNames(
|
|
|
|
IVBSAXXMLReader *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2011-11-21 10:23:25 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
|
|
|
|
riid, rgszNames, cNames, lcid, rgDispId);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_Invoke(
|
|
|
|
IVBSAXXMLReader *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2011-11-21 10:23:25 +01:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
|
|
|
|
dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXXMLReader methods ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_getFeature(
|
|
|
|
IVBSAXXMLReader* iface,
|
2011-10-05 20:29:37 +02:00
|
|
|
const WCHAR *feature,
|
|
|
|
VARIANT_BOOL *value)
|
2008-03-25 04:19:10 +01:00
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
2011-10-05 20:29:37 +02:00
|
|
|
if (!strcmpW(FeatureNamespacesW, feature))
|
|
|
|
return get_feature_value(This, Namespaces, value);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(feature), value);
|
2008-03-25 04:19:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putFeature(
|
|
|
|
IVBSAXXMLReader* iface,
|
2011-10-04 23:27:39 +02:00
|
|
|
const WCHAR *feature,
|
|
|
|
VARIANT_BOOL value)
|
2008-03-25 04:19:10 +01:00
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
2011-10-04 23:27:39 +02:00
|
|
|
TRACE("(%p)->(%s %x)\n", This, debugstr_w(feature), value);
|
|
|
|
|
|
|
|
if (!strcmpW(FeatureExternalGeneralEntitiesW, feature) && value == VARIANT_FALSE)
|
|
|
|
return set_feature_value(This, ExternalGeneralEntities, value);
|
|
|
|
|
2011-10-05 16:20:32 +02:00
|
|
|
if (!strcmpW(FeatureExternalParameterEntitiesW, feature) && value == VARIANT_FALSE)
|
|
|
|
return set_feature_value(This, ExternalParameterEntities, value);
|
|
|
|
|
2011-10-05 16:37:40 +02:00
|
|
|
if (!strcmpW(FeatureLexicalHandlerParEntitiesW, feature))
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(feature), value);
|
|
|
|
return set_feature_value(This, LexicalHandlerParEntities, value);
|
|
|
|
}
|
|
|
|
|
2011-10-05 18:09:28 +02:00
|
|
|
if (!strcmpW(FeatureProhibitDTDW, feature))
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(feature), value);
|
|
|
|
return set_feature_value(This, ProhibitDTD, value);
|
|
|
|
}
|
|
|
|
|
2011-10-05 20:29:37 +02:00
|
|
|
if (!strcmpW(FeatureNamespacesW, feature) && value == VARIANT_TRUE)
|
|
|
|
return set_feature_value(This, Namespaces, value);
|
|
|
|
|
2011-10-04 23:27:39 +02:00
|
|
|
FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(feature), value);
|
2008-03-25 04:19:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getProperty(
|
|
|
|
IVBSAXXMLReader* iface,
|
2011-09-21 19:01:10 +02:00
|
|
|
const WCHAR *prop,
|
|
|
|
VARIANT *value)
|
2008-03-25 04:19:10 +01:00
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2011-09-21 19:01:10 +02:00
|
|
|
return internal_getProperty(This, prop, value, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putProperty(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *pProp,
|
|
|
|
VARIANT value)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-10-01 19:52:36 +02:00
|
|
|
return internal_putProperty(This, pProp, value, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_entityResolver(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXEntityResolver **pEntityResolver)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_getEntityResolver(This, pEntityResolver, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_entityResolver(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXEntityResolver *pEntityResolver)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_putEntityResolver(This, pEntityResolver, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_contentHandler(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXContentHandler **ppContentHandler)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_getContentHandler(This, ppContentHandler, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_contentHandler(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXContentHandler *contentHandler)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_putContentHandler(This, contentHandler, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_dtdHandler(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXDTDHandler **pDTDHandler)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_getDTDHandler(This, pDTDHandler, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_dtdHandler(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXDTDHandler *pDTDHandler)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_putDTDHandler(This, pDTDHandler, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_errorHandler(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXErrorHandler **pErrorHandler)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_getErrorHandler(This, pErrorHandler, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_errorHandler(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXErrorHandler *errorHandler)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_putErrorHandler(This, errorHandler, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_baseURL(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR **pBaseUrl)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
|
2008-03-25 04:19:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_baseURL(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *pBaseUrl)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
|
2008-03-25 04:19:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_secureBaseURL(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR **pSecureBaseUrl)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
|
2008-03-25 04:19:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-09 11:26:51 +02:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_secureBaseURL(
|
2008-03-25 04:19:10 +01:00
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *secureBaseUrl)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
|
2008-03-25 04:19:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_parse(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
VARIANT varInput)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_parse(This, varInput, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_parseURL(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *url)
|
|
|
|
{
|
2008-04-01 01:45:13 +02:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_parseURL(This, url, TRUE);
|
2008-03-25 04:19:10 +01:00
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
static const struct IVBSAXXMLReaderVtbl VBSAXXMLReaderVtbl =
|
2008-03-25 04:19:10 +01:00
|
|
|
{
|
|
|
|
saxxmlreader_QueryInterface,
|
|
|
|
saxxmlreader_AddRef,
|
|
|
|
saxxmlreader_Release,
|
|
|
|
saxxmlreader_GetTypeInfoCount,
|
|
|
|
saxxmlreader_GetTypeInfo,
|
|
|
|
saxxmlreader_GetIDsOfNames,
|
|
|
|
saxxmlreader_Invoke,
|
|
|
|
saxxmlreader_getFeature,
|
|
|
|
saxxmlreader_putFeature,
|
|
|
|
saxxmlreader_getProperty,
|
|
|
|
saxxmlreader_putProperty,
|
2008-09-09 11:26:51 +02:00
|
|
|
saxxmlreader_get_entityResolver,
|
|
|
|
saxxmlreader_put_entityResolver,
|
|
|
|
saxxmlreader_get_contentHandler,
|
|
|
|
saxxmlreader_put_contentHandler,
|
|
|
|
saxxmlreader_get_dtdHandler,
|
|
|
|
saxxmlreader_put_dtdHandler,
|
|
|
|
saxxmlreader_get_errorHandler,
|
|
|
|
saxxmlreader_put_errorHandler,
|
|
|
|
saxxmlreader_get_baseURL,
|
|
|
|
saxxmlreader_put_baseURL,
|
|
|
|
saxxmlreader_get_secureBaseURL,
|
|
|
|
saxxmlreader_put_secureBaseURL,
|
2008-03-25 04:19:10 +01:00
|
|
|
saxxmlreader_parse,
|
|
|
|
saxxmlreader_parseURL
|
|
|
|
};
|
|
|
|
|
2008-07-08 20:52:04 +02:00
|
|
|
/*** ISAXXMLReader interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxxmlreader_QueryInterface(ISAXXMLReader* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return saxxmlreader_QueryInterface(&This->IVBSAXXMLReader_iface, riid, ppvObject);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxxmlreader_AddRef(ISAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return saxxmlreader_AddRef(&This->IVBSAXXMLReader_iface);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxxmlreader_Release(ISAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return saxxmlreader_Release(&This->IVBSAXXMLReader_iface);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXXMLReader methods ***/
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getFeature(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pFeature,
|
|
|
|
VARIANT_BOOL *pValue)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return IVBSAXXMLReader_getFeature(&This->IVBSAXXMLReader_iface, pFeature, pValue);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putFeature(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pFeature,
|
|
|
|
VARIANT_BOOL vfValue)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return IVBSAXXMLReader_putFeature(&This->IVBSAXXMLReader_iface, pFeature, vfValue);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getProperty(
|
|
|
|
ISAXXMLReader* iface,
|
2011-09-21 19:01:10 +02:00
|
|
|
const WCHAR *prop,
|
|
|
|
VARIANT *value)
|
2008-07-08 20:52:04 +02:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2011-09-21 19:01:10 +02:00
|
|
|
return internal_getProperty(This, prop, value, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putProperty(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pProp,
|
|
|
|
VARIANT value)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-10-01 19:52:36 +02:00
|
|
|
return internal_putProperty(This, pProp, value, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getEntityResolver(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXEntityResolver **ppEntityResolver)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_getEntityResolver(This, ppEntityResolver, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putEntityResolver(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXEntityResolver *pEntityResolver)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_putEntityResolver(This, pEntityResolver, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getContentHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXContentHandler **pContentHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_getContentHandler(This, pContentHandler, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putContentHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXContentHandler *contentHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_putContentHandler(This, contentHandler, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getDTDHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXDTDHandler **pDTDHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_getDTDHandler(This, pDTDHandler, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putDTDHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXDTDHandler *pDTDHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_putDTDHandler(This, pDTDHandler, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getErrorHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXErrorHandler **pErrorHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_getErrorHandler(This, pErrorHandler, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putErrorHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXErrorHandler *errorHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_putErrorHandler(This, errorHandler, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR **pBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return IVBSAXXMLReader_get_baseURL(&This->IVBSAXXMLReader_iface, pBaseUrl);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return IVBSAXXMLReader_put_baseURL(&This->IVBSAXXMLReader_iface, pBaseUrl);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getSecureBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR **pSecureBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return IVBSAXXMLReader_get_secureBaseURL(&This->IVBSAXXMLReader_iface, pSecureBaseUrl);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *secureBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2010-12-27 23:12:06 +01:00
|
|
|
return IVBSAXXMLReader_put_secureBaseURL(&This->IVBSAXXMLReader_iface, secureBaseUrl);
|
2008-07-27 19:54:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_parse(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
VARIANT varInput)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_parse(This, varInput, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_parseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *url)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 16:48:20 +02:00
|
|
|
return internal_parseURL(This, url, FALSE);
|
2008-07-08 20:52:04 +02:00
|
|
|
}
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
static const struct ISAXXMLReaderVtbl SAXXMLReaderVtbl =
|
2008-07-08 20:52:04 +02:00
|
|
|
{
|
|
|
|
isaxxmlreader_QueryInterface,
|
|
|
|
isaxxmlreader_AddRef,
|
|
|
|
isaxxmlreader_Release,
|
|
|
|
isaxxmlreader_getFeature,
|
|
|
|
isaxxmlreader_putFeature,
|
|
|
|
isaxxmlreader_getProperty,
|
|
|
|
isaxxmlreader_putProperty,
|
|
|
|
isaxxmlreader_getEntityResolver,
|
|
|
|
isaxxmlreader_putEntityResolver,
|
|
|
|
isaxxmlreader_getContentHandler,
|
|
|
|
isaxxmlreader_putContentHandler,
|
|
|
|
isaxxmlreader_getDTDHandler,
|
|
|
|
isaxxmlreader_putDTDHandler,
|
|
|
|
isaxxmlreader_getErrorHandler,
|
|
|
|
isaxxmlreader_putErrorHandler,
|
|
|
|
isaxxmlreader_getBaseURL,
|
|
|
|
isaxxmlreader_putBaseURL,
|
|
|
|
isaxxmlreader_getSecureBaseURL,
|
|
|
|
isaxxmlreader_putSecureBaseURL,
|
|
|
|
isaxxmlreader_parse,
|
|
|
|
isaxxmlreader_parseURL
|
|
|
|
};
|
|
|
|
|
2011-11-21 10:23:25 +01:00
|
|
|
static const tid_t saxreader_iface_tids[] = {
|
|
|
|
IVBSAXXMLReader_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t saxreader_dispex = {
|
|
|
|
NULL,
|
|
|
|
IVBSAXXMLReader_tid,
|
|
|
|
NULL,
|
|
|
|
saxreader_iface_tids
|
|
|
|
};
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
HRESULT SAXXMLReader_create(MSXML_VERSION version, IUnknown *outer, LPVOID *ppObj)
|
2008-03-25 04:19:10 +01:00
|
|
|
{
|
|
|
|
saxreader *reader;
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
TRACE("(%p, %p)\n", outer, ppObj);
|
2008-03-25 04:19:10 +01:00
|
|
|
|
2010-02-03 20:47:53 +01:00
|
|
|
reader = heap_alloc( sizeof (*reader) );
|
2008-03-25 04:19:10 +01:00
|
|
|
if( !reader )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-12-24 14:10:33 +01:00
|
|
|
reader->IVBSAXXMLReader_iface.lpVtbl = &VBSAXXMLReaderVtbl;
|
|
|
|
reader->ISAXXMLReader_iface.lpVtbl = &SAXXMLReaderVtbl;
|
2008-03-25 04:19:10 +01:00
|
|
|
reader->ref = 1;
|
2008-07-08 21:00:20 +02:00
|
|
|
reader->contentHandler = NULL;
|
2008-08-20 18:32:23 +02:00
|
|
|
reader->vbcontentHandler = NULL;
|
2008-07-08 20:52:41 +02:00
|
|
|
reader->errorHandler = NULL;
|
2008-08-20 18:32:23 +02:00
|
|
|
reader->vberrorHandler = NULL;
|
2008-10-01 19:52:36 +02:00
|
|
|
reader->lexicalHandler = NULL;
|
|
|
|
reader->vblexicalHandler = NULL;
|
|
|
|
reader->declHandler = NULL;
|
|
|
|
reader->vbdeclHandler = NULL;
|
|
|
|
reader->isParsing = FALSE;
|
2011-07-15 14:38:07 +02:00
|
|
|
reader->pool.pool = NULL;
|
|
|
|
reader->pool.index = 0;
|
|
|
|
reader->pool.len = 0;
|
2011-10-05 20:29:37 +02:00
|
|
|
reader->features = Namespaces;
|
2011-10-24 20:08:46 +02:00
|
|
|
reader->version = version;
|
2008-03-25 04:19:10 +01:00
|
|
|
|
2011-11-21 10:23:25 +01:00
|
|
|
init_dispex(&reader->dispex, (IUnknown*)&reader->IVBSAXXMLReader_iface, &saxreader_dispex);
|
|
|
|
|
2008-07-17 00:40:53 +02:00
|
|
|
memset(&reader->sax, 0, sizeof(xmlSAXHandler));
|
|
|
|
reader->sax.initialized = XML_SAX2_MAGIC;
|
2008-07-17 00:41:01 +02:00
|
|
|
reader->sax.startDocument = libxmlStartDocument;
|
2008-07-17 00:41:19 +02:00
|
|
|
reader->sax.endDocument = libxmlEndDocument;
|
2008-07-17 00:41:27 +02:00
|
|
|
reader->sax.startElementNs = libxmlStartElementNS;
|
2008-07-17 00:41:34 +02:00
|
|
|
reader->sax.endElementNs = libxmlEndElementNS;
|
2008-07-17 00:41:40 +02:00
|
|
|
reader->sax.characters = libxmlCharacters;
|
2008-07-17 00:41:52 +02:00
|
|
|
reader->sax.setDocumentLocator = libxmlSetDocumentLocator;
|
2008-10-07 22:11:04 +02:00
|
|
|
reader->sax.comment = libxmlComment;
|
2008-07-19 22:32:10 +02:00
|
|
|
reader->sax.error = libxmlFatalError;
|
|
|
|
reader->sax.fatalError = libxmlFatalError;
|
2008-10-07 22:11:11 +02:00
|
|
|
reader->sax.cdataBlock = libxmlCDataBlock;
|
2008-07-17 00:40:53 +02:00
|
|
|
|
2010-12-27 23:12:06 +01:00
|
|
|
*ppObj = &reader->IVBSAXXMLReader_iface;
|
2008-03-26 04:40:01 +01:00
|
|
|
|
2008-03-25 04:19:10 +01:00
|
|
|
TRACE("returning iface %p\n", *ppObj);
|
2008-03-26 04:40:01 +01:00
|
|
|
|
2008-03-25 04:19:10 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2011-10-24 20:08:46 +02:00
|
|
|
HRESULT SAXXMLReader_create(MSXML_VERSION version, IUnknown *pUnkOuter, LPVOID *ppObj)
|
2008-03-25 04:19:10 +01:00
|
|
|
{
|
|
|
|
MESSAGE("This program tried to use a SAX XML Reader object, but\n"
|
|
|
|
"libxml2 support was not present at compile time.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|