grub/commands/menuentry.c

64 lines
1.7 KiB
C
Raw Normal View History

2010-06-10 15:20:49 +00:00
/* menuentry.c - menuentry command */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB 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.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/normal.h>
static grub_err_t
grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
{
char *src;
2010-07-19 21:03:57 +00:00
unsigned len;
2010-06-10 15:20:49 +00:00
grub_err_t r;
/* XXX Rewrite to make use of already parsed menu definition. */
2010-07-20 22:20:23 +00:00
if (! argc || ! ctxt->script)
2010-06-10 15:20:49 +00:00
return GRUB_ERR_BAD_ARGUMENT;
src = args[argc - 1];
args[argc - 1] = '\0';
2010-07-19 21:03:57 +00:00
len = grub_strlen(src);
src[len - 1] = '\0';
2010-06-10 15:20:49 +00:00
2010-07-19 21:03:57 +00:00
r = grub_normal_add_menu_entry (argc - 1, (const char **) args, src + 1);
2010-06-10 15:20:49 +00:00
2010-07-19 21:03:57 +00:00
src[len - 1] = '}';
2010-06-10 15:20:49 +00:00
args[argc - 1] = src;
return r;
}
static grub_extcmd_t cmd;
GRUB_MOD_INIT(menuentry)
{
cmd = grub_register_extcmd ("menuentry", grub_cmd_menuentry,
GRUB_COMMAND_FLAG_BOTH | GRUB_COMMAND_FLAG_BLOCKS,
N_("BLOCK"), N_("Define a menuentry."), 0);
}
GRUB_MOD_FINI(menuentry)
{
grub_unregister_extcmd (cmd);
}