diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-11-02 15:50:07 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-11-02 15:50:07 (GMT) |
commit | f5df6496fa50927d3d274c939a888afde652b7ad (patch) | |
tree | 281dbfdfdcb8765fea7036af274c63fb5acde8ff /src/graph | |
parent | c3aba0893c29cc098c029306fd7a4c8c1fa2eee2 (diff) |
Improved the computing and the rendering of the graphic view.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@277 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/graph')
-rwxr-xr-x | src/graph/Makefile.am | 18 | ||||
-rw-r--r-- | src/graph/dot.c | 233 | ||||
-rw-r--r-- | src/graph/dot.h | 51 | ||||
-rw-r--r-- | src/graph/layout.c | 219 | ||||
-rw-r--r-- | src/graph/layout.h | 41 | ||||
-rw-r--r-- | src/graph/node.c | 283 | ||||
-rw-r--r-- | src/graph/node.h | 71 |
7 files changed, 0 insertions, 916 deletions
diff --git a/src/graph/Makefile.am b/src/graph/Makefile.am deleted file mode 100755 index e374709..0000000 --- a/src/graph/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ - -noinst_LTLIBRARIES = libgraph.la - -libgraph_la_SOURCES = \ - dot.h dot.c \ - layout.h layout.c \ - node.h node.c - -libgraph_la_LDFLAGS = - - -INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBGRAPH_CFLAGS) - -AM_CPPFLAGS = - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - -SUBDIRS = diff --git a/src/graph/dot.c b/src/graph/dot.c deleted file mode 100644 index 5a80f59..0000000 --- a/src/graph/dot.c +++ /dev/null @@ -1,233 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * dot.c - interactions avec le système dot - * - * Copyright (C) 2009-2012 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 "dot.h" - - -#include <malloc.h> -#include <graphviz/gvc.h> -#include <graphviz/types.h> - - - -/* Graphique selon Graphviz */ -struct _graph_layout -{ - GVC_t *context; /* Contexte pour Graphviz */ - graph_t *graph; /* Graphique construit */ - -}; - - - -/****************************************************************************** -* * -* Paramètres : cmds = description textuelle du graphique à représenter. * -* * -* Description : Charge un graphique à partir de sa description. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -graph_layout *create_graph_layout(char *cmds) -{ - graph_layout *result; /* Composants à retourner */ - int ret; /* Bilan d'un appel */ - - result = (graph_layout *)calloc(1, sizeof(graph_layout)); - - result->context = gvContext(); - result->graph = agmemread(cmds); - - if (result->graph == NULL) goto cdl_error; - - - - ret = gvLayout(result->context, result->graph, "dot"); - - - printf("ret = %d\n", ret); - - /* - ret = gvLayoutJobs(result->context, result->graph); - printf("ret = %d\n", ret); - ret = gvRenderJobs(result->context, result->graph); - printf("ret = %d\n", ret); - */ - - - ret = gvRender(result->context, result->graph, "dot", NULL); - - - - ret = gvRender(result->context, result->graph, "plain", NULL); - - printf("ret = %d\n", ret); - - - - - - return result; - - cdl_error: - - delete_graph_layout(result); - - return NULL; - -} - - -/****************************************************************************** -* * -* Paramètres : layout = graphique à supprimer de la mémoire. * -* * -* Description : Décharge un graphique. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void delete_graph_layout(graph_layout *layout) -{ - if (layout->graph != NULL) - { - gvFreeLayout(layout->context, layout->graph); - agclose(layout->graph); - } - - gvFreeContext(layout->context); - - free(layout); - -} - - -/****************************************************************************** -* * -* Paramètres : layout = graphique à supprimer de la mémoire. * -* view = support de destination. * -* nodes = liste de noeuds à traiter. * -* count = taille de la liste. * -* * -* Description : Place tous les éléments du graphique à l'écran. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void place_nodes_of_graph_layout(const graph_layout *layout, GtkGraphView *view, GGraphNode **nodes, size_t count) -{ - int height; /* Hauteur du graphique */ - node_t *iter; /* Boucle de parcours */ - const GGraphNode *node; /* Intermédiaire concerné */ - - height = GD_bb(layout->graph).UR.y; - - for (iter = agfstnode(layout->graph); iter != NULL; iter = agnxtnode(layout->graph, iter)) - { - node = find_graph_node_by_name(nodes, count, iter->name); - g_graph_node_place(node, view, iter->u.coord.x, height - iter->u.coord.y); - } - -} - - -/****************************************************************************** -* * -* Paramètres : layout = graphique à supprimer de la mémoire. * -* count = nombre d'éléments mis en place. * -* * -* Description : Charge la définition de tous les liens graphiques. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -GtkLinkRenderer **create_links_from_graph_layout(const graph_layout *layout, size_t *count) -{ - GtkLinkRenderer **result; /* Liste à retourner */ - int height; /* Hauteur du graphique */ - node_t *niter; /* Boucle de parcours #1 */ - edge_t *eiter; /* Boucle de parcours #2 */ - splines *lines; /* Lignes déjà tracées */ - int i; /* Boucle de parcours #3 */ - int k; /* Boucle de parcours #4 */ - GdkPoint *points; /* Points de ligne relus */ - size_t points_count; /* Nombre de ces points */ - - result = NULL; - *count = 0; - - height = GD_bb(layout->graph).UR.y; - - for (niter = agfstnode(layout->graph); niter != NULL; niter = agnxtnode(layout->graph, niter)) - for (eiter = agfstout(layout->graph, niter); eiter != NULL; eiter = agnxtout(layout->graph, eiter)) - { - lines = ED_spl(eiter); - - //printf("edge == %p\n", eiter); - - points = NULL; - points_count = 0; - - for (i = 0; i < lines->size; i++) - { - points = (GdkPoint *)realloc(points, (points_count + lines->list[i].size) * sizeof(GdkPoint)); - - for (k = 0; k < lines->list[i].size; k++) - { - points[points_count + k].x = lines->list[i].list[k].x; - points[points_count + k].y = height - lines->list[i].list[k].y; - - /* - printf(" ... ( %d ; %d)\n", - lines->list[i].list[k].x, height - lines->list[i].list[k].y); - */ - - } - - points_count += lines->list[i].size; - - //printf(" ...\n"); - - } - - result = (GtkLinkRenderer **)realloc(result, ++(*count) * sizeof(GtkLinkRenderer *)); - result[*count - 1] = GTK_LINK_RENDERER(gtk_link_renderer_new(points, points_count)); - - } - - return result; - -} diff --git a/src/graph/dot.h b/src/graph/dot.h deleted file mode 100644 index 47550a8..0000000 --- a/src/graph/dot.h +++ /dev/null @@ -1,51 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * dot.h - prototypes pour les interactions avec le système dot - * - * 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/>. - */ - - -#ifndef _GRAPH_DOT_H -#define _GRAPH_DOT_H - - -#include "node.h" -#include "../gtkext/gtklinkrenderer.h" - - - -/* Graphique selon Graphviz */ -typedef struct _graph_layout graph_layout; - - -/* Charge un graphique à partir de sa description. */ -graph_layout *create_graph_layout(char *); - -/* Décharge un graphique. */ -void delete_graph_layout(graph_layout *); - -/* Place tous les éléments du graphique à l'écran. */ -void place_nodes_of_graph_layout(const graph_layout *, GtkGraphView *, GGraphNode **, size_t); - -/* Charge la définition de tous les liens graphiques. */ -GtkLinkRenderer **create_links_from_graph_layout(const graph_layout *, size_t *); - - - -#endif /* _GRAPH_DOT_H */ diff --git a/src/graph/layout.c b/src/graph/layout.c deleted file mode 100644 index f8afad6..0000000 --- a/src/graph/layout.c +++ /dev/null @@ -1,219 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * layout.c - mise en place de graphique - * - * Copyright (C) 2009-2012 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 "layout.h" - - -#include <malloc.h> -#include <string.h> -#include <gtk/gtkfixed.h> - - -#include "dot.h" -#include "node.h" -#include "../analysis/binary.h" -#include "../common/extstr.h" -#include "../gtkext/gtkbufferview.h" - - - -/* Taille maximale des descriptions de liens */ -#define LINKS_DESC_LEN 128 - - -/* Etablit tous les liens entre les différents morceaux de code. */ -static char *complete_graph_links(const GtkGraphView *, GtkViewPanel **, size_t, char *); - - - -/****************************************************************************** -* * -* Paramètres : view = support où placer les différents éléments. * -* views = morceaux de code à afficher de façon organisée. * -* count = quantité de ces morceaux de code. * -* * -* Description : Dispose une série de morceaux d'affichage en graphique. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool build_graph_view(GtkGraphView *view, GtkViewPanel **views, size_t count) -{ - GGraphNode **nodes; /* Intermédiaires en place */ - size_t i; /* Boucle de parcours */ - char *cmds; /* Description à envoyer à dot */ - graph_layout *layout; /* Graphique construit */ - GtkLinkRenderer **links; /* Liens graphiques construits */ - size_t links_count; /* Quantité de ces liens */ - - /* Création de la glue */ - - nodes = (GGraphNode **)calloc(count, sizeof(GGraphNode *)); - - for (i = 0; i < count; i++) - nodes[i] = g_graph_node_new(GTK_WIDGET(views[i])); - - /* Définition du graphique */ - - cmds = strdup("digraph G {\noverlap=false;\n splines=true;\n"); - - for (i = 0; i < count; i++) - cmds = g_graph_node_register_for_dot(nodes[i], cmds); - - cmds = complete_graph_links(view, views, count, cmds); - - cmds = stradd(cmds, "}"); - - layout = create_graph_layout(cmds); - - /* Affichage du graphique */ - - place_nodes_of_graph_layout(layout, view, nodes, count); - - links = create_links_from_graph_layout(layout, &links_count); - gtk_graph_view_attach_links(view, links, links_count); - - gtk_widget_queue_draw(GTK_WIDGET(view)); - - delete_graph_layout(layout); - - /* TODO : free nodes */ - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : view = support contenant les différentes lignes. * -* views = morceaux de code à afficher de façon organisée. * -* count = quantité de ces morceaux de code. * -* desc = description du graphique à compléter. [OUT] * -* * -* Description : Etablit tous les liens entre les différents morceaux de code.* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static char *complete_graph_links(const GtkGraphView *view, GtkViewPanel **views, size_t count, char *desc) -{ - GLoadedBinary *binary; /* Binaire rattaché aux vues */ - GArchInstruction *instrs; /* Instructions pour assembleur*/ - GBufferView *buffer; /* Tampon d'une partie de code */ - vmpa_t end; /* Adresse finale du tampon */ - size_t i; /* Boucle de parcours #1 */ - GArchInstruction *last; /* Dernière instruc. d'un bloc */ - vmpa_t addr; /* Addresse d'instruction */ - GArchInstruction **dests; /* Instr. visée par une autre */ - InstructionLinkType *types; /* Type de lien entre lignes */ - size_t dcount; /* Nombre de liens de dest. */ - size_t j; /* Boucle de parcours #2 */ - size_t k; /* Boucle de parcours #3 */ - char cmd[LINKS_DESC_LEN]; /* Tampon pour l'ajout de liens*/ - GArchInstruction *next; /* Instruction suivante */ - - if (count == 0) - return desc; - - binary = gtk_view_panel_get_binary(views[0]); - instrs = g_loaded_binary_get_instructions(binary); - - for (i = 0; i < count; i++) - { - buffer = gtk_buffer_view_get_buffer(GTK_BUFFER_VIEW(views[i])); - g_buffer_view_get_restrictions(buffer, NULL, &end); - - last = g_arch_instruction_find_by_address(instrs, end, true); - g_arch_instruction_get_location(last, NULL, NULL, &addr); - - if (g_arch_instruction_has_destinations(last)) - { - dcount = g_arch_instruction_get_destinations(last, &dests, &types); - - for (j = 0; j < dcount; j++) - { - g_arch_instruction_get_location(dests[j], NULL, NULL, &addr); - - for (k = 0; k < count; k++) - if (gtk_view_panel_contain_address(views[k], addr)) - break; - - if (k < count) - switch (types[j]) - { - case ILT_JUMP: - snprintf(cmd, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); - desc = stradd(desc, cmd); - break; - - case ILT_JUMP_IF_TRUE: - snprintf(cmd, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); - desc = stradd(desc, cmd); - break; - - case ILT_JUMP_IF_FALSE: - snprintf(cmd, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); - desc = stradd(desc, cmd); - break; - - default: - break; - - } - - } - - } - - /* Si la ligne n'est pas la dernière, on suit le flux normal */ - else if (addr != end) - { - next = g_arch_instruction_get_next_iter(instrs, last, end); - if (next == NULL) continue; - - g_arch_instruction_get_location(next, NULL, NULL, &addr); - - for (k = 0; k < count; k++) - if (gtk_view_panel_contain_address(views[k], addr)) - break; - - if (k < count) - { - snprintf(cmd, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]); - desc = stradd(desc, cmd); - } - - } - - } - - return desc; - -} diff --git a/src/graph/layout.h b/src/graph/layout.h deleted file mode 100644 index 006fa9b..0000000 --- a/src/graph/layout.h +++ /dev/null @@ -1,41 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * layout.h - prototypes pour la mise en place de graphique - * - * Copyright (C) 2009-2012 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/>. - */ - - -#ifndef _GRAPH_LAYOUT_H -#define _GRAPH_LAYOUT_H - - -#include <stdbool.h> - - -#include "../gtkext/gtkgraphview.h" -#include "../gtkext/gtkviewpanel.h" - - - -/* Dispose une série de morceaux d'affichage en graphique. */ -bool build_graph_view(GtkGraphView *, GtkViewPanel **, size_t); - - - -#endif /* _GRAPH_LAYOUT_H */ diff --git a/src/graph/node.c b/src/graph/node.c deleted file mode 100644 index 0d278f3..0000000 --- a/src/graph/node.c +++ /dev/null @@ -1,283 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * node.c - éléments de graphiques chez dot - * - * Copyright (C) 2009-2012 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 "node.h" - - -#include <malloc.h> -#include <stdio.h> -#include <string.h> - - -#include "../common/extstr.h" - - - -/* -------------------------- GESTION DES NOEUDS A L'UNITE -------------------------- */ - - -/* Intermédiaire entre le noeud dot et la bribe de code (instance) */ -struct _GGraphNode -{ - GObject parent; /* A laisser en premier */ - - GtkWidget *view; /* Morceau de code représenté */ - char *name; /* Adresse sous forme humaine */ - -}; - - -/* Intermédiaire entre le noeud dot et la bribe de code (classe) */ -struct _GGraphNodeClass -{ - GObjectClass parent; /* A laisser en premier */ - - double dpi_x; /* Résolution en abscisse */ - double dpi_y; /* Résolution en ordonnée */ - -}; - - -/* Initialise la classe des intermédiaires avec les noeuds dot. */ -static void g_graph_node_class_init(GGraphNodeClass *); - -/* Initialise la classe des intermédiaires avec les noeuds dot. */ -static void g_graph_node_init(GGraphNode *); - - - -/* ---------------------------------------------------------------------------------- */ -/* GESTION DES NOEUDS A L'UNITE */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type définit par la GLib pour le noeud. */ -G_DEFINE_TYPE(GGraphNode, g_graph_node, G_TYPE_OBJECT); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des intermédiaires avec les noeuds dot. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_graph_node_class_init(GGraphNodeClass *klass) -{ - GdkScreen *screen; /* Ecran par défaut */ - gint width; /* Largeur d'écran en pixels */ - gint height; /* Hauteur d'écran en pixels */ - gint width_mm; /* Largeur d'écran en mm. */ - gint height_mm; /* Hauteur d'écran en mm. */ - - screen = gdk_screen_get_default(); - - width = gdk_screen_get_width(screen); - height = gdk_screen_get_height(screen); - - width_mm = gdk_screen_get_width_mm(screen); - height_mm = gdk_screen_get_height_mm(screen); - - /** - * Il y a 2.54 centimètres, soit 25.4 millimètres, dans un pouce. - * On a donc : - * - * dpi = N pixels / (M millimètres / (25.4 millimètres / 1 pouce)) - * = N pixels / (M pouces / 25.4) - * = N * 25.4 pixels / M pouces - * - */ - - if (width_mm > 0 && height_mm > 0) - { - klass->dpi_x = (width * 25.4) / (double)width_mm; - klass->dpi_y = (height * 25.4) / (double)height_mm; - } - else - { - klass->dpi_x = 96; - klass->dpi_y = 96; - } - - - klass->dpi_x = 72; - klass->dpi_y = 72; - -} - - -/****************************************************************************** -* * -* Paramètres : node = instance à initialiser. * -* * -* Description : Initialise la classe des intermédiaires avec les noeuds dot. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_graph_node_init(GGraphNode *node) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : view = morceau d'affichage à représenter. * -* * -* Description : Constitue un intermédiaire entre un noeud dot et du code. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GGraphNode *g_graph_node_new(GtkWidget *view) -{ - GGraphNode *result; /* Structure à retourner */ - size_t len; /* Taille du nom */ - - result = g_object_new(G_TYPE_GRAPH_NODE, NULL); - - result->view = view; - - len = 3 + sizeof(GtkWidget *) * 2 + 1; - - result->name = (char *)calloc(len, sizeof(char)); - snprintf(result->name, len, "_%p", result->view); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : node = intermédiaire à consulter. * -* cmds = description pour dot à compléter. * -* * -* Description : Déclare l'intermédiaire en tant que noeud pour dot. * -* * -* Retour : Description dûment complétée. * -* * -* Remarques : - * -* * -******************************************************************************/ - -char *g_graph_node_register_for_dot(const GGraphNode *node, char *cmds) -{ - GtkRequisition requisition; /* Taille à l'écran requise */ - char buffer[128]; - - gtk_widget_size_request(node->view, &requisition); - - cmds = stradd(cmds, node->name); - cmds = stradd(cmds, " [shape=box, fixedsize "); - - snprintf(buffer, 128, ", width=\"%g\"", - requisition.width / G_GRAPH_NODE_GET_CLASS(node)->dpi_x); - cmds = stradd(cmds, buffer); - - snprintf(buffer, 128, ", height=\"%g\"", - requisition.height / G_GRAPH_NODE_GET_CLASS(node)->dpi_y); - cmds = stradd(cmds, buffer); - - cmds = stradd(cmds, "];\n"); - - return cmds; - -} - - -/****************************************************************************** -* * -* Paramètres : node = intermédiaire à consulter. * -* view = support de destination. * -* x = abscisse du point d'intégration. * -* y = ordonnée du point d'intégration. * -* * -* Description : Place le morceau de code de l'intermédiaire à l'écran. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_graph_node_place(const GGraphNode *node, GtkGraphView *view, gint x, gint y) -{ - GtkRequisition requisition; /* Taille à l'écran actuelle */ - - gtk_widget_size_request(node->view, &requisition); - - x -= requisition.width / 2; - y -= requisition.height / 2; - - gtk_graph_view_put(view, node->view, x, y); - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* MANIPULATION D'ENSEMBLES DE NOEUDS */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : nodes = liste de noeuds à parcourir. * -* count = taille de la liste. * -* target = nom du noeud recherché. * -* * -* Description : Recherche un noeud donné dans une série de noeuds. * -* * -* Retour : Noeud trouvé ou NULL si aucun. * -* * -* Remarques : - * -* * -******************************************************************************/ - -const GGraphNode *find_graph_node_by_name(GGraphNode **nodes, size_t count, const char *target) -{ - const GGraphNode *result; /* Trouvaille à remonter */ - size_t i; /* Boucle de parcours */ - - result = NULL; - - for (i = 0; i < count && result == NULL; i++) - if (strcmp(nodes[i]->name, target) == 0) - result = nodes[i]; - - return result; - -} diff --git a/src/graph/node.h b/src/graph/node.h deleted file mode 100644 index f8d0078..0000000 --- a/src/graph/node.h +++ /dev/null @@ -1,71 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * node.h - prototypes pour les éléments de graphiques chez dot - * - * Copyright (C) 2009-2012 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/>. - */ - - -#ifndef _GRAPH_NODE_H -#define _GRAPH_NODE_H - - -#include "../gtkext/gtkgraphview.h" - - - -/* -------------------------- GESTION DES NOEUDS A L'UNITE -------------------------- */ - - -#define G_TYPE_GRAPH_NODE g_graph_node_get_type() -#define G_GRAPH_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_graph_node_get_type(), GGraphNode)) -#define G_IS_GRAPH_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_graph_node_get_type())) -#define G_GRAPH_NODE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_graph_node_get_type(), GGraphNodeIface)) -#define G_GRAPH_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_GRAPH_NODE, GGraphNodeClass)) - - -/* Intermédiaire entre le noeud dot et la bribe de code (instance) */ -typedef struct _GGraphNode GGraphNode; - -/* Intermédiaire entre le noeud dot et la bribe de code (classe) */ -typedef struct _GGraphNodeClass GGraphNodeClass; - - -/* Indique le type définit par la GLib pour le noeud. */ -GType g_graph_node_get_type(void); - -/* Constitue un intermédiaire entre un noeud dot et du code. */ -GGraphNode *g_graph_node_new(GtkWidget *); - -/* Déclare l'intermédiaire en tant que noeud pour dot. */ -char *g_graph_node_register_for_dot(const GGraphNode *, char *); - -/* Place le morceau de code de l'intermédiaire à l'écran. */ -void g_graph_node_place(const GGraphNode *, GtkGraphView *, gint , gint); - - - -/* ----------------------- MANIPULATION D'ENSEMBLES DE NOEUDS ----------------------- */ - - -/* Recherche un noeud donné dans une série de noeuds. */ -const GGraphNode *find_graph_node_by_name(GGraphNode **, size_t, const char *); - - - -#endif /* _GRAPH_NODE_H */ |