2008-03-25 03:19:10 +00:00
|
|
|
/*
|
|
|
|
* SAX Reader implementation
|
|
|
|
*
|
|
|
|
* Copyright 2008 Alistair Leslie-Hughes
|
2008-07-16 22:40:32 +00:00
|
|
|
* Copyright 2008 Piotr Caban
|
2008-03-25 03:19:10 +00: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 <stdarg.h>
|
2021-10-20 09:39:06 +00:00
|
|
|
#include <libxml/parser.h>
|
|
|
|
#include <libxml/xmlerror.h>
|
|
|
|
#include <libxml/SAX2.h>
|
|
|
|
#include <libxml/parserInternals.h>
|
2011-02-24 12:11:53 +00:00
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "ole2.h"
|
2010-08-29 21:31:49 +00:00
|
|
|
#include "msxml6.h"
|
2008-03-25 03:19:10 +00:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "urlmon.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
2015-02-21 13:58:41 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
2011-12-16 11:33:32 +00:00
|
|
|
typedef enum
|
2011-10-04 21:27:39 +00:00
|
|
|
{
|
2012-04-18 18:39:38 +00:00
|
|
|
FeatureUnknown = 0,
|
2011-10-04 21:27:39 +00:00
|
|
|
ExhaustiveErrors = 1 << 1,
|
|
|
|
ExternalGeneralEntities = 1 << 2,
|
|
|
|
ExternalParameterEntities = 1 << 3,
|
|
|
|
ForcedResync = 1 << 4,
|
|
|
|
NamespacePrefixes = 1 << 5,
|
2011-10-05 18:29:37 +00:00
|
|
|
Namespaces = 1 << 6,
|
2011-10-04 21:27:39 +00: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 14:37:40 +00:00
|
|
|
UseSchemaLocation = 1 << 14,
|
|
|
|
LexicalHandlerParEntities = 1 << 15
|
2012-04-18 18:39:38 +00:00
|
|
|
} saxreader_feature;
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WCHAR FeatureProhibitDTDW[] = {
|
|
|
|
'p','r','o','h','i','b','i','t','-','d','t','d',0
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WCHAR FeatureNamespacePrefixesW[] = {
|
|
|
|
'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','-','p','r','e','f','i','x','e','s',0
|
|
|
|
};
|
|
|
|
|
2018-02-26 22:16:38 +00:00
|
|
|
static const WCHAR ExhaustiveErrorsW[] = {
|
|
|
|
'e','x','h','a','u','s','t','i','v','e','-','e','r','r','o','r','s',0
|
|
|
|
};
|
|
|
|
|
2018-02-26 22:16:40 +00:00
|
|
|
static const WCHAR SchemaValidationW[] = {
|
|
|
|
's','c','h','e','m','a','-','v','a','l','i','d','a','t','i','o','n',0
|
|
|
|
};
|
|
|
|
|
2012-04-18 18:39:38 +00:00
|
|
|
struct saxreader_feature_pair
|
|
|
|
{
|
|
|
|
saxreader_feature feature;
|
|
|
|
const WCHAR *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct saxreader_feature_pair saxreader_feature_map[] = {
|
2018-02-26 22:16:38 +00:00
|
|
|
{ ExhaustiveErrors, ExhaustiveErrorsW },
|
2012-04-18 18:39:38 +00:00
|
|
|
{ ExternalGeneralEntities, FeatureExternalGeneralEntitiesW },
|
|
|
|
{ ExternalParameterEntities, FeatureExternalParameterEntitiesW },
|
|
|
|
{ LexicalHandlerParEntities, FeatureLexicalHandlerParEntitiesW },
|
|
|
|
{ NamespacePrefixes, FeatureNamespacePrefixesW },
|
|
|
|
{ Namespaces, FeatureNamespacesW },
|
2018-02-26 22:16:40 +00:00
|
|
|
{ ProhibitDTD, FeatureProhibitDTDW },
|
|
|
|
{ SchemaValidation, SchemaValidationW },
|
2012-04-18 18:39:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static saxreader_feature get_saxreader_feature(const WCHAR *name)
|
|
|
|
{
|
|
|
|
int min, max, n, c;
|
|
|
|
|
|
|
|
min = 0;
|
2018-02-26 22:16:41 +00:00
|
|
|
max = ARRAY_SIZE(saxreader_feature_map) - 1;
|
2012-04-18 18:39:38 +00:00
|
|
|
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
n = (min+max)/2;
|
|
|
|
|
2021-10-20 09:39:06 +00:00
|
|
|
c = wcscmp(saxreader_feature_map[n].name, name);
|
2012-04-18 18:39:38 +00:00
|
|
|
if (!c)
|
|
|
|
return saxreader_feature_map[n].feature;
|
|
|
|
|
|
|
|
if (c > 0)
|
|
|
|
max = n-1;
|
|
|
|
else
|
|
|
|
min = n+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FeatureUnknown;
|
|
|
|
}
|
2011-10-04 21:27:39 +00:00
|
|
|
|
2019-09-24 17:04:55 +00:00
|
|
|
static const WCHAR empty_str;
|
|
|
|
|
2011-07-15 12:38:07 +00:00
|
|
|
struct bstrpool
|
|
|
|
{
|
|
|
|
BSTR *pool;
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int len;
|
|
|
|
};
|
|
|
|
|
2011-12-24 13:10:33 +00: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;
|
|
|
|
|
2012-07-14 20:36:54 +00:00
|
|
|
enum saxhandler_type
|
|
|
|
{
|
|
|
|
SAXContentHandler = 0,
|
|
|
|
SAXDeclHandler,
|
|
|
|
SAXDTDHandler,
|
2012-11-16 21:46:36 +00:00
|
|
|
SAXEntityResolver,
|
2012-07-14 20:36:54 +00:00
|
|
|
SAXErrorHandler,
|
|
|
|
SAXLexicalHandler,
|
|
|
|
SAXHandler_Last
|
|
|
|
};
|
|
|
|
|
2012-11-16 03:34:58 +00:00
|
|
|
struct saxanyhandler_iface
|
2012-07-14 20:36:54 +00:00
|
|
|
{
|
|
|
|
IUnknown *handler;
|
|
|
|
IUnknown *vbhandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct saxcontenthandler_iface
|
|
|
|
{
|
|
|
|
ISAXContentHandler *handler;
|
|
|
|
IVBSAXContentHandler *vbhandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct saxerrorhandler_iface
|
|
|
|
{
|
|
|
|
ISAXErrorHandler *handler;
|
|
|
|
IVBSAXErrorHandler *vbhandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct saxlexicalhandler_iface
|
|
|
|
{
|
|
|
|
ISAXLexicalHandler *handler;
|
|
|
|
IVBSAXLexicalHandler *vbhandler;
|
|
|
|
};
|
|
|
|
|
2012-11-16 21:46:36 +00:00
|
|
|
struct saxentityresolver_iface
|
|
|
|
{
|
|
|
|
ISAXEntityResolver *handler;
|
|
|
|
IVBSAXEntityResolver *vbhandler;
|
|
|
|
};
|
|
|
|
|
2012-11-16 03:34:58 +00:00
|
|
|
struct saxhandler_iface
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
struct saxcontenthandler_iface content;
|
2012-11-16 21:46:36 +00:00
|
|
|
struct saxentityresolver_iface entityresolver;
|
2012-11-16 03:34:58 +00:00
|
|
|
struct saxerrorhandler_iface error;
|
|
|
|
struct saxlexicalhandler_iface lexical;
|
|
|
|
struct saxanyhandler_iface anyhandler;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2011-12-16 11:33:32 +00:00
|
|
|
typedef struct
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2011-11-21 09:23:25 +00:00
|
|
|
DispatchEx dispex;
|
2010-12-27 22:12:06 +00:00
|
|
|
IVBSAXXMLReader IVBSAXXMLReader_iface;
|
|
|
|
ISAXXMLReader ISAXXMLReader_iface;
|
2008-03-25 03:19:10 +00:00
|
|
|
LONG ref;
|
2012-07-14 20:36:54 +00:00
|
|
|
|
|
|
|
struct saxhandler_iface saxhandlers[SAXHandler_Last];
|
2008-03-25 03:19:10 +00:00
|
|
|
xmlSAXHandler sax;
|
2008-10-01 17:52:36 +00:00
|
|
|
BOOL isParsing;
|
2011-07-15 12:38:07 +00:00
|
|
|
struct bstrpool pool;
|
2012-04-18 18:39:38 +00:00
|
|
|
saxreader_feature features;
|
2012-08-27 05:39:43 +00:00
|
|
|
BSTR xmldecl_version;
|
2011-10-24 18:08:46 +00:00
|
|
|
MSXML_VERSION version;
|
2008-03-25 03:19:10 +00:00
|
|
|
} saxreader;
|
|
|
|
|
2012-07-14 20:36:54 +00:00
|
|
|
static HRESULT saxreader_put_handler(saxreader *reader, enum saxhandler_type type, void *ptr, BOOL vb)
|
|
|
|
{
|
2012-11-16 03:34:58 +00:00
|
|
|
struct saxanyhandler_iface *iface = &reader->saxhandlers[type].u.anyhandler;
|
2012-07-14 20:36:54 +00:00
|
|
|
IUnknown *unk = (IUnknown*)ptr;
|
|
|
|
|
|
|
|
if (unk)
|
|
|
|
IUnknown_AddRef(unk);
|
|
|
|
|
|
|
|
if ((vb && iface->vbhandler) || (!vb && iface->handler))
|
|
|
|
IUnknown_Release(vb ? iface->vbhandler : iface->handler);
|
|
|
|
|
|
|
|
if (vb)
|
|
|
|
iface->vbhandler = unk;
|
|
|
|
else
|
|
|
|
iface->handler = unk;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT saxreader_get_handler(const saxreader *reader, enum saxhandler_type type, BOOL vb, void **ret)
|
|
|
|
{
|
2012-11-16 03:34:58 +00:00
|
|
|
const struct saxanyhandler_iface *iface = &reader->saxhandlers[type].u.anyhandler;
|
2012-07-14 20:36:54 +00:00
|
|
|
|
|
|
|
if (!ret) return E_POINTER;
|
|
|
|
|
|
|
|
if ((vb && iface->vbhandler) || (!vb && iface->handler))
|
|
|
|
{
|
|
|
|
if (vb)
|
|
|
|
IUnknown_AddRef(iface->vbhandler);
|
|
|
|
else
|
|
|
|
IUnknown_AddRef(iface->handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = vb ? iface->vbhandler : iface->handler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct saxcontenthandler_iface *saxreader_get_contenthandler(saxreader *reader)
|
|
|
|
{
|
2012-11-16 03:34:58 +00:00
|
|
|
return &reader->saxhandlers[SAXContentHandler].u.content;
|
2012-07-14 20:36:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct saxerrorhandler_iface *saxreader_get_errorhandler(saxreader *reader)
|
|
|
|
{
|
2012-11-16 03:34:58 +00:00
|
|
|
return &reader->saxhandlers[SAXErrorHandler].u.error;
|
2012-07-14 20:36:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct saxlexicalhandler_iface *saxreader_get_lexicalhandler(saxreader *reader)
|
|
|
|
{
|
2012-11-16 03:34:58 +00:00
|
|
|
return &reader->saxhandlers[SAXLexicalHandler].u.lexical;
|
2012-07-14 20:36:54 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 11:33:32 +00:00
|
|
|
typedef struct
|
2008-07-16 22:40:32 +00:00
|
|
|
{
|
2010-12-27 22:12:06 +00:00
|
|
|
IVBSAXLocator IVBSAXLocator_iface;
|
|
|
|
ISAXLocator ISAXLocator_iface;
|
2011-10-31 11:32:39 +00:00
|
|
|
IVBSAXAttributes IVBSAXAttributes_iface;
|
|
|
|
ISAXAttributes ISAXAttributes_iface;
|
2008-07-16 22:40:32 +00:00
|
|
|
LONG ref;
|
|
|
|
saxreader *saxreader;
|
2008-07-16 22:40:53 +00:00
|
|
|
HRESULT ret;
|
|
|
|
xmlParserCtxtPtr pParserCtxt;
|
2012-11-28 17:45:12 +00:00
|
|
|
BSTR publicId;
|
|
|
|
BSTR systemId;
|
2008-07-23 14:39:04 +00:00
|
|
|
int line;
|
|
|
|
int column;
|
2008-07-31 14:48:03 +00:00
|
|
|
BOOL vbInterface;
|
2011-12-24 13:10:33 +00:00
|
|
|
struct list elements;
|
2008-07-16 22:40:32 +00:00
|
|
|
|
2011-10-31 11:33:18 +00:00
|
|
|
BSTR namespaceUri;
|
2014-07-31 19:07:10 +00:00
|
|
|
int attr_alloc_count;
|
|
|
|
int attr_count;
|
2012-06-17 12:37:45 +00:00
|
|
|
struct _attributes
|
|
|
|
{
|
|
|
|
BSTR szLocalname;
|
|
|
|
BSTR szURI;
|
|
|
|
BSTR szValue;
|
|
|
|
BSTR szQName;
|
|
|
|
} *attributes;
|
2011-10-31 11:32:39 +00:00
|
|
|
} saxlocator;
|
2008-07-27 17:55:05 +00:00
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
static inline saxreader *impl_from_IVBSAXXMLReader( IVBSAXXMLReader *iface )
|
|
|
|
{
|
2010-12-27 22:12:06 +00:00
|
|
|
return CONTAINING_RECORD(iface, saxreader, IVBSAXXMLReader_iface);
|
2008-03-31 19:42:18 +00:00
|
|
|
}
|
2008-03-25 03:19:10 +00:00
|
|
|
|
2008-07-08 18:52:04 +00:00
|
|
|
static inline saxreader *impl_from_ISAXXMLReader( ISAXXMLReader *iface )
|
|
|
|
{
|
2010-12-27 22:12:06 +00:00
|
|
|
return CONTAINING_RECORD(iface, saxreader, ISAXXMLReader_iface);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
2008-07-31 14:47:26 +00:00
|
|
|
static inline saxlocator *impl_from_IVBSAXLocator( IVBSAXLocator *iface )
|
|
|
|
{
|
2010-12-27 22:12:06 +00:00
|
|
|
return CONTAINING_RECORD(iface, saxlocator, IVBSAXLocator_iface);
|
2008-07-31 14:47:26 +00:00
|
|
|
}
|
|
|
|
|
2008-07-16 22:40:32 +00:00
|
|
|
static inline saxlocator *impl_from_ISAXLocator( ISAXLocator *iface )
|
|
|
|
{
|
2010-12-27 22:12:06 +00:00
|
|
|
return CONTAINING_RECORD(iface, saxlocator, ISAXLocator_iface);
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
2011-10-31 11:32:39 +00:00
|
|
|
static inline saxlocator *impl_from_IVBSAXAttributes( IVBSAXAttributes *iface )
|
2008-07-31 14:47:26 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
return CONTAINING_RECORD(iface, saxlocator, IVBSAXAttributes_iface);
|
2008-07-31 14:47:26 +00:00
|
|
|
}
|
|
|
|
|
2011-10-31 11:32:39 +00:00
|
|
|
static inline saxlocator *impl_from_ISAXAttributes( ISAXAttributes *iface )
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
return CONTAINING_RECORD(iface, saxlocator, ISAXAttributes_iface);
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2013-09-30 22:06:49 +00:00
|
|
|
static inline BOOL saxreader_has_handler(const saxlocator *locator, enum saxhandler_type type)
|
2012-07-17 05:58:36 +00:00
|
|
|
{
|
2012-11-16 03:34:58 +00:00
|
|
|
struct saxanyhandler_iface *iface = &locator->saxreader->saxhandlers[type].u.anyhandler;
|
|
|
|
return (locator->vbInterface && iface->vbhandler) || (!locator->vbInterface && iface->handler);
|
2012-07-17 05:58:36 +00:00
|
|
|
}
|
|
|
|
|
2013-03-14 04:27:57 +00:00
|
|
|
static HRESULT saxreader_saxcharacters(saxlocator *locator, BSTR chars)
|
|
|
|
{
|
|
|
|
struct saxcontenthandler_iface *content = saxreader_get_contenthandler(locator->saxreader);
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!saxreader_has_handler(locator, SAXContentHandler)) return S_OK;
|
|
|
|
|
|
|
|
if (locator->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_characters(content->vbhandler, &chars);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_characters(content->handler, chars, SysStringLen(chars));
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
/* property names */
|
|
|
|
static const WCHAR PropertyCharsetW[] = {
|
|
|
|
'c','h','a','r','s','e','t',0
|
|
|
|
};
|
2012-08-27 05:39:43 +00:00
|
|
|
static const WCHAR PropertyXmlDeclVersionW[] = {
|
|
|
|
'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
|
|
|
|
};
|
2011-09-21 17:01:10 +00:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2012-04-18 18:39:38 +00:00
|
|
|
static inline HRESULT set_feature_value(saxreader *reader, saxreader_feature feature, VARIANT_BOOL value)
|
2011-10-04 21:27:39 +00:00
|
|
|
{
|
2012-04-19 06:53:15 +00:00
|
|
|
/* handling of non-VARIANT_* values is version dependent */
|
|
|
|
if ((reader->version < MSXML4) && (value != VARIANT_TRUE))
|
|
|
|
value = VARIANT_FALSE;
|
|
|
|
if ((reader->version >= MSXML4) && (value != VARIANT_FALSE))
|
|
|
|
value = VARIANT_TRUE;
|
|
|
|
|
2011-10-04 21:27:39 +00:00
|
|
|
if (value == VARIANT_TRUE)
|
|
|
|
reader->features |= feature;
|
|
|
|
else
|
|
|
|
reader->features &= ~feature;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-18 18:39:38 +00:00
|
|
|
static inline HRESULT get_feature_value(const saxreader *reader, saxreader_feature feature, VARIANT_BOOL *value)
|
2011-10-05 18:29:37 +00:00
|
|
|
{
|
|
|
|
*value = reader->features & feature ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-19 06:46:03 +00:00
|
|
|
static BOOL is_namespaces_enabled(const saxreader *reader)
|
|
|
|
{
|
|
|
|
return (reader->version < MSXML4) || (reader->features & Namespaces);
|
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
static BSTR build_qname(BSTR prefix, BSTR local)
|
2008-08-20 16:20:50 +00:00
|
|
|
{
|
2011-12-24 13:10:33 +00:00
|
|
|
if (prefix && *prefix)
|
2008-08-20 16:20:50 +00:00
|
|
|
{
|
2011-12-24 13:10:33 +00:00
|
|
|
BSTR qname = SysAllocStringLen(NULL, SysStringLen(prefix) + SysStringLen(local) + 1);
|
|
|
|
WCHAR *ptr;
|
2008-08-20 16:20:50 +00:00
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
ptr = qname;
|
2021-10-20 09:39:06 +00:00
|
|
|
lstrcpyW(ptr, prefix);
|
2011-12-24 13:10:33 +00:00
|
|
|
ptr += SysStringLen(prefix);
|
|
|
|
*ptr++ = ':';
|
2021-10-20 09:39:06 +00:00
|
|
|
lstrcpyW(ptr, local);
|
2011-12-24 13:10:33 +00:00
|
|
|
return qname;
|
2008-08-20 16:20:50 +00:00
|
|
|
}
|
2011-12-24 13:10:33 +00: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 11:32:59 +00:00
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
ret = malloc(sizeof(*ret));
|
2011-12-24 13:10:33 +00:00
|
|
|
if (!ret) return ret;
|
|
|
|
|
|
|
|
ret->local = bstr_from_xmlChar(local);
|
|
|
|
ret->prefix = bstr_from_xmlChar(prefix);
|
|
|
|
ret->qname = build_qname(ret->prefix, ret->local);
|
2022-11-21 01:44:24 +00:00
|
|
|
ret->ns = nb_ns ? malloc(nb_ns * sizeof(ns)) : NULL;
|
2011-12-24 13:10:33 +00:00
|
|
|
ret->ns_count = nb_ns;
|
|
|
|
|
|
|
|
for (i=0; i < nb_ns; i++)
|
2011-10-31 11:32:59 +00:00
|
|
|
{
|
2011-12-24 13:10:33 +00: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 11:32:59 +00:00
|
|
|
}
|
2011-12-24 13:10:33 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_element_entry(element_entry *element)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<element->ns_count;i++)
|
2011-10-31 11:32:59 +00:00
|
|
|
{
|
2011-12-24 13:10:33 +00:00
|
|
|
SysFreeString(element->ns[i].prefix);
|
|
|
|
SysFreeString(element->ns[i].uri);
|
2011-10-31 11:32:59 +00:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
SysFreeString(element->prefix);
|
|
|
|
SysFreeString(element->local);
|
2014-02-12 10:14:49 +00:00
|
|
|
SysFreeString(element->qname);
|
2008-08-20 16:20:50 +00:00
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
free(element->ns);
|
|
|
|
free(element);
|
2008-08-20 16:20:50 +00:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
static void push_element_ns(saxlocator *locator, element_entry *element)
|
2008-08-20 16:20:50 +00:00
|
|
|
{
|
2011-12-24 13:10:33 +00:00
|
|
|
list_add_head(&locator->elements, &element->entry);
|
|
|
|
}
|
2011-10-31 11:32:59 +00:00
|
|
|
|
2011-12-24 13:10:33 +00: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 16:20:50 +00:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
static BSTR find_element_uri(saxlocator *locator, const xmlChar *uri)
|
2011-10-31 11:33:08 +00:00
|
|
|
{
|
2011-12-24 13:10:33 +00:00
|
|
|
element_entry *element;
|
|
|
|
BSTR uriW;
|
2011-10-31 11:33:08 +00:00
|
|
|
int i;
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
if (!uri) return NULL;
|
|
|
|
|
|
|
|
uriW = bstr_from_xmlChar(uri);
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(element, &locator->elements, element_entry, entry)
|
2011-10-31 11:33:08 +00:00
|
|
|
{
|
2011-12-24 13:10:33 +00:00
|
|
|
for (i=0; i < element->ns_count; i++)
|
2021-10-20 09:39:06 +00:00
|
|
|
if (!wcscmp(uriW, element->ns[i].uri))
|
2011-12-24 13:10:33 +00:00
|
|
|
{
|
|
|
|
SysFreeString(uriW);
|
|
|
|
return element->ns[i].uri;
|
|
|
|
}
|
2011-10-31 11:33:08 +00:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
SysFreeString(uriW);
|
|
|
|
ERR("namespace uri not found, %s\n", debugstr_a((char*)uri));
|
2011-10-31 11:33:08 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
/* used to localize version dependent error check behaviour */
|
|
|
|
static inline BOOL sax_callback_failed(saxlocator *This, HRESULT hr)
|
|
|
|
{
|
2012-04-15 09:47:30 +00:00
|
|
|
return This->saxreader->version >= MSXML4 ? FAILED(hr) : hr != S_OK;
|
2011-12-24 13:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2012-04-15 22:29:18 +00:00
|
|
|
if (This->saxreader->version >= MSXML4)
|
2011-12-24 13:10:33 +00:00
|
|
|
{
|
|
|
|
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 12:38:07 +00:00
|
|
|
static BOOL bstr_pool_insert(struct bstrpool *pool, BSTR pool_entry)
|
|
|
|
{
|
|
|
|
if (!pool->pool)
|
|
|
|
{
|
2022-11-21 01:44:24 +00:00
|
|
|
pool->pool = malloc(16 * sizeof(*pool->pool));
|
2011-07-15 12:38:07 +00:00
|
|
|
if (!pool->pool)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pool->index = 0;
|
|
|
|
pool->len = 16;
|
|
|
|
}
|
|
|
|
else if (pool->index == pool->len)
|
|
|
|
{
|
2022-11-21 01:44:24 +00:00
|
|
|
BSTR *new_pool = realloc(pool->pool, pool->len * 2 * sizeof(*new_pool));
|
2011-07-15 12:38:07 +00:00
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
if (!new_pool)
|
2011-07-15 12:38:07 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
pool->pool = new_pool;
|
2011-07-15 12:38:07 +00:00
|
|
|
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]);
|
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
free(pool->pool);
|
2011-07-15 12:38:07 +00:00
|
|
|
|
|
|
|
pool->pool = NULL;
|
|
|
|
pool->index = pool->len = 0;
|
|
|
|
}
|
|
|
|
|
2008-08-03 12:37:37 +00:00
|
|
|
static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len)
|
2008-07-30 18:24:12 +00: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 12:06:53 +00:00
|
|
|
bstr = SysAllocStringLen(NULL, dLen-1);
|
|
|
|
if (!bstr)
|
2008-07-30 18:24:12 +00:00
|
|
|
return NULL;
|
2010-07-17 12:06:53 +00:00
|
|
|
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, bstr, dLen);
|
|
|
|
if(len != -1) bstr[dLen-1] = '\0';
|
2008-07-30 18:24:12 +00:00
|
|
|
|
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
2008-08-03 12:37:37 +00:00
|
|
|
static BSTR QName_from_xmlChar(const xmlChar *prefix, const xmlChar *name)
|
|
|
|
{
|
2010-10-28 21:14:08 +00:00
|
|
|
xmlChar *qname;
|
2008-08-03 12:37:37 +00:00
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
if(!name) return NULL;
|
|
|
|
|
2010-10-28 21:14:08 +00:00
|
|
|
if(!prefix || !*prefix)
|
2008-08-03 12:37:37 +00:00
|
|
|
return bstr_from_xmlChar(name);
|
|
|
|
|
2010-10-28 21:14:08 +00:00
|
|
|
qname = xmlBuildQName(name, prefix, NULL, 0);
|
|
|
|
bstr = bstr_from_xmlChar(qname);
|
|
|
|
xmlFree(qname);
|
2008-08-03 12:37:37 +00:00
|
|
|
|
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
2011-07-15 12:38:07 +00: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 20:32:10 +00:00
|
|
|
static void format_error_message_from_id(saxlocator *This, HRESULT hr)
|
|
|
|
{
|
2012-07-14 20:36:54 +00:00
|
|
|
struct saxerrorhandler_iface *handler = saxreader_get_errorhandler(This->saxreader);
|
2008-07-19 20:32:10 +00:00
|
|
|
xmlStopParser(This->pParserCtxt);
|
|
|
|
This->ret = hr;
|
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
if (saxreader_has_handler(This, SAXErrorHandler))
|
2008-07-19 20:32:10 +00:00
|
|
|
{
|
|
|
|
WCHAR msg[1024];
|
|
|
|
if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
|
2018-02-26 22:16:41 +00:00
|
|
|
NULL, hr, 0, msg, ARRAY_SIZE(msg), NULL))
|
2008-07-19 20:32:10 +00:00
|
|
|
{
|
|
|
|
FIXME("MSXML errors not yet supported.\n");
|
|
|
|
msg[0] = '\0';
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
{
|
|
|
|
BSTR bstrMsg = SysAllocString(msg);
|
2012-07-14 20:36:54 +00:00
|
|
|
IVBSAXErrorHandler_fatalError(handler->vbhandler,
|
2010-12-27 22:12:06 +00:00
|
|
|
&This->IVBSAXLocator_iface, &bstrMsg, hr);
|
2010-10-26 21:15:38 +00:00
|
|
|
SysFreeString(bstrMsg);
|
2008-07-31 14:48:03 +00:00
|
|
|
}
|
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
ISAXErrorHandler_fatalError(handler->handler,
|
2010-12-27 22:12:06 +00:00
|
|
|
&This->ISAXLocator_iface, msg, hr);
|
2008-07-19 20:32:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-28 14:05:25 +00:00
|
|
|
static void update_position(saxlocator *This, BOOL fix_column)
|
2008-07-23 14:39:04 +00:00
|
|
|
{
|
2011-11-28 14:05:25 +00:00
|
|
|
const xmlChar *p = This->pParserCtxt->input->cur-1;
|
2015-09-01 12:25:51 +00:00
|
|
|
const xmlChar *baseP = This->pParserCtxt->input->base;
|
2008-10-07 20:10:43 +00:00
|
|
|
|
2011-11-28 14:05:25 +00:00
|
|
|
This->line = xmlSAX2GetLineNumber(This->pParserCtxt);
|
|
|
|
if(fix_column)
|
2008-10-07 20:10:43 +00:00
|
|
|
{
|
2011-11-28 14:05:25 +00:00
|
|
|
This->column = 1;
|
2015-09-01 12:25:51 +00:00
|
|
|
for(;p>=baseP && *p!='\n' && *p!='\r'; p--)
|
2011-11-28 14:05:25 +00:00
|
|
|
This->column++;
|
2008-07-31 14:45:30 +00:00
|
|
|
}
|
2011-11-28 14:05:25 +00:00
|
|
|
else
|
2008-07-23 14:39:04 +00:00
|
|
|
{
|
2011-11-28 14:05:25 +00:00
|
|
|
This->column = xmlSAX2GetColumnNumber(This->pParserCtxt);
|
2008-07-23 14:39:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:47:41 +00:00
|
|
|
/*** IVBSAXAttributes interface ***/
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_QueryInterface(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes(iface);
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
|
2011-10-31 11:32:39 +00:00
|
|
|
return IVBSAXLocator_QueryInterface(&This->IVBSAXLocator_iface, riid, ppvObject);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxattributes_AddRef(IVBSAXAttributes* iface)
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes(iface);
|
2014-03-05 06:40:53 +00:00
|
|
|
return IVBSAXLocator_AddRef(&This->IVBSAXLocator_iface);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxattributes_Release(IVBSAXAttributes* iface)
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes(iface);
|
2014-03-05 06:40:53 +00:00
|
|
|
return IVBSAXLocator_Release(&This->IVBSAXLocator_iface);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes *iface, UINT* pctinfo )
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetTypeInfo(
|
|
|
|
IVBSAXAttributes *iface,
|
2012-11-29 12:32:38 +00:00
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2022-02-03 10:48:04 +00:00
|
|
|
TRACE("%p, %u, %lx, %p.\n", iface, iTInfo, lcid, ppTInfo);
|
2012-11-29 12:32:38 +00:00
|
|
|
|
2014-03-05 06:40:53 +00:00
|
|
|
return get_typeinfo(IVBSAXAttributes_tid, ppTInfo);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetIDsOfNames(
|
|
|
|
IVBSAXAttributes *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
2012-06-17 12:37:45 +00:00
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-03 10:48:04 +00:00
|
|
|
TRACE("%p, %s, %p, %u, %lx %p.\n", iface, debugstr_guid(riid), rgszNames, cNames,
|
2012-06-17 12:37:45 +00:00
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
2012-11-29 12:32:38 +00:00
|
|
|
{
|
2012-06-17 12:37:45 +00:00
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
2012-11-29 12:32:38 +00:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
2012-06-17 12:37:45 +00:00
|
|
|
|
|
|
|
return hr;
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_Invoke(
|
|
|
|
IVBSAXAttributes *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
2012-06-17 12:37:45 +00:00
|
|
|
WORD wFlags,
|
2008-07-31 14:47:41 +00:00
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
2012-06-17 12:37:45 +00:00
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-03 10:48:04 +00:00
|
|
|
TRACE("%p, %ld, %s, %lx, %d, %p, %p, %p, %p.\n", iface, dispIdMember, debugstr_guid(riid),
|
2012-06-17 12:37:45 +00:00
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
2012-11-29 12:32:38 +00:00
|
|
|
{
|
2022-02-03 10:48:04 +00:00
|
|
|
hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2012-11-29 12:32:38 +00:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
2012-06-17 12:37:45 +00:00
|
|
|
|
|
|
|
return hr;
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXAttributes methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_get_length(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int *nLength)
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2010-12-27 22:12:06 +00:00
|
|
|
return ISAXAttributes_getLength(&This->ISAXAttributes_iface, nLength);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getURI(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *uri)
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *uriW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, nIndex, uri);
|
|
|
|
|
|
|
|
if (!uri)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*uri = NULL;
|
|
|
|
hr = ISAXAttributes_getURI(&This->ISAXAttributes_iface, nIndex, &uriW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(uriW, len, uri);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getLocalName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
2014-03-05 06:40:53 +00:00
|
|
|
BSTR *name)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *nameW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, nIndex, name);
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*name = NULL;
|
|
|
|
hr = ISAXAttributes_getLocalName(&This->ISAXAttributes_iface, nIndex, &nameW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(nameW, len, name);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *QName)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *nameW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, nIndex, QName);
|
|
|
|
|
|
|
|
if (!QName)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*QName = NULL;
|
|
|
|
hr = ISAXAttributes_getQName(&This->ISAXAttributes_iface, nIndex, &nameW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(nameW, len, QName);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getIndexFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
int *index)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
return ISAXAttributes_getIndexFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
|
|
|
|
localName, SysStringLen(localName), index);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getIndexFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
int *index)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
return ISAXAttributes_getIndexFromQName(&This->ISAXAttributes_iface, QName,
|
|
|
|
SysStringLen(QName), index);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getType(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *type)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *typeW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, nIndex, type);
|
|
|
|
|
|
|
|
if (!type)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*type = NULL;
|
|
|
|
hr = ISAXAttributes_getType(&This->ISAXAttributes_iface, nIndex, &typeW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(typeW, len, type);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getTypeFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
BSTR *type)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *typeW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(uri), debugstr_w(localName), type);
|
|
|
|
|
|
|
|
if (!type)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*type = NULL;
|
|
|
|
hr = ISAXAttributes_getTypeFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
|
|
|
|
localName, SysStringLen(localName), &typeW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(typeW, len, type);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getTypeFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
BSTR *type)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *typeW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(QName), type);
|
|
|
|
|
|
|
|
if (!type)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*type = NULL;
|
|
|
|
hr = ISAXAttributes_getTypeFromQName(&This->ISAXAttributes_iface, QName, SysStringLen(QName),
|
|
|
|
&typeW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(typeW, len, type);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValue(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *value)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *valueW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, nIndex, value);
|
|
|
|
|
|
|
|
if (!value)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*value = NULL;
|
|
|
|
hr = ISAXAttributes_getValue(&This->ISAXAttributes_iface, nIndex, &valueW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(valueW, len, value);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValueFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
BSTR *value)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *valueW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(uri), debugstr_w(localName), value);
|
|
|
|
|
|
|
|
if (!value)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*value = NULL;
|
|
|
|
hr = ISAXAttributes_getValueFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
|
|
|
|
localName, SysStringLen(localName), &valueW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(valueW, len, value);
|
2008-07-31 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValueFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
BSTR *value)
|
2008-07-31 14:47:41 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_IVBSAXAttributes( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
const WCHAR *valueW;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(QName), value);
|
|
|
|
|
|
|
|
if (!value)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*value = NULL;
|
|
|
|
hr = ISAXAttributes_getValueFromQName(&This->ISAXAttributes_iface, QName,
|
|
|
|
SysStringLen(QName), &valueW, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstrn(valueW, len, value);
|
2008-07-31 14:47:41 +00: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 17:55:05 +00:00
|
|
|
/*** ISAXAttributes interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxattributes_QueryInterface(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes(iface);
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
|
2011-10-31 11:32:39 +00:00
|
|
|
return ISAXLocator_QueryInterface(&This->ISAXLocator_iface, riid, ppvObject);
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxattributes_AddRef(ISAXAttributes* iface)
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes(iface);
|
2008-07-27 17:55:05 +00:00
|
|
|
TRACE("%p\n", This);
|
2011-10-31 11:32:39 +00:00
|
|
|
return ISAXLocator_AddRef(&This->ISAXLocator_iface);
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxattributes_Release(ISAXAttributes* iface)
|
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes(iface);
|
2012-06-17 12:37:45 +00:00
|
|
|
|
2008-07-27 17:55:05 +00:00
|
|
|
TRACE("%p\n", This);
|
2011-10-31 11:32:39 +00:00
|
|
|
return ISAXLocator_Release(&This->ISAXLocator_iface);
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXAttributes methods ***/
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getLength(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int *length)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
*length = This->attr_count;
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("Length set to %d\n", *length);
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
static inline BOOL is_valid_attr_index(const saxlocator *locator, int index)
|
|
|
|
{
|
|
|
|
return index < locator->attr_count && index >= 0;
|
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getURI(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int index,
|
|
|
|
const WCHAR **url,
|
|
|
|
int *size)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, index);
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
if(!is_valid_attr_index(This, index)) return E_INVALIDARG;
|
2012-06-17 12:37:45 +00:00
|
|
|
if(!url || !size) return E_POINTER;
|
|
|
|
|
|
|
|
*size = SysStringLen(This->attributes[index].szURI);
|
|
|
|
*url = This->attributes[index].szURI;
|
|
|
|
|
|
|
|
TRACE("(%s:%d)\n", debugstr_w(This->attributes[index].szURI), *size);
|
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getLocalName(
|
|
|
|
ISAXAttributes* iface,
|
2014-07-31 19:07:10 +00:00
|
|
|
int index,
|
2012-06-17 12:37:45 +00:00
|
|
|
const WCHAR **pLocalName,
|
|
|
|
int *pLocalNameLength)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2014-07-31 19:07:10 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, index);
|
2012-06-17 12:37:45 +00:00
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
if(!is_valid_attr_index(This, index)) return E_INVALIDARG;
|
2012-06-17 12:37:45 +00:00
|
|
|
if(!pLocalName || !pLocalNameLength) return E_POINTER;
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
*pLocalNameLength = SysStringLen(This->attributes[index].szLocalname);
|
|
|
|
*pLocalName = This->attributes[index].szLocalname;
|
2012-06-17 12:37:45 +00:00
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getQName(
|
|
|
|
ISAXAttributes* iface,
|
2014-07-31 19:07:10 +00:00
|
|
|
int index,
|
2012-06-17 12:37:45 +00:00
|
|
|
const WCHAR **pQName,
|
|
|
|
int *pQNameLength)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2014-07-31 19:07:10 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, index);
|
2012-06-17 12:37:45 +00:00
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
if(!is_valid_attr_index(This, index)) return E_INVALIDARG;
|
2012-06-17 12:37:45 +00:00
|
|
|
if(!pQName || !pQNameLength) return E_POINTER;
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
*pQNameLength = SysStringLen(This->attributes[index].szQName);
|
|
|
|
*pQName = This->attributes[index].szQName;
|
2012-06-17 12:37:45 +00:00
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int index,
|
|
|
|
const WCHAR **uri,
|
|
|
|
int *pUriLength,
|
|
|
|
const WCHAR **localName,
|
|
|
|
int *pLocalNameSize,
|
|
|
|
const WCHAR **QName,
|
|
|
|
int *pQNameLength)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, index);
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
if(!is_valid_attr_index(This, index)) return E_INVALIDARG;
|
2012-06-17 12:37:45 +00:00
|
|
|
if(!uri || !pUriLength || !localName || !pLocalNameSize
|
|
|
|
|| !QName || !pQNameLength) return E_POINTER;
|
|
|
|
|
|
|
|
*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;
|
|
|
|
|
|
|
|
TRACE("(%s, %s, %s)\n", debugstr_w(*uri), debugstr_w(*localName), debugstr_w(*QName));
|
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getIndexFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int cUriLength,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int cocalNameLength,
|
|
|
|
int *index)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
int i;
|
|
|
|
TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), cUriLength,
|
|
|
|
debugstr_w(pLocalName), cocalNameLength);
|
|
|
|
|
|
|
|
if(!pUri || !pLocalName || !index) return E_POINTER;
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
for(i=0; i<This->attr_count; i++)
|
2012-06-17 12:37:45 +00:00
|
|
|
{
|
|
|
|
if(cUriLength!=SysStringLen(This->attributes[i].szURI)
|
|
|
|
|| cocalNameLength!=SysStringLen(This->attributes[i].szLocalname))
|
|
|
|
continue;
|
|
|
|
if(cUriLength && memcmp(pUri, This->attributes[i].szURI,
|
|
|
|
sizeof(WCHAR)*cUriLength))
|
|
|
|
continue;
|
|
|
|
if(cocalNameLength && memcmp(pLocalName, This->attributes[i].szLocalname,
|
|
|
|
sizeof(WCHAR)*cocalNameLength))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getIndexFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQNameLength,
|
|
|
|
int *index)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
int i;
|
|
|
|
TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQNameLength);
|
|
|
|
|
|
|
|
if(!pQName || !index) return E_POINTER;
|
|
|
|
if(!nQNameLength) return E_INVALIDARG;
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
for(i=0; i<This->attr_count; i++)
|
2012-06-17 12:37:45 +00:00
|
|
|
{
|
|
|
|
if(nQNameLength!=SysStringLen(This->attributes[i].szQName)) continue;
|
|
|
|
if(memcmp(pQName, This->attributes[i].szQName, sizeof(WCHAR)*nQNameLength)) continue;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getType(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *pTypeLength)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
|
|
|
|
FIXME("(%p)->(%d) stub\n", This, nIndex);
|
|
|
|
return E_NOTIMPL;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getTypeFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int nUri,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int nLocalName,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *nType)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d, %s, %d) stub\n", This, debugstr_w(pUri), nUri,
|
|
|
|
debugstr_w(pLocalName), nLocalName);
|
|
|
|
return E_NOTIMPL;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getTypeFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQName,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *nType)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d) stub\n", This, debugstr_w(pQName), nQName);
|
|
|
|
return E_NOTIMPL;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getValue(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int index,
|
|
|
|
const WCHAR **value,
|
|
|
|
int *nValue)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, index);
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
if(!is_valid_attr_index(This, index)) return E_INVALIDARG;
|
2012-06-17 12:37:45 +00:00
|
|
|
if(!value || !nValue) return E_POINTER;
|
|
|
|
|
|
|
|
*nValue = SysStringLen(This->attributes[index].szValue);
|
|
|
|
*value = This->attributes[index].szValue;
|
|
|
|
|
|
|
|
TRACE("(%s:%d)\n", debugstr_w(*value), *nValue);
|
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getValueFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int nUri,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int nLocalName,
|
|
|
|
const WCHAR **pValue,
|
|
|
|
int *nValue)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2012-06-17 12:37:45 +00:00
|
|
|
HRESULT hr;
|
|
|
|
int index;
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), nUri,
|
|
|
|
debugstr_w(pLocalName), nLocalName);
|
|
|
|
|
|
|
|
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 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
static HRESULT WINAPI isaxattributes_getValueFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQName,
|
|
|
|
const WCHAR **pValue,
|
|
|
|
int *nValue)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2012-06-17 12:37:45 +00:00
|
|
|
HRESULT hr;
|
|
|
|
int index;
|
2011-10-31 11:32:39 +00:00
|
|
|
saxlocator *This = impl_from_ISAXAttributes( iface );
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQName);
|
|
|
|
|
|
|
|
hr = ISAXAttributes_getIndexFromQName(iface, pQName, nQName, &index);
|
|
|
|
if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
|
|
|
|
|
|
|
|
return hr;
|
2008-07-27 17:55:05 +00: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
|
|
|
|
};
|
|
|
|
|
2013-07-31 06:31:04 +00:00
|
|
|
/* Libxml2 escapes '&' back to char reference '&' in attribute value,
|
|
|
|
so when document has escaped value with '&' it's parsed to '&' and then
|
|
|
|
escaped to '&'. This function takes care of ampersands only. */
|
|
|
|
static BSTR saxreader_get_unescaped_value(const xmlChar *buf, int len)
|
|
|
|
{
|
|
|
|
static const WCHAR ampescW[] = {'&','#','3','8',';',0};
|
|
|
|
WCHAR *dest, *ptrW, *str;
|
|
|
|
DWORD str_len;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
if (!buf)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
str_len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0);
|
|
|
|
if (len != -1) str_len++;
|
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
str = malloc(str_len * sizeof(WCHAR));
|
2013-07-31 06:31:04 +00:00
|
|
|
if (!str) return NULL;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, str, str_len);
|
|
|
|
if (len != -1) str[str_len-1] = 0;
|
|
|
|
|
|
|
|
ptrW = str;
|
2021-10-20 09:39:06 +00:00
|
|
|
while ((dest = wcsstr(ptrW, ampescW)))
|
2013-07-31 06:31:04 +00:00
|
|
|
{
|
|
|
|
WCHAR *src;
|
|
|
|
|
|
|
|
/* leave first '&' from a reference as a value */
|
2018-02-26 22:16:41 +00:00
|
|
|
src = dest + ARRAY_SIZE(ampescW) - 1;
|
2013-07-31 06:31:04 +00:00
|
|
|
dest++;
|
|
|
|
|
|
|
|
/* move together with null terminator */
|
2021-10-20 09:39:06 +00:00
|
|
|
memmove(dest, src, (lstrlenW(src) + 1)*sizeof(WCHAR));
|
2013-07-31 06:31:04 +00:00
|
|
|
|
|
|
|
ptrW++;
|
|
|
|
}
|
|
|
|
|
|
|
|
bstr = SysAllocString(str);
|
2022-11-21 01:44:24 +00:00
|
|
|
free(str);
|
2013-07-31 06:31:04 +00:00
|
|
|
|
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
2014-04-17 08:48:40 +00:00
|
|
|
static void free_attribute_values(saxlocator *locator)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
for (i = 0; i < locator->attr_count; i++)
|
2014-04-17 08:48:40 +00:00
|
|
|
{
|
|
|
|
SysFreeString(locator->attributes[i].szLocalname);
|
|
|
|
locator->attributes[i].szLocalname = NULL;
|
|
|
|
|
|
|
|
SysFreeString(locator->attributes[i].szValue);
|
|
|
|
locator->attributes[i].szValue = NULL;
|
|
|
|
|
|
|
|
SysFreeString(locator->attributes[i].szQName);
|
|
|
|
locator->attributes[i].szQName = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-31 11:32:39 +00:00
|
|
|
static HRESULT SAXAttributes_populate(saxlocator *locator,
|
2008-08-03 12:38:10 +00:00
|
|
|
int nb_namespaces, const xmlChar **xmlNamespaces,
|
2008-07-30 18:24:12 +00:00
|
|
|
int nb_attributes, const xmlChar **xmlAttributes)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
2008-08-03 12:38:10 +00:00
|
|
|
static const xmlChar xmlns[] = "xmlns";
|
2012-06-17 12:37:45 +00:00
|
|
|
static const WCHAR xmlnsW[] = { 'x','m','l','n','s',0 };
|
|
|
|
|
|
|
|
struct _attributes *attrs;
|
2012-04-20 07:03:18 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* skip namespace definitions */
|
|
|
|
if ((locator->saxreader->features & NamespacePrefixes) == 0)
|
|
|
|
nb_namespaces = 0;
|
2008-07-27 17:55:05 +00:00
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
locator->attr_count = nb_namespaces + nb_attributes;
|
|
|
|
if(locator->attr_count > locator->attr_alloc_count)
|
2008-07-30 18:24:12 +00:00
|
|
|
{
|
2014-07-31 19:07:10 +00:00
|
|
|
int new_size = locator->attr_count * 2;
|
2022-11-21 01:44:24 +00:00
|
|
|
attrs = realloc(locator->attributes, new_size * sizeof(*locator->attributes));
|
2012-06-17 12:37:45 +00:00
|
|
|
if(!attrs)
|
|
|
|
{
|
2014-04-17 08:48:40 +00:00
|
|
|
free_attribute_values(locator);
|
2014-07-31 19:07:10 +00:00
|
|
|
locator->attr_count = 0;
|
2012-06-17 12:37:45 +00:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2022-11-21 01:44:24 +00:00
|
|
|
memset(attrs + locator->attr_alloc_count, 0,
|
|
|
|
(new_size - locator->attr_alloc_count) * sizeof(*locator->attributes));
|
2012-06-17 12:37:45 +00:00
|
|
|
locator->attributes = attrs;
|
2014-07-31 19:07:10 +00:00
|
|
|
locator->attr_alloc_count = new_size;
|
2012-06-17 12:37:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
attrs = locator->attributes;
|
2008-07-30 18:24:12 +00:00
|
|
|
}
|
|
|
|
|
2012-06-09 11:37:52 +00:00
|
|
|
for (i = 0; i < nb_namespaces; i++)
|
|
|
|
{
|
2014-04-17 08:48:40 +00:00
|
|
|
SysFreeString(attrs[nb_attributes+i].szLocalname);
|
2012-06-17 12:37:45 +00:00
|
|
|
attrs[nb_attributes+i].szLocalname = SysAllocStringLen(NULL, 0);
|
2014-04-17 08:48:40 +00:00
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
attrs[nb_attributes+i].szURI = locator->namespaceUri;
|
2014-04-17 08:48:40 +00:00
|
|
|
|
|
|
|
SysFreeString(attrs[nb_attributes+i].szValue);
|
2012-06-17 12:37:45 +00:00
|
|
|
attrs[nb_attributes+i].szValue = bstr_from_xmlChar(xmlNamespaces[2*i+1]);
|
2014-04-17 08:48:40 +00:00
|
|
|
|
|
|
|
SysFreeString(attrs[nb_attributes+i].szQName);
|
2012-06-17 12:37:45 +00:00
|
|
|
if(!xmlNamespaces[2*i])
|
|
|
|
attrs[nb_attributes+i].szQName = SysAllocString(xmlnsW);
|
2012-06-09 11:37:52 +00:00
|
|
|
else
|
2012-06-17 12:37:45 +00:00
|
|
|
attrs[nb_attributes+i].szQName = QName_from_xmlChar(xmlns, xmlNamespaces[2*i]);
|
|
|
|
}
|
2012-06-09 11:37:52 +00:00
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
for (i = 0; i < nb_attributes; i++)
|
|
|
|
{
|
|
|
|
static const xmlChar xmlA[] = "xml";
|
2012-06-09 11:37:52 +00:00
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
if (xmlStrEqual(xmlAttributes[i*5+1], xmlA))
|
|
|
|
attrs[i].szURI = bstr_from_xmlChar(xmlAttributes[i*5+2]);
|
|
|
|
else
|
|
|
|
/* that's an important feature to keep same uri pointer for every reported attribute */
|
|
|
|
attrs[i].szURI = find_element_uri(locator, xmlAttributes[i*5+2]);
|
2012-06-09 11:37:52 +00:00
|
|
|
|
2014-04-17 08:48:40 +00:00
|
|
|
SysFreeString(attrs[i].szLocalname);
|
2012-06-17 12:37:45 +00:00
|
|
|
attrs[i].szLocalname = bstr_from_xmlChar(xmlAttributes[i*5]);
|
2014-04-17 08:48:40 +00:00
|
|
|
|
|
|
|
SysFreeString(attrs[i].szValue);
|
2013-07-31 06:31:04 +00:00
|
|
|
attrs[i].szValue = saxreader_get_unescaped_value(xmlAttributes[i*5+3], xmlAttributes[i*5+4]-xmlAttributes[i*5+3]);
|
2014-04-17 08:48:40 +00:00
|
|
|
|
|
|
|
SysFreeString(attrs[i].szQName);
|
|
|
|
attrs[i].szQName = QName_from_xmlChar(xmlAttributes[i*5+1], xmlAttributes[i*5]);
|
2012-06-09 11:37:52 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 17:55:05 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:01 +00:00
|
|
|
/*** LibXML callbacks ***/
|
|
|
|
static void libxmlStartDocument(void *ctx)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2012-07-14 20:36:54 +00:00
|
|
|
struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
|
2008-07-16 22:41:01 +00:00
|
|
|
HRESULT hr;
|
|
|
|
|
2012-04-15 09:47:30 +00:00
|
|
|
if (This->saxreader->version >= MSXML4)
|
2011-11-28 14:05:25 +00:00
|
|
|
{
|
|
|
|
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 18:08:46 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 05:39:43 +00:00
|
|
|
/* store version value, declaration has to contain version attribute */
|
|
|
|
if (This->pParserCtxt->standalone != -1)
|
|
|
|
{
|
|
|
|
SysFreeString(This->saxreader->xmldecl_version);
|
|
|
|
This->saxreader->xmldecl_version = bstr_from_xmlChar(This->pParserCtxt->version);
|
|
|
|
}
|
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
if (saxreader_has_handler(This, SAXContentHandler))
|
2008-07-16 22:41:01 +00:00
|
|
|
{
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = IVBSAXContentHandler_startDocument(handler->vbhandler);
|
2008-07-31 14:48:03 +00:00
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = ISAXContentHandler_startDocument(handler->handler);
|
2008-07-31 14:48:03 +00:00
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-07-19 20:32:10 +00:00
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-16 22:41:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:19 +00:00
|
|
|
static void libxmlEndDocument(void *ctx)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2012-07-14 20:36:54 +00:00
|
|
|
struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
|
2008-07-16 22:41:19 +00:00
|
|
|
HRESULT hr;
|
|
|
|
|
2012-04-15 09:47:30 +00:00
|
|
|
if (This->saxreader->version >= MSXML4) {
|
2011-11-28 14:05:25 +00:00
|
|
|
update_position(This, FALSE);
|
2011-10-24 18:08:46 +00:00
|
|
|
if(This->column > 1)
|
|
|
|
This->line++;
|
|
|
|
This->column = 0;
|
|
|
|
} else {
|
|
|
|
This->column = 0;
|
|
|
|
This->line = 0;
|
|
|
|
}
|
2008-07-16 22:41:19 +00:00
|
|
|
|
2008-07-19 20:31:56 +00:00
|
|
|
if(This->ret != S_OK) return;
|
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
if (saxreader_has_handler(This, SAXContentHandler))
|
2008-07-16 22:41:19 +00:00
|
|
|
{
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = IVBSAXContentHandler_endDocument(handler->vbhandler);
|
2008-07-31 14:48:03 +00:00
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = ISAXContentHandler_endDocument(handler->handler);
|
2008-07-31 14:48:03 +00:00
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-07-19 20:32:10 +00:00
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-16 22:41:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:27 +00: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;
|
2012-07-14 20:36:54 +00:00
|
|
|
struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
|
2011-12-24 13:10:33 +00:00
|
|
|
element_entry *element;
|
|
|
|
HRESULT hr = S_OK;
|
2012-05-08 11:50:19 +00:00
|
|
|
BSTR uri;
|
2008-07-16 22:41:27 +00:00
|
|
|
|
2011-11-28 14:05:25 +00:00
|
|
|
update_position(This, TRUE);
|
2011-10-31 11:32:22 +00:00
|
|
|
if(*(This->pParserCtxt->input->cur) == '/')
|
2011-11-28 14:05:25 +00:00
|
|
|
This->column++;
|
2012-04-15 09:47:30 +00:00
|
|
|
if(This->saxreader->version < MSXML4)
|
2011-11-28 14:05:25 +00:00
|
|
|
This->column++;
|
2008-07-16 22:41:27 +00:00
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
element = alloc_element_entry(localname, prefix, nb_namespaces, namespaces);
|
|
|
|
push_element_ns(This, element);
|
2011-10-31 11:32:59 +00:00
|
|
|
|
2012-05-08 11:50:19 +00:00
|
|
|
if (is_namespaces_enabled(This->saxreader))
|
2008-07-16 22:41:27 +00:00
|
|
|
{
|
2012-05-08 11:50:19 +00:00
|
|
|
int i;
|
2011-12-24 13:10:33 +00:00
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
for (i = 0; i < nb_namespaces && saxreader_has_handler(This, SAXContentHandler); i++)
|
2008-08-03 15:03:28 +00:00
|
|
|
{
|
2012-05-08 11:50:19 +00:00
|
|
|
if (This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_startPrefixMapping(
|
2012-07-14 20:36:54 +00:00
|
|
|
handler->vbhandler,
|
2012-05-08 11:50:19 +00:00
|
|
|
&element->ns[i].prefix,
|
|
|
|
&element->ns[i].uri);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_startPrefixMapping(
|
2012-07-14 20:36:54 +00:00
|
|
|
handler->handler,
|
2012-05-08 11:50:19 +00:00
|
|
|
element->ns[i].prefix,
|
|
|
|
SysStringLen(element->ns[i].prefix),
|
|
|
|
element->ns[i].uri,
|
|
|
|
SysStringLen(element->ns[i].uri));
|
2008-08-03 15:03:28 +00:00
|
|
|
|
2012-05-08 11:50:19 +00:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-08-03 15:03:28 +00:00
|
|
|
{
|
2012-05-08 11:50:19 +00:00
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
return;
|
2008-08-03 15:03:28 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-08 11:50:19 +00:00
|
|
|
}
|
2008-08-03 15:03:28 +00:00
|
|
|
|
2012-05-08 11:50:19 +00:00
|
|
|
uri = find_element_uri(This, URI);
|
|
|
|
hr = SAXAttributes_populate(This, nb_namespaces, namespaces, nb_attributes, attributes);
|
2012-07-17 05:58:36 +00:00
|
|
|
if (hr == S_OK && saxreader_has_handler(This, SAXContentHandler))
|
2012-05-08 11:50:19 +00:00
|
|
|
{
|
|
|
|
BSTR local;
|
2012-04-19 06:46:03 +00:00
|
|
|
|
2012-05-08 11:50:19 +00:00
|
|
|
if (is_namespaces_enabled(This->saxreader))
|
|
|
|
local = element->local;
|
|
|
|
else
|
|
|
|
uri = local = NULL;
|
2012-04-19 06:46:03 +00:00
|
|
|
|
2012-05-08 11:50:19 +00:00
|
|
|
if (This->vbInterface)
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = IVBSAXContentHandler_startElement(handler->vbhandler,
|
2012-05-08 11:50:19 +00:00
|
|
|
&uri, &local, &element->qname, &This->IVBSAXAttributes_iface);
|
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = ISAXContentHandler_startElement(handler->handler,
|
2019-09-24 17:04:55 +00:00
|
|
|
uri ? uri : &empty_str, SysStringLen(uri),
|
|
|
|
local ? local : &empty_str, SysStringLen(local),
|
2012-05-08 11:50:19 +00:00
|
|
|
element->qname, SysStringLen(element->qname),
|
|
|
|
&This->ISAXAttributes_iface);
|
|
|
|
|
|
|
|
if (sax_callback_failed(This, hr))
|
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-16 22:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:34 +00:00
|
|
|
static void libxmlEndElementNS(
|
|
|
|
void *ctx,
|
|
|
|
const xmlChar *localname,
|
|
|
|
const xmlChar *prefix,
|
|
|
|
const xmlChar *URI)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2012-07-14 20:36:54 +00:00
|
|
|
struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
|
2011-12-24 13:10:33 +00:00
|
|
|
element_entry *element;
|
2011-11-28 14:05:25 +00:00
|
|
|
const xmlChar *p;
|
2012-04-19 06:46:03 +00:00
|
|
|
BSTR uri, local;
|
2011-12-24 13:10:33 +00:00
|
|
|
HRESULT hr;
|
2008-07-16 22:41:34 +00:00
|
|
|
|
2011-11-28 14:05:25 +00:00
|
|
|
update_position(This, FALSE);
|
|
|
|
p = This->pParserCtxt->input->cur;
|
2012-04-15 09:47:30 +00:00
|
|
|
|
|
|
|
if (This->saxreader->version >= MSXML4)
|
2011-11-28 14:05:25 +00:00
|
|
|
{
|
|
|
|
p--;
|
|
|
|
while(p>This->pParserCtxt->input->base && *p!='>')
|
|
|
|
{
|
|
|
|
if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
|
|
|
|
This->line--;
|
|
|
|
p--;
|
|
|
|
}
|
2011-10-24 18:08:46 +00:00
|
|
|
}
|
2011-11-28 14:05:25 +00: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-16 22:41:34 +00:00
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
uri = find_element_uri(This, URI);
|
|
|
|
element = pop_element_ns(This);
|
2008-07-16 22:41:34 +00:00
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
if (!saxreader_has_handler(This, SAXContentHandler))
|
2011-12-24 13:10:33 +00:00
|
|
|
{
|
2014-04-17 08:48:40 +00:00
|
|
|
free_attribute_values(This);
|
2014-07-31 19:07:10 +00:00
|
|
|
This->attr_count = 0;
|
2011-12-24 13:10:33 +00:00
|
|
|
free_element_entry(element);
|
|
|
|
return;
|
|
|
|
}
|
2011-10-31 11:32:39 +00:00
|
|
|
|
2012-04-19 06:46:03 +00:00
|
|
|
if (is_namespaces_enabled(This->saxreader))
|
|
|
|
local = element->local;
|
|
|
|
else
|
|
|
|
uri = local = NULL;
|
|
|
|
|
|
|
|
if (This->vbInterface)
|
2011-12-24 13:10:33 +00:00
|
|
|
hr = IVBSAXContentHandler_endElement(
|
2012-07-14 20:36:54 +00:00
|
|
|
handler->vbhandler,
|
2012-04-19 06:46:03 +00:00
|
|
|
&uri, &local, &element->qname);
|
2011-12-24 13:10:33 +00:00
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_endElement(
|
2012-07-14 20:36:54 +00:00
|
|
|
handler->handler,
|
2019-09-24 17:04:55 +00:00
|
|
|
uri ? uri : &empty_str, SysStringLen(uri),
|
|
|
|
local ? local : &empty_str, SysStringLen(local),
|
2011-12-24 13:10:33 +00:00
|
|
|
element->qname, SysStringLen(element->qname));
|
2011-10-26 11:25:27 +00:00
|
|
|
|
2014-04-17 08:48:40 +00:00
|
|
|
free_attribute_values(This);
|
2014-07-31 19:07:10 +00:00
|
|
|
This->attr_count = 0;
|
2011-10-31 11:32:59 +00:00
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
if (sax_callback_failed(This, hr))
|
|
|
|
{
|
|
|
|
format_error_message_from_id(This, hr);
|
2012-02-05 19:44:44 +00:00
|
|
|
free_element_entry(element);
|
2011-12-24 13:10:33 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-10-31 11:32:59 +00:00
|
|
|
|
2012-04-19 06:46:03 +00:00
|
|
|
if (is_namespaces_enabled(This->saxreader))
|
2011-12-24 13:10:33 +00:00
|
|
|
{
|
2012-04-19 06:46:03 +00:00
|
|
|
int i = -1;
|
2012-07-17 05:58:36 +00:00
|
|
|
while (iterate_endprefix_index(This, element, &i) && saxreader_has_handler(This, SAXContentHandler))
|
2012-04-19 06:46:03 +00:00
|
|
|
{
|
|
|
|
if (This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_endPrefixMapping(
|
2012-07-14 20:36:54 +00:00
|
|
|
handler->vbhandler, &element->ns[i].prefix);
|
2012-04-19 06:46:03 +00:00
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_endPrefixMapping(
|
2012-07-14 20:36:54 +00:00
|
|
|
handler->handler, element->ns[i].prefix, SysStringLen(element->ns[i].prefix));
|
2011-10-26 11:25:27 +00:00
|
|
|
|
2012-04-19 06:46:03 +00:00
|
|
|
if (sax_callback_failed(This, hr)) break;
|
|
|
|
}
|
2011-10-26 11:25:27 +00:00
|
|
|
|
2012-05-08 11:50:19 +00:00
|
|
|
if (sax_callback_failed(This, hr))
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
}
|
2011-10-31 11:32:59 +00:00
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
free_element_entry(element);
|
2008-07-16 22:41:34 +00:00
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:40 +00:00
|
|
|
static void libxmlCharacters(
|
|
|
|
void *ctx,
|
|
|
|
const xmlChar *ch,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2008-10-07 20:10:43 +00:00
|
|
|
BSTR Chars;
|
2008-07-16 22:41:40 +00:00
|
|
|
HRESULT hr;
|
2011-11-28 14:05:25 +00:00
|
|
|
xmlChar *cur, *end;
|
2008-10-07 20:10:43 +00:00
|
|
|
BOOL lastEvent = FALSE;
|
2008-07-16 22:41:40 +00:00
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
if (!saxreader_has_handler(This, SAXContentHandler)) return;
|
2008-07-16 22:41:40 +00:00
|
|
|
|
2011-11-28 14:05:25 +00: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 20:10:43 +00:00
|
|
|
cur = (xmlChar*)ch;
|
|
|
|
if(*(ch-1)=='\r') cur--;
|
|
|
|
end = cur;
|
2008-07-23 14:39:12 +00:00
|
|
|
|
2008-10-07 20:10:43 +00:00
|
|
|
while(1)
|
2008-07-16 22:41:40 +00:00
|
|
|
{
|
2008-10-07 20:10:43 +00:00
|
|
|
while(end-ch<len && *end!='\r') end++;
|
|
|
|
if(end-ch==len)
|
2008-07-23 14:39:12 +00:00
|
|
|
{
|
2008-10-07 20:10:43 +00:00
|
|
|
lastEvent = TRUE;
|
|
|
|
}
|
2011-11-28 14:05:25 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*end = '\n';
|
|
|
|
end++;
|
|
|
|
}
|
2008-07-23 14:39:12 +00:00
|
|
|
|
2012-04-15 09:47:30 +00:00
|
|
|
if (This->saxreader->version >= MSXML4)
|
2011-11-28 14:05:25 +00:00
|
|
|
{
|
|
|
|
xmlChar *p;
|
2008-07-23 14:39:12 +00:00
|
|
|
|
2011-11-28 14:05:25 +00:00
|
|
|
for(p=cur; p!=end; p++)
|
|
|
|
{
|
|
|
|
if(*p=='\n')
|
|
|
|
{
|
|
|
|
This->line++;
|
|
|
|
This->column = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->column++;
|
|
|
|
}
|
|
|
|
}
|
2011-10-24 18:08:46 +00:00
|
|
|
|
|
|
|
if(!lastEvent)
|
|
|
|
This->column = 0;
|
|
|
|
}
|
|
|
|
|
2011-11-28 14:05:25 +00:00
|
|
|
Chars = pooled_bstr_from_xmlCharN(&This->saxreader->pool, cur, end-cur);
|
2013-03-14 04:27:57 +00:00
|
|
|
hr = saxreader_saxcharacters(This, Chars);
|
2008-07-31 14:48:03 +00:00
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
if (sax_callback_failed(This, hr))
|
2008-11-13 13:33:27 +00:00
|
|
|
{
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-15 09:47:30 +00:00
|
|
|
if (This->saxreader->version < MSXML4)
|
2011-11-28 14:05:25 +00:00
|
|
|
This->column += end-cur;
|
2008-07-23 14:39:12 +00:00
|
|
|
|
2008-10-07 20:10:43 +00:00
|
|
|
if(lastEvent)
|
|
|
|
break;
|
2008-07-23 14:39:12 +00:00
|
|
|
|
2011-11-28 14:05:25 +00:00
|
|
|
*(end-1) = '\r';
|
2008-10-07 20:10:43 +00:00
|
|
|
if(*end == '\n')
|
|
|
|
{
|
|
|
|
end++;
|
|
|
|
This->column++;
|
2008-07-23 14:39:12 +00:00
|
|
|
}
|
2008-10-07 20:10:43 +00:00
|
|
|
cur = end;
|
2008-07-16 22:41:40 +00:00
|
|
|
|
2008-10-07 20:10:43 +00:00
|
|
|
if(end-ch == len) break;
|
2008-07-16 22:41:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:52 +00:00
|
|
|
static void libxmlSetDocumentLocator(
|
|
|
|
void *ctx,
|
|
|
|
xmlSAXLocatorPtr loc)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2012-07-14 20:36:54 +00:00
|
|
|
struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
|
2010-10-28 21:00:44 +00:00
|
|
|
HRESULT hr = S_OK;
|
2008-07-16 22:41:52 +00:00
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
if (saxreader_has_handler(This, SAXContentHandler))
|
2010-10-28 21:00:44 +00:00
|
|
|
{
|
|
|
|
if(This->vbInterface)
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = IVBSAXContentHandler_putref_documentLocator(handler->vbhandler,
|
2010-12-27 22:12:06 +00:00
|
|
|
&This->IVBSAXLocator_iface);
|
2010-10-28 21:00:44 +00:00
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = ISAXContentHandler_putDocumentLocator(handler->handler, &This->ISAXLocator_iface);
|
2010-10-28 21:00:44 +00:00
|
|
|
}
|
2008-07-16 22:41:52 +00:00
|
|
|
|
|
|
|
if(FAILED(hr))
|
2008-07-19 20:32:10 +00:00
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
}
|
|
|
|
|
2008-10-07 20:11:04 +00:00
|
|
|
static void libxmlComment(void *ctx, const xmlChar *value)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2012-07-14 20:36:54 +00:00
|
|
|
struct saxlexicalhandler_iface *handler = saxreader_get_lexicalhandler(This->saxreader);
|
2008-10-07 20:11:04 +00:00
|
|
|
BSTR bValue;
|
|
|
|
HRESULT hr;
|
2011-11-28 14:05:25 +00:00
|
|
|
const xmlChar *p = This->pParserCtxt->input->cur;
|
2008-10-07 20:11:04 +00:00
|
|
|
|
2011-11-28 14:05:25 +00: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--;
|
|
|
|
}
|
2012-05-08 11:50:19 +00:00
|
|
|
|
2011-11-28 14:05:25 +00:00
|
|
|
This->column = 0;
|
|
|
|
for(; p>=This->pParserCtxt->input->base && *p!='\n' && *p!='\r'; p--)
|
|
|
|
This->column++;
|
2008-10-07 20:11:04 +00:00
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
if (!saxreader_has_handler(This, SAXLexicalHandler)) return;
|
2008-10-07 20:11:04 +00:00
|
|
|
|
2011-07-15 12:38:07 +00:00
|
|
|
bValue = pooled_bstr_from_xmlChar(&This->saxreader->pool, value);
|
2008-10-07 20:11:04 +00:00
|
|
|
|
2012-07-14 20:36:54 +00:00
|
|
|
if (This->vbInterface)
|
|
|
|
hr = IVBSAXLexicalHandler_comment(handler->vbhandler, &bValue);
|
2008-10-07 20:11:04 +00:00
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = ISAXLexicalHandler_comment(handler->handler, bValue, SysStringLen(bValue));
|
2008-10-07 20:11:04 +00:00
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
}
|
|
|
|
|
2021-10-20 09:39:06 +00:00
|
|
|
static void WINAPIV libxmlFatalError(void *ctx, const char *msg, ...)
|
2008-07-19 20:32:10 +00:00
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
2012-07-14 20:36:54 +00:00
|
|
|
struct saxerrorhandler_iface *handler = saxreader_get_errorhandler(This->saxreader);
|
2008-07-19 20:32:10 +00:00
|
|
|
char message[1024];
|
2010-10-26 21:25:26 +00:00
|
|
|
WCHAR *error;
|
2008-07-19 20:32:10 +00:00
|
|
|
DWORD len;
|
|
|
|
va_list args;
|
|
|
|
|
2011-10-24 10:55:13 +00:00
|
|
|
if(This->ret != S_OK) {
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
2011-10-24 10:54:47 +00:00
|
|
|
return;
|
2011-10-24 10:55:13 +00:00
|
|
|
}
|
2011-10-24 10:54:47 +00:00
|
|
|
|
2008-07-19 20:32:10 +00:00
|
|
|
va_start(args, msg);
|
|
|
|
vsprintf(message, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
|
2008-08-26 19:06:09 +00:00
|
|
|
len = MultiByteToWideChar(CP_UNIXCP, 0, message, -1, NULL, 0);
|
2022-11-21 01:44:24 +00:00
|
|
|
error = malloc(sizeof(WCHAR) * len);
|
2010-10-26 21:25:26 +00:00
|
|
|
if(error)
|
|
|
|
{
|
|
|
|
MultiByteToWideChar(CP_UNIXCP, 0, message, -1, error, len);
|
|
|
|
TRACE("fatal error for %p: %s\n", This, debugstr_w(error));
|
|
|
|
}
|
2008-07-19 20:32:10 +00:00
|
|
|
|
2012-07-17 05:58:36 +00:00
|
|
|
if (!saxreader_has_handler(This, SAXErrorHandler))
|
2010-10-28 22:06:33 +00:00
|
|
|
{
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
|
|
|
This->ret = E_FAIL;
|
2022-11-21 01:44:24 +00:00
|
|
|
free(error);
|
2010-10-28 22:06:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Error handling is not compatible.\n");
|
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
{
|
2010-10-26 21:25:26 +00:00
|
|
|
BSTR bstrError = SysAllocString(error);
|
2012-07-14 20:36:54 +00:00
|
|
|
IVBSAXErrorHandler_fatalError(handler->vbhandler, &This->IVBSAXLocator_iface,
|
2010-12-27 22:12:06 +00:00
|
|
|
&bstrError, E_FAIL);
|
2010-10-26 21:15:38 +00:00
|
|
|
SysFreeString(bstrError);
|
2008-07-31 14:48:03 +00:00
|
|
|
}
|
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
ISAXErrorHandler_fatalError(handler->handler, &This->ISAXLocator_iface, error, E_FAIL);
|
2008-07-19 20:32:10 +00:00
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
free(error);
|
2008-07-19 20:32:10 +00:00
|
|
|
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
|
|
|
This->ret = E_FAIL;
|
2008-07-16 22:41:52 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 11:04:59 +00:00
|
|
|
/* The only reason this helper exists is that CDATA section are reported by chunks,
|
|
|
|
newlines are used as delimiter. More than that, reader even alters input data before reporting.
|
|
|
|
|
|
|
|
This helper should be called for substring with trailing newlines.
|
|
|
|
*/
|
|
|
|
static BSTR saxreader_get_cdata_chunk(const xmlChar *str, int len)
|
2008-10-07 20:11:11 +00:00
|
|
|
{
|
2013-03-13 11:04:59 +00:00
|
|
|
BSTR bstr = bstr_from_xmlCharN(str, len), ret;
|
|
|
|
WCHAR *ptr;
|
2008-10-07 20:11:11 +00:00
|
|
|
|
2017-10-05 12:59:56 +00:00
|
|
|
len = SysStringLen(bstr);
|
2013-03-13 11:04:59 +00:00
|
|
|
ptr = bstr + len - 1;
|
|
|
|
while ((*ptr == '\r' || *ptr == '\n') && ptr >= bstr)
|
|
|
|
ptr--;
|
|
|
|
|
|
|
|
while (*++ptr)
|
2011-11-28 14:05:25 +00:00
|
|
|
{
|
2013-03-13 11:04:59 +00:00
|
|
|
/* replace returns as:
|
|
|
|
|
|
|
|
- "\r<char>" -> "\n<char>"
|
|
|
|
- "\r\r" -> "\r"
|
|
|
|
- "\r\n" -> "\n"
|
|
|
|
*/
|
|
|
|
if (*ptr == '\r')
|
|
|
|
{
|
|
|
|
if (*(ptr+1) == '\r' || *(ptr+1) == '\n')
|
|
|
|
{
|
|
|
|
/* shift tail */
|
|
|
|
memmove(ptr, ptr+1, len-- - (ptr-bstr));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*ptr = '\n';
|
|
|
|
}
|
2011-11-28 14:05:25 +00:00
|
|
|
}
|
2008-10-07 20:11:11 +00:00
|
|
|
|
2013-03-13 11:04:59 +00:00
|
|
|
ret = SysAllocStringLen(bstr, len);
|
|
|
|
SysFreeString(bstr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void libxml_cdatablock(void *ctx, const xmlChar *value, int len)
|
|
|
|
{
|
|
|
|
const xmlChar *start, *end;
|
|
|
|
saxlocator *locator = ctx;
|
|
|
|
struct saxlexicalhandler_iface *lexical = saxreader_get_lexicalhandler(locator->saxreader);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
BSTR chars;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
update_position(locator, FALSE);
|
|
|
|
if (saxreader_has_handler(locator, SAXLexicalHandler))
|
2012-05-08 11:56:20 +00:00
|
|
|
{
|
2013-03-13 11:04:59 +00:00
|
|
|
if (locator->vbInterface)
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = IVBSAXLexicalHandler_startCDATA(lexical->vbhandler);
|
2012-05-08 11:56:20 +00:00
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = ISAXLexicalHandler_startCDATA(lexical->handler);
|
2012-05-08 11:56:20 +00:00
|
|
|
}
|
2008-10-07 20:11:11 +00:00
|
|
|
|
|
|
|
if(FAILED(hr))
|
2008-11-13 22:20:52 +00:00
|
|
|
{
|
2013-03-13 11:04:59 +00:00
|
|
|
format_error_message_from_id(locator, hr);
|
2008-11-13 22:20:52 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-10-07 20:11:11 +00:00
|
|
|
|
2013-03-13 11:04:59 +00:00
|
|
|
start = value;
|
|
|
|
end = NULL;
|
|
|
|
i = 0;
|
2008-10-07 20:11:11 +00:00
|
|
|
|
2013-03-13 11:04:59 +00:00
|
|
|
while (i < len)
|
2008-10-07 20:11:11 +00:00
|
|
|
{
|
2013-03-13 11:04:59 +00:00
|
|
|
/* scan for newlines */
|
|
|
|
if (value[i] == '\r' || value[i] == '\n')
|
2008-10-07 20:11:11 +00:00
|
|
|
{
|
2013-03-13 11:04:59 +00:00
|
|
|
/* skip newlines/linefeeds */
|
|
|
|
while (i < len)
|
|
|
|
{
|
|
|
|
if (value[i] != '\r' && value[i] != '\n') break;
|
2017-10-05 12:59:56 +00:00
|
|
|
i++;
|
2013-03-13 11:04:59 +00:00
|
|
|
}
|
|
|
|
end = &value[i];
|
2008-10-07 20:11:11 +00:00
|
|
|
|
2013-03-13 11:04:59 +00:00
|
|
|
/* report */
|
|
|
|
chars = saxreader_get_cdata_chunk(start, end-start);
|
|
|
|
TRACE("(chunk %s)\n", debugstr_w(chars));
|
|
|
|
hr = saxreader_saxcharacters(locator, chars);
|
|
|
|
SysFreeString(chars);
|
2008-10-07 20:11:11 +00:00
|
|
|
|
2013-03-13 11:04:59 +00:00
|
|
|
start = &value[i];
|
|
|
|
end = NULL;
|
2008-10-07 20:11:11 +00:00
|
|
|
}
|
2013-03-13 11:04:59 +00:00
|
|
|
i++;
|
|
|
|
locator->column++;
|
|
|
|
}
|
2008-10-07 20:11:11 +00:00
|
|
|
|
2013-03-13 11:04:59 +00:00
|
|
|
/* no newline chars (or last chunk) report as a whole */
|
|
|
|
if (!end && start == value)
|
|
|
|
{
|
|
|
|
/* report */
|
|
|
|
chars = bstr_from_xmlCharN(start, len-(start-value));
|
|
|
|
TRACE("(%s)\n", debugstr_w(chars));
|
|
|
|
hr = saxreader_saxcharacters(locator, chars);
|
|
|
|
SysFreeString(chars);
|
2008-10-07 20:11:11 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 11:04:59 +00:00
|
|
|
if (saxreader_has_handler(locator, SAXLexicalHandler))
|
2012-05-08 11:56:20 +00:00
|
|
|
{
|
2013-03-13 11:04:59 +00:00
|
|
|
if (locator->vbInterface)
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = IVBSAXLexicalHandler_endCDATA(lexical->vbhandler);
|
2012-05-08 11:56:20 +00:00
|
|
|
else
|
2012-07-14 20:36:54 +00:00
|
|
|
hr = ISAXLexicalHandler_endCDATA(lexical->handler);
|
2012-05-08 11:56:20 +00:00
|
|
|
}
|
2008-10-07 20:11:11 +00:00
|
|
|
|
|
|
|
if(FAILED(hr))
|
2013-03-13 11:04:59 +00:00
|
|
|
format_error_message_from_id(locator, hr);
|
2008-10-07 20:11:11 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:46:36 +00:00
|
|
|
static xmlParserInputPtr libxmlresolveentity(void *ctx, const xmlChar *publicid, const xmlChar *systemid)
|
|
|
|
{
|
|
|
|
FIXME("entity resolving not implemented, %s, %s\n", publicid, systemid);
|
|
|
|
return xmlSAX2ResolveEntity(ctx, publicid, systemid);
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:48:11 +00: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 11:32:39 +00:00
|
|
|
else if ( IsEqualGUID( riid, &IID_IVBSAXAttributes ))
|
|
|
|
{
|
|
|
|
*ppvObject = &This->IVBSAXAttributes_iface;
|
|
|
|
}
|
2008-07-31 14:48:11 +00: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 );
|
2014-03-05 06:41:11 +00:00
|
|
|
return ISAXLocator_AddRef(&This->ISAXLocator_iface);
|
2008-07-31 14:48:11 +00:00
|
|
|
}
|
|
|
|
|
2014-03-05 06:41:11 +00:00
|
|
|
static ULONG WINAPI ivbsaxlocator_Release(IVBSAXLocator* iface)
|
2008-07-31 14:48:11 +00:00
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2014-03-05 06:41:11 +00:00
|
|
|
return ISAXLocator_Release(&This->ISAXLocator_iface);
|
2008-07-31 14:48:11 +00: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,
|
2012-11-29 12:32:38 +00:00
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
2008-07-31 14:48:11 +00:00
|
|
|
{
|
2022-02-03 10:48:04 +00:00
|
|
|
TRACE("%p, %u, %lx, %p.\n", iface, iTInfo, lcid, ppTInfo);
|
2012-11-29 12:32:38 +00:00
|
|
|
|
2014-03-05 06:41:11 +00:00
|
|
|
return get_typeinfo(IVBSAXLocator_tid, ppTInfo);
|
2008-07-31 14:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_GetIDsOfNames(
|
|
|
|
IVBSAXLocator *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-03 10:48:04 +00:00
|
|
|
TRACE("%p, %s, %p, %u, %lx, %p.\n", iface, debugstr_guid(riid), rgszNames, cNames,
|
2008-07-31 14:48:11 +00:00
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
2012-11-29 12:32:38 +00:00
|
|
|
{
|
2008-07-31 14:48:11 +00:00
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
2012-11-29 12:32:38 +00:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
2008-07-31 14:48:11 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-03 10:48:04 +00:00
|
|
|
TRACE("%p, %ld, %s, %lx, %d, %p, %p, %p, %p.\n", iface, dispIdMember, debugstr_guid(riid),
|
2008-07-31 14:48:11 +00:00
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
2012-11-29 12:32:38 +00:00
|
|
|
{
|
2022-02-03 10:48:04 +00:00
|
|
|
hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2012-11-29 12:32:38 +00:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
2008-07-31 14:48:11 +00:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXLocator methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_columnNumber(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
int *pnColumn)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2014-03-05 06:41:11 +00:00
|
|
|
return ISAXLocator_getColumnNumber(&This->ISAXLocator_iface, pnColumn);
|
2008-07-31 14:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_lineNumber(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
int *pnLine)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2014-03-05 06:41:11 +00:00
|
|
|
return ISAXLocator_getLineNumber(&This->ISAXLocator_iface, pnLine);
|
2008-07-31 14:48:11 +00:00
|
|
|
}
|
|
|
|
|
2014-03-05 06:41:11 +00:00
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_publicId(IVBSAXLocator* iface, BSTR *ret)
|
2008-07-31 14:48:11 +00:00
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2014-03-05 06:41:11 +00:00
|
|
|
const WCHAR *publicidW;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ret);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
hr = ISAXLocator_getPublicId(&This->ISAXLocator_iface, &publicidW);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstr(publicidW, ret);
|
2008-07-31 14:48:11 +00:00
|
|
|
}
|
|
|
|
|
2014-03-05 06:41:11 +00:00
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_systemId(IVBSAXLocator* iface, BSTR *ret)
|
2008-07-31 14:48:11 +00:00
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
2014-03-05 06:41:11 +00:00
|
|
|
const WCHAR *systemidW;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ret);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
hr = ISAXLocator_getSystemId(&This->ISAXLocator_iface, &systemidW);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return return_bstr(systemidW, ret);
|
2008-07-31 14:48:11 +00:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
static const struct IVBSAXLocatorVtbl VBSAXLocatorVtbl =
|
2008-07-31 14:48:11 +00: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-16 22:40:32 +00:00
|
|
|
/*** ISAXLocator interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxlocator_QueryInterface(ISAXLocator* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
|
2008-07-16 22:40:32 +00:00
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_ISAXLocator ))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2011-10-31 11:32:39 +00:00
|
|
|
else if ( IsEqualGUID( riid, &IID_ISAXAttributes ))
|
|
|
|
{
|
|
|
|
*ppvObject = &This->ISAXAttributes_iface;
|
|
|
|
}
|
2008-07-16 22:40:32 +00:00
|
|
|
else
|
|
|
|
{
|
2012-04-19 06:55:17 +00:00
|
|
|
WARN("interface %s not implemented\n", debugstr_guid(riid));
|
2008-07-16 22:40:32 +00:00
|
|
|
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 13:10:33 +00:00
|
|
|
ULONG ref = InterlockedIncrement( &This->ref );
|
2022-02-03 10:48:04 +00:00
|
|
|
TRACE("%p, refcount %lu.\n", iface, ref);
|
2011-12-24 13:10:33 +00:00
|
|
|
return ref;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxlocator_Release(
|
|
|
|
ISAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
2022-02-03 10:48:04 +00:00
|
|
|
ULONG ref = InterlockedDecrement( &This->ref );
|
2008-07-16 22:40:32 +00:00
|
|
|
|
2022-02-03 10:48:04 +00:00
|
|
|
TRACE("%p, refcount %ld.\n", iface, ref );
|
2008-07-16 22:40:32 +00:00
|
|
|
|
2022-02-03 10:48:04 +00:00
|
|
|
if (!ref)
|
2008-07-16 22:40:32 +00:00
|
|
|
{
|
2011-12-24 13:10:33 +00:00
|
|
|
element_entry *element, *element2;
|
2012-06-17 12:37:45 +00:00
|
|
|
int index;
|
2011-10-31 11:32:39 +00:00
|
|
|
|
2008-09-21 13:56:18 +00:00
|
|
|
SysFreeString(This->publicId);
|
|
|
|
SysFreeString(This->systemId);
|
2011-10-31 11:33:18 +00:00
|
|
|
SysFreeString(This->namespaceUri);
|
2008-07-16 22:42:01 +00:00
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
for(index = 0; index < This->attr_alloc_count; index++)
|
2012-06-17 12:37:45 +00:00
|
|
|
{
|
|
|
|
SysFreeString(This->attributes[index].szLocalname);
|
|
|
|
SysFreeString(This->attributes[index].szValue);
|
|
|
|
SysFreeString(This->attributes[index].szQName);
|
|
|
|
}
|
2022-11-21 01:44:24 +00:00
|
|
|
free(This->attributes);
|
2011-10-31 11:32:39 +00:00
|
|
|
|
2011-12-24 13:10:33 +00: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 22:12:06 +00:00
|
|
|
ISAXXMLReader_Release(&This->saxreader->ISAXXMLReader_iface);
|
2022-11-21 01:44:24 +00:00
|
|
|
free(This);
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXLocator methods ***/
|
|
|
|
static HRESULT WINAPI isaxlocator_getColumnNumber(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
int *pnColumn)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
*pnColumn = This->column;
|
2008-07-16 22:41:11 +00:00
|
|
|
return S_OK;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getLineNumber(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
int *pnLine)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
*pnLine = This->line;
|
2008-07-16 22:41:11 +00:00
|
|
|
return S_OK;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getPublicId(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
const WCHAR ** ppwchPublicId)
|
|
|
|
{
|
2008-07-16 22:42:01 +00:00
|
|
|
BSTR publicId;
|
2008-07-16 22:40:32 +00:00
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-09-21 13:56:18 +00:00
|
|
|
SysFreeString(This->publicId);
|
2008-07-16 22:42:01 +00:00
|
|
|
|
|
|
|
publicId = bstr_from_xmlChar(xmlSAX2GetPublicId(This->pParserCtxt));
|
|
|
|
if(SysStringLen(publicId))
|
2012-11-28 17:45:12 +00:00
|
|
|
This->publicId = publicId;
|
2008-07-16 22:42:01 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SysFreeString(publicId);
|
|
|
|
This->publicId = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppwchPublicId = This->publicId;
|
|
|
|
return S_OK;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getSystemId(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
const WCHAR ** ppwchSystemId)
|
|
|
|
{
|
2008-07-16 22:42:07 +00:00
|
|
|
BSTR systemId;
|
2008-07-16 22:40:32 +00:00
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-09-21 13:56:18 +00:00
|
|
|
SysFreeString(This->systemId);
|
2008-07-16 22:42:07 +00:00
|
|
|
|
|
|
|
systemId = bstr_from_xmlChar(xmlSAX2GetSystemId(This->pParserCtxt));
|
|
|
|
if(SysStringLen(systemId))
|
2012-11-28 17:45:12 +00:00
|
|
|
This->systemId = systemId;
|
2008-07-16 22:42:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SysFreeString(systemId);
|
|
|
|
This->systemId = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppwchSystemId = This->systemId;
|
|
|
|
return S_OK;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
static const struct ISAXLocatorVtbl SAXLocatorVtbl =
|
2008-07-16 22:40:32 +00:00
|
|
|
{
|
|
|
|
isaxlocator_QueryInterface,
|
|
|
|
isaxlocator_AddRef,
|
|
|
|
isaxlocator_Release,
|
|
|
|
isaxlocator_getColumnNumber,
|
|
|
|
isaxlocator_getLineNumber,
|
|
|
|
isaxlocator_getPublicId,
|
|
|
|
isaxlocator_getSystemId
|
|
|
|
};
|
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
static HRESULT SAXLocator_create(saxreader *reader, saxlocator **ppsaxlocator, BOOL vbInterface)
|
2008-07-16 22:40:32 +00:00
|
|
|
{
|
2011-10-31 11:33:18 +00: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-16 22:40:32 +00:00
|
|
|
saxlocator *locator;
|
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
locator = malloc(sizeof(*locator));
|
2008-07-16 22:40:32 +00:00
|
|
|
if( !locator )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
locator->IVBSAXLocator_iface.lpVtbl = &VBSAXLocatorVtbl;
|
|
|
|
locator->ISAXLocator_iface.lpVtbl = &SAXLocatorVtbl;
|
2011-10-31 11:32:39 +00:00
|
|
|
locator->IVBSAXAttributes_iface.lpVtbl = &ivbsaxattributes_vtbl;
|
|
|
|
locator->ISAXAttributes_iface.lpVtbl = &isaxattributes_vtbl;
|
2008-07-16 22:40:32 +00:00
|
|
|
locator->ref = 1;
|
2008-07-31 14:48:03 +00:00
|
|
|
locator->vbInterface = vbInterface;
|
2008-07-16 22:40:32 +00:00
|
|
|
|
|
|
|
locator->saxreader = reader;
|
2010-12-27 22:12:06 +00:00
|
|
|
ISAXXMLReader_AddRef(&reader->ISAXXMLReader_iface);
|
2008-07-16 22:40:32 +00:00
|
|
|
|
2008-07-16 22:40:53 +00:00
|
|
|
locator->pParserCtxt = NULL;
|
2008-07-16 22:42:01 +00:00
|
|
|
locator->publicId = NULL;
|
2008-07-16 22:42:07 +00:00
|
|
|
locator->systemId = NULL;
|
2012-04-15 09:47:30 +00:00
|
|
|
locator->line = reader->version < MSXML4 ? 0 : 1;
|
2008-07-23 14:39:04 +00:00
|
|
|
locator->column = 0;
|
2008-07-16 22:40:53 +00:00
|
|
|
locator->ret = S_OK;
|
2012-04-15 09:47:30 +00:00
|
|
|
if (locator->saxreader->version >= MSXML6)
|
2011-10-31 11:33:18 +00:00
|
|
|
locator->namespaceUri = SysAllocString(w3xmlns);
|
|
|
|
else
|
|
|
|
locator->namespaceUri = SysAllocStringLen(NULL, 0);
|
2012-06-09 11:37:52 +00:00
|
|
|
if(!locator->namespaceUri)
|
2011-10-31 11:32:39 +00:00
|
|
|
{
|
|
|
|
ISAXXMLReader_Release(&reader->ISAXXMLReader_iface);
|
2022-11-21 01:44:24 +00:00
|
|
|
free(locator);
|
2012-06-17 12:37:45 +00:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2014-07-31 19:07:10 +00:00
|
|
|
locator->attr_alloc_count = 8;
|
|
|
|
locator->attr_count = 0;
|
2022-11-21 01:44:24 +00:00
|
|
|
locator->attributes = calloc(locator->attr_alloc_count, sizeof(*locator->attributes));
|
2012-06-17 12:37:45 +00:00
|
|
|
if(!locator->attributes)
|
|
|
|
{
|
|
|
|
ISAXXMLReader_Release(&reader->ISAXXMLReader_iface);
|
|
|
|
SysFreeString(locator->namespaceUri);
|
2022-11-21 01:44:24 +00:00
|
|
|
free(locator);
|
2011-10-31 11:32:39 +00:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
list_init(&locator->elements);
|
|
|
|
|
2008-07-16 22:40:32 +00:00
|
|
|
*ppsaxlocator = locator;
|
|
|
|
|
|
|
|
TRACE("returning %p\n", *ppsaxlocator);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:48:20 +00:00
|
|
|
/*** SAXXMLReader internal functions ***/
|
|
|
|
static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int size, BOOL vbInterface)
|
|
|
|
{
|
2010-10-30 14:49:43 +00:00
|
|
|
xmlCharEncoding encoding = XML_CHAR_ENCODING_NONE;
|
|
|
|
xmlChar *enc_name = NULL;
|
2008-07-31 14:48:20 +00:00
|
|
|
saxlocator *locator;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2012-06-17 19:51:09 +00:00
|
|
|
TRACE("(%p)->(%p %d)\n", This, buffer, size);
|
|
|
|
|
2008-07-31 14:48:20 +00:00
|
|
|
hr = SAXLocator_create(This, &locator, vbInterface);
|
2012-04-21 08:32:15 +00:00
|
|
|
if (FAILED(hr))
|
2008-11-13 13:33:27 +00:00
|
|
|
return hr;
|
2008-07-31 14:48:20 +00:00
|
|
|
|
2010-10-30 14:49:43 +00: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-21 08:32:15 +00:00
|
|
|
/* if libxml2 detection failed try to guess */
|
|
|
|
if (encoding == XML_CHAR_ENCODING_NONE)
|
|
|
|
{
|
|
|
|
const WCHAR *ptr = (WCHAR*)buffer;
|
2016-05-29 10:41:57 +00:00
|
|
|
/* an xml declaration with optional encoding will still be handled by the parser */
|
2012-04-21 08:32:15 +00:00
|
|
|
if ((size >= 2) && *ptr == '<' && ptr[1] != '?')
|
|
|
|
{
|
|
|
|
enc_name = (xmlChar*)xmlGetCharEncodingName(XML_CHAR_ENCODING_UTF16LE);
|
|
|
|
encoding = XML_CHAR_ENCODING_UTF16LE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (encoding == XML_CHAR_ENCODING_UTF8)
|
|
|
|
enc_name = (xmlChar*)xmlGetCharEncodingName(encoding);
|
|
|
|
else
|
|
|
|
enc_name = NULL;
|
|
|
|
|
2008-07-31 14:48:20 +00:00
|
|
|
locator->pParserCtxt = xmlCreateMemoryParserCtxt(buffer, size);
|
2012-04-21 08:32:15 +00:00
|
|
|
if (!locator->pParserCtxt)
|
2008-07-31 14:48:20 +00:00
|
|
|
{
|
2010-12-27 22:12:06 +00:00
|
|
|
ISAXLocator_Release(&locator->ISAXLocator_iface);
|
2008-07-31 14:48:20 +00:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2012-04-21 08:32:15 +00:00
|
|
|
if (enc_name)
|
|
|
|
{
|
2010-10-30 14:49:43 +00:00
|
|
|
locator->pParserCtxt->encoding = xmlStrdup(enc_name);
|
2012-04-21 08:32:15 +00:00
|
|
|
if (encoding == XML_CHAR_ENCODING_UTF16LE) {
|
|
|
|
TRACE("switching to %s\n", enc_name);
|
|
|
|
xmlSwitchEncoding(locator->pParserCtxt, encoding);
|
|
|
|
}
|
|
|
|
}
|
2010-10-30 14:49:43 +00:00
|
|
|
|
2010-01-10 15:17:37 +00:00
|
|
|
xmlFree(locator->pParserCtxt->sax);
|
2008-07-31 14:48:20 +00:00
|
|
|
locator->pParserCtxt->sax = &locator->saxreader->sax;
|
|
|
|
locator->pParserCtxt->userData = locator;
|
|
|
|
|
2008-10-01 17:52:36 +00:00
|
|
|
This->isParsing = TRUE;
|
2012-04-21 08:32:15 +00:00
|
|
|
if(xmlParseDocument(locator->pParserCtxt) == -1 && locator->ret == S_OK)
|
2011-10-24 10:55:13 +00:00
|
|
|
hr = E_FAIL;
|
|
|
|
else
|
|
|
|
hr = locator->ret;
|
2008-10-01 17:52:36 +00:00
|
|
|
This->isParsing = FALSE;
|
2008-07-31 14:48:20 +00:00
|
|
|
|
|
|
|
if(locator->pParserCtxt)
|
|
|
|
{
|
|
|
|
locator->pParserCtxt->sax = NULL;
|
|
|
|
xmlFreeParserCtxt(locator->pParserCtxt);
|
|
|
|
locator->pParserCtxt = NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-27 22:12:06 +00:00
|
|
|
ISAXLocator_Release(&locator->ISAXLocator_iface);
|
2008-11-13 13:33:27 +00:00
|
|
|
return hr;
|
2008-07-31 14:48:20 +00:00
|
|
|
}
|
|
|
|
|
2012-07-24 05:59:50 +00:00
|
|
|
static HRESULT internal_parseStream(saxreader *This, ISequentialStream *stream, BOOL vbInterface)
|
2008-09-08 13:07:46 +00:00
|
|
|
{
|
|
|
|
saxlocator *locator;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG dataRead;
|
2014-02-12 12:30:56 +00:00
|
|
|
char data[2048];
|
2011-09-21 09:48:17 +00:00
|
|
|
int ret;
|
2008-09-08 13:07:46 +00:00
|
|
|
|
2011-09-21 09:48:17 +00:00
|
|
|
dataRead = 0;
|
2012-07-24 05:59:50 +00:00
|
|
|
hr = ISequentialStream_Read(stream, data, sizeof(data), &dataRead);
|
2011-09-21 09:48:17 +00:00
|
|
|
if(FAILED(hr)) return hr;
|
2008-09-08 13:07:46 +00:00
|
|
|
|
|
|
|
hr = SAXLocator_create(This, &locator, vbInterface);
|
2011-09-21 09:48:17 +00:00
|
|
|
if(FAILED(hr)) return hr;
|
2008-09-08 13:07:46 +00:00
|
|
|
|
|
|
|
locator->pParserCtxt = xmlCreatePushParserCtxt(
|
|
|
|
&locator->saxreader->sax, locator,
|
|
|
|
data, dataRead, NULL);
|
|
|
|
if(!locator->pParserCtxt)
|
|
|
|
{
|
2010-12-27 22:12:06 +00:00
|
|
|
ISAXLocator_Release(&locator->ISAXLocator_iface);
|
2008-09-08 13:07:46 +00:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2008-10-01 17:52:36 +00:00
|
|
|
This->isParsing = TRUE;
|
2008-09-08 13:07:46 +00:00
|
|
|
|
2014-02-12 12:30:56 +00:00
|
|
|
do {
|
|
|
|
dataRead = 0;
|
|
|
|
hr = ISequentialStream_Read(stream, data, sizeof(data), &dataRead);
|
|
|
|
if (FAILED(hr) || !dataRead) break;
|
|
|
|
|
|
|
|
ret = xmlParseChunk(locator->pParserCtxt, data, dataRead, 0);
|
|
|
|
hr = ret!=XML_ERR_OK && locator->ret==S_OK ? E_FAIL : locator->ret;
|
|
|
|
}while(hr == S_OK);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hr))
|
2011-09-21 09:48:17 +00:00
|
|
|
{
|
|
|
|
ret = xmlParseChunk(locator->pParserCtxt, data, 0, 1);
|
2011-10-24 10:55:13 +00:00
|
|
|
hr = ret!=XML_ERR_OK && locator->ret==S_OK ? E_FAIL : locator->ret;
|
2011-09-21 09:48:17 +00:00
|
|
|
}
|
2008-09-08 13:07:46 +00:00
|
|
|
|
2011-09-21 09:48:17 +00:00
|
|
|
|
2008-10-01 17:52:36 +00:00
|
|
|
This->isParsing = FALSE;
|
2008-09-08 13:07:46 +00:00
|
|
|
|
|
|
|
xmlFreeParserCtxt(locator->pParserCtxt);
|
|
|
|
locator->pParserCtxt = NULL;
|
2010-12-27 22:12:06 +00:00
|
|
|
ISAXLocator_Release(&locator->ISAXLocator_iface);
|
2008-09-08 13:07:46 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-11-24 16:23:59 +00:00
|
|
|
static HRESULT internal_parse(
|
2008-07-31 14:48:20 +00:00
|
|
|
saxreader* This,
|
|
|
|
VARIANT varInput,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-02-21 23:04:02 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&varInput));
|
2008-07-31 14:48:20 +00:00
|
|
|
|
2011-07-15 12:38:07 +00:00
|
|
|
/* Dispose of the BSTRs in the pool from a prior run, if any. */
|
|
|
|
free_bstr_pool(&This->pool);
|
|
|
|
|
2008-07-31 14:48:20 +00:00
|
|
|
switch(V_VT(&varInput))
|
|
|
|
{
|
|
|
|
case VT_BSTR:
|
2014-03-03 04:54:52 +00:00
|
|
|
case VT_BSTR|VT_BYREF:
|
|
|
|
{
|
|
|
|
BSTR str = V_ISBYREF(&varInput) ? *V_BSTRREF(&varInput) : V_BSTR(&varInput);
|
2021-10-20 09:39:06 +00:00
|
|
|
hr = internal_parseBuffer(This, (const char*)str, lstrlenW(str)*sizeof(WCHAR), vbInterface);
|
2008-07-31 14:48:20 +00:00
|
|
|
break;
|
2014-03-03 04:54:52 +00:00
|
|
|
}
|
2008-07-31 14:48:20 +00:00
|
|
|
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 10:01:02 +00:00
|
|
|
hr = SafeArrayAccessData(V_ARRAY(&varInput), &pSAData);
|
2008-07-31 14:48:20 +00:00
|
|
|
if(hr != S_OK) break;
|
|
|
|
hr = internal_parseBuffer(This, pSAData, dataRead, vbInterface);
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(&varInput));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
case VT_DISPATCH: {
|
2012-07-24 05:59:50 +00:00
|
|
|
ISequentialStream *stream = NULL;
|
2008-07-31 14:48:20 +00:00
|
|
|
IXMLDOMDocument *xmlDoc;
|
|
|
|
|
2017-03-17 05:23:57 +00:00
|
|
|
if (!V_UNKNOWN(&varInput))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-09-19 14:01:03 +00: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 15:46:30 +00:00
|
|
|
SysFreeString(bstrData);
|
2008-09-19 14:01:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-10-27 21:27:06 +00:00
|
|
|
|
2012-07-24 05:59:50 +00:00
|
|
|
/* try base interface first */
|
2017-03-15 16:38:30 +00:00
|
|
|
IUnknown_QueryInterface(V_UNKNOWN(&varInput), &IID_ISequentialStream, (void**)&stream);
|
|
|
|
if (!stream)
|
|
|
|
/* this should never happen if IStream is implemented properly, but just in case */
|
|
|
|
IUnknown_QueryInterface(V_UNKNOWN(&varInput), &IID_IStream, (void**)&stream);
|
2012-01-23 07:31:55 +00:00
|
|
|
|
2012-07-24 05:59:50 +00:00
|
|
|
if(stream)
|
2008-07-31 14:48:20 +00:00
|
|
|
{
|
2008-09-08 13:07:46 +00:00
|
|
|
hr = internal_parseStream(This, stream, vbInterface);
|
2012-07-24 05:59:50 +00:00
|
|
|
ISequentialStream_Release(stream);
|
2008-07-31 14:48:20 +00:00
|
|
|
}
|
2012-07-24 05:59:50 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("IUnknown* input doesn't support any of expected interfaces\n");
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2008-07-31 14:48:20 +00:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-10-22 06:56:54 +00:00
|
|
|
static HRESULT internal_parseURL(saxreader *reader, const WCHAR *url, BOOL vbInterface)
|
2008-07-31 14:48:20 +00:00
|
|
|
{
|
2012-03-12 09:56:59 +00:00
|
|
|
IMoniker *mon;
|
2008-07-31 14:48:20 +00:00
|
|
|
bsc_t *bsc;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2021-10-22 06:56:54 +00:00
|
|
|
TRACE("%p, %s.\n", reader, debugstr_w(url));
|
|
|
|
|
|
|
|
if (!url && reader->version < MSXML4)
|
|
|
|
return E_INVALIDARG;
|
2008-07-31 14:48:20 +00:00
|
|
|
|
2012-03-12 09:56:59 +00:00
|
|
|
hr = create_moniker_from_url(url, &mon);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2021-10-22 06:56:54 +00:00
|
|
|
if(vbInterface) hr = bind_url(mon, internal_vbonDataAvailable, reader, &bsc);
|
|
|
|
else hr = bind_url(mon, internal_onDataAvailable, reader, &bsc);
|
2012-03-12 09:56:59 +00:00
|
|
|
IMoniker_Release(mon);
|
2008-07-31 14:48:20 +00:00
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-10-24 10:55:00 +00:00
|
|
|
return detach_bsc(bsc);
|
2008-07-31 14:48:20 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
static HRESULT saxreader_put_handler_from_variant(saxreader *This, enum saxhandler_type type, const VARIANT *v, BOOL vb)
|
2008-10-01 17:52:36 +00:00
|
|
|
{
|
2014-03-03 04:55:37 +00:00
|
|
|
const IID *riid;
|
2008-10-01 17:52:36 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
if (V_VT(v) == VT_EMPTY)
|
|
|
|
return saxreader_put_handler(This, type, NULL, vb);
|
2012-07-14 20:36:54 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case SAXDeclHandler:
|
|
|
|
riid = vb ? &IID_IVBSAXDeclHandler : &IID_ISAXDeclHandler;
|
|
|
|
break;
|
|
|
|
case SAXLexicalHandler:
|
|
|
|
riid = vb ? &IID_IVBSAXLexicalHandler : &IID_ISAXLexicalHandler;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("wrong handler type %d\n", type);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2012-07-14 20:36:54 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
switch (V_VT(v))
|
|
|
|
{
|
|
|
|
case VT_DISPATCH:
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
{
|
|
|
|
IUnknown *handler = NULL;
|
2011-09-22 06:50:41 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
if (V_UNKNOWN(v))
|
|
|
|
{
|
|
|
|
HRESULT hr = IUnknown_QueryInterface(V_UNKNOWN(v), riid, (void**)&handler);
|
|
|
|
if (FAILED(hr)) return hr;
|
2008-10-01 17:52:36 +00:00
|
|
|
}
|
2011-09-22 06:50:41 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
saxreader_put_handler(This, type, handler, vb);
|
|
|
|
if (handler) IUnknown_Release(handler);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ERR("value type %d not supported\n", V_VT(v));
|
|
|
|
return E_INVALIDARG;
|
2008-10-01 17:52:36 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
2008-10-01 17:52:36 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
static HRESULT internal_putProperty(
|
|
|
|
saxreader* This,
|
|
|
|
const WCHAR *prop,
|
|
|
|
VARIANT value,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
VARIANT *v;
|
2011-09-21 17:01:10 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
TRACE("(%p)->(%s %s)\n", This, debugstr_w(prop), debugstr_variant(&value));
|
2012-07-14 20:36:54 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
if (This->isParsing) return E_FAIL;
|
2012-04-26 19:54:22 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
v = V_VT(&value) == (VT_VARIANT|VT_BYREF) ? V_VARIANTREF(&value) : &value;
|
|
|
|
if(!memcmp(prop, PropertyDeclHandlerW, sizeof(PropertyDeclHandlerW)))
|
|
|
|
return saxreader_put_handler_from_variant(This, SAXDeclHandler, v, vbInterface);
|
2011-09-21 17:01:10 +00:00
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
if(!memcmp(prop, PropertyLexicalHandlerW, sizeof(PropertyLexicalHandlerW)))
|
|
|
|
return saxreader_put_handler_from_variant(This, SAXLexicalHandler, v, vbInterface);
|
2008-10-01 17:52:36 +00:00
|
|
|
|
2011-10-05 16:19:43 +00:00
|
|
|
if(!memcmp(prop, PropertyMaxXMLSizeW, sizeof(PropertyMaxXMLSizeW)))
|
|
|
|
{
|
2014-03-03 04:55:37 +00:00
|
|
|
if (V_VT(v) == VT_I4 && V_I4(v) == 0) return S_OK;
|
|
|
|
FIXME("(%p)->(%s): max-xml-size unsupported\n", This, debugstr_variant(v));
|
2011-10-05 16:19:43 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-10-05 16:23:56 +00:00
|
|
|
if(!memcmp(prop, PropertyMaxElementDepthW, sizeof(PropertyMaxElementDepthW)))
|
|
|
|
{
|
2014-03-03 04:55:37 +00:00
|
|
|
if (V_VT(v) == VT_I4 && V_I4(v) == 0) return S_OK;
|
|
|
|
FIXME("(%p)->(%s): max-element-depth unsupported\n", This, debugstr_variant(v));
|
2011-10-05 16:23:56 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-03-03 04:55:37 +00:00
|
|
|
FIXME("(%p)->(%s:%s): unsupported property\n", This, debugstr_w(prop), debugstr_variant(v));
|
2010-08-29 21:33:28 +00:00
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
if(!memcmp(prop, PropertyCharsetW, sizeof(PropertyCharsetW)))
|
2010-08-29 21:33:28 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
if(!memcmp(prop, PropertyDomNodeW, sizeof(PropertyDomNodeW)))
|
2010-08-29 21:33:28 +00:00
|
|
|
return E_FAIL;
|
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
if(!memcmp(prop, PropertyInputSourceW, sizeof(PropertyInputSourceW)))
|
2010-08-29 21:33:28 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
if(!memcmp(prop, PropertySchemaDeclHandlerW, sizeof(PropertySchemaDeclHandlerW)))
|
2008-10-01 17:52:36 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
if(!memcmp(prop, PropertyXMLDeclEncodingW, sizeof(PropertyXMLDeclEncodingW)))
|
2008-10-01 17:52:36 +00:00
|
|
|
return E_FAIL;
|
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
if(!memcmp(prop, PropertyXMLDeclStandaloneW, sizeof(PropertyXMLDeclStandaloneW)))
|
2008-10-01 17:52:36 +00:00
|
|
|
return E_FAIL;
|
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
if(!memcmp(prop, PropertyXMLDeclVersionW, sizeof(PropertyXMLDeclVersionW)))
|
2008-10-01 17:52:36 +00:00
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2011-09-21 17:01:10 +00: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;
|
2012-07-14 20:36:54 +00:00
|
|
|
saxreader_get_handler(This, SAXLexicalHandler, vb, (void**)&V_UNKNOWN(value));
|
2011-09-22 06:50:41 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!memcmp(PropertyDeclHandlerW, prop, sizeof(PropertyDeclHandlerW)))
|
|
|
|
{
|
|
|
|
V_VT(value) = VT_UNKNOWN;
|
2012-07-14 20:36:54 +00:00
|
|
|
saxreader_get_handler(This, SAXDeclHandler, vb, (void**)&V_UNKNOWN(value));
|
2011-09-21 17:01:10 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-27 05:39:43 +00:00
|
|
|
if (!memcmp(PropertyXmlDeclVersionW, prop, sizeof(PropertyXmlDeclVersionW)))
|
|
|
|
{
|
|
|
|
V_VT(value) = VT_BSTR;
|
|
|
|
V_BSTR(value) = SysAllocString(This->xmldecl_version);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-21 17:01:10 +00:00
|
|
|
FIXME("(%p)->(%s) unsupported property\n", This, debugstr_w(prop));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-07-08 18:52:04 +00:00
|
|
|
/*** IVBSAXXMLReader interface ***/
|
2008-03-25 03:19:10 +00:00
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_QueryInterface(IVBSAXXMLReader* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
2012-06-17 12:37:45 +00:00
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
|
2008-03-25 03:19:10 +00:00
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IDispatch ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IVBSAXXMLReader ))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2008-07-08 18:52:04 +00:00
|
|
|
else if( IsEqualGUID( riid, &IID_ISAXXMLReader ))
|
|
|
|
{
|
2010-12-27 22:12:06 +00:00
|
|
|
*ppvObject = &This->ISAXXMLReader_iface;
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
2011-11-21 09:23:25 +00:00
|
|
|
else if (dispex_query_interface(&This->dispex, riid, ppvObject))
|
|
|
|
{
|
|
|
|
return *ppvObject ? S_OK : E_NOINTERFACE;
|
|
|
|
}
|
2008-03-25 03:19:10 +00: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 )
|
|
|
|
{
|
2012-07-14 20:36:54 +00:00
|
|
|
int i;
|
2008-10-01 17:52:36 +00:00
|
|
|
|
2012-07-14 20:36:54 +00:00
|
|
|
for (i = 0; i < SAXHandler_Last; i++)
|
|
|
|
{
|
2013-09-03 07:50:00 +00:00
|
|
|
struct saxanyhandler_iface *saxiface = &This->saxhandlers[i].u.anyhandler;
|
2008-10-01 17:52:36 +00:00
|
|
|
|
2013-09-03 07:50:00 +00:00
|
|
|
if (saxiface->handler)
|
|
|
|
IUnknown_Release(saxiface->handler);
|
2012-07-14 19:05:34 +00:00
|
|
|
|
2013-09-03 07:50:00 +00:00
|
|
|
if (saxiface->vbhandler)
|
|
|
|
IUnknown_Release(saxiface->vbhandler);
|
2012-07-14 20:36:54 +00:00
|
|
|
}
|
2012-07-14 19:05:34 +00:00
|
|
|
|
2012-08-27 05:39:43 +00:00
|
|
|
SysFreeString(This->xmldecl_version);
|
2011-07-15 12:38:07 +00:00
|
|
|
free_bstr_pool(&This->pool);
|
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
free(This);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
/*** IDispatch ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader *iface, UINT* pctinfo )
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2011-11-21 09:23:25 +00:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_GetTypeInfo(
|
|
|
|
IVBSAXXMLReader *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2011-11-21 09:23:25 +00:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
|
|
|
|
iTInfo, lcid, ppTInfo);
|
2008-03-25 03:19:10 +00: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 09:23:25 +00:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
|
|
|
|
riid, rgszNames, cNames, lcid, rgDispId);
|
2008-03-25 03:19:10 +00: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 09:23:25 +00:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
|
|
|
|
dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXXMLReader methods ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_getFeature(
|
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR feature_name,
|
2011-10-05 18:29:37 +00:00
|
|
|
VARIANT_BOOL *value)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
return ISAXXMLReader_getFeature(&This->ISAXXMLReader_iface, feature_name, value);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putFeature(
|
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR feature_name,
|
2011-10-04 21:27:39 +00:00
|
|
|
VARIANT_BOOL value)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
return ISAXXMLReader_putFeature(&This->ISAXXMLReader_iface, feature_name, value);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getProperty(
|
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR prop,
|
2011-09-21 17:01:10 +00:00
|
|
|
VARIANT *value)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2011-09-21 17:01:10 +00:00
|
|
|
return internal_getProperty(This, prop, value, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putProperty(
|
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR pProp,
|
2008-03-25 03:19:10 +00:00
|
|
|
VARIANT value)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-10-01 17:52:36 +00:00
|
|
|
return internal_putProperty(This, pProp, value, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_entityResolver(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2012-11-16 21:46:36 +00:00
|
|
|
IVBSAXEntityResolver **resolver)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2012-11-16 21:46:36 +00:00
|
|
|
return saxreader_get_handler(This, SAXEntityResolver, TRUE, (void**)resolver);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_entityResolver(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2012-11-16 21:46:36 +00:00
|
|
|
IVBSAXEntityResolver *resolver)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2012-11-16 21:46:36 +00:00
|
|
|
return saxreader_put_handler(This, SAXEntityResolver, resolver, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_contentHandler(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
IVBSAXContentHandler **handler)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_get_handler(This, SAXContentHandler, TRUE, (void**)handler);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_contentHandler(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
IVBSAXContentHandler *handler)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_put_handler(This, SAXContentHandler, handler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_dtdHandler(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
IVBSAXDTDHandler **handler)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_get_handler(This, SAXDTDHandler, TRUE, (void**)handler);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_dtdHandler(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
IVBSAXDTDHandler *handler)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_put_handler(This, SAXDTDHandler, handler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_errorHandler(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
IVBSAXErrorHandler **handler)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_get_handler(This, SAXErrorHandler, TRUE, (void**)handler);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_errorHandler(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
IVBSAXErrorHandler *handler)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_put_handler(This, SAXErrorHandler, handler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_baseURL(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR *pBaseUrl)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_baseURL(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR pBaseUrl)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
return ISAXXMLReader_putBaseURL(&This->ISAXXMLReader_iface, pBaseUrl);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_get_secureBaseURL(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR *pSecureBaseUrl)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-09-09 09:26:51 +00:00
|
|
|
static HRESULT WINAPI saxxmlreader_put_secureBaseURL(
|
2008-03-25 03:19:10 +00:00
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR secureBaseUrl)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
return ISAXXMLReader_putSecureBaseURL(&This->ISAXXMLReader_iface, secureBaseUrl);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_parse(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
VARIANT varInput)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_parse(This, varInput, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_parseURL(
|
|
|
|
IVBSAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
BSTR url)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_parseURL(This, url, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
static const struct IVBSAXXMLReaderVtbl VBSAXXMLReaderVtbl =
|
2008-03-25 03:19:10 +00: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 09:26:51 +00: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 03:19:10 +00:00
|
|
|
saxxmlreader_parse,
|
|
|
|
saxxmlreader_parseURL
|
|
|
|
};
|
|
|
|
|
2008-07-08 18:52:04 +00:00
|
|
|
/*** ISAXXMLReader interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxxmlreader_QueryInterface(ISAXXMLReader* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
return IVBSAXXMLReader_QueryInterface(&This->IVBSAXXMLReader_iface, riid, ppvObject);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxxmlreader_AddRef(ISAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
return IVBSAXXMLReader_AddRef(&This->IVBSAXXMLReader_iface);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxxmlreader_Release(ISAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-05 06:40:53 +00:00
|
|
|
return IVBSAXXMLReader_Release(&This->IVBSAXXMLReader_iface);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXXMLReader methods ***/
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getFeature(
|
|
|
|
ISAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
const WCHAR *feature_name,
|
|
|
|
VARIANT_BOOL *value)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
saxreader_feature feature;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(feature_name), value);
|
|
|
|
|
|
|
|
feature = get_saxreader_feature(feature_name);
|
2018-02-26 22:16:38 +00:00
|
|
|
|
2018-02-26 22:16:40 +00:00
|
|
|
if (This->version < MSXML4 && (feature == ExhaustiveErrors || feature == SchemaValidation))
|
2018-02-26 22:16:38 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (feature == Namespaces ||
|
|
|
|
feature == NamespacePrefixes ||
|
2018-02-26 22:16:40 +00:00
|
|
|
feature == ExhaustiveErrors ||
|
|
|
|
feature == SchemaValidation)
|
2014-03-03 04:55:16 +00:00
|
|
|
return get_feature_value(This, feature, value);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(feature_name), value);
|
|
|
|
return E_NOTIMPL;
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putFeature(
|
|
|
|
ISAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
const WCHAR *feature_name,
|
|
|
|
VARIANT_BOOL value)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
saxreader_feature feature;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %x)\n", This, debugstr_w(feature_name), value);
|
|
|
|
|
|
|
|
feature = get_saxreader_feature(feature_name);
|
|
|
|
|
|
|
|
/* accepted cases */
|
2018-02-26 22:16:39 +00:00
|
|
|
if ((feature == ExhaustiveErrors && value == VARIANT_FALSE) ||
|
2018-02-26 22:16:40 +00:00
|
|
|
(feature == SchemaValidation && value == VARIANT_FALSE) ||
|
2014-03-03 04:55:16 +00:00
|
|
|
feature == Namespaces ||
|
|
|
|
feature == NamespacePrefixes)
|
|
|
|
{
|
|
|
|
return set_feature_value(This, feature, value);
|
|
|
|
}
|
|
|
|
|
2018-02-26 22:16:39 +00:00
|
|
|
if (feature == LexicalHandlerParEntities ||
|
|
|
|
feature == ProhibitDTD ||
|
|
|
|
feature == ExternalGeneralEntities ||
|
|
|
|
feature == ExternalParameterEntities)
|
2014-03-03 04:55:16 +00:00
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(feature_name), value);
|
|
|
|
return set_feature_value(This, feature, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(feature_name), value);
|
|
|
|
return E_NOTIMPL;
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getProperty(
|
|
|
|
ISAXXMLReader* iface,
|
2011-09-21 17:01:10 +00:00
|
|
|
const WCHAR *prop,
|
|
|
|
VARIANT *value)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2011-09-21 17:01:10 +00:00
|
|
|
return internal_getProperty(This, prop, value, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putProperty(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pProp,
|
|
|
|
VARIANT value)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-10-01 17:52:36 +00:00
|
|
|
return internal_putProperty(This, pProp, value, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getEntityResolver(
|
|
|
|
ISAXXMLReader* iface,
|
2012-11-16 21:46:36 +00:00
|
|
|
ISAXEntityResolver **resolver)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2012-11-16 21:46:36 +00:00
|
|
|
return saxreader_get_handler(This, SAXEntityResolver, FALSE, (void**)resolver);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putEntityResolver(
|
|
|
|
ISAXXMLReader* iface,
|
2012-11-16 21:46:36 +00:00
|
|
|
ISAXEntityResolver *resolver)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2012-11-16 21:46:36 +00:00
|
|
|
return saxreader_put_handler(This, SAXEntityResolver, resolver, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getContentHandler(
|
|
|
|
ISAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
ISAXContentHandler **handler)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_get_handler(This, SAXContentHandler, FALSE, (void**)handler);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putContentHandler(
|
2012-07-14 20:36:54 +00:00
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXContentHandler *handler)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_put_handler(This, SAXContentHandler, handler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getDTDHandler(
|
|
|
|
ISAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
ISAXDTDHandler **handler)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_get_handler(This, SAXDTDHandler, FALSE, (void**)handler);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putDTDHandler(
|
|
|
|
ISAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
ISAXDTDHandler *handler)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_put_handler(This, SAXDTDHandler, handler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getErrorHandler(
|
|
|
|
ISAXXMLReader* iface,
|
2012-07-14 20:36:54 +00:00
|
|
|
ISAXErrorHandler **handler)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_get_handler(This, SAXErrorHandler, FALSE, (void**)handler);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
2012-07-14 20:36:54 +00:00
|
|
|
static HRESULT WINAPI isaxxmlreader_putErrorHandler(ISAXXMLReader* iface, ISAXErrorHandler *handler)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2012-07-14 20:36:54 +00:00
|
|
|
return saxreader_put_handler(This, SAXErrorHandler, handler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
2014-03-03 04:55:16 +00:00
|
|
|
const WCHAR **base_url)
|
2008-07-08 18:52:04 +00:00
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, base_url);
|
|
|
|
return E_NOTIMPL;
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
|
|
|
|
return E_NOTIMPL;
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getSecureBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR **pSecureBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
|
|
|
|
return E_NOTIMPL;
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *secureBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2014-03-03 04:55:16 +00:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
|
|
|
|
return E_NOTIMPL;
|
2008-07-27 17:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_parse(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
VARIANT varInput)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_parse(This, varInput, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_parseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *url)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_parseURL(This, url, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
static const struct ISAXXMLReaderVtbl SAXXMLReaderVtbl =
|
2008-07-08 18:52:04 +00: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 09:23:25 +00: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
|
|
|
|
};
|
|
|
|
|
2014-01-09 11:57:58 +00:00
|
|
|
HRESULT SAXXMLReader_create(MSXML_VERSION version, LPVOID *ppObj)
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
|
|
|
saxreader *reader;
|
|
|
|
|
2014-01-09 11:57:58 +00:00
|
|
|
TRACE("(%p)\n", ppObj);
|
2008-03-25 03:19:10 +00:00
|
|
|
|
2022-11-21 01:44:24 +00:00
|
|
|
reader = malloc(sizeof(*reader));
|
2008-03-25 03:19:10 +00:00
|
|
|
if( !reader )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-12-24 13:10:33 +00:00
|
|
|
reader->IVBSAXXMLReader_iface.lpVtbl = &VBSAXXMLReaderVtbl;
|
|
|
|
reader->ISAXXMLReader_iface.lpVtbl = &SAXXMLReaderVtbl;
|
2008-03-25 03:19:10 +00:00
|
|
|
reader->ref = 1;
|
2012-07-14 20:36:54 +00:00
|
|
|
memset(reader->saxhandlers, 0, sizeof(reader->saxhandlers));
|
2008-10-01 17:52:36 +00:00
|
|
|
reader->isParsing = FALSE;
|
2012-08-27 05:39:43 +00:00
|
|
|
reader->xmldecl_version = NULL;
|
2011-07-15 12:38:07 +00:00
|
|
|
reader->pool.pool = NULL;
|
|
|
|
reader->pool.index = 0;
|
|
|
|
reader->pool.len = 0;
|
2012-04-17 05:44:44 +00:00
|
|
|
reader->features = Namespaces | NamespacePrefixes;
|
2011-10-24 18:08:46 +00:00
|
|
|
reader->version = version;
|
2008-03-25 03:19:10 +00:00
|
|
|
|
2011-11-21 09:23:25 +00:00
|
|
|
init_dispex(&reader->dispex, (IUnknown*)&reader->IVBSAXXMLReader_iface, &saxreader_dispex);
|
|
|
|
|
2008-07-16 22:40:53 +00:00
|
|
|
memset(&reader->sax, 0, sizeof(xmlSAXHandler));
|
|
|
|
reader->sax.initialized = XML_SAX2_MAGIC;
|
2008-07-16 22:41:01 +00:00
|
|
|
reader->sax.startDocument = libxmlStartDocument;
|
2008-07-16 22:41:19 +00:00
|
|
|
reader->sax.endDocument = libxmlEndDocument;
|
2008-07-16 22:41:27 +00:00
|
|
|
reader->sax.startElementNs = libxmlStartElementNS;
|
2008-07-16 22:41:34 +00:00
|
|
|
reader->sax.endElementNs = libxmlEndElementNS;
|
2008-07-16 22:41:40 +00:00
|
|
|
reader->sax.characters = libxmlCharacters;
|
2008-07-16 22:41:52 +00:00
|
|
|
reader->sax.setDocumentLocator = libxmlSetDocumentLocator;
|
2008-10-07 20:11:04 +00:00
|
|
|
reader->sax.comment = libxmlComment;
|
2008-07-19 20:32:10 +00:00
|
|
|
reader->sax.error = libxmlFatalError;
|
|
|
|
reader->sax.fatalError = libxmlFatalError;
|
2013-03-13 11:04:59 +00:00
|
|
|
reader->sax.cdataBlock = libxml_cdatablock;
|
2012-11-16 21:46:36 +00:00
|
|
|
reader->sax.resolveEntity = libxmlresolveentity;
|
2008-07-16 22:40:53 +00:00
|
|
|
|
2010-12-27 22:12:06 +00:00
|
|
|
*ppObj = &reader->IVBSAXXMLReader_iface;
|
2008-03-26 03:40:01 +00:00
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
TRACE("returning iface %p\n", *ppObj);
|
2008-03-26 03:40:01 +00:00
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|