Beispiel #1
0
json_t * rdis_serialize (struct _rdis * rdis)
{
    json_t * json = json_object();

    json_object_set(json, "ot",        json_integer(SERIALIZE_RDIS));
    json_object_set(json, "graph",     object_serialize(rdis->graph));
    json_object_set(json, "labels",    object_serialize(rdis->labels));
    json_object_set(json, "functions", object_serialize(rdis->functions));
    json_object_set(json, "memory",    object_serialize(rdis->memory));

    return json;
}
Beispiel #2
0
json_t * ins_serialize (struct _ins * ins)
{
    json_t * json = json_object();
    json_t * bytes = json_array();

    int i;
    for (i = 0; i < ins->size; i++) {
        json_array_append(bytes, json_integer(ins->bytes[i]));
    }

    json_object_set(json, "ot",          json_integer(SERIALIZE_INSTRUCTION));
    json_object_set(json, "address",     json_uint64_t(ins->address));
    json_object_set(json, "target",      json_uint64_t(ins->target));
    json_object_set(json, "bytes",       bytes);
    if (ins->description == NULL)
        json_object_set(json, "description", json_string(""));
    else
        json_object_set(json, "description", json_string(ins->description));
    if (ins->comment == NULL)
        json_object_set(json, "comment", json_string(""));
    else
        json_object_set(json, "comment", json_string(ins->comment));
    json_object_set(json, "flags",      json_integer(ins->flags));
    json_object_set(json, "references", object_serialize(ins->references));

    return json;
}
Beispiel #3
0
void rdiswindow_save (GtkMenuItem * menuItem, struct _rdiswindow * rdiswindow)
{
    GtkWidget * dialog;
    char tmp[256];

    if (rdiswindow->gui->rdis == NULL) {
        gui_console(rdiswindow->gui, "no rdis loaded");
        return;
    }

    dialog = gtk_file_chooser_dialog_new(LANG_SAVERDISFILE,
                                         GTK_WINDOW(rdiswindow->window),
                                         GTK_FILE_CHOOSER_ACTION_SAVE,
                                         GTK_STOCK_CANCEL,
                                         GTK_RESPONSE_CANCEL,
                                         GTK_STOCK_SAVE,
                                         GTK_RESPONSE_ACCEPT,
                                         NULL);

    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
    {
        char * filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));

        json_t * json = object_serialize(rdiswindow->gui->rdis);
        if (json_dump_file(json, filename, JSON_COMPACT))
            snprintf(tmp, 256, "error (json) saving file %s\n", filename);
        else
            snprintf(tmp, 256, "saved file %s\n", filename);

        gui_console(rdiswindow->gui, tmp);

        json_decref(json);

        g_free(filename);
    }

    gtk_widget_destroy(dialog);
}