diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-07-14 20:42:46 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-07-14 20:42:46 (GMT) |
commit | 24d47dfce830d44fd435805124f1727f24baf24b (patch) | |
tree | 506eb9868abed5657d64a724eeba009388030650 /src/glibext/generators | |
parent | 1d8637561d127fb7b87f9eeae8109d64608180b2 (diff) |
Added an option to select the case of displayed hex data.
Diffstat (limited to 'src/glibext/generators')
-rw-r--r-- | src/glibext/generators/hex.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/glibext/generators/hex.c b/src/glibext/generators/hex.c index 744ca89..ab473b1 100644 --- a/src/glibext/generators/hex.c +++ b/src/glibext/generators/hex.c @@ -32,6 +32,7 @@ #include "../gbufferline.h" #include "../linegen-int.h" #include "../linesegment.h" +#include "../../core/params.h" @@ -442,6 +443,13 @@ static BufferLineFlags g_hex_generator_get_flags(const GHexGenerator *generator, static void g_hex_generator_print(GHexGenerator *generator, GBufferLine *line, size_t index, size_t repeat) { + GGenConfig *config; /* Configuration à consulter */ + bool upper_case; /* Casse des données en hexa */ +#ifndef NDEBUG + bool status; /* Bilan de la consultation */ +#endif + const char *hexa; /* Chaîne à considérer #0 */ + const char *ff; /* Chaîne à considérer #1 */ vmpa2t pos; /* Position définie à la volée */ phys_t got; /* Quantité affichable */ const bin_t *raw; /* Accès direct et brut */ @@ -449,8 +457,30 @@ static void g_hex_generator_print(GHexGenerator *generator, GBufferLine *line, s bin_t byte; /* Copie pour confort */ char tmp[2]; /* Représentation d'un octet */ - //static const char hexa[] = "0123456789abcdef"; - static const char hexa[] = "0123456789ABCDEF"; + static const char hexa_lower[] = "0123456789abcdef"; + static const char hexa_upper[] = "0123456789ABCDEF"; + static const char ff_lower[] = "ff"; + static const char ff_upper[] = "FF"; + + config = get_main_configuration(); + +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_HEX_UPPER_CASE, &upper_case); + assert(status); +#else + g_generic_config_get_value(config, MPK_HEX_UPPER_CASE, &upper_case); +#endif + + if (upper_case) + { + hexa = hexa_upper; + ff = ff_upper; + } + else + { + hexa = hexa_lower; + ff = ff_lower; + } /* Position physique */ @@ -487,7 +517,7 @@ static void g_hex_generator_print(GHexGenerator *generator, GBufferLine *line, s g_buffer_line_append_text(line, BLC_BINARY, "00", 2, RTT_RAW_NULL, NULL); else if (byte == 0xff) - g_buffer_line_append_text(line, BLC_BINARY, "ff", 2, RTT_RAW_FULL, NULL); + g_buffer_line_append_text(line, BLC_BINARY, ff, 2, RTT_RAW_FULL, NULL); else { |