summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-08-21 20:09:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-08-30 21:06:02 +0200
commit0d35c3c8a0c2a1f1ff06eac20a12af0186753bc4 (patch)
treea3a82df9c3b83f36b2fecbd9faadb6b55fd19efd /include
parentc0477d8233369aed15a48239886ffa679802c48a (diff)
downloadbarebox-0d35c3c8a0c2a1f1ff06eac20a12af0186753bc4.tar.gz
barebox-0d35c3c8a0c2a1f1ff06eac20a12af0186753bc4.tar.xz
menu: simplify usage for clients
Clients now only have to call menu_add_submenu or menu_add_command_entry instead of allocating many strings. This also fixes some problems in the menu code. The priv field in struct menu_entry was a pointer to struct menu or a pointer to an allocated string. It was never freed, only had to be freed when it was an allocated string. The reference to a submenu is now kept as a string and not to the menu itself. The code checked the existence of the submenu when creating it, but crashed when the submenu was removed and referenced afterwards. Now the code hapily allows references to nonexistant menus but complains during runtime when the menu is not there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/menu.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/menu.h b/include/menu.h
index 4f85ed69f8..22bfc2301f 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -32,10 +32,10 @@ struct menu_entry {
int num;
char *display;
void (*action)(struct menu *m, struct menu_entry *me);
+ void (*free)(struct menu_entry *me);
int non_re_ent;
struct list_head list;
- void *priv;
};
struct menu {
@@ -65,6 +65,8 @@ static inline struct menu* menu_alloc(void)
}
return m;
}
+struct menu_entry *menu_add_submenu(struct menu *parent, char *submenu, char *display);
+struct menu_entry *menu_add_command_entry(struct menu *m, char *display, char *command);
void menu_free(struct menu *m);
int menu_add(struct menu* m);
void menu_remove(struct menu *m);
@@ -89,8 +91,6 @@ struct menu_entry* menu_entry_get_by_num(struct menu* m, int num);
/*
* menu entry action functions
*/
-void menu_action_run(struct menu *m, struct menu_entry *me);
-void menu_action_show(struct menu *m, struct menu_entry *me);
void menu_action_exit(struct menu *m, struct menu_entry *me);
#endif /* __MENU_H__ */