openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/disk-utils/cfdisk.c
static int ask_menu(struct fdisk_ask* ask, struct cfdisk* cf)
{
    struct cfdisk_menuitem *d, *cm;
    int key;
    size_t i = 0, nitems;
    const char *name, *desc;

    assert(ask);
    assert(cf);

    /* create cfdisk menu according to libfdisk ask-menu, note that the
     * last cm[] item has to be empty -- so nitems + 1 */
    nitems = fdisk_ask_menu_get_nitems(ask);
    cm = xcalloc(nitems + 1, sizeof(struct cfdisk_menuitem));

    for (i = 0; i < nitems; i++)
    {
        if (fdisk_ask_menu_get_item(ask, i, &key, &name, &desc))
            break;
        cm[i].key = key;
        cm[i].desc = desc;
        cm[i].name = name;
    }

    /* make the new menu active */
    menu_push(cf, cm);
    ui_draw_menu(cf);
    refresh();

    /* wait for keys */
    while (!sig_die)
    {
        key = getch();

        if (sig_die)
            break;
        if (sig_resize)
            ui_menu_resize(cf);
        if (ui_menu_move(cf, key) == 0)
            continue;

        switch (key)
        {
            case KEY_ENTER:
            case '\n':
            case '\r':
                d = menu_get_menuitem(cf, cf->menu->idx);
                if (d)
                    fdisk_ask_menu_set_result(ask, d->key);
                menu_pop(cf);
                free(cm);
                return 0;
        }
    }

    if (sig_die)
        die_on_signal();

    menu_pop(cf);
    free(cm);
    return -1;
}
/* converts libfdisk FDISK_ASKTYPE_MENU to cfdisk menu and returns user's
 * response back to libfdisk
 */
converts libfdisk FDISK_ASKTYPE_MENU to cfdisk menu and returns user's
response back to libfdisk
converts libfdisk FDISK_ASKTYPE_MENU to cfdisk menu and returns user ' s response back to libfdisk
static int ask_menu(struct fdisk_ask* ask, struct cfdisk* cf)
{
    struct cfdisk_menuitem *d, *cm;
    int key;
    size_t i = 0, nitems;
    const char *name, *desc;
    assert(ask);
    assert(cf);
    nitems = fdisk_ask_menu_get_nitems(ask);
    cm = xcalloc(nitems + 1, sizeof(struct cfdisk_menuitem));
    for (i = 0; i < nitems; i++)
    {
        if (fdisk_ask_menu_get_item(ask, i, &key, &name, &desc))
            break;
        cm[i].key = key;
        cm[i].desc = desc;
        cm[i].name = name;
    }
    menu_push(cf, cm);
    ui_draw_menu(cf);
    refresh();
    while (!sig_die)
    {
        key = getch();
        if (sig_die)
            break;
        if (sig_resize)
            ui_menu_resize(cf);
        if (ui_menu_move(cf, key) == 0)
            continue;
        switch (key)
        {
            case KEY_ENTER:
            case '\n':
            case '\r':
                d = menu_get_menuitem(cf, cf->menu->idx);
                if (d)
                    fdisk_ask_menu_set_result(ask, d->key);
                menu_pop(cf);
                free(cm);
                return 0;
        }
    }
    if (sig_die)
        die_on_signal();
    menu_pop(cf);
    free(cm);
    return -1;
}
static int ask_menu ( struct fdisk_ask * ask , struct cfdisk * cf ) { struct cfdisk_menuitem * d , * cm ; int key ; size_t i = 0 , nitems ; const char * name , * desc ; assert ( ask ) ; assert ( cf ) ; nitems = fdisk_ask_menu_get_nitems ( ask ) ; cm = xcalloc ( nitems + 1 , sizeof ( struct cfdisk_menuitem ) ) ; for ( i = 0 ; i < nitems ; i ++ ) { if ( fdisk_ask_menu_get_item ( ask , i , & key , & name , & desc ) ) break ; cm [ i ] . key = key ; cm [ i ] . desc = desc ; cm [ i ] . name = name ; } menu_push ( cf , cm ) ; ui_draw_menu ( cf ) ; refresh ( ) ; while ( ! sig_die ) { key = getch ( ) ; if ( sig_die ) break ; if ( sig_resize ) ui_menu_resize ( cf ) ; if ( ui_menu_move ( cf , key ) == 0 ) continue ; switch ( key ) { case KEY_ENTER : case ' \n ' : case ' \r ' : d = menu_get_menuitem ( cf , cf -> menu -> idx ) ; if ( d ) fdisk_ask_menu_set_result ( ask , d -> key ) ; menu_pop ( cf ) ; free ( cm ) ; return 0 ; } } if ( sig_die ) die_on_signal ( ) ; menu_pop ( cf ) ; free ( cm ) ; return -1 ; }
converts libfdisk FDISK_ASKTYPE_MENU to cfdisk menu and returns user's
 response back to libfdisk
converts libfdisk FDISK_ASKTYPE_MENU to cfdisk menu and returns user ' s response back to libfdisk
/* create cfdisk menu according to libfdisk ask-menu, note that the
     * last cm[] item has to be empty -- so nitems + 1 */ /* make the new menu active */ /* wait for keys */