blob: 33f92ddf8a93c8ebf02a95d5f6892a6f8d1f5fa3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include "ucf.h"
int ucf_load(struct ucf *f, const char *filename)
{
int fd = open(filename, O_RDONLY);
unsigned char *map;
size_t l;
if (fd < 0) return -1;
map = mmap(0, l=lseek(fd, 0, SEEK_END), PROT_READ, MAP_SHARED, fd, 0);
close(fd);
if (map == MAP_FAILED) return -1;
return ucf_init(f, map, l);
}
|