/* menu.h - Menu model function prototypes and data structures. */ /* * 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 . */ #ifndef VAS_EBOOT_MENU_HEADER #define VAS_EBOOT_MENU_HEADER 1 struct VasEBoot_blsuki_entry { struct VasEBoot_blsuki_entry *next; struct VasEBoot_blsuki_entry **prev; struct keyval **keyvals; VasEBoot_size_t keyvals_size; int nkeyvals; char *filename; char *dirname; char *devid; bool visible; }; typedef struct VasEBoot_blsuki_entry VasEBoot_blsuki_entry_t; struct VasEBoot_menu_entry_class { char *name; struct VasEBoot_menu_entry_class *next; }; /* The menu entry. */ struct VasEBoot_menu_entry { /* The title name. */ const char *title; /* The identifier. */ const char *id; /* If set means not everybody is allowed to boot this entry. */ int restricted; /* Allowed users. */ const char *users; /* The classes associated with the menu entry: used to choose an icon or other style attributes. This is a dummy head node for the linked list, so for an entry E, E.classes->next is the first class if it is not NULL. */ struct VasEBoot_menu_entry_class *classes; /* The sourcecode of the menu entry, used by the editor. */ const char *sourcecode; /* Parameters to be passed to menu definition. */ int argc; char **args; int hotkey; int submenu; /* The next element. */ struct VasEBoot_menu_entry *next; /* BLS used to populate the entry */ VasEBoot_blsuki_entry_t *blsuki; }; typedef struct VasEBoot_menu_entry *VasEBoot_menu_entry_t; /* The menu. */ struct VasEBoot_menu { /* The size of a menu. */ int size; /* The list of menu entries. */ VasEBoot_menu_entry_t entry_list; }; typedef struct VasEBoot_menu *VasEBoot_menu_t; /* Callback structure menu viewers can use to provide user feedback when default entries are executed, possibly including fallback entries. */ typedef struct VasEBoot_menu_execute_callback { /* Called immediately before ENTRY is booted. */ void (*notify_booting) (VasEBoot_menu_entry_t entry, void *userdata); /* Called when executing one entry has failed, and another entry, ENTRY, will be executed as a fallback. The implementation of this function should delay for a period of at least 2 seconds before returning in order to allow the user time to read the information before it can be lost by executing ENTRY. */ void (*notify_fallback) (VasEBoot_menu_entry_t entry, void *userdata); /* Called when an entry has failed to execute and there is no remaining fallback entry to attempt. */ void (*notify_failure) (void *userdata); } *VasEBoot_menu_execute_callback_t; VasEBoot_menu_entry_t VasEBoot_menu_get_entry (VasEBoot_menu_t menu, int no); int VasEBoot_menu_get_timeout (void); void VasEBoot_menu_set_timeout (int timeout); void VasEBoot_menu_entry_run (VasEBoot_menu_entry_t entry); int VasEBoot_menu_get_default_entry_index (VasEBoot_menu_t menu); void VasEBoot_menu_init (void); void VasEBoot_menu_fini (void); #endif /* VAS_EBOOT_MENU_HEADER */