diff options
Diffstat (limited to 'font_load.c')
-rw-r--r-- | font_load.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/font_load.c b/font_load.c new file mode 100644 index 0000000..33f92dd --- /dev/null +++ b/font_load.c @@ -0,0 +1,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); +} |