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