From: Kevin Day Date: Tue, 7 Sep 2021 02:55:39 +0000 (-0500) Subject: Feature: Add support for -R/--raw parameters in FSS read programs. X-Git-Tag: 0.5.5~3 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=5e789f7c5a76a896507eecb4d3eed3f57fe1dc77;p=fll Feature: Add support for -R/--raw parameters in FSS read programs. The -R/--raw parameters designate that the quotes and the escapes should be preserved. This allows for cleaning up a file and only pulling out valid FSS format and then provide that FSS in its originally escaped and quoted forms. This further allows for maintaining quotes and escapes on Objects or Content individually. --- 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 4500997..70cd5e5 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 @@ -35,6 +35,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_basic_list_read_short_name, fss_basic_list_read_long_name, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); fll_program_print_help_option(output, context, fss_basic_list_read_short_object, fss_basic_list_read_long_object, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Object."); fll_program_print_help_option(output, context, fss_basic_list_read_short_pipe, fss_basic_list_read_long_pipe, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print using the special pipe format."); + fll_program_print_help_option(output, context, fss_basic_list_read_short_raw, fss_basic_list_read_long_raw, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print with the original quotes and escapes."); fll_program_print_help_option(output, context, fss_basic_list_read_short_select, fss_basic_list_read_long_select, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-Content at this index."); fll_program_print_help_option(output, context, fss_basic_list_read_short_total, fss_basic_list_read_long_total, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); fll_program_print_help_option(output, context, fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); 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 f96c249..1f5aa86 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 @@ -86,6 +86,7 @@ extern "C" { #define fss_basic_list_read_short_name "n" #define fss_basic_list_read_short_object "o" #define fss_basic_list_read_short_pipe "p" + #define fss_basic_list_read_short_raw "R" #define fss_basic_list_read_short_select "s" #define fss_basic_list_read_short_total "t" #define fss_basic_list_read_short_trim "T" @@ -100,6 +101,7 @@ extern "C" { #define fss_basic_list_read_long_name "name" #define fss_basic_list_read_long_object "object" #define fss_basic_list_read_long_pipe "pipe" + #define fss_basic_list_read_long_raw "raw" #define fss_basic_list_read_long_select "select" #define fss_basic_list_read_long_total "total" #define fss_basic_list_read_long_trim "trim" @@ -125,6 +127,7 @@ extern "C" { fss_basic_list_read_parameter_name, fss_basic_list_read_parameter_object, fss_basic_list_read_parameter_pipe, + fss_basic_list_read_parameter_raw, fss_basic_list_read_parameter_select, fss_basic_list_read_parameter_total, fss_basic_list_read_parameter_trim, @@ -151,12 +154,13 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_list_read_short_name, fss_basic_list_read_long_name, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_object, fss_basic_list_read_long_object, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_pipe, fss_basic_list_read_long_pipe, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_basic_list_read_short_raw, fss_basic_list_read_long_raw, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_select, fss_basic_list_read_long_select, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_list_read_short_total, fss_basic_list_read_long_total, 0, 0, f_console_type_normal), \ 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 22 + #define fss_basic_list_read_total_parameters 23 #endif // _di_fss_basic_list_read_defines_ /** diff --git a/level_3/fss_basic_list_read/c/private-common.h b/level_3/fss_basic_list_read/c/private-common.h index e7cc67d..6e8fc4b 100644 --- a/level_3/fss_basic_list_read/c/private-common.h +++ b/level_3/fss_basic_list_read/c/private-common.h @@ -135,6 +135,7 @@ extern "C" { * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). * - name: A specific Object name has been requested. * - object: The Object is to be printed. + * - raw: Enable raw printing, where the quotes are printed and no delimits are applied. * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). * - total: The total lines found and selected is printed instead of the Content. * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). @@ -160,9 +161,10 @@ extern "C" { #define fss_basic_list_read_data_option_line 0x10 #define fss_basic_list_read_data_option_name 0x20 #define fss_basic_list_read_data_option_object 0x40 - #define fss_basic_list_read_data_option_select 0x80 - #define fss_basic_list_read_data_option_total 0x100 - #define fss_basic_list_read_data_option_trim 0x200 + #define fss_basic_list_read_data_option_raw 0x80 + #define fss_basic_list_read_data_option_select 0x100 + #define fss_basic_list_read_data_option_total 0x200 + #define fss_basic_list_read_data_option_trim 0x400 typedef struct { uint16_t option; @@ -180,6 +182,7 @@ extern "C" { f_fss_delimits_t delimits_object; f_fss_delimits_t delimits_content; f_fss_comments_t comments; + f_fss_quotes_t quotes; } fss_basic_list_read_data_t; #define fss_basic_list_read_data_t_initialize \ @@ -196,6 +199,7 @@ extern "C" { f_fss_contents_t_initialize, \ f_fss_delimits_t_initialize, \ f_fss_delimits_t_initialize, \ + f_fss_quotes_t_initialize, \ f_fss_comments_t_initialize, \ } #endif // _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 b39d2fb..4e078b1 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 @@ -431,6 +431,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_basic_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_basic_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_basic_list_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + for (f_array_length_t i = 0; i < data->contents.used; ++i) { if (!names[i]) continue; @@ -461,6 +466,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_basic_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_basic_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_basic_list_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + f_array_length_t at = 0; f_status_t status = F_none; @@ -644,6 +654,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_basic_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_basic_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_basic_list_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + f_array_length_t line = 0; f_status_t status = F_none; @@ -721,6 +736,10 @@ extern "C" { data->option |= fss_basic_list_read_data_option_object; } + if (main->parameters[fss_basic_list_read_parameter_raw].result == f_console_result_found) { + data->option |= fss_basic_list_read_data_option_raw; + } + if (main->parameters[fss_basic_list_read_parameter_select].result == f_console_result_additional) { data->option |= fss_basic_list_read_data_option_select; 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 579a687..cbb3a4e 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -35,6 +35,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_basic_read_short_name, fss_basic_read_long_name, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); fll_program_print_help_option(output, context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Object."); fll_program_print_help_option(output, context, fss_basic_read_short_pipe, fss_basic_read_long_pipe, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print using the special pipe format."); + fll_program_print_help_option(output, context, fss_basic_read_short_raw, fss_basic_read_long_raw, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print with the original quotes and escapes."); fll_program_print_help_option(output, context, fss_basic_read_short_select, fss_basic_read_long_select, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-Content at this index."); fll_program_print_help_option(output, context, fss_basic_read_short_total, fss_basic_read_long_total, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); fll_program_print_help_option(output, context, fss_basic_read_short_trim, fss_basic_read_long_trim, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); 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 d5bb89c..916e345 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -86,6 +86,7 @@ extern "C" { #define fss_basic_read_short_name "n" #define fss_basic_read_short_object "o" #define fss_basic_read_short_pipe "p" + #define fss_basic_read_short_raw "R" #define fss_basic_read_short_select "s" #define fss_basic_read_short_total "t" #define fss_basic_read_short_trim "T" @@ -100,6 +101,7 @@ extern "C" { #define fss_basic_read_long_name "name" #define fss_basic_read_long_object "object" #define fss_basic_read_long_pipe "pipe" + #define fss_basic_read_long_raw "raw" #define fss_basic_read_long_select "select" #define fss_basic_read_long_total "total" #define fss_basic_read_long_trim "trim" @@ -125,6 +127,7 @@ extern "C" { fss_basic_read_parameter_name, fss_basic_read_parameter_object, fss_basic_read_parameter_pipe, + fss_basic_read_parameter_raw, fss_basic_read_parameter_select, fss_basic_read_parameter_total, fss_basic_read_parameter_trim, @@ -151,12 +154,13 @@ extern "C" { f_console_parameter_t_initialize(fss_basic_read_short_name, fss_basic_read_long_name, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_object, fss_basic_read_long_object, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_pipe, fss_basic_read_long_pipe, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_basic_read_short_raw, fss_basic_read_long_raw, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_select, fss_basic_read_long_select, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_basic_read_short_total, fss_basic_read_long_total, 0, 0, f_console_type_normal), \ 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 22 + #define fss_basic_read_total_parameters 23 #endif // _di_fss_basic_read_defines_ /** diff --git a/level_3/fss_basic_read/c/private-common.c b/level_3/fss_basic_read/c/private-common.c index b76ae2d..fc3c4b7 100644 --- a/level_3/fss_basic_read/c/private-common.c +++ b/level_3/fss_basic_read/c/private-common.c @@ -18,6 +18,7 @@ extern "C" { macro_f_fss_contents_t_delete_simple(data->contents); macro_f_fss_objects_t_delete_simple(data->objects); macro_f_fss_delimits_t_delete_simple(data->delimits); + macro_f_fss_quotes_t_delete_simple(data->quotes); } #endif // _di_fss_basic_read_data_delete_simple_ diff --git a/level_3/fss_basic_read/c/private-common.h b/level_3/fss_basic_read/c/private-common.h index b0b9ca9..b43aa57 100644 --- a/level_3/fss_basic_read/c/private-common.h +++ b/level_3/fss_basic_read/c/private-common.h @@ -135,6 +135,7 @@ extern "C" { * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). * - name: A specific Object name has been requested. * - object: The Object is to be printed. + * - raw: Enable raw printing, where the quotes are printed and no delimits are applied. * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). * - total: The total lines found and selected is printed instead of the Content. * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). @@ -159,9 +160,10 @@ extern "C" { #define fss_basic_read_data_option_line 0x10 #define fss_basic_read_data_option_name 0x20 #define fss_basic_read_data_option_object 0x40 - #define fss_basic_read_data_option_select 0x80 - #define fss_basic_read_data_option_total 0x100 - #define fss_basic_read_data_option_trim 0x200 + #define fss_basic_read_data_option_raw 0x80 + #define fss_basic_read_data_option_select 0x100 + #define fss_basic_read_data_option_total 0x200 + #define fss_basic_read_data_option_trim 0x400 typedef struct { uint16_t option; @@ -177,6 +179,7 @@ extern "C" { f_fss_objects_t objects; f_fss_contents_t contents; f_fss_delimits_t delimits; + f_fss_quotes_t quotes; } fss_basic_read_data_t; #define fss_basic_read_data_t_initialize \ @@ -192,6 +195,7 @@ extern "C" { f_fss_objects_t_initialize, \ f_fss_contents_t_initialize, \ f_fss_delimits_t_initialize, \ + f_fss_quotes_t_initialize, \ } #endif // _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 865b51b..d94c348 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 @@ -204,8 +204,9 @@ extern "C" { f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); data->delimits.used = 0; + data->quotes.used = 0; - const f_status_t status = fll_fss_basic_read(data->buffer, state, &input, &data->objects, &data->contents, 0, &data->delimits, 0); + const f_status_t status = fll_fss_basic_read(data->buffer, state, &input, &data->objects, &data->contents, &data->quotes, &data->delimits, 0); if (F_status_is_error(status)) { const f_string_t file_name = fss_basic_read_file_identify(input.start, data->files); @@ -262,10 +263,36 @@ extern "C" { if (data->option & fss_basic_read_data_option_object) { if (data->option & fss_basic_read_data_option_trim) { - fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.stream); + if (data->option & fss_basic_read_data_option_raw) { + if (data->quotes.array[at]) { + f_print_character_safely(data->quotes.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + + fl_print_trim_dynamic_partial(data->buffer, data->objects.array[at], main->output.stream); + + if (data->quotes.array[at]) { + f_print_character_safely(data->quotes.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + } + else { + fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.stream); + } } else { - f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.stream); + if (data->option & fss_basic_read_data_option_raw) { + if (data->quotes.array[at]) { + f_print_character_safely(data->quotes.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + + f_print_dynamic_partial(data->buffer, data->objects.array[at], main->output.stream); + + if (data->quotes.array[at]) { + f_print_character_safely(data->quotes.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + } + else { + f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.stream); + } } if (data->option & fss_basic_read_data_option_content) { @@ -274,7 +301,12 @@ extern "C" { } if ((data->option & fss_basic_read_data_option_content) && data->contents.array[at].used) { - f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[0], delimits_content, main->output.stream); + if (data->option & fss_basic_read_data_option_raw) { + f_print_dynamic_partial(data->buffer, data->contents.array[at].array[0], main->output.stream); + } + else { + f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[0], delimits_content, main->output.stream); + } } fss_basic_read_print_set_end(main); @@ -618,6 +650,10 @@ extern "C" { data->option |= fss_basic_read_data_option_object; } + if (main->parameters[fss_basic_read_parameter_raw].result == f_console_result_found) { + data->option |= fss_basic_read_data_option_raw; + } + if (main->parameters[fss_basic_read_parameter_select].result == f_console_result_additional) { data->option |= fss_basic_read_data_option_select; diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index 9e4c924..fd8257a 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -35,6 +35,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_embedded_list_read_short_name, fss_embedded_list_read_long_name, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); fll_program_print_help_option(output, context, fss_embedded_list_read_short_object, fss_embedded_list_read_long_object, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Object."); fll_program_print_help_option(output, context, fss_embedded_list_read_short_pipe, fss_embedded_list_read_long_pipe, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print using the special pipe format."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_raw, fss_embedded_list_read_long_raw, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print with the original quotes and escapes."); fll_program_print_help_option(output, context, fss_embedded_list_read_short_select, fss_embedded_list_read_long_select, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-Content at this index."); fll_program_print_help_option(output, context, fss_embedded_list_read_short_total, fss_embedded_list_read_long_total, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); fll_program_print_help_option(output, context, fss_embedded_list_read_short_trim, fss_embedded_list_read_long_trim, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h index ea26317..70ffd09 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h @@ -86,6 +86,7 @@ extern "C" { #define fss_embedded_list_read_short_name "n" #define fss_embedded_list_read_short_object "o" #define fss_embedded_list_read_short_pipe "p" + #define fss_embedded_list_read_short_raw "R" #define fss_embedded_list_read_short_select "s" #define fss_embedded_list_read_short_total "t" #define fss_embedded_list_read_short_trim "T" @@ -100,6 +101,7 @@ extern "C" { #define fss_embedded_list_read_long_name "name" #define fss_embedded_list_read_long_object "object" #define fss_embedded_list_read_long_pipe "pipe" + #define fss_embedded_list_read_long_raw "raw" #define fss_embedded_list_read_long_select "select" #define fss_embedded_list_read_long_total "total" #define fss_embedded_list_read_long_trim "trim" @@ -125,6 +127,7 @@ extern "C" { fss_embedded_list_read_parameter_name, fss_embedded_list_read_parameter_object, fss_embedded_list_read_parameter_pipe, + fss_embedded_list_read_parameter_raw, fss_embedded_list_read_parameter_select, fss_embedded_list_read_parameter_total, fss_embedded_list_read_parameter_trim, @@ -151,12 +154,13 @@ extern "C" { f_console_parameter_t_initialize(fss_embedded_list_read_short_name, fss_embedded_list_read_long_name, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_object, fss_embedded_list_read_long_object, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_pipe, fss_embedded_list_read_long_pipe, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_embedded_list_read_short_raw, fss_embedded_list_read_long_raw, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_select, fss_embedded_list_read_long_select, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_total, fss_embedded_list_read_long_total, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_trim, fss_embedded_list_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_embedded_list_read_total_parameters 22 + #define fss_embedded_list_read_total_parameters 23 #endif // _di_fss_embedded_list_read_defines_ #ifndef _di_fss_embedded_list_read_delimit_mode_ diff --git a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c index efa1cac..d71cf90 100644 --- a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c @@ -328,6 +328,13 @@ extern "C" { const fss_embedded_list_read_skip_t parents = fss_embedded_list_read_skip_t_initialize; + + if (main->parameters[fss_embedded_list_read_parameter_raw].result == f_console_result_found) { + f_fss_delimits_t except_none = f_fss_delimits_t_initialize; + + return fss_embedded_list_read_main_process_for_depth(arguments, filename, depths, 0, line, parents, main, &except_none, &except_none); + } + return fss_embedded_list_read_main_process_for_depth(arguments, filename, depths, 0, line, parents, main, objects_delimits, contents_delimits); } #endif // _di_fss_embedded_list_read_main_process_file_ 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 08a67b6..fc78896 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 @@ -35,6 +35,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_extended_list_read_short_name, fss_extended_list_read_long_name, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); fll_program_print_help_option(output, context, fss_extended_list_read_short_object, fss_extended_list_read_long_object, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Object."); fll_program_print_help_option(output, context, fss_extended_list_read_short_pipe, fss_extended_list_read_long_pipe, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print using the special pipe format."); + fll_program_print_help_option(output, context, fss_extended_list_read_short_raw, fss_extended_list_read_long_raw, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print with the original quotes and escapes."); fll_program_print_help_option(output, context, fss_extended_list_read_short_select, fss_extended_list_read_long_select, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-Content at this index."); fll_program_print_help_option(output, context, fss_extended_list_read_short_total, fss_extended_list_read_long_total, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); fll_program_print_help_option(output, context, fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); 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 a37aba4..58ada55c 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 @@ -86,6 +86,7 @@ extern "C" { #define fss_extended_list_read_short_name "n" #define fss_extended_list_read_short_object "o" #define fss_extended_list_read_short_pipe "p" + #define fss_extended_list_read_short_raw "R" #define fss_extended_list_read_short_select "s" #define fss_extended_list_read_short_total "t" #define fss_extended_list_read_short_trim "T" @@ -100,6 +101,7 @@ extern "C" { #define fss_extended_list_read_long_name "name" #define fss_extended_list_read_long_object "object" #define fss_extended_list_read_long_pipe "pipe" + #define fss_extended_list_read_long_raw "raw" #define fss_extended_list_read_long_select "select" #define fss_extended_list_read_long_total "total" #define fss_extended_list_read_long_trim "trim" @@ -125,6 +127,7 @@ extern "C" { fss_extended_list_read_parameter_name, fss_extended_list_read_parameter_object, fss_extended_list_read_parameter_pipe, + fss_extended_list_read_parameter_raw, fss_extended_list_read_parameter_select, fss_extended_list_read_parameter_total, fss_extended_list_read_parameter_trim, @@ -151,12 +154,13 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_list_read_short_name, fss_extended_list_read_long_name, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_object, fss_extended_list_read_long_object, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_pipe, fss_extended_list_read_long_pipe, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_extended_list_read_short_raw, fss_extended_list_read_long_raw, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_select, fss_extended_list_read_long_select, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_list_read_short_total, fss_extended_list_read_long_total, 0, 0, f_console_type_normal), \ 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 22 + #define fss_extended_list_read_total_parameters 23 #endif // _di_fss_extended_list_read_defines_ /** diff --git a/level_3/fss_extended_list_read/c/private-common.h b/level_3/fss_extended_list_read/c/private-common.h index 3f09a28..5691f99 100644 --- a/level_3/fss_extended_list_read/c/private-common.h +++ b/level_3/fss_extended_list_read/c/private-common.h @@ -136,6 +136,7 @@ extern "C" { * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). * - name: A specific Object name has been requested. * - object: The Object is to be printed. + * - raw: Enable raw printing, where the quotes are printed and no delimits are applied. * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). * - total: The total lines found and selected is printed instead of the Content. * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). @@ -161,9 +162,10 @@ extern "C" { #define fss_extended_list_read_data_option_line 0x10 #define fss_extended_list_read_data_option_name 0x20 #define fss_extended_list_read_data_option_object 0x40 - #define fss_extended_list_read_data_option_select 0x80 - #define fss_extended_list_read_data_option_total 0x100 - #define fss_extended_list_read_data_option_trim 0x200 + #define fss_extended_list_read_data_option_raw 0x80 + #define fss_extended_list_read_data_option_select 0x100 + #define fss_extended_list_read_data_option_total 0x200 + #define fss_extended_list_read_data_option_trim 0x400 typedef struct { uint16_t option; @@ -180,6 +182,7 @@ extern "C" { f_fss_contents_t contents; f_fss_delimits_t delimits_object; f_fss_delimits_t delimits_content; + f_fss_quotes_t quotes; f_fss_comments_t comments; } fss_extended_list_read_data_t; @@ -197,6 +200,7 @@ extern "C" { f_fss_contents_t_initialize, \ f_fss_delimits_t_initialize, \ f_fss_delimits_t_initialize, \ + f_fss_quotes_t_initialize, \ f_fss_comments_t_initialize, \ } #endif // _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 baa455d..9bceda3 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 @@ -433,6 +433,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_extended_list_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + for (f_array_length_t i = 0; i < data->contents.used; ++i) { if (!names[i]) continue; @@ -463,6 +468,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_extended_list_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + f_array_length_t at = 0; f_status_t status = F_none; @@ -691,6 +701,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_extended_list_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + f_array_length_t line = 0; f_status_t status = F_none; @@ -768,6 +783,10 @@ extern "C" { data->option |= fss_extended_list_read_data_option_object; } + if (main->parameters[fss_extended_list_read_parameter_raw].result == f_console_result_found) { + data->option |= fss_extended_list_read_data_option_raw; + } + if (main->parameters[fss_extended_list_read_parameter_select].result == f_console_result_additional) { data->option |= fss_extended_list_read_data_option_select; 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 f5058c4..3f13d70 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -35,6 +35,7 @@ extern "C" { fll_program_print_help_option(output, context, fss_extended_read_short_name, fss_extended_read_long_name, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); fll_program_print_help_option(output, context, fss_extended_read_short_object, fss_extended_read_long_object, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Object."); fll_program_print_help_option(output, context, fss_extended_read_short_pipe, fss_extended_read_long_pipe, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print using the special pipe format."); + fll_program_print_help_option(output, context, fss_extended_read_short_raw, fss_extended_read_long_raw, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print with the original quotes and escapes."); fll_program_print_help_option(output, context, fss_extended_read_short_select, fss_extended_read_long_select, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-Content at this index."); fll_program_print_help_option(output, context, fss_extended_read_short_total, fss_extended_read_long_total, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); fll_program_print_help_option(output, context, fss_extended_read_short_trim, fss_extended_read_long_trim, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); 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 88ae98d..81d976a 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ b/level_3/fss_extended_read/c/fss_extended_read.h @@ -86,6 +86,7 @@ extern "C" { #define fss_extended_read_short_name "n" #define fss_extended_read_short_object "o" #define fss_extended_read_short_pipe "p" + #define fss_extended_read_short_raw "R" #define fss_extended_read_short_select "s" #define fss_extended_read_short_total "t" #define fss_extended_read_short_trim "T" @@ -100,6 +101,7 @@ extern "C" { #define fss_extended_read_long_name "name" #define fss_extended_read_long_object "object" #define fss_extended_read_long_pipe "pipe" + #define fss_extended_read_long_raw "raw" #define fss_extended_read_long_select "select" #define fss_extended_read_long_total "total" #define fss_extended_read_long_trim "trim" @@ -125,6 +127,7 @@ extern "C" { fss_extended_read_parameter_name, fss_extended_read_parameter_object, fss_extended_read_parameter_pipe, + fss_extended_read_parameter_raw, fss_extended_read_parameter_select, fss_extended_read_parameter_total, fss_extended_read_parameter_trim, @@ -151,12 +154,13 @@ extern "C" { f_console_parameter_t_initialize(fss_extended_read_short_name, fss_extended_read_long_name, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_object, fss_extended_read_long_object, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_pipe, fss_extended_read_long_pipe, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_extended_read_short_raw, fss_extended_read_long_raw, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_select, fss_extended_read_long_select, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_extended_read_short_total, fss_extended_read_long_total, 0, 0, f_console_type_normal), \ 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 22 + #define fss_extended_read_total_parameters 23 #endif // _di_fss_extended_read_defines_ /** diff --git a/level_3/fss_extended_read/c/private-common.c b/level_3/fss_extended_read/c/private-common.c index f301e3b..f72a6ca 100644 --- a/level_3/fss_extended_read/c/private-common.c +++ b/level_3/fss_extended_read/c/private-common.c @@ -19,6 +19,8 @@ extern "C" { macro_f_fss_objects_t_delete_simple(data->objects); macro_f_fss_delimits_t_delete_simple(data->delimits_object); macro_f_fss_delimits_t_delete_simple(data->delimits_content); + macro_f_fss_quotes_t_delete_simple(data->quotes_object); + macro_f_fss_quotess_t_delete_simple(data->quotes_content); } #endif // _di_fss_extended_read_data_delete_simple_ diff --git a/level_3/fss_extended_read/c/private-common.h b/level_3/fss_extended_read/c/private-common.h index 93c08bd..526f63f 100644 --- a/level_3/fss_extended_read/c/private-common.h +++ b/level_3/fss_extended_read/c/private-common.h @@ -135,6 +135,7 @@ extern "C" { * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). * - name: A specific Object name has been requested. * - object: The Object is to be printed. + * - raw: Enable raw printing, where the quotes are printed and no delimits are applied. * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). * - total: The total lines found and selected is printed instead of the Content. * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). @@ -160,9 +161,10 @@ extern "C" { #define fss_extended_read_data_option_line 0x10 #define fss_extended_read_data_option_name 0x20 #define fss_extended_read_data_option_object 0x40 - #define fss_extended_read_data_option_select 0x80 - #define fss_extended_read_data_option_total 0x100 - #define fss_extended_read_data_option_trim 0x200 + #define fss_extended_read_data_option_raw 0x80 + #define fss_extended_read_data_option_select 0x100 + #define fss_extended_read_data_option_total 0x200 + #define fss_extended_read_data_option_trim 0x400 typedef struct { uint16_t option; @@ -179,6 +181,8 @@ extern "C" { f_fss_contents_t contents; f_fss_delimits_t delimits_object; f_fss_delimits_t delimits_content; + f_fss_quotes_t quotes_object; + f_fss_quotess_t quotes_content; } fss_extended_read_data_t; #define fss_extended_read_data_t_initialize \ @@ -195,6 +199,8 @@ extern "C" { f_fss_contents_t_initialize, \ f_fss_delimits_t_initialize, \ f_fss_delimits_t_initialize, \ + f_fss_quotes_t_initialize, \ + f_fss_quotess_t_initialize, \ } #endif // _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 51db43b..9cd1107 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 @@ -232,8 +232,10 @@ extern "C" { data->delimits_object.used = 0; data->delimits_content.used = 0; + data->quotes_object.used = 0; + data->quotes_content.used = 0; - const f_status_t status = fll_fss_extended_read(data->buffer, state, &input, &data->objects, &data->contents, 0, 0, &data->delimits_object, &data->delimits_content); + const f_status_t status = fll_fss_extended_read(data->buffer, state, &input, &data->objects, &data->contents, &data->quotes_object, &data->quotes_content, &data->delimits_object, &data->delimits_content); if (F_status_is_error(status)) { const f_string_t file_name = fss_extended_read_file_identify(input.start, data->files); @@ -290,10 +292,26 @@ extern "C" { if ((data->option & fss_extended_read_data_option_object) || (data->option & fss_extended_read_data_option_content) && (data->contents.array[at].used || (data->option & fss_extended_read_data_option_empty))) { if (data->option & fss_extended_read_data_option_object) { if (data->option & fss_extended_read_data_option_trim) { + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.stream); + + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } } else { + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.stream); + + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } } if (data->option & fss_extended_read_data_option_content) { @@ -308,7 +326,15 @@ extern "C" { if (data->select < data->contents.array[at].used) { content_printed = F_true; + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[data->select]) { + f_print_character_safely(data->quotes_content.array[at].array[data->select] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[data->select], delimits_content, main->output.stream); + + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[data->select]) { + f_print_character_safely(data->quotes_content.array[at].array[data->select] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } } } else { @@ -320,8 +346,16 @@ extern "C" { content_printed = F_true; + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[i]) { + f_print_character_safely(data->quotes_content.array[at].array[i] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[i], delimits_content, main->output.stream); + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[i]) { + f_print_character_safely(data->quotes_content.array[at].array[i] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + if (i + 1 < data->contents.array[at].used && data->contents.array[at].array[i + 1].start <= data->contents.array[at].array[i + 1].stop) { fss_extended_read_print_content_end(main); } @@ -476,6 +510,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select) ? data->select : 0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_extended_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + for (f_array_length_t i = 0; i < data->contents.used; ++i) { if (!names[i]) continue; @@ -521,6 +560,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select) ? data->select : 0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_extended_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + f_array_length_t at = 0; for (f_array_length_t i = 0; i < data->objects.used; ++i) { @@ -539,7 +583,15 @@ extern "C" { } } else { + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + fss_extended_read_print_at(i, *delimits_object, *delimits_content, main, data); + + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_object.array[at]) { + f_print_character_safely(data->quotes_object.array[at] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } } } else if (data->option & fss_extended_read_data_option_columns) { @@ -551,7 +603,15 @@ extern "C" { } } else { + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[i]) { + f_print_character_safely(data->quotes_content.array[at].array[i] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } + fss_extended_read_print_at(i, *delimits_object, *delimits_content, main, data); + + if ((data->option & fss_extended_read_data_option_raw) && data->quotes_content.array[at].array[i]) { + f_print_character_safely(data->quotes_content.array[at].array[i] == f_fss_quote_type_single ? f_fss_quote_single_s[0] : f_fss_quote_double_s[0], main->output.stream); + } } return F_none; @@ -609,6 +669,11 @@ extern "C" { f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select) ? data->select : 0, data) ? &data->delimits_content : &except_none; + if (data->option & fss_extended_read_data_option_raw) { + delimits_object = &except_none; + delimits_content = &except_none; + } + f_array_length_t line = 0; for (f_array_length_t i = 0; i < data->contents.used; ++i) { @@ -719,6 +784,10 @@ extern "C" { data->option |= fss_extended_read_data_option_object; } + if (main->parameters[fss_extended_read_parameter_raw].result == f_console_result_found) { + data->option |= fss_extended_read_data_option_raw; + } + if (main->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { data->option |= fss_extended_read_data_option_select;