static void monitor_find_completion(Monitor *mon,

                                    const char *cmdline)

{

    char *args[MAX_ARGS];

    int nb_args, len;



    /* 1. parse the cmdline */

    if (parse_cmdline(cmdline, &nb_args, args) < 0) {

        return;

    }

#ifdef DEBUG_COMPLETION

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

        monitor_printf(mon, "arg%d = '%s'\n", i, args[i]);

    }

#endif



    /* if the line ends with a space, it means we want to complete the

       next arg */

    len = strlen(cmdline);

    if (len > 0 && qemu_isspace(cmdline[len - 1])) {

        if (nb_args >= MAX_ARGS) {

            goto cleanup;

        }

        args[nb_args++] = g_strdup("");

    }



    /* 2. auto complete according to args */

    monitor_find_completion_by_table(mon, mon->cmd_table, args, nb_args);



cleanup:

    free_cmdline_args(args, nb_args);

}

static void monitor_find_completion(Monitor *mon,

                                    const char *cmdline)

{

    char *args[MAX_ARGS];

    int nb_args, len;



    

    if (parse_cmdline(cmdline, &nb_args, args) < 0) {

        return;

    }

#ifdef DEBUG_COMPLETION

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

        monitor_printf(mon, "arg%d = '%s'\n", i, args[i]);

    }

#endif



    



    len = strlen(cmdline);

    if (len > 0 && qemu_isspace(cmdline[len - 1])) {

        if (nb_args >= MAX_ARGS) {

            goto cleanup;

        }

        args[nb_args++] = g_strdup("");

    }



    

    monitor_find_completion_by_table(mon, mon->cmd_table, args, nb_args);



cleanup:

    free_cmdline_args(args, nb_args);

}

static void FUNC_0(Monitor *VAR_0,

                                    const char *VAR_1)

{

    char *VAR_2[MAX_ARGS];

    int VAR_3, VAR_4;



    

    if (parse_cmdline(VAR_1, &VAR_3, VAR_2) < 0) {

        return;

    }

#ifdef DEBUG_COMPLETION

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

        monitor_printf(VAR_0, "arg%d = '%s'\n", i, VAR_2[i]);

    }

#endif



    



    VAR_4 = strlen(VAR_1);

    if (VAR_4 > 0 && qemu_isspace(VAR_1[VAR_4 - 1])) {

        if (VAR_3 >= MAX_ARGS) {

            goto cleanup;

        }

        VAR_2[VAR_3++] = g_strdup("");

    }



    

    monitor_find_completion_by_table(VAR_0, VAR_0->cmd_table, VAR_2, VAR_3);



cleanup:

    free_cmdline_args(VAR_2, VAR_3);

}

static void FUNC_0(Monitor *VAR_0,
const char *VAR_1)
{ char *VAR_2[MAX_ARGS]; int VAR_3, VAR_4; if (parse_cmdline(VAR_1, &VAR_3, VAR_2) < 0) { return; } #ifdef DEBUG_COMPLETION
for (i = 0; i < VAR_3; i++) { monitor_printf(VAR_0, "arg%d = '%s'\n", i, VAR_2[i]); } #endif
VAR_4 = strlen(VAR_1); if (VAR_4 > 0 && qemu_isspace(VAR_1[VAR_4 - 1])) { if (VAR_3 >= MAX_ARGS) { goto cleanup; } VAR_2[VAR_3++] = g_strdup(""); } monitor_find_completion_by_table(VAR_0, VAR_0->cmd_table, VAR_2, VAR_3); cleanup:
free_cmdline_args(VAR_2, VAR_3); }