2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2010,2012,2013 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
22 #include <grub/util/misc.h>
23 #include <grub/i18n.h>
24 #include <grub/term.h>
25 #include <grub/font.h>
26 #include <grub/gfxmenu_view.h>
27 #include <grub/color.h>
28 #include <grub/util/install.h>
29 #include <grub/emu/hostdisk.h>
39 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
40 #pragma GCC diagnostic ignored "-Wmissing-declarations"
42 #pragma GCC diagnostic error "-Wmissing-prototypes"
43 #pragma GCC diagnostic error "-Wmissing-declarations"
58 static struct argp_option options
[] = {
59 {"input", 'i', N_("FILE"), 0,
60 N_("read text from FILE."), 0},
61 {"color", 'c', N_("COLOR"), 0,
62 N_("use COLOR for text"), 0},
63 {"bgcolor", 'b', N_("COLOR"), 0,
64 N_("use COLOR for background"), 0},
65 {"text", 't', N_("STRING"), 0,
66 /* TRANSLATORS: The result is always stored to file and
67 never shown directly, so don't use "show" as synonym for render. Use "create" if
68 "render" doesn't translate directly. */
69 N_("set the label to render"), 0},
70 {"output", 'o', N_("FILE"), 0,
71 N_("set output filename. Default is STDOUT"), 0},
72 {"font", 'f', N_("FILE"), 0,
73 N_("use FILE as font (PF2)."), 0},
74 {"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
79 #include <grub/types.h>
81 #include <grub/misc.h>
83 #include <grub/video.h>
84 #include <grub/video_fb.h>
87 argp_parser (int key
, char *arg
, struct argp_state
*state
)
89 /* Get the input argument from argp_parse, which we
90 know is a pointer to our arguments structure. */
91 struct arguments
*arguments
= state
->input
;
96 arguments
->input
= xstrdup (arg
);
100 arguments
->bgcolor
= xstrdup (arg
);
104 arguments
->fgcolor
= xstrdup (arg
);
108 arguments
->font
= xstrdup (arg
);
112 arguments
->text
= xstrdup (arg
);
116 arguments
->output
= xstrdup (arg
);
120 arguments
->verbosity
++;
124 return ARGP_ERR_UNKNOWN
;
130 static struct argp argp
= {
131 options
, argp_parser
, N_("[OPTIONS]"),
132 /* TRANSLATORS: This file takes a text and creates a graphical representation of it,
133 putting the result into .disk_label file. The result is always stored to file and
134 never shown directly, so don't use "show" as synonym for render. Use "create" if
135 "render" doesn't translate directly. */
136 N_("Render Apple .disk_label."),
141 main (int argc
, char *argv
[])
144 struct arguments arguments
;
146 grub_util_host_init (&argc
, &argv
);
148 /* Check for options. */
149 memset (&arguments
, 0, sizeof (struct arguments
));
150 if (argp_parse (&argp
, argc
, argv
, 0, 0, &arguments
) != 0)
152 fprintf (stderr
, "%s", _("Error in parsing command line arguments\n"));
156 if ((!arguments
.input
&& !arguments
.text
) || !arguments
.font
)
158 fprintf (stderr
, "%s", _("Missing arguments\n"));
163 text
= arguments
.text
;
166 FILE *in
= grub_util_fopen (arguments
.input
, "r");
169 grub_util_error (_("cannot open `%s': %s"), arguments
.input
,
171 fseek (in
, 0, SEEK_END
);
173 fseek (in
, 0, SEEK_SET
);
174 text
= xmalloc (s
+ 1);
175 if (fread (text
, 1, s
, in
) != s
)
176 grub_util_error (_("cannot read `%s': %s"), arguments
.input
,
186 grub_util_render_label (arguments
.font
,