From: Kevin Day Date: Sat, 3 Oct 2020 21:43:32 +0000 (-0500) Subject: Feature: add -c/--content parameter to FSS read programs. X-Git-Tag: 0.5.1~45 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=5c546f1b32b349b4fb1a947be2c37e30166503df;p=fll Feature: add -c/--content parameter to FSS read programs. The default behavior is already a -c/--content. This provides a literal parameter for good practice and better hackability. This introduces a new possibility where both -o/--object and -c/--content are specified at the same time. In this case, print both the object and the content. It must be noted, however, that this only prints the escaped object and content, just like when -o/--object or -c/--content do already. The objects in the basic read and extended read are printed with a space between them and their respective content. The objects in the basic list read and extended list read are printed with an EOL ('\n') between them and their respective content. --- diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 8eab6b8..af054fd 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -23,11 +23,12 @@ extern "C" { printf("%c", f_string_eol[0]); fll_program_print_help_option(file, context, fss_basic_list_read_short_at, fss_basic_list_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_content, fss_basic_list_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the content (default)."); fll_program_print_help_option(file, context, fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); fll_program_print_help_option(file, context, fss_basic_list_read_short_empty, fss_basic_list_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); fll_program_print_help_option(file, context, fss_basic_list_read_short_line, fss_basic_list_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); fll_program_print_help_option(file, context, fss_basic_list_read_short_name, fss_basic_list_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); - fll_program_print_help_option(file, context, fss_basic_list_read_short_object, fss_basic_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); + fll_program_print_help_option(file, context, fss_basic_list_read_short_object, fss_basic_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object."); fll_program_print_help_option(file, context, fss_basic_list_read_short_select, fss_basic_list_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); fll_program_print_help_option(file, context, fss_basic_list_read_short_total, fss_basic_list_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); fll_program_print_help_option(file, context, fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); @@ -122,6 +123,16 @@ extern "C" { printf("%c", f_string_eol[0]); + printf(" When specifying both the "); + fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); + printf(" parameter and the "); + fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_content); + printf(" parameter, the entire object and content are printed, including the formatting.%c", f_string_eol[0]); + printf(" Both the object and content printed are already escaped.%c", f_string_eol[0]); + printf(" Both the object and content are separated by an EOL.%c", f_string_eol[0]); + + printf("%c", f_string_eol[0]); + return F_none; } #endif // _di_fss_basic_list_read_print_help_ @@ -260,6 +271,21 @@ extern "C" { fss_basic_list_read_delete_data(data); return F_status_set_error(F_parameter); } + + if (data->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) { + if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify both the '", fll_error_print_error); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); + fl_color_print(data->error.to.stream, data->context.set.error, "' and the '"); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_content); + fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total); + fl_color_print(data->error.to.stream, data->context.set.error, "' parameter.%c", f_string_eol[0]); + + fss_basic_list_read_delete_data(data); + return F_status_set_error(F_parameter); + } + } } if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.h b/level_3/fss_basic_list_read/c/fss_basic_list_read.h index 34cd893..192db76 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.h @@ -62,25 +62,27 @@ extern "C" { #endif // _di_fss_basic_list_read_name_ #ifndef _di_fss_basic_list_read_defines_ - #define fss_basic_list_read_short_at "a" - #define fss_basic_list_read_short_depth "d" - #define fss_basic_list_read_short_empty "e" - #define fss_basic_list_read_short_line "l" - #define fss_basic_list_read_short_name "n" - #define fss_basic_list_read_short_object "o" - #define fss_basic_list_read_short_select "s" - #define fss_basic_list_read_short_total "t" - #define fss_basic_list_read_short_trim "T" - - #define fss_basic_list_read_long_at "at" - #define fss_basic_list_read_long_depth "depth" - #define fss_basic_list_read_long_empty "empty" - #define fss_basic_list_read_long_line "line" - #define fss_basic_list_read_long_name "name" - #define fss_basic_list_read_long_object "object" - #define fss_basic_list_read_long_select "select" - #define fss_basic_list_read_long_total "total" - #define fss_basic_list_read_long_trim "trim" + #define fss_basic_list_read_short_at "a" + #define fss_basic_list_read_short_content "c" + #define fss_basic_list_read_short_depth "d" + #define fss_basic_list_read_short_empty "e" + #define fss_basic_list_read_short_line "l" + #define fss_basic_list_read_short_name "n" + #define fss_basic_list_read_short_object "o" + #define fss_basic_list_read_short_select "s" + #define fss_basic_list_read_short_total "t" + #define fss_basic_list_read_short_trim "T" + + #define fss_basic_list_read_long_at "at" + #define fss_basic_list_read_long_content "content" + #define fss_basic_list_read_long_depth "depth" + #define fss_basic_list_read_long_empty "empty" + #define fss_basic_list_read_long_line "line" + #define fss_basic_list_read_long_name "name" + #define fss_basic_list_read_long_object "object" + #define fss_basic_list_read_long_select "select" + #define fss_basic_list_read_long_total "total" + #define fss_basic_list_read_long_trim "trim" enum { fss_basic_list_read_parameter_help, @@ -94,6 +96,7 @@ extern "C" { fss_basic_list_read_parameter_version, fss_basic_list_read_parameter_at, + fss_basic_list_read_parameter_content, fss_basic_list_read_parameter_depth, fss_basic_list_read_parameter_empty, fss_basic_list_read_parameter_line, @@ -116,6 +119,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_basic_list_read_short_at, fss_basic_list_read_long_at, 0, 1, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_content, fss_basic_list_read_long_content, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_empty, fss_basic_list_read_long_empty, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_line, fss_basic_list_read_long_line, 0, 1, f_console_type_normal), \ @@ -126,7 +130,7 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_basic_list_read_total_parameters 18 + #define fss_basic_list_read_total_parameters 19 #endif // _di_fss_basic_list_read_defines_ #ifndef _di_fss_basic_list_read_data_t_ diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index fcc333d..2d0d1a2 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -231,10 +231,10 @@ extern "C" { } } - f_string_length_t select = 0; + f_number_unsigned_t select = 0; if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_additional) { - const f_string_length_t index = data->parameters[fss_basic_list_read_parameter_select].additional.array[data->parameters[fss_basic_list_read_parameter_select].additional.used - 1]; + const f_array_length_t index = data->parameters[fss_basic_list_read_parameter_select].additional.array[data->parameters[fss_basic_list_read_parameter_select].additional.used - 1]; const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range); @@ -250,10 +250,10 @@ extern "C" { } } - f_string_length_t line = 0; + f_array_length_t line = 0; if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { - const f_string_length_t index = data->parameters[fss_basic_list_read_parameter_line].additional.array[data->parameters[fss_basic_list_read_parameter_line].additional.used - 1]; + const f_array_length_t index = data->parameters[fss_basic_list_read_parameter_line].additional.array[data->parameters[fss_basic_list_read_parameter_line].additional.used - 1]; const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range); @@ -266,13 +266,16 @@ extern "C" { bool names[data->objects.used]; + f_array_length_t i = 0; + f_array_length_t j = 0; + if (depths.array[0].index_name > 0) { memset(names, 0, sizeof(bool) * data->objects.used); f_string_length_t name_length = 0; if (data->parameters[fss_basic_list_read_parameter_trim].result == f_console_result_found) { - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; @@ -284,7 +287,7 @@ extern "C" { } // for } else { - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; if (name_length == depths.array[0].value_name.used) { @@ -316,9 +319,9 @@ extern "C" { } } else if (depths.array[0].index_name > 0) { - f_string_length_t total = 0; + f_array_length_t total = 0; - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) continue; total++; @@ -348,7 +351,18 @@ extern "C" { if (names[i]) { if (at == depths.array[0].value_at) { print_object(f_type_output, data->buffer, data->objects.array[i]); - fprintf(f_type_output, "%c", f_string_eol[0]); + + if (data->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) { + if (data->contents.array[i].used) { + fprintf(f_type_output, "%c", f_fss_eol); + f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); + } + else { + fprintf(f_type_output, "%c", f_fss_eol); + } + } + + fprintf(f_type_output, "%c", f_fss_eol); break; } @@ -359,11 +373,22 @@ extern "C" { return F_none; } - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) continue; print_object(f_type_output, data->buffer, data->objects.array[i]); - fprintf(f_type_output, "%c", f_string_eol[0]); + + if (data->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) { + if (data->contents.array[i].used) { + fprintf(f_type_output, "%c", f_fss_eol); + f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); + } + else { + fprintf(f_type_output, "%c", f_fss_eol); + } + } + + fprintf(f_type_output, "%c", f_fss_eol); } // for return F_none; @@ -379,7 +404,6 @@ extern "C" { } f_array_length_t at = 0; - f_array_length_t i = 0; for (; i < data->objects.used; i++) { @@ -390,9 +414,9 @@ extern "C" { fprintf(f_type_output, "0%c", f_string_eol[0]); } else { - f_string_length_t total = 1; + f_array_length_t total = 1; - for (f_string_length_t j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) { + for (j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) { if (!data->buffer.string[j]) continue; if (data->buffer.string[j] == f_string_eol[0]) { @@ -413,7 +437,7 @@ extern "C" { } } else { - f_string_length_t i = data->contents.array[i].array[0].start; + i = data->contents.array[i].array[0].start; if (!line) { for (; i <= data->contents.array[i].array[0].stop; i++) { @@ -427,7 +451,7 @@ extern "C" { } // for } else { - f_string_length_t line_current = 0; + f_array_length_t line_current = 0; for (; i <= data->contents.array[i].array[0].stop; i++) { if (!data->buffer.string[i]) continue; @@ -477,9 +501,9 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { - f_string_length_t total = 0; + f_array_length_t total = 0; - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) continue; if (!data->contents.array[i].used) { @@ -490,7 +514,7 @@ extern "C" { continue; } - for (f_string_length_t j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) { + for (j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) { if (!data->buffer.string[j]) continue; if (data->buffer.string[j] == f_string_eol[0]) { @@ -504,11 +528,7 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { - f_string_length_t line_current = 0; - f_string_length_t i = 0; - f_string_length_t j = 0; - - for (; i < data->contents.used; i++) { + for (f_array_length_t line_current = 0; i < data->contents.used; i++) { if (!names[i]) continue; if (!data->contents.array[i].used) { @@ -561,7 +581,7 @@ extern "C" { return F_none; } - for (f_string_length_t i = 0; i < data->contents.used; i++) { + for (i = 0; i < data->contents.used; i++) { if (!names[i]) continue; if (!data->contents.array[i].used) { diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index ba092b1..e77bad4 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -23,11 +23,12 @@ extern "C" { printf("%c", f_string_eol[0]); fll_program_print_help_option(file, context, fss_basic_read_short_at, fss_basic_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); + fll_program_print_help_option(file, context, fss_basic_read_short_content, fss_basic_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the content (default)."); fll_program_print_help_option(file, context, fss_basic_read_short_depth, fss_basic_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); fll_program_print_help_option(file, context, fss_basic_read_short_empty, fss_basic_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); fll_program_print_help_option(file, context, fss_basic_read_short_line, fss_basic_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); fll_program_print_help_option(file, context, fss_basic_read_short_name, fss_basic_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); - fll_program_print_help_option(file, context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); + fll_program_print_help_option(file, context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object."); fll_program_print_help_option(file, context, fss_basic_read_short_select, fss_basic_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); fll_program_print_help_option(file, context, fss_basic_read_short_total, fss_basic_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); fll_program_print_help_option(file, context, fss_basic_read_short_trim, fss_basic_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); @@ -122,6 +123,16 @@ extern "C" { printf("%c", f_string_eol[0]); + printf(" When specifying both the "); + fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); + printf(" parameter and the "); + fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_content); + printf(" parameter, the entire object and content are printed, including the formatting.%c", f_string_eol[0]); + printf(" Both the object and content printed are already escaped.%c", f_string_eol[0]); + printf(" Both the object and content are separated by a space.%c", f_string_eol[0]); + + printf("%c", f_string_eol[0]); + return F_none; } #endif // _di_fss_basic_read_print_help_ @@ -260,6 +271,21 @@ extern "C" { fss_basic_read_delete_data(data); return F_status_set_error(F_parameter); } + + if (data->parameters[fss_basic_read_parameter_content].result == f_console_result_found) { + if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify both the '", fll_error_print_error); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); + fl_color_print(data->error.to.stream, data->context.set.error, "' and the '"); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_content); + fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total); + fl_color_print(data->error.to.stream, data->context.set.error, "' parameter.%c", f_string_eol[0]); + + fss_basic_read_delete_data(data); + return F_status_set_error(F_parameter); + } + } } if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h index fcd6351..1709fb5 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -62,25 +62,27 @@ extern "C" { #endif // _di_fss_basic_read_name_ #ifndef _di_fss_basic_read_defines_ - #define fss_basic_read_short_at "a" - #define fss_basic_read_short_depth "d" - #define fss_basic_read_short_empty "e" - #define fss_basic_read_short_line "l" - #define fss_basic_read_short_name "n" - #define fss_basic_read_short_object "o" - #define fss_basic_read_short_select "s" - #define fss_basic_read_short_total "t" - #define fss_basic_read_short_trim "T" - - #define fss_basic_read_long_at "at" - #define fss_basic_read_long_depth "depth" - #define fss_basic_read_long_empty "empty" - #define fss_basic_read_long_line "line" - #define fss_basic_read_long_name "name" - #define fss_basic_read_long_object "object" - #define fss_basic_read_long_select "select" - #define fss_basic_read_long_total "total" - #define fss_basic_read_long_trim "trim" + #define fss_basic_read_short_at "a" + #define fss_basic_read_short_content "c" + #define fss_basic_read_short_depth "d" + #define fss_basic_read_short_empty "e" + #define fss_basic_read_short_line "l" + #define fss_basic_read_short_name "n" + #define fss_basic_read_short_object "o" + #define fss_basic_read_short_select "s" + #define fss_basic_read_short_total "t" + #define fss_basic_read_short_trim "T" + + #define fss_basic_read_long_at "at" + #define fss_basic_read_long_content "content" + #define fss_basic_read_long_depth "depth" + #define fss_basic_read_long_empty "empty" + #define fss_basic_read_long_line "line" + #define fss_basic_read_long_name "name" + #define fss_basic_read_long_object "object" + #define fss_basic_read_long_select "select" + #define fss_basic_read_long_total "total" + #define fss_basic_read_long_trim "trim" enum { fss_basic_read_parameter_help, @@ -94,6 +96,7 @@ extern "C" { fss_basic_read_parameter_version, fss_basic_read_parameter_at, + fss_basic_read_parameter_content, fss_basic_read_parameter_depth, fss_basic_read_parameter_empty, fss_basic_read_parameter_line, @@ -116,6 +119,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_basic_read_short_at, fss_basic_read_long_at, 0, 1, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_basic_read_short_content, fss_basic_read_long_content, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_depth, fss_basic_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_empty, fss_basic_read_long_empty, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_line, fss_basic_read_long_line, 0, 1, f_console_type_normal), \ @@ -126,7 +130,7 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_read_short_trim, fss_basic_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_basic_read_total_parameters 18 + #define fss_basic_read_total_parameters 19 #endif // _di_fss_basic_read_defines_ #ifndef _di_fss_basic_read_data_t_ diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index bdcb72f..cb6b9cf 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -231,7 +231,7 @@ extern "C" { } } - f_string_length_t select = 0; + f_number_unsigned_t select = 0; if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_additional) { const f_string_length_t index = data->parameters[fss_basic_read_parameter_select].additional.array[data->parameters[fss_basic_read_parameter_select].additional.used - 1]; @@ -250,10 +250,10 @@ extern "C" { } } - f_string_length_t line = 0; + f_array_length_t line = 0; if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { - const f_string_length_t index = data->parameters[fss_basic_read_parameter_line].additional.array[data->parameters[fss_basic_read_parameter_line].additional.used - 1]; + const f_array_length_t index = data->parameters[fss_basic_read_parameter_line].additional.array[data->parameters[fss_basic_read_parameter_line].additional.used - 1]; const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range); @@ -266,13 +266,15 @@ extern "C" { bool names[data->objects.used]; + f_array_length_t i = 0; + if (depths.array[0].index_name > 0) { memset(names, 0, sizeof(bool) * data->objects.used); f_string_length_t name_length = 0; if (data->parameters[fss_basic_read_parameter_trim].result == f_console_result_found) { - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; @@ -284,7 +286,7 @@ extern "C" { } // for } else { - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; @@ -317,9 +319,9 @@ extern "C" { } } else if (depths.array[0].index_name > 0) { - f_string_length_t total = 0; + f_array_length_t total = 0; - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) continue; total++; @@ -342,14 +344,21 @@ extern "C" { if (depths.array[0].index_at > 0) { f_array_length_t at = 0; - f_array_length_t i = 0; for (; i < data->objects.used; i++) { if (names[i]) { if (at == depths.array[0].value_at) { print_object(f_type_output, data->buffer, data->objects.array[i]); - fprintf(f_type_output, "%c", f_string_eol[0]); + + if (data->parameters[fss_basic_read_parameter_content].result == f_console_result_found) { + if (data->contents.array[i].used) { + fprintf(f_type_output, "%c", f_fss_space); + f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); + } + } + + fprintf(f_type_output, "%c", f_fss_eol); break; } @@ -360,11 +369,19 @@ extern "C" { return F_none; } - for (f_array_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) continue; print_object(f_type_output, data->buffer, data->objects.array[i]); - fprintf(f_type_output, "%c", f_string_eol[0]); + + if (data->parameters[fss_basic_read_parameter_content].result == f_console_result_found) { + if (data->contents.array[i].used) { + fprintf(f_type_output, "%c", f_fss_space); + f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); + } + } + + fprintf(f_type_output, "%c", f_fss_eol); } // for return F_none; @@ -386,7 +403,6 @@ extern "C" { } f_array_length_t at = 0; - f_array_length_t i = 0; for (; i < data->objects.used; i++) { @@ -432,7 +448,7 @@ extern "C" { if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { f_string_length_t total = 0; - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) continue; if (!data->contents.array[i].used && !include_empty) { @@ -447,9 +463,9 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { - f_string_length_t line_current = 0; + f_array_length_t line_current = 0; - for (f_string_length_t i = 0; i < data->contents.used; i++) { + for (i = 0; i < data->contents.used; i++) { if (!names[i]) continue; if (!data->contents.array[i].used) { @@ -478,7 +494,7 @@ extern "C" { return F_none; } - for (f_string_length_t i = 0; i < data->contents.used; i++) { + for (i = 0; i < data->contents.used; i++) { if (!names[i]) continue; if (!data->contents.array[i].used) { diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 9916293..a02cb3a 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -23,11 +23,12 @@ extern "C" { printf("%c", f_string_eol[0]); fll_program_print_help_option(file, context, fss_extended_list_read_short_at, fss_extended_list_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); + fll_program_print_help_option(file, context, fss_extended_list_read_short_content, fss_extended_list_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the content (default)."); fll_program_print_help_option(file, context, fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); fll_program_print_help_option(file, context, fss_extended_list_read_short_empty, fss_extended_list_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); fll_program_print_help_option(file, context, fss_extended_list_read_short_line, fss_extended_list_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); fll_program_print_help_option(file, context, fss_extended_list_read_short_name, fss_extended_list_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); - fll_program_print_help_option(file, context, fss_extended_list_read_short_object, fss_extended_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); + fll_program_print_help_option(file, context, fss_extended_list_read_short_object, fss_extended_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object."); fll_program_print_help_option(file, context, fss_extended_list_read_short_select, fss_extended_list_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); fll_program_print_help_option(file, context, fss_extended_list_read_short_total, fss_extended_list_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); fll_program_print_help_option(file, context, fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); @@ -122,6 +123,16 @@ extern "C" { printf("%c", f_string_eol[0]); + printf(" When specifying both the "); + fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); + printf(" parameter and the "); + fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_content); + printf(" parameter, the entire object and content are printed, including the formatting.%c", f_string_eol[0]); + printf(" Both the object and content printed are already escaped.%c", f_string_eol[0]); + printf(" Both the object and content are separated by an EOL.%c", f_string_eol[0]); + + printf("%c", f_string_eol[0]); + return F_none; } #endif // _di_fss_extended_list_read_print_help_ @@ -260,6 +271,21 @@ extern "C" { fss_extended_list_read_delete_data(data); return F_status_set_error(F_parameter); } + + if (data->parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) { + if (data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) { + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify both the '", fll_error_print_error); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); + fl_color_print(data->error.to.stream, data->context.set.error, "' and the '"); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_content); + fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total); + fl_color_print(data->error.to.stream, data->context.set.error, "' parameter.%c", f_string_eol[0]); + + fss_extended_list_read_delete_data(data); + return F_status_set_error(F_parameter); + } + } } if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.h b/level_3/fss_extended_list_read/c/fss_extended_list_read.h index 291e1a7..516b305 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.h @@ -62,25 +62,27 @@ extern "C" { #endif // _di_fss_extended_list_read_name_ #ifndef _di_fss_extended_list_read_defines_ - #define fss_extended_list_read_short_at "a" - #define fss_extended_list_read_short_depth "d" - #define fss_extended_list_read_short_empty "e" - #define fss_extended_list_read_short_line "l" - #define fss_extended_list_read_short_name "n" - #define fss_extended_list_read_short_object "o" - #define fss_extended_list_read_short_select "s" - #define fss_extended_list_read_short_total "t" - #define fss_extended_list_read_short_trim "T" - - #define fss_extended_list_read_long_at "at" - #define fss_extended_list_read_long_depth "depth" - #define fss_extended_list_read_long_empty "empty" - #define fss_extended_list_read_long_line "line" - #define fss_extended_list_read_long_name "name" - #define fss_extended_list_read_long_object "object" - #define fss_extended_list_read_long_select "select" - #define fss_extended_list_read_long_total "total" - #define fss_extended_list_read_long_trim "trim" + #define fss_extended_list_read_short_at "a" + #define fss_extended_list_read_short_content "c" + #define fss_extended_list_read_short_depth "d" + #define fss_extended_list_read_short_empty "e" + #define fss_extended_list_read_short_line "l" + #define fss_extended_list_read_short_name "n" + #define fss_extended_list_read_short_object "o" + #define fss_extended_list_read_short_select "s" + #define fss_extended_list_read_short_total "t" + #define fss_extended_list_read_short_trim "T" + + #define fss_extended_list_read_long_at "at" + #define fss_extended_list_read_long_content "content" + #define fss_extended_list_read_long_depth "depth" + #define fss_extended_list_read_long_empty "empty" + #define fss_extended_list_read_long_line "line" + #define fss_extended_list_read_long_name "name" + #define fss_extended_list_read_long_object "object" + #define fss_extended_list_read_long_select "select" + #define fss_extended_list_read_long_total "total" + #define fss_extended_list_read_long_trim "trim" enum { fss_extended_list_read_parameter_help, @@ -94,6 +96,7 @@ extern "C" { fss_extended_list_read_parameter_version, fss_extended_list_read_parameter_at, + fss_extended_list_read_parameter_content, fss_extended_list_read_parameter_depth, fss_extended_list_read_parameter_empty, fss_extended_list_read_parameter_line, @@ -116,6 +119,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_extended_list_read_short_at, fss_extended_list_read_long_at, 0, 1, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_extended_list_read_short_content, fss_extended_list_read_long_content, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_empty, fss_extended_list_read_long_empty, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_line, fss_extended_list_read_long_line, 0, 1, f_console_type_normal), \ @@ -126,7 +130,7 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_extended_list_read_total_parameters 18 + #define fss_extended_list_read_total_parameters 19 #endif // _di_fss_extended_list_read_defines_ #ifndef _di_fss_extended_list_read_data_t_ diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index 29455b6..9f29a95 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -241,7 +241,7 @@ extern "C" { } { - f_string_length_t select = 0; + f_number_unsigned_t select = 0; if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_additional) { const f_string_length_t index = data->parameters[fss_extended_list_read_parameter_select].additional.array[data->parameters[fss_extended_list_read_parameter_select].additional.used - 1]; @@ -261,15 +261,13 @@ extern "C" { } } - f_string_length_t line = 0; + f_array_length_t line = 0; if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { - const f_string_length_t index = data->parameters[fss_extended_list_read_parameter_line].additional.array[data->parameters[fss_extended_list_read_parameter_line].additional.used - 1]; + const f_array_length_t index = data->parameters[fss_extended_list_read_parameter_line].additional.array[data->parameters[fss_extended_list_read_parameter_line].additional.used - 1]; const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); - f_number_unsigned_t number = 0; - - status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range); + status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range); if (F_status_is_error(status)) { fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_line, arguments.argv[index]); @@ -288,12 +286,15 @@ extern "C" { #endif // _di_fss_extended_list_read_main_process_file_ #ifndef _di_fss_extended_list_read_main_process_for_depth_ - f_return_status fss_extended_list_read_main_process_for_depth(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depth_t depth_setting, const f_string_length_t line) { + f_return_status fss_extended_list_read_main_process_for_depth(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depth_t depth_setting, const f_array_length_t line) { f_status_t status = F_none; f_fss_items_t *items = &data->nest.depth[depth_setting.depth]; bool names[items->used]; + f_array_length_t i = 0; + f_array_length_t j = 0; + if (depth_setting.index_name > 0) { memset(names, 0, sizeof(bool) * items->used); @@ -301,14 +302,14 @@ extern "C" { value_range.stop = depth_setting.value_name.used - 1; if (data->parameters[fss_extended_list_read_parameter_trim].result == f_console_result_found) { - for (f_string_length_t i = 0; i < items->used; i++) { + for (i = 0; i < items->used; i++) { if (fl_string_dynamic_partial_compare_trim(data->buffer, depth_setting.value_name, items->array[i].object, value_range) == F_equal_to) { names[i] = 1; } } // for } else { - for (f_string_length_t i = 0; i < items->used; i++) { + for (i = 0; i < items->used; i++) { if (fl_string_dynamic_partial_compare(data->buffer, depth_setting.value_name, items->array[i].object, value_range) == F_equal_to) { names[i] = 1; } @@ -339,9 +340,9 @@ extern "C" { return F_none; } else if (depth_setting.index_name > 0) { - f_string_length_t total = 0; + f_array_length_t total = 0; - for (f_string_length_t i = 0; i < items->used; i++) { + for (i = 0; i < items->used; i++) { if (!names[i]) continue; total++; @@ -366,17 +367,39 @@ extern "C" { if (depth_setting.index_at > 0) { if (depth_setting.value_at < items->used && names[depth_setting.value_at]) { print_object(f_type_output, data->buffer, items->array[depth_setting.value_at].object); - fprintf(f_type_output, "%c", f_string_eol[0]); + + if (data->parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) { + if (items->array[depth_setting.value_at].content.used) { + fprintf(f_type_output, "%c", f_fss_eol); + f_print_dynamic_partial(f_type_output, data->buffer, items->array[depth_setting.value_at].content.array[0]); + } + else { + fprintf(f_type_output, "%c", f_fss_eol); + } + } + + fprintf(f_type_output, "%c", f_fss_eol); } return F_none; } - for (f_array_length_t i = 0; i < items->used; i++) { + for (i = 0; i < items->used; i++) { if (names[i]) { print_object(f_type_output, data->buffer, items->array[i].object); - fprintf(f_type_output, "%c", f_string_eol[0]); + + if (data->parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) { + if (items->array[i].content.used) { + fprintf(f_type_output, "%c", f_fss_eol); + f_print_dynamic_partial(f_type_output, data->buffer, items->array[i].content.array[0]); + } + else { + fprintf(f_type_output, "%c", f_fss_eol); + } + } + + fprintf(f_type_output, "%c", f_fss_eol); } } // for @@ -393,7 +416,6 @@ extern "C" { } f_array_length_t at = 0; - f_array_length_t i = 0; for (; i < items->used; i++) { @@ -404,9 +426,9 @@ extern "C" { fprintf(f_type_output, "0%c", f_string_eol[0]); } else { - f_string_length_t total = 1; + f_array_length_t total = 1; - for (f_string_length_t j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; j++) { + for (j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; j++) { if (!data->buffer.string[j]) continue; if (data->buffer.string[j] == f_string_eol[0]) { @@ -427,7 +449,7 @@ extern "C" { } } else { - f_string_length_t i = items->array[i].content.array[0].start; + i = items->array[i].content.array[0].start; if (!line) { for (; i <= items->array[i].content.array[0].stop; i++) { @@ -442,7 +464,7 @@ extern "C" { } // for } else { - f_string_length_t line_current = 0; + f_array_length_t line_current = 0; for (; i <= items->array[i].content.array[0].stop; i++) { if (!data->buffer.string[i]) continue; @@ -492,9 +514,9 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) { - f_string_length_t total = 0; + f_array_length_t total = 0; - for (f_string_length_t i = 0; i < items->used; i++) { + for (i = 0; i < items->used; i++) { if (!names[i]) continue; if (!items->array[i].content.used) { @@ -505,7 +527,7 @@ extern "C" { continue; } - for (f_string_length_t j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; j++) { + for (j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; j++) { if (!data->buffer.string[j]) continue; if (data->buffer.string[j] == f_string_eol[0]) { @@ -519,9 +541,7 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { - f_string_length_t line_current = 0; - f_string_length_t i = 0; - f_string_length_t j = 0; + f_array_length_t line_current = 0; for (; i < items->used; i++) { if (!names[i]) continue; @@ -575,7 +595,7 @@ extern "C" { return F_none; } - for (f_string_length_t i = 0; i < items->used; i++) { + for (i = 0; i < items->used; i++) { if (!names[i]) continue; if (!items->array[i].content.used) { diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h index 5d1c8cd..f592c68 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.h @@ -216,7 +216,7 @@ extern "C" { * @see fss_extended_list_read_main_process_file() */ #ifndef _di_fss_extended_list_read_main_process_for_depth_ - extern f_return_status fss_extended_list_read_main_process_for_depth(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depth_t depth_setting, const f_string_length_t line) f_gcc_attribute_visibility_internal; + extern f_return_status fss_extended_list_read_main_process_for_depth(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depth_t depth_setting, const f_array_length_t line) f_gcc_attribute_visibility_internal; #endif // _di_fss_extended_list_read_main_process_for_depth_ #ifdef __cplusplus diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 8354d77..4fa0f42 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -23,11 +23,12 @@ extern "C" { printf("%c", f_string_eol[0]); fll_program_print_help_option(file, context, fss_extended_read_short_at, fss_extended_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); + fll_program_print_help_option(file, context, fss_extended_read_short_content, fss_extended_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the content (default)."); fll_program_print_help_option(file, context, fss_extended_read_short_depth, fss_extended_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); fll_program_print_help_option(file, context, fss_extended_read_short_empty, fss_extended_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); fll_program_print_help_option(file, context, fss_extended_read_short_line, fss_extended_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); fll_program_print_help_option(file, context, fss_extended_read_short_name, fss_extended_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); - fll_program_print_help_option(file, context, fss_extended_read_short_object, fss_extended_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); + fll_program_print_help_option(file, context, fss_extended_read_short_object, fss_extended_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object."); fll_program_print_help_option(file, context, fss_extended_read_short_select, fss_extended_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index."); fll_program_print_help_option(file, context, fss_extended_read_short_total, fss_extended_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines."); fll_program_print_help_option(file, context, fss_extended_read_short_trim, fss_extended_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, " Trim object names on select or print."); @@ -122,6 +123,16 @@ extern "C" { printf("%c", f_string_eol[0]); + printf(" When specifying both the "); + fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); + printf(" parameter and the "); + fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_content); + printf(" parameter, the entire object and content are printed, including the formatting.%c", f_string_eol[0]); + printf(" Both the object and content printed are already escaped.%c", f_string_eol[0]); + printf(" Both the object and content are separated by a space.%c", f_string_eol[0]); + + printf("%c", f_string_eol[0]); + return F_none; } #endif // _di_fss_extended_read_print_help_ @@ -260,6 +271,21 @@ extern "C" { fss_extended_read_delete_data(data); return F_status_set_error(F_parameter); } + + if (data->parameters[fss_extended_read_parameter_content].result == f_console_result_found) { + if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { + fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify both the '", fll_error_print_error); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); + fl_color_print(data->error.to.stream, data->context.set.error, "' and the '"); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_content); + fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '"); + fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total); + fl_color_print(data->error.to.stream, data->context.set.error, "' parameter.%c", f_string_eol[0]); + + fss_extended_read_delete_data(data); + return F_status_set_error(F_parameter); + } + } } if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { diff --git a/level_3/fss_extended_read/c/fss_extended_read.h b/level_3/fss_extended_read/c/fss_extended_read.h index 53ce420..e3e7b83 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ b/level_3/fss_extended_read/c/fss_extended_read.h @@ -62,25 +62,27 @@ extern "C" { #endif // _di_fss_extended_read_name_ #ifndef _di_fss_extended_read_defines_ - #define fss_extended_read_short_at "a" - #define fss_extended_read_short_depth "d" - #define fss_extended_read_short_empty "e" - #define fss_extended_read_short_line "l" - #define fss_extended_read_short_name "n" - #define fss_extended_read_short_object "o" - #define fss_extended_read_short_select "s" - #define fss_extended_read_short_total "t" - #define fss_extended_read_short_trim "T" - - #define fss_extended_read_long_at "at" - #define fss_extended_read_long_depth "depth" - #define fss_extended_read_long_empty "empty" - #define fss_extended_read_long_line "line" - #define fss_extended_read_long_name "name" - #define fss_extended_read_long_object "object" - #define fss_extended_read_long_select "select" - #define fss_extended_read_long_total "total" - #define fss_extended_read_long_trim "trim" + #define fss_extended_read_short_at "a" + #define fss_extended_read_short_content "c" + #define fss_extended_read_short_depth "d" + #define fss_extended_read_short_empty "e" + #define fss_extended_read_short_line "l" + #define fss_extended_read_short_name "n" + #define fss_extended_read_short_object "o" + #define fss_extended_read_short_select "s" + #define fss_extended_read_short_total "t" + #define fss_extended_read_short_trim "T" + + #define fss_extended_read_long_at "at" + #define fss_extended_read_long_content "content" + #define fss_extended_read_long_depth "depth" + #define fss_extended_read_long_empty "empty" + #define fss_extended_read_long_line "line" + #define fss_extended_read_long_name "name" + #define fss_extended_read_long_object "object" + #define fss_extended_read_long_select "select" + #define fss_extended_read_long_total "total" + #define fss_extended_read_long_trim "trim" enum { fss_extended_read_parameter_help, @@ -94,6 +96,7 @@ extern "C" { fss_extended_read_parameter_version, fss_extended_read_parameter_at, + fss_extended_read_parameter_content, fss_extended_read_parameter_depth, fss_extended_read_parameter_empty, fss_extended_read_parameter_line, @@ -116,6 +119,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_extended_read_short_at, fss_extended_read_long_at, 0, 1, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_extended_read_short_content, fss_extended_read_long_content, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_depth, fss_extended_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_empty, fss_extended_read_long_empty, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_line, fss_extended_read_long_line, 0, 1, f_console_type_normal), \ @@ -126,7 +130,7 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_read_short_trim, fss_extended_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_extended_read_total_parameters 18 + #define fss_extended_read_total_parameters 19 #endif // _di_fss_extended_read_defines_ #ifndef _di_fss_extended_read_data_t_ diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index 294ec9a..de8cda2 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -231,10 +231,10 @@ extern "C" { } } - f_string_length_t select = 0; + f_number_unsigned_t select = 0; if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { - const f_string_length_t index = data->parameters[fss_extended_read_parameter_select].additional.array[data->parameters[fss_extended_read_parameter_select].additional.used - 1]; + const f_array_length_t index = data->parameters[fss_extended_read_parameter_select].additional.array[data->parameters[fss_extended_read_parameter_select].additional.used - 1]; const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range); @@ -245,10 +245,10 @@ extern "C" { } } - f_string_length_t line = 0; + f_array_length_t line = 0; if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { - const f_string_length_t index = data->parameters[fss_extended_read_parameter_line].additional.array[data->parameters[fss_extended_read_parameter_line].additional.used - 1]; + const f_array_length_t index = data->parameters[fss_extended_read_parameter_line].additional.array[data->parameters[fss_extended_read_parameter_line].additional.used - 1]; const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index])); status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range); @@ -261,13 +261,16 @@ extern "C" { bool names[data->objects.used]; + f_array_length_t i = 0; + f_array_length_t j = 0; + if (depths.array[0].index_name > 0) { memset(names, 0, sizeof(bool) * data->objects.used); f_string_length_t name_length = 0; if (data->parameters[fss_extended_read_parameter_trim].result == f_console_result_found) { - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; @@ -279,7 +282,7 @@ extern "C" { } // for } else { - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; @@ -312,9 +315,9 @@ extern "C" { } } else if (depths.array[0].index_name > 0) { - f_string_length_t total = 0; + f_array_length_t total = 0; - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) continue; total++; @@ -337,14 +340,29 @@ extern "C" { if (depths.array[0].index_at > 0) { f_array_length_t at = 0; - f_array_length_t i = 0; - for (; i < data->objects.used; i++) { + for (j = 0; i < data->objects.used; i++) { if (names[i]) { if (at == depths.array[0].value_at) { print_object(f_type_output, data->buffer, data->objects.array[i]); - fprintf(f_type_output, "%c", f_string_eol[0]); + + if (data->parameters[fss_extended_read_parameter_content].result == f_console_result_found) { + if (data->contents.array[i].used) { + fprintf(f_type_output, "%c", f_fss_space); + + for (j = 0; j < data->contents.array[i].used; j++) { + + f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[j]); + + if (j + 1 < data->contents.array[i].used) { + fprintf(f_type_output, "%c", f_fss_space); + } + } // for + } + } + + fprintf(f_type_output, "%c", f_fss_eol); break; } @@ -355,11 +373,27 @@ extern "C" { return F_none; } - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) continue; print_object(f_type_output, data->buffer, data->objects.array[i]); - fprintf(f_type_output, "%c", f_string_eol[0]); + + if (data->parameters[fss_extended_read_parameter_content].result == f_console_result_found) { + if (data->contents.array[i].used) { + fprintf(f_type_output, "%c", f_fss_space); + + for (j = 0; j < data->contents.array[i].used; j++) { + + f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[j]); + + if (j + 1 < data->contents.array[i].used) { + fprintf(f_type_output, "%c", f_fss_space); + } + } // for + } + } + + fprintf(f_type_output, "%c", f_fss_eol); } // for return F_none; @@ -375,7 +409,6 @@ extern "C" { } f_array_length_t at = 0; - f_array_length_t i = 0; for (; i < data->objects.used; i++) { @@ -395,7 +428,7 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { if (!line) { if (data->contents.array[i].used > 0) { - f_string_length_t j = 0; + j = 0; if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { if (select < data->contents.array[i].used) { @@ -431,7 +464,7 @@ extern "C" { } if (data->contents.array[i].used > 0) { - f_string_length_t j = 0; + j = 0; if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { if (select < data->contents.array[i].used) { @@ -473,9 +506,9 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { - f_string_length_t total = 0; + f_array_length_t total = 0; - for (f_string_length_t i = 0; i < data->objects.used; i++) { + for (i = 0; i < data->objects.used; i++) { if (!names[i]) { continue; } @@ -492,11 +525,9 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { - f_string_length_t line_current = 0; - f_string_length_t i = 0; - f_string_length_t j = 0; + f_array_length_t line_current = 0; - for (; i < data->contents.used; i++) { + for (i = 0, j = 0; i < data->contents.used; i++) { if (!names[i]) continue; if (!data->contents.array[i].used) { @@ -540,10 +571,7 @@ extern "C" { return F_none; } - f_string_length_t i = 0; - f_string_length_t j = 0; - - for (; i < data->contents.used; i++) { + for (i = 0, j = 0; i < data->contents.used; i++) { if (!names[i]) continue; if (!data->contents.array[i].used) {