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/fdisk-menu.c
int process_fdisk_menu(struct fdisk_context** cxt0)
{
    struct fdisk_context* cxt = *cxt0;
    const struct menu_entry* ent;
    const struct menu* menu;
    int key, rc;
    const char* prompt;
    char buf[BUFSIZ];

    if (fdisk_is_details(cxt))
        prompt = _("Expert command (m for help): ");
    else
        prompt = _("Command (m for help): ");

    fputc('\n', stdout);
    rc = get_user_reply(prompt, buf, sizeof(buf));

    if (rc == -ECANCELED)
    {
        /* Map ^C and ^D in main menu to 'q' */
        if (is_interactive &&
            fdisk_label_is_changed(fdisk_get_label(cxt, NULL)))
        {
            rc = get_user_reply(_("\nDo you really want to quit? "), buf,
                                sizeof(buf));
            if (rc || !rpmatch(buf))
                return 0;
        }
        key = 'q';
    }
    else if (rc)
    {
        return rc;
    }
    else
        key = buf[0];

    ent = get_fdisk_menu_entry(cxt, key, &menu);
    if (!ent)
    {
        fdisk_warnx(cxt, _("%c: unknown command"), key);
        return -EINVAL;
    }

    DBG(MENU, ul_debug("selected: key=%c, entry='%s'", key, ent->title));

    /* menu has implemented callback, use it */
    if (menu->callback)
        rc = menu->callback(cxt0, menu, ent);
    else
    {
        DBG(MENU, ul_debug("no callback for key '%c'", key));
        rc = -EINVAL;
    }

    DBG(MENU, ul_debug("process menu done [rc=%d]", rc));
    return rc;
}
/* Asks for command, verify the key and perform the command or
 * returns the command key if no callback for the command is
 * implemented.
 *
 * Note that this function might exchange the context pointer to
 * switch to another (nested) context.
 *
 * Returns: <0 on error
 *           0 on success (the command performed)
 *          >0 if no callback (then returns the key)
 */
Asks for command, verify the key and perform the command or
returns the command key if no callback for the command is
implemented.

Note that this function might exchange the context pointer to
switch to another (nested) context.

<0 on error
0 on success (the command performed)
>0 if no callback (then returns the key)
Asks for command verify the key and perform the command or returns the command key if no callback for the command is implemented . Note that this function might exchange the context pointer to switch to another ( nested ) context . <0 on error 0 on success ( the command performed ) > 0 if no callback ( then returns the key )
int process_fdisk_menu(struct fdisk_context** cxt0)
{
    struct fdisk_context* cxt = *cxt0;
    const struct menu_entry* ent;
    const struct menu* menu;
    int key, rc;
    const char* prompt;
    char buf[BUFSIZ];
    if (fdisk_is_details(cxt))
        prompt = _("Expert command (m for help): ");
    else
        prompt = _("Command (m for help): ");
    fputc('\n', stdout);
    rc = get_user_reply(prompt, buf, sizeof(buf));
    if (rc == -ECANCELED)
    {
        if (is_interactive &&
            fdisk_label_is_changed(fdisk_get_label(cxt, NULL)))
        {
            rc = get_user_reply(_("\nDo you really want to quit? "), buf,
                                sizeof(buf));
            if (rc || !rpmatch(buf))
                return 0;
        }
        key = 'q';
    }
    else if (rc)
    {
        return rc;
    }
    else
        key = buf[0];
    ent = get_fdisk_menu_entry(cxt, key, &menu);
    if (!ent)
    {
        fdisk_warnx(cxt, _("%c: unknown command"), key);
        return -EINVAL;
    }
    DBG(MENU, ul_debug("selected: key=%c, entry='%s'", key, ent->title));
    if (menu->callback)
        rc = menu->callback(cxt0, menu, ent);
    else
    {
        DBG(MENU, ul_debug("no callback for key '%c'", key));
        rc = -EINVAL;
    }
    DBG(MENU, ul_debug("process menu done [rc=%d]", rc));
    return rc;
}
int process_fdisk_menu ( struct fdisk_context * * cxt0 ) { struct fdisk_context * cxt = * cxt0 ; const struct menu_entry * ent ; const struct menu * menu ; int key , rc ; const char * prompt ; char buf [ BUFSIZ ] ; if ( fdisk_is_details ( cxt ) ) prompt = _ ( " " ) ; else prompt = _ ( " " ) ; fputc ( ' \n ' , stdout ) ; rc = get_user_reply ( prompt , buf , sizeof ( buf ) ) ; if ( rc == - ECANCELED ) { if ( is_interactive && fdisk_label_is_changed ( fdisk_get_label ( cxt , NULL ) ) ) { rc = get_user_reply ( _ ( " \n " ) , buf , sizeof ( buf ) ) ; if ( rc || ! rpmatch ( buf ) ) return 0 ; } key = ' ' ; } else if ( rc ) { return rc ; } else key = buf [ 0 ] ; ent = get_fdisk_menu_entry ( cxt , key , & menu ) ; if ( ! ent ) { fdisk_warnx ( cxt , _ ( " " ) , key ) ; return - EINVAL ; } DBG ( MENU , ul_debug ( " " , key , ent -> title ) ) ; if ( menu -> callback ) rc = menu -> callback ( cxt0 , menu , ent ) ; else { DBG ( MENU , ul_debug ( " " , key ) ) ; rc = - EINVAL ; } DBG ( MENU , ul_debug ( " " , rc ) ) ; return rc ; }
Asks for command, verify the key and perform the command or
 returns the command key if no callback for the command is
 implemented.
Asks for command verify the key and perform the command or returns the command key if no callback for the command is implemented .
/* Map ^C and ^D in main menu to 'q' */ /* menu has implemented callback, use it */