diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-03-14 02:51:37 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-03-14 02:51:37 +0000 |
commit | 8b8d50881096eb61da10377b8ec19ba882a5b7e7 (patch) | |
tree | e2b62f78b930a5e971172db8e04f1fe46cfacddd /usr.sbin | |
parent | 1be35009bec0e46defcd8a4b5a1871168f30c735 (diff) |
allow listing and soon deleting fonts; aaron@ ok
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/wsconscfg/wsconscfg.c | 10 | ||||
-rw-r--r-- | usr.sbin/wsfontload/wsfontload.c | 78 |
2 files changed, 63 insertions, 25 deletions
diff --git a/usr.sbin/wsconscfg/wsconscfg.c b/usr.sbin/wsconscfg/wsconscfg.c index 8fecfab5b00..01ed66f7380 100644 --- a/usr.sbin/wsconscfg/wsconscfg.c +++ b/usr.sbin/wsconscfg/wsconscfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconscfg.c,v 1.3 2001/01/30 06:50:12 aaron Exp $ */ +/* $OpenBSD: wsconscfg.c,v 1.4 2001/03/14 02:51:36 mickey Exp $ */ /* $NetBSD: wsconscfg.c,v 1.4 1999/07/29 18:24:10 augustss Exp $ */ /* @@ -74,8 +74,8 @@ main(argc, argv) delete = 0; kbd = 0; mux = 0; - asd.screentype = 0; - asd.emul = 0; + asd.screentype[0] = 0; + asd.emul[0] = 0; dsd.flags = 0; while ((c = getopt(argc, argv, "f:dkmt:e:F")) != -1) { @@ -94,10 +94,10 @@ main(argc, argv) kbd++; break; case 't': - asd.screentype = optarg; + strlcpy(asd.screentype, optarg, WSSCREEN_NAME_SIZE); break; case 'e': - asd.emul = optarg; + strlcpy(asd.emul, optarg, WSEMUL_NAME_SIZE); break; case 'F': dsd.flags |= WSDISPLAY_DELSCR_FORCE; diff --git a/usr.sbin/wsfontload/wsfontload.c b/usr.sbin/wsfontload/wsfontload.c index 131fc9134b5..8a243bbbefa 100644 --- a/usr.sbin/wsfontload/wsfontload.c +++ b/usr.sbin/wsfontload/wsfontload.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsfontload.c,v 1.3 2001/03/13 03:10:21 mickey Exp $ */ +/* $OpenBSD: wsfontload.c,v 1.4 2001/03/14 02:51:36 mickey Exp $ */ /* $NetBSD: wsfontload.c,v 1.2 2000/01/05 18:46:43 ad Exp $ */ /* @@ -39,6 +39,7 @@ #include <unistd.h> #include <sys/types.h> #include <sys/ioctl.h> +#include <string.h> #include <err.h> #include <dev/wscons/wsconsio.h> @@ -60,35 +61,51 @@ usage() extern char *__progname; (void)fprintf(stderr, - "Usage: %s [-f wsdev] [-w width] [-h height] [-e encoding]" - " [-N name] [-b] [-B] [fontfile]\n", - __progname); + "Usage: %s [-f wsdev] -l\n" + " %s [-f wsdev] -d name\n" + " %s [-w width] [-h height] [-e encoding] " + "[-N name] [-b] [-B] [fontfile]\n", + __progname, __progname, __progname); exit(1); } +static const +struct { + const char *name; + int val; +} encodings[] = { + {"iso", WSDISPLAY_FONTENC_ISO}, + {"ibm", WSDISPLAY_FONTENC_IBM}, + {"pcvt", WSDISPLAY_FONTENC_PCVT}, + {"iso7", WSDISPLAY_FONTENC_ISO7}, + {"sony", WSDISPLAY_FONTENC_SONY}, +}; + int main(argc, argv) int argc; char **argv; { - char *wsdev; + char *wsdev, *p; struct wsdisplay_font f; - int c, res, wsfd, ffd; + int c, res, wsfd, ffd, list, i; size_t len; void *buf; wsdev = DEFDEV; + f.index = -1; f.fontwidth = DEFWIDTH; f.fontheight = DEFHEIGHT; f.firstchar = 0; f.numchars = 256; f.stride = 0; f.encoding = DEFENC; - f.name = 0; + f.name[0] = 0; f.bitorder = DEFBITORDER; f.byteorder = DEFBYTEORDER; - while ((c = getopt(argc, argv, "bBe:f:h:N:w:")) != -1) { + list = 0; + while ((c = getopt(argc, argv, "bB:e:f:h:lN:w:")) != -1) { switch (c) { case 'f': wsdev = optarg; @@ -106,8 +123,11 @@ main(argc, argv) case 'e': f.encoding = getencoding(optarg); break; + case 'l': + list++; + break; case 'N': - f.name = optarg; + strlcpy(f.name, optarg, WSFONT_NAME_SIZE); break; case 'b': f.bitorder = WSDISPLAY_FONTORDER_R2L; @@ -124,6 +144,9 @@ main(argc, argv) argc -= optind; argv += optind; + if (list && argc) + usage(); + if (argc > 1) usage(); @@ -131,12 +154,36 @@ main(argc, argv) if (wsfd < 0) err(2, "open %s", wsdev); + if (list) { + i = 0; + p = " # Name Encoding W H"; + do { + f.index = i; + res = ioctl(wsfd, WSDISPLAYIO_LSFONT, &f); + if (res == 0) { + if (f.name[0]) { + if (p) { + puts(p); + p = NULL; + } + printf("%2d %-16s %8s %2d %2d\n", + f.index, f.name, + encodings[f.encoding].name, + f.fontwidth, f.fontheight); + } + } + i++; + } while(res == 0); + + return (0); + } + if (argc > 0) { ffd = open(argv[0], O_RDONLY, 0); if (ffd < 0) err(4, "open %s", argv[0]); - if (!f.name) - f.name = argv[0]; + if (!*f.name) + strlcpy(f.name, argv[0], WSFONT_NAME_SIZE); } else ffd = 0; @@ -164,15 +211,6 @@ main(argc, argv) return (0); } -static struct { - char *name; - int val; -} encodings[] = { - {"iso", WSDISPLAY_FONTENC_ISO}, - {"ibm", WSDISPLAY_FONTENC_IBM}, - {"pcvt", WSDISPLAY_FONTENC_PCVT}, -}; - static int getencoding(name) char *name; |