static const mon_cmd_t *monitor_parse_command(Monitor *mon,

                                              const char *cmdline,

                                              int start,

                                              mon_cmd_t *table,

                                              QDict *qdict)

{

    const char *p, *typestr;

    int c;

    const mon_cmd_t *cmd;

    char cmdname[256];

    char buf[1024];

    char *key;



    /* extract the command name */

    p = get_command_name(cmdline + start, cmdname, sizeof(cmdname));

    if (!p)

        return NULL;



    cmd = search_dispatch_table(table, cmdname);

    if (!cmd) {

        monitor_printf(mon, "unknown command: '%.*s'\n",

                       (int)(p - cmdline), cmdline);

        return NULL;

    }



    /* filter out following useless space */

    while (qemu_isspace(*p)) {

        p++;

    }

    /* search sub command */

    if (cmd->sub_table != NULL) {

        /* check if user set additional command */

        if (*p == '\0') {

            return cmd;

        }

        return monitor_parse_command(mon, cmdline, p - cmdline,

                                     cmd->sub_table, qdict);

    }



    /* parse the parameters */

    typestr = cmd->args_type;

    for(;;) {

        typestr = key_get_info(typestr, &key);

        if (!typestr)

            break;

        c = *typestr;

        typestr++;

        switch(c) {

        case 'F':

        case 'B':

        case 's':

            {

                int ret;



                while (qemu_isspace(*p))

                    p++;

                if (*typestr == '?') {

                    typestr++;

                    if (*p == '\0') {

                        /* no optional string: NULL argument */

                        break;

                    }

                }

                ret = get_str(buf, sizeof(buf), &p);

                if (ret < 0) {

                    switch(c) {

                    case 'F':

                        monitor_printf(mon, "%s: filename expected\n",

                                       cmdname);

                        break;

                    case 'B':

                        monitor_printf(mon, "%s: block device name expected\n",

                                       cmdname);

                        break;

                    default:

                        monitor_printf(mon, "%s: string expected\n", cmdname);

                        break;

                    }

                    goto fail;

                }

                qdict_put(qdict, key, qstring_from_str(buf));

            }

            break;

        case 'O':

            {

                QemuOptsList *opts_list;

                QemuOpts *opts;



                opts_list = qemu_find_opts(key);

                if (!opts_list || opts_list->desc->name) {

                    goto bad_type;

                }

                while (qemu_isspace(*p)) {

                    p++;

                }

                if (!*p)

                    break;

                if (get_str(buf, sizeof(buf), &p) < 0) {

                    goto fail;

                }

                opts = qemu_opts_parse(opts_list, buf, 1);

                if (!opts) {

                    goto fail;

                }

                qemu_opts_to_qdict(opts, qdict);

                qemu_opts_del(opts);

            }

            break;

        case '/':

            {

                int count, format, size;



                while (qemu_isspace(*p))

                    p++;

                if (*p == '/') {

                    /* format found */

                    p++;

                    count = 1;

                    if (qemu_isdigit(*p)) {

                        count = 0;

                        while (qemu_isdigit(*p)) {

                            count = count * 10 + (*p - '0');

                            p++;

                        }

                    }

                    size = -1;

                    format = -1;

                    for(;;) {

                        switch(*p) {

                        case 'o':

                        case 'd':

                        case 'u':

                        case 'x':

                        case 'i':

                        case 'c':

                            format = *p++;

                            break;

                        case 'b':

                            size = 1;

                            p++;

                            break;

                        case 'h':

                            size = 2;

                            p++;

                            break;

                        case 'w':

                            size = 4;

                            p++;

                            break;

                        case 'g':

                        case 'L':

                            size = 8;

                            p++;

                            break;

                        default:

                            goto next;

                        }

                    }

                next:

                    if (*p != '\0' && !qemu_isspace(*p)) {

                        monitor_printf(mon, "invalid char in format: '%c'\n",

                                       *p);

                        goto fail;

                    }

                    if (format < 0)

                        format = default_fmt_format;

                    if (format != 'i') {

                        /* for 'i', not specifying a size gives -1 as size */

                        if (size < 0)

                            size = default_fmt_size;

                        default_fmt_size = size;

                    }

                    default_fmt_format = format;

                } else {

                    count = 1;

                    format = default_fmt_format;

                    if (format != 'i') {

                        size = default_fmt_size;

                    } else {

                        size = -1;

                    }

                }

                qdict_put(qdict, "count", qint_from_int(count));

                qdict_put(qdict, "format", qint_from_int(format));

                qdict_put(qdict, "size", qint_from_int(size));

            }

            break;

        case 'i':

        case 'l':

        case 'M':

            {

                int64_t val;



                while (qemu_isspace(*p))

                    p++;

                if (*typestr == '?' || *typestr == '.') {

                    if (*typestr == '?') {

                        if (*p == '\0') {

                            typestr++;

                            break;

                        }

                    } else {

                        if (*p == '.') {

                            p++;

                            while (qemu_isspace(*p))

                                p++;

                        } else {

                            typestr++;

                            break;

                        }

                    }

                    typestr++;

                }

                if (get_expr(mon, &val, &p))

                    goto fail;

                /* Check if 'i' is greater than 32-bit */

                if ((c == 'i') && ((val >> 32) & 0xffffffff)) {

                    monitor_printf(mon, "\'%s\' has failed: ", cmdname);

                    monitor_printf(mon, "integer is for 32-bit values\n");

                    goto fail;

                } else if (c == 'M') {

                    if (val < 0) {

                        monitor_printf(mon, "enter a positive value\n");

                        goto fail;

                    }

                    val <<= 20;

                }

                qdict_put(qdict, key, qint_from_int(val));

            }

            break;

        case 'o':

            {

                int64_t val;

                char *end;



                while (qemu_isspace(*p)) {

                    p++;

                }

                if (*typestr == '?') {

                    typestr++;

                    if (*p == '\0') {

                        break;

                    }

                }

                val = strtosz(p, &end);

                if (val < 0) {

                    monitor_printf(mon, "invalid size\n");

                    goto fail;

                }

                qdict_put(qdict, key, qint_from_int(val));

                p = end;

            }

            break;

        case 'T':

            {

                double val;



                while (qemu_isspace(*p))

                    p++;

                if (*typestr == '?') {

                    typestr++;

                    if (*p == '\0') {

                        break;

                    }

                }

                if (get_double(mon, &val, &p) < 0) {

                    goto fail;

                }

                if (p[0] && p[1] == 's') {

                    switch (*p) {

                    case 'm':

                        val /= 1e3; p += 2; break;

                    case 'u':

                        val /= 1e6; p += 2; break;

                    case 'n':

                        val /= 1e9; p += 2; break;

                    }

                }

                if (*p && !qemu_isspace(*p)) {

                    monitor_printf(mon, "Unknown unit suffix\n");

                    goto fail;

                }

                qdict_put(qdict, key, qfloat_from_double(val));

            }

            break;

        case 'b':

            {

                const char *beg;

                bool val;



                while (qemu_isspace(*p)) {

                    p++;

                }

                beg = p;

                while (qemu_isgraph(*p)) {

                    p++;

                }

                if (p - beg == 2 && !memcmp(beg, "on", p - beg)) {

                    val = true;

                } else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) {

                    val = false;

                } else {

                    monitor_printf(mon, "Expected 'on' or 'off'\n");

                    goto fail;

                }

                qdict_put(qdict, key, qbool_from_bool(val));

            }

            break;

        case '-':

            {

                const char *tmp = p;

                int skip_key = 0;

                /* option */



                c = *typestr++;

                if (c == '\0')

                    goto bad_type;

                while (qemu_isspace(*p))

                    p++;

                if (*p == '-') {

                    p++;

                    if(c != *p) {

                        if(!is_valid_option(p, typestr)) {

                  

                            monitor_printf(mon, "%s: unsupported option -%c\n",

                                           cmdname, *p);

                            goto fail;

                        } else {

                            skip_key = 1;

                        }

                    }

                    if(skip_key) {

                        p = tmp;

                    } else {

                        /* has option */

                        p++;

                        qdict_put(qdict, key, qbool_from_bool(true));

                    }

                }

            }

            break;

        case 'S':

            {

                /* package all remaining string */

                int len;



                while (qemu_isspace(*p)) {

                    p++;

                }

                if (*typestr == '?') {

                    typestr++;

                    if (*p == '\0') {

                        /* no remaining string: NULL argument */

                        break;

                    }

                }

                len = strlen(p);

                if (len <= 0) {

                    monitor_printf(mon, "%s: string expected\n",

                                   cmdname);

                    break;

                }

                qdict_put(qdict, key, qstring_from_str(p));

                p += len;

            }

            break;

        default:

        bad_type:

            monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);

            goto fail;

        }

        g_free(key);

        key = NULL;

    }

    /* check that all arguments were parsed */

    while (qemu_isspace(*p))

        p++;

    if (*p != '\0') {

        monitor_printf(mon, "%s: extraneous characters at the end of line\n",

                       cmdname);

        goto fail;

    }



    return cmd;



fail:

    g_free(key);

    return NULL;

}

static const mon_cmd_t *monitor_parse_command(Monitor *mon,

                                              const char *cmdline,

                                              int start,

                                              mon_cmd_t *table,

                                              QDict *qdict)

{

    const char *p, *typestr;

    int c;

    const mon_cmd_t *cmd;

    char cmdname[256];

    char buf[1024];

    char *key;



    

    p = get_command_name(cmdline + start, cmdname, sizeof(cmdname));

    if (!p)

        return NULL;



    cmd = search_dispatch_table(table, cmdname);

    if (!cmd) {

        monitor_printf(mon, "unknown command: '%.*s'\n",

                       (int)(p - cmdline), cmdline);

        return NULL;

    }



    

    while (qemu_isspace(*p)) {

        p++;

    }

    

    if (cmd->sub_table != NULL) {

        

        if (*p == '\0') {

            return cmd;

        }

        return monitor_parse_command(mon, cmdline, p - cmdline,

                                     cmd->sub_table, qdict);

    }



    

    typestr = cmd->args_type;

    for(;;) {

        typestr = key_get_info(typestr, &key);

        if (!typestr)

            break;

        c = *typestr;

        typestr++;

        switch(c) {

        case 'F':

        case 'B':

        case 's':

            {

                int ret;



                while (qemu_isspace(*p))

                    p++;

                if (*typestr == '?') {

                    typestr++;

                    if (*p == '\0') {

                        

                        break;

                    }

                }

                ret = get_str(buf, sizeof(buf), &p);

                if (ret < 0) {

                    switch(c) {

                    case 'F':

                        monitor_printf(mon, "%s: filename expected\n",

                                       cmdname);

                        break;

                    case 'B':

                        monitor_printf(mon, "%s: block device name expected\n",

                                       cmdname);

                        break;

                    default:

                        monitor_printf(mon, "%s: string expected\n", cmdname);

                        break;

                    }

                    goto fail;

                }

                qdict_put(qdict, key, qstring_from_str(buf));

            }

            break;

        case 'O':

            {

                QemuOptsList *opts_list;

                QemuOpts *opts;



                opts_list = qemu_find_opts(key);

                if (!opts_list || opts_list->desc->name) {

                    goto bad_type;

                }

                while (qemu_isspace(*p)) {

                    p++;

                }

                if (!*p)

                    break;

                if (get_str(buf, sizeof(buf), &p) < 0) {

                    goto fail;

                }

                opts = qemu_opts_parse(opts_list, buf, 1);

                if (!opts) {

                    goto fail;

                }

                qemu_opts_to_qdict(opts, qdict);

                qemu_opts_del(opts);

            }

            break;

        case '/':

            {

                int count, format, size;



                while (qemu_isspace(*p))

                    p++;

                if (*p == '/') {

                    

                    p++;

                    count = 1;

                    if (qemu_isdigit(*p)) {

                        count = 0;

                        while (qemu_isdigit(*p)) {

                            count = count * 10 + (*p - '0');

                            p++;

                        }

                    }

                    size = -1;

                    format = -1;

                    for(;;) {

                        switch(*p) {

                        case 'o':

                        case 'd':

                        case 'u':

                        case 'x':

                        case 'i':

                        case 'c':

                            format = *p++;

                            break;

                        case 'b':

                            size = 1;

                            p++;

                            break;

                        case 'h':

                            size = 2;

                            p++;

                            break;

                        case 'w':

                            size = 4;

                            p++;

                            break;

                        case 'g':

                        case 'L':

                            size = 8;

                            p++;

                            break;

                        default:

                            goto next;

                        }

                    }

                next:

                    if (*p != '\0' && !qemu_isspace(*p)) {

                        monitor_printf(mon, "invalid char in format: '%c'\n",

                                       *p);

                        goto fail;

                    }

                    if (format < 0)

                        format = default_fmt_format;

                    if (format != 'i') {

                        

                        if (size < 0)

                            size = default_fmt_size;

                        default_fmt_size = size;

                    }

                    default_fmt_format = format;

                } else {

                    count = 1;

                    format = default_fmt_format;

                    if (format != 'i') {

                        size = default_fmt_size;

                    } else {

                        size = -1;

                    }

                }

                qdict_put(qdict, "count", qint_from_int(count));

                qdict_put(qdict, "format", qint_from_int(format));

                qdict_put(qdict, "size", qint_from_int(size));

            }

            break;

        case 'i':

        case 'l':

        case 'M':

            {

                int64_t val;



                while (qemu_isspace(*p))

                    p++;

                if (*typestr == '?' || *typestr == '.') {

                    if (*typestr == '?') {

                        if (*p == '\0') {

                            typestr++;

                            break;

                        }

                    } else {

                        if (*p == '.') {

                            p++;

                            while (qemu_isspace(*p))

                                p++;

                        } else {

                            typestr++;

                            break;

                        }

                    }

                    typestr++;

                }

                if (get_expr(mon, &val, &p))

                    goto fail;

                

                if ((c == 'i') && ((val >> 32) & 0xffffffff)) {

                    monitor_printf(mon, "\'%s\' has failed: ", cmdname);

                    monitor_printf(mon, "integer is for 32-bit values\n");

                    goto fail;

                } else if (c == 'M') {

                    if (val < 0) {

                        monitor_printf(mon, "enter a positive value\n");

                        goto fail;

                    }

                    val <<= 20;

                }

                qdict_put(qdict, key, qint_from_int(val));

            }

            break;

        case 'o':

            {

                int64_t val;

                char *end;



                while (qemu_isspace(*p)) {

                    p++;

                }

                if (*typestr == '?') {

                    typestr++;

                    if (*p == '\0') {

                        break;

                    }

                }

                val = strtosz(p, &end);

                if (val < 0) {

                    monitor_printf(mon, "invalid size\n");

                    goto fail;

                }

                qdict_put(qdict, key, qint_from_int(val));

                p = end;

            }

            break;

        case 'T':

            {

                double val;



                while (qemu_isspace(*p))

                    p++;

                if (*typestr == '?') {

                    typestr++;

                    if (*p == '\0') {

                        break;

                    }

                }

                if (get_double(mon, &val, &p) < 0) {

                    goto fail;

                }

                if (p[0] && p[1] == 's') {

                    switch (*p) {

                    case 'm':

                        val /= 1e3; p += 2; break;

                    case 'u':

                        val /= 1e6; p += 2; break;

                    case 'n':

                        val /= 1e9; p += 2; break;

                    }

                }

                if (*p && !qemu_isspace(*p)) {

                    monitor_printf(mon, "Unknown unit suffix\n");

                    goto fail;

                }

                qdict_put(qdict, key, qfloat_from_double(val));

            }

            break;

        case 'b':

            {

                const char *beg;

                bool val;



                while (qemu_isspace(*p)) {

                    p++;

                }

                beg = p;

                while (qemu_isgraph(*p)) {

                    p++;

                }

                if (p - beg == 2 && !memcmp(beg, "on", p - beg)) {

                    val = true;

                } else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) {

                    val = false;

                } else {

                    monitor_printf(mon, "Expected 'on' or 'off'\n");

                    goto fail;

                }

                qdict_put(qdict, key, qbool_from_bool(val));

            }

            break;

        case '-':

            {

                const char *tmp = p;

                int skip_key = 0;

                



                c = *typestr++;

                if (c == '\0')

                    goto bad_type;

                while (qemu_isspace(*p))

                    p++;

                if (*p == '-') {

                    p++;

                    if(c != *p) {

                        if(!is_valid_option(p, typestr)) {

                  

                            monitor_printf(mon, "%s: unsupported option -%c\n",

                                           cmdname, *p);

                            goto fail;

                        } else {

                            skip_key = 1;

                        }

                    }

                    if(skip_key) {

                        p = tmp;

                    } else {

                        

                        p++;

                        qdict_put(qdict, key, qbool_from_bool(true));

                    }

                }

            }

            break;

        case 'S':

            {

                

                int len;



                while (qemu_isspace(*p)) {

                    p++;

                }

                if (*typestr == '?') {

                    typestr++;

                    if (*p == '\0') {

                        

                        break;

                    }

                }

                len = strlen(p);

                if (len <= 0) {

                    monitor_printf(mon, "%s: string expected\n",

                                   cmdname);

                    break;

                }

                qdict_put(qdict, key, qstring_from_str(p));

                p += len;

            }

            break;

        default:

        bad_type:

            monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);

            goto fail;

        }

        g_free(key);

        key = NULL;

    }

    

    while (qemu_isspace(*p))

        p++;

    if (*p != '\0') {

        monitor_printf(mon, "%s: extraneous characters at the end of line\n",

                       cmdname);

        goto fail;

    }



    return cmd;



fail:

    g_free(key);

    return NULL;

}

static const mon_cmd_t *FUNC_0(Monitor *mon,

                                              const char *cmdline,

                                              int start,

                                              mon_cmd_t *table,

                                              QDict *qdict)

{

    const char *VAR_0, *VAR_1;

    int VAR_2;

    const mon_cmd_t *VAR_3;

    char VAR_4[256];

    char VAR_5[1024];

    char *VAR_6;



    

    VAR_0 = get_command_name(cmdline + start, VAR_4, sizeof(VAR_4));

    if (!VAR_0)

        return NULL;



    VAR_3 = search_dispatch_table(table, VAR_4);

    if (!VAR_3) {

        monitor_printf(mon, "unknown command: '%.*s'\n",

                       (int)(VAR_0 - cmdline), cmdline);

        return NULL;

    }



    

    while (qemu_isspace(*VAR_0)) {

        VAR_0++;

    }

    

    if (VAR_3->sub_table != NULL) {

        

        if (*VAR_0 == '\0') {

            return VAR_3;

        }

        return FUNC_0(mon, cmdline, VAR_0 - cmdline,

                                     VAR_3->sub_table, qdict);

    }



    

    VAR_1 = VAR_3->args_type;

    for(;;) {

        VAR_1 = key_get_info(VAR_1, &VAR_6);

        if (!VAR_1)

            break;

        VAR_2 = *VAR_1;

        VAR_1++;

        switch(VAR_2) {

        case 'F':

        case 'B':

        case 's':

            {

                int VAR_7;



                while (qemu_isspace(*VAR_0))

                    VAR_0++;

                if (*VAR_1 == '?') {

                    VAR_1++;

                    if (*VAR_0 == '\0') {

                        

                        break;

                    }

                }

                VAR_7 = get_str(VAR_5, sizeof(VAR_5), &VAR_0);

                if (VAR_7 < 0) {

                    switch(VAR_2) {

                    case 'F':

                        monitor_printf(mon, "%s: filename expected\n",

                                       VAR_4);

                        break;

                    case 'B':

                        monitor_printf(mon, "%s: block device name expected\n",

                                       VAR_4);

                        break;

                    default:

                        monitor_printf(mon, "%s: string expected\n", VAR_4);

                        break;

                    }

                    goto fail;

                }

                qdict_put(qdict, VAR_6, qstring_from_str(VAR_5));

            }

            break;

        case 'O':

            {

                QemuOptsList *opts_list;

                QemuOpts *opts;



                opts_list = qemu_find_opts(VAR_6);

                if (!opts_list || opts_list->desc->name) {

                    goto bad_type;

                }

                while (qemu_isspace(*VAR_0)) {

                    VAR_0++;

                }

                if (!*VAR_0)

                    break;

                if (get_str(VAR_5, sizeof(VAR_5), &VAR_0) < 0) {

                    goto fail;

                }

                opts = qemu_opts_parse(opts_list, VAR_5, 1);

                if (!opts) {

                    goto fail;

                }

                qemu_opts_to_qdict(opts, qdict);

                qemu_opts_del(opts);

            }

            break;

        case '/':

            {

                int VAR_8, VAR_9, VAR_10;



                while (qemu_isspace(*VAR_0))

                    VAR_0++;

                if (*VAR_0 == '/') {

                    

                    VAR_0++;

                    VAR_8 = 1;

                    if (qemu_isdigit(*VAR_0)) {

                        VAR_8 = 0;

                        while (qemu_isdigit(*VAR_0)) {

                            VAR_8 = VAR_8 * 10 + (*VAR_0 - '0');

                            VAR_0++;

                        }

                    }

                    VAR_10 = -1;

                    VAR_9 = -1;

                    for(;;) {

                        switch(*VAR_0) {

                        case 'o':

                        case 'd':

                        case 'u':

                        case 'x':

                        case 'i':

                        case 'VAR_2':

                            VAR_9 = *VAR_0++;

                            break;

                        case 'b':

                            VAR_10 = 1;

                            VAR_0++;

                            break;

                        case 'h':

                            VAR_10 = 2;

                            VAR_0++;

                            break;

                        case 'w':

                            VAR_10 = 4;

                            VAR_0++;

                            break;

                        case 'g':

                        case 'L':

                            VAR_10 = 8;

                            VAR_0++;

                            break;

                        default:

                            goto next;

                        }

                    }

                next:

                    if (*VAR_0 != '\0' && !qemu_isspace(*VAR_0)) {

                        monitor_printf(mon, "invalid char in VAR_9: '%VAR_2'\n",

                                       *VAR_0);

                        goto fail;

                    }

                    if (VAR_9 < 0)

                        VAR_9 = default_fmt_format;

                    if (VAR_9 != 'i') {

                        

                        if (VAR_10 < 0)

                            VAR_10 = default_fmt_size;

                        default_fmt_size = VAR_10;

                    }

                    default_fmt_format = VAR_9;

                } else {

                    VAR_8 = 1;

                    VAR_9 = default_fmt_format;

                    if (VAR_9 != 'i') {

                        VAR_10 = default_fmt_size;

                    } else {

                        VAR_10 = -1;

                    }

                }

                qdict_put(qdict, "VAR_8", qint_from_int(VAR_8));

                qdict_put(qdict, "VAR_9", qint_from_int(VAR_9));

                qdict_put(qdict, "VAR_10", qint_from_int(VAR_10));

            }

            break;

        case 'i':

        case 'l':

        case 'M':

            {

                int64_t VAR_12;



                while (qemu_isspace(*VAR_0))

                    VAR_0++;

                if (*VAR_1 == '?' || *VAR_1 == '.') {

                    if (*VAR_1 == '?') {

                        if (*VAR_0 == '\0') {

                            VAR_1++;

                            break;

                        }

                    } else {

                        if (*VAR_0 == '.') {

                            VAR_0++;

                            while (qemu_isspace(*VAR_0))

                                VAR_0++;

                        } else {

                            VAR_1++;

                            break;

                        }

                    }

                    VAR_1++;

                }

                if (get_expr(mon, &VAR_12, &VAR_0))

                    goto fail;

                

                if ((VAR_2 == 'i') && ((VAR_12 >> 32) & 0xffffffff)) {

                    monitor_printf(mon, "\'%s\' has failed: ", VAR_4);

                    monitor_printf(mon, "integer is for 32-bit values\n");

                    goto fail;

                } else if (VAR_2 == 'M') {

                    if (VAR_12 < 0) {

                        monitor_printf(mon, "enter a positive value\n");

                        goto fail;

                    }

                    VAR_12 <<= 20;

                }

                qdict_put(qdict, VAR_6, qint_from_int(VAR_12));

            }

            break;

        case 'o':

            {

                int64_t VAR_12;

                char *VAR_11;



                while (qemu_isspace(*VAR_0)) {

                    VAR_0++;

                }

                if (*VAR_1 == '?') {

                    VAR_1++;

                    if (*VAR_0 == '\0') {

                        break;

                    }

                }

                VAR_12 = strtosz(VAR_0, &VAR_11);

                if (VAR_12 < 0) {

                    monitor_printf(mon, "invalid VAR_10\n");

                    goto fail;

                }

                qdict_put(qdict, VAR_6, qint_from_int(VAR_12));

                VAR_0 = VAR_11;

            }

            break;

        case 'T':

            {

                double VAR_12;



                while (qemu_isspace(*VAR_0))

                    VAR_0++;

                if (*VAR_1 == '?') {

                    VAR_1++;

                    if (*VAR_0 == '\0') {

                        break;

                    }

                }

                if (get_double(mon, &VAR_12, &VAR_0) < 0) {

                    goto fail;

                }

                if (VAR_0[0] && VAR_0[1] == 's') {

                    switch (*VAR_0) {

                    case 'm':

                        VAR_12 /= 1e3; VAR_0 += 2; break;

                    case 'u':

                        VAR_12 /= 1e6; VAR_0 += 2; break;

                    case 'n':

                        VAR_12 /= 1e9; VAR_0 += 2; break;

                    }

                }

                if (*VAR_0 && !qemu_isspace(*VAR_0)) {

                    monitor_printf(mon, "Unknown unit suffix\n");

                    goto fail;

                }

                qdict_put(qdict, VAR_6, qfloat_from_double(VAR_12));

            }

            break;

        case 'b':

            {

                const char *VAR_13;

                bool VAR_12;



                while (qemu_isspace(*VAR_0)) {

                    VAR_0++;

                }

                VAR_13 = VAR_0;

                while (qemu_isgraph(*VAR_0)) {

                    VAR_0++;

                }

                if (VAR_0 - VAR_13 == 2 && !memcmp(VAR_13, "on", VAR_0 - VAR_13)) {

                    VAR_12 = true;

                } else if (VAR_0 - VAR_13 == 3 && !memcmp(VAR_13, "off", VAR_0 - VAR_13)) {

                    VAR_12 = false;

                } else {

                    monitor_printf(mon, "Expected 'on' or 'off'\n");

                    goto fail;

                }

                qdict_put(qdict, VAR_6, qbool_from_bool(VAR_12));

            }

            break;

        case '-':

            {

                const char *VAR_14 = VAR_0;

                int VAR_15 = 0;

                



                VAR_2 = *VAR_1++;

                if (VAR_2 == '\0')

                    goto bad_type;

                while (qemu_isspace(*VAR_0))

                    VAR_0++;

                if (*VAR_0 == '-') {

                    VAR_0++;

                    if(VAR_2 != *VAR_0) {

                        if(!is_valid_option(VAR_0, VAR_1)) {

                  

                            monitor_printf(mon, "%s: unsupported option -%VAR_2\n",

                                           VAR_4, *VAR_0);

                            goto fail;

                        } else {

                            VAR_15 = 1;

                        }

                    }

                    if(VAR_15) {

                        VAR_0 = VAR_14;

                    } else {

                        

                        VAR_0++;

                        qdict_put(qdict, VAR_6, qbool_from_bool(true));

                    }

                }

            }

            break;

        case 'S':

            {

                

                int VAR_16;



                while (qemu_isspace(*VAR_0)) {

                    VAR_0++;

                }

                if (*VAR_1 == '?') {

                    VAR_1++;

                    if (*VAR_0 == '\0') {

                        

                        break;

                    }

                }

                VAR_16 = strlen(VAR_0);

                if (VAR_16 <= 0) {

                    monitor_printf(mon, "%s: string expected\n",

                                   VAR_4);

                    break;

                }

                qdict_put(qdict, VAR_6, qstring_from_str(VAR_0));

                VAR_0 += VAR_16;

            }

            break;

        default:

        bad_type:

            monitor_printf(mon, "%s: unknown type '%VAR_2'\n", VAR_4, VAR_2);

            goto fail;

        }

        g_free(VAR_6);

        VAR_6 = NULL;

    }

    

    while (qemu_isspace(*VAR_0))

        VAR_0++;

    if (*VAR_0 != '\0') {

        monitor_printf(mon, "%s: extraneous characters at the VAR_11 of line\n",

                       VAR_4);

        goto fail;

    }



    return VAR_3;



fail:

    g_free(VAR_6);

    return NULL;

}

static const mon_cmd_t *FUNC_0(Monitor *mon,
const char *cmdline,
int start,
mon_cmd_t *table,
QDict *qdict)
{ const char *VAR_0, *VAR_1; int VAR_2; const mon_cmd_t *VAR_3; char VAR_4[256]; char VAR_5[1024]; char *VAR_6; VAR_0 = get_command_name(cmdline + start, VAR_4, sizeof(VAR_4)); if (!VAR_0)
return NULL; VAR_3 = search_dispatch_table(table, VAR_4); if (!VAR_3) { monitor_printf(mon, "unknown command: '%.*s'\n",
(int)(VAR_0 - cmdline), cmdline); return NULL; } while (qemu_isspace(*VAR_0)) { VAR_0++; } if (VAR_3->sub_table != NULL) { if (*VAR_0 == '\0') { return VAR_3; } return FUNC_0(mon, cmdline, VAR_0 - cmdline,
VAR_3->sub_table, qdict); } VAR_1 = VAR_3->args_type; for(;;) { VAR_1 = key_get_info(VAR_1, &VAR_6); if (!VAR_1)
break; VAR_2 = *VAR_1; VAR_1++; switch(VAR_2) { case 'F':
case 'B':
case 's':
{ int VAR_7; while (qemu_isspace(*VAR_0))
VAR_0++; if (*VAR_1 == '?') { VAR_1++; if (*VAR_0 == '\0') { break; } } VAR_7 = get_str(VAR_5, sizeof(VAR_5), &VAR_0); if (VAR_7 < 0) { switch(VAR_2) { case 'F':
monitor_printf(mon, "%s: filename expected\n",
VAR_4); break; case 'B':
monitor_printf(mon, "%s: block device name expected\n",
VAR_4); break; default:
monitor_printf(mon, "%s: string expected\n", VAR_4); break; } goto fail; } qdict_put(qdict, VAR_6, qstring_from_str(VAR_5)); } break; case 'O':
{ QemuOptsList *opts_list; QemuOpts *opts; opts_list = qemu_find_opts(VAR_6); if (!opts_list || opts_list->desc->name) { goto bad_type; } while (qemu_isspace(*VAR_0)) { VAR_0++; } if (!*VAR_0)
break; if (get_str(VAR_5, sizeof(VAR_5), &VAR_0) < 0) { goto fail; } opts = qemu_opts_parse(opts_list, VAR_5, 1); if (!opts) { goto fail; } qemu_opts_to_qdict(opts, qdict); qemu_opts_del(opts); } break; case '/':
{ int VAR_8, VAR_9, VAR_10; while (qemu_isspace(*VAR_0))
VAR_0++; if (*VAR_0 == '/') { VAR_0++; VAR_8 = 1; if (qemu_isdigit(*VAR_0)) { VAR_8 = 0; while (qemu_isdigit(*VAR_0)) { VAR_8 = VAR_8 * 10 + (*VAR_0 - '0'); VAR_0++; } } VAR_10 = -1; VAR_9 = -1; for(;;) { switch(*VAR_0) { case 'o':
case 'd':
case 'u':
case 'x':
case 'i':
case 'VAR_2':
VAR_9 = *VAR_0++; break; case 'b':
VAR_10 = 1; VAR_0++; break; case 'h':
VAR_10 = 2; VAR_0++; break; case 'w':
VAR_10 = 4; VAR_0++; break; case 'g':
case 'L':
VAR_10 = 8; VAR_0++; break; default:
goto next; } } next:
if (*VAR_0 != '\0' && !qemu_isspace(*VAR_0)) { monitor_printf(mon, "invalid char in VAR_9: '%VAR_2'\n",
*VAR_0); goto fail; } if (VAR_9 < 0)
VAR_9 = default_fmt_format; if (VAR_9 != 'i') { if (VAR_10 < 0)
VAR_10 = default_fmt_size; default_fmt_size = VAR_10; } default_fmt_format = VAR_9; } else { VAR_8 = 1; VAR_9 = default_fmt_format; if (VAR_9 != 'i') { VAR_10 = default_fmt_size; } else { VAR_10 = -1; } } qdict_put(qdict, "VAR_8", qint_from_int(VAR_8)); qdict_put(qdict, "VAR_9", qint_from_int(VAR_9)); qdict_put(qdict, "VAR_10", qint_from_int(VAR_10)); } break; case 'i':
case 'l':
case 'M':
{ int64_t VAR_12; while (qemu_isspace(*VAR_0))
VAR_0++; if (*VAR_1 == '?' || *VAR_1 == '.') { if (*VAR_1 == '?') { if (*VAR_0 == '\0') { VAR_1++; break; } } else { if (*VAR_0 == '.') { VAR_0++; while (qemu_isspace(*VAR_0))
VAR_0++; } else { VAR_1++; break; } } VAR_1++; } if (get_expr(mon, &VAR_12, &VAR_0))
goto fail; if ((VAR_2 == 'i') && ((VAR_12 >> 32) & 0xffffffff)) { monitor_printf(mon, "\'%s\' has failed: ", VAR_4); monitor_printf(mon, "integer is for 32-bit values\n"); goto fail; } else if (VAR_2 == 'M') { if (VAR_12 < 0) { monitor_printf(mon, "enter a positive value\n"); goto fail; } VAR_12 <<= 20; } qdict_put(qdict, VAR_6, qint_from_int(VAR_12)); } break; case 'o':
{ int64_t VAR_12; char *VAR_11; while (qemu_isspace(*VAR_0)) { VAR_0++; } if (*VAR_1 == '?') { VAR_1++; if (*VAR_0 == '\0') { break; } } VAR_12 = strtosz(VAR_0, &VAR_11); if (VAR_12 < 0) { monitor_printf(mon, "invalid VAR_10\n"); goto fail; } qdict_put(qdict, VAR_6, qint_from_int(VAR_12)); VAR_0 = VAR_11; } break; case 'T':
{ double VAR_12; while (qemu_isspace(*VAR_0))
VAR_0++; if (*VAR_1 == '?') { VAR_1++; if (*VAR_0 == '\0') { break; } } if (get_double(mon, &VAR_12, &VAR_0) < 0) { goto fail; } if (VAR_0[0] && VAR_0[1] == 's') { switch (*VAR_0) { case 'm':
VAR_12 /= 1e3; VAR_0 += 2; break; case 'u':
VAR_12 /= 1e6; VAR_0 += 2; break; case 'n':
VAR_12 /= 1e9; VAR_0 += 2; break; } } if (*VAR_0 && !qemu_isspace(*VAR_0)) { monitor_printf(mon, "Unknown unit suffix\n"); goto fail; } qdict_put(qdict, VAR_6, qfloat_from_double(VAR_12)); } break; case 'b':
{ const char *VAR_13; bool VAR_12; while (qemu_isspace(*VAR_0)) { VAR_0++; } VAR_13 = VAR_0; while (qemu_isgraph(*VAR_0)) { VAR_0++; } if (VAR_0 - VAR_13 == 2 && !memcmp(VAR_13, "on", VAR_0 - VAR_13)) { VAR_12 = true; } else if (VAR_0 - VAR_13 == 3 && !memcmp(VAR_13, "off", VAR_0 - VAR_13)) { VAR_12 = false; } else { monitor_printf(mon, "Expected 'on' or 'off'\n"); goto fail; } qdict_put(qdict, VAR_6, qbool_from_bool(VAR_12)); } break; case '-':
{ const char *VAR_14 = VAR_0; int VAR_15 = 0; VAR_2 = *VAR_1++; if (VAR_2 == '\0')
goto bad_type; while (qemu_isspace(*VAR_0))
VAR_0++; if (*VAR_0 == '-') { VAR_0++; if(VAR_2 != *VAR_0) { if(!is_valid_option(VAR_0, VAR_1)) { monitor_printf(mon, "%s: unsupported option -%VAR_2\n",
VAR_4, *VAR_0); goto fail; } else { VAR_15 = 1; } } if(VAR_15) { VAR_0 = VAR_14; } else { VAR_0++; qdict_put(qdict, VAR_6, qbool_from_bool(true)); } } } break; case 'S':
{ int VAR_16; while (qemu_isspace(*VAR_0)) { VAR_0++; } if (*VAR_1 == '?') { VAR_1++; if (*VAR_0 == '\0') { break; } } VAR_16 = strlen(VAR_0); if (VAR_16 <= 0) { monitor_printf(mon, "%s: string expected\n",
VAR_4); break; } qdict_put(qdict, VAR_6, qstring_from_str(VAR_0)); VAR_0 += VAR_16; } break; default:
bad_type:
monitor_printf(mon, "%s: unknown type '%VAR_2'\n", VAR_4, VAR_2); goto fail; } g_free(VAR_6); VAR_6 = NULL; } while (qemu_isspace(*VAR_0))
VAR_0++; if (*VAR_0 != '\0') { monitor_printf(mon, "%s: extraneous characters at the VAR_11 of line\n",
VAR_4); goto fail; } return VAR_3; fail:
g_free(VAR_6); return NULL; }