static void monitor_protocol_emitter(Monitor *mon, QObject *data)

{

    QDict *qmp;



    qmp = qdict_new();



    if (!monitor_has_error(mon)) {

        /* success response */

        if (data) {

            assert(qobject_type(data) == QTYPE_QDICT);

            qobject_incref(data);

            qdict_put_obj(qmp, "return", data);

        } else {

            /* return an empty QDict by default */

            qdict_put(qmp, "return", qdict_new());

        }

    } else {

        /* error response */

        qdict_put(mon->error->error, "desc", qerror_human(mon->error));

        qdict_put(qmp, "error", mon->error->error);

        QINCREF(mon->error->error);

        QDECREF(mon->error);

        mon->error = NULL;

    }



    if (mon->mc->id) {

        qdict_put_obj(qmp, "id", mon->mc->id);

        mon->mc->id = NULL;

    }



    monitor_json_emitter(mon, QOBJECT(qmp));

    QDECREF(qmp);

}

static void monitor_protocol_emitter(Monitor *mon, QObject *data)

{

    QDict *qmp;



    qmp = qdict_new();



    if (!monitor_has_error(mon)) {

        

        if (data) {

            assert(qobject_type(data) == QTYPE_QDICT);

            qobject_incref(data);

            qdict_put_obj(qmp, "return", data);

        } else {

            

            qdict_put(qmp, "return", qdict_new());

        }

    } else {

        

        qdict_put(mon->error->error, "desc", qerror_human(mon->error));

        qdict_put(qmp, "error", mon->error->error);

        QINCREF(mon->error->error);

        QDECREF(mon->error);

        mon->error = NULL;

    }



    if (mon->mc->id) {

        qdict_put_obj(qmp, "id", mon->mc->id);

        mon->mc->id = NULL;

    }



    monitor_json_emitter(mon, QOBJECT(qmp));

    QDECREF(qmp);

}

static void FUNC_0(Monitor *VAR_0, QObject *VAR_1)

{

    QDict *qmp;



    qmp = qdict_new();



    if (!monitor_has_error(VAR_0)) {

        

        if (VAR_1) {

            assert(qobject_type(VAR_1) == QTYPE_QDICT);

            qobject_incref(VAR_1);

            qdict_put_obj(qmp, "return", VAR_1);

        } else {

            

            qdict_put(qmp, "return", qdict_new());

        }

    } else {

        

        qdict_put(VAR_0->error->error, "desc", qerror_human(VAR_0->error));

        qdict_put(qmp, "error", VAR_0->error->error);

        QINCREF(VAR_0->error->error);

        QDECREF(VAR_0->error);

        VAR_0->error = NULL;

    }



    if (VAR_0->mc->id) {

        qdict_put_obj(qmp, "id", VAR_0->mc->id);

        VAR_0->mc->id = NULL;

    }



    monitor_json_emitter(VAR_0, QOBJECT(qmp));

    QDECREF(qmp);

}

static void FUNC_0(Monitor *VAR_0, QObject *VAR_1)
{ QDict *qmp; qmp = qdict_new(); if (!monitor_has_error(VAR_0)) { if (VAR_1) { assert(qobject_type(VAR_1) == QTYPE_QDICT); qobject_incref(VAR_1); qdict_put_obj(qmp, "return", VAR_1); } else { qdict_put(qmp, "return", qdict_new()); } } else { qdict_put(VAR_0->error->error, "desc", qerror_human(VAR_0->error)); qdict_put(qmp, "error", VAR_0->error->error); QINCREF(VAR_0->error->error); QDECREF(VAR_0->error); VAR_0->error = NULL; } if (VAR_0->mc->id) { qdict_put_obj(qmp, "id", VAR_0->mc->id); VAR_0->mc->id = NULL; } monitor_json_emitter(VAR_0, QOBJECT(qmp)); QDECREF(qmp); }