Lines Matching full:item

16  * Internally, each item in a menu is represented by a struct menu_item.
46 * An iterator function for menu items. callback will be called for each item
47 * in m, with m, a pointer to the item, and extra being passed to callback. If
51 * item from the list of items.
58 struct menu_item *item; in menu_items_iter() local
62 item = list_entry(pos, struct menu_item, list); in menu_items_iter()
64 ret = callback(m, item, extra); in menu_items_iter()
75 * when creating the menu, call it with a pointer to the item's private data.
76 * Otherwise, print the key of the item.
79 struct menu_item *item, in menu_item_print() argument
83 puts(item->key); in menu_item_print()
86 m->item_data_print(item->data); in menu_item_print()
93 * Free the memory used by a menu item. This includes the memory used by its
97 struct menu_item *item, in menu_item_destroy() argument
100 if (item->key) in menu_item_destroy()
101 free(item->key); in menu_item_destroy()
103 free(item); in menu_item_destroy()
113 * Display a menu so the user can make a choice of an item. First display its
114 * title, if any, and then each item in the menu.
128 * Check if an item's key matches a provided string, pointed to by extra. If
129 * extra is NULL, an item with a NULL key will match. Otherwise, the item's
132 * This is called via menu_items_iter, so it returns a pointer to the item if
136 struct menu_item *item, void *extra) in menu_item_key_match() argument
140 if (!item_key || !item->key) { in menu_item_key_match()
141 if (item_key == item->key) in menu_item_key_match()
142 return item; in menu_item_key_match()
147 if (strcmp(item->key, item_key) == 0) in menu_item_key_match()
148 return item; in menu_item_key_match()
154 * Find the first item with a key matching item_key, if any exists.
163 * Set *choice to point to the default item's data, if any default item was
164 * set, and returns 1. If no default item was set, returns -ENOENT.
177 * Displays the menu and asks the user to choose an item. *choice will point
178 * to the private data of the item the user chooses. The user makes a choice
179 * by inputting a string matching the key of an item. Invalid choices will
234 * key for an existing item in the menu.
236 * Returns 1 if successful, -EINVAL if m is NULL, or -ENOENT if no item with a
241 struct menu_item *item; in menu_default_set() local
246 item = menu_item_by_key(m, item_key); in menu_default_set()
248 if (!item) in menu_default_set()
251 m->default_item = item; in menu_default_set()
264 * menu item. If no item is selected or there is an error, no value will be
283 * menu_item_add() - Adds or replaces a menu item. Note that this replaces the
284 * data of an item if it already exists, but doesn't change the order of the
285 * item.
289 * item_key - Points to a string that will uniquely identify the item. The
293 * item_data - An opaque pointer associated with an item. It is never
295 * will be returned from menu_get_choice if the menu item is selected.
298 * insufficient memory to add the menu item.
302 struct menu_item *item; in menu_item_add() local
307 item = menu_item_by_key(m, item_key); in menu_item_add()
309 if (item) { in menu_item_add()
310 item->data = item_data; in menu_item_add()
314 item = malloc(sizeof *item); in menu_item_add()
315 if (!item) in menu_item_add()
318 item->key = strdup(item_key); in menu_item_add()
320 if (!item->key) { in menu_item_add()
321 free(item); in menu_item_add()
325 item->data = item_data; in menu_item_add()
327 list_add_tail(&item->list, &m->items); in menu_item_add()
346 * item_data_print - If not NULL, will be called for each item when the menu
347 * is displayed, with the pointer to the item's data passed as the argument.
348 * If NULL, each item's key will be printed instead. Since an item's key is
349 * what must be entered to select an item, the item_data_print function should
353 * item. Returns a key string corresponding to the chosen item or NULL if
354 * no item has been selected.