grub_file_t file;
char *entryname = NULL, *entrysrc = NULL;
grub_menu_t menu;
+ char *suffix = grub_strdup ("");
+
+ auto grub_err_t getline (char **line, int cont);
+ grub_err_t getline (char **line,
+ int cont __attribute__ ((unused)))
+ {
+ *line = 0;
+ return GRUB_ERR_NONE;
+ }
+
+ if (!suffix)
+ return grub_errno;
file = grub_file_open (filename);
if (! file)
{
char *oldname = NULL;
+ int is_suffix;
oldname = entryname;
- parsed = grub_legacy_parse (buf, &entryname);
+ parsed = grub_legacy_parse (buf, &entryname, &is_suffix);
grub_free (buf);
+ if (is_suffix)
+ {
+ char *t;
+
+ t = suffix;
+ suffix = grub_realloc (suffix, grub_strlen (suffix)
+ + grub_strlen (parsed) + 1);
+ if (!suffix)
+ {
+ grub_free (t);
+ grub_free (entrysrc);
+ grub_free (parsed);
+ grub_free (suffix);
+ return grub_errno;
+ }
+ grub_memcpy (entrysrc + grub_strlen (entrysrc), parsed,
+ grub_strlen (parsed) + 1);
+ grub_free (parsed);
+ parsed = NULL;
+ continue;
+ }
if (oldname != entryname && oldname)
{
const char **args = grub_malloc (sizeof (args[0]));
if (parsed && !entryname)
{
- auto grub_err_t getline (char **line, int cont);
- grub_err_t getline (char **line __attribute__ ((unused)),
- int cont __attribute__ ((unused)))
- {
- return GRUB_ERR_NONE;
- }
-
grub_normal_parse_line (parsed, getline);
grub_print_error ();
grub_free (parsed);
{
grub_free (t);
grub_free (parsed);
+ grub_free (suffix);
return grub_errno;
}
grub_memcpy (entrysrc + grub_strlen (entrysrc), parsed,
grub_normal_add_menu_entry (1, args, NULL, NULL, NULL, NULL, entrysrc);
}
+ grub_normal_parse_line (suffix, getline);
+ grub_print_error ();
+ grub_free (suffix);
+
if (menu && menu->size)
grub_show_menu (menu, 1);
TYPE_REST_VERBATIM
} argt[4];
enum {
- FLAG_IGNORE_REST = 1
+ FLAG_IGNORE_REST = 1,
+ FLAG_SUFFIX = 2
} flags;
const char *shortdesc;
const char *longdesc;
"Halt your system. If APM is available on it, turn off the power using"
" the APM BIOS, unless you specify the option `--no-apm'."},
/* FIXME: help unsupported. */ /* NUL_TERMINATE */
- /* FIXME: hiddenmenu unsupported. */
+ {"hiddenmenu", "if sleep -i $timeout; then timeout=0; else timeout=-1; fi\n",
+ 0, {}, FLAG_SUFFIX, "", "Hide the menu."},
{"hide", "parttool '%s' hidden+\n", 1, {TYPE_PARTITION}, 0, "PARTITION",
"Hide PARTITION by setting the \"hidden\" bit in"
" its partition type code."},
}
char *
-grub_legacy_parse (const char *buf, char **entryname)
+grub_legacy_parse (const char *buf, char **entryname, int *suffix)
{
const char *ptr;
const char *cmdname;
unsigned i, cmdnum;
+ *suffix = 0;
+
for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++);
if (!*ptr || *ptr == '#')
return grub_strdup (buf);
if (cmdnum == ARRAY_SIZE (legacy_commands))
return grub_xasprintf ("# Unsupported legacy command: %s\n", buf);
+ *suffix = !!(legacy_commands[cmdnum].flags & FLAG_SUFFIX);
+
for (; grub_isspace (*ptr) || *ptr == '='; ptr++);
char *args[ARRAY_SIZE (legacy_commands[0].argt)];
#include <grub/types.h>
-char *grub_legacy_parse (const char *buf, char **entryname);
+char *grub_legacy_parse (const char *buf, char **entryname, int *suffix);
char *grub_legacy_escape (const char *in, grub_size_t len);
#endif
char *entryname = NULL;
char *buf = NULL;
size_t bufsize = 0;
+ char *suffix = xstrdup ("");
+ int suffixlen = 0;
+ int is_suffix = 0;
if (argc >= 2 && argv[1][0] == '-')
{
char *oldname = NULL;
oldname = entryname;
- parsed = grub_legacy_parse (buf, &entryname);
+ parsed = grub_legacy_parse (buf, &entryname, &is_suffix);
+ if (is_suffix)
+ {
+ suffixlen += strlen (parsed);
+ suffix = xrealloc (suffix, suffixlen + 1);
+ strcat (suffix, parsed);
+ continue;
+ }
if (oldname != entryname && oldname)
fprintf (out, "}\n\n");
if (oldname != entryname)
if (entryname)
fprintf (out, "}\n\n");
+ fwrite (out, 1, suffixlen, suffix);
if (in != stdin)
fclose (in);