]>
git.saurik.com Git - wxWidgets.git/blob - src/expat/xmlwf/unixfilemap.c
1 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
21 filemap(const char *name
,
22 void (*processor
)(const void *, size_t, const char *, void *arg
),
30 fd
= open(name
, O_RDONLY
);
35 if (fstat(fd
, &sb
) < 0) {
40 if (!S_ISREG(sb
.st_mode
)) {
42 fprintf(stderr
, "%s: not a regular file\n", name
);
47 p
= (void *)mmap((caddr_t
)0, (size_t)nbytes
, PROT_READ
,
48 MAP_FILE
|MAP_PRIVATE
, fd
, (off_t
)0);
49 if (p
== (void *)-1) {
54 processor(p
, nbytes
, name
, arg
);
55 munmap((caddr_t
)p
, nbytes
);