Example #1
0
int
main(int argc, char **argv)
{
	char    *font, *type, *termmode;
	const char *opts;
	int	dumpmod, dumpopt, opt;

	vt4_mode = is_vt4();

	init();

	dumpmod = 0;
	dumpopt = DUMP_FBF;
	termmode = NULL;
	if (vt4_mode)
		opts = "b:Cc:fg:h:Hi:M:m:pPr:S:s:T:t:x";
	else
		opts = "b:Cc:deE:fg:h:Hi:l:LM:m:pPr:S:s:T:t:x";

	while ((opt = getopt(argc, argv, opts)) != -1)
		switch(opt) {
		case 'b':
			set_border_color(optarg);
			break;
		case 'C':
			clear_history();
			break;
		case 'c':
			set_cursor_type(optarg);
			break;
		case 'd':
			if (vt4_mode)
				break;
			print_scrnmap();
			break;
		case 'E':
			if (vt4_mode)
				break;
			set_terminal_emulator(optarg);
			break;
		case 'e':
			if (vt4_mode)
				break;
			get_terminal_emulators();
			break;
		case 'f':
			optarg = nextarg(argc, argv, &optind, 'f', 0);
			if (optarg != NULL) {
				font = nextarg(argc, argv, &optind, 'f', 0);

				if (font == NULL) {
					type = NULL;
					font = optarg;
				} else
					type = optarg;

				load_font(type, font);
			} else {
				if (!vt4_mode)
					usage(); /* Switch syscons to ROM? */

				load_default_vt4font();
			}
			break;
		case 'g':
			if (sscanf(optarg, "%dx%d",
			    &vesa_cols, &vesa_rows) != 2) {
				revert();
				warnx("incorrect geometry: %s", optarg);
				usage();
			}
                	break;
		case 'h':
			set_history(optarg);
			break;
		case 'H':
			dumpopt = DUMP_ALL;
			break;
		case 'i':
			show_info(optarg);
			break;
		case 'l':
			if (vt4_mode)
				break;
			load_scrnmap(optarg);
			break;
		case 'L':
			if (vt4_mode)
				break;
			load_default_scrnmap();
			break;
		case 'M':
			set_mouse_char(optarg);
			break;
		case 'm':
			set_mouse(optarg);
			break;
		case 'p':
			dumpmod = DUMP_FMT_RAW;
			break;
		case 'P':
			dumpmod = DUMP_FMT_TXT;
			break;
		case 'r':
			set_reverse_colors(argc, argv, &optind);
			break;
		case 'S':
			set_lockswitch(optarg);
			break;
		case 's':
			set_console(optarg);
			break;
		case 'T':
			if (strcmp(optarg, "xterm") != 0 &&
			    strcmp(optarg, "cons25") != 0)
				usage();
			termmode = optarg;
			break;
		case 't':
			set_screensaver_timeout(optarg);
			break;
		case 'x':
			hex = 1;
			break;
		default:
			usage();
		}

	if (dumpmod != 0)
		dump_screen(dumpmod, dumpopt);
	video_mode(argc, argv, &optind);
	set_normal_colors(argc, argv, &optind);

	if (optind < argc && !strcmp(argv[optind], "show")) {
		test_frame();
		optind++;
	}

	if (termmode != NULL)
		set_terminal_mode(termmode);

	if ((optind != argc) || (argc == 1))
		usage();
	return (0);
}
Example #2
0
int
main(int argc, char **argv)
{
    char *font, *type;
    int opt;

    if (argc == 1)
        usage();

    init();

    info.size = sizeof(info);

    if (ioctl(0, CONS_GETINFO, &info) == -1)
        err(1, "must be on a virtual console");

    while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:S:s:t:x")) != -1) {
        switch(opt) {
        case 'b':
            set_border_color(optarg);
            break;
        case 'C':
            clear_history();
            break;
        case 'c':
            set_cursor_type(optarg);
            break;
        case 'd':
            print_scrnmap();
            break;
        case 'f':
            type = optarg;
            font = nextarg(argc, argv, &optind, 'f', 0);

            if (font == NULL) {
                type = NULL;
                font = optarg;
            }

            load_font(type, font);
            break;
        case 'g':
            if (sscanf(optarg, "%dx%d",
                       &vesa_cols, &vesa_rows) != 2) {
                revert();
                warnx("incorrect geometry: %s", optarg);
                usage();
            }
            break;
        case 'h':
            set_history(optarg);
            break;
        case 'i':
            show_info(optarg);
            break;
        case 'l':
            load_scrnmap(optarg);
            break;
        case 'L':
            load_default_scrnmap();
            break;
        case 'M':
            set_mouse_char(optarg);
            break;
        case 'm':
            set_mouse(optarg);
            break;
        case 'p':
            dump_screen(DUMP_RAW);
            break;
        case 'P':
            dump_screen(DUMP_TXT);
            break;
        case 'r':
            get_reverse_colors(argc, argv, &optind);
            break;
        case 'S':
            set_lockswitch(optarg);
            break;
        case 's':
            set_console(optarg);
            break;
        case 't':
            set_screensaver_timeout(optarg);
            break;
        case 'x':
            hex = 1;
            break;
        default:
            usage();
        }
    }

    if (optind < argc && !strcmp(argv[optind], "show")) {
        test_frame();
        optind++;
    }

    video_mode(argc, argv, &optind);

    get_normal_colors(argc, argv, &optind);

    if (colors_changed || video_mode_changed) {
        if (!(new_mode_info.vi_flags & V_INFO_GRAPHICS)) {
            if ((normal_back_color < 8) && (revers_back_color < 8)) {
                set_colors();
            } else {
                revert();
                errx(1, "bg color for text modes must be < 8");
            }
        } else {
            set_colors();
        }
    }

    if ((optind != argc) || (argc == 1))
        usage();

    return 0;
}
Example #3
0
int
main(int argc, char **argv)
{
	char    *font, *type, *termmode;
	const char *opts;
	int	dumpmod, dumpopt, opt;
	int	reterr;

	vt4_mode = is_vt4();

	init();

	info.size = sizeof(info);

	if (ioctl(0, CONS_GETINFO, &info) == -1)
		err(1, "must be on a virtual console");
	dumpmod = 0;
	dumpopt = DUMP_FBF;
	termmode = NULL;
	if (vt4_mode)
		opts = "b:Cc:f:g:h:Hi:M:m:pPr:S:s:T:t:x";
	else
		opts = "b:Cc:df:g:h:Hi:l:LM:m:pPr:S:s:T:t:x";

	while ((opt = getopt(argc, argv, opts)) != -1)
		switch(opt) {
		case 'b':
			set_border_color(optarg);
			break;
		case 'C':
			clear_history();
			break;
		case 'c':
			set_cursor_type(optarg);
			break;
		case 'd':
			if (vt4_mode)
				break;
			print_scrnmap();
			break;
		case 'f':
			type = optarg;
			font = nextarg(argc, argv, &optind, 'f', 0);

			if (font == NULL) {
				type = NULL;
				font = optarg;
			}

			load_font(type, font);
			break;
		case 'g':
			if (sscanf(optarg, "%dx%d",
			    &vesa_cols, &vesa_rows) != 2) {
				revert();
				warnx("incorrect geometry: %s", optarg);
				usage();
			}
                	break;
		case 'h':
			set_history(optarg);
			break;
		case 'H':
			dumpopt = DUMP_ALL;
			break;
		case 'i':
			show_info(optarg);
			break;
		case 'l':
			if (vt4_mode)
				break;
			load_scrnmap(optarg);
			break;
		case 'L':
			if (vt4_mode)
				break;
			load_default_scrnmap();
			break;
		case 'M':
			set_mouse_char(optarg);
			break;
		case 'm':
			set_mouse(optarg);
			break;
		case 'p':
			dumpmod = DUMP_FMT_RAW;
			break;
		case 'P':
			dumpmod = DUMP_FMT_TXT;
			break;
		case 'r':
			get_reverse_colors(argc, argv, &optind);
			break;
		case 'S':
			set_lockswitch(optarg);
			break;
		case 's':
			set_console(optarg);
			break;
		case 'T':
			if (strcmp(optarg, "xterm") != 0 &&
			    strcmp(optarg, "cons25") != 0)
				usage();
			termmode = optarg;
			break;
		case 't':
			set_screensaver_timeout(optarg);
			break;
		case 'x':
			hex = 1;
			break;
		default:
			usage();
		}

	if (dumpmod != 0)
		dump_screen(dumpmod, dumpopt);
	reterr = video_mode(argc, argv, &optind);
	get_normal_colors(argc, argv, &optind);

	if (optind < argc && !strcmp(argv[optind], "show")) {
		test_frame();
		optind++;
	}

	video_mode(argc, argv, &optind);
	if (termmode != NULL)
		set_terminal_mode(termmode);

	get_normal_colors(argc, argv, &optind);

	if (colors_changed || video_mode_changed) {
		if (!(new_mode_info.vi_flags & V_INFO_GRAPHICS)) {
			if ((normal_back_color < 8) && (revers_back_color < 8)) {
				set_colors();
			} else {
				revert();
				errx(1, "bg color for text modes must be < 8");
			}
		} else {
			set_colors();
		}
	}

	if ((optind != argc) || (argc == 1))
		usage();
	return reterr;
}