License changes Round 2. Expat. Updating licensing to be consistent with latest version of expat (MIT/X); relicensing NS-contributed code under expat's license (except the build system, which is tri-licensed.) Removing outdated licensing information and adding new COPYING file. This has been checked with James Clark. Bug 98089.

This commit is contained in:
gerv%gerv.net 2001-09-29 00:10:42 +00:00
Родитель a9b96af2fb
Коммит e4842001f0
64 изменённых файлов: 142 добавлений и 7378 удалений

Просмотреть файл

@ -1,427 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <string.h>
#include <stdio.h>
#include <stddef.h>
struct range {
int start;
int end;
};
struct range nmstrt[] = {
{ '_' },
{ ':' },
/* BaseChar */
{ 0x0041, 0x005a },
{ 0x0061, 0x007a },
{ 0x00c0, 0x00d6 },
{ 0x00d8, 0x00f6 },
{ 0x00f8, 0x00ff },
{ 0x0100, 0x0131 },
{ 0x0134, 0x013e },
{ 0x0141, 0x0148 },
{ 0x014a, 0x017e },
{ 0x0180, 0x01c3 },
{ 0x01cd, 0x01f0 },
{ 0x01f4, 0x01f5 },
{ 0x01fa, 0x0217 },
{ 0x0250, 0x02a8 },
{ 0x02bb, 0x02c1 },
{ 0x0386 },
{ 0x0388, 0x038a },
{ 0x038c },
{ 0x038e, 0x03a1 },
{ 0x03a3, 0x03ce },
{ 0x03d0, 0x03d6 },
{ 0x03da },
{ 0x03dc },
{ 0x03de },
{ 0x03e0 },
{ 0x03e2, 0x03f3 },
{ 0x0401, 0x040c },
{ 0x040e, 0x044f },
{ 0x0451, 0x045c },
{ 0x045e, 0x0481 },
{ 0x0490, 0x04c4 },
{ 0x04c7, 0x04c8 },
{ 0x04cb, 0x04cc },
{ 0x04d0, 0x04eb },
{ 0x04ee, 0x04f5 },
{ 0x04f8, 0x04f9 },
{ 0x0531, 0x0556 },
{ 0x0559 },
{ 0x0561, 0x0586 },
{ 0x05d0, 0x05ea },
{ 0x05f0, 0x05f2 },
{ 0x0621, 0x063a },
{ 0x0641, 0x064a },
{ 0x0671, 0x06b7 },
{ 0x06ba, 0x06be },
{ 0x06c0, 0x06ce },
{ 0x06d0, 0x06d3 },
{ 0x06d5 },
{ 0x06e5, 0x06e6 },
{ 0x0905, 0x0939 },
{ 0x093d },
{ 0x0958, 0x0961 },
{ 0x0985, 0x098c },
{ 0x098f, 0x0990 },
{ 0x0993, 0x09a8 },
{ 0x09aa, 0x09b0 },
{ 0x09b2 },
{ 0x09b6, 0x09b9 },
{ 0x09dc, 0x09dd },
{ 0x09df, 0x09e1 },
{ 0x09f0, 0x09f1 },
{ 0x0a05, 0x0a0a },
{ 0x0a0f, 0x0a10 },
{ 0x0a13, 0x0a28 },
{ 0x0a2a, 0x0a30 },
{ 0x0a32, 0x0a33 },
{ 0x0a35, 0x0a36 },
{ 0x0a38, 0x0a39 },
{ 0x0a59, 0x0a5c },
{ 0x0a5e },
{ 0x0a72, 0x0a74 },
{ 0x0a85, 0x0a8b },
{ 0x0a8d },
{ 0x0a8f, 0x0a91 },
{ 0x0a93, 0x0aa8 },
{ 0x0aaa, 0x0ab0 },
{ 0x0ab2, 0x0ab3 },
{ 0x0ab5, 0x0ab9 },
{ 0x0abd },
{ 0x0ae0 },
{ 0x0b05, 0x0b0c },
{ 0x0b0f, 0x0b10 },
{ 0x0b13, 0x0b28 },
{ 0x0b2a, 0x0b30 },
{ 0x0b32, 0x0b33 },
{ 0x0b36, 0x0b39 },
{ 0x0b3d },
{ 0x0b5c, 0x0b5d },
{ 0x0b5f, 0x0b61 },
{ 0x0b85, 0x0b8a },
{ 0x0b8e, 0x0b90 },
{ 0x0b92, 0x0b95 },
{ 0x0b99, 0x0b9a },
{ 0x0b9c },
{ 0x0b9e, 0x0b9f },
{ 0x0ba3, 0x0ba4 },
{ 0x0ba8, 0x0baa },
{ 0x0bae, 0x0bb5 },
{ 0x0bb7, 0x0bb9 },
{ 0x0c05, 0x0c0c },
{ 0x0c0e, 0x0c10 },
{ 0x0c12, 0x0c28 },
{ 0x0c2a, 0x0c33 },
{ 0x0c35, 0x0c39 },
{ 0x0c60, 0x0c61 },
{ 0x0c85, 0x0c8c },
{ 0x0c8e, 0x0c90 },
{ 0x0c92, 0x0ca8 },
{ 0x0caa, 0x0cb3 },
{ 0x0cb5, 0x0cb9 },
{ 0x0cde },
{ 0x0ce0, 0x0ce1 },
{ 0x0d05, 0x0d0c },
{ 0x0d0e, 0x0d10 },
{ 0x0d12, 0x0d28 },
{ 0x0d2a, 0x0d39 },
{ 0x0d60, 0x0d61 },
{ 0x0e01, 0x0e2e },
{ 0x0e30 },
{ 0x0e32, 0x0e33 },
{ 0x0e40, 0x0e45 },
{ 0x0e81, 0x0e82 },
{ 0x0e84 },
{ 0x0e87, 0x0e88 },
{ 0x0e8a },
{ 0x0e8d },
{ 0x0e94, 0x0e97 },
{ 0x0e99, 0x0e9f },
{ 0x0ea1, 0x0ea3 },
{ 0x0ea5 },
{ 0x0ea7 },
{ 0x0eaa, 0x0eab },
{ 0x0ead, 0x0eae },
{ 0x0eb0 },
{ 0x0eb2, 0x0eb3 },
{ 0x0ebd },
{ 0x0ec0, 0x0ec4 },
{ 0x0f40, 0x0f47 },
{ 0x0f49, 0x0f69 },
{ 0x10a0, 0x10c5 },
{ 0x10d0, 0x10f6 },
{ 0x1100 },
{ 0x1102, 0x1103 },
{ 0x1105, 0x1107 },
{ 0x1109 },
{ 0x110b, 0x110c },
{ 0x110e, 0x1112 },
{ 0x113c },
{ 0x113e },
{ 0x1140 },
{ 0x114c },
{ 0x114e },
{ 0x1150 },
{ 0x1154, 0x1155 },
{ 0x1159 },
{ 0x115f, 0x1161 },
{ 0x1163 },
{ 0x1165 },
{ 0x1167 },
{ 0x1169 },
{ 0x116d, 0x116e },
{ 0x1172, 0x1173 },
{ 0x1175 },
{ 0x119e },
{ 0x11a8 },
{ 0x11ab },
{ 0x11ae, 0x11af },
{ 0x11b7, 0x11b8 },
{ 0x11ba },
{ 0x11bc, 0x11c2 },
{ 0x11eb },
{ 0x11f0 },
{ 0x11f9 },
{ 0x1e00, 0x1e9b },
{ 0x1ea0, 0x1ef9 },
{ 0x1f00, 0x1f15 },
{ 0x1f18, 0x1f1d },
{ 0x1f20, 0x1f45 },
{ 0x1f48, 0x1f4d },
{ 0x1f50, 0x1f57 },
{ 0x1f59 },
{ 0x1f5b },
{ 0x1f5d },
{ 0x1f5f, 0x1f7d },
{ 0x1f80, 0x1fb4 },
{ 0x1fb6, 0x1fbc },
{ 0x1fbe },
{ 0x1fc2, 0x1fc4 },
{ 0x1fc6, 0x1fcc },
{ 0x1fd0, 0x1fd3 },
{ 0x1fd6, 0x1fdb },
{ 0x1fe0, 0x1fec },
{ 0x1ff2, 0x1ff4 },
{ 0x1ff6, 0x1ffc },
{ 0x2126 },
{ 0x212a, 0x212b },
{ 0x212e },
{ 0x2180, 0x2182 },
{ 0x3041, 0x3094 },
{ 0x30a1, 0x30fa },
{ 0x3105, 0x312c },
{ 0xac00, 0xd7a3 },
/* Ideographic */
{ 0x4e00, 0x9fa5 },
{ 0x3007 },
{ 0x3021, 0x3029 },
};
/* name chars that are not name start chars */
struct range name[] = {
{ '.' },
{ '-' },
/* CombiningChar */
{ 0x0300, 0x0345 },
{ 0x0360, 0x0361 },
{ 0x0483, 0x0486 },
{ 0x0591, 0x05a1 },
{ 0x05a3, 0x05b9 },
{ 0x05bb, 0x05bd },
{ 0x05bf },
{ 0x05c1, 0x05c2 },
{ 0x05c4 },
{ 0x064b, 0x0652 },
{ 0x0670 },
{ 0x06d6, 0x06dc },
{ 0x06dd, 0x06df },
{ 0x06e0, 0x06e4 },
{ 0x06e7, 0x06e8 },
{ 0x06ea, 0x06ed },
{ 0x0901, 0x0903 },
{ 0x093c },
{ 0x093e, 0x094c },
{ 0x094d },
{ 0x0951, 0x0954 },
{ 0x0962, 0x0963 },
{ 0x0981, 0x0983 },
{ 0x09bc },
{ 0x09be },
{ 0x09bf },
{ 0x09c0, 0x09c4 },
{ 0x09c7, 0x09c8 },
{ 0x09cb, 0x09cd },
{ 0x09d7 },
{ 0x09e2, 0x09e3 },
{ 0x0a02 },
{ 0x0a3c },
{ 0x0a3e },
{ 0x0a3f },
{ 0x0a40, 0x0a42 },
{ 0x0a47, 0x0a48 },
{ 0x0a4b, 0x0a4d },
{ 0x0a70, 0x0a71 },
{ 0x0a81, 0x0a83 },
{ 0x0abc },
{ 0x0abe, 0x0ac5 },
{ 0x0ac7, 0x0ac9 },
{ 0x0acb, 0x0acd },
{ 0x0b01, 0x0b03 },
{ 0x0b3c },
{ 0x0b3e, 0x0b43 },
{ 0x0b47, 0x0b48 },
{ 0x0b4b, 0x0b4d },
{ 0x0b56, 0x0b57 },
{ 0x0b82, 0x0b83 },
{ 0x0bbe, 0x0bc2 },
{ 0x0bc6, 0x0bc8 },
{ 0x0bca, 0x0bcd },
{ 0x0bd7 },
{ 0x0c01, 0x0c03 },
{ 0x0c3e, 0x0c44 },
{ 0x0c46, 0x0c48 },
{ 0x0c4a, 0x0c4d },
{ 0x0c55, 0x0c56 },
{ 0x0c82, 0x0c83 },
{ 0x0cbe, 0x0cc4 },
{ 0x0cc6, 0x0cc8 },
{ 0x0cca, 0x0ccd },
{ 0x0cd5, 0x0cd6 },
{ 0x0d02, 0x0d03 },
{ 0x0d3e, 0x0d43 },
{ 0x0d46, 0x0d48 },
{ 0x0d4a, 0x0d4d },
{ 0x0d57 },
{ 0x0e31 },
{ 0x0e34, 0x0e3a },
{ 0x0e47, 0x0e4e },
{ 0x0eb1 },
{ 0x0eb4, 0x0eb9 },
{ 0x0ebb, 0x0ebc },
{ 0x0ec8, 0x0ecd },
{ 0x0f18, 0x0f19 },
{ 0x0f35 },
{ 0x0f37 },
{ 0x0f39 },
{ 0x0f3e },
{ 0x0f3f },
{ 0x0f71, 0x0f84 },
{ 0x0f86, 0x0f8b },
{ 0x0f90, 0x0f95 },
{ 0x0f97 },
{ 0x0f99, 0x0fad },
{ 0x0fb1, 0x0fb7 },
{ 0x0fb9 },
{ 0x20d0, 0x20dc },
{ 0x20e1 },
{ 0x302a, 0x302f },
{ 0x3099 },
{ 0x309a },
/* Digit */
{ 0x0030, 0x0039 },
{ 0x0660, 0x0669 },
{ 0x06f0, 0x06f9 },
{ 0x0966, 0x096f },
{ 0x09e6, 0x09ef },
{ 0x0a66, 0x0a6f },
{ 0x0ae6, 0x0aef },
{ 0x0b66, 0x0b6f },
{ 0x0be7, 0x0bef },
{ 0x0c66, 0x0c6f },
{ 0x0ce6, 0x0cef },
{ 0x0d66, 0x0d6f },
{ 0x0e50, 0x0e59 },
{ 0x0ed0, 0x0ed9 },
{ 0x0f20, 0x0f29 },
/* Extender */
{ 0xb7 },
{ 0x02d0 },
{ 0x02d1 },
{ 0x0387 },
{ 0x0640 },
{ 0x0e46 },
{ 0x0ec6 },
{ 0x3005 },
{ 0x3031, 0x3035 },
{ 0x309d, 0x309e },
{ 0x30fc, 0x30fe },
};
void setTab(char *tab, struct range *ranges, size_t nRanges)
{
size_t i;
int j;
for (i = 0; i < nRanges; i++) {
if (ranges[i].end) {
for (j = ranges[i].start; j <= ranges[i].end; j++)
tab[j] = 1;
}
else
tab[ranges[i].start] = 1;
}
}
void printTabs(char *tab)
{
int nBitmaps = 2;
int i, j, k;
unsigned char pageIndex[512];
printf(
"static const unsigned namingBitmap[] = {\n\
0x00000000, 0x00000000, 0x00000000, 0x00000000,\n\
0x00000000, 0x00000000, 0x00000000, 0x00000000,\n\
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n\
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n");
for (i = 0; i < 512; i++) {
int kind = tab[i*256];
for (j = 1; j < 256; j++)
if (tab[i*256 +j] != kind) {
kind = -1;
break;
}
if (i >= 256 && memcmp(tab + (i - 256)*256, tab + i*256, 256) == 0)
pageIndex[i] = pageIndex[i - 256];
else if (kind == -1) {
pageIndex[i] = nBitmaps++;
for (j = 0; j < 8; j++) {
unsigned val = 0;
for (k = 0; k < 32; k++) {
if (tab[i*256 + j*32 +k])
val |= (1 << k);
}
printf("0x%08X,", val);
putchar((((j + 1) & 3) == 0) ? '\n' : ' ');
}
}
else
pageIndex[i] = kind;
}
printf("};\n");
printf("static const unsigned char nmstrtPages[] = {\n");
for (i = 0; i < 512; i++) {
if (i == 256)
printf("};\nstatic const unsigned char namePages[] = {\n");
printf("0x%02X,", pageIndex[i]);
putchar((((i + 1) & 7) == 0) ? '\n' : ' ');
}
printf("};\n");
}
int main()
{
char tab[2*65536];
memset(tab, 0, 65536);
setTab(tab, nmstrt, sizeof(nmstrt)/sizeof(nmstrt[0]));
memcpy(tab + 65536, tab, 65536);
setTab(tab + 65536, name, sizeof(name)/sizeof(name[0]));
printTabs(tab);
return 0;
}

Просмотреть файл

@ -1,23 +1,38 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: NPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Netscape 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/NPL/
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the NPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the NPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@

Просмотреть файл

@ -1,151 +0,0 @@
/*
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
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, 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 "xmldef.h"
#ifdef XML_UNICODE_WCHAR_T
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
#endif
#include "hashtable.h"
#define INIT_SIZE 64
static
int keyeq(KEY s1, KEY s2)
{
for (; *s1 == *s2; s1++, s2++)
if (*s1 == 0)
return 1;
return 0;
}
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 = 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 (keyeq(name, table->v[i]->name))
return table->v[i];
}
if (!createSize)
return 0;
if (table->used == table->usedLim) {
/* check for overflow */
size_t newSize = table->size * 2;
NAMED **newV = 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] = 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;
}

Просмотреть файл

@ -1,69 +0,0 @@
/*
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 <stddef.h>
#ifdef XML_UNICODE
#ifdef XML_UNICODE_WCHAR_T
typedef const wchar_t *KEY;
#else /* not XML_UNICODE_WCHAR_T */
typedef const unsigned short *KEY;
#endif /* not XML_UNICODE_WCHAR_T */
#else /* not XML_UNICODE */
typedef const char *KEY;
#endif /* not XML_UNICODE */
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 *);

Просмотреть файл

@ -1,25 +1,40 @@
#!gmake
# ***** BEGIN LICENSE BLOCK *****
# Version: NPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Netscape 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/NPL/
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the NPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the NPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH= ..\..
MODULE = expat

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#include "xmldef.h"

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#ifndef XmlParse_INCLUDED

Просмотреть файл

@ -1,40 +0,0 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = expat
LIBRARY_NAME = xmltok_s
CSRCS = \
xmltok.c \
xmlrole.c \
$(NULL)
# We want only the static lib, not the shared lib
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,86 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#define ASCII_A 0x41
#define ASCII_B 0x42
#define ASCII_C 0x43
#define ASCII_D 0x44
#define ASCII_E 0x45
#define ASCII_F 0x46
#define ASCII_G 0x47
#define ASCII_H 0x48
#define ASCII_I 0x49
#define ASCII_J 0x4A
#define ASCII_K 0x4B
#define ASCII_L 0x4C
#define ASCII_M 0x4D
#define ASCII_N 0x4E
#define ASCII_O 0x4F
#define ASCII_P 0x50
#define ASCII_Q 0x51
#define ASCII_R 0x52
#define ASCII_S 0x53
#define ASCII_T 0x54
#define ASCII_U 0x55
#define ASCII_V 0x56
#define ASCII_W 0x57
#define ASCII_X 0x58
#define ASCII_Y 0x59
#define ASCII_Z 0x5A
#define ASCII_a 0x61
#define ASCII_b 0x62
#define ASCII_c 0x63
#define ASCII_d 0x64
#define ASCII_e 0x65
#define ASCII_f 0x66
#define ASCII_g 0x67
#define ASCII_h 0x68
#define ASCII_i 0x69
#define ASCII_j 0x6A
#define ASCII_k 0x6B
#define ASCII_l 0x6C
#define ASCII_m 0x6D
#define ASCII_n 0x6E
#define ASCII_o 0x6F
#define ASCII_p 0x70
#define ASCII_q 0x71
#define ASCII_r 0x72
#define ASCII_s 0x73
#define ASCII_t 0x74
#define ASCII_u 0x75
#define ASCII_v 0x76
#define ASCII_w 0x77
#define ASCII_x 0x78
#define ASCII_y 0x79
#define ASCII_z 0x7A
#define ASCII_0 0x30
#define ASCII_1 0x31
#define ASCII_2 0x32
#define ASCII_3 0x33
#define ASCII_4 0x34
#define ASCII_5 0x35
#define ASCII_6 0x36
#define ASCII_7 0x37
#define ASCII_8 0x38
#define ASCII_9 0x39
#define ASCII_TAB 0x09
#define ASCII_SPACE 0x20
#define ASCII_EXCL 0x21
#define ASCII_QUOT 0x22
#define ASCII_AMP 0x26
#define ASCII_APOS 0x27
#define ASCII_MINUS 0x2D
#define ASCII_PERIOD 0x2E
#define ASCII_COLON 0x3A
#define ASCII_SEMI 0x3B
#define ASCII_LT 0x3C
#define ASCII_EQUALS 0x3D
#define ASCII_GT 0x3E
#define ASCII_LSQB 0x5B
#define ASCII_RSQB 0x5D
#define ASCII_UNDERSCORE 0x5F

Просмотреть файл

@ -1,37 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
/* 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_COLON, 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,

Просмотреть файл

@ -1,15 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#define STRICT 1
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}

Просмотреть файл

@ -1,38 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
/* 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_COLON, 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,

Просмотреть файл

@ -1,37 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
/* 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,

Просмотреть файл

@ -1,25 +1,40 @@
#!gmake
# ***** BEGIN LICENSE BLOCK *****
# Version: NPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Netscape 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/NPL/
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the NPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the NPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH= ..\..

Просмотреть файл

@ -1,150 +0,0 @@
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,
};

Просмотреть файл

@ -1,38 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
/* 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,

Просмотреть файл

@ -1,59 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#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. */
/* Mozilla specific defines */
#ifdef MOZILLA_CLIENT
#include "nspr.h"
#define malloc(x) PR_Malloc((size_t)(x))
#define realloc(x, y) PR_Realloc((x), (size_t)(y))
#define calloc(x, y) PR_Calloc((x),(y))
#define free(x) PR_Free(x)
#if PR_BYTES_PER_INT != 4
#define int int32
#endif
#define abort() /* as nothing */
/* Enable Unicode string processing in expat. */
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
/* Enable external parameter entity parsing in expat */
#ifndef XML_DTD
#define XML_DTD 1
#endif
#ifdef IS_LITTLE_ENDIAN
#define XML_BYTE_ORDER 12
#else
#define XML_BYTE_ORDER 21
#endif /* IS_LITTLE_ENDIAN */
#endif /* MOZILLA_CLIENT */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#ifndef XmlRole_INCLUDED

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#include "xmldef.h"

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#ifndef XmlTok_INCLUDED

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,46 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
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_COLON,
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>

Просмотреть файл

@ -1,96 +0,0 @@
const ENCODING *NS(XmlGetUtf8InternalEncoding)(void)
{
return &ns(internal_utf8_encoding).enc;
}
const ENCODING *NS(XmlGetUtf16InternalEncoding)(void)
{
#if XML_BYTE_ORDER == 12
return &ns(internal_little2_encoding).enc;
#elif XML_BYTE_ORDER == 21
return &ns(internal_big2_encoding).enc;
#else
const short n = 1;
return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc;
#endif
}
static
const ENCODING *NS(encodings)[] = {
&ns(latin1_encoding).enc,
&ns(ascii_encoding).enc,
&ns(utf8_encoding).enc,
&ns(big2_encoding).enc,
&ns(big2_encoding).enc,
&ns(little2_encoding).enc,
&ns(utf8_encoding).enc /* NO_ENC */
};
static
int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr)
{
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
}
static
int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr)
{
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
}
int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
{
int i = getEncodingIndex(name);
if (i == UNKNOWN_ENC)
return 0;
SET_INIT_ENC_INDEX(p, i);
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
p->initEnc.updatePosition = initUpdatePosition;
p->encPtr = encPtr;
*encPtr = &(p->initEnc);
return 1;
}
static
const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
{
#define ENCODING_MAX 128
char buf[ENCODING_MAX];
char *p = buf;
int i;
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
if (ptr != end)
return 0;
*p = 0;
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
return enc;
i = getEncodingIndex(buf);
if (i == UNKNOWN_ENC)
return 0;
return NS(encodings)[i];
}
int NS(XmlParseXmlDecl)(int isGeneralTextEntity,
const ENCODING *enc,
const char *ptr,
const char *end,
const char **badPtr,
const char **versionPtr,
const char **encodingName,
const ENCODING **encoding,
int *standalone)
{
return doParseXmlDecl(NS(findEncoding),
isGeneralTextEntity,
enc,
ptr,
end,
badPtr,
versionPtr,
encodingName,
encoding,
standalone);
}

Просмотреть файл

@ -1,65 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include "codepage.h"
#ifdef WIN32
#define STRICT 1
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
int codepageMap(int cp, int *map)
{
int i;
CPINFO info;
if (!GetCPInfo(cp, &info) || info.MaxCharSize > 2)
return 0;
for (i = 0; i < 256; i++)
map[i] = -1;
if (info.MaxCharSize > 1) {
for (i = 0; i < MAX_LEADBYTES; i++) {
int j, lim;
if (info.LeadByte[i] == 0 && info.LeadByte[i + 1] == 0)
break;
lim = info.LeadByte[i + 1];
for (j = info.LeadByte[i]; j < lim; j++)
map[j] = -2;
}
}
for (i = 0; i < 256; i++) {
if (map[i] == -1) {
char c = i;
unsigned short n;
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
&c, 1, &n, 1) == 1)
map[i] = n;
}
}
return 1;
}
int codepageConvert(int cp, const char *p)
{
unsigned short c;
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
p, 2, &c, 1) == 1)
return c;
return -1;
}
#else /* not WIN32 */
int codepageMap(int cp, int *map)
{
return 0;
}
int codepageConvert(int cp, const char *p)
{
return -1;
}
#endif /* not WIN32 */

Просмотреть файл

@ -1,7 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
int codepageMap(int cp, int *map);
int codepageConvert(int cp, const char *p);

Просмотреть файл

@ -1,17 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <stddef.h>
#ifdef XML_UNICODE
int filemap(const wchar_t *name,
void (*processor)(const void *, size_t, const wchar_t *, void *arg),
void *arg);
#else
int filemap(const char *name,
void (*processor)(const void *, size_t, const char *, void *arg),
void *arg);
#endif

Просмотреть файл

@ -1,74 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#ifndef S_ISREG
#ifndef S_IFREG
#define S_IFREG _S_IFREG
#endif
#ifndef S_IFMT
#define S_IFMT _S_IFMT
#endif
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif /* not S_ISREG */
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#else
#define O_BINARY 0
#endif
#endif
int filemap(const char *name,
void (*processor)(const void *, size_t, const char *, void *arg),
void *arg)
{
size_t nbytes;
int fd;
int n;
struct stat sb;
void *p;
fd = open(name, O_RDONLY|O_BINARY);
if (fd < 0) {
perror(name);
return 0;
}
if (fstat(fd, &sb) < 0) {
perror(name);
return 0;
}
if (!S_ISREG(sb.st_mode)) {
fprintf(stderr, "%s: not a regular file\n", name);
return 0;
}
nbytes = sb.st_size;
p = malloc(nbytes);
if (!p) {
fprintf(stderr, "%s: out of memory\n", name);
return 0;
}
n = read(fd, p, nbytes);
if (n < 0) {
perror(name);
close(fd);
return 0;
}
if (n != nbytes) {
fprintf(stderr, "%s: read unexpected number of bytes\n", name);
close(fd);
return 0;
}
processor(p, nbytes, name, arg);
free(p);
close(fd);
return 1;
}

Просмотреть файл

@ -1,57 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
#include "filemap.h"
int filemap(const char *name,
void (*processor)(const void *, size_t, const char *, void *arg),
void *arg)
{
int fd;
size_t nbytes;
struct stat sb;
void *p;
fd = open(name, O_RDONLY);
if (fd < 0) {
perror(name);
return 0;
}
if (fstat(fd, &sb) < 0) {
perror(name);
close(fd);
return 0;
}
if (!S_ISREG(sb.st_mode)) {
close(fd);
fprintf(stderr, "%s: not a regular file\n", name);
return 0;
}
nbytes = sb.st_size;
p = (void *)mmap((caddr_t)0, (size_t)nbytes, PROT_READ,
MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
if (p == (void *)-1) {
perror(name);
close(fd);
return 0;
}
processor(p, nbytes, name, arg);
munmap((caddr_t)p, nbytes);
close(fd);
return 1;
}

Просмотреть файл

@ -1,95 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#define STRICT 1
#define WIN32_LEAN_AND_MEAN 1
#ifdef XML_UNICODE_WCHAR_T
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
#endif
#ifdef XML_UNICODE
#define UNICODE
#define _UNICODE
#endif /* XML_UNICODE */
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include "filemap.h"
static void win32perror(const TCHAR *);
int filemap(const TCHAR *name,
void (*processor)(const void *, size_t, const TCHAR *, void *arg),
void *arg)
{
HANDLE f;
HANDLE m;
DWORD size;
DWORD sizeHi;
void *p;
f = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (f == INVALID_HANDLE_VALUE) {
win32perror(name);
return 0;
}
size = GetFileSize(f, &sizeHi);
if (size == (DWORD)-1) {
win32perror(name);
return 0;
}
if (sizeHi) {
_ftprintf(stderr, _T("%s: bigger than 2Gb\n"), name);
return 0;
}
/* CreateFileMapping barfs on zero length files */
if (size == 0) {
static const char c = '\0';
processor(&c, 0, name, arg);
CloseHandle(f);
return 1;
}
m = CreateFileMapping(f, NULL, PAGE_READONLY, 0, 0, NULL);
if (m == NULL) {
win32perror(name);
CloseHandle(f);
return 0;
}
p = MapViewOfFile(m, FILE_MAP_READ, 0, 0, 0);
if (p == NULL) {
win32perror(name);
CloseHandle(m);
CloseHandle(f);
return 0;
}
processor(p, size, name, arg);
UnmapViewOfFile(p);
CloseHandle(m);
CloseHandle(f);
return 1;
}
static
void win32perror(const TCHAR *s)
{
LPVOID buf;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &buf,
0,
NULL)) {
_ftprintf(stderr, _T("%s: %s"), s, buf);
fflush(stderr);
LocalFree(buf);
}
else
_ftprintf(stderr, _T("%s: unknown Windows error\n"), s);
}

Просмотреть файл

@ -1,217 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <fcntl.h>
#include "xmlparse.h"
#include "xmlfile.h"
#include "xmltchar.h"
#include "filemap.h"
#ifdef _MSC_VER
#include <io.h>
#endif
#ifdef _POSIX_SOURCE
#include <unistd.h>
#endif
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#else
#define O_BINARY 0
#endif
#endif
#ifdef _DEBUG
#define READ_SIZE 16
#else
#define READ_SIZE (1024*8)
#endif
typedef struct {
XML_Parser parser;
int *retPtr;
} PROCESS_ARGS;
static
void reportError(XML_Parser parser, const XML_Char *filename)
{
int code = XML_GetErrorCode(parser);
const XML_Char *message = XML_ErrorString(code);
if (message)
ftprintf(stdout, T("%s:%d:%d: %s\n"),
filename,
XML_GetErrorLineNumber(parser),
XML_GetErrorColumnNumber(parser),
message);
else
ftprintf(stderr, T("%s: (unknown message %d)\n"), filename, code);
}
static
void processFile(const void *data,
size_t size,
const XML_Char *filename,
void *args)
{
XML_Parser parser = ((PROCESS_ARGS *)args)->parser;
int *retPtr = ((PROCESS_ARGS *)args)->retPtr;
if (!XML_Parse(parser, data, size, 1)) {
reportError(parser, filename);
*retPtr = 0;
}
else
*retPtr = 1;
}
#ifdef WIN32
static
int isAsciiLetter(XML_Char c)
{
return (T('a') <= c && c <= T('z')) || (T('A') <= c && c <= T('Z'));
}
#endif /* WIN32 */
static
const XML_Char *resolveSystemId(const XML_Char *base, const XML_Char *systemId, XML_Char **toFree)
{
XML_Char *s;
*toFree = 0;
if (!base
|| *systemId == T('/')
#ifdef WIN32
|| *systemId == T('\\')
|| (isAsciiLetter(systemId[0]) && systemId[1] == T(':'))
#endif
)
return systemId;
*toFree = (XML_Char *)malloc((tcslen(base) + tcslen(systemId) + 2)*sizeof(XML_Char));
if (!*toFree)
return systemId;
tcscpy(*toFree, base);
s = *toFree;
if (tcsrchr(s, T('/')))
s = tcsrchr(s, T('/')) + 1;
#ifdef WIN32
if (tcsrchr(s, T('\\')))
s = tcsrchr(s, T('\\')) + 1;
#endif
tcscpy(s, systemId);
return *toFree;
}
static
int externalEntityRefFilemap(XML_Parser parser,
const XML_Char *context,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
int result;
XML_Char *s;
const XML_Char *filename;
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
PROCESS_ARGS args;
args.retPtr = &result;
args.parser = entParser;
filename = resolveSystemId(base, systemId, &s);
XML_SetBase(entParser, filename);
if (!filemap(filename, processFile, &args))
result = 0;
free(s);
XML_ParserFree(entParser);
return result;
}
static
int processStream(const XML_Char *filename, XML_Parser parser)
{
int fd = topen(filename, O_BINARY|O_RDONLY);
if (fd < 0) {
tperror(filename);
return 0;
}
for (;;) {
int nread;
char *buf = XML_GetBuffer(parser, READ_SIZE);
if (!buf) {
close(fd);
ftprintf(stderr, T("%s: out of memory\n"), filename);
return 0;
}
nread = read(fd, buf, READ_SIZE);
if (nread < 0) {
tperror(filename);
close(fd);
return 0;
}
if (!XML_ParseBuffer(parser, nread, nread == 0)) {
reportError(parser, filename);
close(fd);
return 0;
}
if (nread == 0) {
close(fd);
break;;
}
}
return 1;
}
static
int externalEntityRefStream(XML_Parser parser,
const XML_Char *context,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
XML_Char *s;
const XML_Char *filename;
int ret;
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
filename = resolveSystemId(base, systemId, &s);
XML_SetBase(entParser, filename);
ret = processStream(filename, entParser);
free(s);
XML_ParserFree(entParser);
return ret;
}
int XML_ProcessFile(XML_Parser parser,
const XML_Char *filename,
unsigned flags)
{
int result;
if (!XML_SetBase(parser, filename)) {
ftprintf(stderr, T("%s: out of memory"), filename);
exit(1);
}
if (flags & XML_EXTERNAL_ENTITIES)
XML_SetExternalEntityRefHandler(parser,
(flags & XML_MAP_FILE)
? externalEntityRefFilemap
: externalEntityRefStream);
if (flags & XML_MAP_FILE) {
PROCESS_ARGS args;
args.retPtr = &result;
args.parser = parser;
if (!filemap(filename, processFile, &args))
result = 0;
}
else
result = processStream(filename, parser);
return result;
}

Просмотреть файл

@ -1,11 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#define XML_MAP_FILE 01
#define XML_EXTERNAL_ENTITIES 02
extern int XML_ProcessFile(XML_Parser parser,
const XML_Char *filename,
unsigned flags);

Просмотреть файл

@ -1,36 +0,0 @@
#ifdef XML_UNICODE
#ifndef XML_UNICODE_WCHAR_T
#error xmlwf requires a 16-bit Unicode-compatible wchar_t
#endif
#define T(x) L ## x
#define ftprintf fwprintf
#define tfopen _wfopen
#define fputts fputws
#define puttc putwc
#define tcscmp wcscmp
#define tcscpy wcscpy
#define tcscat wcscat
#define tcschr wcschr
#define tcsrchr wcsrchr
#define tcslen wcslen
#define tperror _wperror
#define topen _wopen
#define tmain wmain
#define tremove _wremove
#else /* not XML_UNICODE */
#define T(x) x
#define ftprintf fprintf
#define tfopen fopen
#define fputts fputs
#define puttc putc
#define tcscmp strcmp
#define tcscpy strcpy
#define tcscat strcat
#define tcschr strchr
#define tcsrchr strrchr
#define tcslen strlen
#define tperror perror
#define topen open
#define tmain main
#define tremove remove
#endif /* not XML_UNICODE */

Просмотреть файл

@ -1,766 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include "xmlparse.h"
#include "codepage.h"
#include "xmlfile.h"
#include "xmltchar.h"
#ifdef _MSC_VER
#include <crtdbg.h>
#endif
/* This ensures proper sorting. */
#define NSSEP T('\001')
static void characterData(void *userData, const XML_Char *s, int len)
{
FILE *fp = userData;
for (; len > 0; --len, ++s) {
switch (*s) {
case T('&'):
fputts(T("&amp;"), fp);
break;
case T('<'):
fputts(T("&lt;"), fp);
break;
case T('>'):
fputts(T("&gt;"), fp);
break;
#ifdef W3C14N
case 13:
fputts(T("&#xD;"), fp);
break;
#else
case T('"'):
fputts(T("&quot;"), fp);
break;
case 9:
case 10:
case 13:
ftprintf(fp, T("&#%d;"), *s);
break;
#endif
default:
puttc(*s, fp);
break;
}
}
}
static void attributeValue(FILE *fp, const XML_Char *s)
{
puttc(T('='), fp);
puttc(T('"'), fp);
for (;;) {
switch (*s) {
case 0:
case NSSEP:
puttc(T('"'), fp);
return;
case T('&'):
fputts(T("&amp;"), fp);
break;
case T('<'):
fputts(T("&lt;"), fp);
break;
case T('"'):
fputts(T("&quot;"), fp);
break;
#ifdef W3C14N
case 9:
fputts(T("&#x9;"), fp);
break;
case 10:
fputts(T("&#xA;"), fp);
break;
case 13:
fputts(T("&#xD;"), fp);
break;
#else
case T('>'):
fputts(T("&gt;"), fp);
break;
case 9:
case 10:
case 13:
ftprintf(fp, T("&#%d;"), *s);
break;
#endif
default:
puttc(*s, fp);
break;
}
s++;
}
}
/* Lexicographically comparing UTF-8 encoded attribute values,
is equivalent to lexicographically comparing based on the character number. */
static int attcmp(const void *att1, const void *att2)
{
return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2);
}
static void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
{
int nAtts;
const XML_Char **p;
FILE *fp = userData;
puttc(T('<'), fp);
fputts(name, fp);
p = atts;
while (*p)
++p;
nAtts = (p - atts) >> 1;
if (nAtts > 1)
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp);
while (*atts) {
puttc(T(' '), fp);
fputts(*atts++, fp);
attributeValue(fp, *atts);
atts++;
}
puttc(T('>'), fp);
}
static void endElement(void *userData, const XML_Char *name)
{
FILE *fp = userData;
puttc(T('<'), fp);
puttc(T('/'), fp);
fputts(name, fp);
puttc(T('>'), fp);
}
static int nsattcmp(const void *p1, const void *p2)
{
const XML_Char *att1 = *(const XML_Char **)p1;
const XML_Char *att2 = *(const XML_Char **)p2;
int sep1 = (tcsrchr(att1, NSSEP) != 0);
int sep2 = (tcsrchr(att1, NSSEP) != 0);
if (sep1 != sep2)
return sep1 - sep2;
return tcscmp(att1, att2);
}
static void startElementNS(void *userData, const XML_Char *name, const XML_Char **atts)
{
int nAtts;
int nsi;
const XML_Char **p;
FILE *fp = userData;
const XML_Char *sep;
puttc(T('<'), fp);
sep = tcsrchr(name, NSSEP);
if (sep) {
fputts(T("n1:"), fp);
fputts(sep + 1, fp);
fputts(T(" xmlns:n1"), fp);
attributeValue(fp, name);
nsi = 2;
}
else {
fputts(name, fp);
nsi = 1;
}
p = atts;
while (*p)
++p;
nAtts = (p - atts) >> 1;
if (nAtts > 1)
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, nsattcmp);
while (*atts) {
name = *atts++;
sep = tcsrchr(name, NSSEP);
puttc(T(' '), fp);
if (sep) {
ftprintf(fp, T("n%d:"), nsi);
fputts(sep + 1, fp);
}
else
fputts(name, fp);
attributeValue(fp, *atts);
if (sep) {
ftprintf(fp, T(" xmlns:n%d"), nsi++);
attributeValue(fp, name);
}
atts++;
}
puttc(T('>'), fp);
}
static void endElementNS(void *userData, const XML_Char *name)
{
FILE *fp = userData;
const XML_Char *sep;
puttc(T('<'), fp);
puttc(T('/'), fp);
sep = tcsrchr(name, NSSEP);
if (sep) {
fputts(T("n1:"), fp);
fputts(sep + 1, fp);
}
else
fputts(name, fp);
puttc(T('>'), fp);
}
#ifndef W3C14N
static void processingInstruction(void *userData, const XML_Char *target, const XML_Char *data)
{
FILE *fp = userData;
puttc(T('<'), fp);
puttc(T('?'), fp);
fputts(target, fp);
puttc(T(' '), fp);
fputts(data, fp);
puttc(T('?'), fp);
puttc(T('>'), fp);
}
#endif /* not W3C14N */
static void defaultCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
XML_DefaultCurrent(parser);
}
static void defaultStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
XML_DefaultCurrent(parser);
}
static void defaultEndElement(XML_Parser parser, const XML_Char *name)
{
XML_DefaultCurrent(parser);
}
static void defaultProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
XML_DefaultCurrent(parser);
}
static void nopCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
}
static void nopStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
}
static void nopEndElement(XML_Parser parser, const XML_Char *name)
{
}
static void nopProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
}
static void markup(XML_Parser parser, const XML_Char *s, int len)
{
FILE *fp = XML_GetUserData(parser);
for (; len > 0; --len, ++s)
puttc(*s, fp);
}
static
void metaLocation(XML_Parser parser)
{
const XML_Char *uri = XML_GetBase(parser);
if (uri)
ftprintf(XML_GetUserData(parser), T(" uri=\"%s\""), uri);
ftprintf(XML_GetUserData(parser),
T(" byte=\"%ld\" nbytes=\"%d\" line=\"%d\" col=\"%d\""),
XML_GetCurrentByteIndex(parser),
XML_GetCurrentByteCount(parser),
XML_GetCurrentLineNumber(parser),
XML_GetCurrentColumnNumber(parser));
}
static
void metaStartDocument(XML_Parser parser)
{
fputts(T("<document>\n"), XML_GetUserData(parser));
}
static
void metaEndDocument(XML_Parser parser)
{
fputts(T("</document>\n"), XML_GetUserData(parser));
}
static
void metaStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
FILE *fp = XML_GetUserData(parser);
const XML_Char **specifiedAttsEnd
= atts + XML_GetSpecifiedAttributeCount(parser);
const XML_Char **idAttPtr;
int idAttIndex = XML_GetIdAttributeIndex(parser);
if (idAttIndex < 0)
idAttPtr = 0;
else
idAttPtr = atts + idAttIndex;
ftprintf(fp, T("<starttag name=\"%s\""), name);
metaLocation(parser);
if (*atts) {
fputts(T(">\n"), fp);
do {
ftprintf(fp, T("<attribute name=\"%s\" value=\""), atts[0]);
characterData(fp, atts[1], tcslen(atts[1]));
if (atts >= specifiedAttsEnd)
fputts(T("\" defaulted=\"yes\"/>\n"), fp);
else if (atts == idAttPtr)
fputts(T("\" id=\"yes\"/>\n"), fp);
else
fputts(T("\"/>\n"), fp);
} while (*(atts += 2));
fputts(T("</starttag>\n"), fp);
}
else
fputts(T("/>\n"), fp);
}
static
void metaEndElement(XML_Parser parser, const XML_Char *name)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<endtag name=\"%s\""), name);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<pi target=\"%s\" data=\""), target);
characterData(fp, data, tcslen(data));
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaComment(XML_Parser parser, const XML_Char *data)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<comment data=\""), fp);
characterData(fp, data, tcslen(data));
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaStartCdataSection(XML_Parser parser)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<startcdata"), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaEndCdataSection(XML_Parser parser)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<endcdata"), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<chars str=\""), fp);
characterData(fp, s, len);
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaStartDoctypeDecl(XML_Parser parser, const XML_Char *doctypeName)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<startdoctype name=\"%s\""), doctypeName);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaEndDoctypeDecl(XML_Parser parser)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<enddoctype"), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaUnparsedEntityDecl(XML_Parser parser,
const XML_Char *entityName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId,
const XML_Char *notationName)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<entity name=\"%s\""), entityName);
if (publicId)
ftprintf(fp, T(" public=\"%s\""), publicId);
fputts(T(" system=\""), fp);
characterData(fp, systemId, tcslen(systemId));
puttc(T('"'), fp);
ftprintf(fp, T(" notation=\"%s\""), notationName);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaNotationDecl(XML_Parser parser,
const XML_Char *notationName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<notation name=\"%s\""), notationName);
if (publicId)
ftprintf(fp, T(" public=\"%s\""), publicId);
if (systemId) {
fputts(T(" system=\""), fp);
characterData(fp, systemId, tcslen(systemId));
puttc(T('"'), fp);
}
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaExternalParsedEntityDecl(XML_Parser parser,
const XML_Char *entityName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<entity name=\"%s\""), entityName);
if (publicId)
ftprintf(fp, T(" public=\"%s\""), publicId);
fputts(T(" system=\""), fp);
characterData(fp, systemId, tcslen(systemId));
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaInternalParsedEntityDecl(XML_Parser parser,
const XML_Char *entityName,
const XML_Char *text,
int textLen)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<entity name=\"%s\""), entityName);
metaLocation(parser);
puttc(T('>'), fp);
characterData(fp, text, textLen);
fputts(T("</entity/>\n"), fp);
}
static
void metaStartNamespaceDecl(XML_Parser parser,
const XML_Char *prefix,
const XML_Char *uri)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<startns"), fp);
if (prefix)
ftprintf(fp, T(" prefix=\"%s\""), prefix);
if (uri) {
fputts(T(" ns=\""), fp);
characterData(fp, uri, tcslen(uri));
fputts(T("\"/>\n"), fp);
}
else
fputts(T("/>\n"), fp);
}
static
void metaEndNamespaceDecl(XML_Parser parser, const XML_Char *prefix)
{
FILE *fp = XML_GetUserData(parser);
if (!prefix)
fputts(T("<endns/>\n"), fp);
else
ftprintf(fp, T("<endns prefix=\"%s\"/>\n"), prefix);
}
static
int unknownEncodingConvert(void *data, const char *p)
{
return codepageConvert(*(int *)data, p);
}
static
int unknownEncoding(void *userData,
const XML_Char *name,
XML_Encoding *info)
{
int cp;
static const XML_Char prefixL[] = T("windows-");
static const XML_Char prefixU[] = T("WINDOWS-");
int i;
for (i = 0; prefixU[i]; i++)
if (name[i] != prefixU[i] && name[i] != prefixL[i])
return 0;
cp = 0;
for (; name[i]; i++) {
static const XML_Char digits[] = T("0123456789");
const XML_Char *s = tcschr(digits, name[i]);
if (!s)
return 0;
cp *= 10;
cp += s - digits;
if (cp >= 0x10000)
return 0;
}
if (!codepageMap(cp, info->map))
return 0;
info->convert = unknownEncodingConvert;
/* We could just cast the code page integer to a void *,
and avoid the use of release. */
info->release = free;
info->data = malloc(sizeof(int));
if (!info->data)
return 0;
*(int *)info->data = cp;
return 1;
}
static
int notStandalone(void *userData)
{
return 0;
}
static
void usage(const XML_Char *prog)
{
ftprintf(stderr, T("usage: %s [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] [-e encoding] file ...\n"), prog);
exit(1);
}
int tmain(int argc, XML_Char **argv)
{
int i, j;
const XML_Char *outputDir = 0;
const XML_Char *encoding = 0;
unsigned processFlags = XML_MAP_FILE;
int windowsCodePages = 0;
int outputType = 0;
int useNamespaces = 0;
int requireStandalone = 0;
int paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
#ifdef _MSC_VER
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
#endif
i = 1;
j = 0;
while (i < argc) {
if (j == 0) {
if (argv[i][0] != T('-'))
break;
if (argv[i][1] == T('-') && argv[i][2] == T('\0')) {
i++;
break;
}
j++;
}
switch (argv[i][j]) {
case T('r'):
processFlags &= ~XML_MAP_FILE;
j++;
break;
case T('s'):
requireStandalone = 1;
j++;
break;
case T('n'):
useNamespaces = 1;
j++;
break;
case T('p'):
paramEntityParsing = XML_PARAM_ENTITY_PARSING_ALWAYS;
/* fall through */
case T('x'):
processFlags |= XML_EXTERNAL_ENTITIES;
j++;
break;
case T('w'):
windowsCodePages = 1;
j++;
break;
case T('m'):
outputType = 'm';
j++;
break;
case T('c'):
outputType = 'c';
useNamespaces = 0;
j++;
break;
case T('t'):
outputType = 't';
j++;
break;
case T('d'):
if (argv[i][j + 1] == T('\0')) {
if (++i == argc)
usage(argv[0]);
outputDir = argv[i];
}
else
outputDir = argv[i] + j + 1;
i++;
j = 0;
break;
case T('e'):
if (argv[i][j + 1] == T('\0')) {
if (++i == argc)
usage(argv[0]);
encoding = argv[i];
}
else
encoding = argv[i] + j + 1;
i++;
j = 0;
break;
case T('\0'):
if (j > 1) {
i++;
j = 0;
break;
}
/* fall through */
default:
usage(argv[0]);
}
}
if (i == argc)
usage(argv[0]);
for (; i < argc; i++) {
FILE *fp = 0;
XML_Char *outName = 0;
int result;
XML_Parser parser;
if (useNamespaces)
parser = XML_ParserCreateNS(encoding, NSSEP);
else
parser = XML_ParserCreate(encoding);
if (requireStandalone)
XML_SetNotStandaloneHandler(parser, notStandalone);
XML_SetParamEntityParsing(parser, paramEntityParsing);
if (outputType == 't') {
/* This is for doing timings; this gives a more realistic estimate of
the parsing time. */
outputDir = 0;
XML_SetElementHandler(parser, nopStartElement, nopEndElement);
XML_SetCharacterDataHandler(parser, nopCharacterData);
XML_SetProcessingInstructionHandler(parser, nopProcessingInstruction);
}
else if (outputDir) {
const XML_Char *file = argv[i];
if (tcsrchr(file, T('/')))
file = tcsrchr(file, T('/')) + 1;
#ifdef WIN32
if (tcsrchr(file, T('\\')))
file = tcsrchr(file, T('\\')) + 1;
#endif
outName = malloc((tcslen(outputDir) + tcslen(file) + 2) * sizeof(XML_Char));
tcscpy(outName, outputDir);
tcscat(outName, T("/"));
tcscat(outName, file);
fp = tfopen(outName, T("wb"));
if (!fp) {
tperror(outName);
exit(1);
}
setvbuf(fp, NULL, _IOFBF, 16384);
#ifdef XML_UNICODE
puttc(0xFEFF, fp);
#endif
XML_SetUserData(parser, fp);
switch (outputType) {
case 'm':
XML_UseParserAsHandlerArg(parser);
XML_SetElementHandler(parser, metaStartElement, metaEndElement);
XML_SetProcessingInstructionHandler(parser, metaProcessingInstruction);
XML_SetCommentHandler(parser, metaComment);
XML_SetCdataSectionHandler(parser, metaStartCdataSection, metaEndCdataSection);
XML_SetCharacterDataHandler(parser, metaCharacterData);
XML_SetDoctypeDeclHandler(parser, metaStartDoctypeDecl, metaEndDoctypeDecl);
XML_SetUnparsedEntityDeclHandler(parser, metaUnparsedEntityDecl);
XML_SetNotationDeclHandler(parser, metaNotationDecl);
XML_SetExternalParsedEntityDeclHandler(parser, metaExternalParsedEntityDecl);
XML_SetInternalParsedEntityDeclHandler(parser, metaInternalParsedEntityDecl);
XML_SetNamespaceDeclHandler(parser, metaStartNamespaceDecl, metaEndNamespaceDecl);
metaStartDocument(parser);
break;
case 'c':
XML_UseParserAsHandlerArg(parser);
XML_SetDefaultHandler(parser, markup);
XML_SetElementHandler(parser, defaultStartElement, defaultEndElement);
XML_SetCharacterDataHandler(parser, defaultCharacterData);
XML_SetProcessingInstructionHandler(parser, defaultProcessingInstruction);
break;
default:
if (useNamespaces)
XML_SetElementHandler(parser, startElementNS, endElementNS);
else
XML_SetElementHandler(parser, startElement, endElement);
XML_SetCharacterDataHandler(parser, characterData);
#ifndef W3C14N
XML_SetProcessingInstructionHandler(parser, processingInstruction);
#endif /* not W3C14N */
break;
}
}
if (windowsCodePages)
XML_SetUnknownEncodingHandler(parser, unknownEncoding, 0);
result = XML_ProcessFile(parser, argv[i], processFlags);
if (outputDir) {
if (outputType == 'm')
metaEndDocument(parser);
fclose(fp);
if (!result)
tremove(outName);
free(outName);
}
XML_ParserFree(parser);
}
return 0;
}

Просмотреть файл

@ -1,23 +1,38 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: NPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Netscape 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/NPL/
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the NPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the NPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#define ASCII_A 0x41

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,

Просмотреть файл

@ -1,15 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#define STRICT 1
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}

Просмотреть файл

@ -1,151 +0,0 @@
/*
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
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, 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 "xmldef.h"
#ifdef XML_UNICODE_WCHAR_T
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
#endif
#include "hashtable.h"
#define INIT_SIZE 64
static
int keyeq(KEY s1, KEY s2)
{
for (; *s1 == *s2; s1++, s2++)
if (*s1 == 0)
return 1;
return 0;
}
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 = 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 (keyeq(name, table->v[i]->name))
return table->v[i];
}
if (!createSize)
return 0;
if (table->used == table->usedLim) {
/* check for overflow */
size_t newSize = table->size * 2;
NAMED **newV = 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] = 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;
}

Просмотреть файл

@ -1,69 +0,0 @@
/*
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 <stddef.h>
#ifdef XML_UNICODE
#ifdef XML_UNICODE_WCHAR_T
typedef const wchar_t *KEY;
#else /* not XML_UNICODE_WCHAR_T */
typedef const unsigned short *KEY;
#endif /* not XML_UNICODE_WCHAR_T */
#else /* not XML_UNICODE */
typedef const char *KEY;
#endif /* not XML_UNICODE */
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 *);

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,

Просмотреть файл

@ -1,3 +1,8 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
static const unsigned namingBitmap[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/

Просмотреть файл

@ -1,59 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#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. */
/* Mozilla specific defines */
#ifdef MOZILLA_CLIENT
#include "nspr.h"
#define malloc(x) PR_Malloc((size_t)(x))
#define realloc(x, y) PR_Realloc((x), (size_t)(y))
#define calloc(x, y) PR_Calloc((x),(y))
#define free(x) PR_Free(x)
#if PR_BYTES_PER_INT != 4
#define int int32
#endif
#define abort() /* as nothing */
/* Enable Unicode string processing in expat. */
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
/* Enable external parameter entity parsing in expat */
#ifndef XML_DTD
#define XML_DTD 1
#endif
#ifdef IS_LITTLE_ENDIAN
#define XML_BYTE_ORDER 12
#else
#define XML_BYTE_ORDER 21
#endif /* IS_LITTLE_ENDIAN */
#endif /* MOZILLA_CLIENT */

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#include "xmldef.h"

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#ifndef XmlParse_INCLUDED

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#include "xmldef.h"

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#ifndef XmlRole_INCLUDED

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#include "xmldef.h"

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#ifndef XmlTok_INCLUDED

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
#ifndef IS_INVALID_CHAR

Просмотреть файл

@ -1,6 +1,6 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
See the file COPYING for copying permission.
*/
enum {

Просмотреть файл

@ -1,3 +1,8 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
const ENCODING *NS(XmlGetUtf8InternalEncoding)(void)
{
return &ns(internal_utf8_encoding).enc;

Просмотреть файл

@ -1,65 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include "codepage.h"
#ifdef WIN32
#define STRICT 1
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
int codepageMap(int cp, int *map)
{
int i;
CPINFO info;
if (!GetCPInfo(cp, &info) || info.MaxCharSize > 2)
return 0;
for (i = 0; i < 256; i++)
map[i] = -1;
if (info.MaxCharSize > 1) {
for (i = 0; i < MAX_LEADBYTES; i++) {
int j, lim;
if (info.LeadByte[i] == 0 && info.LeadByte[i + 1] == 0)
break;
lim = info.LeadByte[i + 1];
for (j = info.LeadByte[i]; j < lim; j++)
map[j] = -2;
}
}
for (i = 0; i < 256; i++) {
if (map[i] == -1) {
char c = i;
unsigned short n;
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
&c, 1, &n, 1) == 1)
map[i] = n;
}
}
return 1;
}
int codepageConvert(int cp, const char *p)
{
unsigned short c;
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
p, 2, &c, 1) == 1)
return c;
return -1;
}
#else /* not WIN32 */
int codepageMap(int cp, int *map)
{
return 0;
}
int codepageConvert(int cp, const char *p)
{
return -1;
}
#endif /* not WIN32 */

Просмотреть файл

@ -1,7 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
int codepageMap(int cp, int *map);
int codepageConvert(int cp, const char *p);

Просмотреть файл

@ -1,17 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <stddef.h>
#ifdef XML_UNICODE
int filemap(const wchar_t *name,
void (*processor)(const void *, size_t, const wchar_t *, void *arg),
void *arg);
#else
int filemap(const char *name,
void (*processor)(const void *, size_t, const char *, void *arg),
void *arg);
#endif

Просмотреть файл

@ -1,74 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#ifndef S_ISREG
#ifndef S_IFREG
#define S_IFREG _S_IFREG
#endif
#ifndef S_IFMT
#define S_IFMT _S_IFMT
#endif
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif /* not S_ISREG */
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#else
#define O_BINARY 0
#endif
#endif
int filemap(const char *name,
void (*processor)(const void *, size_t, const char *, void *arg),
void *arg)
{
size_t nbytes;
int fd;
int n;
struct stat sb;
void *p;
fd = open(name, O_RDONLY|O_BINARY);
if (fd < 0) {
perror(name);
return 0;
}
if (fstat(fd, &sb) < 0) {
perror(name);
return 0;
}
if (!S_ISREG(sb.st_mode)) {
fprintf(stderr, "%s: not a regular file\n", name);
return 0;
}
nbytes = sb.st_size;
p = malloc(nbytes);
if (!p) {
fprintf(stderr, "%s: out of memory\n", name);
return 0;
}
n = read(fd, p, nbytes);
if (n < 0) {
perror(name);
close(fd);
return 0;
}
if (n != nbytes) {
fprintf(stderr, "%s: read unexpected number of bytes\n", name);
close(fd);
return 0;
}
processor(p, nbytes, name, arg);
free(p);
close(fd);
return 1;
}

Просмотреть файл

@ -1,57 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
#include "filemap.h"
int filemap(const char *name,
void (*processor)(const void *, size_t, const char *, void *arg),
void *arg)
{
int fd;
size_t nbytes;
struct stat sb;
void *p;
fd = open(name, O_RDONLY);
if (fd < 0) {
perror(name);
return 0;
}
if (fstat(fd, &sb) < 0) {
perror(name);
close(fd);
return 0;
}
if (!S_ISREG(sb.st_mode)) {
close(fd);
fprintf(stderr, "%s: not a regular file\n", name);
return 0;
}
nbytes = sb.st_size;
p = (void *)mmap((caddr_t)0, (size_t)nbytes, PROT_READ,
MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
if (p == (void *)-1) {
perror(name);
close(fd);
return 0;
}
processor(p, nbytes, name, arg);
munmap((caddr_t)p, nbytes);
close(fd);
return 1;
}

Просмотреть файл

@ -1,95 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#define STRICT 1
#define WIN32_LEAN_AND_MEAN 1
#ifdef XML_UNICODE_WCHAR_T
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
#endif
#ifdef XML_UNICODE
#define UNICODE
#define _UNICODE
#endif /* XML_UNICODE */
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include "filemap.h"
static void win32perror(const TCHAR *);
int filemap(const TCHAR *name,
void (*processor)(const void *, size_t, const TCHAR *, void *arg),
void *arg)
{
HANDLE f;
HANDLE m;
DWORD size;
DWORD sizeHi;
void *p;
f = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (f == INVALID_HANDLE_VALUE) {
win32perror(name);
return 0;
}
size = GetFileSize(f, &sizeHi);
if (size == (DWORD)-1) {
win32perror(name);
return 0;
}
if (sizeHi) {
_ftprintf(stderr, _T("%s: bigger than 2Gb\n"), name);
return 0;
}
/* CreateFileMapping barfs on zero length files */
if (size == 0) {
static const char c = '\0';
processor(&c, 0, name, arg);
CloseHandle(f);
return 1;
}
m = CreateFileMapping(f, NULL, PAGE_READONLY, 0, 0, NULL);
if (m == NULL) {
win32perror(name);
CloseHandle(f);
return 0;
}
p = MapViewOfFile(m, FILE_MAP_READ, 0, 0, 0);
if (p == NULL) {
win32perror(name);
CloseHandle(m);
CloseHandle(f);
return 0;
}
processor(p, size, name, arg);
UnmapViewOfFile(p);
CloseHandle(m);
CloseHandle(f);
return 1;
}
static
void win32perror(const TCHAR *s)
{
LPVOID buf;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &buf,
0,
NULL)) {
_ftprintf(stderr, _T("%s: %s"), s, buf);
fflush(stderr);
LocalFree(buf);
}
else
_ftprintf(stderr, _T("%s: unknown Windows error\n"), s);
}

Просмотреть файл

@ -1,217 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <fcntl.h>
#include "xmlparse.h"
#include "xmlfile.h"
#include "xmltchar.h"
#include "filemap.h"
#ifdef _MSC_VER
#include <io.h>
#endif
#ifdef _POSIX_SOURCE
#include <unistd.h>
#endif
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#else
#define O_BINARY 0
#endif
#endif
#ifdef _DEBUG
#define READ_SIZE 16
#else
#define READ_SIZE (1024*8)
#endif
typedef struct {
XML_Parser parser;
int *retPtr;
} PROCESS_ARGS;
static
void reportError(XML_Parser parser, const XML_Char *filename)
{
int code = XML_GetErrorCode(parser);
const XML_Char *message = XML_ErrorString(code);
if (message)
ftprintf(stdout, T("%s:%d:%d: %s\n"),
filename,
XML_GetErrorLineNumber(parser),
XML_GetErrorColumnNumber(parser),
message);
else
ftprintf(stderr, T("%s: (unknown message %d)\n"), filename, code);
}
static
void processFile(const void *data,
size_t size,
const XML_Char *filename,
void *args)
{
XML_Parser parser = ((PROCESS_ARGS *)args)->parser;
int *retPtr = ((PROCESS_ARGS *)args)->retPtr;
if (!XML_Parse(parser, data, size, 1)) {
reportError(parser, filename);
*retPtr = 0;
}
else
*retPtr = 1;
}
#ifdef WIN32
static
int isAsciiLetter(XML_Char c)
{
return (T('a') <= c && c <= T('z')) || (T('A') <= c && c <= T('Z'));
}
#endif /* WIN32 */
static
const XML_Char *resolveSystemId(const XML_Char *base, const XML_Char *systemId, XML_Char **toFree)
{
XML_Char *s;
*toFree = 0;
if (!base
|| *systemId == T('/')
#ifdef WIN32
|| *systemId == T('\\')
|| (isAsciiLetter(systemId[0]) && systemId[1] == T(':'))
#endif
)
return systemId;
*toFree = (XML_Char *)malloc((tcslen(base) + tcslen(systemId) + 2)*sizeof(XML_Char));
if (!*toFree)
return systemId;
tcscpy(*toFree, base);
s = *toFree;
if (tcsrchr(s, T('/')))
s = tcsrchr(s, T('/')) + 1;
#ifdef WIN32
if (tcsrchr(s, T('\\')))
s = tcsrchr(s, T('\\')) + 1;
#endif
tcscpy(s, systemId);
return *toFree;
}
static
int externalEntityRefFilemap(XML_Parser parser,
const XML_Char *context,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
int result;
XML_Char *s;
const XML_Char *filename;
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
PROCESS_ARGS args;
args.retPtr = &result;
args.parser = entParser;
filename = resolveSystemId(base, systemId, &s);
XML_SetBase(entParser, filename);
if (!filemap(filename, processFile, &args))
result = 0;
free(s);
XML_ParserFree(entParser);
return result;
}
static
int processStream(const XML_Char *filename, XML_Parser parser)
{
int fd = topen(filename, O_BINARY|O_RDONLY);
if (fd < 0) {
tperror(filename);
return 0;
}
for (;;) {
int nread;
char *buf = XML_GetBuffer(parser, READ_SIZE);
if (!buf) {
close(fd);
ftprintf(stderr, T("%s: out of memory\n"), filename);
return 0;
}
nread = read(fd, buf, READ_SIZE);
if (nread < 0) {
tperror(filename);
close(fd);
return 0;
}
if (!XML_ParseBuffer(parser, nread, nread == 0)) {
reportError(parser, filename);
close(fd);
return 0;
}
if (nread == 0) {
close(fd);
break;;
}
}
return 1;
}
static
int externalEntityRefStream(XML_Parser parser,
const XML_Char *context,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
XML_Char *s;
const XML_Char *filename;
int ret;
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
filename = resolveSystemId(base, systemId, &s);
XML_SetBase(entParser, filename);
ret = processStream(filename, entParser);
free(s);
XML_ParserFree(entParser);
return ret;
}
int XML_ProcessFile(XML_Parser parser,
const XML_Char *filename,
unsigned flags)
{
int result;
if (!XML_SetBase(parser, filename)) {
ftprintf(stderr, T("%s: out of memory"), filename);
exit(1);
}
if (flags & XML_EXTERNAL_ENTITIES)
XML_SetExternalEntityRefHandler(parser,
(flags & XML_MAP_FILE)
? externalEntityRefFilemap
: externalEntityRefStream);
if (flags & XML_MAP_FILE) {
PROCESS_ARGS args;
args.retPtr = &result;
args.parser = parser;
if (!filemap(filename, processFile, &args))
result = 0;
}
else
result = processStream(filename, parser);
return result;
}

Просмотреть файл

@ -1,11 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#define XML_MAP_FILE 01
#define XML_EXTERNAL_ENTITIES 02
extern int XML_ProcessFile(XML_Parser parser,
const XML_Char *filename,
unsigned flags);

Просмотреть файл

@ -1,36 +0,0 @@
#ifdef XML_UNICODE
#ifndef XML_UNICODE_WCHAR_T
#error xmlwf requires a 16-bit Unicode-compatible wchar_t
#endif
#define T(x) L ## x
#define ftprintf fwprintf
#define tfopen _wfopen
#define fputts fputws
#define puttc putwc
#define tcscmp wcscmp
#define tcscpy wcscpy
#define tcscat wcscat
#define tcschr wcschr
#define tcsrchr wcsrchr
#define tcslen wcslen
#define tperror _wperror
#define topen _wopen
#define tmain wmain
#define tremove _wremove
#else /* not XML_UNICODE */
#define T(x) x
#define ftprintf fprintf
#define tfopen fopen
#define fputts fputs
#define puttc putc
#define tcscmp strcmp
#define tcscpy strcpy
#define tcscat strcat
#define tcschr strchr
#define tcsrchr strrchr
#define tcslen strlen
#define tperror perror
#define topen open
#define tmain main
#define tremove remove
#endif /* not XML_UNICODE */

Просмотреть файл

@ -1,766 +0,0 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include "xmlparse.h"
#include "codepage.h"
#include "xmlfile.h"
#include "xmltchar.h"
#ifdef _MSC_VER
#include <crtdbg.h>
#endif
/* This ensures proper sorting. */
#define NSSEP T('\001')
static void characterData(void *userData, const XML_Char *s, int len)
{
FILE *fp = userData;
for (; len > 0; --len, ++s) {
switch (*s) {
case T('&'):
fputts(T("&amp;"), fp);
break;
case T('<'):
fputts(T("&lt;"), fp);
break;
case T('>'):
fputts(T("&gt;"), fp);
break;
#ifdef W3C14N
case 13:
fputts(T("&#xD;"), fp);
break;
#else
case T('"'):
fputts(T("&quot;"), fp);
break;
case 9:
case 10:
case 13:
ftprintf(fp, T("&#%d;"), *s);
break;
#endif
default:
puttc(*s, fp);
break;
}
}
}
static void attributeValue(FILE *fp, const XML_Char *s)
{
puttc(T('='), fp);
puttc(T('"'), fp);
for (;;) {
switch (*s) {
case 0:
case NSSEP:
puttc(T('"'), fp);
return;
case T('&'):
fputts(T("&amp;"), fp);
break;
case T('<'):
fputts(T("&lt;"), fp);
break;
case T('"'):
fputts(T("&quot;"), fp);
break;
#ifdef W3C14N
case 9:
fputts(T("&#x9;"), fp);
break;
case 10:
fputts(T("&#xA;"), fp);
break;
case 13:
fputts(T("&#xD;"), fp);
break;
#else
case T('>'):
fputts(T("&gt;"), fp);
break;
case 9:
case 10:
case 13:
ftprintf(fp, T("&#%d;"), *s);
break;
#endif
default:
puttc(*s, fp);
break;
}
s++;
}
}
/* Lexicographically comparing UTF-8 encoded attribute values,
is equivalent to lexicographically comparing based on the character number. */
static int attcmp(const void *att1, const void *att2)
{
return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2);
}
static void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
{
int nAtts;
const XML_Char **p;
FILE *fp = userData;
puttc(T('<'), fp);
fputts(name, fp);
p = atts;
while (*p)
++p;
nAtts = (p - atts) >> 1;
if (nAtts > 1)
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp);
while (*atts) {
puttc(T(' '), fp);
fputts(*atts++, fp);
attributeValue(fp, *atts);
atts++;
}
puttc(T('>'), fp);
}
static void endElement(void *userData, const XML_Char *name)
{
FILE *fp = userData;
puttc(T('<'), fp);
puttc(T('/'), fp);
fputts(name, fp);
puttc(T('>'), fp);
}
static int nsattcmp(const void *p1, const void *p2)
{
const XML_Char *att1 = *(const XML_Char **)p1;
const XML_Char *att2 = *(const XML_Char **)p2;
int sep1 = (tcsrchr(att1, NSSEP) != 0);
int sep2 = (tcsrchr(att1, NSSEP) != 0);
if (sep1 != sep2)
return sep1 - sep2;
return tcscmp(att1, att2);
}
static void startElementNS(void *userData, const XML_Char *name, const XML_Char **atts)
{
int nAtts;
int nsi;
const XML_Char **p;
FILE *fp = userData;
const XML_Char *sep;
puttc(T('<'), fp);
sep = tcsrchr(name, NSSEP);
if (sep) {
fputts(T("n1:"), fp);
fputts(sep + 1, fp);
fputts(T(" xmlns:n1"), fp);
attributeValue(fp, name);
nsi = 2;
}
else {
fputts(name, fp);
nsi = 1;
}
p = atts;
while (*p)
++p;
nAtts = (p - atts) >> 1;
if (nAtts > 1)
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, nsattcmp);
while (*atts) {
name = *atts++;
sep = tcsrchr(name, NSSEP);
puttc(T(' '), fp);
if (sep) {
ftprintf(fp, T("n%d:"), nsi);
fputts(sep + 1, fp);
}
else
fputts(name, fp);
attributeValue(fp, *atts);
if (sep) {
ftprintf(fp, T(" xmlns:n%d"), nsi++);
attributeValue(fp, name);
}
atts++;
}
puttc(T('>'), fp);
}
static void endElementNS(void *userData, const XML_Char *name)
{
FILE *fp = userData;
const XML_Char *sep;
puttc(T('<'), fp);
puttc(T('/'), fp);
sep = tcsrchr(name, NSSEP);
if (sep) {
fputts(T("n1:"), fp);
fputts(sep + 1, fp);
}
else
fputts(name, fp);
puttc(T('>'), fp);
}
#ifndef W3C14N
static void processingInstruction(void *userData, const XML_Char *target, const XML_Char *data)
{
FILE *fp = userData;
puttc(T('<'), fp);
puttc(T('?'), fp);
fputts(target, fp);
puttc(T(' '), fp);
fputts(data, fp);
puttc(T('?'), fp);
puttc(T('>'), fp);
}
#endif /* not W3C14N */
static void defaultCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
XML_DefaultCurrent(parser);
}
static void defaultStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
XML_DefaultCurrent(parser);
}
static void defaultEndElement(XML_Parser parser, const XML_Char *name)
{
XML_DefaultCurrent(parser);
}
static void defaultProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
XML_DefaultCurrent(parser);
}
static void nopCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
}
static void nopStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
}
static void nopEndElement(XML_Parser parser, const XML_Char *name)
{
}
static void nopProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
}
static void markup(XML_Parser parser, const XML_Char *s, int len)
{
FILE *fp = XML_GetUserData(parser);
for (; len > 0; --len, ++s)
puttc(*s, fp);
}
static
void metaLocation(XML_Parser parser)
{
const XML_Char *uri = XML_GetBase(parser);
if (uri)
ftprintf(XML_GetUserData(parser), T(" uri=\"%s\""), uri);
ftprintf(XML_GetUserData(parser),
T(" byte=\"%ld\" nbytes=\"%d\" line=\"%d\" col=\"%d\""),
XML_GetCurrentByteIndex(parser),
XML_GetCurrentByteCount(parser),
XML_GetCurrentLineNumber(parser),
XML_GetCurrentColumnNumber(parser));
}
static
void metaStartDocument(XML_Parser parser)
{
fputts(T("<document>\n"), XML_GetUserData(parser));
}
static
void metaEndDocument(XML_Parser parser)
{
fputts(T("</document>\n"), XML_GetUserData(parser));
}
static
void metaStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
FILE *fp = XML_GetUserData(parser);
const XML_Char **specifiedAttsEnd
= atts + XML_GetSpecifiedAttributeCount(parser);
const XML_Char **idAttPtr;
int idAttIndex = XML_GetIdAttributeIndex(parser);
if (idAttIndex < 0)
idAttPtr = 0;
else
idAttPtr = atts + idAttIndex;
ftprintf(fp, T("<starttag name=\"%s\""), name);
metaLocation(parser);
if (*atts) {
fputts(T(">\n"), fp);
do {
ftprintf(fp, T("<attribute name=\"%s\" value=\""), atts[0]);
characterData(fp, atts[1], tcslen(atts[1]));
if (atts >= specifiedAttsEnd)
fputts(T("\" defaulted=\"yes\"/>\n"), fp);
else if (atts == idAttPtr)
fputts(T("\" id=\"yes\"/>\n"), fp);
else
fputts(T("\"/>\n"), fp);
} while (*(atts += 2));
fputts(T("</starttag>\n"), fp);
}
else
fputts(T("/>\n"), fp);
}
static
void metaEndElement(XML_Parser parser, const XML_Char *name)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<endtag name=\"%s\""), name);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<pi target=\"%s\" data=\""), target);
characterData(fp, data, tcslen(data));
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaComment(XML_Parser parser, const XML_Char *data)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<comment data=\""), fp);
characterData(fp, data, tcslen(data));
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaStartCdataSection(XML_Parser parser)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<startcdata"), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaEndCdataSection(XML_Parser parser)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<endcdata"), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<chars str=\""), fp);
characterData(fp, s, len);
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaStartDoctypeDecl(XML_Parser parser, const XML_Char *doctypeName)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<startdoctype name=\"%s\""), doctypeName);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaEndDoctypeDecl(XML_Parser parser)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<enddoctype"), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaUnparsedEntityDecl(XML_Parser parser,
const XML_Char *entityName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId,
const XML_Char *notationName)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<entity name=\"%s\""), entityName);
if (publicId)
ftprintf(fp, T(" public=\"%s\""), publicId);
fputts(T(" system=\""), fp);
characterData(fp, systemId, tcslen(systemId));
puttc(T('"'), fp);
ftprintf(fp, T(" notation=\"%s\""), notationName);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaNotationDecl(XML_Parser parser,
const XML_Char *notationName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<notation name=\"%s\""), notationName);
if (publicId)
ftprintf(fp, T(" public=\"%s\""), publicId);
if (systemId) {
fputts(T(" system=\""), fp);
characterData(fp, systemId, tcslen(systemId));
puttc(T('"'), fp);
}
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaExternalParsedEntityDecl(XML_Parser parser,
const XML_Char *entityName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<entity name=\"%s\""), entityName);
if (publicId)
ftprintf(fp, T(" public=\"%s\""), publicId);
fputts(T(" system=\""), fp);
characterData(fp, systemId, tcslen(systemId));
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaInternalParsedEntityDecl(XML_Parser parser,
const XML_Char *entityName,
const XML_Char *text,
int textLen)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<entity name=\"%s\""), entityName);
metaLocation(parser);
puttc(T('>'), fp);
characterData(fp, text, textLen);
fputts(T("</entity/>\n"), fp);
}
static
void metaStartNamespaceDecl(XML_Parser parser,
const XML_Char *prefix,
const XML_Char *uri)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<startns"), fp);
if (prefix)
ftprintf(fp, T(" prefix=\"%s\""), prefix);
if (uri) {
fputts(T(" ns=\""), fp);
characterData(fp, uri, tcslen(uri));
fputts(T("\"/>\n"), fp);
}
else
fputts(T("/>\n"), fp);
}
static
void metaEndNamespaceDecl(XML_Parser parser, const XML_Char *prefix)
{
FILE *fp = XML_GetUserData(parser);
if (!prefix)
fputts(T("<endns/>\n"), fp);
else
ftprintf(fp, T("<endns prefix=\"%s\"/>\n"), prefix);
}
static
int unknownEncodingConvert(void *data, const char *p)
{
return codepageConvert(*(int *)data, p);
}
static
int unknownEncoding(void *userData,
const XML_Char *name,
XML_Encoding *info)
{
int cp;
static const XML_Char prefixL[] = T("windows-");
static const XML_Char prefixU[] = T("WINDOWS-");
int i;
for (i = 0; prefixU[i]; i++)
if (name[i] != prefixU[i] && name[i] != prefixL[i])
return 0;
cp = 0;
for (; name[i]; i++) {
static const XML_Char digits[] = T("0123456789");
const XML_Char *s = tcschr(digits, name[i]);
if (!s)
return 0;
cp *= 10;
cp += s - digits;
if (cp >= 0x10000)
return 0;
}
if (!codepageMap(cp, info->map))
return 0;
info->convert = unknownEncodingConvert;
/* We could just cast the code page integer to a void *,
and avoid the use of release. */
info->release = free;
info->data = malloc(sizeof(int));
if (!info->data)
return 0;
*(int *)info->data = cp;
return 1;
}
static
int notStandalone(void *userData)
{
return 0;
}
static
void usage(const XML_Char *prog)
{
ftprintf(stderr, T("usage: %s [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] [-e encoding] file ...\n"), prog);
exit(1);
}
int tmain(int argc, XML_Char **argv)
{
int i, j;
const XML_Char *outputDir = 0;
const XML_Char *encoding = 0;
unsigned processFlags = XML_MAP_FILE;
int windowsCodePages = 0;
int outputType = 0;
int useNamespaces = 0;
int requireStandalone = 0;
int paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
#ifdef _MSC_VER
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
#endif
i = 1;
j = 0;
while (i < argc) {
if (j == 0) {
if (argv[i][0] != T('-'))
break;
if (argv[i][1] == T('-') && argv[i][2] == T('\0')) {
i++;
break;
}
j++;
}
switch (argv[i][j]) {
case T('r'):
processFlags &= ~XML_MAP_FILE;
j++;
break;
case T('s'):
requireStandalone = 1;
j++;
break;
case T('n'):
useNamespaces = 1;
j++;
break;
case T('p'):
paramEntityParsing = XML_PARAM_ENTITY_PARSING_ALWAYS;
/* fall through */
case T('x'):
processFlags |= XML_EXTERNAL_ENTITIES;
j++;
break;
case T('w'):
windowsCodePages = 1;
j++;
break;
case T('m'):
outputType = 'm';
j++;
break;
case T('c'):
outputType = 'c';
useNamespaces = 0;
j++;
break;
case T('t'):
outputType = 't';
j++;
break;
case T('d'):
if (argv[i][j + 1] == T('\0')) {
if (++i == argc)
usage(argv[0]);
outputDir = argv[i];
}
else
outputDir = argv[i] + j + 1;
i++;
j = 0;
break;
case T('e'):
if (argv[i][j + 1] == T('\0')) {
if (++i == argc)
usage(argv[0]);
encoding = argv[i];
}
else
encoding = argv[i] + j + 1;
i++;
j = 0;
break;
case T('\0'):
if (j > 1) {
i++;
j = 0;
break;
}
/* fall through */
default:
usage(argv[0]);
}
}
if (i == argc)
usage(argv[0]);
for (; i < argc; i++) {
FILE *fp = 0;
XML_Char *outName = 0;
int result;
XML_Parser parser;
if (useNamespaces)
parser = XML_ParserCreateNS(encoding, NSSEP);
else
parser = XML_ParserCreate(encoding);
if (requireStandalone)
XML_SetNotStandaloneHandler(parser, notStandalone);
XML_SetParamEntityParsing(parser, paramEntityParsing);
if (outputType == 't') {
/* This is for doing timings; this gives a more realistic estimate of
the parsing time. */
outputDir = 0;
XML_SetElementHandler(parser, nopStartElement, nopEndElement);
XML_SetCharacterDataHandler(parser, nopCharacterData);
XML_SetProcessingInstructionHandler(parser, nopProcessingInstruction);
}
else if (outputDir) {
const XML_Char *file = argv[i];
if (tcsrchr(file, T('/')))
file = tcsrchr(file, T('/')) + 1;
#ifdef WIN32
if (tcsrchr(file, T('\\')))
file = tcsrchr(file, T('\\')) + 1;
#endif
outName = malloc((tcslen(outputDir) + tcslen(file) + 2) * sizeof(XML_Char));
tcscpy(outName, outputDir);
tcscat(outName, T("/"));
tcscat(outName, file);
fp = tfopen(outName, T("wb"));
if (!fp) {
tperror(outName);
exit(1);
}
setvbuf(fp, NULL, _IOFBF, 16384);
#ifdef XML_UNICODE
puttc(0xFEFF, fp);
#endif
XML_SetUserData(parser, fp);
switch (outputType) {
case 'm':
XML_UseParserAsHandlerArg(parser);
XML_SetElementHandler(parser, metaStartElement, metaEndElement);
XML_SetProcessingInstructionHandler(parser, metaProcessingInstruction);
XML_SetCommentHandler(parser, metaComment);
XML_SetCdataSectionHandler(parser, metaStartCdataSection, metaEndCdataSection);
XML_SetCharacterDataHandler(parser, metaCharacterData);
XML_SetDoctypeDeclHandler(parser, metaStartDoctypeDecl, metaEndDoctypeDecl);
XML_SetUnparsedEntityDeclHandler(parser, metaUnparsedEntityDecl);
XML_SetNotationDeclHandler(parser, metaNotationDecl);
XML_SetExternalParsedEntityDeclHandler(parser, metaExternalParsedEntityDecl);
XML_SetInternalParsedEntityDeclHandler(parser, metaInternalParsedEntityDecl);
XML_SetNamespaceDeclHandler(parser, metaStartNamespaceDecl, metaEndNamespaceDecl);
metaStartDocument(parser);
break;
case 'c':
XML_UseParserAsHandlerArg(parser);
XML_SetDefaultHandler(parser, markup);
XML_SetElementHandler(parser, defaultStartElement, defaultEndElement);
XML_SetCharacterDataHandler(parser, defaultCharacterData);
XML_SetProcessingInstructionHandler(parser, defaultProcessingInstruction);
break;
default:
if (useNamespaces)
XML_SetElementHandler(parser, startElementNS, endElementNS);
else
XML_SetElementHandler(parser, startElement, endElement);
XML_SetCharacterDataHandler(parser, characterData);
#ifndef W3C14N
XML_SetProcessingInstructionHandler(parser, processingInstruction);
#endif /* not W3C14N */
break;
}
}
if (windowsCodePages)
XML_SetUnknownEncodingHandler(parser, unknownEncoding, 0);
result = XML_ProcessFile(parser, argv[i], processFlags);
if (outputDir) {
if (outputType == 'm')
metaEndDocument(parser);
fclose(fp);
if (!result)
tremove(outName);
free(outName);
}
XML_ParserFree(parser);
}
return 0;
}