From: Kevin Day Date: Sun, 14 May 2023 00:04:38 +0000 (-0500) Subject: Progress: Continue work on refactoring fss_*_read into fss_read. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=23a2b5d6216316712e1f0eea9cdc394cf2ea7a77;p=fll Progress: Continue work on refactoring fss_*_read into fss_read. --- diff --git a/level_3/fss_basic_list_read/c/private-print.c b/level_3/fss_basic_list_read/c/private-print.c index cc6898f..d48271e 100644 --- a/level_3/fss_basic_list_read/c/private-print.c +++ b/level_3/fss_basic_list_read/c/private-print.c @@ -89,6 +89,14 @@ extern "C" { } #endif // _di_fss_basic_list_read_print_object_end_ +#ifndef _di_fss_basic_list_read_print_one_ + void fss_basic_list_read_print_one(fll_program_data_t * const main) { + + f_print_dynamic_raw(f_string_ascii_1_s, main->output.to); + f_print_dynamic_raw(f_string_eol_s, main->output.to); + } +#endif // _di_fss_basic_list_read_print_one_ + #ifndef _di_fss_basic_list_read_print_set_end_ void fss_basic_list_read_print_set_end(fll_program_data_t * const main) { @@ -98,14 +106,6 @@ extern "C" { } #endif // _di_fss_basic_list_read_print_set_end_ -#ifndef _di_fss_basic_list_read_print_one_ - void fss_basic_list_read_print_one(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_1_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_basic_list_read_print_one_ - #ifndef _di_fss_basic_list_read_print_zero_ void fss_basic_list_read_print_zero(fll_program_data_t * const main) { diff --git a/level_3/fss_basic_list_read/c/private-read.h b/level_3/fss_basic_list_read/c/private-read.h index 6c9b008..4b708d4 100644 --- a/level_3/fss_basic_list_read/c/private-read.h +++ b/level_3/fss_basic_list_read/c/private-read.h @@ -199,6 +199,8 @@ extern "C" { * The main program data. * @param data * The program data. + * @param at + * The position within the buffer. * @param delimits_object * The delimits to be applied to an Object. * @param delimits_content diff --git a/level_3/fss_read/c/basic/main.c b/level_3/fss_read/c/basic/main.c index 1211f49..f099e5f 100644 --- a/level_3/fss_read/c/basic/main.c +++ b/level_3/fss_read/c/basic/main.c @@ -21,7 +21,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.process_help = &fss_read_basic_process_help; data.setting.process_last_line = &fss_read_process_last_line; data.setting.process_normal = &fss_read_process_normal; - data.setting.process_pipe = &fss_read_process_pipe; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_read/c/basic_list/main.c b/level_3/fss_read/c/basic_list/main.c index 8b15c77..31d0e36 100644 --- a/level_3/fss_read/c/basic_list/main.c +++ b/level_3/fss_read/c/basic_list/main.c @@ -21,7 +21,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.process_help = &fss_read_basic_list_process_help; data.setting.process_last_line = &fss_read_process_last_line; data.setting.process_normal = &fss_read_process_normal; - data.setting.process_pipe = &fss_read_process_pipe; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_read/c/embedded_list/main.c b/level_3/fss_read/c/embedded_list/main.c index 4eed5ed..ea8c84d 100644 --- a/level_3/fss_read/c/embedded_list/main.c +++ b/level_3/fss_read/c/embedded_list/main.c @@ -21,9 +21,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.process_help = &fss_read_embedded_list_process_help; data.setting.process_last_line = &fss_read_process_last_line; data.setting.process_normal = &fss_read_process_normal; - data.setting.process_pipe = &fss_read_process_pipe; data.setting.flag |= fss_read_main_flag_ignore_e; data.setting.flag |= fss_read_main_flag_content_multiple_e; + data.setting.flag |= fss_read_main_flag_depth_support_e | fss_read_main_flag_select_support_e; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_read/c/extended/main.c b/level_3/fss_read/c/extended/main.c index 0d7a900..c75a0ba 100644 --- a/level_3/fss_read/c/extended/main.c +++ b/level_3/fss_read/c/extended/main.c @@ -21,7 +21,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.process_help = &fss_read_extended_process_help; data.setting.process_last_line = &fss_read_process_last_line; data.setting.process_normal = &fss_read_process_normal; - data.setting.process_pipe = &fss_read_process_pipe; data.setting.flag |= fss_read_main_flag_content_multiple_e; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/extended_list/main.c b/level_3/fss_read/c/extended_list/main.c index 3974995..b242a69 100644 --- a/level_3/fss_read/c/extended_list/main.c +++ b/level_3/fss_read/c/extended_list/main.c @@ -21,7 +21,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.process_help = &fss_read_extended_list_process_help; data.setting.process_last_line = &fss_read_process_last_line; data.setting.process_normal = &fss_read_process_normal; - data.setting.process_pipe = &fss_read_process_pipe; data.setting.flag |= fss_read_main_flag_ignore_e; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index 8f9ddcc..d7c81cb 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -9,21 +9,23 @@ extern "C" { if (!main) return; + f_console_parameters_t * const parameters = &main->program.parameters; + main->setting.state.step_small = fss_read_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = fss_read_allocation_small_d; // Identify and pocess first/last parameters. - if (main->program.parameters.array[fss_read_parameter_line_first_no_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_line_first_no_e].result & f_console_result_found_e) { main->setting.flag -= main->setting.flag & fss_read_main_flag_print_first_e; } else { main->setting.flag |= fss_read_main_flag_print_first_e; } - if (main->program.parameters.array[fss_read_parameter_line_last_no_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_line_last_no_e].result & f_console_result_found_e) { main->setting.flag -= main->setting.flag & fss_read_main_flag_print_last_e; } else { @@ -90,15 +92,15 @@ extern "C" { main->program.output.to.stream = F_type_output_d; main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - if (main->program.parameters.array[fss_read_parameter_help_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= fss_read_main_flag_help_e; } - if (main->program.parameters.array[fss_read_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= fss_read_main_flag_version_e; } - if (main->program.parameters.array[fss_read_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= fss_read_main_flag_copyright_e; } @@ -113,10 +115,11 @@ extern "C" { } } - if (main->program.parameters.array[fss_read_parameter_help_e].result & f_console_result_found_e) return; - if (main->program.parameters.array[fss_read_parameter_version_e].result & f_console_result_found_e) return; + if (parameters->array[fss_read_parameter_help_e].result & f_console_result_found_e) return; + if (parameters->array[fss_read_parameter_version_e].result & f_console_result_found_e) return; f_array_length_t i = 0; + f_array_length_t index = 0; { static const f_array_length_t parameter_code[] = { @@ -150,9 +153,27 @@ extern "C" { message_value, }; + static const uint32_t parameter_flag[] = { + fss_read_main_flag_at_e, + fss_read_main_flag_depth_e, + fss_read_main_flag_line_e, + fss_read_main_flag_select_e, + fss_read_main_flag_name_e, + fss_read_main_flag_delimit_e, + }; + + f_number_unsigned_t * const parameter_value_digit[] = { + 0, // at + 0, // depth + &main->setting.line, // line + &main->setting.select, // select + 0, // name + 0, // delimit + }; + for (i = 0; i < 6; ++i) { - if (main->program.parameters.array[parameter_code[i]].result & f_console_result_found_e)) { + if (parameters->array[parameter_code[i]].result & f_console_result_found_e)) { main->setting.state.status = F_status_set_error(F_parameter); if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { @@ -163,10 +184,25 @@ extern "C" { return; } + else if (parameters->array[parameter_code[i]].result & f_console_result_value_e)) { + main->setting.state.flag |= parameter_flag[i]; + + if (parameter_value_digit[i]) { + index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].values.used - 1]; + + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], parameter_value_digit_single[i]); + + if (F_status_is_error(main->setting.state.status)) { + fll_error_parameter_integer_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, parameter_name[i], parameters->arguments.array[index]); + + return; + } + } + } } // for } - if (main->parameters.array[fss_read_parameter_columns_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_columns_e].result & f_console_result_found_e) { static const f_array_length_t parameter_code[] = { fss_read_parameter_depth_e, fss_read_parameter_line_e, @@ -183,7 +219,7 @@ extern "C" { fss_read_long_total_s, }; - const uint8_t parameter_match[] = { + static const uint8_t parameter_match[] = { f_console_result_value_e, f_console_result_value_e, f_console_result_found_e, @@ -193,7 +229,7 @@ extern "C" { for (i = 0; i < 5; ++i) { - if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { + if (parameters->array[parameter_code[i]].result & parameter_match[i]) { main->setting.state.status = F_status_set_error(F_parameter); if (main->error.verbosity > f_console_verbosity_quiet_e) { @@ -207,10 +243,12 @@ extern "C" { return; } } // for + + main->setting.flag |= fss_read_main_flag_columns_e; } - if (main->parameters.array[fss_read_parameter_pipe_e].result & f_console_result_found_e) { - if ((main->parameters.array[fss_read_parameter_total_e].result & f_console_result_found_e) || (main->parameters.array[fss_read_parameter_total_e].result & f_console_result_found_e)) { + if (parameters->array[fss_read_parameter_pipe_e].result & f_console_result_found_e) { + if ((parameters->array[fss_read_parameter_total_e].result & f_console_result_found_e) || (parameters->array[fss_read_parameter_total_e].result & f_console_result_found_e)) { main->setting.state.status = F_status_set_error(F_parameter); if (main->error.verbosity > f_console_verbosity_quiet_e) { @@ -222,7 +260,7 @@ extern "C" { &main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_read_long_pipe_s, - (main->parameters.array[fss_read_parameter_total_e].result & f_console_result_found_e) + (parameters->array[fss_read_parameter_total_e].result & f_console_result_found_e) ? fss_read_long_total_s : fss_read_long_line_s ); @@ -232,19 +270,18 @@ extern "C" { } } - if (main->parameters.array[fss_read_parameter_delimit_e].result & f_console_result_value_e) { - f_array_length_t index = 0; + if (parameters->array[fss_read_parameter_delimit_e].result & f_console_result_value_e) { f_array_length_t length = 0; // Set the value to 0 to allow for detecting mode based on what is provided. main->setting.delimit_mode = 0; - for (i = 0; i < main->parameters.array[fss_read_parameter_delimit_e].values.used; ++i) { + for (i = 0; i < parameters->array[fss_read_parameter_delimit_e].values.used; ++i) { if (fss_read_signal_check(main)) return; - index = main->parameters.array[fss_read_parameter_delimit_e].values.array[i]; - length = main->program.parameters.arguments.array[index].used; + index = parameters->array[fss_read_parameter_delimit_e].values.array[i]; + length = parameters->arguments.array[index].used; if (!length) { main->setting.state.status = F_status_set_error(F_parameter); @@ -258,13 +295,13 @@ extern "C" { return; } - if (f_compare_dynamic(fss_read_delimit_mode_name_none_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + if (f_compare_dynamic(fss_read_delimit_mode_name_none_s, parameters->arguments.array[index]) == F_equal_to) { main->setting.delimit_mode = fss_read_delimit_mode_none_e; } - else if (f_compare_dynamic(fss_read_delimit_mode_name_all_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + else if (f_compare_dynamic(fss_read_delimit_mode_name_all_s, parameters->arguments.array[index]) == F_equal_to) { main->setting.delimit_mode = fss_read_delimit_mode_all_e; } - else if (f_compare_dynamic(fss_read_delimit_mode_name_object_s, main->program.parameters.arguments.array[index]) == F_equal_to) { + else if (f_compare_dynamic(fss_read_delimit_mode_name_object_s, parameters->arguments.array[index]) == F_equal_to) { switch (main->setting.delimit_mode) { case fss_read_delimit_mode_auto_e: main->setting.delimit_mode = fss_read_delimit_mode_object_e; @@ -305,7 +342,7 @@ extern "C" { main->setting.delimit_mode = fss_read_delimit_mode_content_object_e; } - if (main->program.parameters.arguments.array[index].string[length - 1] == fss_read_delimit_mode_name_greater_s.string[0]) { + if (parameters->arguments.array[index].string[length - 1] == fss_read_delimit_mode_name_greater_s.string[0]) { if (!(main->setting.delimit_mode == fss_read_delimit_mode_none_e || main->setting.delimit_mode == fss_read_delimit_mode_all_e)) { if (main->setting.delimit_mode == fss_read_delimit_mode_content_object_e) { main->setting.delimit_mode = fss_read_delimit_mode_content_greater_object_e; @@ -318,7 +355,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (main->program.parameters.arguments.array[index].string[length - 1] == fss_read_delimit_mode_name_lesser_s.string[0]) { + else if (parameters->arguments.array[index].string[length - 1] == fss_read_delimit_mode_name_lesser_s.string[0]) { if (!(main->setting.delimit_mode == fss_read_delimit_mode_none_e || main->setting.delimit_mode == fss_read_delimit_mode_all_e)) { if (main->setting.delimit_mode == fss_read_delimit_mode_content_object_e) { main->setting.delimit_mode = fss_read_delimit_mode_content_lesser_object_e; @@ -342,18 +379,18 @@ extern "C" { } // Ignore leading plus sign. - if (main->program.parameters.arguments.array[index].string[0] == f_string_ascii_plus_s.string[0]) { + if (parameters->arguments.array[index].string[0] == f_string_ascii_plus_s.string[0]) { ++main->setting.range.start; } - main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], main->setting.range, &main->setting.delimit_depth); + main->setting.state.status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], main->setting.range, &main->setting.delimit_depth); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_parameter_integer_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_partial_to_unsigned_detect), F_true, fss_read_long_delimit_s, main->program.parameters.arguments.array[index]); + fll_error_parameter_integer_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_partial_to_unsigned_detect), F_true, fss_read_long_delimit_s, parameters->arguments.array[index]); return; } @@ -378,14 +415,52 @@ extern "C" { } } - // The standards providing the setting load callback must call this rather than calling this here because they need to perfom tests after this is called based on the results. - main->setting.state.status = fss_read_setting_load_depth(arguments, main); - if (F_status_is_error(main->setting.state.status)) return; + if (parameters->array[fss_read_parameter_content_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_object_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_content_e].location < parameters->array[fss_read_parameter_object_e].location) { + main->setting.flag |= fss_read_main_flag_object_e; + } + else { + main->setting.flag |= fss_read_main_flag_content_e; + } + } + else { + main->setting.flag |= fss_read_main_flag_content_e; + } + } + else if (parameters->array[fss_read_parameter_object_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_object_e; + } + else { - // @todo: Some standards do not support nesting, so any depth greater than 0 can be predicted without processing the file, this check needs to happen in the program specific settings processing function. - // if (data.depths.array[0].depth) { ... + // Fallback to Content as the default. + main->setting.flag |= fss_read_main_flag_content_e; + } - if (main->parameters.array[fss_read_parameter_select_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_empty_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_empty_e; + } + + if (parameters->array[fss_read_parameter_original_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_original_e; + } + + if (parameters->array[fss_read_parameter_pipe_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_pipe_e; + } + + if (parameters->array[fss_read_parameter_total_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_total_e; + } + + if (parameters->array[fss_read_parameter_trim_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_trim_e; + } + + main->setting.state.status = fss_read_setting_load_depth(arguments, main, parameters); + if (F_status_is_error(main->setting.state.status)) return; + + if (parameters->array[fss_read_parameter_select_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { @@ -397,7 +472,7 @@ extern "C" { return; } - if (main->program.parameters.array[fss_read_parameter_trim_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_trim_e].result & f_console_result_found_e) { main->setting.flag |= fss_read_main_flag_trim_e; } @@ -434,19 +509,18 @@ extern "C" { } } - if (main->program.parameters.remaining.used) { - f_array_length_t index = 0; + if (parameters->remaining.used) { off_t size_block = 0; off_t size_file = 0; off_t size_read = 0; - for (i = 0; i < main->parameters.remaining.used; ++i) { + for (i = 0; i < parameters->remaining.used; ++i) { if (fss_read_signal_check(main)) return; - index = main->parameters.remaining.array[i]; + index = parameters->remaining.array[i]; - main->setting.files.array[main->setting.files.used].name = main->program.parameters.arguments.array[index]; + main->setting.files.array[main->setting.files.used].name = parameters->arguments.array[index]; main->setting.files.array[main->setting.files.used].range.start = main->setting.buffer.used; file.id = -1; @@ -459,7 +533,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_open), fll_error_file_flag_fallback_e, main->program.parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_open), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -473,7 +547,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_size_by_id), fll_error_file_flag_fallback_e, main->program.parameters.arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_size_by_id), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -501,7 +575,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_string_dynamic_increase_by), fll_error_file_flag_fallback_e, main->program.parameters.arguments.array[index], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_string_dynamic_increase_by), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_process_s, fll_error_file_type_file_e); break; } @@ -520,15 +594,12 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_read_until), fll_error_file_flag_fallback_e, main->program.parameters.arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_read_until), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); } break; } - f_file_stream_flush(file); - f_file_stream_close(&file); - if (main->setting.buffer.used > main->setting.files.array[main->setting.files.used].range.start) { main->setting.files.array[main->setting.files.used++].range.stop = main->setting.buffer.used - 1; @@ -537,6 +608,9 @@ extern "C" { if (F_status_is_error(main->setting.state.status)) break; } } + + f_file_stream_flush(file); + f_file_stream_close(&file); } else { main->setting.files.array[main->setting.files.used].range.start = 1; @@ -551,14 +625,14 @@ extern "C" { #endif // _di_fss_read_setting_load_ #ifndef _di_fss_read_setting_load_depth_ - void fss_read_setting_load_depth(const f_console_arguments_t arguments, fss_read_main_t * const main) { + void fss_read_setting_load_depth(const f_console_arguments_t arguments, fss_read_main_t * const main, f_console_parameters_t * const parameters) { - if (!main) return; + if (!main || !parameters) return; f_array_length_t i = 1; - if (main->parameters.array[fss_read_parameter_depth_e].result & f_console_result_value_e) { - i = main->parameters.array[fss_read_parameter_depth_e].values.used; + if (parameters->array[fss_read_parameter_depth_e].result & f_console_result_value_e) { + i = parameters->array[fss_read_parameter_depth_e].values.used; } if (i > data->depths.size) { @@ -593,11 +667,11 @@ extern "C" { // This dynamic string is actually a static string, so clear it between loops. macro_f_string_dynamic_t_clear(data->depths.array[i].value_name); - if (!main->parameters.array[fss_read_parameter_depth_e].values.used) { + if (!parameters->array[fss_read_parameter_depth_e].values.used) { position_depth = 0; } else { - position_depth = main->parameters.array[fss_read_parameter_depth_e].values.array[i]; + position_depth = parameters->array[fss_read_parameter_depth_e].values.array[i]; main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[position_depth], &data->depths.array[i].depth); @@ -612,18 +686,18 @@ extern "C" { } } - if (main->parameters.array[fss_read_parameter_at_e].result & f_console_result_value_e) { - for (; position_at < main->parameters.array[fss_read_parameter_at_e].values.used; ++position_at) { + if (parameters->array[fss_read_parameter_at_e].result & f_console_result_value_e) { + for (; position_at < parameters->array[fss_read_parameter_at_e].values.used; ++position_at) { - if (main->parameters.array[fss_read_parameter_at_e].values.array[position_at] < position_depth) { + if (parameters->array[fss_read_parameter_at_e].values.array[position_at] < position_depth) { continue; } - if (i + 1 < data->depths.used && main->parameters.array[fss_read_parameter_at_e].values.array[position_at] > main->parameters.array[fss_read_parameter_depth_e].values.array[i + 1]) { + if (i + 1 < data->depths.used && parameters->array[fss_read_parameter_at_e].values.array[position_at] > parameters->array[fss_read_parameter_depth_e].values.array[i + 1]) { break; } - data->depths.array[i].index_at = main->parameters.array[fss_read_parameter_at_e].values.array[position_at]; + data->depths.array[i].index_at = parameters->array[fss_read_parameter_at_e].values.array[position_at]; main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[data->depths.array[i].index_at], &data->depths.array[i].value_at); @@ -639,20 +713,20 @@ extern "C" { } // for } - if (main->parameters.array[fss_read_parameter_name_e].result & f_console_result_value_e) { - for (; position_name < main->parameters.array[fss_read_parameter_name_e].values.used; ++position_name) { + if (parameters->array[fss_read_parameter_name_e].result & f_console_result_value_e) { + for (; position_name < parameters->array[fss_read_parameter_name_e].values.used; ++position_name) { - if (main->parameters.array[fss_read_parameter_name_e].values.array[position_name] < position_depth) { + if (parameters->array[fss_read_parameter_name_e].values.array[position_name] < position_depth) { continue; } - if (i + 1 < data->depths.used && main->parameters.array[fss_read_parameter_name_e].values.array[position_name] > main->parameters.array[fss_read_parameter_depth_e].values.array[i + 1]) { + if (i + 1 < data->depths.used && parameters->array[fss_read_parameter_name_e].values.array[position_name] > parameters->array[fss_read_parameter_depth_e].values.array[i + 1]) { break; } - data->depths.array[i].index_name = main->parameters.array[fss_read_parameter_name_e].values.array[position_name]; + data->depths.array[i].index_name = parameters->array[fss_read_parameter_name_e].values.array[position_name]; - if (main->parameters.array[fss_read_parameter_trim_e].result & f_console_result_found_e) { + if (parameters->array[fss_read_parameter_trim_e].result & f_console_result_found_e) { main->setting.state.status = f_rip_dynamic(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } else { @@ -664,7 +738,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fss_read_print_error(&main->program.error, (main->parameters.array[fss_read_parameter_trim_e].result & f_console_result_found_e) ? macro_fss_read_f(f_rip_dynamic) : macro_fss_read_f(f_string_dynamic_append)); + fss_read_print_error(&main->program.error, (parameters->array[fss_read_parameter_trim_e].result & f_console_result_found_e) ? macro_fss_read_f(f_rip_dynamic) : macro_fss_read_f(f_string_dynamic_append)); return; } @@ -706,6 +780,11 @@ extern "C" { } // for } // for + if (main->setting.process_load_depth) { + main->setting.process_load_depth(arguments, (void *) main); + if (F_status_is_error(main->setting.state.status)) return; + } + main->setting.state.status = F_none; } #endif // _di_fss_read_setting_load_depth_ diff --git a/level_3/fss_read/c/main/common.h b/level_3/fss_read/c/main/common.h index ca7f0ae..1e90caf 100644 --- a/level_3/fss_read/c/main/common.h +++ b/level_3/fss_read/c/main/common.h @@ -28,6 +28,8 @@ extern "C" { * @param main * The main program data. * + * This calls main.setting.process_last_line() if not NULL. + * * This alters main.setting.range. * * This alters main.setting.state.status: @@ -77,6 +79,8 @@ extern "C" { * @param main * The main program data. * + * This calls main.setting.process_load_depth() if not NULL. + * * This alters main.setting.state.status: * F_none on success. * @@ -88,6 +92,10 @@ extern "C" { * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). * * Errors (with error bit) from: fss_read_depths_resize(). + * @param parameters + * The console parameters structure representing the processed arguments. + * + * Must not be NULL. * * @see f_rip_dynamic() * @see f_string_dynamic_append() @@ -98,7 +106,7 @@ extern "C" { * @see fss_read_setting_load() */ #ifndef _di_fss_read_setting_load_depth_ - extern void fss_read_setting_load_depth(const f_console_arguments_t arguments, fss_read_main_t * const main); + extern void fss_read_setting_load_depth(const f_console_arguments_t arguments, fss_read_main_t * const main, f_console_parameters_t * const parameters); #endif // _di_fss_read_setting_load_depth_ #ifdef __cplusplus diff --git a/level_3/fss_read/c/main/common/enumeration.h b/level_3/fss_read/c/main/common/enumeration.h index 034dbb3..0a88f7f 100644 --- a/level_3/fss_read/c/main/common/enumeration.h +++ b/level_3/fss_read/c/main/common/enumeration.h @@ -20,46 +20,60 @@ extern "C" { * Flags passed to the main function or program. * * fss_read_main_flag_*_e: - * - none: No flags set. - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - copyright: Print copyright. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - help: Print help. - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - print_first: When set, print new line to message output on program begin after loading settings. - * - print_last: When set, print new line to message output on program end. - * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). - * - total: The total lines found and selected is printed instead of the Content. - * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). - * - version: Print version. + * - none: No flags set. + * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. + * - content: The Content is to be printed. + * - content_multiple: Designate that multiple Content is allowed for an Object for this standard rather than a single Content per Object. + * - copyright: Print copyright. + * - delimit: How delimits are to be handled is designated. + * - depth: The depth is specified at least once. + * - depth_multiple: Designate that multiple depths are allowed within Content rather than being single depth Content. + * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). + * - help: Print help. + * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). + * - line_single: Designate that only a single line for Content is allowed for an Object for this standard rather than allowing multiple lines per Content per Object. + * - name: A specific Object name has been requested. + * - object: The Object is to be printed. + * - original: Enable original printing, where the quotes are printed and no delimits are applied. + * - pipe: Print using the special pipe format. + * - print_first: When set, print new line to message output on program begin after loading settings. + * - print_last: When set, print new line to message output on program end. + * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). + * - total: The total lines found and selected is printed instead of the Content. + * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). + * - version: Print version. */ #ifndef _di_fss_read_main_flag_e_ enum { - fss_read_main_flag_none_e = 0x0, - fss_read_main_flag_at_d = 0x1, - fss_read_main_flag_columns_d = 0x2, - fss_read_main_flag_content_d = 0x4, - fss_read_main_flag_copyright_e = 0x8, - fss_read_main_flag_empty_d = 0x10, - fss_read_main_flag_help_e = 0x20, - fss_read_main_flag_line_d = 0x40, - fss_read_main_flag_name_d = 0x80, - fss_read_main_flag_object_d = 0x100, - fss_read_main_flag_original_d = 0x200, - fss_read_main_flag_print_first_e = 0x400, - fss_read_main_flag_print_last_e = 0x800, - fss_read_main_flag_select_d = 0x1000, - fss_read_main_flag_total_d = 0x2000, - fss_read_main_flag_trim_e = 0x4000, - fss_read_main_flag_version_e = 0x8000, + fss_read_main_flag_none_e = 0x0, + fss_read_main_flag_at_e = 0x1, + fss_read_main_flag_columns_e = 0x2, + fss_read_main_flag_content_e = 0x4, + fss_read_main_flag_content_multiple_e = 0x8, + fss_read_main_flag_copyright_e = 0x10, + fss_read_main_flag_delimit_e = 0x20, + fss_read_main_flag_depth_e = 0x40, + fss_read_main_flag_depth_multiple_e = 0x80, + fss_read_main_flag_empty_e = 0x100, + fss_read_main_flag_help_e = 0x200, + fss_read_main_flag_line_e = 0x400, + fss_read_main_flag_line_single_e = 0x800, + fss_read_main_flag_name_e = 0x1000, + fss_read_main_flag_object_e = 0x2000, + fss_read_main_flag_original_e = 0x4000, + fss_read_main_flag_pipe_e = 0x8000, + fss_read_main_flag_print_first_e = 0x10000, + fss_read_main_flag_print_last_e = 0x20000, + fss_read_main_flag_select_e = 0x40000, + fss_read_main_flag_total_e = 0x80000, + fss_read_main_flag_trim_e = 0x100000, + fss_read_main_flag_version_e = 0x200000, }; // enum #endif // _di_fss_read_main_flag_e_ +//@todo figure out if fss_read_main_flag_ignore_e is needed + /** * The main program parameters. */ diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index dc96f4f..72637b4 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -148,14 +148,22 @@ extern "C" { * delimits_content: The positions within the buffer representing Content character delimits. * comments: The positions within the buffer representing comments. * - * process_help: Process help (generally printing help). - * process_last_line: Process printing last line if necessary when loading in a file (or pipe). - * process_normal: Process normally (data from parameters and files). - * process_pipe: Process using the data from input pipe. + * process_help: Process help (generally printing help). + * process_last_line: Process printing last line if necessary when loading in a file (or pipe). + * process_load_depth: Process loading of the depth related parameters when loading the settings. + * process_normal: Process normally (data from parameters and files). + * + * process_at: Process at parameter, usually called by process_normal() callback. + * process_columns: Process columns parameter, usually called by process_normal() callback. + * process_line: Process line parameter, usually called by process_normal() callback. + * process_load: Process loading of FSS data from buffer (not to be confused with loading settings), usually called by process_normal() callback. + * process_name: Process name parameter, usually called by process_normal() callback. + * process_print_at: Process printing a given line, usually called by process_normal() callback. + * process_total: Process total parameter, usually called by process_normal() callback. */ #ifndef _di_fss_read_setting_t_ typedef struct { - uint16_t flag; + uint32_t flag; uint8_t delimit_mode; f_status_t status_thread; @@ -181,8 +189,16 @@ extern "C" { void (*process_help)(void * const main); void (*process_last_line)(void * const main); + void (*process_load_depth)(const f_console_arguments_t arguments, void * const main); void (*process_normal)(void * const main); - void (*process_pipe)(void * const main); + + void (*process_at)(void * const main, const bool names[], const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); + void (*process_columns)(void * const main, const bool names[]); + void (*process_line)(void * const main, const bool names[]); + void (*process_load)(void * const main); + void (*process_name)(void * const main, bool names[]); + void (*process_print_at)(void * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); + void (*process_total)(void * const main, const bool names[]); } fss_read_setting_t; #define fss_read_setting_t_initialize \ @@ -208,6 +224,13 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ } #endif // _di_fss_read_setting_t_ diff --git a/level_3/fss_read/c/main/fss_read.c b/level_3/fss_read/c/main/fss_read.c index 2852496..9094b02 100644 --- a/level_3/fss_read/c/main/fss_read.c +++ b/level_3/fss_read/c/main/fss_read.c @@ -70,394 +70,129 @@ extern "C" { } #endif // _di_fss_read_main_ -#ifndef _di_fss_read_process_last_line_ - void fss_read_process_last_line(void * const void_main) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; +#ifndef _di_fss_read_process_at_line_ + f_status_t fss_read_process_at_line(fss_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t * const line) { - status = f_string_dynamic_append_assure(f_string_eol_s, &main->setting.buffer); + if (!main || !line) return; - if (F_status_is_error(status)) { - if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); - } + if (main->setting.flag & fss_read_main_flag_object_e) { + if (*line == main->setting.line) { + f_file_stream_lock(main->program.output.to); - fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_string_dynamic_append_assure), fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } -#endif // _di_fss_read_process_last_line_ - -#ifndef _di_fss_read_process_normal_ - void fss_read_process_normal(void * const void_main) { - - if (!void_main) return; - - // @todo this is entirely copied from fss_write and may not represent how fss_read needs to handle this. - - fss_read_process_normal_data( - (fss_read_main_t *) void_main, - (((fss_read_main_t *) void_main)->setting.flag & fss_read_main_flag_object_e) - ? ((fss_read_main_t *) void_main)->setting.objects.used - : ((fss_read_main_t *) void_main)->setting.contentss.used - ); - } -#endif // _di_fss_read_process_normal_ - -#ifndef _di_fss_read_process_normal_data_ - void fss_read_process_normal_data(void * const void_main, const f_array_length_t length) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - // @todo this is entirely copied from fss_write and may not represent how fss_read needs to handle this. - - main->setting.ignores = 0; - main->setting.object = 0; - main->setting.content = 0; - main->setting.contents = 0; - - if (length) { - for (f_array_length_t i = 0; i < length; ++i) { - - if (fss_read_signal_check(main)) return; - - if (main->setting.objects.used) { - main->setting.object = &main->setting.objects.array[i]; + if (main->setting.flag & fss_read_main_flag_total_e) { + fss_read_print_number(&main->program.output, 1); } - - if (main->setting.contentss.used) { - main->setting.contents = &main->setting.contentss.array[i]; + else { + fss_read_print_object_at(&main->program.output, at, delimits_object); } - if (main->setting.ignoress.used) { - main->setting.ignores = &main->setting.ignoress.array[i]; - } + f_file_stream_unlock(main->program.output.to); - main->setting.process_set(void_main); - if (F_status_is_error(main->setting.state.status)) break; - } // for - } - else { - if (main->setting.flag & (fss_read_main_flag_object_open_e | fss_read_main_flag_content_next_e | fss_read_main_flag_content_end_e)) { - main->setting.object = 0; - main->setting.contents = 0; - main->setting.ignores = 0; + main->setting.state.status = F_success; - main->setting.process_set(void_main); + return; } - } - } -#endif // _di_fss_read_process_normal_data_ -#ifndef _di_fss_read_process_pipe_ - void fss_read_process_pipe(void * const void_main) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (!main->setting.process_set) return; - - // @todo this is entirely copied from fss_write and may not represent how fss_read needs to handle this. - - if (main->program.message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + ++(*line); } - const f_array_length_t used_objects = main->setting.objects.used; - const f_array_length_t used_contentss = main->setting.contentss.used; - const f_array_length_t used_ignoress = main->setting.ignoress.used; - - main->setting.object = &main->setting.objects.array[used_objects]; - main->setting.contents = &main->setting.contentss.array[used_contentss]; - main->setting.ignores = &main->setting.ignoress.array[used_ignoress]; - - // 0x0 = nothing printed, 0x1 = something printed, 0x2 = ignore enabled, 0x4 = added Content for Object. - uint8_t flag = 0; - - // 0x0 = start new object/content set, 0x1 = processing object, 0x2 = processing content, 0x3 = end object/content set. - uint8_t state = 0; - - // This is processed in a single set, so there is only ever one Object added. - main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, &main->setting.objects); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); - - return; - } - - // This is processed in a single set, so there is only ever one Content added. - main->setting.state.status = f_string_dynamicss_increase(main->setting.state.step_small, &main->setting.contentss); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamicss_increase)); - - return; - } - - main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); - - return; - } - - // This is processed in a single set, so there is only ever one Ignores added. - main->setting.state.status = f_string_rangess_increase(main->setting.state.step_small, &main->setting.ignoress); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_rangess_increase)); - - return; - } - - f_status_t status_pipe = F_none; - - f_file_t input = f_file_t_initialize; - input.id = F_type_descriptor_input_d; - input.size_read = main->setting.state.step_large; + // There is only a single Content column for this standard. + if (main->setting.flag & fss_read_main_flag_content_e) { + if (!main->setting.contents.array[at].used) { + main->setting.state.status = F_none; - f_array_length_t total = 0; - f_array_length_t ignore = 0; - f_string_range_t range = f_string_range_t_initialize; - - // Reset all of the used data before starting the loop. - main->setting.object->used = 0; - main->setting.contents->used = 0; - main->setting.ignores->used = 0; - - for (;;) { + return; + } - if (fss_read_signal_check(main)) break; + f_string_range_t range = main->setting.contents.array[at].array[0]; + // This content has no data, do not even check "include empty" because it cannot be counted as a line. if (range.start > range.stop) { - if (status_pipe == F_none_eof) break; - - main->setting.block.used = 0; - - status_pipe = f_file_read_block(input, &main->setting.block); - - if (F_status_is_error(status_pipe)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_file_read_block)); - - status_pipe = F_status_set_error(F_pipe); - - break; - } - - if (!main->setting.block.used) break; + main->setting.state.status = F_none; - range.start = 0; - range.stop = main->setting.block.used - 1; + return; } - // Start Object. - if (!state || state == 0x1) { - if (!state) { - main->setting.object->used = 0; - - state = 0x1; - } - - // Reset the "has Content for Object" flag and associated contents array used length. - flag -= flag | 0x4; - main->setting.contents->used = 0; - - main->setting.state.status = f_string_dynamic_increase_by(main->setting.block.used, main->setting.object); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); - - break; - } - - for (; range.start <= range.stop; ++range.start) { - - // Do not handle start/end while inside an ignore set. - if (!(flag & 0x2)) { - if (main->setting.block.string[range.start] == fss_read_pipe_content_start_s.string[0]) { - state = 0x2; - ++range.start; + for (f_array_length_t i = range.start; i <= range.stop; ++i) { - break; - } - - if (main->setting.block.string[range.start] == fss_read_pipe_content_end_s.string[0]) { - state = 0x3; - ++range.start; + if (fss_read_signal_check(main)) return; - break; - } - } + if (main->setting.buffer.string[i] == f_string_eol_s.string[0]) { + if (*line == main->setting.line) { + range.stop = i; - // There currently is no support for "ignore" in Objects, but the Ignore should still be processed. - if (main->setting.block.string[range.start] == fss_read_pipe_content_ignore_s.string[0]) { + f_file_stream_lock(main->program.output.to); - // Ignore is enabled. - if (flag & 0x2) { - flag -= 0x2; + if (main->setting.flag & fss_read_main_flag_total_e) { + fss_read_print_number(&main->program.output, 1); } else { - flag |= 0x2; + fss_read_print_content(&main->program.output, range, delimits_content); } - continue; - } - - main->setting.object->string[main->setting.object->used++] = main->setting.block.string[range.start]; - } // for - - if (F_status_is_error(main->setting.state.status)) break; - - // If the start of Content is not found, then fetch the next block. - if (state == 0x1) continue; + f_file_stream_unlock(main->program.output.to); - // If the end of the current block is reached, fetch the next block. - if (range.start > range.stop) continue; - } - - // Start Content. - if (state == 0x2) { - - // Check to see if the Content supports multiple Content per Object. - if (flag & 0x4) { - if (!(main->setting.flag & fss_read_main_flag_content_multiple_e)) { - main->setting.state.status = F_status_set_error(F_support_not); + main->setting.state.status = F_success; - fss_read_print_error_one_content_only(&main->program.error); - - break; + return; } - main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); + range.start = i + 1; - break; + if (i <= range.stop) { + ++(*line); } } + } // for - if (range.start <= range.stop) { - total = (range.stop - range.start) + 1; - } - else { - total = 0; - } - - if (total) { - main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); + // If Content does not end with a newline, it still must be treated as the last line. + if (main->setting.buffer.string[range.stop] != f_string_eol_s.string[0]) { + ++(*line); - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); + if (*line == main->setting.line) { + f_file_stream_lock(main->program.output.to); - break; + if (main->setting.flag & fss_read_main_flag_total_e) { + fss_read_print_number(&main->program.output, 1); } + else { + range.stop = main->setting.contents.array[at].array[0].stop; - for (; range.start <= range.stop; ++range.start) { - - // Do not handle start/end while inside an ignore set. - if (!(flag & 0x2)) { - if (main->setting.block.string[range.start] == fss_read_pipe_content_start_s.string[0]) { - if (!(main->setting.flag & fss_read_main_flag_content_multiple_e)) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_one_content_only(&main->program.error); - - break; - } - } - - if (main->setting.block.string[range.start] == fss_read_pipe_content_end_s.string[0]) { - state = 0x3; - ++range.start; - - break; - } - } - - if (main->setting.block.string[range.start] == fss_read_pipe_content_ignore_s.string[0]) { - - // Ignore is enabled. - if (flag & 0x2) { - main->setting.state.status = f_string_ranges_increase(main->setting.state.step_small, main->setting.ignores); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_ranges_increase)); - - break; - } - - main->setting.ignores->array[main->setting.ignores->used].start = main->setting.contents->array[main->setting.contents->used].used; - main->setting.ignores->array[main->setting.ignores->used].stop = range.start; - - flag -= 0x2; - } - else { - ignore = main->setting.contents->array[main->setting.contents->used].used; - - flag |= 0x2; - } - - continue; - } + fss_read_print_content(&main->program.output, range, delimits_content); + f_print_dynamic_raw(f_string_eol_s, main->program.output.to); + } - main->setting.contents->array[main->setting.contents->used].string[main->setting.contents->array[main->setting.contents->used].used++] = main->setting.block.string[range.start]; - } // for + f_file_stream_unlock(main->program.output.to); - if (F_status_is_error(main->setting.state.status)) break; + main->setting.state.status = F_success; - ++main->setting.contents->used; - flag |= 0x4; - } - else { - state = 0x3; + return; } } + } - // End Object or Content set. - if (state == 0x3) { - main->setting.process_set(void_main); - if (F_status_is_error(main->setting.state.status)) break; - - state = 0; - flag |= 0x1; + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_at_line_ - // Reset all of the used data for next set. - main->setting.object->used = 0; - main->setting.contents->used = 0; - main->setting.ignores->used = 0; +#ifndef _di_fss_read_process_last_line_ + void fss_read_process_last_line(void * const void_main) { - continue; - } - } // for + if (!void_main) return; - // If the pipe ended before finishing, then attempt to wrap up. - if (F_status_is_error_not(main->setting.state.status) && status_pipe == F_none_eof && state) { - main->setting.process_set(void_main); + fss_read_main_t * const main = (fss_read_main_t *) void_main; - flag |= 0x1; - } + main->setting.state.status = f_string_dynamic_append_assure(f_string_eol_s, &main->setting.buffer); - main->setting.block.used = 0; - main->setting.buffer.used = 0; - main->setting.object->used = 0; - main->setting.contents->used = 0; - main->setting.ignores->used = 0; - main->setting.ignoress.used = used_ignoress; - main->setting.objects.used = used_objects; - main->setting.contentss.used = used_contentss; + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } - if (F_status_is_error_not(main->setting.state.status)) { - main->setting.state.status = (flag & 0x1) ? F_none : F_data_not; + fll_error_file_print(&main->error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_string_dynamic_append_assure), fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); } } -#endif // _di_fss_read_process_pipe_ +#endif // _di_fss_read_process_last_line_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/main/fss_read.h b/level_3/fss_read/c/main/fss_read.h index 5860ab7..85cf661 100644 --- a/level_3/fss_read/c/main/fss_read.h +++ b/level_3/fss_read/c/main/fss_read.h @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -79,7 +80,7 @@ extern "C" { * The program and settings data. * Must be of type fss_read_main_t. * - * This alters main.custom.setting.state.status: + * This alters main.setting.state.status: * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. @@ -92,16 +93,13 @@ extern "C" { #endif // _di_fss_read_main_ /** - * Process the current buffer, guarantee that a newline exists at the end of the buffer. - * - * Most standards are new line sensitive. - * When appending files to the buffer, if the file lacks a final new line then this could break the format for files appended thereafter. + * Process based on at parameter. * * @param main * The program and settings data. * Must be of type fss_read_main_t. * - * This alters main.custom.setting.state.status: + * This alters main.setting.state.status: * F_none on success. * * F_parameter (with error bit) if main is NULL or setting is NULL. @@ -109,55 +107,33 @@ extern "C" { * Errors (with error bit) from: f_string_dynamic_append_assure(). * * Errors (with error bit) from: fss_read_signal_check(). - * - * @see f_string_dynamic_append_assure() - * - * @see fss_read_signal_check() - */ -#ifndef _di_fss_read_process_last_line_ - extern void fss_read_process_last_line(void * const void_main); -#endif // _di_fss_read_process_last_line_ - -/** - * Process normally, reading from the input for the assigned FSS format. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.custom.setting.state.status: - * status from fss_read_process_normal_data(). - * - * Errors (with error bit) from: fss_read_process_normal_data(). - * - * @see fss_read_process_normal_data() + * @param at + * The "at" position to be printed. + * @param delimits_object + * The delimits array representing a delimited Object. + * This represents the positions within the current Object at the "at" position. + * @param delimits_content + * The delimits array representing a delimited Content. + * This represents the positions within the current Content at the "at" position. + * @param line + * The current line being processed. + * This will be incremented as necessary. + * Must not be NULL. + * + * @return + * F_none on success. + * + * @see fss_read_process_at_line() */ -#ifndef _di_fss_read_process_normal_ - extern void fss_read_process_normal(void * const main); -#endif // _di_fss_read_process_normal_ +#ifndef _di_fss_read_process_at_ + extern f_status_t fss_read_process_at_line(fss_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t * const line); +#endif // _di_fss_read_process_at_ /** - * Process the data normally, reading from the input for the assigned FSS format. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.custom.setting.state.status: - * F_none on success. - * - * F_parameter (with error bit) if main is NULL or setting is NULL. - * - * Errors (with error bit) from: fss_read_signal_check(). + * Process the current buffer, guarantee that a newline exists at the end of the buffer. * - * @see fss_read_signal_check() - */ -#ifndef _di_fss_read_process_normal_data_ - void fss_read_process_normal_data(void * const main, const f_array_length_t length); -#endif // _di_fss_read_process_normal_data_ - -/** - * Process the pipe, reading from the pipe and writing to the output for the assigned FSS format. + * Most standards are new line sensitive. + * When appending files to the buffer, if the file lacks a final new line then this could break the format for files appended thereafter. * * @param main * The program and settings data. @@ -165,35 +141,20 @@ extern "C" { * * This alters main.setting.state.status: * F_none on success. - * F_data_not on success but pipe contained no relevant data. - * F_basic on success and the basic has been printed. * * F_parameter (with error bit) if main is NULL or setting is NULL. * - * Errors (with error bit) from: fss_read_signal_check(). - * - * @see fss_read_signal_check() - */ -#ifndef _di_fss_read_process_pipe_ - extern void fss_read_process_pipe(void * const main); -#endif // _di_fss_read_process_pipe_ - -/** - * Process a given Object and Content, printing the assigned FSS format if valid or an error if invalid. + * Errors (with error bit) from: f_string_dynamic_append_assure(). * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. + * Errors (with error bit) from: fss_read_signal_check(). * - * This alters main.setting.state.status: - * F_none on success. - * F_interrupt on (exit) signal received. + * @see f_string_dynamic_append_assure() * - * F_parameter (with error bit) if main is NULL or setting is NULL. + * @see fss_read_signal_check() */ -#ifndef _di_fss_read_process_set_ - extern void fss_read_process_set(void * const main); -#endif // _di_fss_read_process_set_ +#ifndef _di_fss_read_process_last_line_ + extern void fss_read_process_last_line(void * const void_main); +#endif // _di_fss_read_process_last_line_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index 72fdb3c..8a81e2e 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -98,9 +98,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_basic_standard_s; main->setting.process_content = &fss_read_basic_process_content; main->setting.process_help = &fss_read_main_process_help; + main->setting.process_load_depth = 0; main->setting.process_normal = &fss_read_process_normal; main->setting.process_object = &fss_read_basic_process_object; - main->setting.process_pipe = &fss_read_process_pipe; main->setting.process_set = &fss_read_process_set; if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_read_parameter_as_e].values.used) { @@ -120,8 +120,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_basic_standard_s; main->setting.process_content = &fss_read_basic_process_content; main->setting.process_help = &fss_read_basic_process_help; + main->setting.process_load_depth = 0; main->setting.process_object = &fss_read_basic_process_object; - main->setting.process_pipe = &fss_read_process_pipe; main->setting.process_normal = &fss_read_process_normal; main->setting.process_set = &fss_read_process_set; main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by basic. @@ -135,8 +135,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_extended_standard_s; main->setting.process_content = &fss_read_extended_process_content; main->setting.process_help = &fss_read_extended_process_help; + main->setting.process_load_depth = 0; main->setting.process_object = &fss_read_extended_process_object; - main->setting.process_pipe = &fss_read_process_pipe; main->setting.process_normal = &fss_read_process_normal; main->setting.process_set = &fss_read_process_set; main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by extended. @@ -150,8 +150,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_basic_list_standard_s; main->setting.process_content = &fss_read_basic_list_process_content; main->setting.process_help = &fss_read_basic_list_process_help; + main->setting.process_load_depth = 0; main->setting.process_object = &fss_read_basic_list_process_object; - main->setting.process_pipe = &fss_read_process_pipe; main->setting.process_normal = &fss_read_process_normal; main->setting.process_set = &fss_read_process_set; main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by basic list. @@ -165,8 +165,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_extended_list_standard_s; main->setting.process_content = &fss_read_extended_list_process_content; main->setting.process_help = &fss_read_extended_list_process_help; + main->setting.process_load_depth = 0; main->setting.process_object = &fss_read_extended_list_process_object; - main->setting.process_pipe = &fss_read_process_pipe; main->setting.process_normal = &fss_read_process_normal; main->setting.process_set = &fss_read_process_set; main->setting.flag |= fss_read_main_flag_ignore_e; @@ -180,8 +180,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_embedded_list_standard_s; main->setting.process_content = &fss_read_embedded_list_process_content; main->setting.process_help = &fss_read_embedded_list_process_help; + main->setting.process_load_depth = 0; main->setting.process_object = &fss_read_embedded_list_process_object; - main->setting.process_pipe = &fss_read_process_pipe; main->setting.process_normal = &fss_read_process_normal; main->setting.process_set = &fss_read_process_set; main->setting.flag |= fss_read_main_flag_ignore_e; @@ -195,9 +195,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_payload_standard_s; main->setting.process_content = 0; // Not used by payload. main->setting.process_help = &fss_read_payload_process_help; + main->setting.process_load_depth = 0; main->setting.process_normal = &fss_read_process_normal; main->setting.process_object = 0; // Not used by payload. - main->setting.process_pipe = &fss_read_payload_process_pipe; main->setting.process_set = &fss_read_payload_process_set; main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by payload. main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by payload. diff --git a/level_3/fss_read/c/main/main.h b/level_3/fss_read/c/main/main.h index 2f17d8e..614cf6a 100644 --- a/level_3/fss_read/c/main/main.h +++ b/level_3/fss_read/c/main/main.h @@ -64,14 +64,11 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * * This alters main.setting.state.status: * F_none on success. + * F_data_not on success but nothing was provided to operate with. * F_interrupt on (exit) signal received. * * F_parameter (with error bit) if main is NULL or setting is NULL. * - * This alters setting.state.status: - * F_none on success. - * F_data_not on success but nothing was provided to operate with. - * * Errors (with error bit) from: f_console_parameter_process(). * Errors (with error bit) from: f_file_stream_open(). * Errors (with error bit) from: f_string_dynamics_resize(). diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index 69d4cff..63136a6 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -4,6 +4,52 @@ extern "C" { #endif +#ifndef _di_fss_read_print_content_ + f_status_t fss_read_print_content(fl_print_t * const print, const f_string_range_t range, const f_fss_delimits_t delimits) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom, + + f_print_except_in_dynamic_partial(main->setting.buffer, range, delimits, main->setting.comments, print->to); + + return F_none; + } +#endif _di_fss_read_print_content_ + +#ifndef _di_fss_read_print_number_ + f_status_t fss_read_print_number(fl_print_t * const print, const f_number_unsigned_t number) { + + if (!print) return F_status_set_error(F_output_not); + + fll_print_format("%ul%r", print->to, number, f_string_eol_s); + + return F_none; + } +#endif // _di_fss_read_print_number_ + +#ifndef _di_fss_read_print_object_at_ + f_status_t fss_read_print_object_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom, + + if (at >= main->setting.objects.used) return F_output_not; + + if (main->setting.flag & fss_read_main_flag_trim_e) { + fl_print_trim_except_dynamic_partial(main->setting.buffer, main->setting.array[at], delimits, print->to); + } + else { + f_print_except_dynamic_partial(main->setting.buffer, main->setting.array[at], delimits, print->to); + } + + fss_read_print_object_end(print); // @todo replace with a callback because each standard may have a different Object end. + + return F_none; + } +#endif // _di_fss_read_print_object_at_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/main/print/data.h b/level_3/fss_read/c/main/print/data.h index 740b03d..14d83c4 100644 --- a/level_3/fss_read/c/main/print/data.h +++ b/level_3/fss_read/c/main/print/data.h @@ -16,6 +16,94 @@ extern "C" { #endif +/** + * Print the Content. + * + * This does not lock the stream. + * + * This does not print a new line after the Content. + * + * @param print + * The output structure to print to. + * + * The print.custom is expected to be of type fss_read_main_t. + * + * This does not alter print.custom.setting.state.status. + * @param range + * The range within the buffer representing the Content to print. + * @param delimits + * The delimits array representing a delimited Content. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + * + * @see f_print_except_in_dynamic_partial() + */ +#ifndef _di_fss_read_print_content_ + extern f_status_t fss_read_print_content(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits); +#endif // _di_fss_read_print_content_ + +/** + * Print the number and a newline. + * + * This does not lock the stream. + * + * @param print + * The output structure to print to. + * + * The print.custom is expected to be of type fss_read_main_t. + * + * This does not alter print.custom.setting.state.status. + * @param number + * The number to print. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_format() + */ +#ifndef _di_fss_read_print_number_ + extern f_status_t fss_read_print_number(fl_print_t * const print, const f_number_unsigned_t number); +#endif // _di_fss_read_print_number_ + +/** + * Print the Object at the given position. + * + * This does not lock the stream. + * + * @param print + * The output structure to print to. + * + * The print.custom is expected to be of type fss_read_main_t. + * + * This does not alter print.custom.setting.state.status. + * @param at + * The "at" position to be printed. + * @param delimits + * The delimits array representing a delimited Object. + * This represents the positions within the current Object at the "at" position. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + * + * @see f_print_except_dynamic_partial() + * @see fl_print_trim_except_dynamic_partial() + * + * @see fss_read_print_object_end() @todo replace this with appropriate print callback. + */ +#ifndef _di_fss_read_print_object_at_ + extern f_status_t fss_read_print_object_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits); +#endif // _di_fss_read_print_object_at_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/main/print/error.h b/level_3/fss_read/c/main/print/error.h index 2a1d617..35ccac4 100644 --- a/level_3/fss_read/c/main/print/error.h +++ b/level_3/fss_read/c/main/print/error.h @@ -22,13 +22,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. * * @see fll_error_print() */ @@ -42,6 +44,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * @param function * The name of the function where the error happened. @@ -57,7 +61,7 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. * * @see fll_error_file_print() */ @@ -71,13 +75,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. * * @see fll_error_print() */ @@ -91,6 +97,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * @param symbol * The symbol string prepended to the first parameter. @@ -99,6 +107,12 @@ extern "C" { * The parameter name. * @param message * The message to print regarding why the message should be displayed. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_print_error_parameter_requires_message_ extern f_status_t fss_read_print_error_parameter_requires_message(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t message); @@ -110,6 +124,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * @param symbol * The symbol string prepended to the first parameter. @@ -120,6 +136,12 @@ extern "C" { * The parameter value that cannot be specified before the "before" function parameter. * @param before * The parameter value that is before the "value" function parameter. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_print_error_parameter_value_before_value_number_ extern f_status_t fss_read_print_error_parameter_value_before_value_number(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_array_length_t value, const f_array_length_t before); @@ -131,6 +153,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * @param symbol * The symbol string prepended to the first parameter. @@ -139,6 +163,12 @@ extern "C" { * The parameter name. * @param value * The parameter value that is already specified. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_print_error_parameter_value_once_only_number_ extern f_status_t fss_read_print_error_parameter_value_once_only_number(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_array_length_t value); @@ -150,13 +180,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_print_error_one_content_only_ extern f_status_t fss_read_print_error_one_content_only(fl_print_t * const print); @@ -168,13 +200,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _fss_read_print_error_prepend_only_whitespace_ extern f_status_t fss_read_print_error_prepend_only_whitespace(fl_print_t * const print); @@ -186,13 +220,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_print_error_unsupported_eol_ extern f_status_t fss_read_print_error_unsupported_eol(fl_print_t * const print); diff --git a/level_3/fss_read/c/main/print/message.h b/level_3/fss_read/c/main/print/message.h index 6dde2e4..beeb4aa 100644 --- a/level_3/fss_read/c/main/print/message.h +++ b/level_3/fss_read/c/main/print/message.h @@ -24,6 +24,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. */ #ifndef _di_fss_read_print_message_help_ @@ -37,12 +39,14 @@ extern "C" { * * @param print * The output structure to print to. + * + * The print.custom is expected to be of type fss_read_main_t. + * + * This does not alter print.custom.setting.state.status. * @param number * The FSS standard number, such as "0000". * @param name * The FSS standard name, such as "Basic". - * - * This does not alter print.custom.setting.state.status. */ #ifndef _di_fss_read_print_message_help_note_header_ extern void fss_read_print_message_help_note_header(fl_print_t * const print, const f_string_static_t number, const f_string_static_t name); @@ -56,6 +60,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * @param new_line * If 0x0 (F_false), then print help regarding space separating Object and Content. @@ -74,6 +80,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. */ #ifndef _di_fss_read_print_message_help_pipe_ diff --git a/level_3/fss_read/c/main/process_normal.c b/level_3/fss_read/c/main/process_normal.c new file mode 100644 index 0000000..07ddf06 --- /dev/null +++ b/level_3/fss_read/c/main/process_normal.c @@ -0,0 +1,312 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_process_normal_ + void fss_read_process_normal(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + // @todo note that embedded list will probably need to implement its own version of this function (aka: fss_read_process_embedded). + // @todo note that payload will probably need to implement its own version of this function (aka: fss_read_process_payload). + + // For depth, most standards do not support nesting, so any depth greater than 0 can be predicted without processing the buffer. + // For select, most standards do not support multiple select, so any select greater than 0 can be predicted without processing the buffer. + if (!(main->setting.flag & fss_read_main_flag_depth_multiple_e) && main->setting.depths.array[0].depth || !(main->setting.flag & fss_read_main_flag_content_multiple_e) && ((main->setting.flag & fss_read_main_flag_select_e) && data->select)) { + if (main->setting.flag & fss_read_main_flag_total_e) { + f_file_stream_lock(main->program.output.to); + + fss_read_print_number(&main->program.output, 0); + + f_file_stream_unlock(main->program.output.to); + } + + main->setting.state.status = F_none; + + return; + } + + // The process_load() callback is required to be non-NULL. + if (!main->setting.process_load) return; + + main->setting.process_load(main); + if (F_status_is_error(main->setting.state.status)) return; + + f_array_lengths_t except_none = f_array_lengths_t_initialize; + f_array_lengths_t *delimits_object = fss_read_delimit_object_is(main, 0) ? &main->setting.delimits_object : &except_none; + f_array_lengths_t *delimits_content = fss_read_delimit_content_is(main, 0) ? &main->setting.delimits_content : &except_none; + + if (main->setting.flag & fss_read_main_flag_original_e) { + delimits_object = &except_none; + delimits_content = &except_none; + } + + bool names[main->setting.objects.used]; + + if (main->setting.process_name) { + main->setting.process_name(main, names); + if (F_status_is_error(main->setting.state.status)) return; + } + else if (main->setting.objects.used) { + memset(names, 0, sizeof(bool) * main->setting.objects.used); + } + + if (main->setting.process_at) { + main->setting.process_at(main, names, *delimits_object, *delimits_content); + + return; + } + + if ((main->setting.flag & fss_read_main_flag_columns_e) && main->setting.process_columns) { + main->setting.process_columns(main, names); + + return; + } + + if ((main->setting.flag & fss_read_main_flag_total_e) && main->setting.process_total) { + main->setting.process_total(main, names); + + return; + } + + if ((main->setting.flag & fss_read_main_flag_line_e) && main->setting.process_line) { + main->setting.process_line(main, names); + + return; + } + + if (main->setting.process_print_at) { + for (f_array_length_t i = 0; i < main->setting.contents.used; ++i) { + + if (!names[i]) continue; + if (fss_read_signal_check(main)) return; + + main->setting.process_print_at(main, i, *delimits_object, *delimits_content); + } // for + } + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_ + +#ifndef _di_fss_read_process_normal_at_ + void fss_read_process_normal_at(void * const main, const bool names[], const f_array_lengths_t delimits_object, f_array_lengths_t delimits_content) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.depths.array[0].value_at >= main->setting.objects.used) { + if (main->setting.flag & (fss_read_main_flag_columns_e | fss_read_main_flag_total_e)) { + f_file_stream_lock(main->program.output.to); + + fss_read_print_number(&main->program.output, 0); + + f_file_stream_unlock(main->program.output.to); + } + + main->setting.state.status = F_none; + + return; + } + + // If the standard only has one line per Content, then any line value greater than 0 equates to no line to print. + if (main->setting.flag & (fss_read_main_flag_line_e | fss_read_main_flag_line_single_e) == (fss_read_main_flag_line_e | fss_read_main_flag_line_single_e)) { + if (main->setting.line) { + if (main->setting.flag & fss_read_main_flag_total_e) { + f_file_stream_lock(main->program.output.to); + + fss_read_print_zero(main); + + f_file_stream_unlock(main->program.output.to); + } + + main->setting.state.status = F_none; + + return; + } + } + + f_array_length_t i = 0; + f_array_length_t j = 0; + f_array_length_t k = 0; + f_array_length_t at = 0; + f_array_length_t line = 0; + f_array_length_t total = 0; + + // @todo this is originally from basic list, compare this against extended and determine what else needs to be done when it comes to quotes (consider checking if flags exist and performing appropriate modifications, or perhaps custom callback). There probably should be a standard flag for designating that quotes should be printed around Objects and the same for Contents. + // Example: + /* + f_print_dynamic_raw( + data->quotes_object.array[at] == f_fss_quote_type_single_e + ? f_fss_quote_single_s + : data->quotes_object.array[at] == f_fss_quote_type_backtick_e + ? f_fss_quote_backtick_s + : f_fss_quote_double_s, + main->program.output.to + ); + */ + + for (; i < main->setting.objects.used; ++i) { + + if (!names[i]) continue; + if (fss_read_signal_check(main)) return; + + if (at == main->setting.depths.array[0].value_at) { + if (main->setting.flag & fss_read_main_flag_line_e) { + + // For standards that only support one line per Object so when using "--at", then the only valid line is line 0. + if (main->setting.flag & fss_read_main_flag_line_single_e) break; + + line = 0; + + if (data->option & fss_basic_list_read_data_option_total_d) { + + // Total is always 1 in this case because "line" parameter forces a single line. + fss_read_print_number(&main->program.output, 1); + } + else { + fss_read_process_at_line(main, data, i, delimits_object, delimits_content, &line); + } + + if (main->setting.state.status == F_success) { + main->setting.state.status = F_none; + + return; + } + } + else if (main->setting.flag & fss_read_main_flag_columns_e) { + fss_read_print_number(&main->program.output, main->setting.contents.array[i].used); + } + else if (main->setting.flag & fss_read_main_flag_total_e) { + total = 0; + k = 0; + + // @todo this is originally from basic list, compare this against extended list and determine what else needs to be done. + + // Count each new line. + for (j = 0; j < main->setting.contents.array[i].used; ++j) { + + if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue; + if (main->setting.contents.array[i].array[j].start > main->setting.buffer.used) continue; + + for (k = main->setting.contents.array[i].array[j].start; k <= main->setting.contents.array[i].array[j].stop && k < main->setting.buffer.used; ++k) { + if (main->setting.buffer.string[k] == f_string_eol_s.string[0]) ++total; + } // for + } // for + + // If there are no newline characters but there is data, then this represents a single line. + if (main->setting.contents.array[i].used && !total) { + total = 1; + } + + fss_read_print_number(&main->program.output, total); + } + else if (main->setting.process_print_at) { + main->setting.process_print_at(main, i, delimits_object, delimits_content); + } + + main->setting.state.status = F_none; + + return; + } + + ++at; + } // for + + if (main->setting.flag & fss_read_main_flag_total_e) { + f_file_stream_lock(main->program.output.to); + + fss_read_print_number(&main->program.output, 0); + + f_file_stream_unlock(main->program.output.to); + } + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_at_ + +#ifndef _di_fss_read_process_normal_columns_ + void fss_read_process_normal_columns(void * const main, const bool names[]) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_columns_ + +#ifndef _di_fss_read_process_normal_line_ + void fss_read_process_normal_line(void * const main, const bool names[]) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_line_ + +#ifndef _di_fss_read_process_normal_load_ + void fss_read_process_normal_load(void * const main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_load_ + +#ifndef _di_fss_read_process_normal_name_ + void fss_read_process_normal_name(void * const main, const bool names[]) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_name_ + +#ifndef _di_fss_read_process_normal_print_at_ + void fss_read_process_normal_print_at(void * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_print_at_ + +#ifndef _di_fss_read_process_normal_read_ + void fss_read_process_normal_read(void * const main, const bool names[]) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_read_ + +#ifndef _di_fss_read_process_normal_total_ + void fss_read_process_normal_total(void * const main, const bool names[]) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_process_normal_total_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/process_normal.h b/level_3/fss_read/c/main/process_normal.h new file mode 100644 index 0000000..7c745ee --- /dev/null +++ b/level_3/fss_read/c/main/process_normal.h @@ -0,0 +1,226 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides process normal functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_process_normal_h +#define _fss_read_process_normal_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Process normally, reading from the input for the assigned FSS format. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: main.setting.process_at(). + * Errors (with error bit) from: main.setting.process_columns(). + * Errors (with error bit) from: main.setting.process_line(). + * Errors (with error bit) from: main.setting.process_load(). + * Errors (with error bit) from: main.setting.process_name(). + * Errors (with error bit) from: main.setting.process_print_at(). + * Errors (with error bit) from: main.setting.process_read(). + * Errors (with error bit) from: main.setting.process_total(). + * + * Errors (with error bit) from: fss_read_signal_check(). + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_ + extern void fss_read_process_normal(void * const main); +#endif // _di_fss_read_process_normal_ + +/** + * Process buffer according to "at" parameter rules. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * @param names + * An array of booleans representing if the name at a given index is enabled. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * @param delimits_object + * The delimits array representing a delimited Object. + * This represents the positions within the current Object at the "at" position. + * @param delimits_content + * The delimits array representing a delimited Content. + * This represents the positions within the current Content at the "at" position. + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_at_ + extern void fss_read_process_normal_at(void * const main, const bool names[], const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); +#endif // _di_fss_read_process_normal_at_ + +/** + * Process buffer according to "columns" parameter rules. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * @param names + * An array of booleans representing if the name at a given index is enabled. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_columns_ + extern void fss_read_process_normal_columns(void * const main, const bool names[]); +#endif // _di_fss_read_process_normal_columns_ + +/** + * Process buffer according to "line" parameter rules. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * @param names + * An array of booleans representing if the name at a given index is enabled. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_line_ + extern void fss_read_process_normal_line(void * const main, const bool names[]); +#endif // _di_fss_read_process_normal_line_ + +/** + * Process buffer according to "load" parameter rules. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_load_ + extern void fss_read_process_normal_load(void * const main); +#endif // _di_fss_read_process_normal_load_ + +/** + * Process buffer according to "name" parameter rules. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * @param names + * An array of booleans representing if the name at a given index is enabled. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_name_ + extern void fss_read_process_normal_name(void * const main, const bool names[]); +#endif // _di_fss_read_process_normal_name_ + +/** + * Process printing the buffer according to "at" position and given delimits. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * @param at + * The "at" position to be printed. + * @param delimits_object + * The delimits array representing a delimited Object. + * This represents the positions within the current Object at the "at" position. + * @param delimits_content + * The delimits array representing a delimited Content. + * This represents the positions within the current Content at the "at" position. + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_print_at_ + extern void fss_read_process_normal_print_at(void * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); +#endif // _di_fss_read_process_normal_print_at_ + +/** + * Process buffer according to "read" parameter rules. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * @param names + * An array of booleans representing if the name at a given index is enabled. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_read_ + extern void fss_read_process_normal_read(void * const main, const bool names[]); +#endif // _di_fss_read_process_normal_read_ + +/** + * Process buffer according to "total" parameter rules. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: fss_read_signal_check(). + * @param names + * An array of booleans representing if the name at a given index is enabled. + * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) + * + * @see fss_read_signal_check() + */ +#ifndef _di_fss_read_process_normal_total_ + extern void fss_read_process_normal_total(void * const main, const bool names[]); +#endif // _di_fss_read_process_normal_total_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_process_normal_h diff --git a/level_3/fss_read/data/build/settings b/level_3/fss_read/data/build/settings index 935c4f1..7988c53 100644 --- a/level_3/fss_read/data/build/settings +++ b/level_3/fss_read/data/build/settings @@ -37,7 +37,7 @@ build_libraries-individual_thread -lf_thread build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library main/fss_read.c main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c main/print/error.c main/print/message.c main/signal.c main/thread.c +build_sources_library main/fss_read.c main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c main/print/error.c main/print/message.c main/process_normal.c main/signal.c main/thread.c build_sources_library basic/fss_read.c basic/common.c basic/print.c build_sources_library basic_list/fss_read.c basic_list/common.c basic_list/print.c build_sources_library embedded_list/fss_read.c embedded_list/common.c embedded_list/print.c @@ -45,7 +45,7 @@ build_sources_library extended/fss_read.c extended/common.c extended/print.c build_sources_library extended_list/fss_read.c extended_list/common.c extended_list/print.c build_sources_library payload/fss_read.c payload/common.c payload/print.c -build_sources_headers main/fss_read.h main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h main/print/error.h main/print/message.h main/signal.h main/thread.h +build_sources_headers main/fss_read.h main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h main/print/error.h main/print/message.h main/process_normal.h main/signal.h main/thread.h build_sources_headers basic/fss_read.h basic/common.h basic/print.h basic/private-common.h build_sources_headers basic_list/fss_read.h basic_list/common.h basic_list/print.h build_sources_headers embedded_list/fss_read.h embedded_list/common.h embedded_list/print.h diff --git a/level_3/fss_write/c/basic/print.h b/level_3/fss_write/c/basic/print.h index b049f95..9820d91 100644 --- a/level_3/fss_write/c/basic/print.h +++ b/level_3/fss_write/c/basic/print.h @@ -18,13 +18,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_basic_print_help_ extern f_status_t fss_write_basic_print_help(fl_print_t * const print); diff --git a/level_3/fss_write/c/basic_list/print.h b/level_3/fss_write/c/basic_list/print.h index 7b6c9fa..4d98e6f 100644 --- a/level_3/fss_write/c/basic_list/print.h +++ b/level_3/fss_write/c/basic_list/print.h @@ -18,13 +18,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_basic_list_print_help_ extern f_status_t fss_write_basic_list_print_help(fl_print_t * const print); diff --git a/level_3/fss_write/c/embedded_list/print.h b/level_3/fss_write/c/embedded_list/print.h index c9c760c..9e97887 100644 --- a/level_3/fss_write/c/embedded_list/print.h +++ b/level_3/fss_write/c/embedded_list/print.h @@ -18,13 +18,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_embedded_list_print_help_ extern f_status_t fss_write_embedded_list_print_help(fl_print_t * const print); diff --git a/level_3/fss_write/c/extended/print.h b/level_3/fss_write/c/extended/print.h index dfae8ef..640f8f4 100644 --- a/level_3/fss_write/c/extended/print.h +++ b/level_3/fss_write/c/extended/print.h @@ -18,13 +18,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_extended_print_help_ extern f_status_t fss_write_extended_print_help(fl_print_t * const print); diff --git a/level_3/fss_write/c/extended_list/print.h b/level_3/fss_write/c/extended_list/print.h index 6155e41..989b300 100644 --- a/level_3/fss_write/c/extended_list/print.h +++ b/level_3/fss_write/c/extended_list/print.h @@ -18,13 +18,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_extended_list_print_help_ extern f_status_t fss_write_extended_list_print_help(fl_print_t * const print); diff --git a/level_3/fss_write/c/main/main/print.h b/level_3/fss_write/c/main/main/print.h index 24ee31f..8a6ec40 100644 --- a/level_3/fss_write/c/main/main/print.h +++ b/level_3/fss_write/c/main/main/print.h @@ -18,6 +18,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * @param value * A string representing the value that is of an unknown format. @@ -26,7 +28,7 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_main_print_error_format_unknown_ extern f_status_t fss_write_main_print_error_format_unknown(fl_print_t * const print, const f_string_static_t value); @@ -38,13 +40,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_print_main_help_ extern f_status_t fss_write_main_print_help(fl_print_t * const print); diff --git a/level_3/fss_write/c/main/print/error.h b/level_3/fss_write/c/main/print/error.h index 42c738f..88f84e3 100644 --- a/level_3/fss_write/c/main/print/error.h +++ b/level_3/fss_write/c/main/print/error.h @@ -22,15 +22,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. - * - * @see fll_error_print() + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_print_error_ extern f_status_t fss_write_print_error(fl_print_t * const print, const f_string_t function); @@ -42,6 +42,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * @param function * The name of the function where the error happened. @@ -57,7 +59,7 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. * * @see fll_error_file_print() */ @@ -71,13 +73,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. * * @see fll_error_print() */ @@ -91,13 +95,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_print_error_one_content_only_ extern f_status_t fss_write_print_error_one_content_only(fl_print_t * const print); @@ -109,13 +115,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _fss_write_print_error_prepend_only_whitespace_ extern f_status_t fss_write_print_error_prepend_only_whitespace(fl_print_t * const print); @@ -127,13 +135,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_print_error_unsupported_eol_ extern f_status_t fss_write_print_error_unsupported_eol(fl_print_t * const print); diff --git a/level_3/fss_write/c/main/print/message.h b/level_3/fss_write/c/main/print/message.h index 66b20e0..6e00e71 100644 --- a/level_3/fss_write/c/main/print/message.h +++ b/level_3/fss_write/c/main/print/message.h @@ -24,6 +24,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. */ #ifndef _di_fss_write_print_message_help_ @@ -38,6 +40,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. */ #ifndef _di_fss_write_print_message_help_end_next_ @@ -52,6 +56,8 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. */ #ifndef _di_fss_write_print_message_help_pipe_ diff --git a/level_3/fss_write/c/payload/print.h b/level_3/fss_write/c/payload/print.h index b919613..32a179b 100644 --- a/level_3/fss_write/c/payload/print.h +++ b/level_3/fss_write/c/payload/print.h @@ -18,13 +18,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. * * @see fll_error_print() */ @@ -38,13 +40,15 @@ extern "C" { * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_write_payload_print_help_ extern f_status_t fss_write_payload_print_help(fl_print_t * const print);