int setfont_main(int argc UNUSED_PARAM, char **argv) { size_t len; struct psf_header *psfhdr; char *mapfilename; int fd; opt_complementary = "=1"; getopt32(argv, "m:", &mapfilename); argv += optind; // load font len = 32*1024; // can't be larger psfhdr = (struct psf_header *) xmalloc_open_zipped_read_close(*argv, &len); fd = get_console_fd_or_die(); do_load(fd, psfhdr, len); // load the screen map, if any if (option_mask32 & 1) { // -m void *map = xmalloc_open_zipped_read_close(mapfilename, &len); if (len == E_TABSZ || len == 2*E_TABSZ) { xioctl(fd, (len == 2*E_TABSZ) ? PIO_UNISCRNMAP : PIO_SCRNMAP, map); } } return EXIT_SUCCESS; }
int deallocvt_main(int argc UNUSED_PARAM, char **argv) { /* num = 0 deallocate all unused consoles */ int num = 0; if (argv[1]) { if (argv[2]) bb_show_usage(); num = xatou_range(argv[1], 1, 63); } /* double cast suppresses "cast to ptr from int of different size" */ xioctl(get_console_fd_or_die(), VT_DISALLOCATE, (void *)(ptrdiff_t)num); return EXIT_SUCCESS; }
int loadfont_main(int argc UNUSED_PARAM, char **argv) { size_t len; unsigned char *buffer; // no arguments allowed! opt_complementary = "=0"; getopt32(argv, ""); /* * We used to look at the length of the input file * with stat(); now that we accept compressed files, * just read the entire file. */ len = 32*1024; // can't be larger buffer = xmalloc_read(STDIN_FILENO, &len); // xmalloc_open_zipped_read_close(filename, &len); if (!buffer) bb_perror_msg_and_die("error reading input font"); do_load(get_console_fd_or_die(), buffer, len); return EXIT_SUCCESS; }
int beep_main(int argc, char **argv) { int speaker = get_console_fd_or_die(); unsigned tickrate_div_freq = tickrate_div_freq; /* for compiler */ unsigned length = length; unsigned delay = delay; unsigned rep = rep; int c; c = 'n'; while (c != -1) { if (c == 'n') { tickrate_div_freq = CLOCK_TICK_RATE / FREQ; length = LENGTH; delay = DELAY; rep = REPETITIONS; } c = getopt(argc, argv, "f:l:d:r:n"); /* TODO: -s, -c: * pipe stdin to stdout, but also beep after each line (-s) or char (-c) */ switch (c) { case 'f': /* TODO: what "-f 0" should do? */ tickrate_div_freq = (unsigned)CLOCK_TICK_RATE / xatou(optarg); continue; case 'l': length = xatou(optarg); continue; case 'd': /* TODO: * -d N, -D N * specify a delay of N milliseconds between repetitions. * -d specifies that this delay should only occur between beeps, * that is, it should not occur after the last repetition. * -D indicates that the delay should occur after every repetition */ delay = xatou(optarg); continue; case 'r': rep = xatou(optarg); continue; case 'n': case -1: break; default: bb_show_usage(); } while (rep) { //bb_info_msg("rep[%d] freq=%d, length=%d, delay=%d", rep, freq, length, delay); xioctl(speaker, KIOCSOUND, (void*)(long)tickrate_div_freq); usleep(1000 * length); ioctl(speaker, KIOCSOUND, (void*)0); if (--rep) usleep(delay); } } if (ENABLE_FEATURE_CLEAN_UP) close(speaker); return EXIT_SUCCESS; }