From 230c0ad633d7720629af693f68ff8ad6831edc90 Mon Sep 17 00:00:00 2001 From: cbennett Date: Sun, 24 May 2009 08:39:29 +0000 Subject: [PATCH] 2009-05-23 Colin D Bennett Cleaned up `include/grub/normal.h'. Grouped prototypes by definition file, and functions defined in `normal/menu.c' have had their prototypes moved to `include/grub/menu.h' for consistency. * include/grub/menu.h (grub_menu_execute_callback): Added; moved from normal.h. (grub_menu_get_entry): Likewise. (grub_menu_get_timeout): Likewise. (grub_menu_set_timeout): Likewise. (grub_menu_execute_entry): Likewise. (grub_menu_execute_with_fallback): Likewise. (grub_menu_entry_run): Likewise. * include/grub/normal.h: Re-ordered and grouped function prototypes by file that the function is defined in. (grub_menu_execute_callback): Removed; moved to menu.h. (grub_menu_get_entry): Likewise. (grub_menu_get_timeout): Likewise. (grub_menu_set_timeout): Likewise. (grub_menu_execute_entry): Likewise. (grub_menu_execute_with_fallback): Likewise. (grub_menu_entry_run): Likewise. (grub_menu_addentry): Renamed from this ... (grub_normal_add_menu_entry): ... to this. * normal/main.c (grub_menu_addentry): Renamed from this ... (grub_normal_add_menu_entry): ... to this. * script/sh/execute.c (grub_script_execute_menuentry): Update reference to renamed grub_menu_addentry function. --- ChangeLog | 33 +++++++++++++++++++++++++ include/grub/menu.h | 33 ++++++++++++++++++++++++- include/grub/normal.h | 57 +++++++++++++++++-------------------------- normal/main.c | 7 ++++-- script/sh/execute.c | 4 +-- 5 files changed, 95 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15a116564..eac7ca707 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2009-05-23 Colin D Bennett + + Cleaned up `include/grub/normal.h'. Grouped prototypes by + definition file, and functions defined in `normal/menu.c' have had + their prototypes moved to `include/grub/menu.h' for consistency. + + * include/grub/menu.h (grub_menu_execute_callback): Added; moved + from normal.h. + (grub_menu_get_entry): Likewise. + (grub_menu_get_timeout): Likewise. + (grub_menu_set_timeout): Likewise. + (grub_menu_execute_entry): Likewise. + (grub_menu_execute_with_fallback): Likewise. + (grub_menu_entry_run): Likewise. + + * include/grub/normal.h: Re-ordered and grouped function + prototypes by file that the function is defined in. + (grub_menu_execute_callback): Removed; moved to menu.h. + (grub_menu_get_entry): Likewise. + (grub_menu_get_timeout): Likewise. + (grub_menu_set_timeout): Likewise. + (grub_menu_execute_entry): Likewise. + (grub_menu_execute_with_fallback): Likewise. + (grub_menu_entry_run): Likewise. + (grub_menu_addentry): Renamed from this ... + (grub_normal_add_menu_entry): ... to this. + + * normal/main.c (grub_menu_addentry): Renamed from this ... + (grub_normal_add_menu_entry): ... to this. + + * script/sh/execute.c (grub_script_execute_menuentry): Update + reference to renamed grub_menu_addentry function. + 2009-05-23 Felix Zielcke * commands/i386/pc/drivemap.c (MODNAME): Remove. Update all users. diff --git a/include/grub/menu.h b/include/grub/menu.h index f11e00516..3bd25e875 100644 --- a/include/grub/menu.h +++ b/include/grub/menu.h @@ -1,4 +1,4 @@ -/* menu.h - Menu and menu entry model declarations. */ +/* menu.h - Menu model function prototypes and data structures. */ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 2009 Free Software Foundation, Inc. @@ -57,4 +57,35 @@ struct grub_menu }; typedef struct grub_menu *grub_menu_t; +/* Callback structure menu viewers can use to provide user feedback when + default entries are executed, possibly including fallback entries. */ +typedef struct grub_menu_execute_callback +{ + /* Called immediately before ENTRY is booted. */ + void (*notify_booting) (grub_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) (grub_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); +} +*grub_menu_execute_callback_t; + + +grub_menu_entry_t grub_menu_get_entry (grub_menu_t menu, int no); +int grub_menu_get_timeout (void); +void grub_menu_set_timeout (int timeout); +void grub_menu_execute_entry (grub_menu_entry_t entry); +void grub_menu_execute_with_fallback (grub_menu_t menu, + grub_menu_entry_t entry, + grub_menu_execute_callback_t callback, + void *callback_data); +void grub_menu_entry_run (grub_menu_entry_t entry); + #endif /* GRUB_MENU_HEADER */ diff --git a/include/grub/normal.h b/include/grub/normal.h index 948289aa6..7d8122a2b 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -43,58 +43,47 @@ typedef enum grub_completion_type grub_completion_type_t; extern struct grub_menu_viewer grub_normal_text_menu_viewer; -/* Callback structure menu viewers can use to provide user feedback when - default entries are executed, possibly including fallback entries. */ -typedef struct grub_menu_execute_callback -{ - /* Called immediately before ENTRY is booted. */ - void (*notify_booting) (grub_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) (grub_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); -} -*grub_menu_execute_callback_t; +/* Defined in `main.c'. */ void grub_enter_normal_mode (const char *config); void grub_normal_execute (const char *config, int nested, int batch); -void grub_menu_execute_with_fallback (grub_menu_t menu, - grub_menu_entry_t entry, - grub_menu_execute_callback_t callback, - void *callback_data); -void grub_menu_entry_run (grub_menu_entry_t entry); -void grub_menu_execute_entry(grub_menu_entry_t entry); -grub_menu_entry_t grub_menu_get_entry (grub_menu_t menu, int no); -int grub_menu_get_timeout (void); -void grub_menu_set_timeout (int timeout); +void grub_normal_init_page (void); +void grub_menu_init_page (int nested, int edit); +grub_err_t grub_normal_add_menu_entry (int argc, const char **args, + const char *sourcecode); +char *grub_file_getline (grub_file_t file); +void grub_cmdline_run (int nested); + +/* Defined in `cmdline.c'. */ int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, int echo_char, int readline); grub_err_t grub_set_history (int newsize); -void grub_normal_init_page (void); -void grub_menu_init_page (int nested, int edit); + +/* Defined in `completion.c'. */ char *grub_normal_do_completion (char *buf, int *restore, void (*hook) (const char *item, grub_completion_type_t type, int count)); + +/* Defined in `misc.c'. */ grub_err_t grub_normal_print_device_info (const char *name); + +/* Defined in `color.c'. */ char *grub_env_write_color_normal (struct grub_env_var *var, const char *val); char *grub_env_write_color_highlight (struct grub_env_var *var, const char *val); void grub_parse_color_name_pair (grub_uint8_t *ret, const char *name); + +/* Defined in `menu_text.c'. */ void grub_wait_after_message (void); -char *grub_file_getline (grub_file_t file); +/* Defined in `handler.c'. */ void read_handler_list (void); void free_handler_list (void); + +/* Defined in `dyncmd.c'. */ void read_command_list (void); + +/* Defined in `autofs.c'. */ void read_fs_list (void); -void grub_cmdline_run (int nested); -grub_err_t grub_menu_addentry (int argc, const char **args, - const char *sourcecode); + #ifdef GRUB_UTIL void grub_normal_init (void); diff --git a/normal/main.c b/normal/main.c index bc0808b02..9c5a82731 100644 --- a/normal/main.c +++ b/normal/main.c @@ -149,9 +149,12 @@ free_menu_entry_classes (struct grub_menu_entry_class *head) } } +/* Add a menu entry to the current menu context (as given by the environment + variable data slot `menu'). As the configuration file is read, the script + parser calls this when a menu entry is to be created. */ grub_err_t -grub_menu_addentry (int argc, const char **args, - const char *sourcecode) +grub_normal_add_menu_entry (int argc, const char **args, + const char *sourcecode) { const char *menutitle = 0; const char *menusourcecode; diff --git a/script/sh/execute.c b/script/sh/execute.c index 123bca8b1..0989f7917 100644 --- a/script/sh/execute.c +++ b/script/sh/execute.c @@ -222,8 +222,8 @@ grub_script_execute_menuentry (struct grub_script_cmd *cmd) } } - grub_menu_addentry (argcount, (const char **) args, - cmd_menuentry->sourcecode); + grub_normal_add_menu_entry (argcount, (const char **) args, + cmd_menuentry->sourcecode); /* Free arguments. */ for (i = 0; i < argcount; i++)