/* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 2009 Free Software Foundation, Inc. * * VAS_EBOOT 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. * * VAS_EBOOT 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 VAS_EBOOT. If not, see . */ #include #include #include #include #include #include VAS_EBOOT_MOD_LICENSE ("GPLv3+"); static VasEBoot_err_t VasEBoot_cmd_eval (VasEBoot_command_t cmd __attribute__((__unused__)), int argc, char *argv[]) { int i; VasEBoot_size_t size = argc; /* +1 for final zero */ char *str, *p; VasEBoot_err_t ret; if (argc == 0) return VAS_EBOOT_ERR_NONE; for (i = 0; i < argc; i++) size += VasEBoot_strlen (argv[i]); str = p = VasEBoot_malloc (size); if (!str) return VasEBoot_errno; for (i = 0; i < argc; i++) { p = VasEBoot_stpcpy (p, argv[i]); *p++ = ' '; } *--p = '\0'; ret = VasEBoot_script_execute_sourcecode (str); VasEBoot_free (str); return ret; } static VasEBoot_command_t cmd; VAS_EBOOT_MOD_INIT(eval) { cmd = VasEBoot_register_command ("eval", VasEBoot_cmd_eval, N_("STRING ..."), N_("Evaluate arguments as VAS_EBOOT commands")); } VAS_EBOOT_MOD_FINI(eval) { VasEBoot_unregister_command (cmd); }