void qmp_memchar_write(const char *device, int64_t size,

                       const char *data, bool has_format,

                       enum DataFormat format,

                       Error **errp)

{

    CharDriverState *chr;

    guchar *write_data;

    int ret;

    gsize write_count;



    chr = qemu_chr_find(device);

    if (!chr) {

        error_set(errp, QERR_DEVICE_NOT_FOUND, device);

        return;

    }



    if (qemu_is_chr(chr, "memory")) {

        error_setg(errp,"%s is not memory char device", device);

        return;

    }



    write_count = (gsize)size;



    if (has_format && (format == DATA_FORMAT_BASE64)) {

        write_data = g_base64_decode(data, &write_count);

    } else {

        write_data = (uint8_t *)data;

    }



    ret = cirmem_chr_write(chr, write_data, write_count);



    if (ret < 0) {

        error_setg(errp, "Failed to write to device %s", device);

        return;

    }

}

void qmp_memchar_write(const char *device, int64_t size,

                       const char *data, bool has_format,

                       enum DataFormat format,

                       Error **errp)

{

    CharDriverState *chr;

    guchar *write_data;

    int ret;

    gsize write_count;



    chr = qemu_chr_find(device);

    if (!chr) {

        error_set(errp, QERR_DEVICE_NOT_FOUND, device);

        return;

    }



    if (qemu_is_chr(chr, "memory")) {

        error_setg(errp,"%s is not memory char device", device);

        return;

    }



    write_count = (gsize)size;



    if (has_format && (format == DATA_FORMAT_BASE64)) {

        write_data = g_base64_decode(data, &write_count);

    } else {

        write_data = (uint8_t *)data;

    }



    ret = cirmem_chr_write(chr, write_data, write_count);



    if (ret < 0) {

        error_setg(errp, "Failed to write to device %s", device);

        return;

    }

}

void qmp_memchar_write(const char *device, int64_t size,                        const char *data, bool has_format,                        enum DataFormat format,     write_count = (gsize)size;
void FUNC_0(const char *VAR_0, int64_t VAR_1,

                       const char *VAR_2, bool VAR_3,

                       enum DataFormat VAR_4,

                       Error **VAR_5)

{

    CharDriverState *chr;

    guchar *write_data;

    int VAR_6;

    gsize write_count;



    chr = qemu_chr_find(VAR_0);

    if (!chr) {

        error_set(VAR_5, QERR_DEVICE_NOT_FOUND, VAR_0);

        return;

    }



    if (qemu_is_chr(chr, "memory")) {

        error_setg(VAR_5,"%s is not memory char VAR_0", VAR_0);

        return;

    }



    write_count = (gsize)VAR_1;



    if (VAR_3 && (VAR_4 == DATA_FORMAT_BASE64)) {

        write_data = g_base64_decode(VAR_2, &write_count);

    } else {

        write_data = (uint8_t *)VAR_2;

    }



    VAR_6 = cirmem_chr_write(chr, write_data, write_count);



    if (VAR_6 < 0) {

        error_setg(VAR_5, "Failed to write to VAR_0 %s", VAR_0);

        return;

    }

}

void FUNC_0(const char *VAR_0, int64_t VAR_1,
const char *VAR_2, bool VAR_3,
enum DataFormat VAR_4,
Error **VAR_5)
{ CharDriverState *chr; guchar *write_data; int VAR_6; gsize write_count; chr = qemu_chr_find(VAR_0); if (!chr) { error_set(VAR_5, QERR_DEVICE_NOT_FOUND, VAR_0); return; } if (qemu_is_chr(chr, "memory")) { error_setg(VAR_5,"%s is not memory char VAR_0", VAR_0); return; } write_count = (gsize)VAR_1; if (VAR_3 && (VAR_4 == DATA_FORMAT_BASE64)) { write_data = g_base64_decode(VAR_2, &write_count); } else { write_data = (uint8_t *)VAR_2; } VAR_6 = cirmem_chr_write(chr, write_data, write_count); if (VAR_6 < 0) { error_setg(VAR_5, "Failed to write to VAR_0 %s", VAR_0); return; } }