static int img_info(int argc, char **argv)

{

    int c;

    OutputFormat output_format = OFORMAT_HUMAN;

    const char *filename, *fmt, *output;

    BlockDriverState *bs;

    ImageInfo *info;



    fmt = NULL;

    output = NULL;

    for(;;) {

        int option_index = 0;

        static const struct option long_options[] = {

            {"help", no_argument, 0, 'h'},

            {"format", required_argument, 0, 'f'},

            {"output", required_argument, 0, OPTION_OUTPUT},

            {0, 0, 0, 0}

        };

        c = getopt_long(argc, argv, "f:h",

                        long_options, &option_index);

        if (c == -1) {

            break;

        }

        switch(c) {

        case '?':

        case 'h':

            help();

            break;

        case 'f':

            fmt = optarg;

            break;

        case OPTION_OUTPUT:

            output = optarg;

            break;

        }

    }

    if (optind >= argc) {

        help();

    }

    filename = argv[optind++];



    if (output && !strcmp(output, "json")) {

        output_format = OFORMAT_JSON;

    } else if (output && !strcmp(output, "human")) {

        output_format = OFORMAT_HUMAN;

    } else if (output) {

        error_report("--output must be used with human or json as argument.");

        return 1;

    }



    bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING);

    if (!bs) {

        return 1;

    }



    info = g_new0(ImageInfo, 1);

    collect_image_info(bs, info, filename, fmt);



    switch (output_format) {

    case OFORMAT_HUMAN:

        dump_human_image_info(info);

        dump_snapshots(bs);

        break;

    case OFORMAT_JSON:

        collect_snapshots(bs, info);

        dump_json_image_info(info);

        break;

    }



    qapi_free_ImageInfo(info);

    bdrv_delete(bs);

    return 0;

}

static int img_info(int argc, char **argv)

{

    int c;

    OutputFormat output_format = OFORMAT_HUMAN;

    const char *filename, *fmt, *output;

    BlockDriverState *bs;

    ImageInfo *info;



    fmt = NULL;

    output = NULL;

    for(;;) {

        int option_index = 0;

        static const struct option long_options[] = {

            {"help", no_argument, 0, 'h'},

            {"format", required_argument, 0, 'f'},

            {"output", required_argument, 0, OPTION_OUTPUT},

            {0, 0, 0, 0}

        };

        c = getopt_long(argc, argv, "f:h",

                        long_options, &option_index);

        if (c == -1) {

            break;

        }

        switch(c) {

        case '?':

        case 'h':

            help();

            break;

        case 'f':

            fmt = optarg;

            break;

        case OPTION_OUTPUT:

            output = optarg;

            break;

        }

    }

    if (optind >= argc) {

        help();

    }

    filename = argv[optind++];



    if (output && !strcmp(output, "json")) {

        output_format = OFORMAT_JSON;

    } else if (output && !strcmp(output, "human")) {

        output_format = OFORMAT_HUMAN;

    } else if (output) {

        error_report("--output must be used with human or json as argument.");

        return 1;

    }



    bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING);

    if (!bs) {

        return 1;

    }



    info = g_new0(ImageInfo, 1);

    collect_image_info(bs, info, filename, fmt);



    switch (output_format) {

    case OFORMAT_HUMAN:

        dump_human_image_info(info);

        dump_snapshots(bs);

        break;

    case OFORMAT_JSON:

        collect_snapshots(bs, info);

        dump_json_image_info(info);

        break;

    }



    qapi_free_ImageInfo(info);

    bdrv_delete(bs);

    return 0;

}

static int FUNC_0(int VAR_0, char **VAR_1)

{

    int VAR_2;

    OutputFormat output_format = OFORMAT_HUMAN;

    const char *VAR_3, *VAR_4, *VAR_5;

    BlockDriverState *bs;

    ImageInfo *info;



    VAR_4 = NULL;

    VAR_5 = NULL;

    for(;;) {

        int VAR_6 = 0;

        static const struct option VAR_7[] = {

            {"help", no_argument, 0, 'h'},

            {"format", required_argument, 0, 'f'},

            {"VAR_5", required_argument, 0, OPTION_OUTPUT},

            {0, 0, 0, 0}

        };

        VAR_2 = getopt_long(VAR_0, VAR_1, "f:h",

                        VAR_7, &VAR_6);

        if (VAR_2 == -1) {

            break;

        }

        switch(VAR_2) {

        case '?':

        case 'h':

            help();

            break;

        case 'f':

            VAR_4 = optarg;

            break;

        case OPTION_OUTPUT:

            VAR_5 = optarg;

            break;

        }

    }

    if (optind >= VAR_0) {

        help();

    }

    VAR_3 = VAR_1[optind++];



    if (VAR_5 && !strcmp(VAR_5, "json")) {

        output_format = OFORMAT_JSON;

    } else if (VAR_5 && !strcmp(VAR_5, "human")) {

        output_format = OFORMAT_HUMAN;

    } else if (VAR_5) {

        error_report("--VAR_5 must be used with human or json as argument.");

        return 1;

    }



    bs = bdrv_new_open(VAR_3, VAR_4, BDRV_O_FLAGS | BDRV_O_NO_BACKING);

    if (!bs) {

        return 1;

    }



    info = g_new0(ImageInfo, 1);

    collect_image_info(bs, info, VAR_3, VAR_4);



    switch (output_format) {

    case OFORMAT_HUMAN:

        dump_human_image_info(info);

        dump_snapshots(bs);

        break;

    case OFORMAT_JSON:

        collect_snapshots(bs, info);

        dump_json_image_info(info);

        break;

    }



    qapi_free_ImageInfo(info);

    bdrv_delete(bs);

    return 0;

}

static int FUNC_0(int VAR_0, char **VAR_1)
{ int VAR_2; OutputFormat output_format = OFORMAT_HUMAN; const char *VAR_3, *VAR_4, *VAR_5; BlockDriverState *bs; ImageInfo *info; VAR_4 = NULL; VAR_5 = NULL; for(;;) { int VAR_6 = 0; static const struct option VAR_7[] = { {"help", no_argument, 0, 'h'}, {"format", required_argument, 0, 'f'}, {"VAR_5", required_argument, 0, OPTION_OUTPUT}, {0, 0, 0, 0} }; VAR_2 = getopt_long(VAR_0, VAR_1, "f:h",
VAR_7, &VAR_6); if (VAR_2 == -1) { break; } switch(VAR_2) { case '?':
case 'h':
help(); break; case 'f':
VAR_4 = optarg; break; case OPTION_OUTPUT:
VAR_5 = optarg; break; } } if (optind >= VAR_0) { help(); } VAR_3 = VAR_1[optind++]; if (VAR_5 && !strcmp(VAR_5, "json")) { output_format = OFORMAT_JSON; } else if (VAR_5 && !strcmp(VAR_5, "human")) { output_format = OFORMAT_HUMAN; } else if (VAR_5) { error_report("--VAR_5 must be used with human or json as argument."); return 1; } bs = bdrv_new_open(VAR_3, VAR_4, BDRV_O_FLAGS | BDRV_O_NO_BACKING); if (!bs) { return 1; } info = g_new0(ImageInfo, 1); collect_image_info(bs, info, VAR_3, VAR_4); switch (output_format) { case OFORMAT_HUMAN:
dump_human_image_info(info); dump_snapshots(bs); break; case OFORMAT_JSON:
collect_snapshots(bs, info); dump_json_image_info(info); break; } qapi_free_ImageInfo(info); bdrv_delete(bs); return 0; }