93 lines
2.7 KiB
C
93 lines
2.7 KiB
C
/* font_cmd.c - Font command definition. */
|
|
/*
|
|
* VasEBoot -- GRand Unified Bootloader
|
|
* Copyright (C) 2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
|
*
|
|
* VasEBoot is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* VasEBoot is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <VasEBoot/font.h>
|
|
#include <VasEBoot/dl.h>
|
|
#include <VasEBoot/misc.h>
|
|
#include <VasEBoot/command.h>
|
|
#include <VasEBoot/i18n.h>
|
|
|
|
static VasEBoot_err_t
|
|
loadfont_command (VasEBoot_command_t cmd __attribute__ ((unused)),
|
|
int argc,
|
|
char **args)
|
|
{
|
|
if (argc == 0)
|
|
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("filename expected"));
|
|
|
|
while (argc--)
|
|
if (VasEBoot_font_load (*args++) == 0)
|
|
{
|
|
if (!VasEBoot_errno)
|
|
return VasEBoot_error (VasEBoot_ERR_BAD_FONT, "invalid font");
|
|
return VasEBoot_errno;
|
|
}
|
|
|
|
return VasEBoot_ERR_NONE;
|
|
}
|
|
|
|
static VasEBoot_err_t
|
|
lsfonts_command (VasEBoot_command_t cmd __attribute__ ((unused)),
|
|
int argc __attribute__ ((unused)),
|
|
char **args __attribute__ ((unused)))
|
|
{
|
|
struct VasEBoot_font_node *node;
|
|
|
|
VasEBoot_puts_ (N_("Loaded fonts:"));
|
|
for (node = VasEBoot_font_list; node; node = node->next)
|
|
{
|
|
VasEBoot_font_t font = node->value;
|
|
VasEBoot_printf ("%s\n", VasEBoot_font_get_name (font));
|
|
}
|
|
|
|
return VasEBoot_ERR_NONE;
|
|
}
|
|
|
|
static VasEBoot_command_t cmd_loadfont, cmd_lsfonts;
|
|
|
|
#if defined (VasEBoot_MACHINE_MIPS_LOONGSON) || defined (VasEBoot_MACHINE_COREBOOT)
|
|
void VasEBoot_font_init (void)
|
|
#else
|
|
VasEBoot_MOD_INIT(font)
|
|
#endif
|
|
{
|
|
VasEBoot_font_loader_init ();
|
|
|
|
cmd_loadfont =
|
|
VasEBoot_register_command ("loadfont", loadfont_command,
|
|
N_("FILE..."),
|
|
N_("Specify one or more font files to load."));
|
|
cmd_lsfonts =
|
|
VasEBoot_register_command ("lsfonts", lsfonts_command,
|
|
0, N_("List the loaded fonts."));
|
|
}
|
|
|
|
#if defined (VasEBoot_MACHINE_MIPS_LOONGSON) || defined (VasEBoot_MACHINE_COREBOOT)
|
|
void VasEBoot_font_fini (void)
|
|
#else
|
|
VasEBoot_MOD_FINI(font)
|
|
#endif
|
|
{
|
|
/* TODO: Determine way to free allocated resources.
|
|
Warning: possible pointer references could be in use. */
|
|
|
|
VasEBoot_unregister_command (cmd_loadfont);
|
|
VasEBoot_unregister_command (cmd_lsfonts);
|
|
}
|