1 /* terminal.c - command to show and select a terminal */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2003,2005,2007 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/normal.h>
23 #include <grub/misc.h>
24 #include <grub/term.h>
27 grub_cmd_terminal_input (struct grub_arg_list
*state
__attribute__ ((unused
)),
28 int argc
, char **args
)
30 grub_term_input_t term
= 0;
32 auto int print_terminal (grub_term_input_t
);
33 auto int find_terminal (grub_term_input_t
);
35 int print_terminal (grub_term_input_t t
)
37 grub_printf (" %s", t
->name
);
41 int find_terminal (grub_term_input_t t
)
43 if (grub_strcmp (t
->name
, args
[0]) == 0)
54 grub_printf ("Available input terminal(s):");
55 grub_term_iterate_input (print_terminal
);
58 grub_printf ("Current input terminal: %s\n", grub_term_get_current_input ()->name
);
62 grub_term_iterate_input (find_terminal
);
64 return grub_error (GRUB_ERR_BAD_ARGUMENT
, "no such input terminal");
66 grub_term_set_current_input (term
);
73 grub_cmd_terminal_output (struct grub_arg_list
*state
__attribute__ ((unused
)),
74 int argc
, char **args
)
76 grub_term_output_t term
= 0;
78 auto int print_terminal (grub_term_output_t
);
79 auto int find_terminal (grub_term_output_t
);
81 int print_terminal (grub_term_output_t t
)
83 grub_printf (" %s", t
->name
);
87 int find_terminal (grub_term_output_t t
)
89 if (grub_strcmp (t
->name
, args
[0]) == 0)
100 grub_printf ("Available output terminal(s):");
101 grub_term_iterate_output (print_terminal
);
104 grub_printf ("Current output terminal: %s\n", grub_term_get_current_output ()->name
);
108 grub_term_iterate_output (find_terminal
);
110 return grub_error (GRUB_ERR_BAD_ARGUMENT
, "no such output terminal");
112 grub_term_set_current_output (term
);
115 return GRUB_ERR_NONE
;
119 GRUB_MOD_INIT(terminal
)
121 (void)mod
; /* To stop warning. */
122 grub_register_command ("terminal_input", grub_cmd_terminal_input
, GRUB_COMMAND_FLAG_BOTH
,
123 "terminal_input [TERM...]", "Select an input terminal.", 0);
124 grub_register_command ("terminal_output", grub_cmd_terminal_output
, GRUB_COMMAND_FLAG_BOTH
,
125 "terminal_output [TERM...]", "Select an output terminal.", 0);
128 GRUB_MOD_FINI(terminal
)
130 grub_unregister_command ("terminal_input");
131 grub_unregister_command ("terminal_output");