Example #1
0
static void
grub_load_config (void)
{
  auto int hook (struct grub_module_header *);
  int hook (struct grub_module_header *header)
    {
      /* Not an embedded config, skip.  */
      if (header->type != OBJ_TYPE_CONFIG)
	return 0;

      grub_parser_execute ((char *) header +
			   sizeof (struct grub_module_header));
      return 1;
    }

  grub_module_iterate (hook);
}
Example #2
0
/* Run a menu entry.  */
void
grub_menu_execute_entry(grub_menu_entry_t entry)
{
  grub_err_t err = GRUB_ERR_NONE;

  if (entry->restricted)
    err = grub_normal_check_authentication (entry->users);

  if (err)
    {
      grub_print_error ();
      grub_errno = GRUB_ERR_NONE;
      return;
    }

  grub_env_set ("chosen", entry->title);

  grub_parser_execute ((char *) entry->sourcecode);

  if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
    /* Implicit execution of boot, only if something is loaded.  */
    grub_command_execute ("boot", 0, 0);
}
Example #3
0
static int
match_string (grub_uitree_t node, const char *str)
{
    grub_uitree_t child;
    char *cmd;

    child = node->child;
    while (child)
    {
        int len;

        len = grub_strlen (child->name);
        if (! grub_memcmp (child->name, str, len))
        {
            const char *p;

            p = str + len;
            if ((*p == '.') || (*p == '-'))
                p++;

            if (match_string (child, p))
                return 1;
        }

        child = child->next;
    }

    cmd = grub_uitree_get_prop (node, "command");
    if (cmd)
    {
        grub_parser_execute (cmd);
        return 1;
    }

    return 0;
}