fll_program_print_help_option(data.context, byte_dump_short_text, byte_dump_long_text, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include a column of text when displaying the bytes.");
fll_program_print_help_option(data.context, byte_dump_short_placeholder, byte_dump_long_placeholder, f_console_symbol_short_enable, f_console_symbol_long_enable, "Use a placeholder character instead of a space for placeholders.");
+ printf("%c", f_string_eol);
+
+ fll_program_print_help_option_long(data.context, byte_dump_long_normal, f_console_symbol_long_enable, "Display UTF-8 symbols for ASCII control codes.");
+ fll_program_print_help_option_long(data.context, byte_dump_long_simple, f_console_symbol_long_enable, "Display spaces for ASCII control codes.");
+ fll_program_print_help_option_long(data.context, byte_dump_long_classic, f_console_symbol_long_enable, "Display periods for ASCII control codes.");
+
fll_program_print_help_usage(data.context, byte_dump_name, "filename(s)");
printf(" When using the ");
f_return_status byte_dump_main(const f_console_arguments arguments, byte_dump_data *data) {
f_status status = f_none;
+ // Identify priority of color parameters.
{
f_console_parameters parameters = { data->parameters, byte_dump_total_parameters };
f_console_parameter_ids choices = f_console_parameter_ids_initialize;
}
}
+ // Identify priority of mode parameters.
{
f_console_parameter_id ids[4] = { byte_dump_parameter_hexidecimal, byte_dump_parameter_octal, byte_dump_parameter_binary, byte_dump_parameter_decimal };
f_console_parameter_id choice = byte_dump_parameter_hexidecimal;
data->mode = byte_dump_mode_decimal;
}
}
+
+ // Identify priority of presentation parameters.
+ {
+ f_console_parameter_id ids[3] = { byte_dump_parameter_normal, byte_dump_parameter_simple, byte_dump_parameter_classic };
+ f_console_parameter_id choice = byte_dump_parameter_normal;
+ choices.id = ids;
+ choices.used = 3;
+
+ status = fl_console_parameter_prioritize(parameters, choices, &choice);
+
+ if (f_status_is_error(status)) {
+ byte_dump_delete_data(data);
+ return f_status_set_error(status);
+ }
+
+ if (choice == byte_dump_parameter_normal) {
+ data->presentation = byte_dump_presentation_normal;
+ }
+ else if (choice == byte_dump_parameter_simple) {
+ data->presentation = byte_dump_presentation_simple;
+ }
+ else if (choice == byte_dump_parameter_classic) {
+ data->presentation = byte_dump_presentation_classic;
+ }
+ }
}
status = f_none;
byte_dump_mode_decimal,
};
+ enum {
+ byte_dump_presentation_normal,
+ byte_dump_presentation_simple,
+ byte_dump_presentation_classic,
+ };
+
#define byte_dump_sequence_acknowledge "␆"
#define byte_dump_sequence_backspace "␈"
#define byte_dump_sequence_bell "␇"
#define byte_dump_long_text "text" // display text
#define byte_dump_long_placeholder "placeholder" // display (colored) placeholders to signify codes that are UTF-8 fragments.
+ #define byte_dump_long_normal "normal" // use normal presentation, displaying UTF-8 sequence codes for ASCII special codes.
+ #define byte_dump_long_simple "simple" // use simple presentation, displaying spaces for ASCII special codes instead of UTF-8 sequence codes.
+ #define byte_dump_long_classic "classic" // use classic presentation, displaying periods for ASCII special codes instead of UTF-8 sequence codes.
+
enum {
byte_dump_parameter_help,
byte_dump_parameter_light,
byte_dump_parameter_text,
byte_dump_parameter_placeholder,
+
+ byte_dump_parameter_normal,
+ byte_dump_parameter_simple,
+ byte_dump_parameter_classic,
};
#define byte_dump_console_parameter_initialize \
f_console_parameter_initialize(byte_dump_short_width, byte_dump_long_width, 0, 1, f_console_type_normal), \
f_console_parameter_initialize(byte_dump_short_text, byte_dump_long_text, 0, 0, f_console_type_normal), \
f_console_parameter_initialize(byte_dump_short_placeholder, byte_dump_long_placeholder, 0, 0, f_console_type_normal), \
+ f_console_parameter_initialize(0, byte_dump_long_normal, 0, 0, f_console_type_normal), \
+ f_console_parameter_initialize(0, byte_dump_long_simple, 0, 0, f_console_type_normal), \
+ f_console_parameter_initialize(0, byte_dump_long_classic, 0, 0, f_console_type_normal), \
}
- #define byte_dump_total_parameters 14
+ #define byte_dump_total_parameters 17
#endif // _di_byte_dump_defines_
#ifndef _di_byte_dump_data_
uint64_t last;
uint8_t width;
uint8_t mode;
+ uint8_t presentation;
fl_color_context context;
} byte_dump_data;
0, \
8, \
byte_dump_mode_hexidecimal, \
+ byte_dump_presentation_normal, \
fl_color_context_initialize, \
}
#endif // _di_byte_dump_data_
uint8_t j = 0;
uint8_t output = 0;
uint8_t width_utf = 0;
+ f_bool printed = f_false;
fl_color_print(f_standard_output, data.context.notable, data.context.reset, " %s ", byte_dump_character_wall);
if (invalid[i]) {
fl_color_print(f_standard_output, data.context.error, data.context.reset, "%s", byte_dump_character_incomplete);
}
- else if (output == 0) {
- printf("%s", byte_dump_sequence_null);
- }
- else if (output == 1) {
- printf("%s", byte_dump_sequence_start_of_header);
- }
- else if (output == 2) {
- printf("%s", byte_dump_sequence_start_of_text);
- }
- else if (output == 3) {
- printf("%s", byte_dump_sequence_end_of_text);
- }
- else if (output == 4) {
- printf("%s", byte_dump_sequence_end_of_transmission);
- }
- else if (output == 5) {
- printf("%s", byte_dump_sequence_end_of_enquiry);
- }
- else if (output == 6) {
- printf("%s", byte_dump_sequence_acknowledge);
- }
- else if (output == 7) {
- printf("%s", byte_dump_sequence_bell);
- }
- else if (output == 8) {
- printf("%s", byte_dump_sequence_backspace);
- }
- else if (output == 9) {
- printf("%s", byte_dump_sequence_tab);
- }
- else if (output == 10) {
- printf("%s", byte_dump_sequence_new_line);
- }
- else if (output == 11) {
- printf("%s", byte_dump_sequence_tab_vertical);
- }
- else if (output == 12) {
- printf("%s", byte_dump_sequence_form_feed);
- }
- else if (output == 13) {
- printf("%s", byte_dump_sequence_carriage_return);
- }
- else if (output == 14) {
- printf("%s", byte_dump_sequence_shift_out);
- }
- else if (output == 15) {
- printf("%s", byte_dump_sequence_shift_in);
- }
- else if (output == 16) {
- printf("%s", byte_dump_sequence_data_link_escape);
- }
- else if (output == 17) {
- printf("%s", byte_dump_sequence_device_control_1);
- }
- else if (output == 18) {
- printf("%s", byte_dump_sequence_device_control_2);
- }
- else if (output == 19) {
- printf("%s", byte_dump_sequence_device_control_3);
- }
- else if (output == 20) {
- printf("%s", byte_dump_sequence_device_control_4);
- }
- else if (output == 21) {
- printf("%s", byte_dump_sequence_negative_acknowledge);
- }
- else if (output == 22) {
- printf("%s", byte_dump_sequence_synchronous_idle);
- }
- else if (output == 23) {
- printf("%s", byte_dump_sequence_end_of_transmission_block);
- }
- else if (output == 24) {
- printf("%s", byte_dump_sequence_cancel);
- }
- else if (output == 25) {
- printf("%s", byte_dump_sequence_end_of_medium);
- }
- else if (output == 26) {
- printf("%s", byte_dump_sequence_substitute);
- }
- else if (output == 27) {
- printf("%s", byte_dump_sequence_escape);
- }
- else if (output == 28) {
- printf("%s", byte_dump_sequence_file_separator);
- }
- else if (output == 29) {
- printf("%s", byte_dump_sequence_group_separator);
- }
- else if (output == 30) {
- printf("%s", byte_dump_sequence_record_separator);
- }
- else if (output == 31) {
- printf("%s", byte_dump_sequence_unit_separator);
- }
- else if (output == 32) {
- printf("%s", byte_dump_sequence_space);
- }
- else if (output == 127) {
- printf("%s", byte_dump_sequence_delete);
+ else if (output >= 0 && output <= 32 || output == 127) {
+ if (data.presentation == byte_dump_presentation_normal) {
+ if (output == 0) {
+ printf("%s", byte_dump_sequence_null);
+ }
+ else if (output == 1) {
+ printf("%s", byte_dump_sequence_start_of_header);
+ }
+ else if (output == 2) {
+ printf("%s", byte_dump_sequence_start_of_text);
+ }
+ else if (output == 3) {
+ printf("%s", byte_dump_sequence_end_of_text);
+ }
+ else if (output == 4) {
+ printf("%s", byte_dump_sequence_end_of_transmission);
+ }
+ else if (output == 5) {
+ printf("%s", byte_dump_sequence_end_of_enquiry);
+ }
+ else if (output == 6) {
+ printf("%s", byte_dump_sequence_acknowledge);
+ }
+ else if (output == 7) {
+ printf("%s", byte_dump_sequence_bell);
+ }
+ else if (output == 8) {
+ printf("%s", byte_dump_sequence_backspace);
+ }
+ else if (output == 9) {
+ printf("%s", byte_dump_sequence_tab);
+ }
+ else if (output == 10) {
+ printf("%s", byte_dump_sequence_new_line);
+ }
+ else if (output == 11) {
+ printf("%s", byte_dump_sequence_tab_vertical);
+ }
+ else if (output == 12) {
+ printf("%s", byte_dump_sequence_form_feed);
+ }
+ else if (output == 13) {
+ printf("%s", byte_dump_sequence_carriage_return);
+ }
+ else if (output == 14) {
+ printf("%s", byte_dump_sequence_shift_out);
+ }
+ else if (output == 15) {
+ printf("%s", byte_dump_sequence_shift_in);
+ }
+ else if (output == 16) {
+ printf("%s", byte_dump_sequence_data_link_escape);
+ }
+ else if (output == 17) {
+ printf("%s", byte_dump_sequence_device_control_1);
+ }
+ else if (output == 18) {
+ printf("%s", byte_dump_sequence_device_control_2);
+ }
+ else if (output == 19) {
+ printf("%s", byte_dump_sequence_device_control_3);
+ }
+ else if (output == 20) {
+ printf("%s", byte_dump_sequence_device_control_4);
+ }
+ else if (output == 21) {
+ printf("%s", byte_dump_sequence_negative_acknowledge);
+ }
+ else if (output == 22) {
+ printf("%s", byte_dump_sequence_synchronous_idle);
+ }
+ else if (output == 23) {
+ printf("%s", byte_dump_sequence_end_of_transmission_block);
+ }
+ else if (output == 24) {
+ printf("%s", byte_dump_sequence_cancel);
+ }
+ else if (output == 25) {
+ printf("%s", byte_dump_sequence_end_of_medium);
+ }
+ else if (output == 26) {
+ printf("%s", byte_dump_sequence_substitute);
+ }
+ else if (output == 27) {
+ printf("%s", byte_dump_sequence_escape);
+ }
+ else if (output == 28) {
+ printf("%s", byte_dump_sequence_file_separator);
+ }
+ else if (output == 29) {
+ printf("%s", byte_dump_sequence_group_separator);
+ }
+ else if (output == 30) {
+ printf("%s", byte_dump_sequence_record_separator);
+ }
+ else if (output == 31) {
+ printf("%s", byte_dump_sequence_unit_separator);
+ }
+ else if (output == 32) {
+ printf("%s", byte_dump_sequence_space);
+ }
+ else if (output == 127) {
+ printf("%s", byte_dump_sequence_delete);
+ }
+ }
+ else if (data.presentation == byte_dump_presentation_simple) {
+ printf(" ");
+ }
+ else if (data.presentation == byte_dump_presentation_classic) {
+ printf(".");
+ }
}
else if (f_utf_is_whitespace_character(characters.string[i]) == f_true) {
printf("%s", byte_dump_sequence_space);