]>
git.saurik.com Git - wxWidgets.git/blob - src/expat/xmlwf/readfilemap.c
1 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
13 #define S_IFREG _S_IFREG
16 #define S_IFMT _S_IFMT
18 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
19 #endif /* not S_ISREG */
23 #define O_BINARY _O_BINARY
32 filemap(const char *name
,
33 void (*processor
)(const void *, size_t, const char *, void *arg
),
42 fd
= open(name
, O_RDONLY
|O_BINARY
);
47 if (fstat(fd
, &sb
) < 0) {
51 if (!S_ISREG(sb
.st_mode
)) {
52 fprintf(stderr
, "%s: not a regular file\n", name
);
58 fprintf(stderr
, "%s: out of memory\n", name
);
61 n
= read(fd
, p
, nbytes
);
69 fprintf(stderr
, "%s: read unexpected number of bytes\n", name
);
74 processor(p
, nbytes
, name
, arg
);