2009-02-09 Felix Zielcke <fzielcke@z-51.de>
[grub2/phcoder/solaris.git] / font / font_cmd.c
blob6cbae5b0aaa66afe631b3ef05f2cbe26f4229976
1 /* font_cmd.c - Font command definition. */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2003,2005,2006,2007,2008,2009 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/font.h>
21 #include <grub/dl.h>
22 #include <grub/normal.h>
23 #include <grub/misc.h>
25 static grub_err_t
26 loadfont_command (struct grub_arg_list *state __attribute__ ((unused)),
27 int argc,
28 char **args)
30 if (argc == 0)
31 return grub_error (GRUB_ERR_BAD_ARGUMENT, "no font specified");
33 while (argc--)
34 if (grub_font_load (*args++) != 0)
35 return GRUB_ERR_BAD_FONT;
37 return GRUB_ERR_NONE;
40 static grub_err_t
41 lsfonts_command (struct grub_arg_list *state __attribute__ ((unused)),
42 int argc __attribute__ ((unused)),
43 char **args __attribute__ ((unused)))
45 struct grub_font_node *node;
47 grub_printf ("Loaded fonts:\n");
48 for (node = grub_font_list; node; node = node->next)
50 grub_font_t font = node->value;
51 grub_printf ("%s\n", grub_font_get_name (font));
54 return GRUB_ERR_NONE;
57 GRUB_MOD_INIT(font_manager)
59 grub_font_loader_init ();
61 grub_register_command ("loadfont", loadfont_command, GRUB_COMMAND_FLAG_BOTH,
62 "loadfont FILE...",
63 "Specify one or more font files to load.", 0);
65 grub_register_command ("lsfonts", lsfonts_command, GRUB_COMMAND_FLAG_BOTH,
66 "lsfonts",
67 "List the loaded fonts.", 0);
70 GRUB_MOD_FINI(font_manager)
72 /* TODO: Determine way to free allocated resources.
73 Warning: possible pointer references could be in use. */
75 grub_unregister_command ("loadfont");