diff options
Diffstat (limited to 'src/glibext/gbinportion.c')
-rw-r--r-- | src/glibext/gbinportion.c | 161 |
1 files changed, 159 insertions, 2 deletions
diff --git a/src/glibext/gbinportion.c b/src/glibext/gbinportion.c index 94a04cc..1fbb460 100644 --- a/src/glibext/gbinportion.c +++ b/src/glibext/gbinportion.c @@ -44,6 +44,7 @@ struct _GBinPortion { GObject parent; /* A laisser en premier */ + unsigned int level; /* Profondeur de la portion */ GBinPortion *container; /* Portion parente ou racine */ char *code; /* Code de la couleur de fond */ @@ -51,8 +52,8 @@ struct _GBinPortion char *desc; /* Désignation humaine */ mrange_t range; /* Emplacement dans le code */ - vmpa2t addr; /* Emplacement dans le code */ - off_t size; /* Taille de la partie */ + vmpa2t addr; /* Emplacement dans le code */ /* TODO : clean */ + off_t size; /* Taille de la partie */ /* TODO : clean */ PortionAccessRights rights; /* Droits d'accès */ @@ -86,6 +87,9 @@ static void g_binary_portion_dispose(GBinPortion *); /* Procède à la libération totale de la mémoire. */ static void g_binary_portion_finalize(GBinPortion *); +/* Définit le niveau de profondeur pour une branche de portions. */ +static void g_binary_portion_set_level(GBinPortion *, unsigned int); + /* Détermine l'aire d'une sous-portion. */ static bool g_binary_portion_compute_sub_area(GBinPortion *, GBinPortion *, const GdkRectangle *, GdkRectangle *); @@ -139,6 +143,7 @@ static void g_binary_portion_class_init(GBinPortionClass *klass) static void g_binary_portion_init(GBinPortion *portion) { + portion->level = 0; } @@ -221,6 +226,37 @@ GBinPortion *g_binary_portion_new(const char *code) /****************************************************************************** * * +* Paramètres : a = premières informations à consulter. * +* b = secondes informations à consulter. * +* * +* Description : Etablit la comparaison ascendante entre deux portions. * +* * +* Retour : Bilan : -1 (a < b), 0 (a == b) ou 1 (a > b). * +* * +* Remarques : - * +* * +******************************************************************************/ + +int g_binary_portion_compare(const GBinPortion **a, const GBinPortion **b) +{ + int result; /* Bilan à retourner */ + + if ((*a)->level < (*b)->level) + result = -1; + + else if ((*a)->level > (*b)->level) + result = 1; + + else + result = cmp_mrange(&(*a)->range, &(*b)->range); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : portion = description de partie à mettre à jour. * * desc = nom à donner à la partie. * * * @@ -362,6 +398,52 @@ void g_binary_portion_include(GBinPortion *portion, GBinPortion *sub) portion->sub_portions[portion->sub_count - 1] = sub; + g_binary_portion_set_level(sub, portion->level + 1); + +} + + +/****************************************************************************** +* * +* Paramètres : portion = description de partie à mettre à jour. * +* level = niveau de profondeur à associer. * +* * +* Description : Définit le niveau de profondeur pour une branche de portions.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_binary_portion_set_level(GBinPortion *portion, unsigned int level) +{ + size_t i; /* Boucle de parcours */ + + portion->level = level; + + for (i = 0; i < portion->sub_count; i++) + g_binary_portion_set_level(portion->sub_portions[i], level + 1); + +} + + +/****************************************************************************** +* * +* Paramètres : portion = description de partie à mettre à jour. * +* * +* Description : Indique le niveau de profondeur d'une portion donnée. * +* * +* Retour : Niveau de profondeur positif ou nul. * +* * +* Remarques : - * +* * +******************************************************************************/ + +unsigned int g_binary_portion_get_level(GBinPortion *portion) +{ + return portion->level; + } @@ -603,6 +685,81 @@ bool g_binary_portion_get_pos_from_addr(GBinPortion *portion, const vmpa2t *addr /****************************************************************************** * * +* Paramètres : portion = description de partie à consulter. * +* buffer = espace où placer ledit contenu. * +* msize = taille idéale des positions et adresses; * +* * +* Description : Insère dans un tampon une description de portion. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_binary_portion_print(const GBinPortion *portion, GCodeBuffer *buffer, MemoryDataSize msize) +{ + GBufferLine *line; /* Nouvelle ligne à éditer */ + char rights[64]; /* Traduction en texte */ + + /* On ne traite pas les portions anonymes ! */ + if (portion->desc == NULL) return; + + line = g_code_buffer_append_new_line(buffer, &portion->range); + g_buffer_line_fill_mrange(line, msize, msize); + + /* Séparation */ + + line = g_code_buffer_append_new_line(buffer, &portion->range); + g_buffer_line_fill_mrange(line, msize, msize); + + g_buffer_line_start_merge_at(line, BLC_ASSEMBLY_HEAD); + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, + "; ======================================================", 56, RTT_COMMENT); + + /* Retour à la ligne */ + + line = g_code_buffer_append_new_line(buffer, &portion->range); + g_buffer_line_fill_mrange(line, msize, msize); + + g_buffer_line_start_merge_at(line, BLC_ASSEMBLY_HEAD); + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "; ", 2, RTT_COMMENT); + + /* Description */ + + line = g_code_buffer_append_new_line(buffer, &portion->range); + g_buffer_line_fill_mrange(line, msize, msize); + + g_buffer_line_start_merge_at(line, BLC_ASSEMBLY_HEAD); + + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "; ", 2, RTT_COMMENT); + + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, portion->desc, strlen(portion->desc), RTT_COMMENT); + + snprintf(rights, sizeof(rights), " (%s%s%s%s)", + _("rights: "), + portion->rights & PAC_READ ? "r" : "-", + portion->rights & PAC_WRITE ? "w" : "-", + portion->rights & PAC_EXEC ? "x" : "-"); + + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, rights, strlen(rights), RTT_COMMENT); + + /* Retour à la ligne */ + + line = g_code_buffer_append_new_line(buffer, &portion->range); + g_buffer_line_fill_mrange(line, msize, msize); + + g_buffer_line_start_merge_at(line, BLC_ASSEMBLY_HEAD); + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "; ", 2, RTT_COMMENT); + + line = g_code_buffer_append_new_line(buffer, &portion->range); + g_buffer_line_fill_mrange(line, msize, msize); + +} + + +/****************************************************************************** +* * * Paramètres : portion = description de partie à mettre à jour. * * x = abscisse du point de recherche. * * y = ordonnée du point de recherche. * |