-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
*/
#include "codepage.h"
#include <windows.h>
-int codepageMap(int cp, int *map)
+int
+codepageMap(int cp, int *map)
{
int i;
CPINFO info;
break;
lim = info.LeadByte[i + 1];
for (j = info.LeadByte[i]; j < lim; j++)
- map[j] = -2;
+ map[j] = -2;
}
}
for (i = 0; i < 256; i++) {
char c = (char)i;
unsigned short n;
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
- &c, 1, &n, 1) == 1)
+ &c, 1, &n, 1) == 1)
map[i] = n;
}
}
return 1;
}
-int codepageConvert(int cp, const char *p)
+int
+codepageConvert(int cp, const char *p)
{
unsigned short c;
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
- p, 2, &c, 1) == 1)
+ p, 2, &c, 1) == 1)
return c;
return -1;
}
#else /* not WIN32 */
-int codepageMap(int cp, int *map)
+int
+codepageMap(int cp, int *map)
{
return 0;
}
-int codepageConvert(int cp, const char *p)
+int
+codepageConvert(int cp, const char *p)
{
return -1;
}
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
*/
int codepageMap(int cp, int *map);
#define CHARSET_MAX 41
-static
-const char *getTok(const char **pp)
+static const char *
+getTok(const char **pp)
{
enum { inAtom, inString, init, inComment };
int state = init;
case '\t':
case '\n':
if (state == inAtom)
- return tokStart;
+ return tokStart;
break;
case '(':
if (state == inAtom)
- return tokStart;
+ return tokStart;
if (state != inString)
- state++;
+ state++;
break;
case ')':
if (state > init)
- --state;
+ --state;
else if (state != inString)
- return 0;
+ return 0;
break;
case ';':
case '/':
case '=':
if (state == inAtom)
- return tokStart;
+ return tokStart;
if (state == init)
- return (*pp)++;
+ return (*pp)++;
break;
case '\\':
++*pp;
if (**pp == '\0')
- return 0;
+ return 0;
break;
case '"':
switch (state) {
case inString:
- ++*pp;
- return tokStart;
+ ++*pp;
+ return tokStart;
case inAtom:
- return tokStart;
+ return tokStart;
case init:
- tokStart = *pp;
- state = inString;
- break;
+ tokStart = *pp;
+ state = inString;
+ break;
}
break;
default:
if (state == init) {
- tokStart = *pp;
- state = inAtom;
+ tokStart = *pp;
+ state = inAtom;
}
break;
}
/* key must be lowercase ASCII */
-static
-int matchkey(const char *start, const char *end, const char *key)
+static int
+matchkey(const char *start, const char *end, const char *key)
{
if (!start)
return 0;
return *key == '\0';
}
-void getXMLCharset(const char *buf, char *charset)
+void
+getXMLCharset(const char *buf, char *charset)
{
const char *next, *p;
if (*p == ';') {
p = getTok(&next);
if (matchkey(p, next, "charset")) {
- p = getTok(&next);
- if (p && *p == '=') {
- p = getTok(&next);
- if (p) {
- char *s = charset;
- if (*p == '"') {
- while (++p != next - 1) {
- if (*p == '\\')
- ++p;
- if (s == charset + CHARSET_MAX - 1) {
- charset[0] = '\0';
- break;
- }
- *s++ = *p;
- }
- *s++ = '\0';
- }
- else {
- if (next - p > CHARSET_MAX - 1)
- break;
- while (p != next)
- *s++ = *p++;
- *s = 0;
- break;
- }
- }
- }
+ p = getTok(&next);
+ if (p && *p == '=') {
+ p = getTok(&next);
+ if (p) {
+ char *s = charset;
+ if (*p == '"') {
+ while (++p != next - 1) {
+ if (*p == '\\')
+ ++p;
+ if (s == charset + CHARSET_MAX - 1) {
+ charset[0] = '\0';
+ break;
+ }
+ *s++ = *p;
+ }
+ *s++ = '\0';
+ }
+ else {
+ if (next - p > CHARSET_MAX - 1)
+ break;
+ while (p != next)
+ *s++ = *p++;
+ *s = 0;
+ break;
+ }
+ }
+ }
}
}
else
}
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
char buf[CHARSET_MAX];
getXMLCharset(argv[1], buf);
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING 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);
+ 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);
+ void (*processor)(const void *, size_t,
+ const char *, void *arg),
+ void *arg);
#endif
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
*/
#include <sys/types.h>
#include "filemap.h"
-int filemap(const char *name,
- void (*processor)(const void *, size_t, const char *, void *arg),
- void *arg)
+int
+filemap(const char *name,
+ void (*processor)(const void *, size_t, const char *, void *arg),
+ void *arg)
{
size_t nbytes;
int fd;
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
*/
#include <sys/types.h>
#include "filemap.h"
-int filemap(const char *name,
- void (*processor)(const void *, size_t, const char *, void *arg),
- void *arg)
+int
+filemap(const char *name,
+ void (*processor)(const void *, size_t, const char *, void *arg),
+ void *arg)
{
int fd;
size_t nbytes;
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);
+ MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
if (p == (void *)-1) {
perror(name);
close(fd);
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
*/
#define STRICT 1
static void win32perror(const TCHAR *);
-int filemap(const TCHAR *name,
- void (*processor)(const void *, size_t, const TCHAR *, void *arg),
- void *arg)
+int
+filemap(const TCHAR *name,
+ void (*processor)(const void *, size_t, const TCHAR *, void *arg),
+ void *arg)
{
HANDLE f;
HANDLE m;
void *p;
f = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
- FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+ FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (f == INVALID_HANDLE_VALUE) {
win32perror(name);
return 0;
return 1;
}
-static
-void win32perror(const TCHAR *s)
+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)) {
+ 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);
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
*/
#include <stdio.h>
#endif
-
typedef struct {
XML_Parser parser;
int *retPtr;
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);
+ 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)
+ const XML_Char *filename, void *args)
{
XML_Parser parser = ((PROCESS_ARGS *)args)->parser;
int *retPtr = ((PROCESS_ARGS *)args)->retPtr;
static const XML_Char *
resolveSystemId(const XML_Char *base, const XML_Char *systemId,
- XML_Char **toFree)
+ XML_Char **toFree)
{
XML_Char *s;
*toFree = 0;
)
return systemId;
*toFree = (XML_Char *)malloc((tcslen(base) + tcslen(systemId) + 2)
- * sizeof(XML_Char));
+ * sizeof(XML_Char));
if (!*toFree)
return systemId;
tcscpy(*toFree, base);
static int
externalEntityRefFilemap(XML_Parser parser,
- const XML_Char *context,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId)
+ const XML_Char *context,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId)
{
int result;
XML_Char *s;
char *buf = XML_GetBuffer(parser, READ_SIZE);
if (!buf) {
if (filename != NULL)
- close(fd);
+ close(fd);
ftprintf(stderr, T("%s: out of memory\n"),
- filename != NULL ? filename : "xmlwf");
+ filename != NULL ? filename : "xmlwf");
return 0;
}
nread = read(fd, buf, READ_SIZE);
if (nread < 0) {
tperror(filename != NULL ? filename : "STDIN");
if (filename != NULL)
- close(fd);
+ close(fd);
return 0;
}
if (!XML_ParseBuffer(parser, nread, nread == 0)) {
reportError(parser, filename != NULL ? filename : "STDIN");
if (filename != NULL)
- close(fd);
+ close(fd);
return 0;
}
if (nread == 0) {
if (filename != NULL)
- close(fd);
+ close(fd);
break;;
}
}
static int
externalEntityRefStream(XML_Parser parser,
- const XML_Char *context,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId)
+ const XML_Char *context,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId)
{
XML_Char *s;
const XML_Char *filename;
int
XML_ProcessFile(XML_Parser parser,
- const XML_Char *filename,
- unsigned flags)
+ const XML_Char *filename,
+ unsigned flags)
{
int result;
if (flags & XML_EXTERNAL_ENTITIES)
XML_SetExternalEntityRefHandler(parser,
- (flags & XML_MAP_FILE)
- ? externalEntityRefFilemap
- : externalEntityRefStream);
+ (flags & XML_MAP_FILE)
+ ? externalEntityRefFilemap
+ : externalEntityRefStream);
if (flags & XML_MAP_FILE) {
PROCESS_ARGS args;
args.retPtr = &result;
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
*/
#define XML_MAP_FILE 01
#include <string.h>
#include "xmlmime.h"
-static
-const char *getTok(const char **pp)
+static const char *
+getTok(const char **pp)
{
/* inComment means one level of nesting; inComment+1 means two levels etc */
enum { inAtom, inString, init, inComment };
switch (**pp) {
case '\0':
if (state == inAtom)
- return tokStart;
+ return tokStart;
return 0;
case ' ':
case '\r':
case '\t':
case '\n':
if (state == inAtom)
- return tokStart;
+ return tokStart;
break;
case '(':
if (state == inAtom)
- return tokStart;
+ return tokStart;
if (state != inString)
- state++;
+ state++;
break;
case ')':
if (state > init)
- --state;
+ --state;
else if (state != inString)
- return 0;
+ return 0;
break;
case ';':
case '/':
case '=':
if (state == inAtom)
- return tokStart;
+ return tokStart;
if (state == init)
- return (*pp)++;
+ return (*pp)++;
break;
case '\\':
++*pp;
if (**pp == '\0')
- return 0;
+ return 0;
break;
case '"':
switch (state) {
case inString:
- ++*pp;
- return tokStart;
+ ++*pp;
+ return tokStart;
case inAtom:
- return tokStart;
+ return tokStart;
case init:
- tokStart = *pp;
- state = inString;
- break;
+ tokStart = *pp;
+ state = inString;
+ break;
}
break;
default:
if (state == init) {
- tokStart = *pp;
- state = inAtom;
+ tokStart = *pp;
+ state = inAtom;
}
break;
}
/* key must be lowercase ASCII */
-static
-int matchkey(const char *start, const char *end, const char *key)
+static int
+matchkey(const char *start, const char *end, const char *key)
{
if (!start)
return 0;
return *key == '\0';
}
-void getXMLCharset(const char *buf, char *charset)
+void
+getXMLCharset(const char *buf, char *charset)
{
const char *next, *p;
if (*p == ';') {
p = getTok(&next);
if (matchkey(p, next, "charset")) {
- p = getTok(&next);
- if (p && *p == '=') {
- p = getTok(&next);
- if (p) {
- char *s = charset;
- if (*p == '"') {
- while (++p != next - 1) {
- if (*p == '\\')
- ++p;
- if (s == charset + CHARSET_MAX - 1) {
- charset[0] = '\0';
- break;
- }
- *s++ = *p;
- }
- *s++ = '\0';
- }
- else {
- if (next - p > CHARSET_MAX - 1)
- break;
- while (p != next)
- *s++ = *p++;
- *s = 0;
- break;
- }
- }
- }
- break;
+ p = getTok(&next);
+ if (p && *p == '=') {
+ p = getTok(&next);
+ if (p) {
+ char *s = charset;
+ if (*p == '"') {
+ while (++p != next - 1) {
+ if (*p == '\\')
+ ++p;
+ if (s == charset + CHARSET_MAX - 1) {
+ charset[0] = '\0';
+ break;
+ }
+ *s++ = *p;
+ }
+ *s++ = '\0';
+ }
+ else {
+ if (next - p > CHARSET_MAX - 1)
+ break;
+ while (p != next)
+ *s++ = *p++;
+ *s = 0;
+ break;
+ }
+ }
+ }
+ break;
}
}
else
#include <stdio.h>
-int main(int argc, char **argv)
+int
+main(int argc, char *argv[])
{
char buf[CHARSET_MAX];
if (argc <= 1)
-
#ifdef __cplusplus
extern "C" {
#endif
#define CHARSET_MAX 41
/* Figure out the charset to use from the ContentType.
-buf contains the body of the header field (the part after "Content-Type:").
-charset gets the charset to use. It must be at least CHARSET_MAX chars long.
-charset will be empty if the default charset should be used. */
+ buf contains the body of the header field (the part after "Content-Type:").
+ charset gets the charset to use. It must be at least CHARSET_MAX chars
+ long. charset will be empty if the default charset should be used.
+*/
void getXMLCharset(const char *buf, char *charset);
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+ See the file COPYING for copying permission.
*/
#include <stdio.h>
static void
processingInstruction(void *userData, const XML_Char *target,
- const XML_Char *data)
+ const XML_Char *data)
{
FILE *fp = userData;
puttc(T('<'), fp);
static void
defaultStartElement(XML_Parser parser, const XML_Char *name,
- const XML_Char **atts)
+ const XML_Char **atts)
{
XML_DefaultCurrent(parser);
}
static void
defaultProcessingInstruction(XML_Parser parser, const XML_Char *target,
- const XML_Char *data)
+ const XML_Char *data)
{
XML_DefaultCurrent(parser);
}
static void
nopProcessingInstruction(XML_Parser parser, const XML_Char *target,
- const XML_Char *data)
+ const XML_Char *data)
{
}
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));
+ XML_GetCurrentByteIndex(parser),
+ XML_GetCurrentByteCount(parser),
+ XML_GetCurrentLineNumber(parser),
+ XML_GetCurrentColumnNumber(parser));
}
static void
static void
metaStartElement(XML_Parser parser, const XML_Char *name,
- const XML_Char **atts)
+ const XML_Char **atts)
{
FILE *fp = XML_GetUserData(parser);
const XML_Char **specifiedAttsEnd
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);
+ fputts(T("\" defaulted=\"yes\"/>\n"), fp);
else if (atts == idAttPtr)
- fputts(T("\" id=\"yes\"/>\n"), fp);
+ fputts(T("\" id=\"yes\"/>\n"), fp);
else
- fputts(T("\"/>\n"), fp);
+ fputts(T("\"/>\n"), fp);
} while (*(atts += 2));
fputts(T("</starttag>\n"), fp);
}
static void
metaProcessingInstruction(XML_Parser parser, const XML_Char *target,
- const XML_Char *data)
+ const XML_Char *data)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<pi target=\"%s\" data=\""), target);
static void
metaStartDoctypeDecl(XML_Parser parser,
- const XML_Char *doctypeName,
- const XML_Char *sysid,
- const XML_Char *pubid,
- int has_internal_subset)
+ const XML_Char *doctypeName,
+ const XML_Char *sysid,
+ const XML_Char *pubid,
+ int has_internal_subset)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<startdoctype name=\"%s\""), doctypeName);
static void
metaNotationDecl(XML_Parser parser,
- const XML_Char *notationName,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId)
+ 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);
static void
metaEntityDecl(XML_Parser parser,
- const XML_Char *entityName,
- int is_param,
- const XML_Char *value,
- int value_length,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId,
- const XML_Char *notationName)
+ const XML_Char *entityName,
+ int is_param,
+ const XML_Char *value,
+ int value_length,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId,
+ const XML_Char *notationName)
{
FILE *fp = XML_GetUserData(parser);
static void
metaStartNamespaceDecl(XML_Parser parser,
- const XML_Char *prefix,
- const XML_Char *uri)
+ const XML_Char *prefix,
+ const XML_Char *uri)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<startns"), fp);
usage(const XML_Char *prog, int rc)
{
ftprintf(stderr,
- T("usage: %s [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] "
- "[-e encoding] file ...\n"), prog);
+ T("usage: %s [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] "
+ "[-e encoding] file ...\n"), prog);
exit(rc);
}
while (i < argc) {
if (j == 0) {
if (argv[i][0] != T('-'))
- break;
+ break;
if (argv[i][1] == T('-') && argv[i][2] == T('\0')) {
- i++;
- break;
+ i++;
+ break;
}
j++;
}
break;
case T('d'):
if (argv[i][j + 1] == T('\0')) {
- if (++i == argc)
- usage(argv[0], 2);
- outputDir = argv[i];
+ if (++i == argc)
+ usage(argv[0], 2);
+ outputDir = argv[i];
}
else
- outputDir = argv[i] + j + 1;
+ 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], 2);
- encoding = argv[i];
+ if (++i == argc)
+ usage(argv[0], 2);
+ encoding = argv[i];
}
else
- encoding = argv[i] + j + 1;
+ encoding = argv[i] + j + 1;
i++;
j = 0;
break;
return 0;
case T('\0'):
if (j > 1) {
- i++;
- j = 0;
- break;
+ i++;
+ j = 0;
+ break;
}
/* fall through */
default:
XML_SetParamEntityParsing(parser, paramEntityParsing);
if (outputType == 't') {
/* This is for doing timings; this gives a more realistic estimate of
- the parsing time. */
+ the parsing time. */
outputDir = 0;
XML_SetElementHandler(parser, nopStartElement, nopEndElement);
XML_SetCharacterDataHandler(parser, nopCharacterData);
else if (outputDir) {
const XML_Char *file = useStdin ? T("STDIN") : argv[i];
if (tcsrchr(file, T('/')))
- file = tcsrchr(file, T('/')) + 1;
+ file = tcsrchr(file, T('/')) + 1;
#ifdef WIN32
if (tcsrchr(file, T('\\')))
- file = tcsrchr(file, T('\\')) + 1;
+ file = tcsrchr(file, T('\\')) + 1;
#endif
outName = malloc((tcslen(outputDir) + tcslen(file) + 2)
- * sizeof(XML_Char));
+ * sizeof(XML_Char));
tcscpy(outName, outputDir);
tcscat(outName, T("/"));
tcscat(outName, file);
fp = tfopen(outName, T("wb"));
if (!fp) {
- tperror(outName);
- exit(1);
+ tperror(outName);
+ exit(1);
}
setvbuf(fp, NULL, _IOFBF, 16384);
#ifdef XML_UNICODE
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_SetEntityDeclHandler(parser, metaEntityDecl);
- XML_SetNotationDeclHandler(parser, metaNotationDecl);
- XML_SetNamespaceDeclHandler(parser, metaStartNamespaceDecl,
- metaEndNamespaceDecl);
- metaStartDocument(parser);
- break;
+ 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_SetEntityDeclHandler(parser, metaEntityDecl);
+ XML_SetNotationDeclHandler(parser, metaNotationDecl);
+ 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;
+ 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);
+ if (useNamespaces)
+ XML_SetElementHandler(parser, startElementNS, endElementNS);
+ else
+ XML_SetElementHandler(parser, startElement, endElement);
+ XML_SetCharacterDataHandler(parser, characterData);
#ifndef W3C14N
- XML_SetProcessingInstructionHandler(parser, processingInstruction);
+ XML_SetProcessingInstructionHandler(parser, processingInstruction);
#endif /* not W3C14N */
- break;
+ break;
}
}
if (windowsCodePages)
result = XML_ProcessFile(parser, useStdin ? NULL : argv[i], processFlags);
if (outputDir) {
if (outputType == 'm')
- metaEndDocument(parser);
+ metaEndDocument(parser);
fclose(fp);
if (!result)
- tremove(outName);
+ tremove(outName);
free(outName);
}
XML_ParserFree(parser);