diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-08-30 10:55:45 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-08-30 10:55:45 (GMT) |
commit | ac447bc36e65b91f97434cf2613ccb1e768267e0 (patch) | |
tree | 471f3b49629269d7ea44a6ea8b9177fe7e437817 /src/analysis/exporter.c | |
parent | 184249f07fb32fb2449723f5f94ce221015231b7 (diff) |
Rendered using the GTK buffer (crappy version).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@107 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/exporter.c')
-rw-r--r-- | src/analysis/exporter.c | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/src/analysis/exporter.c b/src/analysis/exporter.c new file mode 100644 index 0000000..dd0f6c0 --- /dev/null +++ b/src/analysis/exporter.c @@ -0,0 +1,253 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * exporter.c - traduction humaine des lignes de rendus + * + * Copyright (C) 2009 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "exporter.h" + + +#include "exporter-int.h" + + + +/* Indique le type défini pour une exportation de contenu. */ +G_DEFINE_TYPE(GContentExporter, g_content_exporter, G_TYPE_OBJECT); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des lignes de représentation. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_content_exporter_class_init(GContentExporterClass *klass) +{ + GtkTextTagTable *table; /* Seule table globale valable */ + GtkTextTag *tag; + + /* Décorateurs GTK */ + + table = get_gtk_tag_table(); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "green", NULL); + + klass->tags[RTT_COMMENT] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "gray", NULL); + + klass->tags[RTT_RAW_CODE] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "red", NULL); + + klass->tags[RTT_INSTRUCTION] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "purple", NULL); + + klass->tags[RTT_IMMEDIATE] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "blue", NULL); + + klass->tags[RTT_REGISTER] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "blue", "background", "black", NULL); + + klass->tags[RTT_HOOK] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "white", "background", "black", NULL); + + klass->tags[RTT_SIGNS] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "red", "background", "black", NULL); + + klass->tags[RTT_LTGT] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "black", NULL); + + klass->tags[RTT_SEGMENT] = tag; + gtk_text_tag_table_add(table, tag); + + tag = gtk_text_tag_new(NULL); + + g_object_set(G_OBJECT(tag), "foreground", "orange", NULL); + + klass->tags[RTT_STRING] = tag; + gtk_text_tag_table_add(table, tag); + +} + + +/****************************************************************************** +* * +* Paramètres : exporter = instance à initialiser. * +* * +* Description : Initialise une instance de ligne de représentation. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_content_exporter_init(GContentExporter *exporter) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : table = éventuelle instance à enregistrer. * +* * +* Description : Définit et/ou renvoie le singleton pour les marques de texte.* +* * +* Retour : Table courante à utiliser. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkTextTagTable *_get_gtk_tag_table(GtkTextTagTable *table) +{ + static GtkTextTagTable *result = NULL; /* Table valable à renvoyer */ + + if (table != NULL) + { + if (result != NULL) /* TODO : free() */; + result = table; + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : exporter = instance sachant exporter son contenu. * +* buffer = zone de texte à venir compléter. * +* iter = point d'insertion du nouveau texte. [OUT] * +* text = texte à insérer dans l'existant. * +* length = taille du texte à traiter. * +* tag = type de décorateur à utiliser. * +* * +* Description : Ajoute du texte à un texte GTK via l'instance spécifiée. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_content_exporter_insert_with_gtk_tag(GContentExporter *exporter, GtkTextBuffer *buffer, GtkTextIter *iter, const char *text, size_t length, RenderingTagType tag) +{ + size_t init; /* Point d'insertion initial */ + + init = gtk_text_iter_get_offset(iter); + + if (tag != RTT_NONE) + gtk_text_buffer_insert_with_tags(buffer, iter, text, length, + G_CONTENT_EXPORTER_GET_CLASS(exporter)->tags[tag], + NULL); + + else gtk_text_buffer_insert_with_tags(buffer, iter, text, length, NULL); + + gtk_text_iter_set_offset(iter, init + length); + +} + + +/****************************************************************************** +* * +* Paramètres : exporter = instance sachant exporter son contenu. * +* rendering = support effectif final des lignes de code. * +* buffer = zone de texte à venir compléter. * +* iter = point d'insertion du nouveau texte. * +* * +* Description : Ajoute à un texte GTK le contenu de l'instance spécifiée. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_content_exporter_add_to_gtk_buffer(GContentExporter *exporter, MainRendering rendering, GtkTextBuffer *buffer, GtkTextIter *iter) +{ + if (exporter->add_to_gtk_buffer != NULL) + exporter->add_to_gtk_buffer(exporter, rendering, buffer, iter, NULL); + +} + + +/****************************************************************************** +* * +* Paramètres : exporter = instance sachant exporter son contenu. * +* format = format du binaire manipulé. * +* syntax = type de représentation demandée. * +* buffer = zone de texte à venir compléter. * +* iter = point d'insertion du nouveau texte. * +* * +* Description : Ajoute à un texte GTK le contenu d'une architecture. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_content_exporter_add_arch_to_gtk_buffer(const GContentExporter *exporter, const GExeFormat *format, AsmSyntax syntax, GtkTextBuffer *buffer, GtkTextIter *iter) +{ + if (exporter->add_arch_to_gtk_buffer != NULL) + exporter->add_arch_to_gtk_buffer(exporter, format, syntax, buffer, iter); + +} |