~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to grub-core/font/font_cmd.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-02-08 11:39:26 UTC
  • mfrom: (17.6.26 experimental)
  • mto: (17.6.27 experimental)
  • mto: This revision was merged to the branch mainline in revision 104.
  • Revision ID: james.westby@ubuntu.com-20110208113926-clfs90haboyk9zip
Tags: 1.99~rc1-2
* Merge 1.98+20100804-13 and 1.98+20100804-14, updating translations:
  - Kazakh (Baurzhan Muftakhidinov / Timur Birsh).
* mkconfig_skip_dmcrypt.patch: Refer to GRUB_PRELOAD_MODULES rather than
  suggesting people write a /etc/grub.d/01_modules script (thanks, Jordan
  Uggla).
* Handle empty dir passed to grub_find_root_device_from_mountinfo; fixes
  grub-mkrelpath on btrfs subvolumes (LP: #712029).
* Add rootflags=subvol=<name> if / is on a btrfs subvolume (LP: #712029).
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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/>.
 
18
 */
 
19
 
 
20
#include <grub/font.h>
 
21
#include <grub/dl.h>
 
22
#include <grub/misc.h>
 
23
#include <grub/command.h>
 
24
#include <grub/i18n.h>
 
25
 
 
26
static grub_err_t
 
27
loadfont_command (grub_command_t cmd __attribute__ ((unused)),
 
28
                  int argc,
 
29
                  char **args)
 
30
{
 
31
  if (argc == 0)
 
32
    return grub_error (GRUB_ERR_BAD_ARGUMENT, "no font specified");
 
33
 
 
34
  while (argc--)
 
35
    if (grub_font_load (*args++) != 0)
 
36
      return GRUB_ERR_BAD_FONT;
 
37
 
 
38
  return GRUB_ERR_NONE;
 
39
}
 
40
 
 
41
static grub_err_t
 
42
lsfonts_command (grub_command_t cmd __attribute__ ((unused)),
 
43
                 int argc __attribute__ ((unused)),
 
44
                 char **args __attribute__ ((unused)))
 
45
{
 
46
  struct grub_font_node *node;
 
47
 
 
48
  grub_printf ("Loaded fonts:\n");
 
49
  for (node = grub_font_list; node; node = node->next)
 
50
    {
 
51
      grub_font_t font = node->value;
 
52
      grub_printf ("%s\n", grub_font_get_name (font));
 
53
    }
 
54
 
 
55
  return GRUB_ERR_NONE;
 
56
}
 
57
 
 
58
static grub_command_t cmd_loadfont, cmd_lsfonts;
 
59
 
 
60
GRUB_MOD_INIT(font)
 
61
{
 
62
  grub_font_loader_init ();
 
63
 
 
64
  cmd_loadfont =
 
65
    grub_register_command ("loadfont", loadfont_command,
 
66
                           N_("FILE..."),
 
67
                           N_("Specify one or more font files to load."));
 
68
  cmd_lsfonts =
 
69
    grub_register_command ("lsfonts", lsfonts_command,
 
70
                           0, N_("List the loaded fonts."));
 
71
}
 
72
 
 
73
GRUB_MOD_FINI(font)
 
74
{
 
75
  /* TODO: Determine way to free allocated resources.
 
76
     Warning: possible pointer references could be in use.  */
 
77
 
 
78
  grub_unregister_command (cmd_loadfont);
 
79
  grub_unregister_command (cmd_lsfonts);
 
80
}