static void do_sendkey(Monitor *mon, const QDict *qdict)

{

    char keyname_buf[16];

    char *separator;

    int keyname_len, keycode, i, idx;

    const char *keys = qdict_get_str(qdict, "keys");

    int has_hold_time = qdict_haskey(qdict, "hold-time");

    int hold_time = qdict_get_try_int(qdict, "hold-time", -1);



    if (nb_pending_keycodes > 0) {

        qemu_del_timer(key_timer);

        release_keys(NULL);

    }

    if (!has_hold_time)

        hold_time = 100;

    i = 0;

    while (1) {

        separator = strchr(keys, '-');

        keyname_len = separator ? separator - keys : strlen(keys);

        if (keyname_len > 0) {

            pstrcpy(keyname_buf, sizeof(keyname_buf), keys);

            if (keyname_len > sizeof(keyname_buf) - 1) {

                monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf);

                return;

            }

            if (i == MAX_KEYCODES) {

                monitor_printf(mon, "too many keys\n");

                return;

            }



            /* Be compatible with old interface, convert user inputted "<" */

            if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) {

                pstrcpy(keyname_buf, sizeof(keyname_buf), "less");

                keyname_len = 4;

            }



            keyname_buf[keyname_len] = 0;



            idx = index_from_key(keyname_buf);

            if (idx == Q_KEY_CODE_MAX) {

                monitor_printf(mon, "invalid parameter: %s\n", keyname_buf);

                return;

            }



            keycode = key_defs[idx];

            if (keycode < 0) {

                monitor_printf(mon, "unknown key: '%s'\n", keyname_buf);

                return;

            }

            keycodes[i++] = keycode;

        }

        if (!separator)

            break;

        keys = separator + 1;

    }

    nb_pending_keycodes = i;

    /* key down events */

    for (i = 0; i < nb_pending_keycodes; i++) {

        keycode = keycodes[i];

        if (keycode & 0x80)

            kbd_put_keycode(0xe0);

        kbd_put_keycode(keycode & 0x7f);

    }

    /* delayed key up events */

    qemu_mod_timer(key_timer, qemu_get_clock_ns(vm_clock) +

                   muldiv64(get_ticks_per_sec(), hold_time, 1000));

}

static void do_sendkey(Monitor *mon, const QDict *qdict)

{

    char keyname_buf[16];

    char *separator;

    int keyname_len, keycode, i, idx;

    const char *keys = qdict_get_str(qdict, "keys");

    int has_hold_time = qdict_haskey(qdict, "hold-time");

    int hold_time = qdict_get_try_int(qdict, "hold-time", -1);



    if (nb_pending_keycodes > 0) {

        qemu_del_timer(key_timer);

        release_keys(NULL);

    }

    if (!has_hold_time)

        hold_time = 100;

    i = 0;

    while (1) {

        separator = strchr(keys, '-');

        keyname_len = separator ? separator - keys : strlen(keys);

        if (keyname_len > 0) {

            pstrcpy(keyname_buf, sizeof(keyname_buf), keys);

            if (keyname_len > sizeof(keyname_buf) - 1) {

                monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf);

                return;

            }

            if (i == MAX_KEYCODES) {

                monitor_printf(mon, "too many keys\n");

                return;

            }



            

            if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) {

                pstrcpy(keyname_buf, sizeof(keyname_buf), "less");

                keyname_len = 4;

            }



            keyname_buf[keyname_len] = 0;



            idx = index_from_key(keyname_buf);

            if (idx == Q_KEY_CODE_MAX) {

                monitor_printf(mon, "invalid parameter: %s\n", keyname_buf);

                return;

            }



            keycode = key_defs[idx];

            if (keycode < 0) {

                monitor_printf(mon, "unknown key: '%s'\n", keyname_buf);

                return;

            }

            keycodes[i++] = keycode;

        }

        if (!separator)

            break;

        keys = separator + 1;

    }

    nb_pending_keycodes = i;

    

    for (i = 0; i < nb_pending_keycodes; i++) {

        keycode = keycodes[i];

        if (keycode & 0x80)

            kbd_put_keycode(0xe0);

        kbd_put_keycode(keycode & 0x7f);

    }

    

    qemu_mod_timer(key_timer, qemu_get_clock_ns(vm_clock) +

                   muldiv64(get_ticks_per_sec(), hold_time, 1000));

}

static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)

{

    char VAR_2[16];

    char *VAR_3;

    int VAR_4, VAR_5, VAR_6, VAR_7;

    const char *VAR_8 = qdict_get_str(VAR_1, "VAR_8");

    int VAR_9 = qdict_haskey(VAR_1, "hold-time");

    int VAR_10 = qdict_get_try_int(VAR_1, "hold-time", -1);



    if (nb_pending_keycodes > 0) {

        qemu_del_timer(key_timer);

        release_keys(NULL);

    }

    if (!VAR_9)

        VAR_10 = 100;

    VAR_6 = 0;

    while (1) {

        VAR_3 = strchr(VAR_8, '-');

        VAR_4 = VAR_3 ? VAR_3 - VAR_8 : strlen(VAR_8);

        if (VAR_4 > 0) {

            pstrcpy(VAR_2, sizeof(VAR_2), VAR_8);

            if (VAR_4 > sizeof(VAR_2) - 1) {

                monitor_printf(VAR_0, "invalid key: '%s...'\n", VAR_2);

                return;

            }

            if (VAR_6 == MAX_KEYCODES) {

                monitor_printf(VAR_0, "too many VAR_8\n");

                return;

            }



            

            if (!strncmp(VAR_2, "<", 1) && VAR_4 == 1) {

                pstrcpy(VAR_2, sizeof(VAR_2), "less");

                VAR_4 = 4;

            }



            VAR_2[VAR_4] = 0;



            VAR_7 = index_from_key(VAR_2);

            if (VAR_7 == Q_KEY_CODE_MAX) {

                monitor_printf(VAR_0, "invalid parameter: %s\n", VAR_2);

                return;

            }



            VAR_5 = key_defs[VAR_7];

            if (VAR_5 < 0) {

                monitor_printf(VAR_0, "unknown key: '%s'\n", VAR_2);

                return;

            }

            keycodes[VAR_6++] = VAR_5;

        }

        if (!VAR_3)

            break;

        VAR_8 = VAR_3 + 1;

    }

    nb_pending_keycodes = VAR_6;

    

    for (VAR_6 = 0; VAR_6 < nb_pending_keycodes; VAR_6++) {

        VAR_5 = keycodes[VAR_6];

        if (VAR_5 & 0x80)

            kbd_put_keycode(0xe0);

        kbd_put_keycode(VAR_5 & 0x7f);

    }

    

    qemu_mod_timer(key_timer, qemu_get_clock_ns(vm_clock) +

                   muldiv64(get_ticks_per_sec(), VAR_10, 1000));

}

static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{ char VAR_2[16]; char *VAR_3; int VAR_4, VAR_5, VAR_6, VAR_7; const char *VAR_8 = qdict_get_str(VAR_1, "VAR_8"); int VAR_9 = qdict_haskey(VAR_1, "hold-time"); int VAR_10 = qdict_get_try_int(VAR_1, "hold-time", -1); if (nb_pending_keycodes > 0) { qemu_del_timer(key_timer); release_keys(NULL); } if (!VAR_9)
VAR_10 = 100; VAR_6 = 0; while (1) { VAR_3 = strchr(VAR_8, '-'); VAR_4 = VAR_3 ? VAR_3 - VAR_8 : strlen(VAR_8); if (VAR_4 > 0) { pstrcpy(VAR_2, sizeof(VAR_2), VAR_8); if (VAR_4 > sizeof(VAR_2) - 1) { monitor_printf(VAR_0, "invalid key: '%s...'\n", VAR_2); return; } if (VAR_6 == MAX_KEYCODES) { monitor_printf(VAR_0, "too many VAR_8\n"); return; } if (!strncmp(VAR_2, "<", 1) && VAR_4 == 1) { pstrcpy(VAR_2, sizeof(VAR_2), "less"); VAR_4 = 4; } VAR_2[VAR_4] = 0; VAR_7 = index_from_key(VAR_2); if (VAR_7 == Q_KEY_CODE_MAX) { monitor_printf(VAR_0, "invalid parameter: %s\n", VAR_2); return; } VAR_5 = key_defs[VAR_7]; if (VAR_5 < 0) { monitor_printf(VAR_0, "unknown key: '%s'\n", VAR_2); return; } keycodes[VAR_6++] = VAR_5; } if (!VAR_3)
break; VAR_8 = VAR_3 + 1; } nb_pending_keycodes = VAR_6; for (VAR_6 = 0; VAR_6 < nb_pending_keycodes; VAR_6++) { VAR_5 = keycodes[VAR_6]; if (VAR_5 & 0x80)
kbd_put_keycode(0xe0); kbd_put_keycode(VAR_5 & 0x7f); } qemu_mod_timer(key_timer, qemu_get_clock_ns(vm_clock) +
muldiv64(get_ticks_per_sec(), VAR_10, 1000)); }