aboutsummaryrefslogtreecommitdiff
path: root/console-tools/loadfont.c
diff options
context:
space:
mode:
Diffstat (limited to 'console-tools/loadfont.c')
-rw-r--r--console-tools/loadfont.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 6dc8fa831..81d0c3db4 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -51,31 +51,12 @@
51//config: default y 51//config: default y
52//config: depends on LOADFONT || SETFONT 52//config: depends on LOADFONT || SETFONT
53 53
54//applet:IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) 54//applet:IF_LOADFONT(APPLET_NOEXEC(loadfont, loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP, loadfont))
55//applet:IF_SETFONT(APPLET(setfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) 55//applet:IF_SETFONT(APPLET_NOEXEC(setfont, setfont, BB_DIR_USR_SBIN, BB_SUID_DROP, setfont))
56 56
57//kbuild:lib-$(CONFIG_LOADFONT) += loadfont.o 57//kbuild:lib-$(CONFIG_LOADFONT) += loadfont.o
58//kbuild:lib-$(CONFIG_SETFONT) += loadfont.o 58//kbuild:lib-$(CONFIG_SETFONT) += loadfont.o
59 59
60//usage:#define loadfont_trivial_usage
61//usage: "< font"
62//usage:#define loadfont_full_usage "\n\n"
63//usage: "Load a console font from stdin"
64/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
65//usage:
66//usage:#define loadfont_example_usage
67//usage: "$ loadfont < /etc/i18n/fontname\n"
68//usage:
69//usage:#define setfont_trivial_usage
70//usage: "FONT [-m MAPFILE] [-C TTY]"
71//usage:#define setfont_full_usage "\n\n"
72//usage: "Load a console font\n"
73//usage: "\n -m MAPFILE Load console screen map"
74//usage: "\n -C TTY Affect TTY instead of /dev/tty"
75//usage:
76//usage:#define setfont_example_usage
77//usage: "$ setfont -m koi8-r /etc/i18n/fontname\n"
78
79#include "libbb.h" 60#include "libbb.h"
80#include <sys/kd.h> 61#include <sys/kd.h>
81 62
@@ -352,6 +333,14 @@ static void do_load(int fd, unsigned char *buffer, size_t len)
352 333
353 334
354#if ENABLE_LOADFONT 335#if ENABLE_LOADFONT
336//usage:#define loadfont_trivial_usage
337//usage: "< font"
338//usage:#define loadfont_full_usage "\n\n"
339//usage: "Load a console font from stdin"
340/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
341//usage:
342//usage:#define loadfont_example_usage
343//usage: "$ loadfont < /etc/i18n/fontname\n"
355int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 344int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
356int loadfont_main(int argc UNUSED_PARAM, char **argv) 345int loadfont_main(int argc UNUSED_PARAM, char **argv)
357{ 346{
@@ -359,8 +348,7 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
359 unsigned char *buffer; 348 unsigned char *buffer;
360 349
361 // no arguments allowed! 350 // no arguments allowed!
362 opt_complementary = "=0"; 351 getopt32(argv, "^" "" "\0" "=0");
363 getopt32(argv, "");
364 352
365 /* 353 /*
366 * We used to look at the length of the input file 354 * We used to look at the length of the input file
@@ -380,11 +368,9 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
380} 368}
381#endif 369#endif
382 370
383#if ENABLE_SETFONT
384
385/*
386kbd-1.12:
387 371
372#if ENABLE_SETFONT
373/* kbd-1.12:
388setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig] 374setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig]
389[-ou umap.orig] [-N] [font.new ...] [-m cmap] [-u umap] [-C console] 375[-ou umap.orig] [-N] [font.new ...] [-m cmap] [-u umap] [-C console]
390[-hNN] [-v] [-V] 376[-hNN] [-v] [-V]
@@ -414,8 +400,17 @@ setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig]
414-v Verbose 400-v Verbose
415-V Version 401-V Version
416*/ 402*/
403//usage:#define setfont_trivial_usage
404//usage: "FONT [-m MAPFILE] [-C TTY]"
405//usage:#define setfont_full_usage "\n\n"
406//usage: "Load a console font\n"
407//usage: "\n -m MAPFILE Load console screen map"
408//usage: "\n -C TTY Affect TTY instead of /dev/tty"
409//usage:
410//usage:#define setfont_example_usage
411//usage: "$ setfont -m koi8-r /etc/i18n/fontname\n"
417 412
418#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 413# if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
419static int ctoi(char *s) 414static int ctoi(char *s)
420{ 415{
421 if (s[0] == '\'' && s[1] != '\0' && s[2] == '\'' && s[3] == '\0') 416 if (s[0] == '\'' && s[1] != '\0' && s[2] == '\'' && s[3] == '\0')
@@ -429,7 +424,7 @@ static int ctoi(char *s)
429 return -1; 424 return -1;
430 return xstrtoul(s, 0); 425 return xstrtoul(s, 0);
431} 426}
432#endif 427# endif
433 428
434int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 429int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
435int setfont_main(int argc UNUSED_PARAM, char **argv) 430int setfont_main(int argc UNUSED_PARAM, char **argv)
@@ -441,8 +436,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
441 char *mapfilename; 436 char *mapfilename;
442 const char *tty_name = CURRENT_TTY; 437 const char *tty_name = CURRENT_TTY;
443 438
444 opt_complementary = "=1"; 439 opts = getopt32(argv, "^" "m:C:" "\0" "=1", &mapfilename, &tty_name);
445 opts = getopt32(argv, "m:C:", &mapfilename, &tty_name);
446 argv += optind; 440 argv += optind;
447 441
448 fd = xopen_nonblocking(tty_name); 442 fd = xopen_nonblocking(tty_name);
@@ -480,7 +474,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
480 if (len == 2*E_TABSZ) 474 if (len == 2*E_TABSZ)
481 mode = PIO_UNISCRNMAP; 475 mode = PIO_UNISCRNMAP;
482 } 476 }
483#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 477# if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
484 // assume textual Unicode console maps: 478 // assume textual Unicode console maps:
485 // 0x00 U+0000 # NULL (NUL) 479 // 0x00 U+0000 # NULL (NUL)
486 // 0x01 U+0001 # START OF HEADING (SOH) 480 // 0x01 U+0001 # START OF HEADING (SOH)
@@ -527,7 +521,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
527 } 521 }
528#undef unicodes 522#undef unicodes
529 } 523 }
530#endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 524# endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
531 525
532 // do set screen map 526 // do set screen map
533 xioctl(fd, mode, map); 527 xioctl(fd, mode, map);