#endif
#include "filemap.h"
+#include "xmltchar.h"
int
-filemap(const char *name,
- void (*processor)(const void *, size_t, const char *, void *arg),
+filemap(const tchar *name,
+ void (*processor)(const void *, size_t, const tchar *, void *arg),
void *arg)
{
size_t nbytes;
struct stat sb;
void *p;
- fd = open(name, O_RDONLY|O_BINARY);
+ fd = topen(name, O_RDONLY|O_BINARY);
if (fd < 0) {
- perror(name);
+ tperror(name);
return 0;
}
if (fstat(fd, &sb) < 0) {
- perror(name);
+ tperror(name);
close(fd);
return 0;
}
if (!S_ISREG(sb.st_mode)) {
- fprintf(stderr, "%s: not a regular file\n", name);
+ ftprintf(stderr, T("%s: not a regular file\n"), name);
close(fd);
return 0;
}
}
p = malloc(nbytes);
if (!p) {
- fprintf(stderr, "%s: out of memory\n", name);
+ ftprintf(stderr, T("%s: out of memory\n"), name);
close(fd);
return 0;
}
n = _EXPAT_read(fd, p, nbytes);
if (n < 0) {
- perror(name);
+ tperror(name);
free(p);
close(fd);
return 0;
}
if (n != (_EXPAT_read_count_t)nbytes) {
- fprintf(stderr, "%s: read unexpected number of bytes\n", name);
+ ftprintf(stderr, T("%s: read unexpected number of bytes\n"), name);
free(p);
close(fd);
return 0;
if (filename != NULL)
close(fd);
ftprintf(stderr, T("%s: out of memory\n"),
- filename != NULL ? filename : "xmlwf");
+ filename != NULL ? filename : T("xmlwf"));
return 0;
}
nread = read(fd, buf, READ_SIZE);
if (nread < 0) {
- tperror(filename != NULL ? filename : "STDIN");
+ tperror(filename != NULL ? filename : T("STDIN"));
if (filename != NULL)
close(fd);
return 0;
}
if (XML_ParseBuffer(parser, nread, nread == 0) == XML_STATUS_ERROR) {
- reportError(parser, filename != NULL ? filename : "STDIN");
+ reportError(parser, filename != NULL ? filename : T("STDIN"));
if (filename != NULL)
close(fd);
return 0;
#include <crtdbg.h>
#endif
+#ifdef XML_UNICODE
+#include <wchar.h>
+#endif
+
/* Structures for handler user data */
typedef struct NotationList {
struct NotationList *next;
parser = XML_ParserCreate(encoding);
if (! parser) {
- tperror("Could not instantiate parser");
+ tperror(T("Could not instantiate parser"));
exit(1);
}