loadfont.c revision 1.1
1/*
2 * loadfont - load ascii font (for NetBSD/X680x0)
3 * from: amiga/stand/loadkmap/loadkmap.c
4 * Copyright 1993 by Masaru Oki
5 *
6 * $Id: loadfont.c,v 1.1 1996/05/05 12:17:17 oki Exp $
7 */
8
9#include <stdio.h>
10#include <sys/file.h>
11#include <sys/ioctl.h>
12#define ITEKANJI 1 /* XXX */
13#include "../../dev/iteioctl.h" /* XXX */
14
15void load_font __P((const char *file));
16
17int
18main(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
29void
30load_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