mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
our current experimental Neutrino branch
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@27 e54a6e83-5905-42d5-8d5c-058d10e6a962
Origin commit data
------------------
Branch: ni/coolstream
Commit: bc5bd4154e
Author: mrcolor <mrcolor@e54a6e83-5905-42d5-8d5c-058d10e6a962>
Date: 2009-12-08 (Tue, 08 Dec 2009)
------------------
This commit was generated by Migit
This commit is contained in:
8
lib/xmltree/Makefile.am
Normal file
8
lib/xmltree/Makefile.am
Normal file
@@ -0,0 +1,8 @@
|
||||
INCLUDES = -I$(srcdir)/xmltok
|
||||
|
||||
AM_CPPFLAGS = -fno-rtti -fno-exceptions
|
||||
|
||||
noinst_LIBRARIES = libtuxbox-xmltree.a
|
||||
|
||||
libtuxbox_xmltree_a_SOURCES = \
|
||||
hashtab.c xmlparse.cpp xmlrole.c xmltok.c xmltree.cpp xmlinterface.cpp
|
52
lib/xmltree/asciitab.h
Normal file
52
lib/xmltree/asciitab.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_NMSTRT, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
134
lib/xmltree/hashtab.c
Normal file
134
lib/xmltree/hashtab.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
csompliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "xmldef.h"
|
||||
#include "hashtab.h"
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
#define keycmp wcscmp
|
||||
#else
|
||||
#define keycmp strcmp
|
||||
#endif
|
||||
|
||||
#define INIT_SIZE 64
|
||||
|
||||
static
|
||||
unsigned long hash(KEY s)
|
||||
{
|
||||
unsigned long h = 0;
|
||||
while (*s)
|
||||
h = (h << 5) + h + (unsigned char)*s++;
|
||||
return h;
|
||||
}
|
||||
|
||||
NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize)
|
||||
{
|
||||
size_t i;
|
||||
if (table->size == 0) {
|
||||
if (!createSize)
|
||||
return 0;
|
||||
table->v = (NAMED**)calloc(INIT_SIZE, sizeof(NAMED *));
|
||||
if (!table->v)
|
||||
return 0;
|
||||
table->size = INIT_SIZE;
|
||||
table->usedLim = INIT_SIZE / 2;
|
||||
i = hash(name) & (table->size - 1);
|
||||
}
|
||||
else {
|
||||
unsigned long h = hash(name);
|
||||
for (i = h & (table->size - 1);
|
||||
table->v[i];
|
||||
i == 0 ? i = table->size - 1 : --i) {
|
||||
if (keycmp(name, table->v[i]->name) == 0)
|
||||
return table->v[i];
|
||||
}
|
||||
if (!createSize)
|
||||
return 0;
|
||||
if (table->used == table->usedLim) {
|
||||
/* check for overflow */
|
||||
size_t newSize = table->size * 2;
|
||||
NAMED **newV = (NAMED**)calloc(newSize, sizeof(NAMED *));
|
||||
if (!newV)
|
||||
return 0;
|
||||
for (i = 0; i < table->size; i++)
|
||||
if (table->v[i]) {
|
||||
size_t j;
|
||||
for (j = hash(table->v[i]->name) & (newSize - 1);
|
||||
newV[j];
|
||||
j == 0 ? j = newSize - 1 : --j)
|
||||
;
|
||||
newV[j] = table->v[i];
|
||||
}
|
||||
free(table->v);
|
||||
table->v = newV;
|
||||
table->size = newSize;
|
||||
table->usedLim = newSize/2;
|
||||
for (i = h & (table->size - 1);
|
||||
table->v[i];
|
||||
i == 0 ? i = table->size - 1 : --i)
|
||||
;
|
||||
}
|
||||
}
|
||||
table->v[i] = (NAMED*)calloc(1, createSize);
|
||||
if (!table->v[i])
|
||||
return 0;
|
||||
table->v[i]->name = name;
|
||||
(table->used)++;
|
||||
return table->v[i];
|
||||
}
|
||||
|
||||
void hashTableDestroy(HASH_TABLE *table)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < table->size; i++) {
|
||||
NAMED *p = table->v[i];
|
||||
if (p)
|
||||
free(p);
|
||||
}
|
||||
free(table->v);
|
||||
}
|
||||
|
||||
void hashTableInit(HASH_TABLE *p)
|
||||
{
|
||||
p->size = 0;
|
||||
p->usedLim = 0;
|
||||
p->used = 0;
|
||||
p->v = 0;
|
||||
}
|
||||
|
||||
void hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table)
|
||||
{
|
||||
iter->p = table->v;
|
||||
iter->end = iter->p + table->size;
|
||||
}
|
||||
|
||||
NAMED *hashTableIterNext(HASH_TABLE_ITER *iter)
|
||||
{
|
||||
while (iter->p != iter->end) {
|
||||
NAMED *tem = *(iter->p)++;
|
||||
if (tem)
|
||||
return tem;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
59
lib/xmltree/hashtab.h
Normal file
59
lib/xmltree/hashtab.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
typedef const wchar_t *KEY;
|
||||
#else
|
||||
typedef const char *KEY;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
KEY name;
|
||||
} NAMED;
|
||||
|
||||
typedef struct {
|
||||
NAMED **v;
|
||||
size_t size;
|
||||
size_t used;
|
||||
size_t usedLim;
|
||||
} HASH_TABLE;
|
||||
|
||||
NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize);
|
||||
void hashTableInit(HASH_TABLE *);
|
||||
void hashTableDestroy(HASH_TABLE *);
|
||||
|
||||
typedef struct {
|
||||
NAMED **p;
|
||||
NAMED **end;
|
||||
} HASH_TABLE_ITER;
|
||||
|
||||
void hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *);
|
||||
NAMED *hashTableIterNext(HASH_TABLE_ITER *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
53
lib/xmltree/iasctab.h
Normal file
53
lib/xmltree/iasctab.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_NMSTRT, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
178
lib/xmltree/xmlinterface.cpp
Normal file
178
lib/xmltree/xmlinterface.cpp
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* $Header: /cvs/tuxbox/apps/dvb/zapit/src/xmlinterface.cpp,v 1.25 2004/04/07 19:33:21 thegoodguy Exp $
|
||||
*
|
||||
* xmlinterface for zapit - d-box2 linux project
|
||||
*
|
||||
* (C) 2002 by thegoodguy <thegoodguy@berlios.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <xmlinterface.h>
|
||||
|
||||
#ifdef USE_LIBXML
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#else /* USE_LIBXML */
|
||||
#include <xmltok.h>
|
||||
#endif /* USE_LIBXML */
|
||||
|
||||
|
||||
unsigned long xmlGetNumericAttribute(const xmlNodePtr node, char *name, const int base)
|
||||
{
|
||||
char *ptr = xmlGetAttribute(node, name);
|
||||
|
||||
if (!ptr)
|
||||
return 0;
|
||||
|
||||
return strtoul(ptr, 0, base);
|
||||
}
|
||||
|
||||
long xmlGetSignedNumericAttribute(const xmlNodePtr node, char *name, const int base)
|
||||
{
|
||||
char *ptr = xmlGetAttribute(node, name);
|
||||
|
||||
if (!ptr)
|
||||
return 0;
|
||||
|
||||
return strtol(ptr, 0, base);
|
||||
}
|
||||
|
||||
xmlNodePtr xmlGetNextOccurence(xmlNodePtr cur, const char * s)
|
||||
{
|
||||
while ((cur != NULL) && (strcmp(xmlGetName(cur), s) != 0))
|
||||
cur = cur->xmlNextNode;
|
||||
return cur;
|
||||
}
|
||||
|
||||
|
||||
std::string Unicode_Character_to_UTF8(const int character)
|
||||
{
|
||||
#ifdef USE_LIBXML
|
||||
xmlChar buf[5];
|
||||
int length = xmlCopyChar(4, buf, character);
|
||||
return std::string((char*)buf, length);
|
||||
#else /* USE_LIBXML */
|
||||
char buf[XML_UTF8_ENCODE_MAX];
|
||||
int length = XmlUtf8Encode(character, buf);
|
||||
return std::string(buf, length);
|
||||
#endif /* USE_LIBXML */
|
||||
}
|
||||
|
||||
#ifdef USE_LIBXML
|
||||
xmlDocPtr parseXmlFile(const char * filename)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr cur;
|
||||
|
||||
doc = xmlParseFile(filename);
|
||||
|
||||
if (doc == NULL)
|
||||
{
|
||||
WARN("Error parsing \"%s\"", filename);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
cur = xmlDocGetRootElement(doc);
|
||||
if (cur == NULL)
|
||||
{
|
||||
WARN("Empty document\n");
|
||||
xmlFreeDoc(doc);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
#else /* USE_LIBXML */
|
||||
xmlDocPtr parseXml(const char * data)
|
||||
{
|
||||
XMLTreeParser* tree_parser;
|
||||
|
||||
tree_parser = new XMLTreeParser(NULL);
|
||||
|
||||
if (!tree_parser->Parse(data, strlen(data), true))
|
||||
{
|
||||
printf("Error parsing XML Data: %s at line %d\n",
|
||||
tree_parser->ErrorString(tree_parser->GetErrorCode()),
|
||||
tree_parser->GetCurrentLineNumber());
|
||||
|
||||
delete tree_parser;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!tree_parser->RootNode())
|
||||
{
|
||||
printf("Error: No Root Node\n");
|
||||
delete tree_parser;
|
||||
return NULL;
|
||||
}
|
||||
return tree_parser;
|
||||
}
|
||||
|
||||
xmlDocPtr parseXmlFile(const char * filename)
|
||||
{
|
||||
char buffer[2048];
|
||||
XMLTreeParser* tree_parser;
|
||||
size_t done;
|
||||
size_t length;
|
||||
FILE* xml_file;
|
||||
|
||||
xml_file = fopen(filename, "r");
|
||||
|
||||
if (xml_file == NULL)
|
||||
{
|
||||
perror(filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tree_parser = new XMLTreeParser(NULL);
|
||||
|
||||
do
|
||||
{
|
||||
length = fread(buffer, 1, sizeof(buffer), xml_file);
|
||||
done = length < sizeof(buffer);
|
||||
|
||||
if (!tree_parser->Parse(buffer, length, done))
|
||||
{
|
||||
printf("Error parsing \"%s\": %s at line %d\n",
|
||||
filename,
|
||||
tree_parser->ErrorString(tree_parser->GetErrorCode()),
|
||||
tree_parser->GetCurrentLineNumber());
|
||||
|
||||
fclose(xml_file);
|
||||
delete tree_parser;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
while (!done);
|
||||
|
||||
fclose(xml_file);
|
||||
|
||||
if (!tree_parser->RootNode())
|
||||
{
|
||||
delete tree_parser;
|
||||
return NULL;
|
||||
}
|
||||
return tree_parser;
|
||||
}
|
||||
#endif /* USE_LIBXML */
|
93
lib/xmltree/xmlinterface.h
Normal file
93
lib/xmltree/xmlinterface.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* $Header: /cvs/tuxbox/apps/dvb/zapit/include/zapit/xmlinterface.h,v 1.21 2004/04/07 19:33:21 thegoodguy Exp $
|
||||
*
|
||||
* xmlinterface for zapit - d-box2 linux project
|
||||
*
|
||||
* (C) 2002 by thegoodguy <thegoodguy@berlios.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __xmlinterface_h__
|
||||
#define __xmlinterface_h__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef USE_LIBXML
|
||||
#include <libxml/parser.h>
|
||||
#define xmlNextNode next
|
||||
inline char* xmlGetAttribute (xmlNodePtr cur, const char * s) { return (char *)xmlGetProp(cur, (const xmlChar *)s); };
|
||||
inline char* xmlGetName (xmlNodePtr cur) { return (char *)(cur->name); };
|
||||
|
||||
#else /* use libxmltree */
|
||||
#include <xmltree.h>
|
||||
typedef XMLTreeParser* xmlDocPtr;
|
||||
typedef XMLTreeNode* xmlNodePtr;
|
||||
#define xmlChildrenNode GetChild()
|
||||
#define xmlNextNode GetNext()
|
||||
inline xmlNodePtr xmlDocGetRootElement(xmlDocPtr doc) { return doc->RootNode(); };
|
||||
inline void xmlFreeDoc (xmlDocPtr doc) { delete doc; };
|
||||
inline char* xmlGetAttribute (xmlNodePtr cur, char * s) { return cur->GetAttributeValue(s); };
|
||||
inline char* xmlGetName (xmlNodePtr cur) { return cur->GetType(); };
|
||||
inline char* xmlGetData (xmlNodePtr cur) { return cur->GetData(); };
|
||||
#endif /* USE_LIBXML */
|
||||
|
||||
|
||||
unsigned long xmlGetNumericAttribute (const xmlNodePtr node, char *name, const int base);
|
||||
long xmlGetSignedNumericAttribute (const xmlNodePtr node, char *name, const int base);
|
||||
xmlNodePtr xmlGetNextOccurence (xmlNodePtr cur, const char * s);
|
||||
|
||||
std::string Unicode_Character_to_UTF8(const int character);
|
||||
|
||||
inline std::string convert_UTF8_To_UTF8_XML(const char * s)
|
||||
{
|
||||
std::string r;
|
||||
|
||||
while ((*s) != 0)
|
||||
{
|
||||
/* cf. http://www.w3.org/TR/xhtml1/dtds.html */
|
||||
switch (*s)
|
||||
{
|
||||
case '<':
|
||||
r += "<";
|
||||
break;
|
||||
case '>':
|
||||
r += ">";
|
||||
break;
|
||||
case '&':
|
||||
r += "&";
|
||||
break;
|
||||
case '\"':
|
||||
r += """;
|
||||
break;
|
||||
case '\'':
|
||||
r += "'";
|
||||
break;
|
||||
default:
|
||||
r += *s;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
xmlDocPtr parseXml(const char *data);
|
||||
xmlDocPtr parseXmlFile(const char * filename);
|
||||
|
||||
#endif /* __xmlinterface_h__ */
|
2734
lib/xmltree/xmlparse.cpp
Normal file
2734
lib/xmltree/xmlparse.cpp
Normal file
File diff suppressed because it is too large
Load Diff
317
lib/xmltree/xmlparse.h
Normal file
317
lib/xmltree/xmlparse.h
Normal file
@@ -0,0 +1,317 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Fabian Giesen - converted this monster to C++ (at least the core)
|
||||
|
||||
ChangeLog:
|
||||
|
||||
$Log: xmlparse.h,v $
|
||||
Revision 1.2 2003/03/14 05:13:04 obi
|
||||
compileable with -W -Werror
|
||||
|
||||
Revision 1.1 2002/01/18 20:22:39 tmbinc
|
||||
initial checkin
|
||||
|
||||
Revision 1.1.1.1 2001/10/07 13:01:16 tmbinc
|
||||
Import of ezap2-200110070
|
||||
|
||||
Revision 1.2 1999/01/24 16:00:05 cvs
|
||||
First release of the XMLTree API (ryg)
|
||||
|
||||
Revision 1.1 1999/01/11 23:01:58 cvs
|
||||
Another try to commit this.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef XmlParse_INCLUDED
|
||||
#define XmlParse_INCLUDED 1
|
||||
|
||||
#ifndef XMLPARSEAPI
|
||||
#define XMLPARSEAPI /* as nothing */
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
|
||||
/* XML_UNICODE_WCHAR_T will work only if sizeof(wchar_t) == 2 and wchar_t
|
||||
uses Unicode. */
|
||||
/* Information is UTF-16 encoded as wchar_ts */
|
||||
|
||||
#ifndef XML_UNICODE
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
|
||||
#else /* not XML_UNICODE_WCHAR_T */
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
|
||||
/* Information is UTF-16 encoded as unsigned shorts */
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
|
||||
#else /* not XML_UNICODE */
|
||||
|
||||
/* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
|
||||
#endif /* not XML_UNICODE */
|
||||
|
||||
#endif /* not XML_UNICODE_WCHAR_T */
|
||||
|
||||
#include "xmltok.h"
|
||||
#include "xmlrole.h"
|
||||
#include "hashtab.h"
|
||||
|
||||
typedef struct {
|
||||
int map[256];
|
||||
void *data;
|
||||
int (*convert)(void *data, const char *s);
|
||||
void (*release)(void *data);
|
||||
} XML_Encoding;
|
||||
|
||||
enum XML_Error {
|
||||
XML_ERROR_NONE,
|
||||
XML_ERROR_NO_MEMORY,
|
||||
XML_ERROR_SYNTAX,
|
||||
XML_ERROR_NO_ELEMENTS,
|
||||
XML_ERROR_INVALID_TOKEN,
|
||||
XML_ERROR_UNCLOSED_TOKEN,
|
||||
XML_ERROR_PARTIAL_CHAR,
|
||||
XML_ERROR_TAG_MISMATCH,
|
||||
XML_ERROR_DUPLICATE_ATTRIBUTE,
|
||||
XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
|
||||
XML_ERROR_PARAM_ENTITY_REF,
|
||||
XML_ERROR_UNDEFINED_ENTITY,
|
||||
XML_ERROR_RECURSIVE_ENTITY_REF,
|
||||
XML_ERROR_ASYNC_ENTITY,
|
||||
XML_ERROR_BAD_CHAR_REF,
|
||||
XML_ERROR_BINARY_ENTITY_REF,
|
||||
XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
|
||||
XML_ERROR_MISPLACED_XML_PI,
|
||||
XML_ERROR_UNKNOWN_ENCODING,
|
||||
XML_ERROR_INCORRECT_ENCODING,
|
||||
XML_ERROR_UNCLOSED_CDATA_SECTION,
|
||||
XML_ERROR_EXTERNAL_ENTITY_HANDLING
|
||||
};
|
||||
|
||||
#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */
|
||||
#define INIT_DATA_BUF_SIZE 1024
|
||||
#define INIT_ATTS_SIZE 16
|
||||
#define INIT_BLOCK_SIZE 1024
|
||||
#define INIT_BUFFER_SIZE 1024
|
||||
|
||||
typedef struct tag {
|
||||
struct tag *parent;
|
||||
const char *rawName;
|
||||
int rawNameLength;
|
||||
const XML_Char *name;
|
||||
char *buf;
|
||||
char *bufEnd;
|
||||
} TAG;
|
||||
|
||||
typedef struct {
|
||||
const XML_Char *name;
|
||||
const XML_Char *textPtr;
|
||||
int textLen;
|
||||
const XML_Char *systemId;
|
||||
const XML_Char *base;
|
||||
const XML_Char *publicId;
|
||||
const XML_Char *notation;
|
||||
char open;
|
||||
} ENTITY;
|
||||
|
||||
typedef struct block {
|
||||
struct block *next;
|
||||
int size;
|
||||
XML_Char s[1];
|
||||
} BLOCK;
|
||||
|
||||
typedef struct {
|
||||
BLOCK *blocks;
|
||||
BLOCK *freeBlocks;
|
||||
const XML_Char *end;
|
||||
XML_Char *ptr;
|
||||
XML_Char *start;
|
||||
} STRING_POOL;
|
||||
|
||||
/* The XML_Char before the name is used to determine whether
|
||||
an attribute has been specified. */
|
||||
typedef struct {
|
||||
XML_Char *name;
|
||||
char maybeTokenized;
|
||||
} ATTRIBUTE_ID;
|
||||
|
||||
typedef struct {
|
||||
const ATTRIBUTE_ID *id;
|
||||
char isCdata;
|
||||
const XML_Char *value;
|
||||
} DEFAULT_ATTRIBUTE;
|
||||
|
||||
typedef struct {
|
||||
const XML_Char *name;
|
||||
int nDefaultAtts;
|
||||
int allocDefaultAtts;
|
||||
DEFAULT_ATTRIBUTE *defaultAtts;
|
||||
} ELEMENT_TYPE;
|
||||
|
||||
typedef struct {
|
||||
HASH_TABLE generalEntities;
|
||||
HASH_TABLE elementTypes;
|
||||
HASH_TABLE attributeIds;
|
||||
STRING_POOL pool;
|
||||
int complete;
|
||||
int standalone;
|
||||
const XML_Char *base;
|
||||
} DTD;
|
||||
|
||||
typedef enum XML_Error Processor(void *parser,
|
||||
const char *start,
|
||||
const char *end,
|
||||
const char **endPtr);
|
||||
|
||||
extern Processor prologProcessor;
|
||||
extern Processor prologInitProcessor;
|
||||
extern Processor contentProcessor;
|
||||
extern Processor cdataSectionProcessor;
|
||||
extern Processor epilogProcessor;
|
||||
extern Processor errorProcessor;
|
||||
extern Processor externalEntityInitProcessor;
|
||||
extern Processor externalEntityInitProcessor2;
|
||||
extern Processor externalEntityInitProcessor3;
|
||||
extern Processor externalEntityContentProcessor;
|
||||
|
||||
|
||||
class XML_Parser
|
||||
{
|
||||
friend Processor prologProcessor;
|
||||
friend Processor prologInitProcessor;
|
||||
friend Processor contentProcessor;
|
||||
friend Processor cdataSectionProcessor;
|
||||
friend Processor epilogProcessor;
|
||||
friend Processor errorProcessor;
|
||||
friend Processor externalEntityInitProcessor;
|
||||
friend Processor externalEntityInitProcessor2;
|
||||
friend Processor externalEntityInitProcessor3;
|
||||
friend Processor externalEntityContentProcessor;
|
||||
|
||||
protected:
|
||||
char *buffer;
|
||||
/* first character to be parsed */
|
||||
const char *bufferPtr;
|
||||
/* past last character to be parsed */
|
||||
char *bufferEnd;
|
||||
/* allocated end of buffer */
|
||||
const char *bufferLim;
|
||||
long parseEndByteIndex;
|
||||
const char *parseEndPtr;
|
||||
XML_Char *dataBuf;
|
||||
XML_Char *dataBufEnd;
|
||||
const ENCODING *encoding;
|
||||
INIT_ENCODING initEncoding;
|
||||
const XML_Char *protocolEncodingName;
|
||||
void *unknownEncodingMem;
|
||||
void *unknownEncodingData;
|
||||
void *unknownEncodingHandlerData;
|
||||
void (*unknownEncodingRelease)(void *);
|
||||
PROLOG_STATE prologState;
|
||||
Processor *processor;
|
||||
enum XML_Error errorCode;
|
||||
const char *eventPtr;
|
||||
const char *eventEndPtr;
|
||||
const char *positionPtr;
|
||||
int tagLevel;
|
||||
ENTITY *declEntity;
|
||||
const XML_Char *declNotationName;
|
||||
const XML_Char *declNotationPublicId;
|
||||
ELEMENT_TYPE *declElementType;
|
||||
ATTRIBUTE_ID *declAttributeId;
|
||||
char declAttributeIsCdata;
|
||||
DTD dtd;
|
||||
TAG *tagStack;
|
||||
TAG *freeTagList;
|
||||
int attsSize;
|
||||
ATTRIBUTE *atts;
|
||||
POSITION position;
|
||||
STRING_POOL tempPool;
|
||||
STRING_POOL temp2Pool;
|
||||
char *groupConnector;
|
||||
unsigned groupSize;
|
||||
int hadExternalDoctype;
|
||||
|
||||
int startElementHandler, endElementHandler, characterDataHandler;
|
||||
int processingInstructionHandler, defaultHandler;
|
||||
int unparsedEntityDeclHandler, notationDeclHandler;
|
||||
int externalEntityRefHandler, unknownEncodingHandler;
|
||||
|
||||
virtual enum XML_Error handleUnknownEncoding(const XML_Char *encodingName);
|
||||
virtual enum XML_Error processXmlDecl(int isGeneralTextEntity, const char *, const char *);
|
||||
virtual enum XML_Error initializeEncoding();
|
||||
virtual enum XML_Error doContent(int startTagLevel, const ENCODING *enc, const char *start, const char *end, const char **endPtr);
|
||||
virtual enum XML_Error doCdataSection(const ENCODING *, const char **startPtr, const char *end, const char **nextPtr);
|
||||
virtual enum XML_Error storeAtts(const ENCODING *, const XML_Char *tagName, const char *s);
|
||||
virtual int defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, int isCdata, const XML_Char *dfltValue);
|
||||
virtual enum XML_Error storeAttributeValue(const ENCODING *, int isCdata, const char *, const char *, STRING_POOL *);
|
||||
virtual enum XML_Error appendAttributeValue(const ENCODING *, int isCdata, const char *, const char *, STRING_POOL *);
|
||||
virtual ATTRIBUTE_ID *getAttributeId(const ENCODING *enc, const char *start, const char *end);
|
||||
virtual enum XML_Error storeEntityValue(const char *start, const char *end);
|
||||
virtual int reportProcessingInstruction(const ENCODING *enc, const char *start, const char *end);
|
||||
virtual void reportDefault(const ENCODING *enc, const char *start, const char *end);
|
||||
|
||||
virtual const XML_Char *getOpenEntityNames();
|
||||
virtual int setOpenEntityNames(const XML_Char *openEntityNames);
|
||||
virtual void normalizePublicId(XML_Char *s);
|
||||
|
||||
virtual void StartElementHandler(const XML_Char* /*name*/, const XML_Char** /*atts*/) {};
|
||||
virtual void EndElementHandler(const XML_Char* /*name*/) {};
|
||||
virtual void CharacterDataHandler(const XML_Char* /*s*/, int /*len*/) {};
|
||||
virtual void ProcessingInstructionHandler(const XML_Char* /*target*/, const XML_Char* /*data*/) {};
|
||||
virtual void DefaultHandler(const XML_Char* /*s*/, int /*len*/) {};
|
||||
virtual void UnparsedEntityDeclHandler(const XML_Char* /*entityName*/, const XML_Char* /*base*/, const XML_Char* /*systemId*/, const XML_Char* /*publicId*/, const XML_Char* /*notationName*/) {};
|
||||
virtual void NotationDeclHandler(const XML_Char* /*notationName*/, const XML_Char* /*base*/, const XML_Char* /*systemId*/, const XML_Char* /*publicId*/) {};
|
||||
virtual int ExternalEntityRefHandler(const XML_Char* /*openEntityNames*/, const XML_Char* /*base*/, const XML_Char* /*systemId*/, const XML_Char* /*publicId*/) {return 0;};
|
||||
virtual int UnknownEncodingHandler(void* /*encodingHandlerData*/, const XML_Char* /*name*/, XML_Encoding* /*info*/) {return 0;};
|
||||
|
||||
virtual void DefaultCurrent();
|
||||
|
||||
public:
|
||||
XML_Parser(const XML_Char *encoding);
|
||||
virtual ~XML_Parser();
|
||||
|
||||
virtual int SetBase(const XML_Char *base);
|
||||
virtual const XML_Char *GetBase();
|
||||
|
||||
virtual int Parse(const char *s, int len, int isFinal);
|
||||
virtual void *GetBuffer(int len);
|
||||
virtual int ParseBuffer(int len, int isFinal);
|
||||
virtual XML_Parser *ExternalEntityParserCreate(const XML_Char *openEntityNames, const XML_Char *encoding);
|
||||
|
||||
virtual enum XML_Error GetErrorCode();
|
||||
|
||||
virtual int GetCurrentLineNumber();
|
||||
virtual int GetCurrentColumnNumber();
|
||||
virtual long GetCurrentByteIndex();
|
||||
|
||||
virtual const XML_LChar *ErrorString(int code);
|
||||
};
|
||||
|
||||
#endif /* not XmlParse_INCLUDED */
|
1269
lib/xmltree/xmlrole.c
Normal file
1269
lib/xmltree/xmlrole.c
Normal file
File diff suppressed because it is too large
Load Diff
101
lib/xmltree/xmlrole.h
Normal file
101
lib/xmltree/xmlrole.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef XmlRole_INCLUDED
|
||||
#define XmlRole_INCLUDED 1
|
||||
|
||||
#include "xmltok.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
XML_ROLE_ERROR = -1,
|
||||
XML_ROLE_NONE = 0,
|
||||
XML_ROLE_XML_DECL,
|
||||
XML_ROLE_INSTANCE_START,
|
||||
XML_ROLE_DOCTYPE_NAME,
|
||||
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||
XML_ROLE_DOCTYPE_CLOSE,
|
||||
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||
XML_ROLE_PARAM_ENTITY_NAME,
|
||||
XML_ROLE_ENTITY_VALUE,
|
||||
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_PUBLIC_ID,
|
||||
XML_ROLE_ATTRIBUTE_NAME,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_ELEMENT_NAME,
|
||||
XML_ROLE_CONTENT_ANY,
|
||||
XML_ROLE_CONTENT_EMPTY,
|
||||
XML_ROLE_CONTENT_PCDATA,
|
||||
XML_ROLE_GROUP_OPEN,
|
||||
XML_ROLE_GROUP_CLOSE,
|
||||
XML_ROLE_GROUP_CLOSE_REP,
|
||||
XML_ROLE_GROUP_CLOSE_OPT,
|
||||
XML_ROLE_GROUP_CLOSE_PLUS,
|
||||
XML_ROLE_GROUP_CHOICE,
|
||||
XML_ROLE_GROUP_SEQUENCE,
|
||||
XML_ROLE_CONTENT_ELEMENT,
|
||||
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||
XML_ROLE_PARAM_ENTITY_REF
|
||||
};
|
||||
|
||||
typedef struct prolog_state {
|
||||
int (*handler)(struct prolog_state *state,
|
||||
int tok,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const ENCODING *enc);
|
||||
unsigned level;
|
||||
} PROLOG_STATE;
|
||||
|
||||
void XMLTOKAPI XmlPrologStateInit(PROLOG_STATE *);
|
||||
|
||||
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||
(((state)->handler)(state, tok, ptr, end, enc))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlRole_INCLUDED */
|
1655
lib/xmltree/xmltimpl.c
Normal file
1655
lib/xmltree/xmltimpl.c
Normal file
File diff suppressed because it is too large
Load Diff
60
lib/xmltree/xmltimpl.h
Normal file
60
lib/xmltree/xmltimpl.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
enum {
|
||||
BT_NONXML,
|
||||
BT_MALFORM,
|
||||
BT_LT,
|
||||
BT_AMP,
|
||||
BT_RSQB,
|
||||
BT_LEAD2,
|
||||
BT_LEAD3,
|
||||
BT_LEAD4,
|
||||
BT_TRAIL,
|
||||
BT_CR,
|
||||
BT_LF,
|
||||
BT_GT,
|
||||
BT_QUOT,
|
||||
BT_APOS,
|
||||
BT_EQUALS,
|
||||
BT_QUEST,
|
||||
BT_EXCL,
|
||||
BT_SOL,
|
||||
BT_SEMI,
|
||||
BT_NUM,
|
||||
BT_LSQB,
|
||||
BT_S,
|
||||
BT_NMSTRT,
|
||||
BT_HEX,
|
||||
BT_DIGIT,
|
||||
BT_NAME,
|
||||
BT_MINUS,
|
||||
BT_OTHER, /* known not to be a name or name start character */
|
||||
BT_NONASCII, /* might be a name or name start character */
|
||||
BT_PERCNT,
|
||||
BT_LPAR,
|
||||
BT_RPAR,
|
||||
BT_AST,
|
||||
BT_PLUS,
|
||||
BT_COMMA,
|
||||
BT_VERBAR
|
||||
};
|
||||
|
||||
#include <stddef.h>
|
1164
lib/xmltree/xmltok.c
Normal file
1164
lib/xmltree/xmltok.c
Normal file
File diff suppressed because it is too large
Load Diff
276
lib/xmltree/xmltok.h
Normal file
276
lib/xmltree/xmltok.h
Normal file
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef XmlTok_INCLUDED
|
||||
#define XmlTok_INCLUDED 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef XMLTOKAPI
|
||||
#define XMLTOKAPI /* as nothing */
|
||||
#endif
|
||||
|
||||
/* The following token may be returned by XmlContentTok */
|
||||
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be start of
|
||||
illegal ]]> sequence */
|
||||
/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
|
||||
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
|
||||
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
|
||||
might be part of CRLF sequence */
|
||||
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
|
||||
#define XML_TOK_PARTIAL -1 /* only part of a token */
|
||||
#define XML_TOK_INVALID 0
|
||||
|
||||
/* The following tokens are returned by XmlContentTok; some are also
|
||||
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok */
|
||||
|
||||
#define XML_TOK_START_TAG_WITH_ATTS 1
|
||||
#define XML_TOK_START_TAG_NO_ATTS 2
|
||||
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
|
||||
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||
#define XML_TOK_END_TAG 5
|
||||
#define XML_TOK_DATA_CHARS 6
|
||||
#define XML_TOK_DATA_NEWLINE 7
|
||||
#define XML_TOK_CDATA_SECT_OPEN 8
|
||||
#define XML_TOK_ENTITY_REF 9
|
||||
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||
|
||||
/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
|
||||
#define XML_TOK_PI 11 /* processing instruction */
|
||||
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
|
||||
#define XML_TOK_COMMENT 13
|
||||
#define XML_TOK_BOM 14 /* Byte order mark */
|
||||
|
||||
/* The following tokens are returned only by XmlPrologTok */
|
||||
#define XML_TOK_PROLOG_S 15
|
||||
#define XML_TOK_DECL_OPEN 16 /* <!foo */
|
||||
#define XML_TOK_DECL_CLOSE 17 /* > */
|
||||
#define XML_TOK_NAME 18
|
||||
#define XML_TOK_NMTOKEN 19
|
||||
#define XML_TOK_POUND_NAME 20 /* #name */
|
||||
#define XML_TOK_OR 21 /* | */
|
||||
#define XML_TOK_PERCENT 22
|
||||
#define XML_TOK_OPEN_PAREN 23
|
||||
#define XML_TOK_CLOSE_PAREN 24
|
||||
#define XML_TOK_OPEN_BRACKET 25
|
||||
#define XML_TOK_CLOSE_BRACKET 26
|
||||
#define XML_TOK_LITERAL 27
|
||||
#define XML_TOK_PARAM_ENTITY_REF 28
|
||||
#define XML_TOK_INSTANCE_START 29
|
||||
|
||||
/* The following occur only in element type declarations */
|
||||
#define XML_TOK_NAME_QUESTION 30 /* name? */
|
||||
#define XML_TOK_NAME_ASTERISK 31 /* name* */
|
||||
#define XML_TOK_NAME_PLUS 32 /* name+ */
|
||||
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
|
||||
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
|
||||
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
|
||||
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
|
||||
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
|
||||
#define XML_TOK_COMMA 38
|
||||
|
||||
/* The following token is returned only by XmlAttributeValueTok */
|
||||
#define XML_TOK_ATTRIBUTE_VALUE_S 39
|
||||
|
||||
/* The following token is returned only by XmlCdataSectionTok */
|
||||
#define XML_TOK_CDATA_SECT_CLOSE 40
|
||||
|
||||
#define XML_N_STATES 3
|
||||
#define XML_PROLOG_STATE 0
|
||||
#define XML_CONTENT_STATE 1
|
||||
#define XML_CDATA_SECTION_STATE 2
|
||||
|
||||
#define XML_N_LITERAL_TYPES 2
|
||||
#define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||
#define XML_ENTITY_VALUE_LITERAL 1
|
||||
|
||||
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
|
||||
#define XML_UTF8_ENCODE_MAX 4
|
||||
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
|
||||
#define XML_UTF16_ENCODE_MAX 2
|
||||
|
||||
typedef struct position {
|
||||
/* first line and first column are 0 not 1 */
|
||||
unsigned long lineNumber;
|
||||
unsigned long columnNumber;
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *valuePtr;
|
||||
const char *valueEnd;
|
||||
char normalized;
|
||||
} ATTRIBUTE;
|
||||
|
||||
struct encoding;
|
||||
typedef struct encoding ENCODING;
|
||||
|
||||
struct encoding {
|
||||
int (*scanners[XML_N_STATES])(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char **);
|
||||
int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char **);
|
||||
int (*sameName)(const ENCODING *,
|
||||
const char *, const char *);
|
||||
int (*nameMatchesAscii)(const ENCODING *,
|
||||
const char *, const char *);
|
||||
int (*nameLength)(const ENCODING *, const char *);
|
||||
const char *(*skipS)(const ENCODING *, const char *);
|
||||
int (*getAtts)(const ENCODING *enc, const char *ptr,
|
||||
int attsMax, ATTRIBUTE *atts);
|
||||
int (*charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||
int (*predefinedEntityName)(const ENCODING *, const char *, const char *);
|
||||
void (*updatePosition)(const ENCODING *,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
POSITION *);
|
||||
int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **badPtr);
|
||||
void (*utf8Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
char **toP,
|
||||
const char *toLim);
|
||||
void (*utf16Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
unsigned short **toP,
|
||||
const unsigned short *toLim);
|
||||
int minBytesPerChar;
|
||||
char isUtf8;
|
||||
char isUtf16;
|
||||
};
|
||||
|
||||
/*
|
||||
Scan the string starting at ptr until the end of the next complete token,
|
||||
but do not scan past eptr. Return an integer giving the type of token.
|
||||
|
||||
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_PARTIAL when the string does not contain a complete token;
|
||||
nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_INVALID when the string does not start a valid token; nextTokPtr
|
||||
will be set to point to the character which made the token invalid.
|
||||
|
||||
Otherwise the string starts with a valid token; nextTokPtr will be set to point
|
||||
to the character following the end of that token.
|
||||
|
||||
Each data character counts as a single token, but adjacent data characters
|
||||
may be returned together. Similarly for characters in the prolog outside
|
||||
literals, comments and processing instructions.
|
||||
*/
|
||||
|
||||
|
||||
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
|
||||
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlContentTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
/* This is used for performing a 2nd-level tokenization on
|
||||
the content of a literal that has already been returned by XmlTok. */
|
||||
|
||||
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
|
||||
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||
|
||||
#define XmlNameMatchesAscii(enc, ptr1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, ptr2))
|
||||
|
||||
#define XmlNameLength(enc, ptr) \
|
||||
(((enc)->nameLength)(enc, ptr))
|
||||
|
||||
#define XmlSkipS(enc, ptr) \
|
||||
(((enc)->skipS)(enc, ptr))
|
||||
|
||||
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
|
||||
(((enc)->getAtts)(enc, ptr, attsMax, atts))
|
||||
|
||||
#define XmlCharRefNumber(enc, ptr) \
|
||||
(((enc)->charRefNumber)(enc, ptr))
|
||||
|
||||
#define XmlPredefinedEntityName(enc, ptr, end) \
|
||||
(((enc)->predefinedEntityName)(enc, ptr, end))
|
||||
|
||||
#define XmlUpdatePosition(enc, ptr, end, pos) \
|
||||
(((enc)->updatePosition)(enc, ptr, end, pos))
|
||||
|
||||
#define XmlIsPublicId(enc, ptr, end, badPtr) \
|
||||
(((enc)->isPublicId)(enc, ptr, end, badPtr))
|
||||
|
||||
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
typedef struct {
|
||||
ENCODING initEnc;
|
||||
const ENCODING **encPtr;
|
||||
} INIT_ENCODING;
|
||||
|
||||
int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr,
|
||||
int *standalonePtr);
|
||||
|
||||
int XMLTOKAPI XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncoding();
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncoding();
|
||||
int XMLTOKAPI XmlUtf8Encode(int charNumber, char *buf);
|
||||
int XMLTOKAPI XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||
|
||||
int XMLTOKAPI XmlSizeOfUnknownEncoding();
|
||||
ENCODING XMLTOKAPI *
|
||||
XmlInitUnknownEncoding(void *mem,
|
||||
int *table,
|
||||
int (*convert)(void *userData, const char *p),
|
||||
void *userData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlTok_INCLUDED */
|
62
lib/xmltree/xmltok/latin1tab.h
Normal file
62
lib/xmltree/xmltok/latin1tab.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998, 1999
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms
|
||||
of the GNU General Public License (the "GPL"), in which case the
|
||||
provisions of the GPL are applicable instead of those above. If you
|
||||
wish to allow use of your version of this file only under the terms of
|
||||
the GPL and not to allow others to use your version of this file under
|
||||
the MPL, indicate your decision by deleting the provisions above and
|
||||
replace them with the notice and other provisions required by the
|
||||
GPL. If you do not delete the provisions above, a recipient may use
|
||||
your version of this file under either the MPL or the GPL.
|
||||
*/
|
||||
|
||||
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
|
||||
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
150
lib/xmltree/xmltok/nametab.h
Normal file
150
lib/xmltree/xmltok/nametab.h
Normal file
@@ -0,0 +1,150 @@
|
||||
static const unsigned namingBitmap[] = {
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
|
||||
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
|
||||
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
|
||||
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
|
||||
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
|
||||
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
|
||||
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
|
||||
0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
|
||||
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
|
||||
0x40000000, 0xF580C900, 0x00000007, 0x02010800,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
|
||||
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
|
||||
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
|
||||
0x00000000, 0x00004C40, 0x00000000, 0x00000000,
|
||||
0x00000007, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
|
||||
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
|
||||
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
|
||||
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
|
||||
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
|
||||
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
|
||||
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
|
||||
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
|
||||
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
|
||||
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
|
||||
0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
|
||||
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
|
||||
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
|
||||
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
|
||||
};
|
||||
static const unsigned char nmstrtPages[] = {
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
|
||||
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const unsigned char namePages[] = {
|
||||
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
|
||||
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
63
lib/xmltree/xmltok/utf8tab.h
Normal file
63
lib/xmltree/xmltok/utf8tab.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998, 1999
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms
|
||||
of the GNU General Public License (the "GPL"), in which case the
|
||||
provisions of the GPL are applicable instead of those above. If you
|
||||
wish to allow use of your version of this file only under the terms of
|
||||
the GPL and not to allow others to use your version of this file under
|
||||
the MPL, indicate your decision by deleting the provisions above and
|
||||
replace them with the notice and other provisions required by the
|
||||
GPL. If you do not delete the provisions above, a recipient may use
|
||||
your version of this file under either the MPL or the GPL.
|
||||
*/
|
||||
|
||||
|
||||
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
|
||||
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
|
63
lib/xmltree/xmltok/xmldef.h
Normal file
63
lib/xmltree/xmltok/xmldef.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998, 1999
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms
|
||||
of the GNU General Public License (the "GPL"), in which case the
|
||||
provisions of the GPL are applicable instead of those above. If you
|
||||
wish to allow use of your version of this file only under the terms of
|
||||
the GPL and not to allow others to use your version of this file under
|
||||
the MPL, indicate your decision by deleting the provisions above and
|
||||
replace them with the notice and other provisions required by the
|
||||
GPL. If you do not delete the provisions above, a recipient may use
|
||||
your version of this file under either the MPL or the GPL.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef XML_WINLIB
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
|
||||
#define malloc(x) HeapAlloc(GetProcessHeap(), 0, (x))
|
||||
#define calloc(x, y) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x)*(y))
|
||||
#define free(x) HeapFree(GetProcessHeap(), 0, (x))
|
||||
#define realloc(x, y) HeapReAlloc(GetProcessHeap(), 0, x, y)
|
||||
#define abort() /* as nothing */
|
||||
|
||||
#else /* not XML_WINLIB */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#endif /* not XML_WINLIB */
|
||||
|
||||
/* This file can be used for any definitions needed in
|
||||
particular environments. */
|
||||
|
||||
#ifdef MOZILLA
|
||||
|
||||
#include "nspr.h"
|
||||
#define malloc(x) PR_Malloc(x)
|
||||
#define realloc(x, y) PR_Realloc((x), (y))
|
||||
#define calloc(x, y) PR_Calloc((x),(y))
|
||||
#define free(x) PR_Free(x)
|
||||
#define int int32
|
||||
|
||||
#endif /* MOZILLA */
|
446
lib/xmltree/xmltree.cpp
Normal file
446
lib/xmltree/xmltree.cpp
Normal file
@@ -0,0 +1,446 @@
|
||||
/* xmltree.cpp
|
||||
*
|
||||
* XMLTree API implementation
|
||||
*
|
||||
* $Id: xmltree.cpp,v 1.2 2003/03/14 05:13:04 obi Exp $
|
||||
*
|
||||
* Changelog:
|
||||
* $Log: xmltree.cpp,v $
|
||||
* Revision 1.2 2003/03/14 05:13:04 obi
|
||||
* compileable with -W -Werror
|
||||
*
|
||||
* Revision 1.1 2002/01/18 20:22:39 tmbinc
|
||||
* initial checkin
|
||||
*
|
||||
* Revision 1.1.1.1 2001/10/07 13:01:18 tmbinc
|
||||
* Import of ezap2-200110070
|
||||
*
|
||||
* Revision 1.4 1999/02/26 13:17:21 cvs
|
||||
* - thousands of bugs fixed (really)
|
||||
* - modifications in the XML part
|
||||
* - added a new object for testing, cpiwButton (usable already, see
|
||||
* win32/ts.cpp)
|
||||
* - modified ts.cpp to create a pseudo-GUI again (for testing the
|
||||
* buttons)
|
||||
* - ts now exits on a click in the windows
|
||||
* - ts has no titlebar anymore (will soon by replace by a special
|
||||
* widget)
|
||||
*
|
||||
* (ryg)
|
||||
*
|
||||
* Revision 1.3 1999/01/25 18:05:27 cvs
|
||||
* ARG! tmb, next time you look bevor you say shit, okay? (ryg)
|
||||
*
|
||||
* Revision 1.1 1999/01/24 16:01:14 cvs
|
||||
* First release of the XMLTree API (ryg)
|
||||
*
|
||||
*/
|
||||
|
||||
#define stricmp strcasecmp
|
||||
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "xmltree.h"
|
||||
|
||||
/* XMLAttribute class */
|
||||
|
||||
XMLAttribute::XMLAttribute()
|
||||
{
|
||||
name=value=0;
|
||||
next=prev=0;
|
||||
}
|
||||
|
||||
XMLAttribute::XMLAttribute(char *nam, char *val)
|
||||
{
|
||||
name=value=0;
|
||||
next=prev=0;
|
||||
|
||||
SetName(nam);
|
||||
SetValue(val);
|
||||
}
|
||||
|
||||
XMLAttribute::XMLAttribute(XMLAttribute *prv, char *nam, char *val)
|
||||
{
|
||||
name=value=0;
|
||||
|
||||
SetName(nam);
|
||||
SetValue(val);
|
||||
SetPrevious(prv);
|
||||
|
||||
next=0;
|
||||
}
|
||||
|
||||
XMLAttribute::XMLAttribute(XMLAttribute *prv, char *nam, char *val, XMLAttribute *nxt)
|
||||
{
|
||||
name=value=0;
|
||||
|
||||
SetName(nam);
|
||||
SetValue(val);
|
||||
|
||||
SetPrevious(prv);
|
||||
SetNext(nxt);
|
||||
}
|
||||
|
||||
XMLAttribute::~XMLAttribute()
|
||||
{
|
||||
if (name) { free(name); name=0; };
|
||||
if (value) { free(value); value=0; };
|
||||
|
||||
next=prev=0;
|
||||
}
|
||||
|
||||
void XMLAttribute::SetName(char *nam)
|
||||
{
|
||||
if (name) free(name);
|
||||
|
||||
name=strdup(nam);
|
||||
}
|
||||
|
||||
void XMLAttribute::SetValue(char *val)
|
||||
{
|
||||
if (value) free(value);
|
||||
|
||||
value=strdup(val);
|
||||
}
|
||||
|
||||
void XMLAttribute::SetNext(XMLAttribute *nxt)
|
||||
{
|
||||
next=nxt;
|
||||
}
|
||||
|
||||
void XMLAttribute::SetPrevious(XMLAttribute *prv)
|
||||
{
|
||||
prev=prv;
|
||||
}
|
||||
|
||||
/* XMLTreeNode class */
|
||||
|
||||
XMLTreeNode::XMLTreeNode(XMLTreeNode *prnt)
|
||||
{
|
||||
attributes=0;
|
||||
next=child=0;
|
||||
type=data=0;
|
||||
dataSize=0;
|
||||
|
||||
SetMatchingMode(prnt?prnt->mmode:MATCH_CASE);
|
||||
SetParent(prnt);
|
||||
}
|
||||
|
||||
XMLTreeNode::XMLTreeNode(XMLTreeNode *prnt, char *typ)
|
||||
{
|
||||
attributes=0;
|
||||
next=child=0;
|
||||
type=data=0;
|
||||
dataSize=0;
|
||||
|
||||
SetType(typ);
|
||||
SetMatchingMode(prnt?prnt->mmode:MATCH_CASE);
|
||||
SetParent(prnt);
|
||||
}
|
||||
|
||||
XMLTreeNode::XMLTreeNode(XMLTreeNode *prnt, char *typ, char *dta, unsigned int dtaSize)
|
||||
{
|
||||
attributes=0;
|
||||
next=child=0;
|
||||
type=0;
|
||||
|
||||
SetType(typ);
|
||||
SetData(dta, dtaSize);
|
||||
SetMatchingMode(prnt?prnt->mmode:MATCH_CASE);
|
||||
SetParent(prnt);
|
||||
}
|
||||
|
||||
XMLTreeNode::XMLTreeNode(XMLTreeNode *prnt, char *typ, char *dta, unsigned int dtaSize, XMLTreeNode *cld)
|
||||
{
|
||||
attributes=0;
|
||||
next=0;
|
||||
type=0;
|
||||
|
||||
SetType(typ);
|
||||
SetData(dta, dtaSize);
|
||||
SetChild(cld);
|
||||
SetMatchingMode(prnt?prnt->mmode:MATCH_CASE);
|
||||
SetParent(prnt);
|
||||
}
|
||||
|
||||
XMLTreeNode::XMLTreeNode(XMLTreeNode *prnt, char *typ, char *dta, unsigned int dtaSize, XMLTreeNode *cld, XMLTreeNode *nxt)
|
||||
{
|
||||
attributes=0;
|
||||
type=0;
|
||||
|
||||
SetType(typ);
|
||||
SetData(dta, dtaSize);
|
||||
SetChild(cld);
|
||||
SetNext(nxt);
|
||||
SetMatchingMode(prnt?prnt->mmode:MATCH_CASE);
|
||||
SetParent(prnt);
|
||||
}
|
||||
|
||||
XMLTreeNode::~XMLTreeNode()
|
||||
{
|
||||
DeleteAttributes();
|
||||
DeleteChildren();
|
||||
|
||||
if (type) { free(type); type=0; };
|
||||
if (data) { delete[] data; dataSize=0; };
|
||||
|
||||
next=0;
|
||||
}
|
||||
|
||||
XMLAttribute *XMLTreeNode::GetAttribute(char *name) const
|
||||
{
|
||||
XMLAttribute *a;
|
||||
|
||||
a=attributes;
|
||||
|
||||
while (a)
|
||||
{
|
||||
if (a->GetName())
|
||||
{
|
||||
switch (mmode)
|
||||
{
|
||||
case MATCH_CASE:
|
||||
if (!strcmp(a->GetName(), name)) return a;
|
||||
|
||||
case MATCH_NOCASE:
|
||||
if (!stricmp(a->GetName(), name)) return a;
|
||||
}
|
||||
}
|
||||
|
||||
a=a->GetNext();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *XMLTreeNode::GetAttributeValue(char *name) const
|
||||
{
|
||||
XMLAttribute *a;
|
||||
|
||||
a=GetAttribute(name);
|
||||
if (a) return a->GetValue();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XMLTreeNode::AddNode(XMLTreeNode *node, addmode mode)
|
||||
{
|
||||
XMLTreeNode *n=0;
|
||||
|
||||
if (!node) return;
|
||||
node->next=0;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case ADD_NEIGHBOUR:
|
||||
n=this;
|
||||
|
||||
case ADD_CHILD:
|
||||
n=child;
|
||||
}
|
||||
|
||||
if (n)
|
||||
{
|
||||
while (n->next) n=n->next;
|
||||
|
||||
n->next=node;
|
||||
}
|
||||
else
|
||||
child=node;
|
||||
}
|
||||
|
||||
XMLTreeNode *XMLTreeNode::AddNode(addmode mode)
|
||||
{
|
||||
XMLTreeNode *n=new XMLTreeNode(this);
|
||||
|
||||
AddNode(n, mode);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void XMLTreeNode::SetNext(XMLTreeNode *nxt)
|
||||
{
|
||||
next=nxt;
|
||||
}
|
||||
|
||||
void XMLTreeNode::SetChild(XMLTreeNode *cld)
|
||||
{
|
||||
child=cld;
|
||||
}
|
||||
|
||||
void XMLTreeNode::SetParent(XMLTreeNode *prnt)
|
||||
{
|
||||
parent=prnt;
|
||||
}
|
||||
|
||||
void XMLTreeNode::SetAttribute(char *name, char *value)
|
||||
{
|
||||
XMLAttribute *a;
|
||||
|
||||
a=GetAttribute(name);
|
||||
|
||||
if (a)
|
||||
a->SetValue(value);
|
||||
else
|
||||
{
|
||||
a=attributes;
|
||||
|
||||
if (a)
|
||||
{
|
||||
while (a->GetNext()) a=a->GetNext();
|
||||
|
||||
a->SetNext(new XMLAttribute(a, name, value, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
a=attributes=new XMLAttribute(0, name, value, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void XMLTreeNode::SetType(char *typ)
|
||||
{
|
||||
if (type) free(type);
|
||||
|
||||
type=strdup(typ);
|
||||
}
|
||||
|
||||
void XMLTreeNode::SetData(char *dat, unsigned int datSize)
|
||||
{
|
||||
if (data) delete[] data;
|
||||
|
||||
dataSize=datSize;
|
||||
data=new char[dataSize+1];
|
||||
data[dataSize]=0;
|
||||
|
||||
memcpy(data, dat, datSize);
|
||||
}
|
||||
|
||||
void XMLTreeNode::AppendData(char *dat, unsigned int datSize)
|
||||
{
|
||||
if (!data)
|
||||
SetData(dat, datSize);
|
||||
else
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp=new char[dataSize+datSize];
|
||||
memcpy(tmp, data, dataSize);
|
||||
memcpy(tmp+dataSize, dat, datSize);
|
||||
|
||||
SetData(tmp, dataSize+datSize);
|
||||
|
||||
delete[] tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void XMLTreeNode::SetPDataOff(int pdo)
|
||||
{
|
||||
pdataOff=pdo;
|
||||
}
|
||||
|
||||
void XMLTreeNode::SetMatchingMode(matchmode mode)
|
||||
{
|
||||
mmode=mode;
|
||||
};
|
||||
|
||||
void XMLTreeNode::DeleteAttribute(char *name)
|
||||
{
|
||||
XMLAttribute *a, *next, *prev;
|
||||
|
||||
a=GetAttribute(name);
|
||||
if (!a) return;
|
||||
|
||||
next=a->GetNext();
|
||||
prev=a->GetPrevious();
|
||||
|
||||
if (prev) prev->SetNext(next);
|
||||
if (next) next->SetPrevious(prev);
|
||||
|
||||
delete a;
|
||||
}
|
||||
|
||||
void XMLTreeNode::DeleteAttributes()
|
||||
{
|
||||
XMLAttribute *a, *b;
|
||||
|
||||
a=attributes;
|
||||
|
||||
while (a)
|
||||
{
|
||||
b=a->GetNext(); delete a;
|
||||
a=b;
|
||||
}
|
||||
|
||||
attributes=0;
|
||||
}
|
||||
|
||||
void XMLTreeNode::DeleteChildren()
|
||||
{
|
||||
XMLTreeNode *a, *b;
|
||||
|
||||
if (!child) return;
|
||||
a=child;
|
||||
|
||||
while (a)
|
||||
{
|
||||
b=a->next; delete a;
|
||||
a=b;
|
||||
}
|
||||
|
||||
child=0;
|
||||
}
|
||||
|
||||
void XMLTreeParser::StartElementHandler(const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
XMLTreeNode *n;
|
||||
const XML_Char **a=atts;
|
||||
|
||||
n=new XMLTreeNode(current, (char *) name);
|
||||
|
||||
if (a)
|
||||
{
|
||||
while (*a) { n->SetAttribute((char *) a[0], (char *) a[1]); a+=2; };
|
||||
}
|
||||
|
||||
if (current)
|
||||
{
|
||||
n->SetPDataOff(current->GetDataSize());
|
||||
current->AddNode(n, XMLTreeNode::ADD_CHILD);
|
||||
current=n;
|
||||
}
|
||||
else
|
||||
{
|
||||
root=current=n;
|
||||
}
|
||||
}
|
||||
|
||||
void XMLTreeParser::EndElementHandler(const XML_Char* /*name*/)
|
||||
{
|
||||
if (current)
|
||||
{
|
||||
if (current->GetParent()) current=current->GetParent();
|
||||
}
|
||||
}
|
||||
|
||||
void XMLTreeParser::CharacterDataHandler(const XML_Char *s, int len)
|
||||
{
|
||||
if (current)
|
||||
current->AppendData((char *) s, len);
|
||||
}
|
||||
|
||||
XMLTreeParser::XMLTreeParser(const XML_Char *encoding): XML_Parser(encoding)
|
||||
{
|
||||
root=current=0;
|
||||
|
||||
startElementHandler=endElementHandler=characterDataHandler=1;
|
||||
}
|
||||
|
||||
XMLTreeParser::~XMLTreeParser()
|
||||
{
|
||||
if (root)
|
||||
{
|
||||
delete root;
|
||||
root=current=0;
|
||||
}
|
||||
}
|
156
lib/xmltree/xmltree.h
Normal file
156
lib/xmltree/xmltree.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/* xmltree.h
|
||||
*
|
||||
* XMLTree API header
|
||||
*
|
||||
* $Id: xmltree.h,v 1.1 2002/01/18 20:22:39 tmbinc Exp $
|
||||
*
|
||||
* Changelog:
|
||||
* $Log: xmltree.h,v $
|
||||
* Revision 1.1 2002/01/18 20:22:39 tmbinc
|
||||
* initial checkin
|
||||
*
|
||||
* Revision 1.1.1.1 2001/10/07 13:01:15 tmbinc
|
||||
* Import of ezap2-200110070
|
||||
*
|
||||
* Revision 1.4 1999/02/26 13:17:22 cvs
|
||||
* - thousands of bugs fixed (really)
|
||||
* - modifications in the XML part
|
||||
* - added a new object for testing, cpiwButton (usable already, see
|
||||
* win32/ts.cpp)
|
||||
* - modified ts.cpp to create a pseudo-GUI again (for testing the
|
||||
* buttons)
|
||||
* - ts now exits on a click in the windows
|
||||
* - ts has no titlebar anymore (will soon by replace by a special
|
||||
* widget)
|
||||
*
|
||||
* (ryg)
|
||||
*
|
||||
* Revision 1.3 1999/01/25 18:05:27 cvs
|
||||
* ARG! tmb, next time you look bevor you say shit, okay? (ryg)
|
||||
*
|
||||
* Revision 1.1 1999/01/24 16:01:15 cvs
|
||||
* First release of the XMLTree API (ryg)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __XMLTREE_H
|
||||
#define __XMLTREE_H
|
||||
|
||||
#include "xmlparse.h"
|
||||
|
||||
class XMLAttribute
|
||||
{
|
||||
private:
|
||||
char *name, *value;
|
||||
XMLAttribute *next, *prev;
|
||||
|
||||
public:
|
||||
XMLAttribute();
|
||||
XMLAttribute(char *nam, char *val);
|
||||
XMLAttribute(XMLAttribute *prv, char *nam, char *val);
|
||||
XMLAttribute(XMLAttribute *prv, char *nam, char *val, XMLAttribute *nxt);
|
||||
~XMLAttribute();
|
||||
|
||||
char *GetName() { return name; }
|
||||
char *GetValue() { return value; }
|
||||
XMLAttribute *GetNext() { return next; }
|
||||
XMLAttribute *GetPrevious() { return prev; }
|
||||
|
||||
void SetName(char *nam);
|
||||
void SetValue(char *val);
|
||||
void SetNext(XMLAttribute *nxt);
|
||||
void SetPrevious(XMLAttribute *prv);
|
||||
};
|
||||
|
||||
class XMLTreeNode
|
||||
{
|
||||
public:
|
||||
// matching mode: case insensitive or case sensitive?
|
||||
|
||||
enum matchmode
|
||||
{
|
||||
MATCH_CASE = 0,
|
||||
MATCH_NOCASE = 1
|
||||
};
|
||||
|
||||
private:
|
||||
XMLAttribute *attributes;
|
||||
XMLTreeNode *next;
|
||||
XMLTreeNode *child;
|
||||
XMLTreeNode *parent;
|
||||
|
||||
char *type;
|
||||
char *data;
|
||||
unsigned int dataSize;
|
||||
unsigned int pdataOff;
|
||||
|
||||
matchmode mmode;
|
||||
|
||||
public:
|
||||
XMLTreeNode(XMLTreeNode *prnt);
|
||||
XMLTreeNode(XMLTreeNode *prnt, char *typ);
|
||||
XMLTreeNode(XMLTreeNode *prnt, char *typ, char *dta, unsigned int dtaSize);
|
||||
XMLTreeNode(XMLTreeNode *prnt, char *typ, char *dta, unsigned int dtaSize, XMLTreeNode *cld);
|
||||
XMLTreeNode(XMLTreeNode *prnt, char *typ, char *dta, unsigned int dtaSize, XMLTreeNode *cld, XMLTreeNode *nxt);
|
||||
~XMLTreeNode();
|
||||
|
||||
// add modes: add the node as child or neighbour?
|
||||
|
||||
enum addmode
|
||||
{
|
||||
ADD_NEIGHBOUR = 0,
|
||||
ADD_CHILD = 1
|
||||
};
|
||||
|
||||
XMLTreeNode *GetNext() const { return next; }
|
||||
XMLTreeNode *GetChild() const { return child; }
|
||||
XMLTreeNode *GetParent() const { return parent; };
|
||||
|
||||
XMLAttribute *GetAttributes() const { return attributes; }
|
||||
XMLAttribute *GetAttribute(char *name) const;
|
||||
char *GetAttributeValue(char *name) const;
|
||||
|
||||
matchmode GetMatchingMode() const { return mmode; }
|
||||
|
||||
char *GetType() const { return type; }
|
||||
char *GetData() const { return data; }
|
||||
unsigned int GetDataSize() const { return dataSize; }
|
||||
unsigned int GetPDataOff() const { return pdataOff; }
|
||||
|
||||
void AddNode(XMLTreeNode *node, addmode mode);
|
||||
XMLTreeNode *AddNode(addmode mode);
|
||||
|
||||
void SetNext(XMLTreeNode *nxt);
|
||||
void SetChild(XMLTreeNode *cld);
|
||||
void SetParent(XMLTreeNode *prnt);
|
||||
|
||||
void SetAttribute(char *name, char *value);
|
||||
void SetType(char *typ);
|
||||
void SetData(char *dat, unsigned int datSize);
|
||||
void AppendData(char *dat, unsigned int datSize);
|
||||
void SetPDataOff(int pdo);
|
||||
|
||||
void SetMatchingMode(matchmode mode);
|
||||
|
||||
void DeleteAttribute(char *name);
|
||||
void DeleteAttributes();
|
||||
void DeleteChildren();
|
||||
};
|
||||
|
||||
class XMLTreeParser:public XML_Parser
|
||||
{
|
||||
protected:
|
||||
XMLTreeNode *root, *current;
|
||||
|
||||
virtual void StartElementHandler(const XML_Char *name, const XML_Char **atts);
|
||||
virtual void EndElementHandler(const XML_Char *name);
|
||||
virtual void CharacterDataHandler(const XML_Char *s, int len);
|
||||
|
||||
public:
|
||||
XMLTreeParser(const XML_Char *encoding);
|
||||
virtual ~XMLTreeParser();
|
||||
|
||||
XMLTreeNode *RootNode() { return root; };
|
||||
};
|
||||
|
||||
#endif // __XMLTREE_H
|
Reference in New Issue
Block a user