diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/glibext/Makefile.am | 1 | ||||
-rw-r--r-- | src/glibext/gbinportion-int.h | 64 | ||||
-rw-r--r-- | src/glibext/gbinportion.c | 47 | ||||
-rw-r--r-- | src/glibext/gbinportion.h | 3 |
4 files changed, 81 insertions, 34 deletions
diff --git a/src/glibext/Makefile.am b/src/glibext/Makefile.am index 11d2baf..127f60c 100644 --- a/src/glibext/Makefile.am +++ b/src/glibext/Makefile.am @@ -9,6 +9,7 @@ libglibext_la_SOURCES = \ delayed-int.h \ delayed.h delayed.c \ gbinarycursor.h gbinarycursor.c \ + gbinportion-int.h \ gbinportion.h gbinportion.c \ gbuffercache.h gbuffercache.c \ gbufferline.h gbufferline.c \ diff --git a/src/glibext/gbinportion-int.h b/src/glibext/gbinportion-int.h new file mode 100644 index 0000000..b5c70c8 --- /dev/null +++ b/src/glibext/gbinportion-int.h @@ -0,0 +1,64 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * binportion.h - prototypes pour la définition interne des portions de binaire + * + * Copyright (C) 2019 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GLIBEXT_BINPORTION_INT_H +#define _GLIBEXT_BINPORTION_INT_H + + +#include "gbinportion.h" + + + +/* Portion de données binaires quelconques (instance) */ +struct _GBinPortion +{ + GObject parent; /* A laisser en premier */ + + char *code; /* Code de la couleur de fond */ + + cairo_surface_t *icon; /* Image de représentation */ + + char *desc; /* Désignation humaine */ + char **text; /* Lignes brutes à représenter */ + size_t lcount; /* Quantité de ces lignes */ + + mrange_t range; /* Emplacement dans le code */ + bool continued; /* Suite d'une découpe ? */ + + PortionAccessRights rights; /* Droits d'accès */ + + GBinPortion **subs; /* Portions incluses */ + size_t count; /* Quantité d'inclusions */ + +}; + +/* Portion de données binaires quelconques (classe) */ +struct _GBinPortionClass +{ + GObjectClass parent; /* A laisser en premier */ + +}; + + + +#endif /* _GLIBEXT_BINPORTION_INT_H */ diff --git a/src/glibext/gbinportion.c b/src/glibext/gbinportion.c index 8826bd3..e020506 100644 --- a/src/glibext/gbinportion.c +++ b/src/glibext/gbinportion.c @@ -34,6 +34,7 @@ #include <i18n.h> +#include "gbinportion-int.h" #include "../analysis/human/asm/lang.h" #include "../common/extstr.h" #include "../common/sort.h" @@ -45,37 +46,6 @@ /* ------------------------------- PORTION DE BINAIRE ------------------------------- */ -/* Portion de données binaires quelconques (instance) */ -struct _GBinPortion -{ - GObject parent; /* A laisser en premier */ - - char *code; /* Code de la couleur de fond */ - - cairo_surface_t *icon; /* Image de représentation */ - - char *desc; /* Désignation humaine */ - char **text; /* Lignes brutes à représenter */ - size_t lcount; /* Quantité de ces lignes */ - - mrange_t range; /* Emplacement dans le code */ - bool continued; /* Suite d'une découpe ? */ - - PortionAccessRights rights; /* Droits d'accès */ - - GBinPortion **subs; /* Portions incluses */ - size_t count; /* Quantité d'inclusions */ - -}; - -/* Portion de données binaires quelconques (classe) */ -struct _GBinPortionClass -{ - GObjectClass parent; /* A laisser en premier */ - -}; - - /* Initialise la classe des portions de données binaires. */ static void g_binary_portion_class_init(GBinPortionClass *); @@ -179,10 +149,17 @@ static void g_binary_portion_class_init(GBinPortionClass *klass) static void g_binary_portion_init(GBinPortion *portion) { + vmpa2t dummy; /* Coquille presque vide */ + + portion->code = NULL; + portion->desc = NULL; portion->text = NULL; portion->lcount = 0; + init_vmpa(&dummy, VMPA_NO_PHYSICAL, VMPA_NO_VIRTUAL); + init_mrange(&portion->range, &dummy, VMPA_NO_VIRTUAL); + portion->continued = false; } @@ -246,7 +223,8 @@ static void g_binary_portion_finalize(GBinPortion *portion) { size_t i; /* Boucle de parcours */ - free(portion->code); + if (portion->code != NULL) + free(portion->code); if (portion->icon != NULL) cairo_surface_destroy(portion->icon); @@ -480,7 +458,7 @@ const char *g_binary_portion_get_desc(const GBinPortion *portion) * * * Description : Fournit l'emplacement d'une partie de code binaire. * * * -* Retour : - * +* Retour : Espace de couverture associé à la portion. * * * * Remarques : - * * * @@ -748,7 +726,8 @@ void g_binary_portion_draw(const GBinPortion *portion, GtkStyleContext *context, gtk_style_context_save(context); - gtk_style_context_add_class(context, portion->code); + if (portion->code != NULL) + gtk_style_context_add_class(context, portion->code); gtk_render_background(context, cr, area->x, area->y, area->width, area->height); diff --git a/src/glibext/gbinportion.h b/src/glibext/gbinportion.h index 5c8c363..e20e159 100644 --- a/src/glibext/gbinportion.h +++ b/src/glibext/gbinportion.h @@ -75,6 +75,9 @@ typedef enum _PortionAccessRights } PortionAccessRights; +#define PAC_ALL ((PortionAccessRights)(PAC_READ | PAC_WRITE | PAC_EXEC)) + + /* Indique le type défini par la GLib pour les portions de données binaires. */ GType g_binary_portion_get_type(void); |