From c03d6d0204e15a60f2dc7f74bbd9898444d37a6e Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 10 Feb 2022 22:32:22 -0600 Subject: [PATCH] Progress: Continue mass converting to f_string_static_t. This should get all of the programs compiling again. There is still more work to do with switching to f_string_static_t, but the current pass is considered complete. Another pass will follow up shortly. --- level_1/fl_print/c/private-print.c | 30 +++---- level_1/fl_string/c/string.c | 66 +++++++-------- level_1/fl_string/c/string.h | 2 +- level_2/fll_fss/c/fss.c | 24 +++--- level_2/fll_fss/c/fss.h | 2 +- level_3/control/c/control.h | 1 + level_3/control/c/private-common.h | 2 +- level_3/control/data/build/dependencies | 1 + level_3/control/data/build/settings | 2 +- level_3/controller/c/control/private-control.c | 2 - .../controller/c/controller/private-controller.c | 2 +- level_3/fake/c/private-make-operate_process_type.c | 8 +- level_3/fake/c/private-make-operate_validate.c | 4 +- level_3/fss_basic_list_read/c/private-common.h | 1 + level_3/fss_basic_read/c/fss_basic_read.c | 35 ++++---- level_3/fss_basic_read/c/private-common.h | 4 + level_3/fss_basic_read/c/private-read.c | 58 +++++++------ level_3/fss_basic_read/c/private-read.h | 32 ++++---- level_3/fss_embedded_list_read/c/private-read.c | 4 +- level_3/fss_embedded_list_write/c/private-write.c | 1 - .../c/fss_extended_list_read.c | 35 ++++---- level_3/fss_extended_list_read/c/private-common.h | 4 + level_3/fss_extended_list_read/c/private-read.c | 72 ++++++++--------- level_3/fss_extended_list_read/c/private-read.h | 46 +++++------ level_3/fss_extended_list_write/c/common.h | 6 +- .../c/fss_extended_list_write.c | 14 ++-- level_3/fss_extended_list_write/c/private-write.c | 14 +++- level_3/fss_extended_read/c/common.h | 22 ++--- level_3/fss_extended_read/c/fss_extended_read.c | 58 ++++++------- level_3/fss_extended_read/c/private-common.h | 4 + level_3/fss_extended_read/c/private-read.c | 50 ++++++------ level_3/fss_extended_read/c/private-read.h | 71 +++------------- level_3/fss_extended_write/c/fss_extended_write.c | 42 ++-------- level_3/fss_extended_write/c/private-write.c | 2 +- level_3/fss_extended_write/c/private-write.h | 2 +- level_3/fss_identify/c/fss_identify.c | 34 ++++---- level_3/fss_identify/c/private-common.h | 6 +- level_3/fss_identify/c/private-identify.c | 13 +-- level_3/fss_identify/c/private-identify.h | 8 +- level_3/fss_identify/c/private-print.c | 4 +- level_3/fss_identify/c/private-print.h | 2 +- level_3/fss_payload_read/c/common.c | 2 + level_3/fss_payload_read/c/common.h | 20 +++-- level_3/fss_payload_read/c/fss_payload_read.c | 56 +++++++------ level_3/fss_payload_read/c/private-common.h | 4 + level_3/fss_payload_read/c/private-read.c | 94 +++++++++++----------- level_3/fss_payload_read/c/private-read.h | 50 ++++++------ level_3/fss_payload_write/c/common.c | 2 +- level_3/fss_payload_write/c/fss_payload_write.c | 55 +++---------- level_3/fss_payload_write/c/private-write.c | 22 ++++- level_3/fss_payload_write/c/private-write.h | 2 +- level_3/utf8/c/private-common.h | 2 +- 52 files changed, 517 insertions(+), 582 deletions(-) diff --git a/level_1/fl_print/c/private-print.c b/level_1/fl_print/c/private-print.c index 61592ad..f7df626 100644 --- a/level_1/fl_print/c/private-print.c +++ b/level_1/fl_print/c/private-print.c @@ -1034,50 +1034,50 @@ extern "C" { char format[32]; char buffer[128]; - format[f++] = '%'; + format[f++] = f_string_ascii_percent_s.string[0]; if (flag & F_print_format_flag_sign_always_d) { - format[f++] = '+'; + format[f++] = f_string_ascii_plus_s.string[0]; } else if (flag & F_print_format_flag_sign_pad_d) { - format[f++] = ' '; + format[f++] = f_string_ascii_space_s.string[0]; } if (flag & F_print_format_flag_align_left_d) { - format[f++] = '-'; + format[f++] = f_string_ascii_minus_s.string[0]; } if (flag & F_print_format_flag_zeros_leading_d) { - format[f++] = '0'; + format[f++] = f_string_ascii_0_s.string[0]; } if (flag & F_print_format_flag_width_d) { - format[f++] = '*'; + format[f++] = f_string_ascii_asterisk_s.string[0]; } if (flag & F_print_format_flag_precision_d) { - format[f++] = '.'; - format[f++] = '*'; + format[f++] = f_string_ascii_period_s.string[0]; + format[f++] = f_string_ascii_asterisk_s.string[0]; } if (flag & F_print_format_flag_exponent_d) { if (flag & F_print_format_flag_exponent_upper_d) { - format[f++] = 'E'; + format[f++] = f_string_ascii_E_s.string[0]; } else { - format[f++] = 'e'; + format[f++] = f_string_ascii_e_s.string[0]; } } else if (flag & F_print_format_flag_exponent_either_d) { if (flag & F_print_format_flag_exponent_upper_d) { - format[f++] = 'G'; + format[f++] = f_string_ascii_G_s.string[0]; } else { - format[f++] = 'g'; + format[f++] = f_string_ascii_g_s.string[0]; } } else { - format[f++] = 'f'; + format[f++] = f_string_ascii_f_s.string[0]; } format[f] = 0; @@ -1415,7 +1415,7 @@ extern "C" { status = f_utf_is_whitespace(string + i, (length - i) + 1); - // consider invalid data not-whitespace. + // Consider invalid data not-whitespace. if (F_status_is_error(status) || status == F_false) break; i += macro_f_utf_byte_width(string[i]); @@ -1449,7 +1449,7 @@ extern "C" { status = f_utf_is_whitespace(string + i, (length - i) + 1); - // determine if this is an end of string whitespace that needs to be trimmed. + // Determine if this is an end of string whitespace that needs to be trimmed. if (status == F_true || !string[i]) { j = i + macro_f_utf_byte_width(string[i]); status = F_none; diff --git a/level_1/fl_string/c/string.c b/level_1/fl_string/c/string.c index 98f6239..12592d9 100644 --- a/level_1/fl_string/c/string.c +++ b/level_1/fl_string/c/string.c @@ -682,7 +682,7 @@ extern "C" { #endif // _di_fl_string_dynamic_seek_to_utf_character_ #ifndef _di_fl_string_fll_identify_ - f_status_t fl_string_fll_identify(const f_string_t buffer, f_string_range_t *range, f_fll_id_t *id) { + f_status_t fl_string_fll_identify(const f_string_static_t buffer, f_string_range_t *range, f_fll_id_t *id) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -694,7 +694,7 @@ extern "C" { // Skip past all leading NULLs. for (; range->start <= range->stop; ++range->start) { - if (buffer[range->start]) break; + if (buffer.string[range->start]) break; } // for if (range->start > range->stop) { @@ -707,13 +707,13 @@ extern "C" { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for return F_found_not; @@ -723,7 +723,7 @@ extern "C" { for (; range->start <= range->stop; ) { - status = f_utf_is_whitespace(buffer + range->start, (range->stop - range->start) + 1); + status = f_utf_is_whitespace(buffer.string + range->start, (range->stop - range->start) + 1); if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { @@ -734,7 +734,7 @@ extern "C" { } if (status == F_false) { - if (!buffer[range->start]) { + if (!buffer.string[range->start]) { ++range->start; continue; @@ -743,13 +743,13 @@ extern "C" { break; } - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; return F_found_not; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for if (range->start > range->stop) { @@ -761,13 +761,13 @@ extern "C" { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for return F_found_not; @@ -777,11 +777,11 @@ extern "C" { for (; range->start <= range->stop; ) { - status = f_utf_is_word(buffer + range->start, (range->stop - range->start) + 1, F_true); + status = f_utf_is_word(buffer.string + range->start, (range->stop - range->start) + 1, F_true); if (F_status_is_error(status)) return status; if (status == F_false) { - if (!buffer[range->start]) { + if (!buffer.string[range->start]) { ++range->start; continue; @@ -790,21 +790,21 @@ extern "C" { break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for - if (range->start > range->stop || buffer[range->start] != f_string_ascii_minus_s.string[0]) { + if (range->start > range->stop || buffer.string[range->start] != f_string_ascii_minus_s.string[0]) { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for return F_found_not; @@ -817,18 +817,18 @@ extern "C" { for (++range->start; range->start <= range->stop && j < 4; ++range->start, ++j) { // The hexidecimal representing the number may only be ASCII. - if (macro_f_utf_byte_width_is(buffer[range->start])) { + if (macro_f_utf_byte_width_is(buffer.string[range->start])) { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for if (id) { @@ -838,11 +838,11 @@ extern "C" { return F_found_not; } - if (isxdigit(buffer[range->start])) { - number[j] = buffer[range->start]; + if (isxdigit(buffer.string[range->start])) { + number[j] = buffer.string[range->start]; } else { - if (!buffer[range->start]) continue; + if (!buffer.string[range->start]) continue; break; } @@ -858,13 +858,13 @@ extern "C" { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for if (id) { @@ -875,14 +875,14 @@ extern "C" { } } - // skip past all NULLs. + // Skip past all NULLs. for (; range->start <= range->stop; ++range->start) { - if (buffer[range->start]) break; + if (buffer.string[range->start]) break; } // for // The end of line, whitespace, or range stop point are the only valid stop points. if (range->start <= range->stop) { - status = f_utf_is_whitespace(buffer + range->start, (range->stop - range->start) + 1); + status = f_utf_is_whitespace(buffer.string + range->start, (range->stop - range->start) + 1); if (F_status_is_error(status)) { if (id) { @@ -897,13 +897,13 @@ extern "C" { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for if (id) { @@ -914,17 +914,17 @@ extern "C" { } } - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; } if (id) { for (f_array_length_t j = i, i = 0; j <= range->stop; ++j) { - if (!buffer[j]) continue; - if (buffer[j] == f_string_ascii_minus_s.string[0]) break; + if (!buffer.string[j]) continue; + if (buffer.string[j] == f_string_ascii_minus_s.string[0]) break; - id->name[i] = buffer[j]; + id->name[i] = buffer.string[j]; ++i; } // for diff --git a/level_1/fl_string/c/string.h b/level_1/fl_string/c/string.h index 08dce11..fa7d689 100644 --- a/level_1/fl_string/c/string.h +++ b/level_1/fl_string/c/string.h @@ -967,7 +967,7 @@ extern "C" { * @see f_utf_is_word() */ #ifndef _di_fl_string_fll_identify_ - extern f_status_t fl_string_fll_identify(const f_string_t buffer, f_string_range_t *range, f_fll_id_t *id); + extern f_status_t fl_string_fll_identify(const f_string_static_t buffer, f_string_range_t *range, f_fll_id_t *id); #endif // _di_fl_string_fll_identify_ /** diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index bb5be88..c886d8b 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -6,14 +6,14 @@ extern "C" { #endif #ifndef _di_fll_fss_identify_ - f_status_t fll_fss_identify(const f_string_t buffer, f_string_range_t *range, f_fll_ids_t *ids) { + f_status_t fll_fss_identify(const f_string_static_t buffer, f_string_range_t *range, f_fll_ids_t *ids) { #ifndef _di_level_2_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ // Skip past all NULLs. for (; range->start <= range->stop; ++range->start) { - if (buffer[range->start]) break; + if (buffer.string[range->start]) break; } if (range->start > range->stop) { @@ -21,18 +21,18 @@ extern "C" { } // The first character must be a '#'. - if (buffer[range->start] != f_fss_pound_s.string[0]) { + if (buffer.string[range->start] != f_fss_pound_s.string[0]) { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for if (ids) { @@ -44,7 +44,7 @@ extern "C" { // skip past all NULLs after the '#'. for (++range->start; range->start <= range->stop; ++range->start) { - if (buffer[range->start]) break; + if (buffer.string[range->start]) break; } if (range->start > range->stop) { @@ -61,13 +61,13 @@ extern "C" { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for if (ids) { @@ -77,7 +77,7 @@ extern "C" { return F_found_not; } - f_status_t status = f_utf_is_whitespace(buffer + range->start, (range->stop - range->start) + 1); + f_status_t status = f_utf_is_whitespace(buffer.string + range->start, (range->stop - range->start) + 1); if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_maybe) { @@ -92,19 +92,19 @@ extern "C" { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop; ) { - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; break; } - range->start += macro_f_utf_byte_width(buffer[range->start]); + range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for return F_found_not; } - if (buffer[range->start] == f_string_eol_s.string[0]) { + if (buffer.string[range->start] == f_string_eol_s.string[0]) { ++range->start; if (ids) { diff --git a/level_2/fll_fss/c/fss.h b/level_2/fll_fss/c/fss.h index 69783fb..f116306 100644 --- a/level_2/fll_fss/c/fss.h +++ b/level_2/fll_fss/c/fss.h @@ -74,7 +74,7 @@ extern "C" { * @see fl_string_fll_identify() */ #ifndef _di_fll_fss_identify_ - extern f_status_t fll_fss_identify(const f_string_t buffer, f_string_range_t *range, f_fll_ids_t *ids); + extern f_status_t fll_fss_identify(const f_string_static_t buffer, f_string_range_t *range, f_fll_ids_t *ids); #endif // _di_fll_fss_identify_ /** diff --git a/level_3/control/c/control.h b/level_3/control/c/control.h index 7c2b677..b3bc210 100644 --- a/level_3/control/c/control.h +++ b/level_3/control/c/control.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/level_3/control/c/private-common.h b/level_3/control/c/private-common.h index dcfea3a..2fafdbf 100644 --- a/level_3/control/c/private-common.h +++ b/level_3/control/c/private-common.h @@ -236,10 +236,10 @@ extern "C" { /** * The control data. * + * argv: The argument structure in the progam data parameters for simplifying syntax. * command: The command type code. * cache: A cache. * socket: A socket used to connect to the controller. - * argv: The argument structure in fll_program_data_t.parameters for simplifying syntax. */ #ifndef _di_control_data_t_ typedef struct { diff --git a/level_3/control/data/build/dependencies b/level_3/control/data/build/dependencies index 0e9b310..7af7025 100644 --- a/level_3/control/data/build/dependencies +++ b/level_3/control/data/build/dependencies @@ -9,6 +9,7 @@ f_color f_console f_file f_fss +f_path f_pipe f_print f_signal diff --git a/level_3/control/data/build/settings b/level_3/control/data/build/settings index 0a5a10b..d1d6ca7 100644 --- a/level_3/control/data/build/settings +++ b/level_3/control/data/build/settings @@ -21,7 +21,7 @@ build_indexer ar build_indexer_arguments rcs build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_fss -lfl_print -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_fss -lf_memory -lf_pipe -lf_print -lf_signal -lf_socket -lf_status_string -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_fss -lfl_print -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_signal -lf_socket -lf_status_string -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_libraries_shared diff --git a/level_3/controller/c/control/private-control.c b/level_3/controller/c/control/private-control.c index 9159d5f..6dad89f 100644 --- a/level_3/controller/c/control/private-control.c +++ b/level_3/controller/c/control/private-control.c @@ -131,8 +131,6 @@ extern "C" { // @todo process the data. - fll_print_format("\nDEBUG: received packet: '%Q'\n", stdout, control->input); - // @todo send any responses. f_socket_disconnect(&client, f_socket_close_fast_e); diff --git a/level_3/controller/c/controller/private-controller.c b/level_3/controller/c/controller/private-controller.c index 38078b7..273c5d2 100644 --- a/level_3/controller/c/controller/private-controller.c +++ b/level_3/controller/c/controller/private-controller.c @@ -19,7 +19,7 @@ extern "C" { if (!buffer.string[result.start]) continue; - if (buffer.string[result.start] == '-' || buffer.string[result.start] == '+') { + if (buffer.string[result.start] == f_string_ascii_minus_s.string[0] || buffer.string[result.start] == f_string_ascii_plus_s.string[0]) { ++result.start; } diff --git a/level_3/fake/c/private-make-operate_process_type.c b/level_3/fake/c/private-make-operate_process_type.c index f5ed6c3..dcdcc15 100644 --- a/level_3/fake/c/private-make-operate_process_type.c +++ b/level_3/fake/c/private-make-operate_process_type.c @@ -641,10 +641,10 @@ extern "C" { range.start = 0; range.stop = arguments.array[i].used - 1; - if (arguments.array[i].string[0] == '+') { + if (arguments.array[i].string[0] == f_string_ascii_plus_s.string[0]) { range.start = 1; } - else if (arguments.array[i].string[0] == '-') { + else if (arguments.array[i].string[0] == f_string_ascii_minus_s.string[0]) { range.start = 1; is_negative_left = F_true; } @@ -665,10 +665,10 @@ extern "C" { is_negative_right = F_false; - if (arguments.array[i].string[0] == '+') { + if (arguments.array[i].string[0] == f_string_ascii_plus_s.string[0]) { range.start = 1; } - else if (arguments.array[i].string[0] == '-') { + else if (arguments.array[i].string[0] == f_string_ascii_minus_s.string[0]) { range.start = 1; is_negative_right = F_true; } diff --git a/level_3/fake/c/private-make-operate_validate.c b/level_3/fake/c/private-make-operate_validate.c index e48a696..7f0d47b 100644 --- a/level_3/fake/c/private-make-operate_validate.c +++ b/level_3/fake/c/private-make-operate_validate.c @@ -1004,10 +1004,10 @@ extern "C" { range.start = 0; range.stop = arguments.array[i].used - 1; - if (arguments.array[i].string[0] == '+') { + if (arguments.array[i].string[0] == f_string_ascii_plus_s.string[0]) { range.start = 1; } - else if (arguments.array[i].string[0] == '-') { + else if (arguments.array[i].string[0] == f_string_ascii_minus_s.string[0]) { range.start = 1; is_negative = F_true; } 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 46e122b..3d85cdf 100644 --- a/level_3/fss_basic_list_read/c/private-common.h +++ b/level_3/fss_basic_list_read/c/private-common.h @@ -140,6 +140,7 @@ extern "C" { * - 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). * + * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. * delimit_mode: The delimit mode. * delimit_depth: The delimit depth. 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 af533bf..46aba99 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -195,8 +195,6 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - status = F_none; if (main->parameters.array[fss_basic_read_parameter_help_e].result == f_console_result_found_e) { @@ -219,6 +217,7 @@ extern "C" { fss_basic_read_file_t files_array[main->parameters.remaining.used + 1]; fss_basic_read_data_t data = fss_basic_read_data_t_initialize; + data.argv = main->parameters.arguments.array; data.files.array = files_array; data.files.used = 1; data.files.size = main->parameters.remaining.used + 1; @@ -367,7 +366,7 @@ extern "C" { } index = main->parameters.array[fss_basic_read_parameter_delimit_e].values.array[i]; - length = argv[index].used; + length = data.argv[index].used; if (!length) { flockfile(main->error.to.stream); @@ -382,13 +381,13 @@ extern "C" { break; } - else if (fl_string_dynamic_compare(fss_basic_read_delimit_mode_name_none_s, argv[index]) == F_equal_to) { + else if (fl_string_dynamic_compare(fss_basic_read_delimit_mode_name_none_s, data.argv[index]) == F_equal_to) { data.delimit_mode = fss_basic_read_delimit_mode_none_e; } - else if (fl_string_dynamic_compare(fss_basic_read_delimit_mode_name_all_s, argv[index]) == F_equal_to) { + else if (fl_string_dynamic_compare(fss_basic_read_delimit_mode_name_all_s, data.argv[index]) == F_equal_to) { data.delimit_mode = fss_basic_read_delimit_mode_all_e; } - else if (fl_string_dynamic_compare(fss_basic_read_delimit_mode_name_object_s, argv[index]) == F_equal_to) { + else if (fl_string_dynamic_compare(fss_basic_read_delimit_mode_name_object_s, data.argv[index]) == F_equal_to) { switch (data.delimit_mode) { case 0: data.delimit_mode = fss_basic_read_delimit_mode_object_e; @@ -425,7 +424,7 @@ extern "C" { data.delimit_mode = fss_basic_read_delimit_mode_content_object_e; } - if (argv[index].string[length - 1] == fss_basic_read_delimit_mode_name_greater_s.string[0]) { + if (data.argv[index].string[length - 1] == fss_basic_read_delimit_mode_name_greater_s.string[0]) { if (!(data.delimit_mode == fss_basic_read_delimit_mode_none_e || data.delimit_mode == fss_basic_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_basic_read_delimit_mode_content_object_e) { data.delimit_mode = fss_basic_read_delimit_mode_content_greater_object_e; @@ -438,7 +437,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (argv[index].string[length - 1] == fss_basic_read_delimit_mode_name_lesser_s.string[0]) { + else if (data.argv[index].string[length - 1] == fss_basic_read_delimit_mode_name_lesser_s.string[0]) { if (!(data.delimit_mode == fss_basic_read_delimit_mode_none_e || data.delimit_mode == fss_basic_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_basic_read_delimit_mode_content_object_e) { data.delimit_mode = fss_basic_read_delimit_mode_content_lesser_object_e; @@ -455,14 +454,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (argv[index].string[0] == f_string_ascii_plus_s.string[0]) { + if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { ++range.start; } - status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &data.delimit_depth); + status = fl_conversion_string_to_number_unsigned(data.argv[index].string, range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_delimit_s, argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_delimit_s, data.argv[index]); break; } @@ -488,7 +487,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fss_basic_read_depth_process(main, arguments, &data); + status = fss_basic_read_depth_process(main, &data); } // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. @@ -568,10 +567,10 @@ extern "C" { file.stream = 0; file.id = -1; - status = f_file_stream_open(argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); + status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -580,7 +579,7 @@ extern "C" { status = f_file_size_by_id(file.id, &size_file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -591,13 +590,13 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = argv[main->parameters.remaining.array[i]]; + data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. @@ -620,7 +619,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fss_basic_read_process(main, arguments, &data); + status = fss_basic_read_process(main, &data); } fss_basic_read_data_delete_simple(&data); diff --git a/level_3/fss_basic_read/c/private-common.h b/level_3/fss_basic_read/c/private-common.h index 99955fe..bab1c6d 100644 --- a/level_3/fss_basic_read/c/private-common.h +++ b/level_3/fss_basic_read/c/private-common.h @@ -140,6 +140,7 @@ extern "C" { * - 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). * + * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. * delimit_mode: The delimit mode. * delimit_depth: The delimit depth. @@ -172,6 +173,8 @@ extern "C" { f_number_unsigned_t select; f_number_unsigned_t line; + f_string_static_t *argv; + fss_basic_read_files_t files; fss_basic_read_depths_t depths; @@ -189,6 +192,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ fss_basic_read_files_t_initialize, \ fss_basic_read_depths_t_initialize, \ f_string_dynamic_t_initialize, \ diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index a8016a2..101a308 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -8,7 +8,7 @@ extern "C" { #endif #ifndef _di_fss_basic_read_delimit_object_is_ - f_status_t fss_basic_read_delimit_object_is(const f_array_length_t depth, fss_basic_read_data_t * const data) { + f_status_t fss_basic_read_delimit_object_is(fss_basic_read_data_t * const data, const f_array_length_t depth) { switch (data->delimit_mode) { case fss_basic_read_delimit_mode_none_e: @@ -33,7 +33,7 @@ extern "C" { #endif // _di_fss_basic_read_delimit_object_is_ #ifndef _di_fss_basic_read_depth_process_ - f_status_t fss_basic_read_depth_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_basic_read_data_t *data) { + f_status_t fss_basic_read_depth_process(fll_program_data_t * const main, fss_basic_read_data_t * const data) { f_status_t status = F_none; @@ -61,8 +61,6 @@ extern "C" { f_array_length_t position_at = 0; f_array_length_t position_name = 0; - f_string_static_t * const argv = main->parameters.arguments.array; - for (f_array_length_t i = 0; i < data->depths.used; ++i) { if (fss_basic_read_signal_received(main)) { @@ -82,12 +80,12 @@ extern "C" { else { position_depth = main->parameters.array[fss_basic_read_parameter_depth_e].values.array[i]; - const f_string_range_t range = macro_f_string_range_t_initialize(argv[position_depth].used); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[position_depth].used); - status = fl_conversion_string_to_number_unsigned(argv[position_depth].string, range, &data->depths.array[i].depth); + status = fl_conversion_string_to_number_unsigned(data->argv[position_depth].string, range, &data->depths.array[i].depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_depth_s, argv[position_depth]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_depth_s, data->argv[position_depth]); return status; } @@ -106,12 +104,12 @@ extern "C" { data->depths.array[i].index_at = main->parameters.array[fss_basic_read_parameter_at_e].values.array[position_at]; - const f_string_range_t range = macro_f_string_range_t_initialize(argv[data->depths.array[i].index_at].used); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[data->depths.array[i].index_at].used); - status = fl_conversion_string_to_number_unsigned(argv[data->depths.array[i].index_at].string, range, &data->depths.array[i].value_at); + status = fl_conversion_string_to_number_unsigned(data->argv[data->depths.array[i].index_at].string, range, &data->depths.array[i].value_at); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_at_s, argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_at_s, data->argv[data->depths.array[i].index_at]); return status; } @@ -132,10 +130,10 @@ extern "C" { data->depths.array[i].index_name = main->parameters.array[fss_basic_read_parameter_name_e].values.array[position_name]; if (main->parameters.array[fss_basic_read_parameter_trim_e].result == f_console_result_found_e) { - status = fl_string_rip(argv[data->depths.array[i].index_name].string, argv[data->depths.array[i].index_name].used, &data->depths.array[i].value_name); + status = fl_string_rip(data->argv[data->depths.array[i].index_name].string, data->argv[data->depths.array[i].index_name].used, &data->depths.array[i].value_name); } else { - status = f_string_dynamic_append(argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); + status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } if (F_status_is_error(status)) { @@ -215,7 +213,7 @@ extern "C" { #endif // _di_fss_basic_read_file_identify_ #ifndef _di_fss_basic_read_load_ - f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t *data) { + f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_basic_read_common_allocation_large_d, fss_basic_read_common_allocation_small_d, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); @@ -248,16 +246,16 @@ extern "C" { #endif // _di_fss_basic_read_load_ #ifndef _di_fss_basic_read_load_number_ - f_status_t fss_basic_read_load_number(fll_program_data_t * const main, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_basic_read_load_number(fll_program_data_t * const main, fss_basic_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(main->parameters.arguments.array[index].used); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[index].used); - const f_status_t status = fl_conversion_string_to_number_unsigned(main->parameters.arguments.array[index].string, range, number); + const f_status_t status = fl_conversion_string_to_number_unsigned(data->argv[index].string, range, number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, main->parameters.arguments.array[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, data->argv[index]); return status; } @@ -270,9 +268,9 @@ extern "C" { #endif // _di_fss_basic_read_load_number_ #ifndef _di_fss_basic_read_process_ - f_status_t fss_basic_read_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_basic_read_data_t *data) { + f_status_t fss_basic_read_process(fll_program_data_t * const main, fss_basic_read_data_t * const data) { - f_status_t status = fss_basic_read_process_option(main, arguments, data); + f_status_t status = fss_basic_read_process_option(main, data); if (F_status_is_error(status)) return status; // This standard does not support multiple content groups. @@ -313,7 +311,7 @@ extern "C" { } f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(0, data) ? &data->delimits : &except_none; + f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(data, 0) ? &data->delimits : &except_none; for (f_array_length_t i = 0; i < data->contents.used; ++i) { @@ -327,7 +325,7 @@ extern "C" { #endif // _di_fss_basic_read_process_ #ifndef _di_fss_basic_read_process_at_ - f_status_t fss_basic_read_process_at(fll_program_data_t * const main, fss_basic_read_data_t *data, bool names[]) { + f_status_t fss_basic_read_process_at(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { if (data->option & (fss_basic_read_data_option_columns_d | fss_basic_read_data_option_total_d)) { @@ -357,7 +355,7 @@ extern "C" { } f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(0, data) ? &data->delimits : &except_none; + f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(data, 0) ? &data->delimits : &except_none; f_array_length_t at = 0; @@ -424,7 +422,7 @@ extern "C" { #endif // _di_fss_basic_read_process_at_ #ifndef _di_fss_basic_read_process_columns_ - f_status_t fss_basic_read_process_columns(fll_program_data_t * const main, fss_basic_read_data_t *data, bool names[]) { + f_status_t fss_basic_read_process_columns(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) { if (!(data->option & fss_basic_read_data_option_content_d)) { flockfile(main->output.to.stream); @@ -458,10 +456,10 @@ extern "C" { #endif // _di_fss_basic_read_process_columns_ #ifndef _di_fss_basic_read_process_line_ - f_status_t fss_basic_read_process_line(fll_program_data_t * const main, fss_basic_read_data_t *data, bool names[]) { + f_status_t fss_basic_read_process_line(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(0, data) ? &data->delimits : &except_none; + f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(data, 0) ? &data->delimits : &except_none; f_array_length_t line = 0; @@ -507,7 +505,7 @@ extern "C" { #endif // _di_fss_basic_read_process_line_ #ifndef _di_fss_basic_read_process_name_ - f_status_t fss_basic_read_process_name(fss_basic_read_data_t *data, bool names[]) { + f_status_t fss_basic_read_process_name(fss_basic_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; @@ -542,7 +540,7 @@ extern "C" { #endif // _di_fss_basic_read_process_name_ #ifndef _di_fss_basic_read_process_option_ - f_status_t fss_basic_read_process_option(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_basic_read_data_t *data) { + f_status_t fss_basic_read_process_option(fll_program_data_t * const main, fss_basic_read_data_t * const data) { f_status_t status = F_none; @@ -565,7 +563,7 @@ extern "C" { if (main->parameters.array[fss_basic_read_parameter_line_e].result == f_console_result_additional_e) { data->option |= fss_basic_read_data_option_line_d; - status = fss_basic_read_load_number(main, fss_basic_read_parameter_line_e, fss_basic_read_long_line_s, &data->line); + status = fss_basic_read_load_number(main, data, fss_basic_read_parameter_line_e, fss_basic_read_long_line_s, &data->line); if (F_status_is_error(status)) return status; } @@ -584,7 +582,7 @@ extern "C" { if (main->parameters.array[fss_basic_read_parameter_select_e].result == f_console_result_additional_e) { data->option |= fss_basic_read_data_option_select_d; - status = fss_basic_read_load_number(main, fss_basic_read_parameter_select_e, fss_basic_read_long_select_s, &data->select); + status = fss_basic_read_load_number(main, data, fss_basic_read_parameter_select_e, fss_basic_read_long_select_s, &data->select); if (F_status_is_error(status)) return status; } @@ -606,7 +604,7 @@ extern "C" { #endif // _di_fss_basic_read_process_option_ #ifndef _di_fss_basic_read_process_total_ - f_status_t fss_basic_read_process_total(fll_program_data_t * const main, fss_basic_read_data_t *data, bool names[]) { + f_status_t fss_basic_read_process_total(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) { f_array_length_t total = 0; diff --git a/level_3/fss_basic_read/c/private-read.h b/level_3/fss_basic_read/c/private-read.h index 9e0f387..d3a15ac 100644 --- a/level_3/fss_basic_read/c/private-read.h +++ b/level_3/fss_basic_read/c/private-read.h @@ -15,17 +15,17 @@ extern "C" { /** * Determine if the given depth is to be delimited or not for an Object. * - * @param depth - * The depth to check. * @param data * The program data. + * @param depth + * The depth to check. * * @return * F_true if to apply delimits. * F_false if to not apply delimits. */ #ifndef _di_fss_basic_read_delimit_object_is_ - extern f_status_t fss_basic_read_delimit_object_is(const f_array_length_t depth, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_delimit_object_is(fss_basic_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_delimit_object_is_ /** @@ -56,7 +56,7 @@ extern "C" { * @see fss_basic_read_depths_resize() */ #ifndef _di_fss_basic_read_depth_process_ - extern f_status_t fss_basic_read_depth_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_basic_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_depth_process(fll_program_data_t * const main, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_depth_process_ /** @@ -100,7 +100,7 @@ extern "C" { * @see fss_basic_read_process_option() */ #ifndef _di_fss_basic_read_load_ - extern f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_load_ /** @@ -110,6 +110,8 @@ extern "C" { * * @param main * The main program data. + * @param data + * The program data. * @param parameter * An ID representing the parameter. * @param name @@ -128,7 +130,7 @@ extern "C" { * @see fss_basic_read_depths_resize() */ #ifndef _di_fss_basic_read_load_number_ - extern f_status_t fss_basic_read_load_number(fll_program_data_t * const main, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_load_number(fll_program_data_t * const main, fss_basic_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_load_number_ /** @@ -138,8 +140,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -153,7 +153,7 @@ extern "C" { * @see fss_basic_read_process_option() */ #ifndef _di_fss_basic_read_process_ - extern f_status_t fss_basic_read_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_basic_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_process(fll_program_data_t * const main, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_process_ /** @@ -171,7 +171,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_read_process_at_ - extern f_status_t fss_basic_read_process_at(fll_program_data_t * const main, fss_basic_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_process_at(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_process_at_ /** @@ -189,7 +189,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_read_process_columns_ - extern f_status_t fss_basic_read_process_columns(fll_program_data_t * const main, fss_basic_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_process_columns(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_process_columns_ /** @@ -207,7 +207,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_read_process_line_ - extern f_status_t fss_basic_read_process_line(fll_program_data_t * const main, fss_basic_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_process_line(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_process_line_ /** @@ -225,7 +225,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_read_process_name_ - extern f_status_t fss_basic_read_process_name(fss_basic_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_process_name(fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_process_name_ /** @@ -233,8 +233,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -248,7 +246,7 @@ extern "C" { * @see fss_basic_read_load_setting() */ #ifndef _di_fss_basic_read_process_option_ - extern f_status_t fss_basic_read_process_option(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_basic_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_process_option(fll_program_data_t * const main, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_process_option_ /** @@ -266,7 +264,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_basic_read_process_total_ - extern f_status_t fss_basic_read_process_total(fll_program_data_t * const main, fss_basic_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_read_process_total(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_process_total_ #ifdef __cplusplus diff --git a/level_3/fss_embedded_list_read/c/private-read.c b/level_3/fss_embedded_list_read/c/private-read.c index 3a01112..7c3dd54 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -182,10 +182,10 @@ extern "C" { } } else { - status = f_string_append(argv[values_order[i]].string, argv[values_order[i]].used, &depths->array[depths->used].value_name); + status = f_string_dynamic_append(argv[values_order[i]], &depths->array[depths->used].value_name); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); return status; } diff --git a/level_3/fss_embedded_list_write/c/private-write.c b/level_3/fss_embedded_list_write/c/private-write.c index 07ec520..5539572 100644 --- a/level_3/fss_embedded_list_write/c/private-write.c +++ b/level_3/fss_embedded_list_write/c/private-write.c @@ -116,7 +116,6 @@ extern "C" { prepend = &main->parameters.arguments.array[index]; } - status = fl_fss_embedded_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, prepend, ignore, state, &range, buffer); if (F_status_is_error(status)) { 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 b596019..aa21681 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 @@ -195,8 +195,6 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - status = F_none; if (main->parameters.array[fss_extended_list_read_parameter_help_e].result == f_console_result_found_e) { @@ -219,6 +217,7 @@ extern "C" { fss_extended_list_read_file_t files_array[main->parameters.remaining.used + 1]; fss_extended_list_read_data_t data = fss_extended_list_read_data_t_initialize; + data.argv = main->parameters.arguments.array; data.files.array = files_array; data.files.used = 1; data.files.size = main->parameters.remaining.used + 1; @@ -367,7 +366,7 @@ extern "C" { } index = main->parameters.array[fss_extended_list_read_parameter_delimit_e].values.array[i]; - length = argv[index].used; + length = data.argv[index].used; if (!length) { flockfile(main->error.to.stream); @@ -382,13 +381,13 @@ extern "C" { break; } - else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_none_s.string, argv[index], fss_extended_list_read_delimit_mode_name_none_s.used) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_none_s.string, data.argv[index], fss_extended_list_read_delimit_mode_name_none_s.used) == F_equal_to) { data.delimit_mode = fss_extended_list_read_delimit_mode_none_e; } - else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_all_s.string, argv[index], fss_extended_list_read_delimit_mode_name_all_s.used) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_all_s.string, data.argv[index], fss_extended_list_read_delimit_mode_name_all_s.used) == F_equal_to) { data.delimit_mode = fss_extended_list_read_delimit_mode_all_e; } - else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_object_s.string, argv[index], fss_extended_list_read_delimit_mode_name_object_s.used) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_object_s.string, data.argv[index], fss_extended_list_read_delimit_mode_name_object_s.used) == F_equal_to) { switch (data.delimit_mode) { case 0: data.delimit_mode = fss_extended_list_read_delimit_mode_object_e; @@ -425,7 +424,7 @@ extern "C" { data.delimit_mode = fss_extended_list_read_delimit_mode_content_object_e; } - if (argv[index].string[length - 1] == fss_extended_list_read_delimit_mode_name_greater_s.string[0]) { + if (data.argv[index].string[length - 1] == fss_extended_list_read_delimit_mode_name_greater_s.string[0]) { if (!(data.delimit_mode == fss_extended_list_read_delimit_mode_none_e || data.delimit_mode == fss_extended_list_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_extended_list_read_delimit_mode_content_object_e) { data.delimit_mode = fss_extended_list_read_delimit_mode_content_greater_object_e; @@ -438,7 +437,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (argv[index].string[length - 1] == fss_extended_list_read_delimit_mode_name_lesser_s.string[0]) { + else if (data.argv[index].string[length - 1] == fss_extended_list_read_delimit_mode_name_lesser_s.string[0]) { if (!(data.delimit_mode == fss_extended_list_read_delimit_mode_none_e || data.delimit_mode == fss_extended_list_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_extended_list_read_delimit_mode_content_object_e) { data.delimit_mode = fss_extended_list_read_delimit_mode_content_lesser_object_e; @@ -455,14 +454,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (argv[index].string[0] == f_string_ascii_plus_s.string[0]) { + if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { ++range.start; } - status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &data.delimit_depth); + status = fl_conversion_string_to_number_unsigned(data.argv[index].string, range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_delimit_s, argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_delimit_s, data.argv[index]); break; } @@ -488,7 +487,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fss_extended_list_read_depth_process(main, arguments, &data); + status = fss_extended_list_read_depth_process(main, &data); } // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. @@ -568,10 +567,10 @@ extern "C" { file.stream = 0; file.id = -1; - status = f_file_stream_open(argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); + status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -580,7 +579,7 @@ extern "C" { status = f_file_size_by_id(file.id, &size_file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -591,12 +590,12 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } else if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = argv[main->parameters.remaining.array[i]]; + data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. @@ -619,7 +618,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fss_extended_list_read_process(main, arguments, &data); + status = fss_extended_list_read_process(main, &data); } fss_extended_list_read_data_delete_simple(&data); 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 4d4679f..238f36f 100644 --- a/level_3/fss_extended_list_read/c/private-common.h +++ b/level_3/fss_extended_list_read/c/private-common.h @@ -141,6 +141,7 @@ extern "C" { * - 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). * + * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. * delimit_mode: The delimit mode. * delimit_depth: The delimit depth. @@ -174,6 +175,8 @@ extern "C" { f_number_unsigned_t select; f_number_unsigned_t line; + f_string_static_t *argv; + fss_extended_list_read_files_t files; fss_extended_list_read_depths_t depths; @@ -193,6 +196,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ fss_extended_list_read_files_t_initialize, \ fss_extended_list_read_depths_t_initialize, \ f_string_dynamic_t_initialize, \ diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index e96ccd2..43d4dc5 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -8,7 +8,7 @@ extern "C" { #endif #ifndef _di_fss_extended_list_read_delimit_content_is_ - f_status_t fss_extended_list_read_delimit_content_is(const f_array_length_t depth, fss_extended_list_read_data_t * const data) { + f_status_t fss_extended_list_read_delimit_content_is(fss_extended_list_read_data_t * const data, const f_array_length_t depth) { if (data->delimit_mode == fss_extended_list_read_delimit_mode_none_e) { return F_false; @@ -31,7 +31,7 @@ extern "C" { #endif // _di_fss_extended_list_read_delimit_content_is_ #ifndef _di_fss_extended_list_read_delimit_object_is_ - f_status_t fss_extended_list_read_delimit_object_is(const f_array_length_t depth, fss_extended_list_read_data_t * const data) { + f_status_t fss_extended_list_read_delimit_object_is(fss_extended_list_read_data_t * const data, const f_array_length_t depth) { switch (data->delimit_mode) { case fss_extended_list_read_delimit_mode_none_e: @@ -56,7 +56,7 @@ extern "C" { #endif // _di_fss_extended_list_read_delimit_object_is_ #ifndef _di_fss_extended_list_read_depth_process_ - f_status_t fss_extended_list_read_depth_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_list_read_data_t *data) { + f_status_t fss_extended_list_read_depth_process(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { f_status_t status = F_none; @@ -84,8 +84,6 @@ extern "C" { f_array_length_t position_at = 0; f_array_length_t position_name = 0; - f_string_static_t * const argv = main->parameters.arguments.array; - for (f_array_length_t i = 0; i < data->depths.used; ++i) { if (fss_extended_list_read_signal_received(main)) { @@ -105,12 +103,12 @@ extern "C" { else { position_depth = main->parameters.array[fss_extended_list_read_parameter_depth_e].values.array[i]; - const f_string_range_t range = macro_f_string_range_t_initialize(argv[position_depth].used); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[position_depth].used); - status = fl_conversion_string_to_number_unsigned(argv[position_depth].string, range, &data->depths.array[i].depth); + status = fl_conversion_string_to_number_unsigned(data->argv[position_depth].string, range, &data->depths.array[i].depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_depth_s, argv[position_depth]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_depth_s, data->argv[position_depth]); return status; } @@ -129,12 +127,12 @@ extern "C" { data->depths.array[i].index_at = main->parameters.array[fss_extended_list_read_parameter_at_e].values.array[position_at]; - const f_string_range_t range = macro_f_string_range_t_initialize(argv[data->depths.array[i].index_at].used); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[data->depths.array[i].index_at].used); - status = fl_conversion_string_to_number_unsigned(argv[data->depths.array[i].index_at].string, range, &data->depths.array[i].value_at); + status = fl_conversion_string_to_number_unsigned(data->argv[data->depths.array[i].index_at].string, range, &data->depths.array[i].value_at); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_at_s, argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_at_s, data->argv[data->depths.array[i].index_at]); return status; } @@ -155,10 +153,10 @@ extern "C" { data->depths.array[i].index_name = main->parameters.array[fss_extended_list_read_parameter_name_e].values.array[position_name]; if (main->parameters.array[fss_extended_list_read_parameter_trim_e].result == f_console_result_found_e) { - status = fl_string_rip(argv[data->depths.array[i].index_name].string, argv[data->depths.array[i].index_name].used, &data->depths.array[i].value_name); + status = fl_string_rip(data->argv[data->depths.array[i].index_name].string, data->argv[data->depths.array[i].index_name].used, &data->depths.array[i].value_name); } else { - status = f_string_dynamic_append(argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); + status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } if (F_status_is_error(status)) { @@ -237,7 +235,7 @@ extern "C" { #endif // _di_fss_extended_list_read_file_identify_ #ifndef _di_fss_extended_list_read_load_ - f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t *data) { + f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_extended_list_read_common_allocation_large_d, fss_extended_list_read_common_allocation_small_d, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); @@ -270,16 +268,16 @@ extern "C" { #endif // _di_fss_extended_list_read_load_ #ifndef _di_fss_extended_list_read_load_number_ - f_status_t fss_extended_list_read_load_number(fll_program_data_t * const main, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_extended_list_read_load_number(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(main->parameters.arguments.array[index].used); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[index].used); - const f_status_t status = fl_conversion_string_to_number_unsigned(main->parameters.arguments.array[index].string, range, number); + const f_status_t status = fl_conversion_string_to_number_unsigned(data->argv[index].string, range, number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, main->parameters.arguments.array[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, data->argv[index]); return status; } @@ -292,9 +290,9 @@ extern "C" { #endif // _di_fss_extended_list_read_load_number_ #ifndef _di_fss_extended_list_read_process_ - f_status_t fss_extended_list_read_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_list_read_data_t *data) { + f_status_t fss_extended_list_read_process(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - f_status_t status = fss_extended_list_read_process_option(main, arguments, data); + f_status_t status = fss_extended_list_read_process_option(main, data); if (F_status_is_error(status)) return status; // This standard does not support multiple content groups. @@ -331,8 +329,8 @@ extern "C" { } f_array_lengths_t except_none = f_array_lengths_t_initialize; - 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; + f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; + f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; if (data->option & fss_extended_list_read_data_option_raw_d) { delimits_object = &except_none; @@ -351,7 +349,7 @@ extern "C" { #endif // _di_fss_extended_list_read_process_ #ifndef _di_fss_extended_list_read_process_at_ - f_status_t fss_extended_list_read_process_at(fll_program_data_t * const main, fss_extended_list_read_data_t *data, bool names[]) { + f_status_t fss_extended_list_read_process_at(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { if (data->option & (fss_extended_list_read_data_option_columns_d | fss_extended_list_read_data_option_total_d)) { @@ -366,8 +364,8 @@ extern "C" { } f_array_lengths_t except_none = f_array_lengths_t_initialize; - 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; + f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; + f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; if (data->option & fss_extended_list_read_data_option_raw_d) { delimits_object = &except_none; @@ -385,7 +383,7 @@ extern "C" { if (data->option & fss_extended_list_read_data_option_line_d) { f_array_length_t line = 0; - status = fss_extended_list_read_process_at_line(main, i, *delimits_object, *delimits_content, data, &line); + status = fss_extended_list_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); if (status == F_success) return F_none; } else if (data->option & fss_extended_list_read_data_option_columns_d) { @@ -470,7 +468,7 @@ extern "C" { #endif // _di_fss_extended_list_read_process_at_ #ifndef _di_fss_extended_list_read_process_at_line_ - f_status_t fss_extended_list_read_process_at_line(fll_program_data_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_extended_list_read_data_t *data, f_array_length_t *line) { + f_status_t fss_extended_list_read_process_at_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) { if (data->option & fss_extended_list_read_data_option_object_d) { @@ -566,7 +564,7 @@ extern "C" { #endif // _di_fss_extended_list_read_process_at_line_ #ifndef _di_fss_extended_list_read_process_columns_ - f_status_t fss_extended_list_read_process_columns(fll_program_data_t * const main, fss_extended_list_read_data_t *data, bool names[]) { + f_status_t fss_extended_list_read_process_columns(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { if (!(data->option & fss_extended_list_read_data_option_content_d)) { flockfile(main->output.to.stream); @@ -596,11 +594,11 @@ extern "C" { #endif // _di_fss_extended_list_read_process_columns_ #ifndef _di_fss_extended_list_read_process_line_ - f_status_t fss_extended_list_read_process_line(fll_program_data_t * const main, fss_extended_list_read_data_t *data, bool names[]) { + f_status_t fss_extended_list_read_process_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; - 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; + f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; + f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; if (data->option & fss_extended_list_read_data_option_raw_d) { delimits_object = &except_none; @@ -614,7 +612,7 @@ extern "C" { if (!names[i]) continue; - status = fss_extended_list_read_process_at_line(main, i, *delimits_object, *delimits_content, data, &line); + status = fss_extended_list_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); if (status == F_success) break; } // for @@ -623,7 +621,7 @@ extern "C" { #endif // _di_fss_extended_list_read_process_line_ #ifndef _di_fss_extended_list_read_process_name_ - f_status_t fss_extended_list_read_process_name(fss_extended_list_read_data_t *data, bool names[]) { + f_status_t fss_extended_list_read_process_name(fss_extended_list_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; @@ -649,7 +647,7 @@ extern "C" { #endif // _di_fss_extended_list_read_process_name_ #ifndef _di_fss_extended_list_read_process_option_ - f_status_t fss_extended_list_read_process_option(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_list_read_data_t *data) { + f_status_t fss_extended_list_read_process_option(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { f_status_t status = F_none; @@ -672,7 +670,7 @@ extern "C" { if (main->parameters.array[fss_extended_list_read_parameter_line_e].result == f_console_result_additional_e) { data->option |= fss_extended_list_read_data_option_line_d; - status = fss_extended_list_read_load_number(main, fss_extended_list_read_parameter_line_e, fss_extended_list_read_long_line_s, &data->line); + status = fss_extended_list_read_load_number(main, data, fss_extended_list_read_parameter_line_e, fss_extended_list_read_long_line_s, &data->line); if (F_status_is_error(status)) return status; } @@ -691,7 +689,7 @@ extern "C" { if (main->parameters.array[fss_extended_list_read_parameter_select_e].result == f_console_result_additional_e) { data->option |= fss_extended_list_read_data_option_select_d; - status = fss_extended_list_read_load_number(main, fss_extended_list_read_parameter_select_e, fss_extended_list_read_long_select_s, &data->select); + status = fss_extended_list_read_load_number(main, data, fss_extended_list_read_parameter_select_e, fss_extended_list_read_long_select_s, &data->select); if (F_status_is_error(status)) return status; } @@ -713,7 +711,7 @@ extern "C" { #endif // _di_fss_extended_list_read_process_option_ #ifndef _di_fss_extended_list_read_process_total_ - f_status_t fss_extended_list_read_process_total(fll_program_data_t * const main, fss_extended_list_read_data_t *data, bool names[]) { + f_status_t fss_extended_list_read_process_total(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { f_array_length_t total = 0; f_string_range_t range = f_string_range_t_initialize; diff --git a/level_3/fss_extended_list_read/c/private-read.h b/level_3/fss_extended_list_read/c/private-read.h index 426cff4..15a3230 100644 --- a/level_3/fss_extended_list_read/c/private-read.h +++ b/level_3/fss_extended_list_read/c/private-read.h @@ -15,33 +15,33 @@ extern "C" { /** * Determine if the given depth is to be delimited or not for Content. * - * @param depth - * The depth to check. * @param data * The program data. + * @param depth + * The depth to check. * * @return * F_true if to apply delimits. * F_false if to not apply delimits. */ #ifndef _di_fss_extended_list_read_delimit_content_is_ - extern f_status_t fss_extended_list_read_delimit_content_is(const f_array_length_t depth, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_delimit_content_is(fss_extended_list_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_delimit_content_is_ /** * Determine if the given depth is to be delimited or not for an Object. * - * @param depth - * The depth to check. * @param data * The program data. + * @param depth + * The depth to check. * * @return * F_true if to apply delimits. * F_false if to not apply delimits. */ #ifndef _di_fss_extended_list_read_delimit_object_is_ - extern f_status_t fss_extended_list_read_delimit_object_is(const f_array_length_t depth, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_delimit_object_is(fss_extended_list_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_delimit_object_is_ /** @@ -51,8 +51,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -72,7 +70,7 @@ extern "C" { * @see fss_extended_list_read_depths_resize() */ #ifndef _di_fss_extended_list_read_depth_process_ - extern f_status_t fss_extended_list_read_depth_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_list_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_depth_process(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_depth_process_ /** @@ -116,7 +114,7 @@ extern "C" { * @see fss_extended_list_read_process_option() */ #ifndef _di_fss_extended_list_read_load_ - extern f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_load_ /** @@ -126,6 +124,8 @@ extern "C" { * * @param main * The main program data. + * @param data + * The program data. * @param parameter * An ID representing the parameter. * @param name @@ -144,7 +144,7 @@ extern "C" { * @see fss_extended_list_read_depths_resize() */ #ifndef _di_fss_extended_list_read_load_number_ - extern f_status_t fss_extended_list_read_load_number(fll_program_data_t * const main, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_load_number(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_load_number_ /** @@ -154,8 +154,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -169,7 +167,7 @@ extern "C" { * @see fss_extended_list_read_process_option() */ #ifndef _di_fss_extended_list_read_process_ - extern f_status_t fss_extended_list_read_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_list_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_process(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_process_ /** @@ -189,7 +187,7 @@ extern "C" { * @see fss_extended_list_read_process_at_line() */ #ifndef _di_fss_extended_list_read_process_at_ - extern f_status_t fss_extended_list_read_process_at(fll_program_data_t * const main, fss_extended_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_process_at(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_process_at_ /** @@ -197,12 +195,12 @@ extern "C" { * * @param main * The main program data. + * @param data + * The program data. * @param delimits_object * The delimits to be applied to an Object. * @param delimits_content * The delimits to be applied to Content. - * @param data - * The program data. * @param line * The current line being processed. * This will be incremented as necessary. @@ -212,7 +210,7 @@ extern "C" { * F_success on success and the line was matched (and possibly printed). */ #ifndef _di_fss_extended_list_read_process_at_line_ - extern f_status_t fss_extended_list_read_process_at_line(fll_program_data_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_extended_list_read_data_t *data, f_array_length_t *line) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_process_at_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_process_at_line_ /** @@ -230,7 +228,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_list_read_process_columns_ - extern f_status_t fss_extended_list_read_process_columns(fll_program_data_t * const main, fss_extended_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_process_columns(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_process_columns_ /** @@ -248,7 +246,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_list_read_process_line_ - extern f_status_t fss_extended_list_read_process_line(fll_program_data_t * const main, fss_extended_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_process_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_process_line_ /** @@ -266,14 +264,12 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_list_read_process_name_ - extern f_status_t fss_extended_list_read_process_name(fss_extended_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_process_name(fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_process_name_ /** * Process the parameters, populating the option property of the program data. * - * @param arguments - * The parameters passed to the process. * @param main * The main program data. * @param data @@ -289,7 +285,7 @@ extern "C" { * @see fss_extended_list_read_load_setting() */ #ifndef _di_fss_extended_list_read_process_option_ - extern f_status_t fss_extended_list_read_process_option(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_list_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_process_option(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_process_option_ /** @@ -307,7 +303,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_list_read_process_total_ - extern f_status_t fss_extended_list_read_process_total(fll_program_data_t * const main, fss_extended_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_list_read_process_total(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_process_total_ #ifdef __cplusplus diff --git a/level_3/fss_extended_list_write/c/common.h b/level_3/fss_extended_list_write/c/common.h index 3bb5648..76d15b6 100644 --- a/level_3/fss_extended_list_write/c/common.h +++ b/level_3/fss_extended_list_write/c/common.h @@ -71,9 +71,9 @@ extern "C" { #ifndef _di_fss_extended_list_write_defines_ #define fss_extended_list_write_signal_check_d 10000 - #define FSS_EXTENDED_LIST_READ_pipe_name_s "(pipe)" + #define FSS_EXTENDED_LIST_WRITE_pipe_name_s "(pipe)" - #define FSS_EXTENDED_LIST_READ_pipe_name_s_length 6 + #define FSS_EXTENDED_LIST_WRITE_pipe_name_s_length 6 #define FSS_EXTENDED_LIST_WRITE_pipe_content_end_s "\f" #define FSS_EXTENDED_LIST_WRITE_pipe_content_ignore_s "\v" @@ -83,7 +83,7 @@ extern "C" { #define FSS_EXTENDED_LIST_WRITE_pipe_content_ignore_s_length 1 #define FSS_EXTENDED_LIST_WRITE_pipe_content_start_s_length 1 - extern const f_string_static_t fss_extended_list_read_pipe_name_s; + extern const f_string_static_t fss_extended_list_write_pipe_name_s; extern const f_string_static_t fss_extended_list_write_pipe_content_end_s; extern const f_string_static_t fss_extended_list_write_pipe_content_ignore_s; diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.c b/level_3/fss_extended_list_write/c/fss_extended_list_write.c index 4099813..890bb79 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.c @@ -325,16 +325,12 @@ extern "C" { else if (main->parameters.array[fss_extended_list_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_extended_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_extended_list_write_parameter_prepend_e].values.used - 1]; - if (length) { - f_string_range_t range = macro_f_string_range_t_initialize(length); + if (argv[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); - main->prepend.string = argv[index]; - main->prepend.used = length; - main->prepend.size = length; + for (; range.start < argv[index].used; ++range.start) { - for (; range.start < length; ++range.start) { - - status = f_fss_is_space(main->prepend, range); + status = f_fss_is_space(argv[index], range); if (F_status_is_error(status)) break; if (status == F_false) { @@ -402,7 +398,7 @@ extern "C" { } } - f_fss_quote_t quote = f_fss_delimit_quote_double_s; + f_fss_quote_t quote = f_fss_quote_type_double_e; if (F_status_is_error_not(status)) { if (main->parameters.array[fss_extended_list_write_parameter_double_e].result == f_console_result_found_e) { diff --git a/level_3/fss_extended_list_write/c/private-write.c b/level_3/fss_extended_list_write/c/private-write.c index 649eac7..47dbf96 100644 --- a/level_3/fss_extended_list_write/c/private-write.c +++ b/level_3/fss_extended_list_write/c/private-write.c @@ -108,7 +108,15 @@ extern "C" { range.start = 0; range.stop = content->used - 1; - status = fl_fss_extended_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, &main->prepend, ignore, state, &range, buffer); + const f_string_static_t *prepend = 0; + + if (main->parameters.array[fss_extended_list_write_parameter_prepend_e].result == f_console_result_additional_e) { + const f_array_length_t index = main->parameters.array[fss_extended_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_extended_list_write_parameter_prepend_e].values.used - 1]; + + prepend = &main->parameters.arguments.array[index]; + } + + status = fl_fss_extended_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, prepend, ignore, state, &range, buffer); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fl_fss_extended_list_content_write", F_true); @@ -401,7 +409,7 @@ extern "C" { index = main->parameters.array[fss_extended_list_write_parameter_ignore_e].values.array[i * 2]; range.start = 0; - range.stop = strnlen(argv[index], F_console_parameter_size_d) - 1; + range.stop = argv[index].used - 1; // allow and ignore the positive sign. if (range.stop > 0 && argv[index].string[0] == f_string_ascii_plus_s.string[0]) { @@ -421,7 +429,7 @@ extern "C" { index = main->parameters.array[fss_extended_list_write_parameter_ignore_e].values.array[(i * 2) + 1]; range.start = 0; - range.stop = strnlen(argv[index], F_console_parameter_size_d) - 1; + range.stop = argv[index].used - 1; // allow and ignore the positive sign. if (range.stop > 0 && argv[index].string[0] == f_string_ascii_plus_s.string[0]) { diff --git a/level_3/fss_extended_read/c/common.h b/level_3/fss_extended_read/c/common.h index c22c4cd..79c37aa 100644 --- a/level_3/fss_extended_read/c/common.h +++ b/level_3/fss_extended_read/c/common.h @@ -255,17 +255,17 @@ extern "C" { * - object: Objects arre to have delimits applied. */ #ifndef _di_fss_extended_read_delimit_mode_ - #define FSS_EXTENDED_READ_delimit_mode_name_none "none" - #define FSS_EXTENDED_READ_delimit_mode_name_all "all" - #define FSS_EXTENDED_READ_delimit_mode_name_object "object" - #define FSS_EXTENDED_READ_delimit_mode_name_greater "+" - #define FSS_EXTENDED_READ_delimit_mode_name_lesser "-" - - #define FSS_EXTENDED_READ_delimit_mode_name_none_length 4 - #define FSS_EXTENDED_READ_delimit_mode_name_all_length 3 - #define FSS_EXTENDED_READ_delimit_mode_name_object_length 6 - #define FSS_EXTENDED_READ_delimit_mode_name_greater_length 1 - #define FSS_EXTENDED_READ_delimit_mode_name_lesser_length 1 + #define FSS_EXTENDED_READ_delimit_mode_name_none_s "none" + #define FSS_EXTENDED_READ_delimit_mode_name_all_s "all" + #define FSS_EXTENDED_READ_delimit_mode_name_object_s "object" + #define FSS_EXTENDED_READ_delimit_mode_name_greater_s "+" + #define FSS_EXTENDED_READ_delimit_mode_name_lesser_s "-" + + #define FSS_EXTENDED_READ_delimit_mode_name_none_s_length 4 + #define FSS_EXTENDED_READ_delimit_mode_name_all_s_length 3 + #define FSS_EXTENDED_READ_delimit_mode_name_object_s_length 6 + #define FSS_EXTENDED_READ_delimit_mode_name_greater_s_length 1 + #define FSS_EXTENDED_READ_delimit_mode_name_lesser_s_length 1 extern const f_string_static_t fss_extended_read_delimit_mode_name_none_s; extern const f_string_static_t fss_extended_read_delimit_mode_name_all_s; 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 05aba44..752829a 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -91,18 +91,18 @@ extern "C" { fl_print_format(" Both the Object and Content are separated by a space.%r%r", file.stream, f_string_eol_s, f_string_eol_s); fl_print_format(" The parameter %[%r%r%] accepts the following:%r", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_read_long_delimit_s, context.set.notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Do not apply delimits.%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_none, context.set.notable, f_string_eol_s); - fl_print_format(" - %[%r%]: (default) Apply all delimits.%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_all, context.set.notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Apply delimits for Objects.%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_object, context.set.notable, f_string_eol_s); + fl_print_format(" - %[%r%]: Do not apply delimits.%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_none_s, context.set.notable, f_string_eol_s); + fl_print_format(" - %[%r%]: (default) Apply all delimits.%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_all_s, context.set.notable, f_string_eol_s); + fl_print_format(" - %[%r%]: Apply delimits for Objects.%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_object_s, context.set.notable, f_string_eol_s); fl_print_format(" - A number, 0 or greater: apply delimits for Content at the specified depth.%r", file.stream, f_string_eol_s); - fl_print_format(" - A number, 0 or greater, followed by a %[%r%]: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_greater, context.set.notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" - A number, 0 or lesser, followed by a %[%r%]: (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%r%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_lesser, context.set.notable, f_string_eol_s, f_string_eol_s); + fl_print_format(" - A number, 0 or greater, followed by a %[%r%]: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_greater_s, context.set.notable, f_string_eol_s, f_string_eol_s); + fl_print_format(" - A number, 0 or lesser, followed by a %[%r%]: (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%r%r", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_lesser_s, context.set.notable, f_string_eol_s, f_string_eol_s); fl_print_format(" The %[%r%r%] parameter may be specified multiple times to customize the delimit behavior.%r", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_read_long_delimit_s, context.set.notable, f_string_eol_s); fl_print_format(" The %[%r%r%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_read_long_delimit_s, context.set.notable); - fl_print_format(" values %[%r%]", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_none, context.set.notable); - fl_print_format(" and %[%r%],", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_all, context.set.notable); + fl_print_format(" values %[%r%]", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_none_s, context.set.notable); + fl_print_format(" and %[%r%],", file.stream, context.set.notable, fss_extended_read_delimit_mode_name_all_s, context.set.notable); fl_print_format(" overrule all other delimit values.%r%r", file.stream, f_string_eol_s, f_string_eol_s); fl_print_format(" The parameters %[%r%r%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, fss_extended_read_long_columns_s, context.set.notable); @@ -195,8 +195,6 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - status = F_none; if (main->parameters.array[fss_extended_read_parameter_help_e].result == f_console_result_found_e) { @@ -219,6 +217,7 @@ extern "C" { fss_extended_read_file_t files_array[main->parameters.remaining.used + 1]; fss_extended_read_data_t data = fss_extended_read_data_t_initialize; + data.argv = main->parameters.arguments.array; data.files.array = files_array; data.files.used = 1; data.files.size = main->parameters.remaining.used + 1; @@ -285,7 +284,7 @@ extern "C" { fss_extended_read_parameter_total_e, }; - const f_string_t parameter_name[] = { + const f_string_static_t parameter_name[] = { fss_extended_read_long_depth_s, fss_extended_read_long_line_s, fss_extended_read_long_pipe_s, @@ -350,7 +349,7 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_extended_read_parameter_delimit_e].result == f_console_result_additional_e) { - f_array_length_t location = 0; + f_array_length_t index = 0; f_array_length_t length = 0; uint16_t signal_check = 0; @@ -362,14 +361,15 @@ extern "C" { if (!((++signal_check) % fss_extended_read_signal_check_d)) { if (fss_extended_read_signal_received(main)) { status = F_status_set_error(F_signal); + break; } signal_check = 0; } - location = main->parameters.array[fss_extended_read_parameter_delimit_e].values.array[i]; - length = strnlen(argv[location], F_console_parameter_size_d); + index = main->parameters.array[fss_extended_read_parameter_delimit_e].values.array[i]; + length = data.argv[index].used; if (!length) { flockfile(main->error.to.stream); @@ -384,13 +384,13 @@ extern "C" { break; } - else if (fl_string_compare(argv[location], fss_extended_read_delimit_mode_name_none, length, fss_extended_read_delimit_mode_name_none_length) == F_equal_to) { + else if (fl_string_dynamic_compare(data.argv[index], fss_extended_read_delimit_mode_name_none_s) == F_equal_to) { data.delimit_mode = fss_extended_read_delimit_mode_none_e; } - else if (fl_string_compare(argv[location], fss_extended_read_delimit_mode_name_all, length, fss_extended_read_delimit_mode_name_all_length) == F_equal_to) { + else if (fl_string_dynamic_compare(data.argv[index], fss_extended_read_delimit_mode_name_all_s) == F_equal_to) { data.delimit_mode = fss_extended_read_delimit_mode_all_e; } - else if (fl_string_compare(argv[location], fss_extended_read_delimit_mode_name_object, length, fss_extended_read_delimit_mode_name_object_length) == F_equal_to) { + else if (fl_string_dynamic_compare(data.argv[index], fss_extended_read_delimit_mode_name_object_s) == F_equal_to) { switch (data.delimit_mode) { case 0: data.delimit_mode = fss_extended_read_delimit_mode_object_e; @@ -427,7 +427,7 @@ extern "C" { data.delimit_mode = fss_extended_read_delimit_mode_content_object_e; } - if (argv[location][length - 1] == fss_extended_read_delimit_mode_name_greater[0]) { + if (data.argv[index].string[length - 1] == fss_extended_read_delimit_mode_name_greater_s.string[0]) { if (!(data.delimit_mode == fss_extended_read_delimit_mode_none_e || data.delimit_mode == fss_extended_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_extended_read_delimit_mode_content_object_e) { data.delimit_mode = fss_extended_read_delimit_mode_content_greater_object_e; @@ -440,7 +440,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (argv[location][length - 1] == fss_extended_read_delimit_mode_name_lesser[0]) { + else if (data.argv[index].string[length - 1] == fss_extended_read_delimit_mode_name_lesser_s.string[0]) { if (!(data.delimit_mode == fss_extended_read_delimit_mode_none_e || data.delimit_mode == fss_extended_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_extended_read_delimit_mode_content_object_e) { data.delimit_mode = fss_extended_read_delimit_mode_content_lesser_object_e; @@ -457,14 +457,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (argv[location][0] == '+') { + if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { ++range.start; } - status = fl_conversion_string_to_number_unsigned(argv[location], range, &data.delimit_depth); + status = fl_conversion_string_to_number_unsigned(data.argv[index].string, range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_delimit_s, argv[location]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_delimit_s, data.argv[index]); break; } @@ -490,7 +490,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fss_extended_read_depth_process(main, arguments, &data); + status = fss_extended_read_depth_process(main, &data); } // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. @@ -536,7 +536,7 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, f_string_ascii_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); } else if (data.buffer.used) { data.files.array[0].range.stop = data.buffer.used - 1; @@ -574,10 +574,10 @@ extern "C" { file.stream = 0; file.id = -1; - status = f_file_stream_open(argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); + status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -586,7 +586,7 @@ extern "C" { status = f_file_size_by_id(file.id, &size_file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -597,13 +597,13 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = argv[main->parameters.remaining.array[i]]; + data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. @@ -626,7 +626,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fss_extended_read_process(main, arguments, &data); + status = fss_extended_read_process(main, &data); } fss_extended_read_data_delete_simple(&data); diff --git a/level_3/fss_extended_read/c/private-common.h b/level_3/fss_extended_read/c/private-common.h index b9211a0..a8bbd96 100644 --- a/level_3/fss_extended_read/c/private-common.h +++ b/level_3/fss_extended_read/c/private-common.h @@ -140,6 +140,7 @@ extern "C" { * - 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). * + * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. * delimit_mode: The delimit mode. * delimit_depth: The delimit depth. @@ -173,6 +174,8 @@ extern "C" { f_number_unsigned_t select; f_number_unsigned_t line; + f_string_static_t *argv; + fss_extended_read_files_t files; fss_extended_read_depths_t depths; @@ -192,6 +195,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ fss_extended_read_files_t_initialize, \ fss_extended_read_depths_t_initialize, \ f_string_dynamic_t_initialize, \ diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index 272b21b..b653b46 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -60,7 +60,7 @@ extern "C" { #endif // _di_fss_extended_read_delimit_content_is_ #ifndef _di_fss_extended_read_depth_process_ - f_status_t fss_extended_read_depth_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_read_data_t *data) { + f_status_t fss_extended_read_depth_process(fll_program_data_t * const main, fss_extended_read_data_t * const data) { f_status_t status = F_none; @@ -112,12 +112,12 @@ extern "C" { else { position_depth = main->parameters.array[fss_extended_read_parameter_depth_e].values.array[i]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[position_depth])); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[position_depth].used); - status = fl_conversion_string_to_number_unsigned(arguments->argv[position_depth], range, &data->depths.array[i].depth); + status = fl_conversion_string_to_number_unsigned(data->argv[position_depth].string, range, &data->depths.array[i].depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_depth_s, arguments->argv[position_depth]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_depth_s, data->argv[position_depth]); return status; } @@ -136,12 +136,12 @@ extern "C" { data->depths.array[i].index_at = main->parameters.array[fss_extended_read_parameter_at_e].values.array[position_at]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[data->depths.array[i].index_at])); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[data->depths.array[i].index_at].used); - status = fl_conversion_string_to_number_unsigned(arguments->argv[data->depths.array[i].index_at], range, &data->depths.array[i].value_at); + status = fl_conversion_string_to_number_unsigned(data->argv[data->depths.array[i].index_at].string, range, &data->depths.array[i].value_at); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_at_s, arguments->argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_at_s, data->argv[data->depths.array[i].index_at]); return status; } @@ -162,14 +162,14 @@ extern "C" { data->depths.array[i].index_name = main->parameters.array[fss_extended_read_parameter_name_e].values.array[position_name]; if (main->parameters.array[fss_extended_read_parameter_trim_e].result == f_console_result_found_e) { - status = fl_string_rip(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = fl_string_rip(data->argv[data->depths.array[i].index_name].string, data->argv[data->depths.array[i].index_name].used, &data->depths.array[i].value_name); } else { - status = f_string_append(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_extended_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_rip" : "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_extended_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_rip" : "f_string_dynamic_append", F_true); return status; } @@ -248,7 +248,7 @@ extern "C" { #endif // _di_fss_extended_read_file_identify_ #ifndef _di_fss_extended_read_load_ - f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t *data) { + f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_extended_read_common_allocation_large_d, fss_extended_read_common_allocation_small_d, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); @@ -283,16 +283,16 @@ extern "C" { #endif // _di_fss_extended_read_load_ #ifndef _di_fss_extended_read_load_number_ - f_status_t fss_extended_read_load_number(fll_program_data_t * const main, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_extended_read_load_number(fll_program_data_t * const main, fss_extended_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(main->parameters.arguments.array[index].used); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[index].used); - const f_status_t status = fl_conversion_string_to_number_unsigned(main->parameters.arguments.array[index].string, range, number); + const f_status_t status = fl_conversion_string_to_number_unsigned(data->argv[index].string, range, number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, main->parameters.arguments.array[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, data->argv[index]); return status; } @@ -305,9 +305,9 @@ extern "C" { #endif // _di_fss_extended_read_load_number_ #ifndef _di_fss_extended_read_process_ - f_status_t fss_extended_read_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_read_data_t *data) { + f_status_t fss_extended_read_process(fll_program_data_t * const main, fss_extended_read_data_t * const data) { - f_status_t status = fss_extended_read_process_option(main, arguments, data); + f_status_t status = fss_extended_read_process_option(main, data); if (F_status_is_error(status)) return status; status = fss_extended_read_load(main, data); @@ -355,7 +355,7 @@ extern "C" { #endif // _di_fss_extended_read_process_ #ifndef _di_fss_extended_read_process_at_ - f_status_t fss_extended_read_process_at(fll_program_data_t * const main, fss_extended_read_data_t *data, bool names[]) { + f_status_t fss_extended_read_process_at(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { if (data->option & (fss_extended_read_data_option_columns_d | fss_extended_read_data_option_total_d)) { @@ -461,7 +461,7 @@ extern "C" { #endif // _di_fss_extended_read_process_at_ #ifndef _di_fss_extended_read_process_columns_ - f_status_t fss_extended_read_process_columns(fll_program_data_t * const main, fss_extended_read_data_t *data, bool names[]) { + f_status_t fss_extended_read_process_columns(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) { if (!(data->option & fss_extended_read_data_option_content_d)) { flockfile(main->output.to.stream); @@ -491,7 +491,7 @@ extern "C" { #endif // _di_fss_extended_read_process_columns_ #ifndef _di_fss_extended_read_process_line_ - f_status_t fss_extended_read_process_line(fll_program_data_t * const main, fss_extended_read_data_t *data, bool names[]) { + f_status_t fss_extended_read_process_line(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; @@ -542,7 +542,7 @@ extern "C" { #endif // _di_fss_extended_read_process_line_ #ifndef _di_fss_extended_read_process_name_ - f_status_t fss_extended_read_process_name(fss_extended_read_data_t *data, bool names[]) { + f_status_t fss_extended_read_process_name(fss_extended_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; @@ -577,7 +577,7 @@ extern "C" { #endif // _di_fss_extended_read_process_name_ #ifndef _di_fss_extended_read_process_option_ - f_status_t fss_extended_read_process_option(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_read_data_t *data) { + f_status_t fss_extended_read_process_option(fll_program_data_t * const main, fss_extended_read_data_t * const data) { f_status_t status = F_none; @@ -600,7 +600,7 @@ extern "C" { if (main->parameters.array[fss_extended_read_parameter_line_e].result == f_console_result_additional_e) { data->option |= fss_extended_read_data_option_line_d; - status = fss_extended_read_load_number(main, fss_extended_read_parameter_line_e, fss_extended_read_long_line_s, &data->line); + status = fss_extended_read_load_number(main, data, fss_extended_read_parameter_line_e, fss_extended_read_long_line_s, &data->line); if (F_status_is_error(status)) return status; } @@ -619,7 +619,7 @@ extern "C" { if (main->parameters.array[fss_extended_read_parameter_select_e].result == f_console_result_additional_e) { data->option |= fss_extended_read_data_option_select_d; - status = fss_extended_read_load_number(main, fss_extended_read_parameter_select_e, fss_extended_read_long_select_s, &data->select); + status = fss_extended_read_load_number(main, data, fss_extended_read_parameter_select_e, fss_extended_read_long_select_s, &data->select); if (F_status_is_error(status)) return status; } @@ -641,7 +641,7 @@ extern "C" { #endif // _di_fss_extended_read_process_option_ #ifndef _di_fss_extended_read_process_total_ - f_status_t fss_extended_read_process_total(fll_program_data_t * const main, fss_extended_read_data_t *data, bool names[]) { + f_status_t fss_extended_read_process_total(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) { f_array_length_t total = 0; diff --git a/level_3/fss_extended_read/c/private-read.h b/level_3/fss_extended_read/c/private-read.h index 3cf437e..1e6f45c 100644 --- a/level_3/fss_extended_read/c/private-read.h +++ b/level_3/fss_extended_read/c/private-read.h @@ -51,8 +51,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -72,7 +70,7 @@ extern "C" { * @see fss_extended_read_depths_resize() */ #ifndef _di_fss_extended_read_depth_process_ - extern f_status_t fss_extended_read_depth_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_depth_process(fll_program_data_t * const main, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_depth_process_ /** @@ -116,7 +114,7 @@ extern "C" { * @see fss_extended_read_process_option() */ #ifndef _di_fss_extended_read_load_ - extern f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_load_ /** @@ -126,6 +124,8 @@ extern "C" { * * @param main * The main program data. + * @param data + * The program data. * @param parameter * An ID representing the parameter. * @param name @@ -144,7 +144,7 @@ extern "C" { * @see fss_extended_read_depths_resize() */ #ifndef _di_fss_extended_read_load_number_ - extern f_status_t fss_extended_read_load_number(fll_program_data_t * const main, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_load_number(fll_program_data_t * const main, fss_extended_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_load_number_ /** @@ -154,8 +154,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -169,7 +167,7 @@ extern "C" { * @see fss_extended_read_process_option() */ #ifndef _di_fss_extended_read_process_ - extern f_status_t fss_extended_read_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_process(fll_program_data_t * const main, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_process_ /** @@ -187,7 +185,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_read_process_at_ - extern f_status_t fss_extended_read_process_at(fll_program_data_t * const main, fss_extended_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_process_at(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_process_at_ /** @@ -205,7 +203,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_read_process_columns_ - extern f_status_t fss_extended_read_process_columns(fll_program_data_t * const main, fss_extended_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_process_columns(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_process_columns_ /** @@ -223,7 +221,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_read_process_line_ - extern f_status_t fss_extended_read_process_line(fll_program_data_t * const main, fss_extended_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_process_line(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_process_line_ /** @@ -241,7 +239,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_read_process_name_ - extern f_status_t fss_extended_read_process_name(fss_extended_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_process_name(fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_process_name_ /** @@ -249,8 +247,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -264,7 +260,7 @@ extern "C" { * @see fss_extended_read_load_setting() */ #ifndef _di_fss_extended_read_process_option_ - extern f_status_t fss_extended_read_process_option(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_extended_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_process_option(fll_program_data_t * const main, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_process_option_ /** @@ -282,52 +278,9 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_extended_read_process_total_ - extern f_status_t fss_extended_read_process_total(fll_program_data_t * const main, fss_extended_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_extended_read_process_total(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_process_total_ -/** - * Determine if the given depth is to be delimited or not. - * - * @param main - * The main program data. - * @param depth - * The depth to check. - * - * @return - * F_true if delimited. - * F_false if not delimited. - */ -#ifndef _di_fss_extended_read_is_delimited_at_depth_ - extern f_status_t fss_extended_read_is_delimited_at_depth(fll_program_data_t * const main, const f_array_length_t depth) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_is_delimited_at_depth_ - -/** - * Process a given file. - * - * @param main - * The main program data. - * @param arguments - * The console arguments passed to the program. - * @param file_name - * The name of the file being processed. - * @param depths - * The processed depth parameters. - * @param objects_delimits - * An array of delimits detected during processing, for top-level objects. - * @param contents_delimits - * An array of delimits detected during processing, for contents. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - * - * @see fss_extended_read_main_preprocess_depth() - */ -#ifndef _di_fss_extended_read_main_process_file_ - extern f_status_t fss_extended_read_main_process_file(fll_program_data_t * const main, const f_console_arguments_t arguments, const f_string_t file_name, const fss_extended_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_main_process_file_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index a1bab6c..139496d 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -187,7 +187,7 @@ extern "C" { } } else if (main->parameters.array[fss_extended_write_parameter_file_e].result == f_console_result_found_e) { - fss_extended_write_error_parameter_value_missing_print(main, f_console_symbol_long_enable_s.string fss_extended_write_long_file_s); + fss_extended_write_error_parameter_value_missing_print(main, f_console_symbol_long_enable_s, fss_extended_write_long_file_s); status = F_status_set_error(F_parameter); } } @@ -339,7 +339,7 @@ extern "C" { if (argv[index].used) { f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); - for (; range.start < length; ++range.start) { + for (; range.start < argv[index].used; ++range.start) { status = f_fss_is_space(argv[index], range); if (F_status_is_error(status)) break; @@ -425,7 +425,6 @@ extern "C" { } f_string_dynamic_t buffer = f_string_dynamic_t_initialize; - f_string_dynamic_t object = f_string_dynamic_t_initialize; f_string_dynamics_t contents = f_string_dynamics_t_initialize; if (F_status_is_error_not(status)) { @@ -450,6 +449,7 @@ extern "C" { if (main->parameters.array[fss_extended_write_parameter_partial_e].result == f_console_result_found_e) { if (main->parameters.array[fss_extended_write_parameter_object_e].result == f_console_result_additional_e) { contents.used = 0; + uint16_t signal_check = 0; for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_write_parameter_object_e].values.used; ++i) { @@ -464,17 +464,11 @@ extern "C" { signal_check = 0; } - object.string = argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - status = fss_extended_write_process(main, output, quote, &object, 0, &buffer); + status = fss_extended_write_process(main, output, quote, &argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]], 0, &buffer); if (F_status_is_error(status)) break; } // for } else { - object.used = 0; - status = f_string_dynamics_increase_by(main->parameters.array[fss_extended_write_parameter_content_e].values.used, &contents); if (status == F_array_too_large) { @@ -493,16 +487,6 @@ extern "C" { } // for status = fss_extended_write_process(main, output, quote, 0, &contents, &buffer); - - // clear the contents array of the static strings to avoid deallocation attempts on static variables. - for (; i < main->parameters.array[fss_extended_write_parameter_content_e].values.used; ++i) { - contents.array[contents.used].string = 0; - contents.array[contents.used].used = 0; - contents.array[contents.used].size = 0; - } // for - - contents.used = 0; - contents.size = 0; } } } @@ -518,6 +502,7 @@ extern "C" { if (!((++signal_check) % fss_extended_write_signal_check_d)) { if (fss_extended_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -530,8 +515,6 @@ extern "C" { object_next = main->parameters.array[fss_extended_write_parameter_object_e].locations.array[i + 1]; } - object = argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]]; - contents.used = 0; for (; j < main->parameters.array[fss_extended_write_parameter_content_e].values.used; ++j) { @@ -554,10 +537,10 @@ extern "C" { contents.array[contents.used].used = 0; } - status = f_string_append(argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[j]], strnlen(argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[j]], F_console_parameter_size_d), &contents.array[contents.used]); + status = f_string_dynamic_append(argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[j]], &contents.array[contents.used]); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); break; } @@ -567,7 +550,7 @@ extern "C" { if (F_status_is_error(status)) break; - status = fss_extended_write_process(main, output, quote, &object, &contents, &buffer); + status = fss_extended_write_process(main, output, quote, &argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]], &contents, &buffer); if (F_status_is_error(status)) break; } // for } @@ -590,14 +573,6 @@ extern "C" { } f_string_dynamic_resize(0, &escaped); - - // Object, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). - object.string = 0; - object.used = 0; - object.size = 0; - - // Reset contents used, it is dynamically allocated so leave everything else alone. - contents.used = 0; } if (main->parameters.array[fss_extended_write_parameter_file_e].result == f_console_result_additional_e) { @@ -618,7 +593,6 @@ extern "C" { } f_string_dynamic_resize(0, &buffer); - f_string_dynamic_resize(0, &object); f_string_dynamics_resize(0, &contents); fss_extended_write_main_delete(main); diff --git a/level_3/fss_extended_write/c/private-write.c b/level_3/fss_extended_write/c/private-write.c index e0190fd..c2c0708 100644 --- a/level_3/fss_extended_write/c/private-write.c +++ b/level_3/fss_extended_write/c/private-write.c @@ -28,7 +28,7 @@ extern "C" { #endif // _di_fss_extended_write_error_parameter_at_least_once_print_ #ifndef _di_fss_extended_write_error_parameter_value_missing_print_ - void fss_extended_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_t symbol, const f_string_t parameter) { + void fss_extended_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_static_t symbol, const f_string_static_t parameter) { if (main->error.verbosity == f_console_verbosity_quiet_e) { return; diff --git a/level_3/fss_extended_write/c/private-write.h b/level_3/fss_extended_write/c/private-write.h index b5a5066..9226487 100644 --- a/level_3/fss_extended_write/c/private-write.h +++ b/level_3/fss_extended_write/c/private-write.h @@ -41,7 +41,7 @@ extern "C" { * F_failure (with error bit) for any othe failure. */ #ifndef _di_fss_extended_write_error_parameter_value_missing_print_ - void fss_extended_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_t symbol, const f_string_t parameter) F_attribute_visibility_internal_d; + void fss_extended_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_static_t symbol, const f_string_static_t parameter) F_attribute_visibility_internal_d; #endif // _di_fss_extended_write_error_parameter_value_missing_print_ /** diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 96e7c22..36e8e59 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -11,7 +11,7 @@ extern "C" { flockfile(file.stream); - fll_program_print_help_header(file, context, fss_identify_program_name_long_s, fss_identify_program_version); + fll_program_print_help_header(file, context, fss_identify_program_name_long_s, fss_identify_program_version_s); fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); @@ -140,8 +140,6 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - status = F_none; if (main->parameters.array[fss_identify_parameter_help_e].result == f_console_result_found_e) { @@ -153,7 +151,7 @@ extern "C" { } if (main->parameters.array[fss_identify_parameter_version_e].result == f_console_result_found_e) { - fll_program_print_version(main->output.to, fss_identify_program_version); + fll_program_print_version(main->output.to, fss_identify_program_version_s); fss_identify_main_delete(main); @@ -162,6 +160,8 @@ extern "C" { fss_identify_data_t data = fss_identify_data_t_initialize; + data.argv = main->parameters.arguments.array; + if (F_status_is_error_not(status)) { if (main->parameters.array[fss_identify_parameter_line_e].result == f_console_result_found_e) { flockfile(main->error.to.stream); @@ -176,12 +176,12 @@ extern "C" { } else if (main->parameters.array[fss_identify_parameter_line_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_identify_parameter_line_e].values.array[main->parameters.array[fss_identify_parameter_line_e].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); + const f_string_range_t range = macro_f_string_range_t_initialize(data.argv[index].used); - status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &data.line); + status = fl_conversion_string_to_number_unsigned(data.argv[index].string, range, &data.line); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_identify_long_line_s, argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_identify_long_line_s, data.argv[index]); } } } @@ -229,7 +229,7 @@ extern "C" { } else if (main->parameters.array[fss_identify_parameter_name_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_identify_parameter_name_e].values.array[main->parameters.array[fss_identify_parameter_name_e].values.used - 1]; - const f_array_length_t length = argv[index].used; + const f_array_length_t length = data.argv[index].used; const f_string_range_t range = macro_f_string_range_t_initialize(length); if (length == 0) { @@ -255,7 +255,7 @@ extern "C" { for (f_array_length_t i = range.start; i <= range.stop; ++i) { - status = f_utf_is_word(argv[index].string + i, length, F_true); + status = f_utf_is_word(data.argv[index].string + i, length, F_true); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_utf_is_word", F_true); @@ -266,7 +266,7 @@ extern "C" { flockfile(main->error.to.stream); fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, argv[index], main->error.notable); + fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, data.argv[index], main->error.notable); fl_print_format("%[' for the parameter '%]", main->error.to.stream, main->error.context, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_name_s, main->error.notable); fl_print_format("%[' may only contain word characters.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); @@ -278,7 +278,7 @@ extern "C" { break; } - data.name.string[data.name.used++] = argv[index].string[i]; + data.name.string[data.name.used++] = data.argv[index].string[i]; } // for } } @@ -293,10 +293,10 @@ extern "C" { file.stream = F_type_input_d; file.size_read = 512; - status = fss_identify_load_line(main, file, "-", &buffer, &range); + status = fss_identify_load_line(main, file, f_string_empty_s, &buffer, &range); if (F_status_is_error_not(status)) { - status = fss_identify_process(main, "-", buffer, &range, &data); + status = fss_identify_process(main, &data, f_string_ascii_minus_s, buffer, &range); } } @@ -322,16 +322,16 @@ extern "C" { file.size_read = 512; - status = f_file_stream_open(argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); + status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); } else { - status = fss_identify_load_line(main, file, argv[main->parameters.remaining.array[i]], &buffer, &range); + status = fss_identify_load_line(main, file, data.argv[main->parameters.remaining.array[i]], &buffer, &range); if (F_status_is_error_not(status)) { - status = fss_identify_process(main, argv[main->parameters.remaining.array[i]], buffer, &range, &data); + status = fss_identify_process(main, &data, data.argv[main->parameters.remaining.array[i]], buffer, &range); } } diff --git a/level_3/fss_identify/c/private-common.h b/level_3/fss_identify/c/private-common.h index d102665..c578f0e 100644 --- a/level_3/fss_identify/c/private-common.h +++ b/level_3/fss_identify/c/private-common.h @@ -15,10 +15,11 @@ extern "C" { /** * The data structure for FSS Identify. * + * argv: The argument structure in the progam data parameters for simplifying syntax. * current: The current position within the ids, used to determine when the line is matched. * line: The line number to select. - * total: The total ids across all files. * name: The name to select. + * total: The total ids across all files. */ #ifndef _di_fss_identify_data_t_ typedef struct { @@ -26,6 +27,8 @@ extern "C" { f_array_length_t line; f_array_length_t total; + f_string_static_t *argv; + f_string_dynamic_t name; } fss_identify_data_t; @@ -34,6 +37,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ f_string_dynamic_t_initialize, \ } #endif // _di_fss_identify_data_t_ diff --git a/level_3/fss_identify/c/private-identify.c b/level_3/fss_identify/c/private-identify.c index 2909152..4b4d6d3 100644 --- a/level_3/fss_identify/c/private-identify.c +++ b/level_3/fss_identify/c/private-identify.c @@ -22,6 +22,7 @@ extern "C" { if (!((++signal_check) % fss_identify_signal_check_d)) { if (fss_identify_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -32,7 +33,7 @@ extern "C" { status = f_string_dynamic_resize(buffer->size + file.size_read, buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, name.used ? name : f_string_ascii_s, f_file_operation_read_s, name ? fll_error_file_type_file_e : fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, name.used ? name : f_string_ascii_minus_s, f_file_operation_read_s, name.used ? fll_error_file_type_file_e : fll_error_file_type_pipe_e); return status; } @@ -41,7 +42,7 @@ extern "C" { status = f_file_stream_read_block(file, buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read_block", F_true, name.used ? name : f_string_ascii_s, f_file_operation_read_s, name ? fll_error_file_type_file_e : fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read_block", F_true, name.used ? name : f_string_ascii_minus_s, f_file_operation_read_s, name.used ? fll_error_file_type_file_e : fll_error_file_type_pipe_e); return status; } @@ -56,7 +57,7 @@ extern "C" { } while (F_status_is_error_not(status) && status != F_none_eof); - // reset the start point to prepare the buffer for processing. + // Reset the start point to prepare the buffer for processing. range->start = 0; return status; @@ -64,15 +65,15 @@ extern "C" { #endif // _di_fss_identify_load_line_ #ifndef _di_fss_identify_process_ - f_status_t fss_identify_process(fll_program_data_t * const main, const f_string_t name, const f_string_static_t buffer, f_string_range_t *range, fss_identify_data_t *data) { + f_status_t fss_identify_process(fll_program_data_t * const main, fss_identify_data_t * const data, const f_string_static_t name, const f_string_static_t buffer, f_string_range_t *range) { f_status_t status = F_none; f_fll_ids_t ids = f_fll_ids_t_initialize; - status = fll_fss_identify(buffer.string, range, &ids); + status = fll_fss_identify(buffer, range, &ids); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_identify", F_true, name.used ? name : f_string_ascii_s, f_file_operation_read_s, name.used ? fll_error_file_type_file_e : fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_identify", F_true, name.used ? name : f_string_ascii_pipe_s, f_file_operation_read_s, name.used ? fll_error_file_type_file_e : fll_error_file_type_pipe_e); f_type_fll_ids_resize(0, &ids); diff --git a/level_3/fss_identify/c/private-identify.h b/level_3/fss_identify/c/private-identify.h index 05c04bf..ab6542b 100644 --- a/level_3/fss_identify/c/private-identify.h +++ b/level_3/fss_identify/c/private-identify.h @@ -37,7 +37,7 @@ extern "C" { * @see f_string_dynamic_resize() */ #ifndef _di_fss_identify_load_line_ - extern f_status_t fss_identify_load_line(fll_program_data_t * const main, const f_file_t file, const f_string_t name, f_string_static_t *buffer, f_string_range_t *range) F_attribute_visibility_internal_d; + extern f_status_t fss_identify_load_line(fll_program_data_t * const main, const f_file_t file, const f_string_static_t name, f_string_static_t *buffer, f_string_range_t *range) F_attribute_visibility_internal_d; #endif // _di_fss_identify_load_line_ /** @@ -45,6 +45,8 @@ extern "C" { * * @param main * The main program data. + * @param data + * The program data. * @param name * The name of the file. * Set to NULL to designate that this is a pipe. @@ -52,8 +54,6 @@ extern "C" { * The string representing the file to process. * @param range * The range representing the line in the buffer. - * @param data - * The program data. * * @return * F_none on success. @@ -63,7 +63,7 @@ extern "C" { * @see fll_fss_identify() */ #ifndef _di_fss_identify_process_ - extern f_status_t fss_identify_process(fll_program_data_t * const main, const f_string_t name, const f_string_static_t buffer, f_string_range_t *range, fss_identify_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_identify_process(fll_program_data_t * const main, fss_identify_data_t * const data, const f_string_static_t name, const f_string_static_t buffer, f_string_range_t *range) F_attribute_visibility_internal_d; #endif // _di_fss_identify_process_ #ifdef __cplusplus diff --git a/level_3/fss_identify/c/private-print.c b/level_3/fss_identify/c/private-print.c index bc8b53b..a5dcfac 100644 --- a/level_3/fss_identify/c/private-print.c +++ b/level_3/fss_identify/c/private-print.c @@ -7,12 +7,12 @@ extern "C" { #endif #ifndef _di_fss_identify_print_ - void fss_identify_print(fll_program_data_t * const main, f_fll_id_t id) { + void fss_identify_print(fll_program_data_t * const main, const f_fll_id_t id) { flockfile(main->output.to.stream); if (main->parameters.array[fss_identify_parameter_object_e].result == f_console_result_found_e || main->parameters.array[fss_identify_parameter_content_e].result != f_console_result_found_e) { - f_print(id.name, id.used, main->output.to.stream); + f_print((const f_string_t) id.name, id.used, main->output.to.stream); if (main->parameters.array[fss_identify_parameter_object_e].result != f_console_result_found_e || main->parameters.array[fss_identify_parameter_content_e].result == f_console_result_found_e) { f_print_dynamic_raw(f_fss_type_header_part5_s, main->output.to.stream); diff --git a/level_3/fss_identify/c/private-print.h b/level_3/fss_identify/c/private-print.h index a03314d..8ebcb57 100644 --- a/level_3/fss_identify/c/private-print.h +++ b/level_3/fss_identify/c/private-print.h @@ -21,7 +21,7 @@ extern "C" { * The Identifier to print. */ #ifndef _di_fss_identify_print_ - extern void fss_identify_print(fll_program_data_t * const main, f_fll_id_t id) F_attribute_visibility_internal_d; + extern void fss_identify_print(fll_program_data_t * const main, const f_fll_id_t id) F_attribute_visibility_internal_d; #endif // _di_fss_identify_print_ #ifdef __cplusplus diff --git a/level_3/fss_payload_read/c/common.c b/level_3/fss_payload_read/c/common.c index 61f353e..1f472c2 100644 --- a/level_3/fss_payload_read/c/common.c +++ b/level_3/fss_payload_read/c/common.c @@ -5,6 +5,8 @@ extern "C" { #endif #ifndef _di_fss_payload_read_defines_ + const f_string_static_t fss_payload_read_pipe_name_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_pipe_name_s, 0, FSS_PAYLOAD_READ_pipe_name_s_length); + const f_string_static_t fss_payload_read_pipe_content_end_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_pipe_content_end_s, 0, FSS_PAYLOAD_READ_pipe_content_end_s_length); const f_string_static_t fss_payload_read_pipe_content_ignore_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_pipe_content_ignore_s, 0, FSS_PAYLOAD_READ_pipe_content_ignore_s_length); const f_string_static_t fss_payload_read_pipe_content_start_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_pipe_content_start_s, 0, FSS_PAYLOAD_READ_pipe_content_start_s_length); diff --git a/level_3/fss_payload_read/c/common.h b/level_3/fss_payload_read/c/common.h index 9ffe698..9755de2 100644 --- a/level_3/fss_payload_read/c/common.h +++ b/level_3/fss_payload_read/c/common.h @@ -65,17 +65,23 @@ extern "C" { #ifndef _di_fss_payload_read_defines_ #define fss_payload_read_signal_check_d 10000 - #define FSS_PAYLOAD_READ_pipe_content_end_s '\f' - #define FSS_PAYLOAD_READ_pipe_content_ignore_s '\v' - #define FSS_PAYLOAD_READ_pipe_content_start_s '\b' + #define FSS_PAYLOAD_READ_pipe_name_s "(pipe)" + + #define FSS_PAYLOAD_READ_pipe_content_end_s "\f" + #define FSS_PAYLOAD_READ_pipe_content_ignore_s "\v" + #define FSS_PAYLOAD_READ_pipe_content_start_s "\b" + + #define FSS_PAYLOAD_READ_pipe_name_s_length 6 #define FSS_PAYLOAD_READ_pipe_content_end_s_length 1 #define FSS_PAYLOAD_READ_pipe_content_ignore_s_length 1 #define FSS_PAYLOAD_READ_pipe_content_start_s_length 1 - extern const fss_payload_read_pipe_content_end_s; - extern const fss_payload_read_pipe_content_ignore_s; - extern const fss_payload_read_pipe_content_start_s; + extern const f_string_static_t fss_payload_read_pipe_name_s; + + extern const f_string_static_t fss_payload_read_pipe_content_end_s; + extern const f_string_static_t fss_payload_read_pipe_content_ignore_s; + extern const f_string_static_t fss_payload_read_pipe_content_start_s; #endif // _di_fss_payload_read_defines_ /** @@ -226,7 +232,7 @@ extern "C" { macro_f_console_parameter_t_initialize(fss_payload_read_short_trim_s.string, fss_payload_read_long_trim_s.string, 0, 0, f_console_type_normal_e), \ } - #define fss_payload_total_parameters_d 23 + #define fss_payload_read_total_parameters_d 23 #endif // _di_fss_payload_read_parameters_ /** diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c index 425f825..6a582b4 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -21,7 +21,7 @@ extern "C" { flockfile(file.stream); - fll_program_print_help_header(file, context, fss_payload_program_name_long_s, fss_payload_program_version_s); + fll_program_print_help_header(file, context, fss_payload_read_program_name_long_s, fss_payload_read_program_version_s); fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); @@ -50,7 +50,7 @@ extern "C" { fll_program_print_help_option(file, context, fss_payload_read_short_total_s, fss_payload_read_long_total_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); fll_program_print_help_option(file, context, fss_payload_read_short_trim_s, fss_payload_read_long_trim_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); - fll_program_print_help_usage(file, context, fss_payload_program_name_s, fll_program_parameter_filenames_s); + fll_program_print_help_usage(file, context, fss_payload_read_program_name_s, fll_program_parameter_filenames_s); fl_print_format(" %[Notes:%]%r", file.stream, context.set.important, context.set.important, f_string_eol_s); @@ -214,21 +214,21 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; - status = F_none; if (main->parameters.array[fss_payload_read_parameter_help_e].result == f_console_result_found_e) { fss_payload_read_print_help(main->output.to, main->context); fss_payload_read_main_delete(main); + return status; } if (main->parameters.array[fss_payload_read_parameter_version_e].result == f_console_result_found_e) { - fll_program_print_version(main->output.to, fss_payload_program_version_s); + fll_program_print_version(main->output.to, fss_payload_read_program_version_s); fss_payload_read_main_delete(main); + return status; } @@ -236,6 +236,7 @@ extern "C" { fss_payload_read_file_t files_array[main->parameters.remaining.used + 1]; fss_payload_read_data_t data = fss_payload_read_data_t_initialize; + data.argv = main->parameters.arguments.array; data.files.array = files_array; data.files.used = 1; data.files.size = main->parameters.remaining.used + 1; @@ -302,7 +303,7 @@ extern "C" { fss_payload_read_parameter_total_e, }; - const f_string_t parameter_name[] = { + const f_string_static_t parameter_name[] = { fss_payload_read_long_depth_s, fss_payload_read_long_line_s, fss_payload_read_long_pipe_s, @@ -332,6 +333,7 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } } // for @@ -367,7 +369,7 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_payload_read_parameter_delimit_e].result == f_console_result_additional_e) { - f_array_length_t location = 0; + f_array_length_t index = 0; f_array_length_t length = 0; uint16_t signal_check = 0; @@ -379,14 +381,15 @@ extern "C" { if (!((++signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } signal_check = 0; } - location = main->parameters.array[fss_payload_read_parameter_delimit_e].values.array[i]; - length = strnlen(arguments->argv[location], F_console_parameter_size_d); + index = main->parameters.array[fss_payload_read_parameter_delimit_e].values.array[i]; + length = data.argv[index].used; if (!length) { flockfile(main->error.to.stream); @@ -398,15 +401,16 @@ extern "C" { funlockfile(main->error.to.stream); status = F_status_set_error(F_parameter); + break; } - else if (fl_string_compare(arguments->argv[location], fss_payload_read_delimit_mode_name_none_s, length, fss_payload_read_delimit_mode_name_none_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare(data.argv[index], fss_payload_read_delimit_mode_name_none_s) == F_equal_to) { data.delimit_mode = fss_payload_read_delimit_mode_none_e; } - else if (fl_string_compare(arguments->argv[location], fss_payload_read_delimit_mode_name_all_s, length, fss_payload_read_delimit_mode_name_all_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare(data.argv[index], fss_payload_read_delimit_mode_name_all_s) == F_equal_to) { data.delimit_mode = fss_payload_read_delimit_mode_all_e; } - else if (fl_string_compare(arguments->argv[location], fss_payload_read_delimit_mode_name_object_s, length, fss_payload_read_delimit_mode_name_object_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare(data.argv[index], fss_payload_read_delimit_mode_name_object_s) == F_equal_to) { switch (data.delimit_mode) { case 0: data.delimit_mode = fss_payload_read_delimit_mode_object_e; @@ -443,7 +447,7 @@ extern "C" { data.delimit_mode = fss_payload_read_delimit_mode_content_object_e; } - if (arguments->argv[location][length - 1] == fss_payload_read_delimit_mode_name_greater_s.string[0]) { + if (data.argv[index].string[length - 1] == fss_payload_read_delimit_mode_name_greater_s.string[0]) { if (!(data.delimit_mode == fss_payload_read_delimit_mode_none_e || data.delimit_mode == fss_payload_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_payload_read_delimit_mode_content_object_e) { data.delimit_mode = fss_payload_read_delimit_mode_content_greater_object_e; @@ -456,7 +460,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (arguments->argv[location][length - 1] == fss_payload_read_delimit_mode_name_lesser_s.string[0]) { + else if (data.argv[index].string[length - 1] == fss_payload_read_delimit_mode_name_lesser_s.string[0]) { if (!(data.delimit_mode == fss_payload_read_delimit_mode_none_e || data.delimit_mode == fss_payload_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_payload_read_delimit_mode_content_object_e) { data.delimit_mode = fss_payload_read_delimit_mode_content_lesser_object_e; @@ -473,14 +477,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (arguments->argv[location][0] == '+') { + if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { ++range.start; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[location], range, &data.delimit_depth); + status = fl_conversion_string_to_number_unsigned(data.argv[index].string, range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_payload_read_long_delimit_s, arguments->argv[location]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_payload_read_long_delimit_s, data.argv[index]); break; } @@ -506,7 +510,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fss_payload_read_depth_process(main, arguments, &data); + status = fss_payload_read_depth_process(main, &data); } // This standard only partially supports nesting, so any depth greater than 1 can be predicted without processing the file. @@ -565,7 +569,7 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, f_string_ascii_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); } else if (data.buffer.used) { data.files.array[0].range.stop = data.buffer.used - 1; @@ -575,7 +579,7 @@ extern "C" { status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_assure", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); } } else { @@ -605,10 +609,10 @@ extern "C" { file.stream = 0; file.id = -1; - status = f_file_stream_open(arguments->argv[main->parameters.remaining.array[i]], 0, &file); + status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -617,7 +621,7 @@ extern "C" { status = f_file_size_by_id(file.id, &size_file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -639,12 +643,12 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } else if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = arguments->argv[main->parameters.remaining.array[i]]; + data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; } } @@ -659,7 +663,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fss_payload_read_process(main, arguments, &data); + status = fss_payload_read_process(main, &data); } fss_payload_read_data_delete_simple(&data); diff --git a/level_3/fss_payload_read/c/private-common.h b/level_3/fss_payload_read/c/private-common.h index 8e3ea3e..4d9f3b0 100644 --- a/level_3/fss_payload_read/c/private-common.h +++ b/level_3/fss_payload_read/c/private-common.h @@ -141,6 +141,7 @@ extern "C" { * - 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). * + * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. * delimit_mode: The delimit mode. * delimit_depth: The delimit depth. @@ -180,6 +181,8 @@ extern "C" { f_number_unsigned_t select; f_number_unsigned_t line; + f_string_static_t *argv; + fss_payload_read_files_t files; fss_payload_read_depths_t depths; @@ -206,6 +209,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ fss_payload_read_files_t_initialize, \ fss_payload_read_depths_t_initialize, \ f_string_dynamic_t_initialize, \ diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index 1a8b98e..fd558a9 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -8,7 +8,7 @@ extern "C" { #endif #ifndef _di_fss_payload_read_delimit_content_is_ - f_status_t fss_payload_read_delimit_content_is(const f_array_length_t depth, fss_payload_read_data_t * const data) { + f_status_t fss_payload_read_delimit_content_is(fss_payload_read_data_t * const data, const f_array_length_t depth) { if (data->delimit_mode == fss_payload_read_delimit_mode_none_e) { return F_false; @@ -31,7 +31,7 @@ extern "C" { #endif // _di_fss_payload_read_delimit_content_is_ #ifndef _di_fss_payload_read_delimit_object_is_ - f_status_t fss_payload_read_delimit_object_is(const f_array_length_t depth, fss_payload_read_data_t * const data) { + f_status_t fss_payload_read_delimit_object_is(fss_payload_read_data_t * const data, const f_array_length_t depth) { switch (data->delimit_mode) { case fss_payload_read_delimit_mode_none_e: @@ -56,7 +56,7 @@ extern "C" { #endif // _di_fss_payload_read_delimit_object_is_ #ifndef _di_fss_payload_read_depth_process_ - f_status_t fss_payload_read_depth_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_payload_read_data_t *data) { + f_status_t fss_payload_read_depth_process(fll_program_data_t * const main, fss_payload_read_data_t * const data) { f_status_t status = F_none; @@ -108,12 +108,12 @@ extern "C" { else { position_depth = main->parameters.array[fss_payload_read_parameter_depth_e].values.array[i]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[position_depth])); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[position_depth].used); - status = fl_conversion_string_to_number_unsigned(arguments->argv[position_depth], range, &data->depths.array[i].depth); + status = fl_conversion_string_to_number_unsigned(data->argv[position_depth].string, range, &data->depths.array[i].depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_payload_read_long_depth_s, arguments->argv[position_depth]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_payload_read_long_depth_s, data->argv[position_depth]); return status; } @@ -132,12 +132,12 @@ extern "C" { data->depths.array[i].index_at = main->parameters.array[fss_payload_read_parameter_at_e].values.array[position_at]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[data->depths.array[i].index_at])); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[data->depths.array[i].index_at].used); - status = fl_conversion_string_to_number_unsigned(arguments->argv[data->depths.array[i].index_at], range, &data->depths.array[i].value_at); + status = fl_conversion_string_to_number_unsigned(data->argv[data->depths.array[i].index_at].string, range, &data->depths.array[i].value_at); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_payload_read_long_at_s, arguments->argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_payload_read_long_at_s, data->argv[data->depths.array[i].index_at]); return status; } @@ -158,14 +158,14 @@ extern "C" { data->depths.array[i].index_name = main->parameters.array[fss_payload_read_parameter_name_e].values.array[position_name]; if (main->parameters.array[fss_payload_read_parameter_trim_e].result == f_console_result_found_e) { - status = fl_string_rip(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = fl_string_rip(data->argv[data->depths.array[i].index_name].string, data->argv[data->depths.array[i].index_name].used, &data->depths.array[i].value_name); } else { - status = f_string_append(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_payload_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_rip" : "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_payload_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_rip" : "f_string_dynamic_append", F_true); return status; } @@ -244,7 +244,7 @@ extern "C" { #endif // _di_fss_payload_read_file_identify_ #ifndef _di_fss_payload_read_load_ - f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t *data) { + f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_payload_read_common_allocation_large_d, fss_payload_read_common_allocation_small_d, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); @@ -314,16 +314,16 @@ extern "C" { #endif // _di_fss_payload_read_load_ #ifndef _di_fss_payload_read_load_number_ - f_status_t fss_payload_read_load_number(fll_program_data_t * const main, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_payload_read_load_number(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(strnlen(main->parameters.arguments.array[index], F_console_parameter_size_d)); + const f_string_range_t range = macro_f_string_range_t_initialize(data->argv[index].used); - const f_status_t status = fl_conversion_string_to_number_unsigned(main->parameters.arguments.array[index].string, range, number); + const f_status_t status = fl_conversion_string_to_number_unsigned(data->argv[index].string, range, number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, main->parameters.arguments.array[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, data->argv[index]); return status; } @@ -336,9 +336,9 @@ extern "C" { #endif // _di_fss_payload_read_load_number_ #ifndef _di_fss_payload_read_process_ - f_status_t fss_payload_read_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_payload_read_data_t *data) { + f_status_t fss_payload_read_process(fll_program_data_t * const main, fss_payload_read_data_t * const data) { - f_status_t status = fss_payload_read_process_option(main, arguments, data); + f_status_t status = fss_payload_read_process_option(main, data); if (F_status_is_error(status)) return status; // This standard does not support multiple content groups, except for "headers" FSS-0001 Extended at depth 1. @@ -406,8 +406,8 @@ extern "C" { } f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(0, data) ? &data->delimits_object_header : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is((data->option & fss_payload_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content_header : &except_none; + f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object_header : &except_none; + f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, (data->option & fss_payload_read_data_option_select_d) ? data->select : 0) ? &data->delimits_content_header : &except_none; if (data->option & fss_payload_read_data_option_raw_d) { delimits_object = &except_none; @@ -441,8 +441,8 @@ extern "C" { } f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; + f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; uint16_t signal_check = 0; bool is_payload = F_false; @@ -473,7 +473,7 @@ extern "C" { #endif // _di_fss_payload_read_process_ #ifndef _di_fss_payload_read_process_at_ - f_status_t fss_payload_read_process_at(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_at(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { if (data->depths.array[0].value_at >= data->objects.used) { if (data->option & (fss_payload_read_data_option_columns_d | fss_payload_read_data_option_total_d)) { @@ -488,8 +488,8 @@ extern "C" { } f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; + f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; if (data->option & fss_payload_read_data_option_raw_d) { delimits_object = &except_none; @@ -517,7 +517,7 @@ extern "C" { if (data->option & fss_payload_read_data_option_line_d) { f_array_length_t line = 0; - status = fss_payload_read_process_at_line(main, i, *delimits_object, *delimits_content, data, &line); + status = fss_payload_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); if (status == F_success) return F_none; } else if (data->option & fss_payload_read_data_option_columns_d) { @@ -560,7 +560,7 @@ extern "C" { #endif // _di_fss_payload_read_process_at_ #ifndef _di_fss_payload_read_process_at_extended_ - f_status_t fss_payload_read_process_at_extended(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_at_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { if (data->depths.array[data->depths.used - 1].value_at >= data->objects_header.used) { if (data->option & (fss_payload_read_data_option_columns_d | fss_payload_read_data_option_total_d)) { @@ -590,8 +590,8 @@ extern "C" { } f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(0, data) ? &data->delimits_object_header : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is((data->option & fss_payload_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content_header : &except_none; + f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object_header : &except_none; + f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, (data->option & fss_payload_read_data_option_select_d) ? data->select : 0) ? &data->delimits_content_header : &except_none; if (data->option & fss_payload_read_data_option_raw_d) { delimits_object = &except_none; @@ -666,7 +666,7 @@ extern "C" { #endif // _di_fss_payload_read_process_at_extended_ #ifndef _di_fss_payload_read_process_at_line_ - f_status_t fss_payload_read_process_at_line(fll_program_data_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_payload_read_data_t *data, f_array_length_t *line) { + f_status_t fss_payload_read_process_at_line(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) { if (data->option & fss_payload_read_data_option_object_d) { if (*line == data->line) { @@ -770,7 +770,7 @@ extern "C" { #endif // _di_fss_payload_read_process_at_line_ #ifndef _di_fss_payload_read_process_columns_ - f_status_t fss_payload_read_process_columns(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_columns(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { if (!(data->option & fss_payload_read_data_option_content_d)) { flockfile(main->output.to.stream); @@ -809,7 +809,7 @@ extern "C" { #endif // _di_fss_payload_read_process_columns_ #ifndef _di_fss_payload_read_process_columns_extended_ - f_status_t fss_payload_read_process_columns_extended(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_columns_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { if (!(data->option & fss_payload_read_data_option_content_d)) { flockfile(main->output.to.stream); @@ -839,11 +839,11 @@ extern "C" { #endif // _di_fss_payload_read_process_columns_extended_ #ifndef _di_fss_payload_read_process_line_ - f_status_t fss_payload_read_process_line(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_line(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(0, data) ? &data->delimits_content : &except_none; + f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; + f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; if (data->option & fss_payload_read_data_option_raw_d) { delimits_object = &except_none; @@ -866,7 +866,7 @@ extern "C" { signal_check = 0; } - status = fss_payload_read_process_at_line(main, i, *delimits_object, *delimits_content, data, &line); + status = fss_payload_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); if (status == F_success) break; } // for @@ -875,11 +875,11 @@ extern "C" { #endif // _di_fss_payload_read_process_line_ #ifndef _di_fss_payload_read_process_line_extended_ - f_status_t fss_payload_read_process_line_extended(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_line_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(0, data) ? &data->delimits_object_header : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is((data->option & fss_payload_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content_header : &except_none; + f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object_header : &except_none; + f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, (data->option & fss_payload_read_data_option_select_d) ? data->select : 0) ? &data->delimits_content_header : &except_none; if (data->option & fss_payload_read_data_option_raw_d) { delimits_object = &except_none; @@ -926,7 +926,7 @@ extern "C" { #endif // _di_fss_payload_read_process_line_extended_ #ifndef _di_fss_payload_read_process_name_ - f_status_t fss_payload_read_process_name(fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_name(fss_payload_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; @@ -952,7 +952,7 @@ extern "C" { #endif // _di_fss_payload_read_process_name_ #ifndef _di_fss_payload_read_process_name_extended_ - f_status_t fss_payload_read_process_name_extended(fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_name_extended(fss_payload_read_data_t * const data, bool names[]) { f_array_lengths_t except_none = f_array_lengths_t_initialize; @@ -987,7 +987,7 @@ extern "C" { #endif // _di_fss_payload_read_process_name_extended_ #ifndef _di_fss_payload_read_process_option_ - f_status_t fss_payload_read_process_option(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_payload_read_data_t *data) { + f_status_t fss_payload_read_process_option(fll_program_data_t * const main, fss_payload_read_data_t * const data) { f_status_t status = F_none; @@ -1010,7 +1010,7 @@ extern "C" { if (main->parameters.array[fss_payload_read_parameter_line_e].result == f_console_result_additional_e) { data->option |= fss_payload_read_data_option_line_d; - status = fss_payload_read_load_number(main, fss_payload_read_parameter_line_e, fss_payload_read_long_line_s, &data->line); + status = fss_payload_read_load_number(main, data, fss_payload_read_parameter_line_e, fss_payload_read_long_line_s, &data->line); if (F_status_is_error(status)) return status; } @@ -1029,7 +1029,7 @@ extern "C" { if (main->parameters.array[fss_payload_read_parameter_select_e].result == f_console_result_additional_e) { data->option |= fss_payload_read_data_option_select_d; - status = fss_payload_read_load_number(main, fss_payload_read_parameter_select_e, fss_payload_read_long_select_s, &data->select); + status = fss_payload_read_load_number(main, data, fss_payload_read_parameter_select_e, fss_payload_read_long_select_s, &data->select); if (F_status_is_error(status)) return status; } @@ -1051,7 +1051,7 @@ extern "C" { #endif // _di_fss_payload_read_process_option_ #ifndef _di_fss_payload_read_process_total_ - f_status_t fss_payload_read_process_total(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_total(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { f_array_length_t total = 0; f_string_range_t range = f_string_range_t_initialize; @@ -1126,7 +1126,7 @@ extern "C" { #endif // _di_fss_payload_read_process_total_ #ifndef _di_fss_payload_read_process_total_extended_ - f_status_t fss_payload_read_process_total_extended(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) { + f_status_t fss_payload_read_process_total_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { f_array_length_t total = 0; diff --git a/level_3/fss_payload_read/c/private-read.h b/level_3/fss_payload_read/c/private-read.h index cfe60df..e614965 100644 --- a/level_3/fss_payload_read/c/private-read.h +++ b/level_3/fss_payload_read/c/private-read.h @@ -25,23 +25,23 @@ extern "C" { * F_false if to not apply delimits. */ #ifndef _di_fss_payload_read_delimit_content_is_ - extern f_status_t fss_payload_read_delimit_content_is(const f_array_length_t depth, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_delimit_content_is(fss_payload_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_delimit_content_is_ /** * Determine if the given depth is to be delimited or not for an Object. * - * @param depth - * The depth to check. * @param data * The program data. + * @param depth + * The depth to check. * * @return * F_true if to apply delimits. * F_false if to not apply delimits. */ #ifndef _di_fss_payload_read_delimit_object_is_ - extern f_status_t fss_payload_read_delimit_object_is(const f_array_length_t depth, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_delimit_object_is(fss_payload_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_delimit_object_is_ /** @@ -74,7 +74,7 @@ extern "C" { * @see fss_payload_read_depths_resize() */ #ifndef _di_fss_payload_read_depth_process_ - extern f_status_t fss_payload_read_depth_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_payload_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_depth_process(fll_program_data_t * const main, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_depth_process_ /** @@ -118,7 +118,7 @@ extern "C" { * @see fss_payload_read_process_option() */ #ifndef _di_fss_payload_read_load_ - extern f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_load_ /** @@ -128,6 +128,8 @@ extern "C" { * * @param main * The main program data. + * @param data + * The program data. * @param parameter * An ID representing the parameter. * @param name @@ -146,7 +148,7 @@ extern "C" { * @see fss_payload_read_depths_resize() */ #ifndef _di_fss_payload_read_load_number_ - extern f_status_t fss_payload_read_load_number(fll_program_data_t * const main, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_load_number(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_load_number_ /** @@ -156,8 +158,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -171,7 +171,7 @@ extern "C" { * @see fss_payload_read_process_option() */ #ifndef _di_fss_payload_read_process_ - extern f_status_t fss_payload_read_process(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_payload_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process(fll_program_data_t * const main, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_ /** @@ -191,7 +191,7 @@ extern "C" { * @see fss_payload_read_process_at_line() */ #ifndef _di_fss_payload_read_process_at_ - extern f_status_t fss_payload_read_process_at(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_at(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_at_ /** @@ -211,7 +211,7 @@ extern "C" { * @see fss_payload_read_process_at_line() */ #ifndef _di_fss_payload_read_process_at_extended_ - extern f_status_t fss_payload_read_process_at_extended(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_at_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_at_extended_ /** @@ -219,12 +219,12 @@ extern "C" { * * @param main * The main program data. + * @param data + * The program data. * @param delimits_object * The delimits to be applied to an Object. * @param delimits_content * The delimits to be applied to Content. - * @param data - * The program data. * @param line * The current line being processed. * This will be incremented as necessary. @@ -234,7 +234,7 @@ extern "C" { * F_success on success and the line was matched (and possibly printed). */ #ifndef _di_fss_payload_read_process_at_line_ - extern f_status_t fss_payload_read_process_at_line(fll_program_data_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, fss_payload_read_data_t *data, f_array_length_t *line) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_at_line(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_at_line_ /** @@ -252,7 +252,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_payload_read_process_columns_ - extern f_status_t fss_payload_read_process_columns(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_columns(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_columns_ /** @@ -270,7 +270,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_payload_read_process_columns_extended_ - extern f_status_t fss_payload_read_process_columns_extended(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_columns_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_columns_extended_ /** @@ -288,7 +288,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_payload_read_process_line_ - extern f_status_t fss_payload_read_process_line(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_line(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_line_ /** @@ -306,7 +306,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_payload_read_process_line_extended_ - extern f_status_t fss_payload_read_process_line_extended(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_line_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_line_extended_ /** @@ -324,7 +324,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_payload_read_process_name_ - extern f_status_t fss_payload_read_process_name(fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_name(fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_name_ /** @@ -342,7 +342,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_payload_read_process_name_extended_ - extern f_status_t fss_payload_read_process_name_extended(fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_name_extended(fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_name_extended_ /** @@ -350,8 +350,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The parameters passed to the process. * @param data * The program data. * @@ -365,7 +363,7 @@ extern "C" { * @see fss_payload_read_load_setting() */ #ifndef _di_fss_payload_read_process_option_ - extern f_status_t fss_payload_read_process_option(fll_program_data_t * const main, const f_console_arguments_t *arguments, fss_payload_read_data_t *data) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_option(fll_program_data_t * const main, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_option_ /** @@ -383,7 +381,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_payload_read_process_total_ - extern f_status_t fss_payload_read_process_total(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_total(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_total_ /** @@ -401,7 +399,7 @@ extern "C" { * F_none on success. */ #ifndef _di_fss_payload_read_process_total_extended_ - extern f_status_t fss_payload_read_process_total_extended(fll_program_data_t * const main, fss_payload_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; + extern f_status_t fss_payload_read_process_total_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_process_total_extended_ #ifdef __cplusplus diff --git a/level_3/fss_payload_write/c/common.c b/level_3/fss_payload_write/c/common.c index 2a8a2aa..50e369a 100644 --- a/level_3/fss_payload_write/c/common.c +++ b/level_3/fss_payload_write/c/common.c @@ -10,7 +10,7 @@ extern "C" { const f_string_static_t fss_payload_write_pipe_content_start_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_pipe_content_start_s, 0, FSS_PAYLOAD_WRITE_pipe_content_start_s_length); #endif // _di_fss_payload_write_defines_ -##ifndef _di_fss_payload_write_parameters_ +#ifndef _di_fss_payload_write_parameters_ const f_string_static_t fss_payload_write_short_file_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_file_s, 0, FSS_PAYLOAD_WRITE_short_file_s_length); const f_string_static_t fss_payload_write_short_content_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_content_s, 0, FSS_PAYLOAD_WRITE_short_content_s_length); const f_string_static_t fss_payload_write_short_double_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_double_s, 0, FSS_PAYLOAD_WRITE_short_double_s_length); diff --git a/level_3/fss_payload_write/c/fss_payload_write.c b/level_3/fss_payload_write/c/fss_payload_write.c index 77be49d..4399f15 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.c +++ b/level_3/fss_payload_write/c/fss_payload_write.c @@ -187,10 +187,10 @@ extern "C" { output.id = -1; output.stream = 0; - status = f_file_stream_open(arguments->argv[location], 0, &output); + status = f_file_stream_open(argv[location], f_string_empty_s, &output); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[location], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[location], f_file_operation_open_s, fll_error_file_type_file_e); } } } @@ -328,18 +328,13 @@ extern "C" { } else if (main->parameters.array[fss_payload_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_prepend_e].values.array[main->parameters.array[fss_payload_write_parameter_prepend_e].values.used - 1]; - const f_array_length_t length = strnlen(arguments->argv[index], F_console_parameter_size_d); - if (length) { - f_string_range_t range = macro_f_string_range_t_initialize(length); + if (argv[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); - main->prepend.string = arguments->argv[index]; - main->prepend.used = length; - main->prepend.size = length; + for (; range.start < argv[index].used; range.start++) { - for (; range.start < length; range.start++) { - - status = f_fss_is_space(main->prepend, range); + status = f_fss_is_space(argv[index], range); if (F_status_is_error(status)) break; if (status == F_false) { @@ -422,8 +417,6 @@ extern "C" { } f_string_dynamic_t buffer = f_string_dynamic_t_initialize; - f_string_dynamic_t object = f_string_dynamic_t_initialize; - f_string_dynamic_t content = f_string_dynamic_t_initialize; // @todo Go through the list of Objects, if given, and confirm that payload is specified and is specified last, otherwise error out. // @todo a new parameter needs to exist for specifying that a Content is a payload for cases where Object is not given (and then this needs to verify that only a single Content is given). @@ -454,14 +447,11 @@ extern "C" { if (fss_payload_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } - object.string = arguments->argv[main->parameters.array[fss_payload_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - status = fss_payload_write_process(main, output, quote, &object, 0, &buffer); + status = fss_payload_write_process(main, output, quote, &argv[main->parameters.array[fss_payload_write_parameter_object_e].values.array[i]], 0, &buffer); if (F_status_is_error(status)) break; } // for } @@ -470,14 +460,11 @@ extern "C" { if (fss_payload_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } - content.string = arguments->argv[main->parameters.array[fss_payload_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_payload_write_process(main, output, quote, 0, &content, &buffer); + status = fss_payload_write_process(main, output, quote, 0, &argv[main->parameters.array[fss_payload_write_parameter_content_e].values.array[i]], &buffer); if (F_status_is_error(status)) break; } // for } @@ -487,18 +474,11 @@ extern "C" { if (fss_payload_write_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } - object.string = arguments->argv[main->parameters.array[fss_payload_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - content.string = arguments->argv[main->parameters.array[fss_payload_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_payload_write_process(main, output, quote, &object, &content, &buffer); + status = fss_payload_write_process(main, output, quote, &argv[main->parameters.array[fss_payload_write_parameter_object_e].values.array[i]], &argv[main->parameters.array[fss_payload_write_parameter_content_e].values.array[i]], &buffer); if (F_status_is_error(status)) break; } // for } @@ -521,15 +501,6 @@ extern "C" { } f_string_dynamic_resize(0, &escaped); - - // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). - object.string = 0; - object.used = 0; - object.size = 0; - - content.string = 0; - content.used = 0; - content.size = 0; } if (main->parameters.array[fss_payload_write_parameter_file_e].result == f_console_result_additional_e) { @@ -546,8 +517,6 @@ extern "C" { } f_string_dynamic_resize(0, &buffer); - f_string_dynamic_resize(0, &object); - f_string_dynamic_resize(0, &content); fss_payload_write_main_delete(main); return status; diff --git a/level_3/fss_payload_write/c/private-write.c b/level_3/fss_payload_write/c/private-write.c index c2358b8..162ac5f 100644 --- a/level_3/fss_payload_write/c/private-write.c +++ b/level_3/fss_payload_write/c/private-write.c @@ -45,7 +45,7 @@ extern "C" { #endif // _di_fss_payload_write_error_parameter_unsupported_eol_print_ #ifndef _di_fss_payload_write_error_parameter_value_missing_print_ - void fss_payload_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_t symbol, const f_string_t parameter) { + void fss_payload_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_static_t symbol, const f_string_static_t parameter) { if (main->error.verbosity == f_console_verbosity_quiet_e) { return; @@ -85,7 +85,15 @@ extern "C" { range.stop = 0; } - status = fll_fss_payload_write_string(*object, *content, trim, &main->prepend, state, buffer); + const f_string_static_t *prepend = 0; + + if (main->parameters.array[fss_payload_write_parameter_prepend_e].result == f_console_result_additional_e) { + const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_prepend_e].values.array[main->parameters.array[fss_payload_write_parameter_prepend_e].values.used - 1]; + + prepend = &main->parameters.arguments.array[index]; + } + + status = fll_fss_payload_write_string(*object, *content, trim, prepend, state, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_payload_write_error_parameter_unsupported_eol_print(main); @@ -140,7 +148,15 @@ extern "C" { range.start = 0; range.stop = content->used - 1; - status = fl_fss_basic_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, &main->prepend, state, &range, buffer); + const f_string_static_t *prepend = 0; + + if (main->parameters.array[fss_payload_write_parameter_prepend_e].result == f_console_result_additional_e) { + const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_prepend_e].values.array[main->parameters.array[fss_payload_write_parameter_prepend_e].values.used - 1]; + + prepend = &main->parameters.arguments.array[index]; + } + + status = fl_fss_basic_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, prepend, state, &range, buffer); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fl_fss_payload_content_write", F_true); diff --git a/level_3/fss_payload_write/c/private-write.h b/level_3/fss_payload_write/c/private-write.h index ffe2782..f4d673b 100644 --- a/level_3/fss_payload_write/c/private-write.h +++ b/level_3/fss_payload_write/c/private-write.h @@ -43,7 +43,7 @@ extern "C" { * The parameter name, such as "help" in "--help". */ #ifndef _di_fss_payload_write_error_parameter_value_missing_print_ - void fss_payload_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_t symbol, const f_string_t parameter) F_attribute_visibility_internal_d; + void fss_payload_write_error_parameter_value_missing_print(fll_program_data_t * const main, const f_string_static_t symbol, const f_string_static_t parameter) F_attribute_visibility_internal_d; #endif // _di_fss_payload_write_error_parameter_value_missing_print_ /** diff --git a/level_3/utf8/c/private-common.h b/level_3/utf8/c/private-common.h index ee6b9bb..3baa637 100644 --- a/level_3/utf8/c/private-common.h +++ b/level_3/utf8/c/private-common.h @@ -37,8 +37,8 @@ extern "C" { /** * The program data. * + * argv: The argument structure in the progam data parameters for simplifying syntax. * main: The main program data. - * argv: The argument structure in fll_program_data_t.parameters for simplifying syntax. * file: The output file for writing the processed data to (may potentially default to "output"). * mode: The input/output mode (see utf8_modes). * valid: Designate the output context set for valid characters. -- 1.8.3.1