コード例 #1
0
ファイル: bitsmodule.c プロジェクト: mfleming/bits
static PyObject *bits_register_grub_command(PyObject *self, PyObject *args)
{
    const char *cmd, *summary, *description;
    char *cmd_copy, *summary_copy, *description_copy;

    if (!grub_command_callback)
        return PyErr_Format(PyExc_RuntimeError, "Internal error: attempted to register grub command before setting callback.");

    if (!PyArg_ParseTuple(args, "sss:register_grub_command", &cmd, &summary, &description))
        return NULL;

    cmd_copy = grub_strdup(cmd);
    summary_copy = grub_strdup(summary);
    description_copy = grub_strdup(description);
    if (!cmd_copy || !summary_copy || !description_copy) {
        grub_free(cmd_copy);
        grub_free(summary_copy);
        grub_free(description_copy);
        return PyErr_NoMemory();
    }

    grub_register_command(cmd_copy, grub_cmd_pydispatch, summary_copy, description_copy);

    return Py_BuildValue("");
}
コード例 #2
0
ファイル: main.c プロジェクト: Arvian/GRUB2
void
grub_script_init (void)
{
  cmd_break = grub_register_command ("break", grub_script_break,
				     N_("[NUM]"), N_("Exit from loops"));
  cmd_continue = grub_register_command ("continue", grub_script_break,
					N_("[NUM]"), N_("Continue loops"));
  cmd_shift = grub_register_command ("shift", grub_script_shift,
				     N_("[NUM]"),
				     /* TRANSLATORS: Positional arguments are
					arguments $0, $1, $2, ...  */
				     N_("Shift positional parameters."));
  cmd_setparams = grub_register_command ("setparams", grub_script_setparams,
					 N_("[VALUE]..."),
					 N_("Set positional parameters."));
  cmd_return = grub_register_command ("return", grub_script_return,
				      N_("[NUM]"),
				      /* TRANSLATORS: It's a command description
					 and "Return" is a verb, not a noun. The
					 command in question is "return" and
					 has exactly the same semanics as bash
					 equivalent.  */
				      N_("Return from a function."));
}