/* Searches the menu for menuitems that start with the key parameter.  */
static int menu_key_find(const menu_t *menu, const char *key)
/* Searches the menu for menuitems that start with the key parameter.  */
static int menu_key_find(const menu_t *menu, const char *key)
{
    int menuitem_found = MenuKeyFindNone;
    int num_found = 0;
    int menu_size = menu_get_size(menu);
    int index = 0;
    for (index = 0; index < menu_size; ++index)
    {
        if (menu->menuitems[index].key == NULL)
            continue;
        if (strncasecmp(key, menu->menuitems[index].key, strlen(key)) == 0)
        {
            if (menuitem_found == MenuKeyFindNone)
                menuitem_found = index;
            ++num_found;
        }
    }
    return num_found == 0 ? MenuKeyFindNone :
           num_found > 1 ? MenuKeyFindMoreThanOne : menuitem_found;
}