loadfont.c revision 1.4
1/*
2 * loadfont - load ascii font (for NetBSD/X680x0)
3 * from: amiga/stand/loadkmap/loadkmap.c
4 * Copyright 1993 by Masaru Oki
5 *
6 *	$NetBSD: loadfont.c,v 1.4 2003/05/17 10:37:55 isaki Exp $
7 */
8
9#include <stdio.h>
10#include <sys/file.h>
11#include <sys/ioctl.h>
12#define ITEKANJI 1 /* XXX */
13#include <machine/iteioctl.h>
14
15void load_font(const char *);
16
17int
18main(int argc, char *argv[])
19{
20
21	if (argc != 2) {
22		fprintf(stderr, "Usage: %s fontfile\n", argv[0]);
23		exit (1);
24	}
25
26	load_font(argv[1]);
27	exit(0);
28}
29
30void
31load_font(const char *file)
32{
33	unsigned char buf[4096];
34	int fd;
35
36	if ((fd = open(file, O_RDONLY)) >= 0) {
37		if (read (fd, buf, sizeof(buf)) == sizeof (buf)) {
38			if (ioctl(0, ITELOADFONT, buf) == 0)
39				return;
40			else
41				perror("ITELOADFONT");
42		} else {
43			perror("read font");
44		}
45
46		close(fd);
47	} else {
48		perror("open font");
49	}
50}
51