xref: /netbsd/sys/arch/x68k/usr.bin/loadfont/loadfont.c (revision 6550d01e)
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.7 2006/08/04 02:30:00 mhitch Exp $
7  */
8 
9 #include <sys/cdefs.h>
10 __RCSID("$NetBSD: loadfont.c,v 1.7 2006/08/04 02:30:00 mhitch Exp $");
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <sys/file.h>
15 #include <sys/ioctl.h>
16 #define ITEKANJI 1 /* XXX */
17 #include <machine/iteioctl.h>
18 
19 void load_font(const char *);
20 
21 int
22 main(int argc, char *argv[])
23 {
24 
25 	if (argc != 2) {
26 		fprintf(stderr, "Usage: %s fontfile\n", argv[0]);
27 		exit (1);
28 	}
29 
30 	load_font(argv[1]);
31 	exit(0);
32 }
33 
34 void
35 load_font(const char *file)
36 {
37 	unsigned char buf[4096];
38 	int fd;
39 
40 	if ((fd = open(file, O_RDONLY)) >= 0) {
41 		if (read (fd, buf, sizeof(buf)) == sizeof (buf)) {
42 			if (ioctl(0, ITELOADFONT, buf) == 0)
43 				return;
44 			else
45 				perror("ITELOADFONT");
46 		} else {
47 			perror("read font");
48 		}
49 
50 		close(fd);
51 	} else {
52 		perror("open font");
53 	}
54 }
55