xref: /netbsd/sys/arch/x68k/usr.bin/loadfont/loadfont.c (revision bf9ec67e)
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.3 1998/08/06 14:08:55 minoura 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 
15 void load_font __P((const char *file));
16 
17 int
18 main(argc, argv)
19      int argc;
20      char *argv[];
21 {
22   if (argc != 2)
23     fprintf (stderr, "Usage: %s fontfile\n", argv[0]), exit (1);
24 
25   load_font (argv[1]);
26   exit (0);
27 }
28 
29 void
30 load_font (file)
31      const char *file;
32 {
33   int fd;
34   unsigned char buf[4096];
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       }
43       else
44 	  perror("read font");
45 
46       close(fd);
47   }
48   else
49       perror("open font");
50 }
51