From: BVK Chaitanya Date: Tue, 20 Jul 2010 22:20:23 +0000 (+0530) Subject: pull-in block-arg again X-Git-Tag: 1.99~596^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bcfd8a295c0a09fb6b4362fde14e2e471b05b08;p=thirdparty%2Fgrub.git pull-in block-arg again --- 2bcfd8a295c0a09fb6b4362fde14e2e471b05b08 diff --cc commands/extcmd.c index 9dbb0a2ce,cc0362e14..8fe2ead35 --- a/commands/extcmd.c +++ b/commands/extcmd.c @@@ -38,9 -38,11 +38,9 @@@ grub_extcmd_dispatcher (struct grub_com context.state = 0; context.extcmd = ext; - context.script_params = scripts; + context.script = script; - /* Dynamic commands should not perform option parsing before - corresponding module gets loaded. */ - if (cmd->flags & GRUB_COMMAND_FLAG_DYNCMD) + if (! ext->options) { ret = (ext->func) (&context, argc, args); return ret; diff --cc commands/menuentry.c index 0ce5a9e0e,000000000..2d389e942 mode 100644,000000..100644 --- a/commands/menuentry.c +++ b/commands/menuentry.c @@@ -1,63 -1,0 +1,63 @@@ +/* 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 . + */ + +#include +#include +#include +#include +#include +#include +#include + +static grub_err_t +grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) +{ + char *src; + unsigned len; + grub_err_t r; + + /* XXX Rewrite to make use of already parsed menu definition. */ - if (! argc || ! ctxt->script_params || ! ctxt->script_params[argc - 1]) ++ if (! argc || ! ctxt->script) + return GRUB_ERR_BAD_ARGUMENT; + + src = args[argc - 1]; + args[argc - 1] = '\0'; + len = grub_strlen(src); + src[len - 1] = '\0'; + + r = grub_normal_add_menu_entry (argc - 1, (const char **) args, src + 1); + + src[len - 1] = '}'; + 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); +}