From: Kevin Day Date: Thu, 23 Mar 2023 02:58:27 +0000 (-0500) Subject: Progress: Continue program related work, focusing on print and main structures for... X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=d120b9fbe5a1e62bfb043dc07827168baee9d5fc;p=fll Progress: Continue program related work, focusing on print and main structures for already migrated projects. I did a lot of mass replacements with absolutely no consideration to the non-migrated projects. The files were probably process and likely have a mess of some of the changes while not having any of the other migration changes. I've updated and did minimal runtime tests to confirm that the following projects work: - fake - fss_write - iki_read - iki_write - status_code - utf8 --- diff --git a/level_3/byte_dump/c/common.c b/level_3/byte_dump/c/common.c index 196467a..d1f5bad 100644 --- a/level_3/byte_dump/c/common.c +++ b/level_3/byte_dump/c/common.c @@ -79,34 +79,34 @@ extern "C" { #ifndef _di_byte_dump_setting_load_ void byte_dump_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, byte_dump_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = byte_dump_allocation_console_d; + main->setting.state.step_small = byte_dump_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = byte_dump_allocation_small_d; + main->setting.state.step_small = byte_dump_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[byte_dump_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & byte_dump_main_flag_print_first_e; + if (main->program.parameters.array[byte_dump_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & byte_dump_main_flag_print_first_e; } else { - setting->flag |= byte_dump_main_flag_print_first_e; + main->setting.flag |= byte_dump_main_flag_print_first_e; } - if (main->parameters.array[byte_dump_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & byte_dump_main_flag_print_last_e; + if (main->program.parameters.array[byte_dump_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & byte_dump_main_flag_print_last_e; } else { - setting->flag |= byte_dump_main_flag_print_last_e; + main->setting.flag |= byte_dump_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -124,13 +124,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -145,13 +145,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -159,26 +159,26 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[byte_dump_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= byte_dump_main_flag_help_e; + if (main->program.parameters.array[byte_dump_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= byte_dump_main_flag_help_e; return; } - if (main->parameters.array[byte_dump_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= byte_dump_main_flag_version_e; + if (main->program.parameters.array[byte_dump_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= byte_dump_main_flag_version_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[byte_dump_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= byte_dump_main_flag_strip_invalid_e; + if (main->program.parameters.array[byte_dump_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= byte_dump_main_flag_strip_invalid_e; } } #endif // _di_byte_dump_setting_load_ diff --git a/level_3/byte_dump/c/main.c b/level_3/byte_dump/c/main.c index 07f5c70..be9c1d8 100644 --- a/level_3/byte_dump/c/main.c +++ b/level_3/byte_dump/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = byte_dump_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = byte_dump_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = byte_dump_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - byte_dump_setting_load(arguments, &data, &setting); + byte_dump_setting_load(arguments, &data); } - byte_dump_main(&data, &setting); + byte_dump_main(&data); - byte_dump_setting_unload(&data, &setting); + byte_dump_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/control/c/common.c b/level_3/control/c/common.c index 75c690c..b64d50c 100644 --- a/level_3/control/c/common.c +++ b/level_3/control/c/common.c @@ -182,7 +182,7 @@ extern "C" { #ifndef _di_control_setting_load_ void control_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, control_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; setting->state.step_small = control_allocation_console_d; diff --git a/level_3/control/c/main.c b/level_3/control/c/main.c index b02424e..c2c0e3d 100644 --- a/level_3/control/c/main.c +++ b/level_3/control/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = control_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = control_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = control_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - control_setting_load(arguments, &data, &setting); + control_setting_load(arguments, &data); } - control_main(&data, &setting); + control_main(&data); - control_setting_unload(&data, &setting); + control_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index 3fc06c3..177abe8 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -215,12 +215,12 @@ extern "C" { #ifndef _di_controller_main_delete_ f_status_t controller_main_delete(controller_main_t * const main) { - f_console_parameters_delete(&main->parameters); + f_console_parameters_delete(&main->program.parameters); - macro_f_color_context_t_delete_simple(main->context); + macro_f_color_context_t_delete_simple(main->program.context); - f_string_dynamic_resize(0, &main->path_pid); - f_string_dynamic_resize(0, &main->path_setting); + f_string_dynamic_resize(0, &main->program.path_pid); + f_string_dynamic_resize(0, &main->program.path_setting); return F_none; } @@ -614,34 +614,34 @@ extern "C" { #ifndef _di_controller_setting_load_ void controller_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, controller_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = controller_allocation_console_d; + main->setting.state.step_small = controller_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = controller_allocation_small_d; + main->setting.state.step_small = controller_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[controller_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & controller_main_flag_print_first_e; + if (main->program.parameters.array[controller_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & controller_main_flag_print_first_e; } else { - setting->flag |= controller_main_flag_print_first_e; + main->setting.flag |= controller_main_flag_print_first_e; } - if (main->parameters.array[controller_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & controller_main_flag_print_last_e; + if (main->program.parameters.array[controller_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & controller_main_flag_print_last_e; } else { - setting->flag |= controller_main_flag_print_last_e; + main->setting.flag |= controller_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -659,13 +659,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -680,13 +680,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -694,32 +694,32 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[controller_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= controller_main_flag_help_e; + if (main->program.parameters.array[controller_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= controller_main_flag_help_e; return; } - if (main->parameters.array[controller_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= controller_main_flag_version_e; + if (main->program.parameters.array[controller_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= controller_main_flag_version_e; return; } - if (main->parameters.array[controller_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= controller_main_flag_copyright_e; + if (main->program.parameters.array[controller_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= controller_main_flag_copyright_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[controller_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= controller_main_flag_strip_invalid_e; + if (main->program.parameters.array[controller_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= controller_main_flag_strip_invalid_e; } } #endif // _di_controller_setting_load_ diff --git a/level_3/controller/c/main.c b/level_3/controller/c/main.c index 73c0ec7..06dcbaa 100644 --- a/level_3/controller/c/main.c +++ b/level_3/controller/c/main.c @@ -16,59 +16,59 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = controller_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = controller_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = controller_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - data.pid = getpid(); + data.program.pid = getpid(); - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); - f_file_umask_get(&data.umask); + f_file_umask_get(&data.program.umask); - data.default_engine = &controller_default_engine_s; - data.default_path_setting = &controller_path_settings_s; - data.default_path_setting_init = &controller_path_settings_init_s; - data.default_path_pid = &controller_path_pid_s; - data.default_path_pid_init = &controller_path_pid_init_s; - data.default_path_pid_prefix = &controller_path_pid_prefix_s; - data.default_path_pid_suffix = &controller_path_pid_suffix_s; - data.default_path_socket = &controller_path_socket_s; - data.default_path_socket_init = &controller_path_socket_init_s; - data.default_path_socket_prefix = &controller_path_socket_prefix_s; - data.default_path_socket_suffix = &controller_path_socket_suffix_s; - data.program_name = &controller_program_name_s; - data.program_name_long = &controller_program_name_long_s; + data.program.default_engine = &controller_default_engine_s; + data.program.default_path_setting = &controller_path_settings_s; + data.program.default_path_setting_init = &controller_path_settings_init_s; + data.program.default_path_pid = &controller_path_pid_s; + data.program.default_path_pid_init = &controller_path_pid_init_s; + data.program.default_path_pid_prefix = &controller_path_pid_prefix_s; + data.program.default_path_pid_suffix = &controller_path_pid_suffix_s; + data.program.default_path_socket = &controller_path_socket_s; + data.program.default_path_socket_init = &controller_path_socket_init_s; + data.program.default_path_socket_prefix = &controller_path_socket_prefix_s; + data.program.default_path_socket_suffix = &controller_path_socket_suffix_s; + data.program.program_name = &controller_program_name_s; + data.program.program_name_long = &controller_program_name_long_s; // When run as "init" by default, provide the default system-level init path. #ifdef _controller_as_init_ - data.as_init = F_true; + data.program.as_init = F_true; #else - data.as_init = F_false; + data.program.as_init = F_false; #endif // _controller_as_init_ { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - controller_setting_load(arguments, &data, &setting); + controller_setting_load(arguments, &data); } - controller_main(&data, &setting); + controller_main(&data); - controller_setting_unload(&data, &setting); + controller_setting_unload(&data); - controller_main_delete(&data); + controller_main_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); // When the child process exits, it must return the code to the parent so the parent knows how to handle the exit. if (status == F_child) { exit(data.child); } - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fake/c/main/common/type.h b/level_3/fake/c/main/common/type.h index 30e8e26..4c24669 100644 --- a/level_3/fake/c/main/common/type.h +++ b/level_3/fake/c/main/common/type.h @@ -186,7 +186,7 @@ extern "C" { * * file_documents_readme: The documents readme file data. * - * main: The main program and settings data. + * main: The program and settings data. */ #ifndef _di_fake_data_t_ typedef struct { diff --git a/level_3/fake/c/main/fake.c b/level_3/fake/c/main/fake.c index 5749053..558a66c 100644 --- a/level_3/fake/c/main/fake.c +++ b/level_3/fake/c/main/fake.c @@ -24,7 +24,6 @@ extern "C" { main->setting.state.status = F_none; if (main->setting.flag & (fake_main_flag_help_e | fake_main_flag_version_e | fake_main_flag_copyright_e)) { - if (main->setting.flag & fake_main_flag_help_e) { fake_print_message_help(&main->program.message); } diff --git a/level_3/fake/c/main/print/error.c b/level_3/fake/c/main/print/error.c index 8f4363a..3b3fe01 100644 --- a/level_3/fake/c/main/print/error.c +++ b/level_3/fake/c/main/print/error.c @@ -292,9 +292,7 @@ extern "C" { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - fake_main_t * const main = (fake_main_t *) print->custom; - - if (fll_error_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_none_e) == F_known_not) return F_false; + if (fll_error_print(print, F_status_set_fine(((fake_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_none_e) == F_known_not) return F_false; return F_true; } diff --git a/level_3/firewall/c/common.c b/level_3/firewall/c/common.c index ddbab0d..d491919 100644 --- a/level_3/firewall/c/common.c +++ b/level_3/firewall/c/common.c @@ -115,32 +115,32 @@ extern "C" { #ifndef _di_firewall_setting_load_ void firewall_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, firewall_setting_t * const setting, f_state_t * const state) { - if (!main || !setting) return; + if (!main) return; - setting->flag = 0; + main->setting.flag = 0; - setting->state.status = f_console_parameter_process(state, arguments, &main->parameters, &setting->state, 0); + main->setting.state.status = f_console_parameter_process(state, arguments, &main->program.parameters, &main->setting.state, 0); // Identify and pocess first/last parameters. - if (main->parameters.array[firewall_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & firewall_main_flag_print_first_e; + if (main->program.parameters.array[firewall_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & firewall_main_flag_print_first_e; } else { - setting->flag |= firewall_main_flag_print_first_e; + main->setting.flag |= firewall_main_flag_print_first_e; } - if (main->parameters.array[firewall_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & firewall_main_flag_print_last_e; + if (main->program.parameters.array[firewall_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & firewall_main_flag_print_last_e; } else { - setting->flag |= firewall_main_flag_print_last_e; + main->setting.flag |= firewall_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -158,13 +158,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -179,13 +179,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -193,26 +193,26 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[firewall_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= firewall_main_flag_help_e; + if (main->program.parameters.array[firewall_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= firewall_main_flag_help_e; return; } - if (main->parameters.array[firewall_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= firewall_main_flag_version_e; + if (main->program.parameters.array[firewall_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= firewall_main_flag_version_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[firewall_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= firewall_main_flag_strip_invalid_e; + if (main->program.parameters.array[firewall_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= firewall_main_flag_strip_invalid_e; } } #endif // _di_firewall_setting_load_ diff --git a/level_3/firewall/c/main.c b/level_3/firewall/c/main.c index 03333d0..a1c424e 100644 --- a/level_3/firewall/c/main.c +++ b/level_3/firewall/c/main.c @@ -15,33 +15,33 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = firewall_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = firewall_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = firewall_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - firewall_setting_load(arguments, &data, &setting); + firewall_setting_load(arguments, &data); } - firewall_main(&data, &setting); + firewall_main(&data); - firewall_setting_unload(&data, &setting); + firewall_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); if (status == F_child) { exit(data.child); } - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_basic_list_read/c/common.c b/level_3/fss_basic_list_read/c/common.c index 83de53b..7da8248 100644 --- a/level_3/fss_basic_list_read/c/common.c +++ b/level_3/fss_basic_list_read/c/common.c @@ -73,34 +73,34 @@ extern "C" { #ifndef _di_fss_basic_list_read_setting_load_ void fss_basic_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = fss_basic_list_read_allocation_console_d; + main->setting.state.step_small = fss_basic_list_read_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = fss_basic_list_read_allocation_small_d; + main->setting.state.step_small = fss_basic_list_read_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[fss_basic_list_read_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_basic_list_read_main_flag_print_first_e; + if (main->program.parameters.array[fss_basic_list_read_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_basic_list_read_main_flag_print_first_e; } else { - setting->flag |= fss_basic_list_read_main_flag_print_first_e; + main->setting.flag |= fss_basic_list_read_main_flag_print_first_e; } - if (main->parameters.array[fss_basic_list_read_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_basic_list_read_main_flag_print_last_e; + if (main->program.parameters.array[fss_basic_list_read_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_basic_list_read_main_flag_print_last_e; } else { - setting->flag |= fss_basic_list_read_main_flag_print_last_e; + main->setting.flag |= fss_basic_list_read_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -118,13 +118,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -139,13 +139,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -153,32 +153,32 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[fss_basic_list_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_list_read_main_flag_help_e; + if (main->program.parameters.array[fss_basic_list_read_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_basic_list_read_main_flag_help_e; return; } - if (main->parameters.array[fss_basic_list_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_list_read_main_flag_version_e; + if (main->program.parameters.array[fss_basic_list_read_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_basic_list_read_main_flag_version_e; return; } - if (main->parameters.array[fss_basic_list_read_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_list_read_main_flag_copyright_e; + if (main->program.parameters.array[fss_basic_list_read_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_basic_list_read_main_flag_copyright_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[fss_basic_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_list_read_main_flag_strip_invalid_e; + if (main->program.parameters.array[fss_basic_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= fss_basic_list_read_main_flag_strip_invalid_e; } } #endif // _di_fss_basic_list_read_setting_load_ diff --git a/level_3/fss_basic_list_read/c/main.c b/level_3/fss_basic_list_read/c/main.c index dbb3c36..be01e36 100644 --- a/level_3/fss_basic_list_read/c/main.c +++ b/level_3/fss_basic_list_read/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = fss_basic_list_read_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_basic_list_read_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_basic_list_read_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_basic_list_read_setting_load(arguments, &data, &setting); + fss_basic_list_read_setting_load(arguments, &data); } - fss_basic_list_read_main(&data, &setting); + fss_basic_list_read_main(&data); - fss_basic_list_read_setting_unload(&data, &setting); + fss_basic_list_read_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_basic_read/c/common.c b/level_3/fss_basic_read/c/common.c index d7c1845..f9fd3e4 100644 --- a/level_3/fss_basic_read/c/common.c +++ b/level_3/fss_basic_read/c/common.c @@ -72,34 +72,34 @@ extern "C" { #ifndef _di_fss_basic_read_setting_load_ void fss_basic_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_read_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = fss_basic_read_allocation_console_d; + main->setting.state.step_small = fss_basic_read_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = fss_basic_read_allocation_small_d; + main->setting.state.step_small = fss_basic_read_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[fss_basic_read_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_basic_read_main_flag_print_first_e; + if (main->program.parameters.array[fss_basic_read_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_basic_read_main_flag_print_first_e; } else { - setting->flag |= fss_basic_read_main_flag_print_first_e; + main->setting.flag |= fss_basic_read_main_flag_print_first_e; } - if (main->parameters.array[fss_basic_read_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_basic_read_main_flag_print_last_e; + if (main->program.parameters.array[fss_basic_read_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_basic_read_main_flag_print_last_e; } else { - setting->flag |= fss_basic_read_main_flag_print_last_e; + main->setting.flag |= fss_basic_read_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -117,13 +117,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -138,13 +138,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -152,32 +152,32 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[fss_basic_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_read_main_flag_help_e; + if (main->program.parameters.array[fss_basic_read_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_basic_read_main_flag_help_e; return; } - if (main->parameters.array[fss_basic_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_read_main_flag_version_e; + if (main->program.parameters.array[fss_basic_read_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_basic_read_main_flag_version_e; return; } - if (main->parameters.array[fss_basic_read_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_read_main_flag_copyright_e; + if (main->program.parameters.array[fss_basic_read_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_basic_read_main_flag_copyright_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[fss_basic_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= fss_basic_read_main_flag_strip_invalid_e; + if (main->program.parameters.array[fss_basic_read_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= fss_basic_read_main_flag_strip_invalid_e; } } #endif // _di_fss_basic_read_setting_load_ diff --git a/level_3/fss_basic_read/c/main.c b/level_3/fss_basic_read/c/main.c index b710253..771393c 100644 --- a/level_3/fss_basic_read/c/main.c +++ b/level_3/fss_basic_read/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = fss_basic_read_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_basic_read_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_basic_read_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_basic_read_setting_load(arguments, &data, &setting); + fss_basic_read_setting_load(arguments, &data); } - fss_basic_read_main(&data, &setting); + fss_basic_read_main(&data); - fss_basic_read_setting_unload(&data, &setting); + fss_basic_read_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_embedded_list_read/c/common.c b/level_3/fss_embedded_list_read/c/common.c index 96c64c7..4b632a2 100644 --- a/level_3/fss_embedded_list_read/c/common.c +++ b/level_3/fss_embedded_list_read/c/common.c @@ -71,34 +71,34 @@ extern "C" { #ifndef _di_fss_embedded_list_read_setting_load_ void fss_embedded_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_embedded_list_read_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = fss_embedded_list_read_allocation_console_d; + main->setting.state.step_small = fss_embedded_list_read_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = fss_embedded_list_read_allocation_small_d; + main->setting.state.step_small = fss_embedded_list_read_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[fss_embedded_list_read_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_embedded_list_read_main_flag_print_first_e; + if (main->program.parameters.array[fss_embedded_list_read_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_embedded_list_read_main_flag_print_first_e; } else { - setting->flag |= fss_embedded_list_read_main_flag_print_first_e; + main->setting.flag |= fss_embedded_list_read_main_flag_print_first_e; } - if (main->parameters.array[fss_embedded_list_read_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_embedded_list_read_main_flag_print_last_e; + if (main->program.parameters.array[fss_embedded_list_read_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_embedded_list_read_main_flag_print_last_e; } else { - setting->flag |= fss_embedded_list_read_main_flag_print_last_e; + main->setting.flag |= fss_embedded_list_read_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -116,13 +116,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -137,13 +137,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -151,32 +151,32 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[fss_embedded_list_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_embedded_list_read_main_flag_help_e; + if (main->program.parameters.array[fss_embedded_list_read_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_embedded_list_read_main_flag_help_e; return; } - if (main->parameters.array[fss_embedded_list_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_embedded_list_read_main_flag_version_e; + if (main->program.parameters.array[fss_embedded_list_read_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_embedded_list_read_main_flag_version_e; return; } - if (main->parameters.array[fss_embedded_list_read_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= fss_embedded_list_read_main_flag_copyright_e; + if (main->program.parameters.array[fss_embedded_list_read_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_embedded_list_read_main_flag_copyright_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[fss_embedded_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= fss_embedded_list_read_main_flag_strip_invalid_e; + if (main->program.parameters.array[fss_embedded_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= fss_embedded_list_read_main_flag_strip_invalid_e; } } #endif // _di_fss_embedded_list_read_setting_load_ diff --git a/level_3/fss_embedded_list_read/c/main.c b/level_3/fss_embedded_list_read/c/main.c index 9ea6188..fc94ae9 100644 --- a/level_3/fss_embedded_list_read/c/main.c +++ b/level_3/fss_embedded_list_read/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = fss_embedded_list_read_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_embedded_list_read_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_embedded_list_read_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_embedded_list_read_setting_load(arguments, &data, &setting); + fss_embedded_list_read_setting_load(arguments, &data); } - fss_embedded_list_read_main(&data, &setting); + fss_embedded_list_read_main(&data); - fss_embedded_list_read_setting_unload(&data, &setting); + fss_embedded_list_read_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_extended_list_read/c/common.c b/level_3/fss_extended_list_read/c/common.c index fcec750..765b9fc 100644 --- a/level_3/fss_extended_list_read/c/common.c +++ b/level_3/fss_extended_list_read/c/common.c @@ -79,34 +79,34 @@ extern "C" { #ifndef _di_fss_extended_list_read_setting_load_ void fss_extended_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = fss_extended_list_read_allocation_console_d; + main->setting.state.step_small = fss_extended_list_read_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = fss_extended_list_read_allocation_small_d; + main->setting.state.step_small = fss_extended_list_read_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[fss_extended_list_read_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_extended_list_read_main_flag_print_first_e; + if (main->program.parameters.array[fss_extended_list_read_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_extended_list_read_main_flag_print_first_e; } else { - setting->flag |= fss_extended_list_read_main_flag_print_first_e; + main->setting.flag |= fss_extended_list_read_main_flag_print_first_e; } - if (main->parameters.array[fss_extended_list_read_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_extended_list_read_main_flag_print_last_e; + if (main->program.parameters.array[fss_extended_list_read_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_extended_list_read_main_flag_print_last_e; } else { - setting->flag |= fss_extended_list_read_main_flag_print_last_e; + main->setting.flag |= fss_extended_list_read_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -124,13 +124,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -145,13 +145,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -159,32 +159,32 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[fss_extended_list_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_list_read_main_flag_help_e; + if (main->program.parameters.array[fss_extended_list_read_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_extended_list_read_main_flag_help_e; return; } - if (main->parameters.array[fss_extended_list_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_list_read_main_flag_version_e; + if (main->program.parameters.array[fss_extended_list_read_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_extended_list_read_main_flag_version_e; return; } - if (main->parameters.array[fss_extended_list_read_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_list_read_main_flag_copyright_e; + if (main->program.parameters.array[fss_extended_list_read_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_extended_list_read_main_flag_copyright_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[fss_extended_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_list_read_main_flag_strip_invalid_e; + if (main->program.parameters.array[fss_extended_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= fss_extended_list_read_main_flag_strip_invalid_e; } } #endif // _di_fss_extended_list_read_setting_load_ diff --git a/level_3/fss_extended_list_read/c/main.c b/level_3/fss_extended_list_read/c/main.c index 2772e11..bfcbedf 100644 --- a/level_3/fss_extended_list_read/c/main.c +++ b/level_3/fss_extended_list_read/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = fss_extended_list_read_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_extended_list_read_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_extended_list_read_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_extended_list_read_setting_load(arguments, &data, &setting); + fss_extended_list_read_setting_load(arguments, &data); } - fss_extended_list_read_main(&data, &setting); + fss_extended_list_read_main(&data); - fss_extended_list_read_setting_unload(&data, &setting); + fss_extended_list_read_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_extended_read/c/common.c b/level_3/fss_extended_read/c/common.c index 844e7ec..eb7f77d 100644 --- a/level_3/fss_extended_read/c/common.c +++ b/level_3/fss_extended_read/c/common.c @@ -72,34 +72,34 @@ extern "C" { #ifndef _di_fss_extended_read_setting_load_ void fss_extended_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_read_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = fss_extended_read_allocation_console_d; + main->setting.state.step_small = fss_extended_read_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = fss_extended_read_allocation_small_d; + main->setting.state.step_small = fss_extended_read_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[fss_extended_read_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_extended_read_main_flag_print_first_e; + if (main->program.parameters.array[fss_extended_read_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_extended_read_main_flag_print_first_e; } else { - setting->flag |= fss_extended_read_main_flag_print_first_e; + main->setting.flag |= fss_extended_read_main_flag_print_first_e; } - if (main->parameters.array[fss_extended_read_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_extended_read_main_flag_print_last_e; + if (main->program.parameters.array[fss_extended_read_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_extended_read_main_flag_print_last_e; } else { - setting->flag |= fss_extended_read_main_flag_print_last_e; + main->setting.flag |= fss_extended_read_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -117,13 +117,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -138,13 +138,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -152,32 +152,32 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[fss_extended_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_read_main_flag_help_e; + if (main->program.parameters.array[fss_extended_read_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_extended_read_main_flag_help_e; return; } - if (main->parameters.array[fss_extended_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_read_main_flag_version_e; + if (main->program.parameters.array[fss_extended_read_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_extended_read_main_flag_version_e; return; } - if (main->parameters.array[fss_extended_read_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_read_main_flag_copyright_e; + if (main->program.parameters.array[fss_extended_read_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_extended_read_main_flag_copyright_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[fss_extended_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= fss_extended_read_main_flag_strip_invalid_e; + if (main->program.parameters.array[fss_extended_read_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= fss_extended_read_main_flag_strip_invalid_e; } } #endif // _di_fss_extended_read_setting_load_ diff --git a/level_3/fss_extended_read/c/main.c b/level_3/fss_extended_read/c/main.c index 64b0324..45f6899 100644 --- a/level_3/fss_extended_read/c/main.c +++ b/level_3/fss_extended_read/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = fss_extended_read_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_extended_read_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_extended_read_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_extended_read_setting_load(arguments, &data, &setting); + fss_extended_read_setting_load(arguments, &data); } - fss_extended_read_main(&data, &setting); + fss_extended_read_main(&data); - fss_extended_read_setting_unload(&data, &setting); + fss_extended_read_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_identify/c/common.c b/level_3/fss_identify/c/common.c index 271f9db..8eee4d2 100644 --- a/level_3/fss_identify/c/common.c +++ b/level_3/fss_identify/c/common.c @@ -39,34 +39,34 @@ extern "C" { #ifndef _di_fss_identify_setting_load_ void fss_identify_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_identify_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = fss_identify_allocation_console_d; + main->setting.state.step_small = fss_identify_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = fss_identify_allocation_small_d; + main->setting.state.step_small = fss_identify_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[fss_identify_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_identify_main_flag_print_first_e; + if (main->program.parameters.array[fss_identify_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_identify_main_flag_print_first_e; } else { - setting->flag |= fss_identify_main_flag_print_first_e; + main->setting.flag |= fss_identify_main_flag_print_first_e; } - if (main->parameters.array[fss_identify_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_identify_main_flag_print_last_e; + if (main->program.parameters.array[fss_identify_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_identify_main_flag_print_last_e; } else { - setting->flag |= fss_identify_main_flag_print_last_e; + main->setting.flag |= fss_identify_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -84,13 +84,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -105,13 +105,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -119,32 +119,32 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[fss_identify_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_identify_main_flag_help_e; + if (main->program.parameters.array[fss_identify_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_identify_main_flag_help_e; return; } - if (main->parameters.array[fss_identify_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_identify_main_flag_version_e; + if (main->program.parameters.array[fss_identify_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_identify_main_flag_version_e; return; } - if (main->parameters.array[fss_identify_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= fss_identify_main_flag_copyright_e; + if (main->program.parameters.array[fss_identify_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_identify_main_flag_copyright_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[fss_identify_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= fss_identify_main_flag_strip_invalid_e; + if (main->program.parameters.array[fss_identify_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= fss_identify_main_flag_strip_invalid_e; } } #endif // _di_fss_identify_setting_load_ diff --git a/level_3/fss_identify/c/main.c b/level_3/fss_identify/c/main.c index 4aba210..d94ad0e 100644 --- a/level_3/fss_identify/c/main.c +++ b/level_3/fss_identify/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = fss_identify_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_identify_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_identify_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_identify_setting_load(arguments, &data, &setting); + fss_identify_setting_load(arguments, &data); } - fss_identify_main(&data, &setting); + fss_identify_main(&data); - fss_identify_setting_unload(&data, &setting); + fss_identify_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_payload_read/c/common.c b/level_3/fss_payload_read/c/common.c index 15b4d22..73c378a 100644 --- a/level_3/fss_payload_read/c/common.c +++ b/level_3/fss_payload_read/c/common.c @@ -73,34 +73,34 @@ extern "C" { #ifndef _di_fss_payload_read_setting_load_ void fss_payload_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_read_setting_t * const setting) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = fss_payload_read_allocation_console_d; + main->setting.state.step_small = fss_payload_read_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = fss_payload_read_allocation_small_d; + main->setting.state.step_small = fss_payload_read_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[payload_read_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & payload_read_main_flag_print_first_e; + if (main->program.parameters.array[payload_read_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & payload_read_main_flag_print_first_e; } else { - setting->flag |= payload_read_main_flag_print_first_e; + main->setting.flag |= payload_read_main_flag_print_first_e; } - if (main->parameters.array[payload_read_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & payload_read_main_flag_print_last_e; + if (main->program.parameters.array[payload_read_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & payload_read_main_flag_print_last_e; } else { - setting->flag |= payload_read_main_flag_print_last_e; + main->setting.flag |= payload_read_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -118,13 +118,13 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -139,13 +139,13 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - fll_error_print(main->error, F_status_set_fine(setting->state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); + if (F_status_is_error(main->setting.state.status)) { + fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error); } return; @@ -153,32 +153,32 @@ extern "C" { } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[fss_payload_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_read_main_flag_help_e; + if (main->program.parameters.array[fss_payload_read_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_payload_read_main_flag_help_e; return; } - if (main->parameters.array[fss_payload_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_read_main_flag_version_e; + if (main->program.parameters.array[fss_payload_read_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_payload_read_main_flag_version_e; return; } - if (main->parameters.array[fss_payload_read_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_read_main_flag_copyright_e; + if (main->program.parameters.array[fss_payload_read_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_payload_read_main_flag_copyright_e; return; } - f_string_static_t * const args = main->parameters.arguments.array; + f_string_static_t * const args = main->program.parameters.arguments.array; - if (main->parameters.array[fss_payload_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_read_main_flag_strip_invalid_e; + if (main->program.parameters.array[fss_payload_read_parameter_strip_invalid_e].result & f_console_result_found_e) { + main->setting.flag |= fss_payload_read_main_flag_strip_invalid_e; } } #endif // _di_fss_payload_read_setting_load_ diff --git a/level_3/fss_payload_read/c/main.c b/level_3/fss_payload_read/c/main.c index 3fd77e7..9058dd7 100644 --- a/level_3/fss_payload_read/c/main.c +++ b/level_3/fss_payload_read/c/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = fss_payload_read_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_payload_read_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_payload_read_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_payload_read_setting_load(arguments, &data, &setting); + fss_payload_read_setting_load(arguments, &data); } - fss_payload_read_main(&data, &setting); + fss_payload_read_main(&data); - fss_payload_read_setting_unload(&data, &setting); + fss_payload_read_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_write/c/basic/fss_write.c b/level_3/fss_write/c/basic/fss_write.c index 698abcc..a2815d2 100644 --- a/level_3/fss_write/c/basic/fss_write.c +++ b/level_3/fss_write/c/basic/fss_write.c @@ -6,44 +6,44 @@ extern "C" { #endif #ifndef _di_fss_write_basic_process_content_ - void fss_write_basic_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + void fss_write_basic_process_content(void * const void_main, const bool last) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->content) { + if (main->setting.content) { fl_fss_basic_content_write( - *setting->content, - (setting->flag & fss_write_main_flag_partial_e) + *main->setting.content, + (main->setting.flag & fss_write_main_flag_partial_e) ? f_fss_complete_partial_e : f_fss_complete_full_e, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_content_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_basic_content_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_object_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_content_end_e) { - setting->state.status = f_string_dynamic_append(f_fss_basic_close_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_object_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_close_s, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } @@ -51,60 +51,60 @@ extern "C" { #endif // _di_fss_write_basic_process_content_ #ifndef _di_fss_write_basic_process_help_ - void fss_write_basic_process_help(fll_program_data_t * const main, void * const void_setting) { + void fss_write_basic_process_help(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_basic_print_help(void_setting, main->message); + fss_write_basic_print_help(&((fss_write_main_t *) void_main)->program.message); } #endif // _di_fss_write_basic_process_help_ #ifndef _di_fss_write_basic_process_object_ - void fss_write_basic_process_object(fll_program_data_t * const main, void * const void_setting) { + void fss_write_basic_process_object(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->object) { + if (main->setting.object) { fl_fss_basic_object_write( - *setting->object, - setting->quote.used - ? setting->quote.string[0] + *main->setting.object, + main->setting.quote.used + ? main->setting.quote.string[0] : f_fss_quote_double_s.string[0], - (setting->flag & fss_write_main_flag_partial_e) - ? (setting->flag & fss_write_main_flag_trim_e) + (main->setting.flag & fss_write_main_flag_partial_e) + ? (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_trim_e : f_fss_complete_none_e - : (setting->flag & fss_write_main_flag_trim_e) + : (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_object_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_basic_object_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_content_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_object_open_e) { - setting->state.status = f_string_dynamic_append(f_fss_basic_open_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_content_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_open_s, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } diff --git a/level_3/fss_write/c/basic/fss_write.h b/level_3/fss_write/c/basic/fss_write.h index a69eaae..7ac9851 100644 --- a/level_3/fss_write/c/basic/fss_write.h +++ b/level_3/fss_write/c/basic/fss_write.h @@ -45,12 +45,13 @@ // FSS Write includes. #include #include -#include -#include -#include +#include +#include +#include #include #include -#include +#include +#include #include #ifdef __cplusplus @@ -61,54 +62,48 @@ extern "C" { * Process a single Content, printing the FSS-0000 (Basic) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. * @param last * If TRUE, then this is the last Content in the Content set. * If FALSE, then this is not the last Content in the Content set. */ #ifndef _di_fss_write_basic_process_content_ - extern void fss_write_basic_process_content(fll_program_data_t * const main, void * const setting, const bool last); + extern void fss_write_basic_process_content(void * const main, const bool last); #endif // _di_fss_write_basic_process_content_ /** * Process help for FSS-0000 (Basic). * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This does not alter setting.state.status. + * This does not alter main.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_write_basic_process_help_ - extern void fss_write_basic_process_help(fll_program_data_t * const main, void * const setting); + extern void fss_write_basic_process_help(void * const main); #endif // _di_fss_write_basic_process_help_ /** * Process a single Object, printing the FSS-0000 (Basic) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. */ #ifndef _di_fss_write_basic_process_object_ - extern void fss_write_basic_process_object(fll_program_data_t * const main, void * const setting); + extern void fss_write_basic_process_object(void * const main); #endif // _di_fss_write_basic_process_object_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/basic/main.c b/level_3/fss_write/c/basic/main.c index fe2d361..702e839 100644 --- a/level_3/fss_write/c/basic/main.c +++ b/level_3/fss_write/c/basic/main.c @@ -15,40 +15,40 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.warning.custom = (void *) &data; data.program.debug.custom = (void *) &data; - setting.state.custom = (void *) &data; - setting.standard = fss_write_basic_standard_s; - setting.process_content = &fss_write_basic_process_content; - setting.process_help = &fss_write_basic_process_help; - setting.process_normal = &fss_write_process_normal; - setting.process_object = &fss_write_basic_process_object; - setting.process_pipe = &fss_write_process_pipe; - setting.process_set = &fss_write_process_set; + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_write_basic_standard_s; + data.setting.process_content = &fss_write_basic_process_content; + data.setting.process_help = &fss_write_basic_process_help; + data.setting.process_normal = &fss_write_process_normal; + data.setting.process_object = &fss_write_basic_process_object; + data.setting.process_pipe = &fss_write_process_pipe; + data.setting.process_set = &fss_write_process_set; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; - data.parameters.used = fss_write_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_write_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_write_setting_load(arguments, &data, &setting, 0); + fss_write_setting_load(arguments, &data, 0); } - fss_write_main(&data, &setting); + fss_write_main(&data); - fss_write_setting_unload(&data, &setting); + fss_write_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_write/c/basic/print.c b/level_3/fss_write/c/basic/print.c index 7c24b21..50e38f3 100644 --- a/level_3/fss_write/c/basic/print.c +++ b/level_3/fss_write/c/basic/print.c @@ -5,32 +5,32 @@ extern "C" { #endif #ifndef _di_fss_write_basic_print_help_ - f_status_t fss_write_basic_print_help(fss_write_setting_t * const setting, const fl_print_t print) { + f_status_t fss_write_basic_print_help(fl_print_t * const print) { - if (!setting) return F_status_set_error(F_output_not); + if (!print) return F_status_set_error(F_output_not); - f_file_stream_lock(print.to); + f_file_stream_lock(print->to); fll_program_print_help_header(print, fss_write_basic_program_name_long_s, fss_write_program_version_s); - fss_write_print_help(setting, print); + fss_write_print_message_help(print); - f_print_dynamic_raw(f_string_eol_s, print.to); + f_print_dynamic_raw(f_string_eol_s, print->to); fll_program_print_help_usage(print, fss_write_basic_program_name_s, f_string_empty_s); - fss_write_print_help_pipe(setting, print); + fss_write_print_message_help_pipe(print); - fss_write_print_help_end_next(setting, print); + fss_write_print_message_help_end_next(print); - fl_print_format("%r The FSS-0000 (Basic) specification does not support multi-line Content, therefore the parameter '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_prepend_s, print.set->notable); - fl_print_format(" does nothing.%r%r", print.to, f_string_eol_s, f_string_eol_s); + fl_print_format("%r The FSS-0000 (Basic) specification does not support multi-line Content, therefore the parameter '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_prepend_s, print->set->notable); + fl_print_format(" does nothing.%r%r", print->to, f_string_eol_s, f_string_eol_s); - fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); - fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); return F_none; } diff --git a/level_3/fss_write/c/basic/print.h b/level_3/fss_write/c/basic/print.h index 611e19d..b049f95 100644 --- a/level_3/fss_write/c/basic/print.h +++ b/level_3/fss_write/c/basic/print.h @@ -15,13 +15,11 @@ extern "C" { /** * Print help for FSS-0000 (Basic). * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print * The output structure to print to. * + * This does not alter print.custom.setting.state.status. + * * @return * F_none on success. * F_output_not on success, but no printing is performed. @@ -29,7 +27,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_fss_write_basic_print_help_ - extern f_status_t fss_write_basic_print_help(fss_write_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_write_basic_print_help(fl_print_t * const print); #endif // _di_fss_write_basic_print_help_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/basic_list/fss_write.c b/level_3/fss_write/c/basic_list/fss_write.c index 39c6f25..120fc95 100644 --- a/level_3/fss_write/c/basic_list/fss_write.c +++ b/level_3/fss_write/c/basic_list/fss_write.c @@ -6,47 +6,47 @@ extern "C" { #endif #ifndef _di_fss_write_basic_list_process_content_ - void fss_write_basic_list_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + void fss_write_basic_list_process_content(void * const void_main, const bool last) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->content) { + if (main->setting.content) { fl_fss_basic_list_content_write( - *setting->content, - (setting->flag & fss_write_main_flag_partial_e) + *main->setting.content, + (main->setting.flag & fss_write_main_flag_partial_e) ? f_fss_complete_partial_e - : (setting->flag & fss_write_main_flag_trim_e) + : (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e, - &setting->prepend, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.prepend, + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_content_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_basic_list_content_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_object_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_content_end_e) { - setting->state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_object_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } @@ -54,61 +54,61 @@ extern "C" { #endif // _di_fss_write_basic_list_process_content_ #ifndef _di_fss_write_basic_list_process_help_ - void fss_write_basic_list_process_help(fll_program_data_t * const main, void * const void_setting) { + void fss_write_basic_list_process_help(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_basic_list_print_help(void_setting, main->message); + fss_write_basic_list_print_help(&((fss_write_main_t *) void_main)->program.message); } #endif // _di_fss_write_basic_list_process_help_ #ifndef _di_fss_write_basic_list_process_object_ - void fss_write_basic_list_process_object(fll_program_data_t * const main, void * const void_setting) { + void fss_write_basic_list_process_object(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->object) { + if (main->setting.object) { fl_fss_basic_list_object_write( - *setting->object, - (setting->flag & fss_write_main_flag_partial_e) - ? (setting->flag & fss_write_main_flag_trim_e) + *main->setting.object, + (main->setting.flag & fss_write_main_flag_partial_e) + ? (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_trim_e : f_fss_complete_none_e - : (setting->flag & fss_write_main_flag_trim_e) + : (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_basic_list_object_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_content_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_object_open_e) { - setting->state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_content_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &main->setting.buffer); - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &setting->buffer); + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &main->setting.buffer); } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } diff --git a/level_3/fss_write/c/basic_list/fss_write.h b/level_3/fss_write/c/basic_list/fss_write.h index 9058c44..fe27f9f 100644 --- a/level_3/fss_write/c/basic_list/fss_write.h +++ b/level_3/fss_write/c/basic_list/fss_write.h @@ -46,12 +46,13 @@ // FSS Write includes. #include #include -#include -#include -#include +#include +#include +#include #include #include -#include +#include +#include #include #ifdef __cplusplus @@ -62,54 +63,48 @@ extern "C" { * Process a single Content, printing the FSS-0002 (Basic List) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. * @param last * If TRUE, then this is the last Content in the Content set. * If FALSE, then this is not the last Content in the Content set. */ #ifndef _di_fss_write_basic_list_process_content_ - extern void fss_write_basic_list_process_content(fll_program_data_t * const main, void * const setting, const bool last); + extern void fss_write_basic_list_process_content(void * const main, const bool last); #endif // _di_fss_write_basic_list_process_content_ /** * Process help for FSS-0002 (Basic List). * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This does not alter setting.state.status. + * This does not alter main.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_write_basic_list_process_help_ - extern void fss_write_basic_list_process_help(fll_program_data_t * const main, void * const setting); + extern void fss_write_basic_list_process_help(void * const main); #endif // _di_fss_write_basic_list_process_help_ /** * Process a single Object, printing the FSS-0002 (Basic List) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. */ #ifndef _di_fss_write_basic_list_process_object_ - extern void fss_write_basic_list_process_object(fll_program_data_t * const main, void * const setting); + extern void fss_write_basic_list_process_object(void * const main); #endif // _di_fss_write_basic_list_process_object_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/basic_list/main.c b/level_3/fss_write/c/basic_list/main.c index 256d415..78fdb2b 100644 --- a/level_3/fss_write/c/basic_list/main.c +++ b/level_3/fss_write/c/basic_list/main.c @@ -15,40 +15,40 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.warning.custom = (void *) &data; data.program.debug.custom = (void *) &data; - setting.state.custom = (void *) &data; - setting.standard = fss_write_basic_list_standard_s; - setting.process_content = &fss_write_basic_list_process_content; - setting.process_help = &fss_write_basic_list_process_help; - setting.process_normal = &fss_write_process_normal; - setting.process_object = &fss_write_basic_list_process_object; - setting.process_pipe = &fss_write_process_pipe; - setting.process_set = &fss_write_process_set; + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_write_basic_list_standard_s; + data.setting.process_content = &fss_write_basic_list_process_content; + data.setting.process_help = &fss_write_basic_list_process_help; + data.setting.process_normal = &fss_write_process_normal; + data.setting.process_object = &fss_write_basic_list_process_object; + data.setting.process_pipe = &fss_write_process_pipe; + data.setting.process_set = &fss_write_process_set; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; - data.parameters.used = fss_write_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_write_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_write_setting_load(arguments, &data, &setting, 0); + fss_write_setting_load(arguments, &data, 0); } - fss_write_main(&data, &setting); + fss_write_main(&data); - fss_write_setting_unload(&data, &setting); + fss_write_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_write/c/basic_list/print.c b/level_3/fss_write/c/basic_list/print.c index ea68ed0..35ce56e 100644 --- a/level_3/fss_write/c/basic_list/print.c +++ b/level_3/fss_write/c/basic_list/print.c @@ -5,32 +5,32 @@ extern "C" { #endif #ifndef _di_fss_write_basic_list_print_help_ - f_status_t fss_write_basic_list_print_help(fss_write_setting_t * const setting, const fl_print_t print) { + f_status_t fss_write_basic_list_print_help(fl_print_t * const print) { - if (!setting) return F_status_set_error(F_output_not); + if (!print) return F_status_set_error(F_output_not); - f_file_stream_lock(print.to); + f_file_stream_lock(print->to); fll_program_print_help_header(print, fss_write_basic_list_program_name_long_s, fss_write_program_version_s); - fss_write_print_help(setting, print); + fss_write_print_message_help(print); - f_print_dynamic_raw(f_string_eol_s, print.to); + f_print_dynamic_raw(f_string_eol_s, print->to); fll_program_print_help_usage(print, fss_write_basic_list_program_name_s, f_string_empty_s); - fss_write_print_help_pipe(setting, print); + fss_write_print_message_help_pipe(print); - fss_write_print_help_end_next(setting, print); + fss_write_print_message_help_end_next(print); - fl_print_format("%r The FSS-0002 (Basic List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); - fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print.set->notable, f_string_eol_s, f_string_eol_s); + fl_print_format("%r The FSS-0002 (Basic List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print->set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); - fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); return F_none; } diff --git a/level_3/fss_write/c/basic_list/print.h b/level_3/fss_write/c/basic_list/print.h index 30538c1..7b6c9fa 100644 --- a/level_3/fss_write/c/basic_list/print.h +++ b/level_3/fss_write/c/basic_list/print.h @@ -15,13 +15,11 @@ extern "C" { /** * Print help for FSS-0002 (Basic List). * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print * The output structure to print to. * + * This does not alter print.custom.setting.state.status. + * * @return * F_none on success. * F_output_not on success, but no printing is performed. @@ -29,7 +27,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_fss_write_basic_list_print_help_ - extern f_status_t fss_write_basic_list_print_help(fss_write_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_write_basic_list_print_help(fl_print_t * const print); #endif // _di_fss_write_basic_list_print_help_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/embedded_list/fss_write.c b/level_3/fss_write/c/embedded_list/fss_write.c index 9d40954..a74c16c 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.c +++ b/level_3/fss_write/c/embedded_list/fss_write.c @@ -6,52 +6,52 @@ extern "C" { #endif #ifndef _di_fss_write_embedded_list_process_content_ - void fss_write_embedded_list_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + void fss_write_embedded_list_process_content(void * const void_main, const bool last) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->content) { + if (main->setting.content) { fl_fss_embedded_list_content_write( - *setting->content, - (setting->flag & fss_write_main_flag_partial_e) + *main->setting.content, + (main->setting.flag & fss_write_main_flag_partial_e) ? f_fss_complete_partial_e : last ? f_fss_complete_end_e : f_fss_complete_next_e, - &setting->prepend, - setting->ignores, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.prepend, + main->setting.ignores, + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_content_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_embedded_list_content_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_object_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_content_end_e) { - setting->state.status = f_string_dynamic_append(f_fss_embedded_list_close_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_object_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_close_s, &main->setting.buffer); - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = f_string_dynamic_append(f_fss_embedded_list_close_end_s, &setting->buffer); + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_close_end_s, &main->setting.buffer); } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } @@ -59,61 +59,61 @@ extern "C" { #endif // _di_fss_write_embedded_list_process_content_ #ifndef _di_fss_write_embedded_list_process_help_ - void fss_write_embedded_list_process_help(fll_program_data_t * const main, void * const void_setting) { + void fss_write_embedded_list_process_help(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_embedded_list_print_help(void_setting, main->message); + fss_write_embedded_list_print_help(&((fss_write_main_t *) void_main)->program.message); } #endif // _di_fss_write_embedded_list_process_help_ #ifndef _di_fss_write_embedded_list_process_object_ - void fss_write_embedded_list_process_object(fll_program_data_t * const main, void * const void_setting) { + void fss_write_embedded_list_process_object(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->object) { + if (main->setting.object) { fl_fss_embedded_list_object_write( - *setting->object, - (setting->flag & fss_write_main_flag_partial_e) - ? (setting->flag & fss_write_main_flag_trim_e) + *main->setting.object, + (main->setting.flag & fss_write_main_flag_partial_e) + ? (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_trim_e : f_fss_complete_none_e - : (setting->flag & fss_write_main_flag_trim_e) + : (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_object_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_embedded_list_object_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_content_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_object_open_e) { - setting->state.status = f_string_dynamic_append(f_fss_embedded_list_open_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_content_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_open_s, &main->setting.buffer); - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = f_string_dynamic_append(f_fss_embedded_list_open_end_s, &setting->buffer); + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_open_end_s, &main->setting.buffer); } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } diff --git a/level_3/fss_write/c/embedded_list/fss_write.h b/level_3/fss_write/c/embedded_list/fss_write.h index f8ca58c..35e1819 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.h +++ b/level_3/fss_write/c/embedded_list/fss_write.h @@ -45,12 +45,13 @@ // FSS Write includes. #include #include -#include -#include -#include +#include +#include +#include #include #include -#include +#include +#include #include #ifdef __cplusplus @@ -61,54 +62,48 @@ extern "C" { * Process a single Content, printing the FSS-0008 (Embedded List) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. * @param last * If TRUE, then this is the last Content in the Content set. * If FALSE, then this is not the last Content in the Content set. */ #ifndef _di_fss_write_embedded_list_process_content_ - extern void fss_write_embedded_list_process_content(fll_program_data_t * const main, void * const setting, const bool last); + extern void fss_write_embedded_list_process_content(void * const main, const bool last); #endif // _di_fss_write_embedded_list_process_content_ /** * Process help for FSS-0008 (Embedded List). * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This does not alter setting.state.status. + * This does not alter main.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_write_embedded_list_process_help_ - extern void fss_write_embedded_list_process_help(fll_program_data_t * const main, void * const setting); + extern void fss_write_embedded_list_process_help(void * const main); #endif // _di_fss_write_embedded_list_process_help_ /** * Process a single Object, printing the FSS-0008 (Embedded List) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. */ #ifndef _di_fss_write_embedded_list_process_object_ - extern void fss_write_embedded_list_process_object(fll_program_data_t * const main, void * const setting); + extern void fss_write_embedded_list_process_object(void * const main); #endif // _di_fss_write_embedded_list_process_object_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/embedded_list/main.c b/level_3/fss_write/c/embedded_list/main.c index 067ac11..21a9696 100644 --- a/level_3/fss_write/c/embedded_list/main.c +++ b/level_3/fss_write/c/embedded_list/main.c @@ -15,42 +15,42 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.warning.custom = (void *) &data; data.program.debug.custom = (void *) &data; - setting.state.custom = (void *) &data; - setting.standard = fss_write_embedded_list_standard_s; - setting.process_content = &fss_write_embedded_list_process_content; - setting.process_help = &fss_write_embedded_list_process_help; - setting.process_normal = &fss_write_process_normal; - setting.process_object = &fss_write_embedded_list_process_object; - setting.process_pipe = &fss_write_process_pipe; - setting.process_set = &fss_write_process_set; - setting.flag |= fss_write_main_flag_ignore_e; - setting.flag |= fss_write_main_flag_content_multiple_e; + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_write_embedded_list_standard_s; + data.setting.process_content = &fss_write_embedded_list_process_content; + data.setting.process_help = &fss_write_embedded_list_process_help; + data.setting.process_normal = &fss_write_process_normal; + data.setting.process_object = &fss_write_embedded_list_process_object; + data.setting.process_pipe = &fss_write_process_pipe; + data.setting.process_set = &fss_write_process_set; + data.setting.flag |= fss_write_main_flag_ignore_e; + data.setting.flag |= fss_write_main_flag_content_multiple_e; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; - data.parameters.used = fss_write_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_write_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_write_setting_load(arguments, &data, &setting, 0); + fss_write_setting_load(arguments, &data, 0); } - fss_write_main(&data, &setting); + fss_write_main(&data); - fss_write_setting_unload(&data, &setting); + fss_write_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_write/c/embedded_list/print.c b/level_3/fss_write/c/embedded_list/print.c index e2af36f..5c29ff9 100644 --- a/level_3/fss_write/c/embedded_list/print.c +++ b/level_3/fss_write/c/embedded_list/print.c @@ -5,35 +5,35 @@ extern "C" { #endif #ifndef _di_fss_write_embedded_list_print_help_ - f_status_t fss_write_embedded_list_print_help(fss_write_setting_t * const setting, const fl_print_t print) { + f_status_t fss_write_embedded_list_print_help(fl_print_t * const print) { - if (!setting) return F_status_set_error(F_output_not); + if (!print) return F_status_set_error(F_output_not); - f_file_stream_lock(print.to); + f_file_stream_lock(print->to); fll_program_print_help_header(print, fss_write_embedded_list_program_name_long_s, fss_write_program_version_s); - fss_write_print_help(setting, print); + fss_write_print_message_help(print); - f_print_dynamic_raw(f_string_eol_s, print.to); + f_print_dynamic_raw(f_string_eol_s, print->to); fll_program_print_help_usage(print, fss_write_embedded_list_program_name_s, f_string_empty_s); - fss_write_print_help_pipe(setting, print); + fss_write_print_message_help_pipe(print); - fss_write_print_help_end_next(setting, print); + fss_write_print_message_help_end_next(print); - fl_print_format("%r The FSS-0008 (Embedded List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); - fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print.set->notable, f_string_eol_s, f_string_eol_s); + fl_print_format("%r The FSS-0008 (Embedded List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print->set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" The parameter '%[%r%r%]' designates to not escape any valid nested Object or Content within some Content.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); - fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); - fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%r", print.to, f_string_eol_s); - fl_print_format(" This parameter must be specified after a '%[%r%r%]'", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable); - fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%r%r%]' parameter.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable, f_string_eol_s); + fl_print_format(" The parameter '%[%r%r%]' designates to not escape any valid nested Object or Content within some Content.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%r", print->to, f_string_eol_s); + fl_print_format(" This parameter must be specified after a '%[%r%r%]'", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print->set->notable); + fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%r%r%]' parameter.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print->set->notable, f_string_eol_s); - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); return F_none; } diff --git a/level_3/fss_write/c/embedded_list/print.h b/level_3/fss_write/c/embedded_list/print.h index 292849d..c9c760c 100644 --- a/level_3/fss_write/c/embedded_list/print.h +++ b/level_3/fss_write/c/embedded_list/print.h @@ -15,13 +15,11 @@ extern "C" { /** * Print help for FSS-0008 (Embedded List). * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print * The output structure to print to. * + * This does not alter print.custom.setting.state.status. + * * @return * F_none on success. * F_output_not on success, but no printing is performed. @@ -29,7 +27,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_fss_write_embedded_list_print_help_ - extern f_status_t fss_write_embedded_list_print_help(fss_write_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_write_embedded_list_print_help(fl_print_t * const print); #endif // _di_fss_write_embedded_list_print_help_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/extended/fss_write.c b/level_3/fss_write/c/extended/fss_write.c index d8ffefc..652551d 100644 --- a/level_3/fss_write/c/extended/fss_write.c +++ b/level_3/fss_write/c/extended/fss_write.c @@ -6,56 +6,56 @@ extern "C" { #endif #ifndef _di_fss_write_extended_process_content_ - void fss_write_extended_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + void fss_write_extended_process_content(void * const void_main, const bool last) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->content) { + if (main->setting.content) { fl_fss_extended_content_write( - *setting->content, - setting->quote.used - ? setting->quote.string[0] + *main->setting.content, + main->setting.quote.used + ? main->setting.quote.string[0] : f_fss_quote_double_s.string[0], - (setting->flag & fss_write_main_flag_partial_e) + (main->setting.flag & fss_write_main_flag_partial_e) ? f_fss_complete_partial_e : last ? f_fss_complete_end_e : f_fss_complete_next_e, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_content_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_extended_content_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_object_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_content_end_e) { - setting->state.status = f_string_dynamic_append(f_fss_extended_close_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_object_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_close_s, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } - else if (setting->flag & fss_write_main_flag_content_next_e) { - setting->state.status = f_string_dynamic_append(f_fss_extended_next_s, &setting->buffer); + else if (main->setting.flag & fss_write_main_flag_content_next_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_next_s, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } @@ -63,59 +63,59 @@ extern "C" { #endif // _di_fss_write_extended_process_content_ #ifndef _di_fss_write_extended_process_help_ - void fss_write_extended_process_help(fll_program_data_t * const main, void * const void_setting) { + void fss_write_extended_process_help(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_extended_print_help(void_setting, main->message); + fss_write_extended_print_help(&((fss_write_main_t *) void_main)->program.message); } #endif // _di_fss_write_extended_process_help_ #ifndef _di_fss_write_extended_process_object_ - void fss_write_extended_process_object(fll_program_data_t * const main, void * const void_setting) { + void fss_write_extended_process_object(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->object) { + if (main->setting.object) { fl_fss_extended_object_write( - *setting->object, - setting->quote.used - ? setting->quote.string[0] + *main->setting.object, + main->setting.quote.used + ? main->setting.quote.string[0] : f_fss_quote_double_s.string[0], - (setting->flag & fss_write_main_flag_partial_e) - ? (setting->flag & fss_write_main_flag_trim_e) + (main->setting.flag & fss_write_main_flag_partial_e) + ? (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_trim_e : f_fss_complete_none_e - : (setting->flag & fss_write_main_flag_trim_e) + : (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_object_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_extended_object_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_content_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_object_open_e) { - setting->state.status = f_string_dynamic_append(f_fss_extended_open_s, &setting->buffer); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_content_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_open_s, &main->setting.buffer); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } diff --git a/level_3/fss_write/c/extended/fss_write.h b/level_3/fss_write/c/extended/fss_write.h index 81089ce..3e25405 100644 --- a/level_3/fss_write/c/extended/fss_write.h +++ b/level_3/fss_write/c/extended/fss_write.h @@ -45,12 +45,13 @@ // FSS Write includes. #include #include -#include -#include -#include +#include +#include +#include #include #include -#include +#include +#include #include #ifdef __cplusplus @@ -61,54 +62,48 @@ extern "C" { * Process a single Content, printing the FSS-0001 (Extended) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. * @param last * If TRUE, then this is the last Content in the Content set. * If FALSE, then this is not the last Content in the Content set. */ #ifndef _di_fss_write_extended_process_content_ - extern void fss_write_extended_process_content(fll_program_data_t * const main, void * const setting, const bool last); + extern void fss_write_extended_process_content(void * const main, const bool last); #endif // _di_fss_write_extended_process_content_ /** * Process help for FSS-0001 (Extended). * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This does not alter setting.state.status. + * This does not alter main.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_write_extended_process_help_ - extern void fss_write_extended_process_help(fll_program_data_t * const main, void * const setting); + extern void fss_write_extended_process_help(void * const main); #endif // _di_fss_write_extended_process_help_ /** * Process a single Object, printing the FSS-0001 (Extended) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. */ #ifndef _di_fss_write_extended_process_object_ - extern void fss_write_extended_process_object(fll_program_data_t * const main, void * const setting); + extern void fss_write_extended_process_object(void * const main); #endif // _di_fss_write_extended_process_object_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/extended/main.c b/level_3/fss_write/c/extended/main.c index 9255969..8218952 100644 --- a/level_3/fss_write/c/extended/main.c +++ b/level_3/fss_write/c/extended/main.c @@ -15,41 +15,41 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.warning.custom = (void *) &data; data.program.debug.custom = (void *) &data; - setting.state.custom = (void *) &data; - setting.standard = fss_write_extended_standard_s; - setting.process_content = &fss_write_extended_process_content; - setting.process_help = &fss_write_extended_process_help; - setting.process_normal = &fss_write_process_normal; - setting.process_object = &fss_write_extended_process_object; - setting.process_pipe = &fss_write_process_pipe; - setting.process_set = &fss_write_process_set; - setting.flag |= fss_write_main_flag_content_multiple_e; + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_write_extended_standard_s; + data.setting.process_content = &fss_write_extended_process_content; + data.setting.process_help = &fss_write_extended_process_help; + data.setting.process_normal = &fss_write_process_normal; + data.setting.process_object = &fss_write_extended_process_object; + data.setting.process_pipe = &fss_write_process_pipe; + data.setting.process_set = &fss_write_process_set; + data.setting.flag |= fss_write_main_flag_content_multiple_e; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; - data.parameters.used = fss_write_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_write_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_write_setting_load(arguments, &data, &setting, 0); + fss_write_setting_load(arguments, &data, 0); } - fss_write_main(&data, &setting); + fss_write_main(&data); - fss_write_setting_unload(&data, &setting); + fss_write_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_write/c/extended/print.c b/level_3/fss_write/c/extended/print.c index e5db7c8..e161833 100644 --- a/level_3/fss_write/c/extended/print.c +++ b/level_3/fss_write/c/extended/print.c @@ -5,32 +5,32 @@ extern "C" { #endif #ifndef _di_fss_write_extended_print_help_ - f_status_t fss_write_extended_print_help(fss_write_setting_t * const setting, const fl_print_t print) { + f_status_t fss_write_extended_print_help(fl_print_t * const print) { - if (!setting) return F_status_set_error(F_output_not); + if (!print) return F_status_set_error(F_output_not); - f_file_stream_lock(print.to); + f_file_stream_lock(print->to); fll_program_print_help_header(print, fss_write_extended_program_name_long_s, fss_write_program_version_s); - fss_write_print_help(setting, print); + fss_write_print_message_help(print); - f_print_dynamic_raw(f_string_eol_s, print.to); + f_print_dynamic_raw(f_string_eol_s, print->to); fll_program_print_help_usage(print, fss_write_extended_program_name_s, f_string_empty_s); - fss_write_print_help_pipe(setting, print); + fss_write_print_message_help_pipe(print); - fss_write_print_help_end_next(setting, print); + fss_write_print_message_help_end_next(print); - fl_print_format("%r The FSS-0001 (Extended) specification does not support multi-line Content, therefore the parameter '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_prepend_s, print.set->notable); - fl_print_format(" does nothing.%r%r", print.to, f_string_eol_s, f_string_eol_s); + fl_print_format("%r The FSS-0001 (Extended) specification does not support multi-line Content, therefore the parameter '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_prepend_s, print->set->notable); + fl_print_format(" does nothing.%r%r", print->to, f_string_eol_s, f_string_eol_s); - fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); - fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); return F_none; } diff --git a/level_3/fss_write/c/extended/print.h b/level_3/fss_write/c/extended/print.h index 195d03c..dfae8ef 100644 --- a/level_3/fss_write/c/extended/print.h +++ b/level_3/fss_write/c/extended/print.h @@ -15,13 +15,11 @@ extern "C" { /** * Print help for FSS-0001 (Extended). * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print * The output structure to print to. * + * This does not alter print.custom.setting.state.status. + * * @return * F_none on success. * F_output_not on success, but no printing is performed. @@ -29,7 +27,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_fss_write_extended_print_help_ - extern f_status_t fss_write_extended_print_help(fss_write_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_write_extended_print_help(fl_print_t * const print); #endif // _di_fss_write_extended_print_help_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/extended_list/fss_write.c b/level_3/fss_write/c/extended_list/fss_write.c index b59f788..c83eab3 100644 --- a/level_3/fss_write/c/extended_list/fss_write.c +++ b/level_3/fss_write/c/extended_list/fss_write.c @@ -6,52 +6,52 @@ extern "C" { #endif #ifndef _di_fss_write_extended_list_process_content_ - void fss_write_extended_list_process_content(fll_program_data_t * const main, void * const void_setting, const bool last) { + void fss_write_extended_list_process_content(void * const void_main, const bool last) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->content) { + if (main->setting.content) { fl_fss_extended_list_content_write( - *setting->content, - (setting->flag & fss_write_main_flag_partial_e) + *main->setting.content, + (main->setting.flag & fss_write_main_flag_partial_e) ? last ? f_fss_complete_none_e : f_fss_complete_partial_e : f_fss_complete_full_e, - &setting->prepend, - setting->ignores, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.prepend, + main->setting.ignores, + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_list_content_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_extended_list_content_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_object_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_content_end_e) { - setting->state.status = f_string_dynamic_append(f_fss_extended_list_close_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_object_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_close_s, &main->setting.buffer); - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = f_string_dynamic_append(f_fss_extended_list_close_end_s, &setting->buffer); + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_close_end_s, &main->setting.buffer); } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } @@ -59,61 +59,61 @@ extern "C" { #endif // _di_fss_write_extended_list_process_content_ #ifndef _di_fss_write_extended_list_process_help_ - void fss_write_extended_list_process_help(fll_program_data_t * const main, void * const void_setting) { + void fss_write_extended_list_process_help(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_extended_list_print_help(macro_fss_write_setting(void_setting), main->message); + fss_write_extended_list_print_help(&((fss_write_main_t *) void_main)->program.message); } #endif // _di_fss_write_extended_list_process_help_ #ifndef _di_fss_write_extended_list_process_object_ - void fss_write_extended_list_process_object(fll_program_data_t * const main, void * const void_setting) { + void fss_write_extended_list_process_object(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (setting->object) { + if (main->setting.object) { fl_fss_extended_list_object_write( - *setting->object, - (setting->flag & fss_write_main_flag_partial_e) - ? (setting->flag & fss_write_main_flag_trim_e) + *main->setting.object, + (main->setting.flag & fss_write_main_flag_partial_e) + ? (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_trim_e : f_fss_complete_none_e - : (setting->flag & fss_write_main_flag_trim_e) + : (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(macro_fss_write_setting(setting)->state.status) == F_none_eol) { - macro_fss_write_setting(setting)->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(macro_fss_write_setting(setting)->state.status)) { - fss_write_print_error(macro_fss_write_setting(setting), main->error, macro_fss_write_f(fl_fss_extended_list_object_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_extended_list_object_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_content_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_object_open_e) { - setting->state.status = f_string_dynamic_append(f_fss_extended_list_open_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_content_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_open_s, &main->setting.buffer); - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = f_string_dynamic_append(f_fss_extended_list_open_end_s, &setting->buffer); + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_open_end_s, &main->setting.buffer); } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); } } } diff --git a/level_3/fss_write/c/extended_list/fss_write.h b/level_3/fss_write/c/extended_list/fss_write.h index 9dab7c7..9262924 100644 --- a/level_3/fss_write/c/extended_list/fss_write.h +++ b/level_3/fss_write/c/extended_list/fss_write.h @@ -45,12 +45,13 @@ // FSS Write includes. #include #include -#include -#include -#include +#include +#include +#include #include #include -#include +#include +#include #include #ifdef __cplusplus @@ -61,54 +62,48 @@ extern "C" { * Process a single Content, printing the FSS-0003 (Extended List) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. * @param last * If TRUE, then this is the last Content in the Content set. * If FALSE, then this is not the last Content in the Content set. */ #ifndef _di_fss_write_extended_list_process_content_ - extern void fss_write_extended_list_process_content(fll_program_data_t * const main, void * const setting, const bool last); + extern void fss_write_extended_list_process_content(void * const main, const bool last); #endif // _di_fss_write_extended_list_process_content_ /** * Process help for FSS-0003 (Extended List). * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This does not alter setting.state.status. + * This does not alter main.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_write_extended_list_process_help_ - extern void fss_write_extended_list_process_help(fll_program_data_t * const main, void * const setting); + extern void fss_write_extended_list_process_help(void * const main); #endif // _di_fss_write_extended_list_process_help_ /** * Process a single Object, printing the FSS-0003 (Extended List) if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.status. - * This uses and alters setting.buffer. + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. */ #ifndef _di_fss_write_extended_list_process_object_ - extern void fss_write_extended_list_process_object(fll_program_data_t * const main, void * const setting); + extern void fss_write_extended_list_process_object(void * const main); #endif // _di_fss_write_extended_list_process_object_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/extended_list/main.c b/level_3/fss_write/c/extended_list/main.c index 620ad72..38ebe50 100644 --- a/level_3/fss_write/c/extended_list/main.c +++ b/level_3/fss_write/c/extended_list/main.c @@ -15,41 +15,41 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.warning.custom = (void *) &data; data.program.debug.custom = (void *) &data; - setting.state.custom = (void *) &data; - setting.standard = fss_write_extended_list_standard_s; - setting.process_content = &fss_write_extended_list_process_content; - setting.process_help = &fss_write_extended_list_process_help; - setting.process_normal = &fss_write_process_normal; - setting.process_object = &fss_write_extended_list_process_object; - setting.process_pipe = &fss_write_process_pipe; - setting.process_set = &fss_write_process_set; - setting.flag |= fss_write_main_flag_ignore_e; + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_write_extended_list_standard_s; + data.setting.process_content = &fss_write_extended_list_process_content; + data.setting.process_help = &fss_write_extended_list_process_help; + data.setting.process_normal = &fss_write_process_normal; + data.setting.process_object = &fss_write_extended_list_process_object; + data.setting.process_pipe = &fss_write_process_pipe; + data.setting.process_set = &fss_write_process_set; + data.setting.flag |= fss_write_main_flag_ignore_e; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; - data.parameters.used = fss_write_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_write_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_write_setting_load(arguments, &data, &setting, 0); + fss_write_setting_load(arguments, &data, 0); } - fss_write_main(&data, &setting); + fss_write_main(&data); - fss_write_setting_unload(&data, &setting); + fss_write_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_write/c/extended_list/print.c b/level_3/fss_write/c/extended_list/print.c index db3f8d3..a3c7426 100644 --- a/level_3/fss_write/c/extended_list/print.c +++ b/level_3/fss_write/c/extended_list/print.c @@ -5,35 +5,35 @@ extern "C" { #endif #ifndef _di_fss_write_extended_list_print_help_ - f_status_t fss_write_extended_list_print_help(fss_write_setting_t * const setting, const fl_print_t print) { + f_status_t fss_write_extended_list_print_help(fl_print_t * const print) { - if (!setting) return F_status_set_error(F_output_not); + if (!print) return F_status_set_error(F_output_not); - f_file_stream_lock(print.to); + f_file_stream_lock(print->to); fll_program_print_help_header(print, fss_write_extended_list_program_name_long_s, fss_write_program_version_s); - fss_write_print_help(setting, print); + fss_write_print_message_help(print); - f_print_dynamic_raw(f_string_eol_s, print.to); + f_print_dynamic_raw(f_string_eol_s, print->to); fll_program_print_help_usage(print, fss_write_extended_list_program_name_s, f_string_empty_s); - fss_write_print_help_pipe(setting, print); + fss_write_print_message_help_pipe(print); - fss_write_print_help_end_next(setting, print); + fss_write_print_message_help_end_next(print); - fl_print_format("%r The FSS-0003 (Extended List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); - fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print.set->notable, f_string_eol_s, f_string_eol_s); + fl_print_format("%r The FSS-0003 (Extended List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print->set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" The parameter '%[%r%r%]' designates to not escape any valid nested Object or Content within some Content.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); - fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); - fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%r", print.to, f_string_eol_s); - fl_print_format(" This parameter must be specified after a '%[%r%r%]'", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable); - fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%r%r%]' parameter.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable, f_string_eol_s); + fl_print_format(" The parameter '%[%r%r%]' designates to not escape any valid nested Object or Content within some Content.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%r", print->to, f_string_eol_s); + fl_print_format(" This parameter must be specified after a '%[%r%r%]'", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print->set->notable); + fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%r%r%]' parameter.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print->set->notable, f_string_eol_s); - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); return F_none; } diff --git a/level_3/fss_write/c/extended_list/print.h b/level_3/fss_write/c/extended_list/print.h index 009c449..6155e41 100644 --- a/level_3/fss_write/c/extended_list/print.h +++ b/level_3/fss_write/c/extended_list/print.h @@ -15,13 +15,11 @@ extern "C" { /** * Print help for FSS-0003 (Extended List). * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print * The output structure to print to. * + * This does not alter print.custom.setting.state.status. + * * @return * F_none on success. * F_output_not on success, but no printing is performed. @@ -29,7 +27,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_fss_write_extended_list_print_help_ - extern f_status_t fss_write_extended_list_print_help(fss_write_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_write_extended_list_print_help(fl_print_t * const print); #endif // _di_fss_write_extended_list_print_help_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/main/common-type.h b/level_3/fss_write/c/main/common-type.h deleted file mode 100644 index 59aa1e2..0000000 --- a/level_3/fss_write/c/main/common-type.h +++ /dev/null @@ -1,259 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Write - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the common data structures. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _fss_write_common_type_h -#define _fss_write_common_type_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The program default defines. - * - * fss_write_*: - * - allocation_console: An allocation step used for small buffers specifically for console parameter. - * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. - * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. - * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. - */ -#ifndef _di_fss_write_d_ - #define fss_write_allocation_console_d 4 - #define fss_write_allocation_large_d 2048 - #define fss_write_allocation_small_d 128 - #define iki_write_signal_check_d 20000 -#endif // _di_fss_write_d_ - -/** - * The program defines. - * - * macro_fss_write_setting: - * - Used to represent a cast to ((fss_write_setting_t *) setting). - * - Simplifies the number of parenthesis used to make code slightly cleaner. - * - Is wrapped in a parenthesis and not a block. - */ -#ifndef _di_fss_write_d_ - #define fss_write_signal_check_d 20000 - - #define macro_fss_write_setting(setting) ((fss_write_setting_t *) setting) -#endif // _di_fss_write_d_ - -/** - * Flags passed to the main function or program. - * - * fss_write_main_flag_*_e: - * - none: No flags set. - * - content: The Content being written is specified. - * - content_end: The Content end characters are to be printed. - * - content_multiple: Designate that multiple Content is allowed for an Object for this standard rather than a single Content per Object. - * - content_next: The Content next characters are to be printed. - * - copyright: Print copyright. - * - file_to: Using a specified destination file. - * - help: Print help. - * - ignore: Ignore a given range within a Content (specify flag before setting loading to designate ignores is supported by standard). - * - object: The Object being written is specified. - * - object_open: The Object open characters are to be printed. - * - partial: Do not write end of Object/Content character. - * - 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. - * - trim: Trim Object names. - * - version: Print version. - */ -#ifndef _di_fss_write_main_flag_e_ - enum { - fss_write_main_flag_none_e = 0x0, - fss_write_main_flag_content_e = 0x1, - fss_write_main_flag_content_end_e = 0x2, - fss_write_main_flag_content_multiple_e = 0x4, - fss_write_main_flag_content_next_e = 0x8, - fss_write_main_flag_copyright_e = 0x10, - fss_write_main_flag_file_to_e = 0x20, - fss_write_main_flag_help_e = 0x40, - fss_write_main_flag_ignore_e = 0x80, - fss_write_main_flag_object_e = 0x100, - fss_write_main_flag_object_open_e = 0x200, - fss_write_main_flag_partial_e = 0x400, - fss_write_main_flag_prepend_e = 0x800, - fss_write_main_flag_print_first_e = 0x1000, - fss_write_main_flag_print_last_e = 0x2000, - fss_write_main_flag_trim_e = 0x4000, - fss_write_main_flag_version_e = 0x8000, - }; // enum -#endif // _di_fss_write_main_flag_e_ - -/** - * The main program parameters. - */ -#ifndef _di_fss_write_parameter_e_ - enum { - fss_write_parameter_help_e, - fss_write_parameter_copyright_e, - fss_write_parameter_light_e, - fss_write_parameter_dark_e, - fss_write_parameter_no_color_e, - fss_write_parameter_verbosity_quiet_e, - fss_write_parameter_verbosity_error_e, - fss_write_parameter_verbosity_normal_e, - fss_write_parameter_verbosity_verbose_e, - fss_write_parameter_verbosity_debug_e, - fss_write_parameter_version_e, - fss_write_parameter_line_first_no_e, - fss_write_parameter_line_last_no_e, - - fss_write_parameter_as_e, - fss_write_parameter_backtick_e, - fss_write_parameter_content_e, - fss_write_parameter_content_end_e, - fss_write_parameter_content_next_e, - fss_write_parameter_double_e, - fss_write_parameter_file_e, - fss_write_parameter_ignore_e, - fss_write_parameter_object_e, - fss_write_parameter_object_open_e, - fss_write_parameter_partial_e, - fss_write_parameter_prepend_e, - fss_write_parameter_single_e, - fss_write_parameter_trim_e, - }; // enum - - #define fss_write_console_parameter_t_initialize \ - { \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_error_s, f_console_standard_long_error_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_normal_s, f_console_standard_long_normal_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_first_no_s, f_console_standard_long_line_first_no_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_last_no_s, f_console_standard_long_line_last_no_s, 0, f_console_flag_inverse_e), \ - \ - macro_f_console_parameter_t_initialize_3(fss_write_short_as_s, fss_write_long_as_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_backtick_s, fss_write_long_backtick_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_content_s, fss_write_long_content_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_content_end_s, fss_write_long_content_end_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_content_next_s, fss_write_long_content_next_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_double_s, fss_write_long_double_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_file_s, fss_write_long_file_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_ignore_s, fss_write_long_ignore_s, 2, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_object_s, fss_write_long_object_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_object_open_s, fss_write_long_object_open_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_partial_s, fss_write_long_partial_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_prepend_s, fss_write_long_prepend_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_single_s, fss_write_long_single_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_write_short_trim_s, fss_write_long_trim_s, 0, f_console_flag_normal_e), \ - } - - #define fss_write_total_parameters_d 27 -#endif // _di_fss_write_parameter_e_ - -/** - * The fss payload write main program settings. - * - * This is passed to the program-specific main entry point to designate program settings. - * These program settings are often processed from the program arguments (often called the command line arguments). - * - * flag: Flags passed to the main function. - * - * state: The state data used when processing the FSS data. - * range: A range used as a buffer during processing. - * - * quote: This holds the quote used during processing. - * standard: A human-friendly string describing the standard in use, such as "FSS-0000 (Basic)". - * - * escaped: A buffer used for escaping strings during processing. - * block: A buffer used to storing one or more blocks while processing a file line by line. - * buffer: A buffer used during processing the file. - * prepend: A string to prepend to each multi-line Content. - * - * ignoress: An array of range sets passed as values to the "--ignore" parameter or via the input pipe. - * objects: An array of objects passed as values to the "--object" parameter or via the input pipe. - * contentss: An array of content sets passed as values to the "--content" parameter or via the input pipe. - * - * object: A pointer to a specific Object used during processing. - * content: A pointer to a specific Content used during processing. - * contents: A pointer to a specific set of Content used during processing. - * - * process_content: Process a single Content. - * process_help: Process help (generally printing help). - * process_normal: Process normally (data from parameters and files). - * process_object: Process a single Object. - * process_pipe: Process using the data from input pipe. - * process_set: Process a set of Object and one or more Content. - */ -#ifndef _di_fss_write_setting_t_ - typedef struct { - uint16_t flag; - - f_state_t state; - f_string_range_t range; - - f_string_static_t quote; - f_string_static_t standard; - - f_string_dynamic_t escaped; - f_string_dynamic_t block; - f_string_dynamic_t buffer; - f_string_dynamic_t prepend; - - f_string_rangess_t ignoress; - f_string_dynamics_t objects; - f_string_dynamicss_t contentss; - - f_string_ranges_t *ignores; - f_string_static_t *object; - f_string_static_t *content; - f_string_statics_t *contents; - - void (*process_content)(fll_program_data_t * const main, void * const setting, const bool last); - void (*process_help)(fll_program_data_t * const main, void * const setting); - void (*process_normal)(fll_program_data_t * const main, void * const setting); - void (*process_object)(fll_program_data_t * const main, void * const setting); - void (*process_pipe)(fll_program_data_t * const main, void * const setting); - void (*process_set)(fll_program_data_t * const main, void * const setting); - } fss_write_setting_t; - - #define fss_write_setting_t_initialize \ - { \ - fss_write_main_flag_none_e, \ - macro_f_state_t_initialize_1(fss_write_allocation_large_d, fss_write_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0), \ - f_string_range_t_initialize, \ - f_string_static_t_initialize, \ - f_string_static_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_rangess_t_initialize, \ - f_string_dynamics_t_initialize, \ - f_string_dynamicss_t_initialize, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - } -#endif // _di_fss_write_setting_t_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_write_common_type_h diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index 2f52688..b7dc1b2 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -23,37 +23,37 @@ extern "C" { #endif // _di_fss_write_setting_delete_ #ifndef _di_fss_write_setting_load_ - void fss_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting, void (*callback)(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting)) { + void fss_write_setting_load(const f_console_arguments_t arguments, fss_write_main_t * const main, void (*callback)(const f_console_arguments_t arguments, fss_write_main_t * const main)) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = fss_write_allocation_console_d; + main->setting.state.step_small = fss_write_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = fss_write_allocation_small_d; + main->setting.state.step_small = fss_write_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[fss_write_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_write_main_flag_print_first_e; + if (main->program.parameters.array[fss_write_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_write_main_flag_print_first_e; } else { - setting->flag |= fss_write_main_flag_print_first_e; + main->setting.flag |= fss_write_main_flag_print_first_e; } - if (main->parameters.array[fss_write_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_write_main_flag_print_last_e; + if (main->program.parameters.array[fss_write_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_write_main_flag_print_last_e; } else { - setting->flag |= fss_write_main_flag_print_last_e; + main->setting.flag |= fss_write_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(f_console_parameter_process)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_console_parameter_process)); return; } @@ -69,14 +69,14 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(fll_program_parameter_process_context)); + fss_write_print_error(&main->program.error, macro_fss_write_f(fll_program_parameter_process_context)); return; } @@ -90,147 +90,147 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(fll_program_parameter_process_verbosity)); + fss_write_print_error(&main->program.error, macro_fss_write_f(fll_program_parameter_process_verbosity)); return; } } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_write_main_flag_help_e; + if (main->program.parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_write_main_flag_help_e; } - if (main->parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_write_main_flag_version_e; + if (main->program.parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_write_main_flag_version_e; } - if (main->parameters.array[fss_write_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= fss_write_main_flag_copyright_e; + if (main->program.parameters.array[fss_write_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_write_main_flag_copyright_e; } if (callback) { - callback(arguments, main, setting); - if (F_status_is_error(setting->state.status)) return; + callback(arguments, main); + if (F_status_is_error(main->setting.state.status)) return; - if (setting->state.status == F_done) { - setting->state.status = F_none; + if (main->setting.state.status == F_done) { + main->setting.state.status = F_none; return; } } - if (main->parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) return; - if (main->parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) return; + if (main->program.parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) return; + if (main->program.parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) return; - if ((main->parameters.array[fss_write_parameter_file_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_file_e].values.used) { - if (main->parameters.array[fss_write_parameter_file_e].values.used > 1) { - setting->state.status = F_status_set_error(F_parameter); + if ((main->program.parameters.array[fss_write_parameter_file_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_file_e].values.used) { + if (main->program.parameters.array[fss_write_parameter_file_e].values.used > 1) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_must_specify_once(&main->error, f_console_symbol_long_normal_s, fss_write_long_file_s); + fll_program_print_error_parameter_must_specify_once(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_file_s); return; } - const f_array_length_t index = main->parameters.array[fss_write_parameter_file_e].values.array[0]; + const f_array_length_t index = main->program.parameters.array[fss_write_parameter_file_e].values.array[0]; - main->output.to.id = -1; - main->output.to.stream = 0; + main->program.output.to.id = -1; + main->program.output.to.stream = 0; - setting->state.status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); + main->setting.state.status = f_file_stream_open(main->program.parameters.arguments.array[index], f_string_empty_s, &main->program.output.to); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error_file(setting, main->error, macro_fss_write_f(f_file_stream_open), main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + fss_write_print_error_file(&main->program.error, macro_fss_write_f(f_file_stream_open), main->program.parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); return; } - setting->flag |= fss_write_main_flag_file_to_e; + main->setting.flag |= fss_write_main_flag_file_to_e; } - else if (main->parameters.array[fss_write_parameter_file_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[fss_write_parameter_file_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, fss_write_long_file_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_file_s); return; } - if ((main->parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_object_e].values.used) { - f_array_lengths_t * const values = &main->parameters.array[fss_write_parameter_object_e].values; + if ((main->program.parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_object_e].values.used) { + f_array_lengths_t * const values = &main->program.parameters.array[fss_write_parameter_object_e].values; - setting->objects.used = 0; + main->setting.objects.used = 0; - setting->state.status = f_string_dynamics_resize(values->used, &setting->objects); + main->setting.state.status = f_string_dynamics_resize(values->used, &main->setting.objects); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_resize)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamics_resize)); return; } // Construct the array without allocating any more memory for the string data by setting this as a static string (used > 0, size = 0). - for (f_array_length_t index = 0; setting->objects.used < values->used; ) { + for (f_array_length_t index = 0; main->setting.objects.used < values->used; ) { - index = values->array[setting->objects.used]; + index = values->array[main->setting.objects.used]; - setting->objects.array[setting->objects.used].string = main->parameters.arguments.array[index].string; - setting->objects.array[setting->objects.used].used = main->parameters.arguments.array[index].used; - setting->objects.array[setting->objects.used++].size = 0; + main->setting.objects.array[main->setting.objects.used].string = main->program.parameters.arguments.array[index].string; + main->setting.objects.array[main->setting.objects.used].used = main->program.parameters.arguments.array[index].used; + main->setting.objects.array[main->setting.objects.used++].size = 0; } // for - setting->flag |= fss_write_main_flag_object_e; + main->setting.flag |= fss_write_main_flag_object_e; } - else if (main->parameters.array[fss_write_parameter_object_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[fss_write_parameter_object_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, fss_write_long_object_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_object_s); return; } - if ((main->parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_content_e].values.used) { + if ((main->program.parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_content_e].values.used) { - if (setting->flag & fss_write_main_flag_object_e) { - if (!(setting->flag & fss_write_main_flag_content_multiple_e)) { - if (main->parameters.array[fss_write_parameter_content_e].values.used > main->parameters.array[fss_write_parameter_object_e].values.used) { - setting->state.status = F_status_set_error(F_support_not); + if (main->setting.flag & fss_write_main_flag_object_e) { + if (!(main->setting.flag & fss_write_main_flag_content_multiple_e)) { + if (main->program.parameters.array[fss_write_parameter_content_e].values.used > main->program.parameters.array[fss_write_parameter_object_e].values.used) { + main->setting.state.status = F_status_set_error(F_support_not); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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); } - fss_write_print_error_one_content_only(setting, main->error); + fss_write_print_error_one_content_only(&main->program.error); return; } @@ -240,21 +240,21 @@ extern "C" { f_array_length_t stub_object_array[1] = { 0 }; f_array_lengths_t stub_object = macro_f_array_lengths_t_initialize(stub_object_array, 0, 1); - f_array_lengths_t * const values_content = &main->parameters.array[fss_write_parameter_content_e].values; - f_array_lengths_t * const values_object = main->parameters.array[fss_write_parameter_object_e].values.used - ? &main->parameters.array[fss_write_parameter_object_e].values + f_array_lengths_t * const values_content = &main->program.parameters.array[fss_write_parameter_content_e].values; + f_array_lengths_t * const values_object = main->program.parameters.array[fss_write_parameter_object_e].values.used + ? &main->program.parameters.array[fss_write_parameter_object_e].values : &stub_object; - setting->contentss.used = 0; + main->setting.contentss.used = 0; - setting->state.status = f_string_dynamicss_increase_by(values_object->used, &setting->contentss); + main->setting.state.status = f_string_dynamicss_increase_by(values_object->used, &main->setting.contentss); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase_by)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamicss_increase_by)); return; } @@ -275,21 +275,21 @@ extern "C" { if (!total) { - ++setting->contentss.used; + ++main->setting.contentss.used; if (++j < values_object->used) continue; break; } - setting->state.status = f_string_dynamics_increase_by(total, &setting->contentss.array[j]); + main->setting.state.status = f_string_dynamics_increase_by(total, &main->setting.contentss.array[j]); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase_by)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamics_increase_by)); return; } @@ -298,64 +298,64 @@ extern "C" { index = values_content->array[i++]; - setting->contentss.array[j].array[setting->contentss.array[j].used].string = main->parameters.arguments.array[index].string; - setting->contentss.array[j].array[setting->contentss.array[j].used].used = main->parameters.arguments.array[index].used; - setting->contentss.array[j].array[setting->contentss.array[j].used++].size = 0; + main->setting.contentss.array[j].array[main->setting.contentss.array[j].used].string = main->program.parameters.arguments.array[index].string; + main->setting.contentss.array[j].array[main->setting.contentss.array[j].used].used = main->program.parameters.arguments.array[index].used; + main->setting.contentss.array[j].array[main->setting.contentss.array[j].used++].size = 0; } // for } // while if (total) { - ++setting->contentss.used; + ++main->setting.contentss.used; } - setting->flag |= fss_write_main_flag_content_e; + main->setting.flag |= fss_write_main_flag_content_e; } - else if (main->parameters.array[fss_write_parameter_content_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[fss_write_parameter_content_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, fss_write_long_content_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_content_s); return; } - if ((main->parameters.array[fss_write_parameter_prepend_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_prepend_e].values.used) { - const f_array_length_t index = main->parameters.array[fss_write_parameter_prepend_e].values.array[main->parameters.array[fss_write_parameter_prepend_e].values.used - 1]; + if ((main->program.parameters.array[fss_write_parameter_prepend_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_prepend_e].values.used) { + const f_array_length_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].values.used - 1]; - setting->prepend.used = 0; + main->setting.prepend.used = 0; - setting->state.status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->prepend); + main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[index], &main->setting.prepend); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append_nulless)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append_nulless)); return; } - if (main->parameters.arguments.array[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize2(main->parameters.arguments.array[index].used); + if (main->program.parameters.arguments.array[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize2(main->program.parameters.arguments.array[index].used); - for (; range.start < main->parameters.arguments.array[index].used; range.start++) { + for (; range.start < main->program.parameters.arguments.array[index].used; range.start++) { - if (f_fss_is_space(main->parameters.arguments.array[index], range, &setting->state) == F_false) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (f_fss_is_space(main->program.parameters.arguments.array[index], range, &main->setting.state) == F_false) { + if ((main->setting.flag & fss_write_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(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_fss_is_space)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_fss_is_space)); } else { - setting->state.status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - fss_write_print_error_prepend_only_whitespace(setting, main->error); + fss_write_print_error_prepend_only_whitespace(&main->program.error); } return; @@ -363,55 +363,55 @@ extern "C" { } // for } - setting->flag |= fss_write_main_flag_prepend_e; + main->setting.flag |= fss_write_main_flag_prepend_e; } - else if (main->parameters.array[fss_write_parameter_prepend_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[fss_write_parameter_prepend_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, fss_write_long_prepend_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_prepend_s); return; } - if ((main->parameters.array[fss_write_parameter_ignore_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_ignore_e].values.used) { - if (main->parameters.array[fss_write_parameter_ignore_e].values.used % 2 != 0) { - setting->state.status = F_status_set_error(F_parameter); + if ((main->program.parameters.array[fss_write_parameter_ignore_e].result & f_console_result_value_e) && main->program.parameters.array[fss_write_parameter_ignore_e].values.used) { + if (main->program.parameters.array[fss_write_parameter_ignore_e].values.used % 2 != 0) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_missing_value_requires_amount(&main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, fss_write_string_two_s); + fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, fss_write_string_two_s); return; } // Only process if the standard designates that the ingore is supported. - if (setting->flag & fss_write_main_flag_ignore_e) { + if (main->setting.flag & fss_write_main_flag_ignore_e) { f_array_length_t stub_data_array[1] = { 0 }; f_array_lengths_t stub_data = macro_f_array_lengths_t_initialize(stub_data_array, 0, 1); - f_array_lengths_t * const values_ignore = &main->parameters.array[fss_write_parameter_ignore_e].values; - f_array_lengths_t * const values_data = main->parameters.array[fss_write_parameter_object_e].values.used - ? &main->parameters.array[fss_write_parameter_object_e].values - : main->parameters.array[fss_write_parameter_content_e].values.used - ? &main->parameters.array[fss_write_parameter_content_e].values + f_array_lengths_t * const values_ignore = &main->program.parameters.array[fss_write_parameter_ignore_e].values; + f_array_lengths_t * const values_data = main->program.parameters.array[fss_write_parameter_object_e].values.used + ? &main->program.parameters.array[fss_write_parameter_object_e].values + : main->program.parameters.array[fss_write_parameter_content_e].values.used + ? &main->program.parameters.array[fss_write_parameter_content_e].values : &stub_data; - setting->ignoress.used = 0; + main->setting.ignoress.used = 0; - setting->state.status = f_string_rangess_increase_by(values_data->used, &setting->ignoress); + main->setting.state.status = f_string_rangess_increase_by(values_data->used, &main->setting.ignoress); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase_by)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_rangess_increase_by)); return; } @@ -431,21 +431,21 @@ extern "C" { } // for if (!total) { - ++setting->ignoress.used; + ++main->setting.ignoress.used; if (++j < values_data->used) continue; break; } - setting->state.status = f_string_ranges_increase_by(total, &setting->ignoress.array[j]); + main->setting.state.status = f_string_ranges_increase_by(total, &main->setting.ignoress.array[j]); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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); } - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_ranges_increase_by)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_ranges_increase_by)); return; } @@ -454,56 +454,56 @@ extern "C" { index = values_ignore->array[i++]; - setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->ignoress.array[j].array[setting->ignoress.array[j].used].start); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].start); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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_program_print_error_parameter_integer_not(&main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->program.parameters.arguments.array[index]); return; } index = values_ignore->array[i++]; - setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->ignoress.array[j].array[setting->ignoress.array[j].used].stop); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].stop); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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_program_print_error_parameter_integer_not(&main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->program.parameters.arguments.array[index]); return; } - if (setting->ignoress.array[j].array[setting->ignoress.array[j].used].stop > setting->ignoress.array[j].array[setting->ignoress.array[j].used].start) { - setting->state.status = F_status_set_error(F_parameter); + if (main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].stop > main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].start) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_range_start_before_stop( - main->error, + &main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, - main->parameters.arguments.array[values_ignore->array[i - 1]], - main->parameters.arguments.array[index] + main->program.parameters.arguments.array[values_ignore->array[i - 1]], + main->program.parameters.arguments.array[index] ); return; } - ++setting->ignoress.array[j].used; + ++main->setting.ignoress.array[j].used; } // for } // while if (total) { - ++setting->ignoress.used; + ++main->setting.ignoress.used; } } else { @@ -513,49 +513,49 @@ extern "C" { f_array_length_t index = 0; f_string_range_t number = f_string_range_t_initialize; - while (i < main->parameters.array[fss_write_parameter_ignore_e].values.used) { + while (i < main->program.parameters.array[fss_write_parameter_ignore_e].values.used) { - index = main->parameters.array[fss_write_parameter_ignore_e].values.array[i++]; + index = main->program.parameters.array[fss_write_parameter_ignore_e].values.array[i++]; - setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &number.start); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number.start); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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_program_print_error_parameter_integer_not(&main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->program.parameters.arguments.array[index]); return; } - index = main->parameters.array[fss_write_parameter_ignore_e].values.array[i++]; + index = main->program.parameters.array[fss_write_parameter_ignore_e].values.array[i++]; - setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &number.stop); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number.stop); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_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_program_print_error_parameter_integer_not(&main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, main->program.parameters.arguments.array[index]); return; } if (number.start > number.stop) { - setting->state.status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_range_start_before_stop( - main->error, + &main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s, - main->parameters.arguments.array[main->parameters.array[fss_write_parameter_ignore_e].values.array[i - 1]], - main->parameters.arguments.array[index] + main->program.parameters.arguments.array[main->program.parameters.array[fss_write_parameter_ignore_e].values.array[i - 1]], + main->program.parameters.arguments.array[index] ); return; @@ -563,27 +563,27 @@ extern "C" { } // while } } - else if (main->parameters.array[fss_write_parameter_ignore_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[fss_write_parameter_ignore_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, fss_write_long_ignore_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_ignore_s); return; } else { // There is no Object or Content, so remove ignores if set. - if (setting->flag & fss_write_main_flag_ignore_e) { - setting->flag -= fss_write_main_flag_ignore_e; + if (main->setting.flag & fss_write_main_flag_ignore_e) { + main->setting.flag -= fss_write_main_flag_ignore_e; } } - if (main->parameters.array[fss_write_parameter_partial_e].result & f_console_result_found_e) { - setting->flag |= fss_write_main_flag_partial_e; + if (main->program.parameters.array[fss_write_parameter_partial_e].result & f_console_result_found_e) { + main->setting.flag |= fss_write_main_flag_partial_e; } { @@ -619,22 +619,22 @@ extern "C" { for (uint8_t i = 0; i < 3; ++i) { - if (main->parameters.array[has[i]].result & f_console_result_found_e) { - if (setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e)) { - if (!(setting->flag & fss_write_main_flag_partial_e)) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[has[i]].result & f_console_result_found_e) { + if (main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e)) { + if (!(main->setting.flag & fss_write_main_flag_partial_e)) { + main->setting.state.status = F_status_set_error(F_parameter); - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error.to); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error.to); } fll_program_print_error_parameter_cannot_use_with_without( - main->error, + &main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], - (setting->flag & fss_write_main_flag_object_e) + (main->setting.flag & fss_write_main_flag_object_e) ? fss_write_long_object_s : fss_write_long_content_s, fss_write_long_partial_s @@ -644,60 +644,60 @@ extern "C" { } } - if (main->parameters.array[has_cannots[i][0]].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[has_cannots[i][0]].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_cannot_use_with(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][0]); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][0]); return; } - if (main->parameters.array[has_cannots[i][1]].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[has_cannots[i][1]].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_cannot_use_with(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][1]); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][1]); return; } - setting->flag |= has_flag[i]; + main->setting.flag |= has_flag[i]; } } // for } - if (setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e)) { - if (setting->flag & fss_write_main_flag_object_e) { - if (setting->flag & fss_write_main_flag_content_multiple_e) { - if (main->parameters.array[fss_write_parameter_object_e].locations_sub.used > main->parameters.array[fss_write_parameter_content_e].locations_sub.used && !(setting->flag & fss_write_main_flag_partial_e)) { - setting->state.status = F_status_set_error(F_parameter); + if (main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e)) { + if (main->setting.flag & fss_write_main_flag_object_e) { + if (main->setting.flag & fss_write_main_flag_content_multiple_e) { + if (main->program.parameters.array[fss_write_parameter_object_e].locations_sub.used > main->program.parameters.array[fss_write_parameter_content_e].locations_sub.used && !(main->setting.flag & fss_write_main_flag_partial_e)) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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); } - fss_write_print_error_parameter_same_times_at_least(setting, main->error); + fss_write_print_error_parameter_same_times_at_least(&main->program.error); return; } } - if ((setting->flag & fss_write_main_flag_content_e) && (setting->flag & fss_write_main_flag_partial_e)) { - if (main->parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) { - setting->state.status = F_status_set_error(F_parameter); + if ((main->setting.flag & fss_write_main_flag_content_e) && (main->setting.flag & fss_write_main_flag_partial_e)) { + if (main->program.parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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_program_print_error_parameter_cannot_use_with_xor(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_write_long_partial_s, fss_write_long_object_s, fss_write_long_content_s); + fll_program_print_error_parameter_cannot_use_with_xor(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_write_long_partial_s, fss_write_long_object_s, fss_write_long_content_s); return; } @@ -705,50 +705,50 @@ extern "C" { } } - setting->quote = f_fss_quote_double_s; + main->setting.quote = f_fss_quote_double_s; - if (main->parameters.array[fss_write_parameter_double_e].result & f_console_result_found_e) { - if (main->parameters.array[fss_write_parameter_single_e].result & f_console_result_found_e) { - if (main->parameters.array[fss_write_parameter_double_e].location < main->parameters.array[fss_write_parameter_single_e].location) { - setting->quote = f_fss_quote_single_s; + if (main->program.parameters.array[fss_write_parameter_double_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_write_parameter_single_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_write_parameter_double_e].location < main->program.parameters.array[fss_write_parameter_single_e].location) { + main->setting.quote = f_fss_quote_single_s; - if (main->parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { - if (main->parameters.array[fss_write_parameter_single_e].location < main->parameters.array[fss_write_parameter_backtick_e].location) { - setting->quote = f_fss_quote_backtick_s; + if (main->program.parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_write_parameter_single_e].location < main->program.parameters.array[fss_write_parameter_backtick_e].location) { + main->setting.quote = f_fss_quote_backtick_s; } } } - else if (main->parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { - if (main->parameters.array[fss_write_parameter_double_e].location < main->parameters.array[fss_write_parameter_backtick_e].location) { - setting->quote = f_fss_quote_backtick_s; + else if (main->program.parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_write_parameter_double_e].location < main->program.parameters.array[fss_write_parameter_backtick_e].location) { + main->setting.quote = f_fss_quote_backtick_s; } } } - else if (main->parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { - if (main->parameters.array[fss_write_parameter_double_e].location < main->parameters.array[fss_write_parameter_backtick_e].location) { - setting->quote = f_fss_quote_backtick_s; + else if (main->program.parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_write_parameter_double_e].location < main->program.parameters.array[fss_write_parameter_backtick_e].location) { + main->setting.quote = f_fss_quote_backtick_s; } } } - else if (main->parameters.array[fss_write_parameter_single_e].result & f_console_result_found_e) { - setting->quote = f_fss_quote_single_s; + else if (main->program.parameters.array[fss_write_parameter_single_e].result & f_console_result_found_e) { + main->setting.quote = f_fss_quote_single_s; - if (main->parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { - if (main->parameters.array[fss_write_parameter_single_e].location < main->parameters.array[fss_write_parameter_backtick_e].location) { - setting->quote = f_fss_quote_backtick_s; + if (main->program.parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_write_parameter_single_e].location < main->program.parameters.array[fss_write_parameter_backtick_e].location) { + main->setting.quote = f_fss_quote_backtick_s; } } } - else if (main->parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { - setting->quote = f_fss_quote_backtick_s; + else if (main->program.parameters.array[fss_write_parameter_backtick_e].result & f_console_result_found_e) { + main->setting.quote = f_fss_quote_backtick_s; } - if (main->parameters.array[fss_write_parameter_trim_e].result & f_console_result_found_e) { - setting->flag |= fss_write_main_flag_trim_e; + if (main->program.parameters.array[fss_write_parameter_trim_e].result & f_console_result_found_e) { + main->setting.flag |= fss_write_main_flag_trim_e; } - if (!(setting->flag & (fll_program_data_pipe_input_e | fss_write_main_flag_content_e | fss_write_parameter_object_e))) { - setting->state.status = F_data_not; + if (!(main->setting.flag & (fll_program_data_pipe_input_e | fss_write_main_flag_content_e | fss_write_parameter_object_e))) { + main->setting.state.status = F_data_not; } } #endif // _di_fss_write_setting_load_ diff --git a/level_3/fss_write/c/main/common.h b/level_3/fss_write/c/main/common.h index 1438df8..b4b28bc 100644 --- a/level_3/fss_write/c/main/common.h +++ b/level_3/fss_write/c/main/common.h @@ -70,7 +70,7 @@ extern "C" { * @see fll_program_parameter_process_verbosity() */ #ifndef _di_fss_write_setting_load_ - extern void fss_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting, void (*callback)(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting)); + extern void fss_write_setting_load(const f_console_arguments_t arguments, fss_write_main_t * const main, void (*callback)(const f_console_arguments_t arguments, fss_write_main_t * const main)); #endif // _di_fss_write_setting_load_ /** diff --git a/level_3/fss_write/c/main/common/define.c b/level_3/fss_write/c/main/common/define.c index e69de29..0b80a88 100644 --- a/level_3/fss_write/c/main/common/define.c +++ b/level_3/fss_write/c/main/common/define.c @@ -0,0 +1,9 @@ +#include "../fss_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_write/c/main/common/define.h b/level_3/fss_write/c/main/common/define.h index e69de29..1e7785a 100644 --- a/level_3/fss_write/c/main/common/define.h +++ b/level_3/fss_write/c/main/common/define.h @@ -0,0 +1,39 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common data structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_write_common_define_h +#define _fss_write_common_define_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The program default defines. + * + * fss_write_*: + * - allocation_console: An allocation step used for small buffers specifically for console parameter. + * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. + * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. + * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. + */ +#ifndef _di_fss_write_d_ + #define fss_write_allocation_console_d 4 + #define fss_write_allocation_large_d 2048 + #define fss_write_allocation_small_d 128 + #define fss_write_signal_check_d 20000 +#endif // _di_fss_write_d_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_write_common_define_h diff --git a/level_3/fss_write/c/main/common/enumeration.c b/level_3/fss_write/c/main/common/enumeration.c index e69de29..0b80a88 100644 --- a/level_3/fss_write/c/main/common/enumeration.c +++ b/level_3/fss_write/c/main/common/enumeration.c @@ -0,0 +1,9 @@ +#include "../fss_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_write/c/main/common/enumeration.h b/level_3/fss_write/c/main/common/enumeration.h index e69de29..f6fc743 100644 --- a/level_3/fss_write/c/main/common/enumeration.h +++ b/level_3/fss_write/c/main/common/enumeration.h @@ -0,0 +1,160 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common enumeration structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_write_common_enumeration_h +#define _fss_write_common_enumeration_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Flags passed to the main function or program. + * + * fss_write_main_flag_*_e: + * - none: No flags set. + * - content: The Content being written is specified. + * - content_end: The Content end characters are to be printed. + * - content_multiple: Designate that multiple Content is allowed for an Object for this standard rather than a single Content per Object. + * - content_next: The Content next characters are to be printed. + * - copyright: Print copyright. + * - file_to: Using a specified destination file. + * - help: Print help. + * - ignore: Ignore a given range within a Content (specify flag before setting loading to designate ignores is supported by standard). + * - object: The Object being written is specified. + * - object_open: The Object open characters are to be printed. + * - partial: Do not write end of Object/Content character. + * - 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. + * - trim: Trim Object names. + * - version: Print version. + */ +#ifndef _di_fss_write_main_flag_e_ + enum { + fss_write_main_flag_none_e = 0x0, + fss_write_main_flag_content_e = 0x1, + fss_write_main_flag_content_end_e = 0x2, + fss_write_main_flag_content_multiple_e = 0x4, + fss_write_main_flag_content_next_e = 0x8, + fss_write_main_flag_copyright_e = 0x10, + fss_write_main_flag_file_to_e = 0x20, + fss_write_main_flag_help_e = 0x40, + fss_write_main_flag_ignore_e = 0x80, + fss_write_main_flag_object_e = 0x100, + fss_write_main_flag_object_open_e = 0x200, + fss_write_main_flag_partial_e = 0x400, + fss_write_main_flag_prepend_e = 0x800, + fss_write_main_flag_print_first_e = 0x1000, + fss_write_main_flag_print_last_e = 0x2000, + fss_write_main_flag_trim_e = 0x4000, + fss_write_main_flag_version_e = 0x8000, + }; // enum +#endif // _di_fss_write_main_flag_e_ + +/** + * The main program parameters. + */ +#ifndef _di_fss_write_parameter_e_ + enum { + fss_write_parameter_help_e, + fss_write_parameter_copyright_e, + fss_write_parameter_light_e, + fss_write_parameter_dark_e, + fss_write_parameter_no_color_e, + fss_write_parameter_verbosity_quiet_e, + fss_write_parameter_verbosity_error_e, + fss_write_parameter_verbosity_normal_e, + fss_write_parameter_verbosity_verbose_e, + fss_write_parameter_verbosity_debug_e, + fss_write_parameter_version_e, + fss_write_parameter_line_first_no_e, + fss_write_parameter_line_last_no_e, + + fss_write_parameter_as_e, + fss_write_parameter_backtick_e, + fss_write_parameter_content_e, + fss_write_parameter_content_end_e, + fss_write_parameter_content_next_e, + fss_write_parameter_double_e, + fss_write_parameter_file_e, + fss_write_parameter_ignore_e, + fss_write_parameter_object_e, + fss_write_parameter_object_open_e, + fss_write_parameter_partial_e, + fss_write_parameter_prepend_e, + fss_write_parameter_single_e, + fss_write_parameter_trim_e, + }; // enum + + #define fss_write_console_parameter_t_initialize \ + { \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_error_s, f_console_standard_long_error_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_normal_s, f_console_standard_long_normal_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_first_no_s, f_console_standard_long_line_first_no_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_last_no_s, f_console_standard_long_line_last_no_s, 0, f_console_flag_inverse_e), \ + \ + macro_f_console_parameter_t_initialize_3(fss_write_short_as_s, fss_write_long_as_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_backtick_s, fss_write_long_backtick_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_content_s, fss_write_long_content_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_content_end_s, fss_write_long_content_end_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_content_next_s, fss_write_long_content_next_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_double_s, fss_write_long_double_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_file_s, fss_write_long_file_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_ignore_s, fss_write_long_ignore_s, 2, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_object_s, fss_write_long_object_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_object_open_s, fss_write_long_object_open_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_partial_s, fss_write_long_partial_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_prepend_s, fss_write_long_prepend_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_single_s, fss_write_long_single_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_write_short_trim_s, fss_write_long_trim_s, 0, f_console_flag_normal_e), \ + } + + #define fss_write_total_parameters_d 27 +#endif // _di_fss_write_parameter_e_ + +/** + * Flags for fine-tuned print control. + * + * fss_write_print_flag_*_e: + * - none: No flags set. + * - debug: Stream is for debug printing. + * - error: Stream is for error printing. + * - message: Stream is for message printing. + * - warning: Stream is for warning printing. + * - file_to: Stream is a destination file. + * - file_from: Stream is a source file. + */ +#ifndef _di_fss_write_print_flag_e_ + enum { + fss_write_print_flag_none_e = 0x0, + fss_write_print_flag_debug_e = 0x1, + fss_write_print_flag_error_e = 0x2, + fss_write_print_flag_message_e = 0x4, + fss_write_print_flag_warning_e = 0x8, + fss_write_print_flag_file_to_e = 0x10, + fss_write_print_flag_file_from_e = 0x20, + }; // enum +#endif // _di_fss_write_print_flag_e_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_write_common_enumeration_h diff --git a/level_3/fss_write/c/main/common-print.c b/level_3/fss_write/c/main/common/print.c similarity index 98% rename from level_3/fss_write/c/main/common-print.c rename to level_3/fss_write/c/main/common/print.c index 89157ba..9484a0a 100644 --- a/level_3/fss_write/c/main/common-print.c +++ b/level_3/fss_write/c/main/common/print.c @@ -1,4 +1,4 @@ -#include "fss_write.h" +#include "../fss_write.h" #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/main/common-print.h b/level_3/fss_write/c/main/common/print.h similarity index 100% rename from level_3/fss_write/c/main/common-print.h rename to level_3/fss_write/c/main/common/print.h diff --git a/level_3/fss_write/c/main/common-string.c b/level_3/fss_write/c/main/common/string.c similarity index 99% rename from level_3/fss_write/c/main/common-string.c rename to level_3/fss_write/c/main/common/string.c index b40ae68..e1bf325 100644 --- a/level_3/fss_write/c/main/common-string.c +++ b/level_3/fss_write/c/main/common/string.c @@ -1,4 +1,4 @@ -#include "fss_write.h" +#include "../fss_write.h" #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/main/common-string.h b/level_3/fss_write/c/main/common/string.h similarity index 100% rename from level_3/fss_write/c/main/common-string.h rename to level_3/fss_write/c/main/common/string.h diff --git a/level_3/fss_write/c/main/common-type.c b/level_3/fss_write/c/main/common/type.c similarity index 76% rename from level_3/fss_write/c/main/common-type.c rename to level_3/fss_write/c/main/common/type.c index cf14e90..0b80a88 100644 --- a/level_3/fss_write/c/main/common-type.c +++ b/level_3/fss_write/c/main/common/type.c @@ -1,4 +1,4 @@ -#include "fss_write.h" +#include "../fss_write.h" #ifdef __cplusplus extern "C" { diff --git a/level_3/fss_write/c/main/common/type.h b/level_3/fss_write/c/main/common/type.h new file mode 100644 index 0000000..a5e700c --- /dev/null +++ b/level_3/fss_write/c/main/common/type.h @@ -0,0 +1,137 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common data structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_write_common_type_h +#define _fss_write_common_type_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The fss payload write main program settings. + * + * This is passed to the program-specific main entry point to designate program settings. + * These program settings are often processed from the program arguments (often called the command line arguments). + * + * For all function pointers on this structure, the main variable must be of type fss_write_main_t. + * + * flag: Flags passed to the main function. + * + * state: The state data used when processing the FSS data. + * range: A range used as a buffer during processing. + * + * quote: This holds the quote used during processing. + * standard: A human-friendly string describing the standard in use, such as "FSS-0000 (Basic)". + * + * escaped: A buffer used for escaping strings during processing. + * block: A buffer used to storing one or more blocks while processing a file line by line. + * buffer: A buffer used during processing the file. + * prepend: A string to prepend to each multi-line Content. + * + * ignoress: An array of range sets passed as values to the "--ignore" parameter or via the input pipe. + * objects: An array of objects passed as values to the "--object" parameter or via the input pipe. + * contentss: An array of content sets passed as values to the "--content" parameter or via the input pipe. + * + * object: A pointer to a specific Object used during processing. + * content: A pointer to a specific Content used during processing. + * contents: A pointer to a specific set of Content used during processing. + * + * process_content: Process a single Content. + * process_help: Process help (generally printing help). + * process_normal: Process normally (data from parameters and files). + * process_object: Process a single Object. + * process_pipe: Process using the data from input pipe. + * process_set: Process a set of Object and one or more Content. + */ +#ifndef _di_fss_write_setting_t_ + typedef struct { + uint16_t flag; + + f_state_t state; + f_string_range_t range; + + f_string_static_t quote; + f_string_static_t standard; + + f_string_dynamic_t escaped; + f_string_dynamic_t block; + f_string_dynamic_t buffer; + f_string_dynamic_t prepend; + + f_string_rangess_t ignoress; + f_string_dynamics_t objects; + f_string_dynamicss_t contentss; + + f_string_ranges_t *ignores; + f_string_static_t *object; + f_string_static_t *content; + f_string_statics_t *contents; + + void (*process_content)(void * const main, const bool last); + void (*process_help)(void * const main); + void (*process_normal)(void * const main); + void (*process_object)(void * const main); + void (*process_pipe)(void * const main); + void (*process_set)(void * const main); + } fss_write_setting_t; + + #define fss_write_setting_t_initialize \ + { \ + fss_write_main_flag_none_e, \ + macro_f_state_t_initialize_1(fss_write_allocation_large_d, fss_write_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0), \ + f_string_range_t_initialize, \ + f_string_static_t_initialize, \ + f_string_static_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_rangess_t_initialize, \ + f_string_dynamics_t_initialize, \ + f_string_dynamicss_t_initialize, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + } +#endif // _di_fss_write_setting_t_ + +/** + * The main program data as a single structure. + * + * program: The main program data. + * setting: The settings data. + */ +#ifndef _di_fss_write_main_t_ + typedef struct { + fll_program_data_t program; + fss_write_setting_t setting; + } fss_write_main_t; + + #define fss_write_main_t_initialize \ + { \ + fll_program_data_t_initialize, \ + fss_write_setting_t_initialize, \ + } +#endif // _di_fss_write_main_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_write_common_type_h diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index 14d2fc8..17208c0 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -5,28 +5,34 @@ extern "C" { #endif #ifndef _di_fss_write_main_ - void fss_write_main(fll_program_data_t * const main, fss_write_setting_t * const setting) { + void fss_write_main(void * const void_main) { - if (!main || !setting) return; + if (!void_main) return; - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & fss_write_main_flag_print_last_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + fss_write_main_t * const main = (fss_write_main_t *) void_main; + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_write_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } return; } - if ((setting->flag & fss_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_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); } - setting->state.status = F_none; + main->setting.state.status = F_none; if (main->setting.flag & (fss_write_main_flag_help_e | fss_write_main_flag_version_e | fss_write_main_flag_copyright_e)) { - if (main->setting.flag & fss_write_main_flag_help_e) { - fss_write_print_message_help(&main->program.message); + if (main->setting.process_help) { + main->setting.process_help(void_main); + } + else { + fss_write_print_message_help(&main->program.message); + } } else if (main->setting.flag & fss_write_main_flag_version_e) { fll_program_print_version(&main->program.message, fss_write_program_version_s); @@ -42,115 +48,116 @@ extern "C" { return; } - setting->escaped.used = 0; + main->setting.escaped.used = 0; - if (main->pipe & fll_program_data_pipe_input_e) { - if (setting->process_pipe) { - setting->process_pipe(main, setting); + if (main->program.pipe & fll_program_data_pipe_input_e) { + if (main->setting.process_pipe) { + main->setting.process_pipe(void_main); } } - if (F_status_is_error_not(setting->state.status)) { - if (setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e | fss_write_main_flag_object_open_e | fss_write_main_flag_content_next_e | fss_write_main_flag_content_end_e)) { - if (setting->process_normal) { - setting->process_normal(main, (void *) setting); + if (F_status_is_error_not(main->setting.state.status)) { + if (main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e | fss_write_main_flag_object_open_e | fss_write_main_flag_content_next_e | fss_write_main_flag_content_end_e)) { + if (main->setting.process_normal) { + main->setting.process_normal(void_main); } } } - if ((setting->flag & fss_write_main_flag_print_last_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & fss_write_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } } #endif // _di_fss_write_main_ #ifndef _di_fss_write_process_normal_ - void fss_write_process_normal(fll_program_data_t * const main, void * const void_setting) { + void fss_write_process_normal(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; fss_write_process_normal_data( - main, - macro_fss_write_setting(void_setting), - (macro_fss_write_setting(void_setting)->flag & fss_write_main_flag_object_e) - ? macro_fss_write_setting(void_setting)->objects.used - : macro_fss_write_setting(void_setting)->contentss.used + (fss_write_main_t *) void_main, + (((fss_write_main_t *) void_main)->setting.flag & fss_write_main_flag_object_e) + ? ((fss_write_main_t *) void_main)->setting.objects.used + : ((fss_write_main_t *) void_main)->setting.contentss.used ); } #endif // _di_fss_write_process_normal_ #ifndef _di_fss_write_process_normal_data_ - void fss_write_process_normal_data(fll_program_data_t * const main, fss_write_setting_t * const setting, const f_array_length_t length) { + void fss_write_process_normal_data(void * const void_main, const f_array_length_t length) { + + if (!void_main) return; - if (!main || !setting || !setting->process_set) return; + fss_write_main_t * const main = (fss_write_main_t *) void_main; - setting->ignores = 0; - setting->object = 0; - setting->content = 0; - setting->contents = 0; + 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) { - // @todo replace all signal checks with forked main process that independently checks and assigns main->signal_received. - if (!((++main->signal_check) % fss_write_signal_check_d)) { + // @todo replace all signal checks with forked main process that independently checks and assigns main->program.signal_received. + if (!((++main->program.signal_check) % fss_write_signal_check_d)) { if (fll_program_standard_signal_received(&main->program)) { - setting->state.status = F_status_set_error(F_interrupt); + main->setting.state.status = F_status_set_error(F_interrupt); return; } - main->signal_check = 0; + main->program.signal_check = 0; } - if (setting->objects.used) { - setting->object = &setting->objects.array[i]; + if (main->setting.objects.used) { + main->setting.object = &main->setting.objects.array[i]; } - if (setting->contentss.used) { - setting->contents = &setting->contentss.array[i]; + if (main->setting.contentss.used) { + main->setting.contents = &main->setting.contentss.array[i]; } - if (setting->ignoress.used) { - setting->ignores = &setting->ignoress.array[i]; + if (main->setting.ignoress.used) { + main->setting.ignores = &main->setting.ignoress.array[i]; } - setting->process_set(main, setting); - if (F_status_is_error(setting->state.status)) break; + main->setting.process_set(void_main); + if (F_status_is_error(main->setting.state.status)) break; } // for } else { - if (setting->flag & (fss_write_main_flag_object_open_e | fss_write_main_flag_content_next_e | fss_write_main_flag_content_end_e)) { - setting->object = 0; - setting->contents = 0; - setting->ignores = 0; + if (main->setting.flag & (fss_write_main_flag_object_open_e | fss_write_main_flag_content_next_e | fss_write_main_flag_content_end_e)) { + main->setting.object = 0; + main->setting.contents = 0; + main->setting.ignores = 0; - setting->process_set(main, setting); + main->setting.process_set(void_main); } } } #endif // _di_fss_write_process_normal_data_ #ifndef _di_fss_write_process_pipe_ - void fss_write_process_pipe(fll_program_data_t * const main, void * const void_setting) { + void fss_write_process_pipe(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (!setting->process_set) return; + if (!main->setting.process_set) return; - if (main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - const f_array_length_t used_objects = setting->objects.used; - const f_array_length_t used_contentss = setting->contentss.used; - const f_array_length_t used_ignoress = setting->ignoress.used; + 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; - setting->object = &setting->objects.array[used_objects]; - setting->contents = &setting->contentss.array[used_contentss]; - setting->ignores = &setting->ignoress.array[used_ignoress]; + 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; @@ -159,36 +166,36 @@ extern "C" { uint8_t state = 0; // This is processed in a single set, so there is only ever one Object added. - setting->state.status = f_string_dynamics_increase(setting->state.step_small, &setting->objects); + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, &main->setting.objects); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamics_increase)); return; } // This is processed in a single set, so there is only ever one Content added. - setting->state.status = f_string_dynamicss_increase(setting->state.step_small, &setting->contentss); + main->setting.state.status = f_string_dynamicss_increase(main->setting.state.step_small, &main->setting.contentss); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamicss_increase)); return; } - setting->state.status = f_string_dynamics_increase(setting->state.step_small, setting->contents); + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamics_increase)); return; } // This is processed in a single set, so there is only ever one Ignores added. - setting->state.status = f_string_rangess_increase(setting->state.step_small, &setting->ignoress); + main->setting.state.status = f_string_rangess_increase(main->setting.state.step_small, &main->setting.ignoress); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_rangess_increase)); return; } @@ -197,68 +204,68 @@ extern "C" { f_file_t input = f_file_t_initialize; input.id = F_type_descriptor_input_d; - input.size_read = setting->state.step_large; + input.size_read = main->setting.state.step_large; 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. - setting->object->used = 0; - setting->contents->used = 0; - setting->ignores->used = 0; + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; for (;;) { - if (!((++main->signal_check) % fss_write_signal_check_d)) { + if (!((++main->program.signal_check) % fss_write_signal_check_d)) { if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(&main->warning, main->signal_received); + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); - setting->state.status = F_status_set_error(F_interrupt); + main->setting.state.status = F_status_set_error(F_interrupt); break; } - main->signal_check = 0; + main->program.signal_check = 0; } if (range.start > range.stop) { if (status_pipe == F_none_eof) break; - setting->block.used = 0; + main->setting.block.used = 0; - status_pipe = f_file_read_block(input, &setting->block); + status_pipe = f_file_read_block(input, &main->setting.block); if (F_status_is_error(status_pipe)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_file_read_block)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_file_read_block)); status_pipe = F_status_set_error(F_pipe); break; } - if (!setting->block.used) break; + if (!main->setting.block.used) break; range.start = 0; - range.stop = setting->block.used - 1; + range.stop = main->setting.block.used - 1; } // Start Object. if (!state || state == 0x1) { if (!state) { - setting->object->used = 0; + main->setting.object->used = 0; state = 0x1; } // Reset the "has Content for Object" flag and associated contents array used length. flag -= flag | 0x4; - setting->contents->used = 0; + main->setting.contents->used = 0; - setting->state.status = f_string_dynamic_increase_by(setting->block.used, setting->object); + main->setting.state.status = f_string_dynamic_increase_by(main->setting.block.used, main->setting.object); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } @@ -267,14 +274,14 @@ extern "C" { // Do not handle start/end while inside an ignore set. if (!(flag & 0x2)) { - if (setting->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { state = 0x2; ++range.start; break; } - if (setting->block.string[range.start] == fss_write_pipe_content_end_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_end_s.string[0]) { state = 0x3; ++range.start; @@ -283,7 +290,7 @@ extern "C" { } // There currently is no support for "ignore" in Objects, but the Ignore should still be processed. - if (setting->block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) { // Ignore is enabled. if (flag & 0x2) { @@ -296,10 +303,10 @@ extern "C" { continue; } - setting->object->string[setting->object->used++] = setting->block.string[range.start]; + main->setting.object->string[main->setting.object->used++] = main->setting.block.string[range.start]; } // for - if (F_status_is_error(setting->state.status)) break; + 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; @@ -313,18 +320,18 @@ extern "C" { // Check to see if the Content supports multiple Content per Object. if (flag & 0x4) { - if (!(setting->flag & fss_write_main_flag_content_multiple_e)) { - setting->state.status = F_status_set_error(F_support_not); + if (!(main->setting.flag & fss_write_main_flag_content_multiple_e)) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_one_content_only(setting, main->error); + fss_write_print_error_one_content_only(&main->program.error); break; } - setting->state.status = f_string_dynamics_increase(setting->state.step_small, setting->contents); + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamics_increase)); break; } @@ -338,10 +345,10 @@ extern "C" { } if (total) { - setting->state.status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); + main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } @@ -350,17 +357,17 @@ extern "C" { // Do not handle start/end while inside an ignore set. if (!(flag & 0x2)) { - if (setting->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { - if (!(setting->flag & fss_write_main_flag_content_multiple_e)) { - setting->state.status = F_status_set_error(F_support_not); + if (main->setting.block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { + if (!(main->setting.flag & fss_write_main_flag_content_multiple_e)) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_one_content_only(setting, main->error); + fss_write_print_error_one_content_only(&main->program.error); break; } } - if (setting->block.string[range.start] == fss_write_pipe_content_end_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_end_s.string[0]) { state = 0x3; ++range.start; @@ -368,25 +375,25 @@ extern "C" { } } - if (setting->block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) { // Ignore is enabled. if (flag & 0x2) { - setting->state.status = f_string_ranges_increase(setting->state.step_small, setting->ignores); + main->setting.state.status = f_string_ranges_increase(main->setting.state.step_small, main->setting.ignores); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_ranges_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_ranges_increase)); break; } - setting->ignores->array[setting->ignores->used].start = setting->contents->array[setting->contents->used].used; - setting->ignores->array[setting->ignores->used].stop = range.start; + 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 = setting->contents->array[setting->contents->used].used; + ignore = main->setting.contents->array[main->setting.contents->used].used; flag |= 0x2; } @@ -394,12 +401,12 @@ extern "C" { continue; } - setting->contents->array[setting->contents->used].string[setting->contents->array[setting->contents->used].used++] = setting->block.string[range.start]; + 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 - if (F_status_is_error(setting->state.status)) break; + if (F_status_is_error(main->setting.state.status)) break; - ++setting->contents->used; + ++main->setting.contents->used; flag |= 0x4; } else { @@ -409,103 +416,103 @@ extern "C" { // End Object or Content set. if (state == 0x3) { - setting->process_set(main, void_setting); - if (F_status_is_error(setting->state.status)) break; + main->setting.process_set(void_main); + if (F_status_is_error(main->setting.state.status)) break; state = 0; flag |= 0x1; // Reset all of the used data for next set. - setting->object->used = 0; - setting->contents->used = 0; - setting->ignores->used = 0; + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; continue; } } // for // If the pipe ended before finishing, then attempt to wrap up. - if (F_status_is_error_not(setting->state.status) && status_pipe == F_none_eof && state) { - setting->process_set(main, void_setting); + if (F_status_is_error_not(main->setting.state.status) && status_pipe == F_none_eof && state) { + main->setting.process_set(void_main); flag |= 0x1; } - setting->block.used = 0; - setting->buffer.used = 0; - setting->object->used = 0; - setting->contents->used = 0; - setting->ignores->used = 0; - setting->ignoress.used = used_ignoress; - setting->objects.used = used_objects; - setting->contentss.used = used_contentss; - - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = (flag & 0x1) ? F_none : F_data_not; + 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_not(main->setting.state.status)) { + main->setting.state.status = (flag & 0x1) ? F_none : F_data_not; } } #endif // _di_fss_write_process_pipe_ #ifndef _di_fss_write_process_set_ - void fss_write_process_set(fll_program_data_t * const main, void * const void_setting) { + void fss_write_process_set(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - setting->buffer.used = 0; + main->setting.buffer.used = 0; - if ((!(setting->flag & fss_write_main_flag_partial_e) || (setting->flag & fss_write_main_flag_partial_e) && (setting->flag & fss_write_main_flag_object_e)) && setting->object || (setting->flag & fss_write_main_flag_object_open_e)) { + if ((!(main->setting.flag & fss_write_main_flag_partial_e) || (main->setting.flag & fss_write_main_flag_partial_e) && (main->setting.flag & fss_write_main_flag_object_e)) && main->setting.object || (main->setting.flag & fss_write_main_flag_object_open_e)) { - if (setting->object) { - if (setting->object->used) { - setting->range.start = 0; - setting->range.stop = setting->object->used - 1; + if (main->setting.object) { + if (main->setting.object->used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.object->used - 1; } else { - setting->range.start = 1; - setting->range.stop = 0; + main->setting.range.start = 1; + main->setting.range.stop = 0; } } - if (setting->process_object) { - setting->process_object(main, void_setting); - if (F_status_is_error(setting->state.status)) return; + if (main->setting.process_object) { + main->setting.process_object(void_main); + if (F_status_is_error(main->setting.state.status)) return; } } - if ((!(setting->flag & fss_write_main_flag_partial_e) || (setting->flag & fss_write_main_flag_partial_e) && (setting->flag & fss_write_main_flag_content_e)) && setting->contents || (setting->flag & (fss_write_main_flag_content_next_e | fss_write_main_flag_content_end_e))) { + if ((!(main->setting.flag & fss_write_main_flag_partial_e) || (main->setting.flag & fss_write_main_flag_partial_e) && (main->setting.flag & fss_write_main_flag_content_e)) && main->setting.contents || (main->setting.flag & (fss_write_main_flag_content_next_e | fss_write_main_flag_content_end_e))) { - if (setting->process_content) { - if (setting->contents && setting->contents->used) { - for (f_array_length_t i = 0; i < setting->contents->used; ++i) { + if (main->setting.process_content) { + if (main->setting.contents && main->setting.contents->used) { + for (f_array_length_t i = 0; i < main->setting.contents->used; ++i) { - if (setting->contents->array[i].used) { - setting->range.start = 0; - setting->range.stop = setting->contents->array[i].used - 1; + if (main->setting.contents->array[i].used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.contents->array[i].used - 1; } else { - setting->range.start = 1; - setting->range.stop = 0; + main->setting.range.start = 1; + main->setting.range.stop = 0; } - setting->content = &setting->contents->array[i]; + main->setting.content = &main->setting.contents->array[i]; - setting->process_content(main, void_setting, i + 1 == setting->contents->used); - if (F_status_is_error(setting->state.status)) return; + main->setting.process_content(void_main, i + 1 == main->setting.contents->used); + if (F_status_is_error(main->setting.state.status)) return; } // for } else { - setting->content = 0; + main->setting.content = 0; - setting->process_content(main, void_setting, F_true); - if (F_status_is_error(setting->state.status)) return; + main->setting.process_content(void_main, F_true); + if (F_status_is_error(main->setting.state.status)) return; } } } - if (setting->buffer.used) { - fll_print_dynamic(setting->buffer, main->output.to); + if (main->setting.buffer.used) { + fll_print_dynamic(main->setting.buffer, main->program.output.to); } } #endif // _di_fss_write_process_set_ diff --git a/level_3/fss_write/c/main/fss_write.h b/level_3/fss_write/c/main/fss_write.h index 4641f8d..fa48535 100644 --- a/level_3/fss_write/c/main/fss_write.h +++ b/level_3/fss_write/c/main/fss_write.h @@ -44,11 +44,14 @@ // FSS Write includes. #include #include -#include -#include -#include +#include +#include +#include #include -#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -66,11 +69,10 @@ extern "C" { * - F_signal_termination * * @param main - * The main program data. - * @param setting - * The main program settings. + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.state.status: + * This alters main.custom.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. @@ -79,19 +81,17 @@ extern "C" { * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_fss_write_main_ - extern void fss_write_main(fll_program_data_t * const main, fss_write_setting_t * const setting); + extern void fss_write_main(void * const main); #endif // _di_fss_write_main_ /** * Process normally, writing to the output for the assigned FSS format. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.state.status: + * This alters main.custom.setting.state.status: * status from fss_write_process_normal_data(). * * Errors (with error bit) from fss_write_process_normal_data(). @@ -99,38 +99,34 @@ extern "C" { * @see fss_write_process_normal_data() */ #ifndef _di_fss_write_process_normal_ - extern void fss_write_process_normal(fll_program_data_t * const main, void * const setting); + extern void fss_write_process_normal(void * const main); #endif // _di_fss_write_process_normal_ /** * Process the data normally, writing to the output for the assigned FSS format. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.state.status: + * This alters main.custom.setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_fss_write_process_normal_data_ - void fss_write_process_normal_data(fll_program_data_t * const main, fss_write_setting_t * const setting, const f_array_length_t length); + void fss_write_process_normal_data(void * const main, const f_array_length_t length); #endif // _di_fss_write_process_normal_data_ /** * Process the pipe, reading from the pipe and writing to the output for the assigned FSS format. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.state.status: + * 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. @@ -139,26 +135,24 @@ extern "C" { * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_fss_write_process_pipe_ - extern void fss_write_process_pipe(fll_program_data_t * const main, void * const setting); + extern void fss_write_process_pipe(void * const main); #endif // _di_fss_write_process_pipe_ /** * Process a given Object and Content, printing the assigned FSS format if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.state.status: + * This alters main.setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_fss_write_process_set_ - extern void fss_write_process_set(fll_program_data_t * const main, void * const setting); + extern void fss_write_process_set(void * const main); #endif // _di_fss_write_process_set_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/main/main-print.c b/level_3/fss_write/c/main/main-print.c deleted file mode 100644 index b9d33ba..0000000 --- a/level_3/fss_write/c/main/main-print.c +++ /dev/null @@ -1,109 +0,0 @@ -#include "fss_write.h" -#include "main-print.h" -#include "../basic/fss_write.h" -#include "../basic_list/fss_write.h" -#include "../extended/fss_write.h" -#include "../extended_list/fss_write.h" -#include "../embedded_list/fss_write.h" -#include "../payload/fss_write.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_write_main_print_error_format_unknown_ - f_status_t fss_write_main_print_error_format_unknown(const fl_print_t print, const f_string_static_t value) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - f_file_stream_lock(print.to); - - fl_print_format("%r%[%QThe format '%]", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error); - fl_print_format("%[%Q%]", print.to, print.set->notable, value, print.set->notable); - fl_print_format("%[' is not known for the parameter%] ", print.to, print.set->error, print.set->error); - fl_print_format("%[%Q%Q%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print.set->notable); - fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_write_main_print_error_format_unknown_ - -#ifndef _di_fss_write_main_print_help_ - f_status_t fss_write_main_print_help(fss_write_setting_t * const setting, const fl_print_t print) { - - if (!setting) return F_status_set_error(F_output_not); - - f_file_stream_lock(print.to); - - fll_program_print_help_header(print, fss_write_program_name_long_s, fss_write_program_version_s); - - fss_write_print_help(setting, print); - - fll_program_print_help_option(print, fss_write_short_as_s, fss_write_long_as_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Designate the supported format to write as."); - - f_print_dynamic_raw(f_string_eol_s, print.to); - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_usage(print, fss_write_program_name_s, f_string_empty_s); - - fss_write_print_help_pipe(setting, print); - - fss_write_print_help_end_next(setting, print); - - f_print_dynamic_raw(f_string_eol_s, print.to); - - fl_print_format(" The '%[%r%r%]' parameter supports the following standards with the specified possible case-sensitive values:%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print.set->notable, f_string_eol_s); - - // FSS-0000 (Basic) - fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_basic_standard_s, print.set->notable); - fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0000_s, print.set->notable); - fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0000_s, print.set->notable); - fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0000_s, print.set->notable, f_string_eol_s); - - // FSS-0001 (Extended) - fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_extended_standard_s, print.set->notable); - fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0001_s, print.set->notable); - fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0001_s, print.set->notable); - fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0001_s, print.set->notable, f_string_eol_s); - - // FSS-0002 (Basic List) - fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_basic_list_standard_s, print.set->notable); - fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0002_s, print.set->notable); - fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0002_s, print.set->notable); - fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0002_s, print.set->notable, f_string_eol_s); - - // FSS-0003 (Extended List) - fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_extended_list_standard_s, print.set->notable); - fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0003_s, print.set->notable); - fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0003_s, print.set->notable); - fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0003_s, print.set->notable, f_string_eol_s); - - // FSS-0008 (Embedded List) - fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_embedded_list_standard_s, print.set->notable); - fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_0008_s, print.set->notable); - fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_0008_s, print.set->notable); - fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_0008_s, print.set->notable, f_string_eol_s); - - // FSS-000E (Payload) - fl_print_format(" - As %[%r%] format: ", print.to, print.set->notable, fss_write_payload_standard_s, print.set->notable); - fl_print_format("'%[%r%]', ", print.to, print.set->notable, fss_write_format_code_short_000e_s, print.set->notable); - fl_print_format("'%[%r%]', or ", print.to, print.set->notable, fss_write_format_code_long_000e_s, print.set->notable); - fl_print_format("'%[%r%]'.%r", print.to, print.set->notable, fss_write_format_code_human_000e_s, print.set->notable, f_string_eol_s); - - f_print_dynamic_raw(f_string_eol_s, print.to); - - fl_print_format(" The %[%r%] format is the default when no ", print.to, print.set->notable, fss_write_basic_standard_s, print.set->notable); - fl_print_format("'%[%r%r%]' is specified.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print.set->notable, f_string_eol_s); - - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_write_main_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_write/c/main/main.c b/level_3/fss_write/c/main/main.c index d1c99c6..aee7ebe 100644 --- a/level_3/fss_write/c/main/main.c +++ b/level_3/fss_write/c/main/main.c @@ -1,6 +1,6 @@ #include "fss_write.h" #include "main.h" -#include "main-print.h" +#include "main/print.h" #include "../basic/fss_write.h" #include "../basic_list/fss_write.h" #include "../extended/fss_write.h" @@ -12,8 +12,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fss_write_main_t data = fss_write_main_t_initialize; - setting.state.custom = (void *) &data; - data.program.debug.flag |= fss_write_print_flag_debug_e; data.program.error.flag |= fss_write_print_flag_error_e; data.program.message.flag |= fss_write_print_flag_message_e; @@ -24,184 +22,186 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.warning.custom = (void *) &data; data.program.debug.custom = (void *) &data; + data.setting.state.custom = (void *) &data; + f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_write_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_write_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_write_setting_load(arguments, &data, &setting, &fss_write_main_setting_load_as); + fss_write_setting_load(arguments, &data, &fss_write_main_setting_load_as); } - fss_write_main(&data, &setting); + fss_write_main(&data); - fss_write_setting_unload(&data, &setting); + fss_write_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } #ifndef _di_fss_write_main_process_help_ - void fss_write_main_process_help(fll_program_data_t * const main, void * const void_setting) { + void fss_write_main_process_help(void * const void_main) { - if (!main || !void_setting) return; + if (!main) return; - fss_write_main_print_help(macro_fss_write_setting(void_setting), main->message); + fss_write_main_print_help(&((fss_write_main_t *) void_main)->program.message); } #endif // _di_fss_write_main_process_help_ #ifndef _di_fss_write_main_setting_load_as_ - void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting) { + void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fss_write_main_t * const main) { - if (!main || !setting || F_status_is_error(setting->state.status) || (setting->flag & fss_write_main_flag_version_e)) return; + if (!main || F_status_is_error(main->setting.state.status) || (main->setting.flag & fss_write_main_flag_version_e)) return; - setting->standard = fss_write_basic_standard_s; - setting->process_content = &fss_write_basic_process_content; - setting->process_help = &fss_write_main_process_help; - setting->process_normal = &fss_write_process_normal; - setting->process_object = &fss_write_basic_process_object; - setting->process_pipe = &fss_write_process_pipe; - setting->process_set = &fss_write_process_set; + main->setting.standard = fss_write_basic_standard_s; + main->setting.process_content = &fss_write_basic_process_content; + main->setting.process_help = &fss_write_main_process_help; + main->setting.process_normal = &fss_write_process_normal; + main->setting.process_object = &fss_write_basic_process_object; + main->setting.process_pipe = &fss_write_process_pipe; + main->setting.process_set = &fss_write_process_set; - if (main->parameters.array[fss_write_parameter_as_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_as_e].values.used) { + if (main->program.parameters.array[fss_write_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_write_parameter_as_e].values.used) { f_array_length_t index = 0; - f_string_static_t *argv = main->parameters.arguments.array; + f_string_static_t *argv = main->program.parameters.arguments.array; - for (f_array_length_t i = 0; i < main->parameters.array[fss_write_parameter_as_e].values.used; ++i) { + for (f_array_length_t i = 0; i < main->program.parameters.array[fss_write_parameter_as_e].values.used; ++i) { - index = main->parameters.array[fss_write_parameter_as_e].values.array[i]; + index = main->program.parameters.array[fss_write_parameter_as_e].values.array[i]; if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0000_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0000_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0000_s) == F_equal_to) { - setting->standard = fss_write_basic_standard_s; - setting->process_content = &fss_write_basic_process_content; - setting->process_help = &fss_write_basic_process_help; - setting->process_object = &fss_write_basic_process_object; - setting->process_pipe = &fss_write_process_pipe; - setting->process_normal = &fss_write_process_normal; - setting->process_set = &fss_write_process_set; - setting->flag -= setting->flag & fss_write_main_flag_ignore_e; // Not supported by basic. - setting->flag -= setting->flag & fss_write_main_flag_content_multiple_e; // Not supported by basic. + main->setting.standard = fss_write_basic_standard_s; + main->setting.process_content = &fss_write_basic_process_content; + main->setting.process_help = &fss_write_basic_process_help; + main->setting.process_object = &fss_write_basic_process_object; + main->setting.process_pipe = &fss_write_process_pipe; + main->setting.process_normal = &fss_write_process_normal; + main->setting.process_set = &fss_write_process_set; + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by basic. + main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; // Not supported by basic. } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0001_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0001_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0001_s) == F_equal_to) { - setting->standard = fss_write_extended_standard_s; - setting->process_content = &fss_write_extended_process_content; - setting->process_help = &fss_write_extended_process_help; - setting->process_object = &fss_write_extended_process_object; - setting->process_pipe = &fss_write_process_pipe; - setting->process_normal = &fss_write_process_normal; - setting->process_set = &fss_write_process_set; - setting->flag -= setting->flag & fss_write_main_flag_ignore_e; // Not supported by extended. - setting->flag |= fss_write_main_flag_content_multiple_e; + main->setting.standard = fss_write_extended_standard_s; + main->setting.process_content = &fss_write_extended_process_content; + main->setting.process_help = &fss_write_extended_process_help; + main->setting.process_object = &fss_write_extended_process_object; + main->setting.process_pipe = &fss_write_process_pipe; + main->setting.process_normal = &fss_write_process_normal; + main->setting.process_set = &fss_write_process_set; + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by extended. + main->setting.flag |= fss_write_main_flag_content_multiple_e; } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0002_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0002_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0002_s) == F_equal_to) { - setting->standard = fss_write_basic_list_standard_s; - setting->process_content = &fss_write_basic_list_process_content; - setting->process_help = &fss_write_basic_list_process_help; - setting->process_object = &fss_write_basic_list_process_object; - setting->process_pipe = &fss_write_process_pipe; - setting->process_normal = &fss_write_process_normal; - setting->process_set = &fss_write_process_set; - setting->flag -= setting->flag & fss_write_main_flag_ignore_e; // Not supported by basic list. - setting->flag -= setting->flag & fss_write_main_flag_content_multiple_e; // Not supported by basic list. + main->setting.standard = fss_write_basic_list_standard_s; + main->setting.process_content = &fss_write_basic_list_process_content; + main->setting.process_help = &fss_write_basic_list_process_help; + main->setting.process_object = &fss_write_basic_list_process_object; + main->setting.process_pipe = &fss_write_process_pipe; + main->setting.process_normal = &fss_write_process_normal; + main->setting.process_set = &fss_write_process_set; + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by basic list. + main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; // Not supported by basic list. } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0003_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0003_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0003_s) == F_equal_to) { - setting->standard = fss_write_extended_list_standard_s; - setting->process_content = &fss_write_extended_list_process_content; - setting->process_help = &fss_write_extended_list_process_help; - setting->process_object = &fss_write_extended_list_process_object; - setting->process_pipe = &fss_write_process_pipe; - setting->process_normal = &fss_write_process_normal; - setting->process_set = &fss_write_process_set; - setting->flag |= fss_write_main_flag_ignore_e; - setting->flag -= setting->flag & fss_write_main_flag_content_multiple_e; // Not supported by extended list. + main->setting.standard = fss_write_extended_list_standard_s; + main->setting.process_content = &fss_write_extended_list_process_content; + main->setting.process_help = &fss_write_extended_list_process_help; + main->setting.process_object = &fss_write_extended_list_process_object; + main->setting.process_pipe = &fss_write_process_pipe; + main->setting.process_normal = &fss_write_process_normal; + main->setting.process_set = &fss_write_process_set; + main->setting.flag |= fss_write_main_flag_ignore_e; + main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; // Not supported by extended list. } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0008_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0008_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_human_0008_s) == F_equal_to) { - setting->standard = fss_write_embedded_list_standard_s; - setting->process_content = &fss_write_embedded_list_process_content; - setting->process_help = &fss_write_embedded_list_process_help; - setting->process_object = &fss_write_embedded_list_process_object; - setting->process_pipe = &fss_write_process_pipe; - setting->process_normal = &fss_write_process_normal; - setting->process_set = &fss_write_process_set; - setting->flag |= fss_write_main_flag_ignore_e; - setting->flag |= fss_write_main_flag_content_multiple_e; + main->setting.standard = fss_write_embedded_list_standard_s; + main->setting.process_content = &fss_write_embedded_list_process_content; + main->setting.process_help = &fss_write_embedded_list_process_help; + main->setting.process_object = &fss_write_embedded_list_process_object; + main->setting.process_pipe = &fss_write_process_pipe; + main->setting.process_normal = &fss_write_process_normal; + main->setting.process_set = &fss_write_process_set; + main->setting.flag |= fss_write_main_flag_ignore_e; + main->setting.flag |= fss_write_main_flag_content_multiple_e; } else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_000e_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_long_000e_s) == F_equal_to || fl_string_dynamic_compare(argv[index], fss_write_format_code_human_000e_s) == F_equal_to) { - setting->standard = fss_write_payload_standard_s; - setting->process_content = 0; // Not used by payload. - setting->process_help = &fss_write_payload_process_help; - setting->process_normal = &fss_write_process_normal; - setting->process_object = 0; // Not used by payload. - setting->process_pipe = &fss_write_payload_process_pipe; - setting->process_set = &fss_write_payload_process_set; - setting->flag -= setting->flag & fss_write_main_flag_ignore_e; // Not supported by payload. - setting->flag -= setting->flag & fss_write_main_flag_content_multiple_e; // Not supported by payload. + main->setting.standard = fss_write_payload_standard_s; + main->setting.process_content = 0; // Not used by payload. + main->setting.process_help = &fss_write_payload_process_help; + main->setting.process_normal = &fss_write_process_normal; + main->setting.process_object = 0; // Not used by payload. + main->setting.process_pipe = &fss_write_payload_process_pipe; + main->setting.process_set = &fss_write_payload_process_set; + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by payload. + main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; // Not supported by payload. } else { - if (setting->flag & fss_write_main_flag_help_e) { - setting->state.status = F_status_set_error(F_parameter); + if (main->setting.flag & fss_write_main_flag_help_e) { + main->setting.state.status = F_status_set_error(F_parameter); break; } - setting->state.status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - fss_write_main_print_error_format_unknown(main->error, argv[index]); + fss_write_main_print_error_format_unknown(&main->program.error, argv[index]); } } // for - if (F_status_is_error(setting->state.status)) { - if (setting->flag & fss_write_main_flag_help_e) { - fss_write_main_process_help(main, setting); + if (F_status_is_error(main->setting.state.status)) { + if (main->setting.flag & fss_write_main_flag_help_e) { + fss_write_main_process_help((void *) main); } return; } } - else if (main->parameters.array[fss_write_parameter_as_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[fss_write_parameter_as_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if (setting->flag & fss_write_main_flag_help_e) { - fss_write_main_process_help(main, setting); + if (main->setting.flag & fss_write_main_flag_help_e) { + fss_write_main_process_help((void *) main); return; } - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error.to); + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error.to); } - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_write_long_as_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_write_long_as_s); return; } diff --git a/level_3/fss_write/c/main/main.h b/level_3/fss_write/c/main/main.h index 7c230ae..f467646 100644 --- a/level_3/fss_write/c/main/main.h +++ b/level_3/fss_write/c/main/main.h @@ -35,19 +35,17 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * Process printing help for when not specifying "--as". * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This does not alter setting.state.status. + * This does not alter main.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_write_main_process_help_ - extern void fss_write_main_process_help(fll_program_data_t * const main, void * const setting); + extern void fss_write_main_process_help(void * const main); #endif // _di_fss_write_main_process_help_ /** @@ -60,13 +58,11 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * @param arguments * The parameters passed to the process (often referred to as command line arguments). * @param main - * The main program data. - * @param setting - * The main program settings. + * The main program and settings data. * - * This alters setting.process_help, setting.process_normal, and setting.process_pipe. + * This alters main.setting.process_help, main.setting.process_normal, and main.setting.process_pipe. * - * This alters setting.state.status: + * This alters main.setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * @@ -91,7 +87,7 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * @see fss_write_setting_load() */ #ifndef _di_fss_write_main_setting_load_as_ - extern void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting); + extern void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fss_write_main_t * const main); #endif // _di_fss_write_main_setting_load_as_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/main/main/print.c b/level_3/fss_write/c/main/main/print.c new file mode 100644 index 0000000..065eee8 --- /dev/null +++ b/level_3/fss_write/c/main/main/print.c @@ -0,0 +1,109 @@ +#include "../fss_write.h" +#include "print.h" +#include "../../basic/fss_write.h" +#include "../../basic_list/fss_write.h" +#include "../../extended/fss_write.h" +#include "../../extended_list/fss_write.h" +#include "../../embedded_list/fss_write.h" +#include "../../payload/fss_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_write_main_print_error_format_unknown_ + f_status_t fss_write_main_print_error_format_unknown(fl_print_t * const print, const f_string_static_t value) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe format '%]", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%Q%]", print->to, print->set->notable, value, print->set->notable); + fl_print_format("%[' is not known for the parameter%] ", print->to, print->set->error, print->set->error); + fl_print_format("%[%Q%Q%]", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print->set->notable); + fl_print_format("%[.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_write_main_print_error_format_unknown_ + +#ifndef _di_fss_write_main_main_print_help_ + f_status_t fss_write_main_print_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_write_program_name_long_s, fss_write_program_version_s); + + fss_write_print_message_help(print); + + fll_program_print_help_option(print, fss_write_short_as_s, fss_write_long_as_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Designate the supported format to write as."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_write_program_name_s, f_string_empty_s); + + fss_write_print_message_help_pipe(print); + + fss_write_print_message_help_end_next(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fl_print_format(" The '%[%r%r%]' parameter supports the following standards with the specified possible case-sensitive values:%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print->set->notable, f_string_eol_s); + + // FSS-0000 (Basic) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_write_basic_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_write_format_code_short_0000_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_write_format_code_long_0000_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_write_format_code_human_0000_s, print->set->notable, f_string_eol_s); + + // FSS-0001 (Extended) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_write_extended_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_write_format_code_short_0001_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_write_format_code_long_0001_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_write_format_code_human_0001_s, print->set->notable, f_string_eol_s); + + // FSS-0002 (Basic List) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_write_basic_list_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_write_format_code_short_0002_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_write_format_code_long_0002_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_write_format_code_human_0002_s, print->set->notable, f_string_eol_s); + + // FSS-0003 (Extended List) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_write_extended_list_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_write_format_code_short_0003_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_write_format_code_long_0003_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_write_format_code_human_0003_s, print->set->notable, f_string_eol_s); + + // FSS-0008 (Embedded List) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_write_embedded_list_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_write_format_code_short_0008_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_write_format_code_long_0008_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_write_format_code_human_0008_s, print->set->notable, f_string_eol_s); + + // FSS-000E (Payload) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_write_payload_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_write_format_code_short_000e_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_write_format_code_long_000e_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_write_format_code_human_000e_s, print->set->notable, f_string_eol_s); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fl_print_format(" The %[%r%] format is the default when no ", print->to, print->set->notable, fss_write_basic_standard_s, print->set->notable); + fl_print_format("'%[%r%r%]' is specified.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_as_s, print->set->notable, f_string_eol_s); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_write_main_main_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_write/c/main/main-print.h b/level_3/fss_write/c/main/main/print.h similarity index 67% rename from level_3/fss_write/c/main/main-print.h rename to level_3/fss_write/c/main/main/print.h index 73e9f49..24ee31f 100644 --- a/level_3/fss_write/c/main/main-print.h +++ b/level_3/fss_write/c/main/main/print.h @@ -15,39 +15,39 @@ extern "C" { /** * Print an error message about a value given to the --as parameter being unknown. * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print - * Designates the how and where to print. + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. * @param value * A string representing the value that is of an unknown format. * * @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. */ #ifndef _di_fss_write_main_print_error_format_unknown_ - extern f_status_t fss_write_main_print_error_format_unknown(const fl_print_t print, const f_string_static_t value); + extern f_status_t fss_write_main_print_error_format_unknown(fl_print_t * const print, const f_string_static_t value); #endif // _di_fss_write_main_print_error_format_unknown_ /** * Print help for "main" fss_write. * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print * The output structure to print to. * + * 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. */ #ifndef _di_fss_write_print_main_help_ - extern f_status_t fss_write_main_print_help(fss_write_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_write_main_print_help(fl_print_t * const print); #endif // _di_fss_write_print_main_help_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/main/print.c b/level_3/fss_write/c/main/print.c deleted file mode 100644 index fc0ed10..0000000 --- a/level_3/fss_write/c/main/print.c +++ /dev/null @@ -1,169 +0,0 @@ -#include "fss_write.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_write_print_error_ - f_status_t fss_write_print_error(fss_write_setting_t * const setting, const fl_print_t print, const f_string_t function) { - - if (!setting) return F_status_set_error(F_output_not); - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e); - - return F_none; - } -#endif // _di_fss_write_print_error_ - -#ifndef _di_fss_write_print_error_file_ - f_status_t fss_write_print_error_file(fss_write_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { - - if (!setting) return F_status_set_error(F_output_not); - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type); - - return F_none; - } -#endif // _di_fss_write_print_error_file_ - -#ifndef _di_fss_write_print_error_parameter_same_times_at_least_ - f_status_t fss_write_print_error_parameter_same_times_at_least(fss_write_setting_t * const setting, const fl_print_t print) { - - if (!setting) return F_status_set_error(F_output_not); - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - f_file_stream_lock(print.to); - - fl_print_format("%[%QMust specify the '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%r%r%]", print.to, print.notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.notable); - fl_print_format("%[' parameter at least the same number of times as the '%]", print.to, print.context, print.context); - fl_print_format("%[%r%r%]", print.to, print.notable, f_console_symbol_long_normal_s, fss_write_long_object_s, print.notable); - fl_print_format("%[' parameter when not specifying the '%]", print.to, print.context, print.context); - fl_print_format("%[%r%r%]", print.to, print.notable, f_console_symbol_long_normal_s, fss_write_long_partial_s, print.notable); - fl_print_format("%[' parameter.%]%r", print.to, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_write_print_error_parameter_same_times_at_least_ - -#ifndef _di_fss_write_print_error_one_content_only_ - f_status_t fss_write_print_error_one_content_only(fss_write_setting_t * const setting, const fl_print_t print) { - - if (!setting) return F_status_set_error(F_output_not); - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - f_file_stream_lock(print.to); - - fl_print_format("%r%[%QThe%] ", print.to, f_string_eol_s, print.context, print.prefix, print.context); - fl_print_format("%[%r%]", print.to, print.notable, setting->standard, print.notable); - fl_print_format(" %[standard only supports one Content per Object.%]%r", print.to, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_write_print_error_one_content_only_ - -#ifndef _fss_write_print_error_prepend_only_whitespace_ - f_status_t fss_write_print_error_prepend_only_whitespace(fss_write_setting_t * const setting, const fl_print_t print) { - - if (!setting) return F_status_set_error(F_output_not); - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - f_file_stream_lock(print.to); - - fl_print_format("%r%[%QThe value for the parameter '%]", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error); - fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_prepend_s, print.set->notable); - fl_print_format("%[' must only contain white space.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _fss_write_print_error_prepend_only_whitespace_ - -#ifndef _di_fss_write_print_error_unsupported_eol_ - f_status_t fss_write_print_error_unsupported_eol(fss_write_setting_t * const setting, const fl_print_t print) { - - if (!setting) return F_status_set_error(F_output_not); - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - f_file_stream_lock(print.to); - - fl_print_format("%r%[%QThe%] ", print.to, f_string_eol_s, print.context, print.prefix, print.context); - fl_print_format("%[%r%]", print.to, print.notable, setting->standard, print.notable); - fl_print_format(" %[standard does not support end of line character '%]", print.to, print.context, print.context); - fl_print_format("%[\\n%]", print.to, print.set->notable, print.set->notable); - fl_print_format("%[' (%]", print.to, print.set->error, print.set->error); - fl_print_format("%[U+000A%]", print.to, print.set->notable, print.set->notable); - fl_print_format("%[) in Objects.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_write_print_error_unsupported_eol_ - -#ifndef _di_fss_write_print_help_ - void fss_write_print_help(fss_write_setting_t * const setting, const fl_print_t print) { - - if (!setting) return; - - fll_program_print_help_option_standard(print); - - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_option(print, fss_write_short_backtick_s, fss_write_long_backtick_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use backticks to quote."); - fll_program_print_help_option(print, fss_write_short_content_s, fss_write_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Content to write."); - fll_program_print_help_option(print, fss_write_short_content_end_s, fss_write_long_content_end_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Write the end of Content characters."); - fll_program_print_help_option(print, fss_write_short_content_next_s, fss_write_long_content_next_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Write the next Content characters (separates multi-Content apart)."); - fll_program_print_help_option(print, fss_write_short_double_s, fss_write_long_double_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use double quotes (default)."); - fll_program_print_help_option(print, fss_write_short_file_s, fss_write_long_file_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a file to send data to."); - fll_program_print_help_option(print, fss_write_short_ignore_s, fss_write_long_ignore_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Ignore a given range within a Content."); - fll_program_print_help_option(print, fss_write_short_object_s, fss_write_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Object to write."); - fll_program_print_help_option(print, fss_write_short_object_open_s, fss_write_long_object_open_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Write the open Object characters."); - fll_program_print_help_option(print, fss_write_short_partial_s, fss_write_long_partial_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Do not write a complete Object and Content set."); - fll_program_print_help_option(print, fss_write_short_prepend_s, fss_write_long_prepend_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Prepend the given white space characters to the start of each multi-line Content."); - fll_program_print_help_option(print, fss_write_short_single_s, fss_write_long_single_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use single quotes."); - fll_program_print_help_option(print, fss_write_short_trim_s, fss_write_long_trim_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Trim Object names."); - - f_print_dynamic_raw(f_string_eol_s, print.to); - } -#endif // _di_fss_write_print_help_ - -#ifndef _di_fss_write_print_help_end_next_ - void fss_write_print_help_end_next(fss_write_setting_t * const setting, const fl_print_t print) { - - if (!setting); - - fl_print_format("%r The '%[%r%r%]',", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_object_open_s, print.set->notable); - fl_print_format(" '%[%r%r%]', and", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_next_s, print.set->notable); - fl_print_format(" '%[%r%r%]' help facilitate writing the designated data for when using", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_end_s, print.set->notable); - fl_print_format(" '%[%r%r%]'.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_partial_s, print.set->notable, f_string_eol_s); - - fl_print_format(" These may also be used when there is no '%[%r%r%]' or", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_object_s, print.set->notable); - fl_print_format(" '%[%r%r%]' specified to only print the designated data.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable, f_string_eol_s); - } -#endif // _di_fss_write_print_help_end_next_ - -#ifndef _di_fss_write_print_help_pipe_ - void fss_write_print_help_pipe(fss_write_setting_t * const setting, const fl_print_t print) { - - if (!setting) return; - - fl_print_format("%r The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%r", print.to, f_string_eol_s, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); - fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); - fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range (use this both before and after the range).%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); - fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable); - fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%r", print.to, print.set->notable, print.set->notable, print.set->notable, print.set->notable, f_string_eol_s); - fl_print_format(" The end of the pipe represents the end of any Object or Content.%r", print.to, f_string_eol_s); - } -#endif // _di_fss_write_print_help_pipe_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_write/c/main/print.h b/level_3/fss_write/c/main/print.h deleted file mode 100644 index a5c73fc..0000000 --- a/level_3/fss_write/c/main/print.h +++ /dev/null @@ -1,190 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Write - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _fss_write_print_h -#define _fss_write_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print generic error message regarding a function failing in some way. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * Designates the how and where to print. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - * - * @see fll_error_print() - */ -#ifndef _di_fss_write_print_error_ - extern f_status_t fss_write_print_error(fss_write_setting_t * const setting, const fl_print_t print, const f_string_t function); -#endif // _di_fss_write_print_error_ - -/** - * Print file related error or warning messages. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * Designates how printing is to be performed. - * @param function - * The name of the function where the error happened. - * Set to 0 to disable. - * @param name - * The name of the file or directory. - * @param operation - * The operation that fails, such as 'create' or 'access'. - * @param type - * A valid file type code from the fll_error_file_type enum. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - * - * @see fll_error_file_print() - */ -#ifndef _di_fss_write_print_error_file_ - extern f_status_t fss_write_print_error_file(fss_write_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); -#endif // _di_fss_write_print_error_file_ - -/** - * Print an error message about the object and content parameters not being specified at least the same number of times when partial is not requested. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * Designates the how and where to print. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - * - * @see fll_error_print() - */ -#ifndef _di_fss_write_print_error_parameter_same_times_at_least_ - extern f_status_t fss_write_print_error_parameter_same_times_at_least(fss_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_write_print_error_parameter_same_times_at_least_ - -/** - * Print an message about a multiple Content being unsupported for a particular standard. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * Designates the how and where to print. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - */ -#ifndef _di_fss_write_print_error_one_content_only_ - extern f_status_t fss_write_print_error_one_content_only(fss_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_write_print_error_one_content_only_ - -/** - * Print error when prepend parameter has something other than white space. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * Designates the how and where to print. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - */ -#ifndef _fss_write_print_error_prepend_only_whitespace_ - extern f_status_t fss_write_print_error_prepend_only_whitespace(fss_write_setting_t * const setting, const fl_print_t print); -#endif // _fss_write_print_error_prepend_only_whitespace_ - -/** - * Print an error message about a parameter New Line character '\n' (U+000A) being unsupported. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * Designates the how and where to print. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - */ -#ifndef _di_fss_write_print_error_unsupported_eol_ - extern f_status_t fss_write_print_error_unsupported_eol(fss_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_write_print_error_unsupported_eol_ - -/** - * Print standard parts of the help. - * - * This is expected to be called as part of the help printing and does not perform any locking. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - */ -#ifndef _di_fss_write_print_help_ - extern void fss_write_print_help(fss_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_write_print_help_ - -/** - * Print standard parts of the help regarding Object End, Content Next, and Content End usage. - * - * This is expected to be called as part of the help printing and does not perform any locking. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - */ -#ifndef _di_fss_write_print_help_end_next_ - extern void fss_write_print_help_end_next(fss_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_write_print_help_end_next_ - -/** - * Print standard parts of the help regarding pipe usage. - * - * This is expected to be called as part of the help printing and does not perform any locking. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - */ -#ifndef _di_fss_write_print_help_pipe_ - extern void fss_write_print_help_pipe(fss_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_write_print_help_pipe_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_write_print_h diff --git a/level_3/fss_write/c/main/print/data.c b/level_3/fss_write/c/main/print/data.c index e69de29..0b80a88 100644 --- a/level_3/fss_write/c/main/print/data.c +++ b/level_3/fss_write/c/main/print/data.c @@ -0,0 +1,9 @@ +#include "../fss_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_write/c/main/print/data.h b/level_3/fss_write/c/main/print/data.h index e69de29..32fde6a 100644 --- a/level_3/fss_write/c/main/print/data.h +++ b/level_3/fss_write/c/main/print/data.h @@ -0,0 +1,23 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print data functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_write_print_data_h +#define _fss_write_print_data_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_write_print_data_h diff --git a/level_3/fss_write/c/main/print/error.c b/level_3/fss_write/c/main/print/error.c index e69de29..eb4ea34 100644 --- a/level_3/fss_write/c/main/print/error.c +++ b/level_3/fss_write/c/main/print/error.c @@ -0,0 +1,113 @@ +#include "../fss_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_write_print_error_ + f_status_t fss_write_print_error(fl_print_t * const print, const f_string_t function) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + fll_error_print(print, F_status_set_fine(((fss_write_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e); + + return F_none; + } +#endif // _di_fss_write_print_error_ + +#ifndef _di_fss_write_print_error_file_ + f_status_t fss_write_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + fll_error_file_print(print, F_status_set_fine(((fss_write_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type); + + return F_none; + } +#endif // _di_fss_write_print_error_file_ + +#ifndef _di_fss_write_print_error_parameter_same_times_at_least_ + f_status_t fss_write_print_error_parameter_same_times_at_least(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QMust specify the '%]", print->to, print->context, print->prefix, print->context); + fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print->notable); + fl_print_format("%[' parameter at least the same number of times as the '%]", print->to, print->context, print->context); + fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_write_long_object_s, print->notable); + fl_print_format("%[' parameter when not specifying the '%]", print->to, print->context, print->context); + fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_write_long_partial_s, print->notable); + fl_print_format("%[' parameter.%]%r", print->to, print->context, print->context, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_write_print_error_parameter_same_times_at_least_ + +#ifndef _di_fss_write_print_error_one_content_only_ + f_status_t fss_write_print_error_one_content_only(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe%] ", print->to, print->context, print->prefix, print->context); + fl_print_format("%[%r%]", print->to, print->notable, ((fss_write_main_t *) print->custom)->setting.standard, print->notable); + fl_print_format(" %[standard only supports one Content per Object.%]%r", print->to, print->context, print->context, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_write_print_error_one_content_only_ + +#ifndef _fss_write_print_error_prepend_only_whitespace_ + f_status_t fss_write_print_error_prepend_only_whitespace(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe value for the parameter '%]", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_prepend_s, print->set->notable); + fl_print_format("%[' must only contain white space.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _fss_write_print_error_prepend_only_whitespace_ + +#ifndef _di_fss_write_print_error_unsupported_eol_ + f_status_t fss_write_print_error_unsupported_eol(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe%] ", print->to, print->context, print->prefix, print->context); + fl_print_format("%[%r%]", print->to, print->notable, ((fss_write_main_t *) print->custom)->setting.standard, print->notable); + fl_print_format(" %[standard does not support end of line character '%]", print->to, print->context, print->context); + fl_print_format("%[\\n%]", print->to, print->set->notable, print->set->notable); + fl_print_format("%[' (%]", print->to, print->set->error, print->set->error); + fl_print_format("%[U+000A%]", print->to, print->set->notable, print->set->notable); + fl_print_format("%[) in Objects.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_write_print_error_unsupported_eol_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_write/c/main/print/error.h b/level_3/fss_write/c/main/print/error.h index e69de29..42c738f 100644 --- a/level_3/fss_write/c/main/print/error.h +++ b/level_3/fss_write/c/main/print/error.h @@ -0,0 +1,146 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print error functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_write_print_error_h +#define _fss_write_print_error_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print generic error message regarding a function failing in some way. + * + * @param print + * The output structure to print to. + * + * 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() + */ +#ifndef _di_fss_write_print_error_ + extern f_status_t fss_write_print_error(fl_print_t * const print, const f_string_t function); +#endif // _di_fss_write_print_error_ + +/** + * Print file related error or warning messages. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param type + * A valid file type code from the fll_error_file_type enum. + * + * @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_file_print() + */ +#ifndef _di_fss_write_print_error_file_ + extern f_status_t fss_write_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); +#endif // _di_fss_write_print_error_file_ + +/** + * Print an error message about the object and content parameters not being specified at least the same number of times when partial is not requested. + * + * @param print + * The output structure to print to. + * + * 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() + */ +#ifndef _di_fss_write_print_error_parameter_same_times_at_least_ + extern f_status_t fss_write_print_error_parameter_same_times_at_least(fl_print_t * const print); +#endif // _di_fss_write_print_error_parameter_same_times_at_least_ + +/** + * Print an message about a multiple Content being unsupported for a particular standard. + * + * @param print + * The output structure to print to. + * + * 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. + */ +#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); +#endif // _di_fss_write_print_error_one_content_only_ + +/** + * Print error when prepend parameter has something other than white space. + * + * @param print + * The output structure to print to. + * + * 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. + */ +#ifndef _fss_write_print_error_prepend_only_whitespace_ + extern f_status_t fss_write_print_error_prepend_only_whitespace(fl_print_t * const print); +#endif // _fss_write_print_error_prepend_only_whitespace_ + +/** + * Print an error message about a parameter New Line character '\n' (U+000A) being unsupported. + * + * @param print + * The output structure to print to. + * + * 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. + */ +#ifndef _di_fss_write_print_error_unsupported_eol_ + extern f_status_t fss_write_print_error_unsupported_eol(fl_print_t * const print); +#endif // _di_fss_write_print_error_unsupported_eol_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_write_print_error_h diff --git a/level_3/fss_write/c/main/print/message.c b/level_3/fss_write/c/main/print/message.c index e69de29..1d1889d 100644 --- a/level_3/fss_write/c/main/print/message.c +++ b/level_3/fss_write/c/main/print/message.c @@ -0,0 +1,63 @@ +#include "../fss_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_write_print_message_help_ + void fss_write_print_message_help(fl_print_t * const print) { + + if (!print) return; + + fll_program_print_help_option_standard(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_option(print, fss_write_short_backtick_s, fss_write_long_backtick_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use backticks to quote."); + fll_program_print_help_option(print, fss_write_short_content_s, fss_write_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Content to write."); + fll_program_print_help_option(print, fss_write_short_content_end_s, fss_write_long_content_end_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Write the end of Content characters."); + fll_program_print_help_option(print, fss_write_short_content_next_s, fss_write_long_content_next_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Write the next Content characters (separates multi-Content apart)."); + fll_program_print_help_option(print, fss_write_short_double_s, fss_write_long_double_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use double quotes (default)."); + fll_program_print_help_option(print, fss_write_short_file_s, fss_write_long_file_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a file to send data to."); + fll_program_print_help_option(print, fss_write_short_ignore_s, fss_write_long_ignore_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Ignore a given range within a Content."); + fll_program_print_help_option(print, fss_write_short_object_s, fss_write_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Object to write."); + fll_program_print_help_option(print, fss_write_short_object_open_s, fss_write_long_object_open_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Write the open Object characters."); + fll_program_print_help_option(print, fss_write_short_partial_s, fss_write_long_partial_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Do not write a complete Object and Content set."); + fll_program_print_help_option(print, fss_write_short_prepend_s, fss_write_long_prepend_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Prepend the given white space characters to the start of each multi-line Content."); + fll_program_print_help_option(print, fss_write_short_single_s, fss_write_long_single_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use single quotes."); + fll_program_print_help_option(print, fss_write_short_trim_s, fss_write_long_trim_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Trim Object names."); + } +#endif // _di_fss_write_print_message_help_ + +#ifndef _di_fss_write_print_message_help_end_next_ + void fss_write_print_message_help_end_next(fl_print_t * const print) { + + if (!print) return; + + fl_print_format(" The '%[%r%r%]',", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_object_open_s, print->set->notable); + fl_print_format(" '%[%r%r%]', and", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_content_next_s, print->set->notable); + fl_print_format(" '%[%r%r%]' help facilitate writing the designated data for when using", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_content_end_s, print->set->notable); + fl_print_format(" '%[%r%r%]'.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_partial_s, print->set->notable, f_string_eol_s); + + fl_print_format(" These may also be used when there is no '%[%r%r%]' or", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_object_s, print->set->notable); + fl_print_format(" '%[%r%r%]' specified to only print the designated data.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print->set->notable, f_string_eol_s); + } +#endif // _di_fss_write_print_message_help_end_next_ + +#ifndef _di_fss_write_print_message_help_pipe_ + void fss_write_print_message_help_pipe(fl_print_t * const print) { + + if (!print) return; + + fl_print_format(" The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%r", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%r", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range (use this both before and after the range).%r", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable); + fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%r", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" The end of the pipe represents the end of any Object or Content.%r", print->to, f_string_eol_s); + } +#endif // _di_fss_write_print_message_help_pipe_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_write/c/main/print/message.h b/level_3/fss_write/c/main/print/message.h index e69de29..66b20e0 100644 --- a/level_3/fss_write/c/main/print/message.h +++ b/level_3/fss_write/c/main/print/message.h @@ -0,0 +1,65 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print message functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_write_print_message_h +#define _fss_write_print_message_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print standard parts of the help. + * + * This is expected to be called as part of the help printing and does not perform any locking. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_fss_write_print_message_help_ + extern void fss_write_print_message_help(fl_print_t * const print); +#endif // _di_fss_write_print_message_help_ + +/** + * Print standard parts of the help regarding Object End, Content Next, and Content End usage. + * + * This is expected to be called as part of the help printing and does not perform any locking. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_fss_write_print_message_help_end_next_ + extern void fss_write_print_message_help_end_next(fl_print_t * const print); +#endif // _di_fss_write_print_message_help_end_next_ + +/** + * Print standard parts of the help regarding pipe usage. + * + * This is expected to be called as part of the help printing and does not perform any locking. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_fss_write_print_message_help_pipe_ + extern void fss_write_print_message_help_pipe(fl_print_t * const print); +#endif // _di_fss_write_print_message_help_pipe_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_write_print_message_h diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index ee03aa6..cda9787 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -6,37 +6,37 @@ extern "C" { #endif #ifndef _di_fss_write_payload_process_help_ - void fss_write_payload_process_help(fll_program_data_t * const main, void * const void_setting) { + void fss_write_payload_process_help(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_payload_print_help(macro_fss_write_setting(void_setting), main->message); + fss_write_payload_print_help(&((fss_write_main_t *) void_main)->program.message); } #endif // _di_fss_write_payload_process_help_ #ifndef _di_fss_write_payload_process_pipe_ - void fss_write_payload_process_pipe(fll_program_data_t * const main, void * const void_setting) { + void fss_write_payload_process_pipe(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; + + fss_write_main_t * const main = (fss_write_main_t *) void_main; 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 = fss_write_allocation_large_d; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - f_array_length_t total = 0; f_array_length_t length = 0; f_string_range_t range = f_string_range_t_initialize; - const f_array_length_t used_objects = setting->objects.used; - const f_array_length_t used_contentss = setting->contentss.used; - const f_array_length_t used_ignoress = setting->ignoress.used; + 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; - setting->object = &setting->objects.array[used_objects]; - setting->contents = &setting->contentss.array[used_contentss]; - setting->ignores = &setting->ignoress.array[used_ignoress]; + 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, 0x8 = "payload" matched. uint8_t flag = 0; @@ -45,113 +45,113 @@ extern "C" { uint8_t state = 0; // This is processed in a single set, so there is only ever one Object added. - setting->state.status = f_string_dynamics_increase(setting->state.step_small, &setting->objects); + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, &main->setting.objects); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamics_increase)); return; } // This is processed in a single set, so there is only ever one Content added. - setting->state.status = f_string_dynamicss_increase(setting->state.step_small, &setting->contentss); + main->setting.state.status = f_string_dynamicss_increase(main->setting.state.step_small, &main->setting.contentss); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamicss_increase)); return; } - setting->state.status = f_string_dynamics_increase(setting->state.step_small, setting->contents); + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamics_increase)); return; } // This is processed in a single set, so there is only ever one Ignores added. - setting->state.status = f_string_rangess_increase(setting->state.step_small, &setting->ignoress); + main->setting.state.status = f_string_rangess_increase(main->setting.state.step_small, &main->setting.ignoress); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_rangess_increase)); return; } // Reset all of the used data before starting the loop. - setting->object->used = 0; - setting->contents->used = 0; - setting->ignores->used = 0; + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; for (;;) { - if (!((++main->signal_check) % fss_write_signal_check_d)) { + if (!((++main->program.signal_check) % fss_write_signal_check_d)) { if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); - setting->state.status = F_status_set_error(F_interrupt); + main->setting.state.status = F_status_set_error(F_interrupt); break; } - main->signal_check = 0; + main->program.signal_check = 0; } if (range.start > range.stop) { if (status_pipe == F_none_eof) break; - setting->block.used = 0; + main->setting.block.used = 0; - status_pipe = f_file_read_block(input, &setting->block); + status_pipe = f_file_read_block(input, &main->setting.block); if (F_status_is_error(status_pipe)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_file_read_block)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_file_read_block)); status_pipe = F_status_set_error(F_pipe); break; } - if (!setting->block.used) break; + if (!main->setting.block.used) break; range.start = 0; - range.stop = setting->block.used - 1; + range.stop = main->setting.block.used - 1; status_pipe = F_none; } // Start Object. if (!state || state == 0x1) { if (!state) { - setting->object->used = 0; + main->setting.object->used = 0; state = 0x1; } // Reset the "has Content for Object" flag and associated contents array used length. flag -= flag | 0x4; - setting->contents->used = 0; + main->setting.contents->used = 0; - setting->state.status = f_string_dynamic_increase_by(setting->block.used, setting->object); + main->setting.state.status = f_string_dynamic_increase_by(main->setting.block.used, main->setting.object); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } - for (; range.start <= range.stop && range.start < setting->block.used; ++range.start) { + for (; range.start <= range.stop && range.start < main->setting.block.used; ++range.start) { // Do not handle start/end while inside an ignore set. if (!(flag & 0x2)) { - if (setting->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { state = 0x2; ++range.start; break; } - if (setting->block.string[range.start] == fss_write_pipe_content_end_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_end_s.string[0]) { state = 0x3; ++range.start; @@ -160,7 +160,7 @@ extern "C" { } // There currently is no support for "ignore" in Objects, but the Ignore should still be processed. - if (setting->block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) { // Ignore is enabled. if (flag & 0x2) { @@ -173,10 +173,10 @@ extern "C" { continue; } - setting->object->string[setting->object->used++] = setting->block.string[range.start]; + main->setting.object->string[main->setting.object->used++] = main->setting.block.string[range.start]; } // for - if (F_status_is_error(setting->state.status)) break; + if (F_status_is_error(main->setting.state.status)) break; // If the start of Content was not found, then fetch the next block. if (state == 0x1) continue; @@ -190,18 +190,18 @@ extern "C" { // Check to see if the Content supports multiple Content per Object. if (flag & 0x4) { - if (!(setting->flag & fss_write_main_flag_content_multiple_e)) { - setting->state.status = F_status_set_error(F_support_not); + if (!(main->setting.flag & fss_write_main_flag_content_multiple_e)) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_one_content_only(setting, main->error); + fss_write_print_error_one_content_only(&main->program.error); break; } - setting->state.status = f_string_dynamics_increase(setting->state.step_small, setting->contents); + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamics_increase)); break; } @@ -215,19 +215,19 @@ extern "C" { } // When payload is provided, all data at this point is part of the payload until the end of the pipe. - if (fl_string_dynamic_compare(f_fss_payload_s, *setting->object) == F_equal_to) { + if (fl_string_dynamic_compare(f_fss_payload_s, *main->setting.object) == F_equal_to) { if (total > 1) { - setting->state.status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); + main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } - memcpy(setting->contents->array[setting->contents->used].string, setting->block.string + range.start, sizeof(f_char_t) * total); + memcpy(main->setting.contents->array[main->setting.contents->used].string, main->setting.block.string + range.start, sizeof(f_char_t) * total); - setting->contents->array[setting->contents->used].used += total; + main->setting.contents->array[main->setting.contents->used].used += total; } state = 0x4; @@ -241,27 +241,27 @@ extern "C" { } if (total) { - setting->state.status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); + main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } - for (; range.start <= range.stop && range.start < setting->block.used; ++range.start) { + for (; range.start <= range.stop && range.start < main->setting.block.used; ++range.start) { // Do not handle start/end while inside an ignore set. if (!(flag & 0x2)) { - if (setting->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { - setting->state.status = F_status_set_error(F_support_not); + if (main->setting.block.string[range.start] == fss_write_pipe_content_start_s.string[0]) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_one_content_only(setting, main->error); + fss_write_print_error_one_content_only(&main->program.error); break; } - if (setting->block.string[range.start] == fss_write_pipe_content_end_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_end_s.string[0]) { state = 0x3; ++range.start; @@ -270,7 +270,7 @@ extern "C" { } // There currently is no support for "ignore" in Contents, but the Ignore should still be processed. - if (setting->block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) { + if (main->setting.block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) { // Ignore is enabled. if (flag & 0x2) { @@ -283,12 +283,12 @@ extern "C" { continue; } - setting->contents->array[setting->contents->used].string[setting->contents->array[setting->contents->used].used++] = setting->block.string[range.start]; + 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 - if (F_status_is_error(setting->state.status)) break; + if (F_status_is_error(main->setting.state.status)) break; - ++setting->contents->used; + ++main->setting.contents->used; flag |= 0x4; } else { @@ -298,36 +298,36 @@ extern "C" { // End Object or Content set. if (state == 0x3) { - fss_write_payload_process_set(main, void_setting); - if (F_status_is_error(setting->state.status)) break; + fss_write_payload_process_set(void_main); + if (F_status_is_error(main->setting.state.status)) break; state = 0; flag |= 0x1; // Reset all of the used data for next set. - setting->object->used = 0; - setting->contents->used = 0; - setting->ignores->used = 0; + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; continue; } // Payload Object. if (state == 0x4) { - if (setting->block.used && range.start <= range.stop) { + if (main->setting.block.used && range.start <= range.stop) { length = (range.stop - range.start) + 1; - setting->state.status = f_string_dynamic_increase_by(length + 1, &setting->contents->array[setting->contents->used]); + main->setting.state.status = f_string_dynamic_increase_by(length + 1, &main->setting.contents->array[main->setting.contents->used]); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } - memcpy(setting->contents->array[setting->contents->used].string + range.start, setting->block.string, sizeof(f_char_t) * length); + memcpy(main->setting.contents->array[main->setting.contents->used].string + range.start, main->setting.block.string, sizeof(f_char_t) * length); - setting->contents->array[setting->contents->used].used += length; + main->setting.contents->array[main->setting.contents->used].used += length; } // Designate to read next block from pipe. @@ -335,142 +335,142 @@ extern "C" { range.stop = 0; // Reset all of the used data for next set. - setting->object->used = 0; - setting->contents->used = 0; - setting->ignores->used = 0; + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; } } // for // If the pipe ended before finishing, then attempt to wrap up. - if (F_status_is_error_not(setting->state.status) && status_pipe == F_none_eof && state) { - fss_write_payload_process_set(main, void_setting); + if (F_status_is_error_not(main->setting.state.status) && status_pipe == F_none_eof && state) { + fss_write_payload_process_set(void_main); flag |= 0x1; } - setting->block.used = 0; - setting->buffer.used = 0; - setting->object->used = 0; - setting->contents->used = 0; - setting->ignores->used = 0; - setting->objects.used = used_objects; - setting->contentss.used = used_contentss; - setting->ignoress.used = used_ignoress; + 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.objects.used = used_objects; + main->setting.contentss.used = used_contentss; + main->setting.ignoress.used = used_ignoress; - if (F_status_is_error_not(setting->state.status)) { + if (F_status_is_error_not(main->setting.state.status)) { if (flag & 0x1) { if (flag & 0x8) { - setting->state.status = F_payload; + main->setting.state.status = F_payload; } else { - setting->state.status = F_none; + main->setting.state.status = F_none; } } else { - setting->state.status = F_data_not; + main->setting.state.status = F_data_not; } // Payload. - if (setting->contentss.used && (flag & 0x8)) { - fll_print_dynamic(f_fss_payload_header_close_s, main->output.to); + if (main->setting.contentss.used && (flag & 0x8)) { + fll_print_dynamic(f_fss_payload_header_close_s, main->program.output.to); } } } #endif // _di_fss_write_payload_process_pipe_ #ifndef _di_fss_write_payload_process_set_ - void fss_write_payload_process_set(fll_program_data_t * const main, void * const void_setting) { + void fss_write_payload_process_set(void * const void_main) { - if (!main || !void_setting) return; + if (!void_main) return; - fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); + fss_write_main_t * const main = (fss_write_main_t *) void_main; - if ((!(setting->flag & fss_write_main_flag_partial_e) || (setting->flag & fss_write_main_flag_partial_e) && (setting->flag & fss_write_main_flag_object_e))) { - if (setting->object && !(setting->flag & fss_write_main_flag_partial_e) && setting->contents && setting->contents->used) { - if (setting->object->used) { - setting->range.start = 0; - setting->range.stop = setting->object->used - 1; + if ((!(main->setting.flag & fss_write_main_flag_partial_e) || (main->setting.flag & fss_write_main_flag_partial_e) && (main->setting.flag & fss_write_main_flag_object_e))) { + if (main->setting.object && !(main->setting.flag & fss_write_main_flag_partial_e) && main->setting.contents && main->setting.contents->used) { + if (main->setting.object->used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.object->used - 1; } else { - setting->range.start = 1; - setting->range.stop = 0; + main->setting.range.start = 1; + main->setting.range.stop = 0; } fll_fss_payload_write( - *setting->object, - setting->contents->array[0], - (setting->flag & fss_write_main_flag_trim_e), - (setting->flag & fss_write_main_flag_prepend_e) - ? &setting->prepend + *main->setting.object, + main->setting.contents->array[0], + (main->setting.flag & fss_write_main_flag_trim_e), + (main->setting.flag & fss_write_main_flag_prepend_e) + ? &main->setting.prepend : 0, - &setting->buffer, - &setting->state + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fll_fss_payload_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fll_fss_payload_write)); return; } } else { - if (setting->object) { - if (setting->object->used) { - setting->range.start = 0; - setting->range.stop = setting->object->used - 1; + if (main->setting.object) { + if (main->setting.object->used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.object->used - 1; } else { - setting->range.start = 1; - setting->range.stop = 0; + main->setting.range.start = 1; + main->setting.range.stop = 0; } fl_fss_basic_list_object_write( - *setting->object, - (setting->flag & fss_write_main_flag_partial_e) - ? (setting->flag & fss_write_main_flag_trim_e) + *main->setting.object, + (main->setting.flag & fss_write_main_flag_partial_e) + ? (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_trim_e : f_fss_complete_none_e - : (setting->flag & fss_write_main_flag_trim_e) + : (main->setting.flag & fss_write_main_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_set_fine(setting->state.status) == F_none_eol) { - setting->state.status = F_status_set_error(F_support_not); + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); - fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_error_unsupported_eol(&main->program.error); return; } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_basic_list_object_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_content_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_object_open_e) { - setting->state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_content_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &main->setting.buffer); - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &setting->buffer); + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &main->setting.buffer); } - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); return; } @@ -479,42 +479,42 @@ extern "C" { } } else { - if (setting->contents && setting->contents->used && setting->contents->array[0].used) { - setting->range.start = 0; - setting->range.stop = setting->contents->array[0].used - 1; + if (main->setting.contents && main->setting.contents->used && main->setting.contents->array[0].used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.contents->array[0].used - 1; const f_string_static_t *prepend = 0; - if (setting->flag & fss_write_main_flag_prepend_e) { - const f_array_length_t index = main->parameters.array[fss_write_parameter_prepend_e].values.array[main->parameters.array[fss_write_parameter_prepend_e].values.used - 1]; + if (main->setting.flag & fss_write_main_flag_prepend_e) { + const f_array_length_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].values.used - 1]; - prepend = &main->parameters.arguments.array[index]; + prepend = &main->program.parameters.arguments.array[index]; } fl_fss_basic_list_content_write( - setting->contents->array[0], - setting->object + main->setting.contents->array[0], + main->setting.object ? f_fss_complete_full_e : f_fss_complete_none_e, prepend, - &setting->range, - &setting->buffer, - &setting->state + &main->setting.range, + &main->setting.buffer, + &main->setting.state ); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_payload_content_write)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(fl_fss_payload_content_write)); return; } } - if ((setting->flag & fss_write_main_flag_partial_e) && !(setting->flag & fss_write_main_flag_object_e) || !(setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { - if (setting->flag & fss_write_main_flag_content_end_e) { - setting->state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &setting->buffer); + if ((main->setting.flag & fss_write_main_flag_partial_e) && !(main->setting.flag & fss_write_main_flag_object_e) || !(main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e))) { + if (main->setting.flag & fss_write_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); return; } @@ -522,39 +522,39 @@ extern "C" { } } - if (!setting->object || !(setting->contents && setting->contents->used)) { - setting->state.status = f_string_dynamic_append(f_string_eol_s, &setting->buffer); + if (!main->setting.object || !(main->setting.contents && main->setting.contents->used)) { + main->setting.state.status = f_string_dynamic_append(f_string_eol_s, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + if (F_status_is_error(main->setting.state.status)) { + fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_dynamic_append)); return; } } - fll_print_dynamic(setting->buffer, main->output.to); + fll_print_dynamic(main->setting.buffer, main->program.output.to); - setting->buffer.used = 0; - setting->state.status = F_none; + main->setting.buffer.used = 0; + main->setting.state.status = F_none; } #endif // _di_fss_write_payload_process_set_ #ifndef _di_fss_write_payload_setting_load_ - void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting) { + void fss_write_payload_setting_load(const f_console_arguments_t arguments, fss_write_main_t * const main) { - if (!main || !setting) return; + if (!main) return; - f_array_lengths_t * const values = &main->parameters.array[fss_write_parameter_object_e].values; - f_string_static_t * const argv = main->parameters.arguments.array; + f_array_lengths_t * const values = &main->program.parameters.array[fss_write_parameter_object_e].values; + f_string_static_t * const argv = main->program.parameters.arguments.array; - if ((main->parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && values->used) { + if ((main->program.parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && values->used) { for (f_array_length_t i = 0; i < values->used; ++i) { if (fl_string_dynamic_compare(argv[values->array[i]], fss_write_payload_s) == F_equal_to && i + 1 < values->used) { - setting->state.status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - fss_write_payload_print_error_payload_not_last(setting, main->error); + fss_write_payload_print_error_payload_not_last(&main->program.error); return; } diff --git a/level_3/fss_write/c/payload/fss_write.h b/level_3/fss_write/c/payload/fss_write.h index 7882c34..a2da5db 100644 --- a/level_3/fss_write/c/payload/fss_write.h +++ b/level_3/fss_write/c/payload/fss_write.h @@ -44,12 +44,15 @@ #include // FSS Write includes. -#include -#include -#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include #include #ifdef __cplusplus @@ -60,31 +63,27 @@ extern "C" { * Process help for FSS-000E (Payload). * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This does not alter setting.state.status. + * This does not alter main.setting.state.status. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ #ifndef _di_fss_write_payload_process_help_ - extern void fss_write_payload_process_help(fll_program_data_t * const main, void * const setting); + extern void fss_write_payload_process_help(void * const main); #endif // _di_fss_write_payload_process_help_ /** * Process the pipe, reading from the pipe and writing to the output. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.state.status: + * This alters main.setting.state.status: * F_none on success. * F_data_not on success but pipe contained no relevant data. * F_payload on success and the payload has been printed. @@ -93,26 +92,24 @@ extern "C" { * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_fss_write_payload_process_pipe_ - extern void fss_write_payload_process_pipe(fll_program_data_t * const main, void * const setting); + extern void fss_write_payload_process_pipe(void * const main); #endif // _di_fss_write_payload_process_pipe_ /** * Process a given object and content, printing the FSS if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. - * Must be of type (fss_write_setting_t *). + * The program and settings data. + * Must be of type fss_write_main_t. * - * This alters setting.state.status: + * This alters main.setting.state.status: * F_none on success. * F_interrupt on (exit) signal received. * * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_fss_write_payload_process_set_ - extern void fss_write_payload_process_set(fll_program_data_t * const main, void * const setting); + extern void fss_write_payload_process_set(void * const main); #endif // _di_fss_write_payload_process_set_ /** @@ -145,7 +142,7 @@ extern "C" { * @see fss_write_setting_load() */ #ifndef _di_fss_write_payload_setting_load_ - extern void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting); + extern void fss_write_payload_setting_load(const f_console_arguments_t arguments, fss_write_main_t * const main); #endif // _di_fss_write_payload_setting_load_ #ifdef __cplusplus diff --git a/level_3/fss_write/c/payload/main.c b/level_3/fss_write/c/payload/main.c index 0adfd64..06c96b5 100644 --- a/level_3/fss_write/c/payload/main.c +++ b/level_3/fss_write/c/payload/main.c @@ -15,40 +15,40 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.warning.custom = (void *) &data; data.program.debug.custom = (void *) &data; - setting.state.custom = (void *) &data; - setting.standard = fss_write_payload_standard_s; - setting.process_content = 0; // Not used by payload. - setting.process_help = &fss_write_payload_process_help; - setting.process_normal = &fss_write_process_normal; - setting.process_object = 0; // Not used by payload. - setting.process_pipe = &fss_write_payload_process_pipe; - setting.process_set = &fss_write_payload_process_set; + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_write_payload_standard_s; + data.setting.process_content = 0; // Not used by payload. + data.setting.process_help = &fss_write_payload_process_help; + data.setting.process_normal = &fss_write_process_normal; + data.setting.process_object = 0; // Not used by payload. + data.setting.process_pipe = &fss_write_payload_process_pipe; + data.setting.process_set = &fss_write_payload_process_set; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; - data.parameters.used = fss_write_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_write_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - fss_write_setting_load(arguments, &data, &setting, &fss_write_payload_setting_load); + fss_write_setting_load(arguments, &data, &fss_write_payload_setting_load); } - fss_write_main(&data, &setting); + fss_write_main(&data); - fss_write_setting_unload(&data, &setting); + fss_write_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/fss_write/c/payload/print.c b/level_3/fss_write/c/payload/print.c index e4dddb2..a8312c7 100644 --- a/level_3/fss_write/c/payload/print.c +++ b/level_3/fss_write/c/payload/print.c @@ -5,47 +5,48 @@ extern "C" { #endif #ifndef _di_fss_write_payload_print_error_payload_not_last_ - f_status_t fss_write_payload_print_error_payload_not_last(fss_write_setting_t * const setting, const fl_print_t print) { + f_status_t fss_write_payload_print_error_payload_not_last(fl_print_t * const print) { - if (!setting || print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + if (!print) return F_status_set_error(F_output_not); + if (!print || print->verbosity == f_console_verbosity_quiet_e) return F_output_not; - f_file_stream_lock(print.to); + f_file_stream_lock(print->to); - fl_print_format("%r%[%QThe payload may only be specified last.%]%r", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error, f_string_eol_s); + fl_print_format("%r%[%QThe payload may only be specified last.%]%r", print->to, f_string_eol_s, print->set->error, print->prefix, print->set->error, f_string_eol_s); - f_file_stream_unlock(print.to); + f_file_stream_unlock(print->to); return F_none; } #endif // _di_fss_write_payload_print_error_payload_not_last_ #ifndef _di_fss_write_payload_print_help_ - f_status_t fss_write_payload_print_help(fss_write_setting_t * const setting, const fl_print_t print) { + f_status_t fss_write_payload_print_help(fl_print_t * const print) { - if (!setting) return F_status_set_error(F_output_not); + if (!print) return F_status_set_error(F_output_not); - f_file_stream_lock(print.to); + f_file_stream_lock(print->to); fll_program_print_help_header(print, fss_write_payload_program_name_long_s, fss_write_program_version_s); - fss_write_print_help(setting, print); + fss_write_print_message_help(print); - f_print_dynamic_raw(f_string_eol_s, print.to); + f_print_dynamic_raw(f_string_eol_s, print->to); fll_program_print_help_usage(print, fss_write_payload_program_name_s, f_string_empty_s); - fss_write_print_help_pipe(setting, print); + fss_write_print_message_help_pipe(print); - fss_write_print_help_end_next(setting, print); + fss_write_print_message_help_end_next(print); - fl_print_format("%r The FSS-000E (Payload) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, f_string_eol_s, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print.set->notable); - fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print.set->notable, f_string_eol_s, f_string_eol_s); + fl_print_format("%r The FSS-000E (Payload) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_single_s, print->set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print.set->notable, f_string_eol_s); - fl_print_format(" This parameter requires two values.%r", print.to, f_string_eol_s); + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_write_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); return F_none; } diff --git a/level_3/fss_write/c/payload/print.h b/level_3/fss_write/c/payload/print.h index 1d00341..b919613 100644 --- a/level_3/fss_write/c/payload/print.h +++ b/level_3/fss_write/c/payload/print.h @@ -15,33 +15,31 @@ extern "C" { /** * Print error message about the "payload" not being specified last (when it is specified at all). * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print - * Designates the how and where to print. + * The output structure to print to. + * + * 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() */ #ifndef _di_fss_write_payload_print_error_payload_not_last_ - extern f_status_t fss_write_payload_print_error_payload_not_last(fss_write_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_write_payload_print_error_payload_not_last(fl_print_t * const print); #endif // _di_fss_write_payload_print_error_payload_not_last_ /** * Print help for FSS-000E (Payload). * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. * @param print * The output structure to print to. * + * This does not alter print.custom.setting.state.status. + * * @return * F_none on success. * F_output_not on success, but no printing is performed. @@ -49,7 +47,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_fss_write_payload_print_help_ - extern f_status_t fss_write_payload_print_help(fss_write_setting_t * const setting, const fl_print_t print); + extern f_status_t fss_write_payload_print_help(fl_print_t * const print); #endif // _di_fss_write_payload_print_help_ #ifdef __cplusplus diff --git a/level_3/fss_write/data/build/settings b/level_3/fss_write/data/build/settings index f7e0c75..4a5bd26 100644 --- a/level_3/fss_write/data/build/settings +++ b/level_3/fss_write/data/build/settings @@ -25,7 +25,7 @@ build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_pr build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library main/fss_write.c main/common.c main/common-print.c main/common-string.c main/common-type.c main/print.c +build_sources_library main/fss_write.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 build_sources_library basic/fss_write.c basic/common.c basic/print.c build_sources_library basic_list/fss_write.c basic_list/common.c basic_list/print.c build_sources_library embedded_list/fss_write.c embedded_list/common.c embedded_list/print.c @@ -33,7 +33,7 @@ build_sources_library extended/fss_write.c extended/common.c extended/print.c build_sources_library extended_list/fss_write.c extended_list/common.c extended_list/print.c build_sources_library payload/fss_write.c payload/common.c payload/print.c -build_sources_headers main/fss_write.h main/common.h main/common-print.h main/common-string.h main/common-type.h main/print.h main/private-common.h +build_sources_headers main/fss_write.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 build_sources_headers basic/fss_write.h basic/common.h basic/print.h basic/private-common.h build_sources_headers basic_list/fss_write.h basic_list/common.h basic_list/print.h build_sources_headers embedded_list/fss_write.h embedded_list/common.h embedded_list/print.h diff --git a/level_3/fss_write/data/build/settings.main b/level_3/fss_write/data/build/settings.main index e2309db..72d0c10 100644 --- a/level_3/fss_write/data/build/settings.main +++ b/level_3/fss_write/data/build/settings.main @@ -26,7 +26,7 @@ build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_pr build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_program main/main.c main/main-print.c +build_sources_program main/main.c main/main/print.c build_sources_documentation man diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index 89a0245..ec40eca 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -25,37 +25,37 @@ extern "C" { #endif // _di_iki_read_setting_delete_ #ifndef _di_iki_read_setting_load_ - void iki_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_read_setting_t * const setting) { + void iki_read_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = iki_read_allocation_console_d; + main->setting.state.step_small = iki_read_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = iki_read_allocation_small_d; + main->setting.state.step_small = iki_read_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[iki_read_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & iki_read_main_flag_print_first_e; + if (main->program.parameters.array[iki_read_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & iki_read_main_flag_print_first_e; } else { - setting->flag |= iki_read_main_flag_print_first_e; + main->setting.flag |= iki_read_main_flag_print_first_e; } - if (main->parameters.array[iki_read_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & iki_read_main_flag_print_last_e; + if (main->program.parameters.array[iki_read_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & iki_read_main_flag_print_last_e; } else { - setting->flag |= iki_read_main_flag_print_last_e; + main->setting.flag |= iki_read_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_console_parameter_process)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_console_parameter_process)); return; } @@ -71,14 +71,14 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(fll_program_parameter_process_context)); + iki_read_print_error(&main->program.error, macro_iki_read_f(fll_program_parameter_process_context)); return; } @@ -92,139 +92,139 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(fll_program_parameter_process_verbosity)); + iki_read_print_error(&main->program.error, macro_iki_read_f(fll_program_parameter_process_verbosity)); return; } } - if (main->parameters.array[iki_read_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= iki_read_main_flag_help_e; + if (main->program.parameters.array[iki_read_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= iki_read_main_flag_help_e; return; } - if (main->parameters.array[iki_read_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= iki_read_main_flag_version_e; + if (main->program.parameters.array[iki_read_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= iki_read_main_flag_version_e; return; } - if (main->parameters.array[iki_read_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= iki_read_main_flag_copyright_e; + if (main->program.parameters.array[iki_read_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= iki_read_main_flag_copyright_e; return; } } - if (!(main->parameters.remaining.used || (main->pipe & fll_program_data_pipe_input_e))) { - setting->state.status = F_status_set_error(F_parameter); + if (!(main->program.parameters.remaining.used || (main->program.pipe & fll_program_data_pipe_input_e))) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_missing_file(&main->error); + fll_program_print_error_missing_file(&main->program.error); return; } - if (main->parameters.array[iki_read_parameter_at_e].result & f_console_result_value_e) { - if (main->parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[iki_read_parameter_at_e].result & f_console_result_value_e) { + if (main->program.parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_cannot_use_with(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_at_s, iki_read_long_whole_s); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_at_s, iki_read_long_whole_s); return; } - const f_array_length_t index = main->parameters.array[iki_read_parameter_at_e].values.array[main->parameters.array[iki_read_parameter_at_e].values.used - 1]; + const f_array_length_t index = main->program.parameters.array[iki_read_parameter_at_e].values.array[main->program.parameters.array[iki_read_parameter_at_e].values.used - 1]; - setting->at = 0; + main->setting.at = 0; - setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->at); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.at); - if (F_status_is_error(setting->state.status)) { - setting->state.status = F_status_set_error(F_parameter); + if (F_status_is_error(main->setting.state.status)) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_integer_not(&main->error, f_console_symbol_long_normal_s, iki_read_long_at_s, main->parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_at_s, main->program.parameters.arguments.array[index]); return; } - setting->flag |= iki_read_main_flag_at_e; + main->setting.flag |= iki_read_main_flag_at_e; } - else if (main->parameters.array[iki_read_parameter_at_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[iki_read_parameter_at_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, iki_read_long_at_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_at_s); return; } - if (main->parameters.array[iki_read_parameter_line_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[iki_read_parameter_line_e].values.array[main->parameters.array[iki_read_parameter_line_e].values.used - 1]; + if (main->program.parameters.array[iki_read_parameter_line_e].result & f_console_result_value_e) { + const f_array_length_t index = main->program.parameters.array[iki_read_parameter_line_e].values.array[main->program.parameters.array[iki_read_parameter_line_e].values.used - 1]; - setting->line = 0; + main->setting.line = 0; - setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->line); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.line); - if (F_status_is_error(setting->state.status)) { - setting->state.status = F_status_set_error(F_parameter); + if (F_status_is_error(main->setting.state.status)) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_integer_not(&main->error, f_console_symbol_long_normal_s, iki_read_long_line_s, main->parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_line_s, main->program.parameters.arguments.array[index]); return; } - setting->flag |= iki_read_main_flag_line_e; + main->setting.flag |= iki_read_main_flag_line_e; } - else if (main->parameters.array[iki_read_parameter_line_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[iki_read_parameter_line_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, iki_read_long_line_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_line_s); return; } - if (main->parameters.array[iki_read_parameter_name_e].result & f_console_result_value_e) { - setting->names.used = 0; + if (main->program.parameters.array[iki_read_parameter_name_e].result & f_console_result_value_e) { + main->setting.names.used = 0; - setting->state.status = f_string_dynamics_increase_by(main->parameters.array[iki_read_parameter_name_e].values.used, &setting->names); + main->setting.state.status = f_string_dynamics_increase_by(main->program.parameters.array[iki_read_parameter_name_e].values.used, &main->setting.names); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_increase_by)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_dynamics_increase_by)); return; } @@ -232,75 +232,75 @@ extern "C" { // Distinctly append all names. f_array_length_t i = 0; f_array_length_t j = 0; - f_array_lengths_t *values = &main->parameters.array[iki_read_parameter_name_e].values; + f_array_lengths_t *values = &main->program.parameters.array[iki_read_parameter_name_e].values; for (; i < values->used; ++i) { - for (j = 0; j < setting->names.used; ++j) { - if (fl_string_dynamic_compare(main->parameters.arguments.array[values->array[i]], setting->names.array[j]) == F_equal_to) break; + for (j = 0; j < main->setting.names.used; ++j) { + if (fl_string_dynamic_compare(main->program.parameters.arguments.array[values->array[i]], main->setting.names.array[j]) == F_equal_to) break; } // for - if (j < setting->names.used) continue; + if (j < main->setting.names.used) continue; - setting->names.array[setting->names.used].used = 0; + main->setting.names.array[main->setting.names.used].used = 0; - if (main->parameters.arguments.array[values->array[i]].used) { - setting->state.status = f_string_dynamics_append(main->parameters.arguments.array[values->array[i]], &setting->names); - if (F_status_is_error(setting->state.status)) break; + if (main->program.parameters.arguments.array[values->array[i]].used) { + main->setting.state.status = f_string_dynamics_append(main->program.parameters.arguments.array[values->array[i]], &main->setting.names); + if (F_status_is_error(main->setting.state.status)) break; } else { - setting->state.status = f_string_dynamics_append(f_string_empty_s, &setting->names); - if (F_status_is_error(setting->state.status)) break; + main->setting.state.status = f_string_dynamics_append(f_string_empty_s, &main->setting.names); + if (F_status_is_error(main->setting.state.status)) break; } } // for - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_append)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_dynamics_append)); return; } - setting->flag |= iki_read_main_flag_name_e; + main->setting.flag |= iki_read_main_flag_name_e; } - else if (main->parameters.array[iki_read_parameter_name_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[iki_read_parameter_name_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, iki_read_long_name_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_name_s); return; } - if (main->parameters.array[iki_read_parameter_replace_e].result != f_console_result_none_e) { - if ((main->parameters.array[iki_read_parameter_replace_e].result & f_console_result_found_e) || main->parameters.array[iki_read_parameter_replace_e].values.used % 2 != 0) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[iki_read_parameter_replace_e].result != f_console_result_none_e) { + if ((main->program.parameters.array[iki_read_parameter_replace_e].result & f_console_result_found_e) || main->program.parameters.array[iki_read_parameter_replace_e].values.used % 2 != 0) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_missing_value_requires_amount(&main->error, f_console_symbol_long_normal_s, iki_read_long_replace_s, iki_read_string_two_s); + fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_replace_s, iki_read_string_two_s); return; } - setting->replace.used = 0; + main->setting.replace.used = 0; - setting->state.status = f_string_maps_increase_by(main->parameters.array[iki_read_parameter_replace_e].values.used / 2, &setting->replace); + main->setting.state.status = f_string_maps_increase_by(main->program.parameters.array[iki_read_parameter_replace_e].values.used / 2, &main->setting.replace); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_maps_increase_by)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_maps_increase_by)); return; } @@ -310,14 +310,14 @@ extern "C" { f_array_length_t i = 0; f_array_length_t j = 0; - for (; i < main->parameters.array[iki_read_parameter_replace_e].values.used; ++i) { + for (; i < main->program.parameters.array[iki_read_parameter_replace_e].values.used; ++i) { - index = main->parameters.array[iki_read_parameter_replace_e].values.array[i]; + index = main->program.parameters.array[iki_read_parameter_replace_e].values.array[i]; // Replace any existing value so that each name exists only once. - for (j = 0; j < setting->replace.used; ++j) { + for (j = 0; j < main->setting.replace.used; ++j) { - if (fl_string_dynamic_compare(main->parameters.arguments.array[index], setting->replace.array[j].name) == F_equal_to) { + if (fl_string_dynamic_compare(main->program.parameters.arguments.array[index], main->setting.replace.array[j].name) == F_equal_to) { break; } } // for @@ -325,77 +325,77 @@ extern "C" { at = j; // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. - if (setting->replace.array[at].name.size) { - setting->state.status = f_string_dynamic_resize(0, &setting->replace.array[at].name); + if (main->setting.replace.array[at].name.size) { + main->setting.state.status = f_string_dynamic_resize(0, &main->setting.replace.array[at].name); } - if (F_status_is_error_not(setting->state.status) && setting->replace.array[at].value.size) { - setting->state.status = f_string_dynamic_resize(0, &setting->replace.array[at].value); + if (F_status_is_error_not(main->setting.state.status) && main->setting.replace.array[at].value.size) { + main->setting.state.status = f_string_dynamic_resize(0, &main->setting.replace.array[at].value); } - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_dynamic_resize)); return; } - setting->replace.array[at].name.string = main->parameters.arguments.array[index].string; - setting->replace.array[at].name.used = main->parameters.arguments.array[index].used; - setting->replace.array[at].name.size = 0; + main->setting.replace.array[at].name.string = main->program.parameters.arguments.array[index].string; + main->setting.replace.array[at].name.used = main->program.parameters.arguments.array[index].used; + main->setting.replace.array[at].name.size = 0; - index = main->parameters.array[iki_read_parameter_replace_e].values.array[++i]; + index = main->program.parameters.array[iki_read_parameter_replace_e].values.array[++i]; - setting->replace.array[at].value.string = main->parameters.arguments.array[index].string; - setting->replace.array[at].value.used = main->parameters.arguments.array[index].used; - setting->replace.array[at].value.size = 0; + main->setting.replace.array[at].value.string = main->program.parameters.arguments.array[index].string; + main->setting.replace.array[at].value.used = main->program.parameters.arguments.array[index].used; + main->setting.replace.array[at].value.size = 0; - if (at == setting->replace.used) { - ++setting->replace.used; + if (at == main->setting.replace.used) { + ++main->setting.replace.used; } } // for - setting->flag |= iki_read_main_flag_replace_e; + main->setting.flag |= iki_read_main_flag_replace_e; } - if (iki_read_setting_load_parameter_substitution(main, setting, main->parameters.array[iki_read_parameter_reassign_e], iki_read_long_reassign_s, &setting->reassign)) { - setting->flag |= iki_read_main_flag_reassign_e; + if (iki_read_setting_load_parameter_substitution(main, main->program.parameters.array[iki_read_parameter_reassign_e], iki_read_long_reassign_s, &main->setting.reassign)) { + main->setting.flag |= iki_read_main_flag_reassign_e; } - if (F_status_is_error(setting->state.status)) return; + if (F_status_is_error(main->setting.state.status)) return; - if (iki_read_setting_load_parameter_substitution(main, setting, main->parameters.array[iki_read_parameter_substitute_e], iki_read_long_substitute_s, &setting->substitute)) { - setting->flag |= iki_read_main_flag_substitute_e; + if (iki_read_setting_load_parameter_substitution(main, main->program.parameters.array[iki_read_parameter_substitute_e], iki_read_long_substitute_s, &main->setting.substitute)) { + main->setting.flag |= iki_read_main_flag_substitute_e; } - if (F_status_is_error(setting->state.status)) return; + if (F_status_is_error(main->setting.state.status)) return; - if (main->parameters.array[iki_read_parameter_wrap_e].result != f_console_result_none_e) { - if ((main->parameters.array[iki_read_parameter_wrap_e].result & f_console_result_found_e) || main->parameters.array[iki_read_parameter_wrap_e].values.used % 3 != 0) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[iki_read_parameter_wrap_e].result != f_console_result_none_e) { + if ((main->program.parameters.array[iki_read_parameter_wrap_e].result & f_console_result_found_e) || main->program.parameters.array[iki_read_parameter_wrap_e].values.used % 3 != 0) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_missing_value_requires_amount(&main->error, f_console_symbol_long_normal_s, iki_read_long_wrap_s, iki_read_string_three_s); + fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_wrap_s, iki_read_string_three_s); return; } - setting->wrap.used = 0; + main->setting.wrap.used = 0; - setting->state.status = f_string_triples_increase_by(main->parameters.array[iki_read_parameter_wrap_e].values.used / 3, &setting->wrap); + main->setting.state.status = f_string_triples_increase_by(main->program.parameters.array[iki_read_parameter_wrap_e].values.used / 3, &main->setting.wrap); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_triples_increase_by)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_triples_increase_by)); return; } @@ -405,14 +405,14 @@ extern "C" { f_array_length_t i = 0; f_array_length_t j = 0; - for (; i < main->parameters.array[iki_read_parameter_wrap_e].values.used; ++i) { + for (; i < main->program.parameters.array[iki_read_parameter_wrap_e].values.used; ++i) { - index = main->parameters.array[iki_read_parameter_wrap_e].values.array[i]; + index = main->program.parameters.array[iki_read_parameter_wrap_e].values.array[i]; // Replace any existing values so that each name exists only once. - for (j = 0; j < setting->wrap.used; ++j) { + for (j = 0; j < main->setting.wrap.used; ++j) { - if (fl_string_dynamic_compare(main->parameters.arguments.array[index], setting->wrap.array[j].a) == F_equal_to) { + if (fl_string_dynamic_compare(main->program.parameters.arguments.array[index], main->setting.wrap.array[j].a) == F_equal_to) { break; } } // for @@ -420,53 +420,53 @@ extern "C" { at = j; // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. - if (setting->wrap.array[at].a.size) { - setting->state.status = f_string_dynamic_resize(0, &setting->wrap.array[at].a); + if (main->setting.wrap.array[at].a.size) { + main->setting.state.status = f_string_dynamic_resize(0, &main->setting.wrap.array[at].a); } - if (F_status_is_error_not(setting->state.status) && setting->wrap.array[at].b.size) { - setting->state.status = f_string_dynamic_resize(0, &setting->wrap.array[at].b); + if (F_status_is_error_not(main->setting.state.status) && main->setting.wrap.array[at].b.size) { + main->setting.state.status = f_string_dynamic_resize(0, &main->setting.wrap.array[at].b); } - if (F_status_is_error_not(setting->state.status) && setting->wrap.array[at].c.size) { - setting->state.status = f_string_dynamic_resize(0, &setting->wrap.array[at].c); + if (F_status_is_error_not(main->setting.state.status) && main->setting.wrap.array[at].c.size) { + main->setting.state.status = f_string_dynamic_resize(0, &main->setting.wrap.array[at].c); } - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_dynamic_resize)); return; } - setting->wrap.array[at].a.string = main->parameters.arguments.array[index].string; - setting->wrap.array[at].a.used = main->parameters.arguments.array[index].used; - setting->wrap.array[at].a.size = 0; + main->setting.wrap.array[at].a.string = main->program.parameters.arguments.array[index].string; + main->setting.wrap.array[at].a.used = main->program.parameters.arguments.array[index].used; + main->setting.wrap.array[at].a.size = 0; - index = main->parameters.array[iki_read_parameter_wrap_e].values.array[++i]; + index = main->program.parameters.array[iki_read_parameter_wrap_e].values.array[++i]; - setting->wrap.array[at].b.string = main->parameters.arguments.array[index].string; - setting->wrap.array[at].b.used = main->parameters.arguments.array[index].used; - setting->wrap.array[at].b.size = 0; + main->setting.wrap.array[at].b.string = main->program.parameters.arguments.array[index].string; + main->setting.wrap.array[at].b.used = main->program.parameters.arguments.array[index].used; + main->setting.wrap.array[at].b.size = 0; - index = main->parameters.array[iki_read_parameter_wrap_e].values.array[++i]; + index = main->program.parameters.array[iki_read_parameter_wrap_e].values.array[++i]; - setting->wrap.array[at].c.string = main->parameters.arguments.array[index].string; - setting->wrap.array[at].c.used = main->parameters.arguments.array[index].used; - setting->wrap.array[at].c.size = 0; + main->setting.wrap.array[at].c.string = main->program.parameters.arguments.array[index].string; + main->setting.wrap.array[at].c.used = main->program.parameters.arguments.array[index].used; + main->setting.wrap.array[at].c.size = 0; - if (at == setting->wrap.used) { - ++setting->wrap.used; + if (at == main->setting.wrap.used) { + ++main->setting.wrap.used; } } // for - setting->flag |= iki_read_main_flag_wrap_e; + main->setting.flag |= iki_read_main_flag_wrap_e; } - if (main->parameters.array[iki_read_parameter_literal_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_read_parameter_literal_e].result & f_console_result_found_e) { const uint8_t ids[3] = { iki_read_parameter_object_e, iki_read_parameter_content_e, @@ -481,22 +481,22 @@ extern "C" { for (uint8_t i = 0; i < 3; ++i) { - if (main->parameters.array[ids[i]].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[ids[i]].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_cannot_use_with(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_literal_s, names[i]); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_literal_s, names[i]); return; } } // for - setting->flag |= iki_read_main_flag_literal_e; + main->setting.flag |= iki_read_main_flag_literal_e; } - else if (main->parameters.array[iki_read_parameter_object_e].result & f_console_result_found_e) { + else if (main->program.parameters.array[iki_read_parameter_object_e].result & f_console_result_found_e) { const uint8_t ids[2] = { iki_read_parameter_content_e, iki_read_parameter_total_e, @@ -509,109 +509,109 @@ extern "C" { for (uint8_t i = 0; i < 2; ++i) { - if (main->parameters.array[ids[i]].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[ids[i]].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_cannot_use_with(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_object_s, names[i]); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_object_s, names[i]); return; } } // for - setting->flag |= iki_read_main_flag_object_e; + main->setting.flag |= iki_read_main_flag_object_e; } - else if (main->parameters.array[iki_read_parameter_content_e].result & f_console_result_found_e) { - if (main->parameters.array[iki_read_parameter_total_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[iki_read_parameter_content_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_read_parameter_total_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_cannot_use_with(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_content_s, iki_read_long_total_s); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_content_s, iki_read_long_total_s); return; } - setting->flag |= iki_read_main_flag_content_e; + main->setting.flag |= iki_read_main_flag_content_e; } - else if (main->parameters.array[iki_read_parameter_total_e].result & f_console_result_found_e) { - if (main->parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[iki_read_parameter_total_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_cannot_use_with(&main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_total_s, iki_read_long_wrap_s); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_total_s, iki_read_long_wrap_s); return; } - setting->flag |= iki_read_main_flag_total_e; + main->setting.flag |= iki_read_main_flag_total_e; } else { // This is the default behavior. - setting->flag |= iki_read_main_flag_content_e; + main->setting.flag |= iki_read_main_flag_content_e; } - if (main->parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { - setting->flag |= iki_read_main_flag_whole_e; + if (main->program.parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { + main->setting.flag |= iki_read_main_flag_whole_e; } - if (main->parameters.remaining.used) { - setting->files.used = 0; + if (main->program.parameters.remaining.used) { + main->setting.files.used = 0; - setting->state.status = f_string_dynamics_resize(main->parameters.remaining.used, &setting->files); + main->setting.state.status = f_string_dynamics_resize(main->program.parameters.remaining.used, &main->setting.files); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_resize)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_dynamics_resize)); return; } f_array_length_t index = 0; - for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i, ++setting->files.used) { + for (f_array_length_t i = 0; i < main->program.parameters.remaining.used; ++i, ++main->setting.files.used) { // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. - if (setting->files.array[setting->files.used].size) { - setting->state.status = f_string_dynamic_resize(0, &setting->files.array[setting->files.used]); + if (main->setting.files.array[main->setting.files.used].size) { + main->setting.state.status = f_string_dynamic_resize(0, &main->setting.files.array[main->setting.files.used]); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_dynamic_resize)); return; } } - index = main->parameters.remaining.array[i]; + index = main->program.parameters.remaining.array[i]; - setting->files.array[setting->files.used].string = main->parameters.arguments.array[index].string; - setting->files.array[setting->files.used].used = main->parameters.arguments.array[index].used; - setting->files.array[setting->files.used].size = 0; + main->setting.files.array[main->setting.files.used].string = main->program.parameters.arguments.array[index].string; + main->setting.files.array[main->setting.files.used].used = main->program.parameters.arguments.array[index].used; + main->setting.files.array[main->setting.files.used].size = 0; - setting->state.status = f_file_exists(setting->files.array[setting->files.used], F_true); + main->setting.state.status = f_file_exists(main->setting.files.array[main->setting.files.used], F_true); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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_file_print(main->error, F_status_set_fine(setting->state.status), macro_iki_read_f(f_file_exists), fll_error_file_flag_fallback_e, setting->files.array[setting->files.used], f_file_operation_verify_s, fll_error_file_type_file_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_iki_read_f(f_file_exists), fll_error_file_flag_fallback_e, main->setting.files.array[main->setting.files.used], f_file_operation_verify_s, fll_error_file_type_file_e); return; } @@ -621,32 +621,32 @@ extern "C" { #endif // _di_iki_read_setting_load_ #ifndef _di_iki_read_setting_load_parameter_substitution_ - f_status_t iki_read_setting_load_parameter_substitution(fll_program_data_t * const main, iki_read_setting_t * const setting, const f_console_parameter_t parameter, const f_string_static_t name, f_string_triples_t *triple) { + f_status_t iki_read_setting_load_parameter_substitution(iki_read_main_t * const main, const f_console_parameter_t parameter, const f_string_static_t name, f_string_triples_t *triple) { if (!(parameter.result & f_console_result_found_e)) return F_false; if ((parameter.result & f_console_result_found_e) || parameter.values.used % 3 != 0) { - setting->state.status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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_program_print_error_parameter_missing_value_requires_amount(&main->error, f_console_symbol_long_normal_s, name, iki_read_string_three_s); + fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, name, iki_read_string_three_s); return F_false; } triple->used = 0; - setting->state.status = f_string_triples_increase_by(parameter.values.used / 3, triple); + main->setting.state.status = f_string_triples_increase_by(parameter.values.used / 3, triple); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_triples_increase_by)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_triples_increase_by)); return F_false; } @@ -663,8 +663,8 @@ extern "C" { // Replace any existing values so that each name and value pair exists only once. for (j = 0; j < triple->used; ++j) { - if (fl_string_dynamic_compare(main->parameters.arguments.array[index], triple->array[j].a) == F_equal_to) { - if (fl_string_dynamic_compare(main->parameters.arguments.array[parameter.values.array[i + 1]], triple->array[j].b) == F_equal_to) { + if (fl_string_dynamic_compare(main->program.parameters.arguments.array[index], triple->array[j].a) == F_equal_to) { + if (fl_string_dynamic_compare(main->program.parameters.arguments.array[parameter.values.array[i + 1]], triple->array[j].b) == F_equal_to) { break; } } @@ -674,41 +674,41 @@ extern "C" { // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. if (triple->array[at].a.size) { - setting->state.status = f_string_dynamic_resize(0, &triple->array[at].a); + main->setting.state.status = f_string_dynamic_resize(0, &triple->array[at].a); } - if (F_status_is_error_not(setting->state.status) && triple->array[at].b.size) { - setting->state.status = f_string_dynamic_resize(0, &triple->array[at].b); + if (F_status_is_error_not(main->setting.state.status) && triple->array[at].b.size) { + main->setting.state.status = f_string_dynamic_resize(0, &triple->array[at].b); } - if (F_status_is_error_not(setting->state.status) && triple->array[at].c.size) { - setting->state.status = f_string_dynamic_resize(0, &triple->array[at].c); + if (F_status_is_error_not(main->setting.state.status) && triple->array[at].c.size) { + main->setting.state.status = f_string_dynamic_resize(0, &triple->array[at].c); } - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_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); } - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_dynamic_resize)); return F_false; } - triple->array[at].a.string = main->parameters.arguments.array[index].string; - triple->array[at].a.used = main->parameters.arguments.array[index].used; + triple->array[at].a.string = main->program.parameters.arguments.array[index].string; + triple->array[at].a.used = main->program.parameters.arguments.array[index].used; triple->array[at].a.size = 0; index = parameter.values.array[++i]; - triple->array[at].b.string = main->parameters.arguments.array[index].string; - triple->array[at].b.used = main->parameters.arguments.array[index].used; + triple->array[at].b.string = main->program.parameters.arguments.array[index].string; + triple->array[at].b.used = main->program.parameters.arguments.array[index].used; triple->array[at].b.size = 0; index = parameter.values.array[++i]; - triple->array[at].c.string = main->parameters.arguments.array[index].string; - triple->array[at].c.used = main->parameters.arguments.array[index].used; + triple->array[at].c.string = main->program.parameters.arguments.array[index].string; + triple->array[at].c.used = main->program.parameters.arguments.array[index].used; triple->array[at].c.size = 0; if (at == triple->used) { diff --git a/level_3/iki_read/c/main/common.h b/level_3/iki_read/c/main/common.h index 75b31da..9386d8d 100644 --- a/level_3/iki_read/c/main/common.h +++ b/level_3/iki_read/c/main/common.h @@ -43,11 +43,9 @@ extern "C" { * @param arguments * The parameters passed to the process (often referred to as command line arguments). * @param main - * The main program data. - * @param setting - * The main program settings. + * The program and settings data. * - * This alters setting.state.status: + * This alters main.setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). @@ -69,7 +67,7 @@ extern "C" { * @see fll_program_parameter_process_verbosity() */ #ifndef _di_iki_read_setting_load_ - extern void iki_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_read_setting_t * const setting); + extern void iki_read_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main); #endif // _di_iki_read_setting_load_ /** @@ -78,11 +76,9 @@ extern "C" { * This prints error messages as appropriate. * * @param main - * The main program data. - * @param setting - * The main program settings. + * The program and settings data. * - * This alters setting.state.status: + * This alters main.setting.state.status: * F_none on success. * * Errors (with error bit) from: f_string_dynamic_resize(). @@ -101,14 +97,15 @@ extern "C" { * @see f_string_triples_resize() */ #ifndef _di_iki_read_setting_load_parameter_substitution_ - extern f_status_t iki_read_setting_load_parameter_substitution(fll_program_data_t * const main, iki_read_setting_t * const setting, const f_console_parameter_t parameter, const f_string_static_t name, f_string_triples_t *triple); + extern f_status_t iki_read_setting_load_parameter_substitution(iki_read_main_t * const main, const f_console_parameter_t parameter, const f_string_static_t name, f_string_triples_t *triple); #endif // _di_iki_read_setting_load_parameter_substitution_ /** * Perform the standard program setting unload process. * * @param main - * The main program and setting data. + * The program and settings data. + * * All buffers are deallocated. * * This does not alter main.setting.state.status. diff --git a/level_3/iki_read/c/main/common/define.h b/level_3/iki_read/c/main/common/define.h index a7c14eb..124e161 100644 --- a/level_3/iki_read/c/main/common/define.h +++ b/level_3/iki_read/c/main/common/define.h @@ -16,6 +16,27 @@ extern "C" { #endif +/** + * The program defines. + * + * iki_read_*: + * - allocation_console: An allocation step used for small buffers specifically for console parameter. + * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. + * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. + * - block_max: The max block read size before checking for interrupt. + * - block_read_small: The block read size for small files. + * - block_read_large: The block read size for large files. + * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. + */ +#ifndef _di_iki_read_d_ + #define iki_read_allocation_console_d 4 + #define iki_read_allocation_large_d 256 + #define iki_read_allocation_small_d 16 + #define iki_read_block_max 16777216 + #define iki_read_block_read_small 8192 + #define iki_read_block_read_large 65536 + #define iki_read_signal_check_d 20000 +#endif // _di_iki_read_d_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/iki_read/c/main/common/enumeration.h b/level_3/iki_read/c/main/common/enumeration.h index 4e2d0e4..0849e1f 100644 --- a/level_3/iki_read/c/main/common/enumeration.h +++ b/level_3/iki_read/c/main/common/enumeration.h @@ -17,6 +17,118 @@ extern "C" { #endif /** + * Flags passed to the main function or program. + * + * iki_read_main_flag_*_e: + * - none: No flags set. + * - at: Selecting at a specific index. + * - content: Print Contents. + * - copyright: Print copyright. + * - help: Print help. + * - literal: Print as literal data (printing entire variable). + * - line: Selecting at a specific line. + * - name: Selecting using a specific Vocabulary name. + * - object: Print Objects. + * - 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. + * - replace: Using re-assignments. + * - replace: Using replacements. + * - substitute: Using substitutions. + * - total: Enable printing of "total" count. + * - version: Print version. + * - whole: Print all data. + * - wrap: Using wrapping. + */ +#ifndef _di_iki_read_main_flag_e_ + enum { + iki_read_main_flag_none_e = 0x0, + iki_read_main_flag_at_e = 0x1, + iki_read_main_flag_content_e = 0x2, + iki_read_main_flag_copyright_e = 0x4, + iki_read_main_flag_help_e = 0x8, + iki_read_main_flag_literal_e = 0x10, + iki_read_main_flag_line_e = 0x20, + iki_read_main_flag_name_e = 0x40, + iki_read_main_flag_object_e = 0x80, + iki_read_main_flag_print_first_e = 0x100, + iki_read_main_flag_print_last_e = 0x200, + iki_read_main_flag_reassign_e = 0x400, + iki_read_main_flag_replace_e = 0x800, + iki_read_main_flag_substitute_e = 0x1000, + iki_read_main_flag_total_e = 0x2000, + iki_read_main_flag_version_e = 0x4000, + iki_read_main_flag_whole_e = 0x8000, + iki_read_main_flag_wrap_e = 0x10000, + }; // enum +#endif // _di_iki_read_main_flag_e_ + +/** + * The main program parameters. + */ +#ifndef _di_iki_read_parameter_e_ + enum { + iki_read_parameter_help_e, + iki_read_parameter_copyright_e, + iki_read_parameter_light_e, + iki_read_parameter_dark_e, + iki_read_parameter_no_color_e, + iki_read_parameter_verbosity_quiet_e, + iki_read_parameter_verbosity_error_e, + iki_read_parameter_verbosity_normal_e, + iki_read_parameter_verbosity_verbose_e, + iki_read_parameter_verbosity_debug_e, + iki_read_parameter_version_e, + iki_read_parameter_line_first_no_e, + iki_read_parameter_line_last_no_e, + + iki_read_parameter_at_e, + iki_read_parameter_content_e, + iki_read_parameter_line_e, + iki_read_parameter_literal_e, + iki_read_parameter_name_e, + iki_read_parameter_object_e, + iki_read_parameter_reassign_e, + iki_read_parameter_replace_e, + iki_read_parameter_substitute_e, + iki_read_parameter_total_e, + iki_read_parameter_whole_e, + iki_read_parameter_wrap_e, + }; // enum + + #define iki_read_console_parameter_t_initialize \ + { \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_error_s, f_console_standard_long_error_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_normal_s, f_console_standard_long_normal_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_first_no_s, f_console_standard_long_line_first_no_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_last_no_s, f_console_standard_long_line_last_no_s, 0, f_console_flag_inverse_e), \ + \ + macro_f_console_parameter_t_initialize_3(iki_read_short_at_s, iki_read_long_at_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_content_s, iki_read_long_content_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_line_s, iki_read_long_line_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_literal_s, iki_read_long_literal_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_name_s, iki_read_long_name_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_object_s, iki_read_long_object_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_reassign_s, iki_read_long_reassign_s, 3, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_replace_s, iki_read_long_replace_s, 2, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_substitute_s, iki_read_long_substitute_s, 3, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_total_s, iki_read_long_total_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_whole_s, iki_read_long_whole_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_read_short_wrap_s, iki_read_long_wrap_s, 3, f_console_flag_normal_e), \ + } + + #define iki_read_total_parameters_d 25 +#endif // _di_iki_read_parameter_e_ + +/** * Flags for fine-tuned print control. * * iki_read_print_flag_*_e: diff --git a/level_3/iki_read/c/main/common/type.h b/level_3/iki_read/c/main/common/type.h index 7e439c4..2764820 100644 --- a/level_3/iki_read/c/main/common/type.h +++ b/level_3/iki_read/c/main/common/type.h @@ -17,140 +17,6 @@ extern "C" { #endif /** - * The program defines. - * - * iki_read_*: - * - allocation_console: An allocation step used for small buffers specifically for console parameter. - * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. - * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. - * - block_max: The max block read size before checking for interrupt. - * - block_read_small: The block read size for small files. - * - block_read_large: The block read size for large files. - * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. - */ -#ifndef _di_iki_read_d_ - #define iki_read_allocation_console_d 4 - #define iki_read_allocation_large_d 256 - #define iki_read_allocation_small_d 16 - #define iki_read_block_max 16777216 - #define iki_read_block_read_small 8192 - #define iki_read_block_read_large 65536 - #define iki_read_signal_check_d 20000 -#endif // _di_iki_read_d_ - -/** - * Flags passed to the main function or program. - * - * iki_read_main_flag_*_e: - * - none: No flags set. - * - at: Selecting at a specific index. - * - content: Print Contents. - * - copyright: Print copyright. - * - help: Print help. - * - literal: Print as literal data (printing entire variable). - * - line: Selecting at a specific line. - * - name: Selecting using a specific Vocabulary name. - * - object: Print Objects. - * - 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. - * - replace: Using re-assignments. - * - replace: Using replacements. - * - substitute: Using substitutions. - * - total: Enable printing of "total" count. - * - version: Print version. - * - whole: Print all data. - * - wrap: Using wrapping. - */ -#ifndef _di_iki_read_main_flag_e_ - enum { - iki_read_main_flag_none_e = 0x0, - iki_read_main_flag_at_e = 0x1, - iki_read_main_flag_content_e = 0x2, - iki_read_main_flag_copyright_e = 0x4, - iki_read_main_flag_help_e = 0x8, - iki_read_main_flag_literal_e = 0x10, - iki_read_main_flag_line_e = 0x20, - iki_read_main_flag_name_e = 0x40, - iki_read_main_flag_object_e = 0x80, - iki_read_main_flag_print_first_e = 0x100, - iki_read_main_flag_print_last_e = 0x200, - iki_read_main_flag_reassign_e = 0x400, - iki_read_main_flag_replace_e = 0x800, - iki_read_main_flag_substitute_e = 0x1000, - iki_read_main_flag_total_e = 0x2000, - iki_read_main_flag_version_e = 0x4000, - iki_read_main_flag_whole_e = 0x8000, - iki_read_main_flag_wrap_e = 0x10000, - }; // enum -#endif // _di_iki_read_main_flag_e_ - -/** - * The main program parameters. - */ -#ifndef _di_iki_read_parameter_e_ - enum { - iki_read_parameter_help_e, - iki_read_parameter_copyright_e, - iki_read_parameter_light_e, - iki_read_parameter_dark_e, - iki_read_parameter_no_color_e, - iki_read_parameter_verbosity_quiet_e, - iki_read_parameter_verbosity_error_e, - iki_read_parameter_verbosity_normal_e, - iki_read_parameter_verbosity_verbose_e, - iki_read_parameter_verbosity_debug_e, - iki_read_parameter_version_e, - iki_read_parameter_line_first_no_e, - iki_read_parameter_line_last_no_e, - - iki_read_parameter_at_e, - iki_read_parameter_content_e, - iki_read_parameter_line_e, - iki_read_parameter_literal_e, - iki_read_parameter_name_e, - iki_read_parameter_object_e, - iki_read_parameter_reassign_e, - iki_read_parameter_replace_e, - iki_read_parameter_substitute_e, - iki_read_parameter_total_e, - iki_read_parameter_whole_e, - iki_read_parameter_wrap_e, - }; // enum - - #define iki_read_console_parameter_t_initialize \ - { \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_error_s, f_console_standard_long_error_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_normal_s, f_console_standard_long_normal_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_first_no_s, f_console_standard_long_line_first_no_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_last_no_s, f_console_standard_long_line_last_no_s, 0, f_console_flag_inverse_e), \ - \ - macro_f_console_parameter_t_initialize_3(iki_read_short_at_s, iki_read_long_at_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_content_s, iki_read_long_content_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_line_s, iki_read_long_line_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_literal_s, iki_read_long_literal_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_name_s, iki_read_long_name_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_object_s, iki_read_long_object_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_reassign_s, iki_read_long_reassign_s, 3, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_replace_s, iki_read_long_replace_s, 2, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_substitute_s, iki_read_long_substitute_s, 3, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_total_s, iki_read_long_total_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_whole_s, iki_read_long_whole_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_read_short_wrap_s, iki_read_long_wrap_s, 3, f_console_flag_normal_e), \ - } - - #define iki_read_total_parameters_d 25 -#endif // _di_iki_read_parameter_e_ - -/** * The iki read main program settings. * * This is passed to the program-specific main entry point to designate program settings. diff --git a/level_3/iki_read/c/main/identify.c b/level_3/iki_read/c/main/identify.c index e882339..7d5a1ef 100644 --- a/level_3/iki_read/c/main/identify.c +++ b/level_3/iki_read/c/main/identify.c @@ -5,25 +5,25 @@ extern "C" { #endif #ifndef _di_iki_read_identify_alteration_ - void iki_read_identify_alteration(iki_read_setting_t * const setting) { + void iki_read_identify_alteration(iki_read_main_t * const main) { - if (!(setting->replace.used || setting->wrap.used)) return; + if (!main || !(main->setting.replace.used || main->setting.wrap.used)) return; f_array_length_t i = 0; - if (setting->flag & (iki_read_main_flag_content_e | iki_read_main_flag_literal_e)) { + if (main->setting.flag & (iki_read_main_flag_content_e | iki_read_main_flag_literal_e)) { f_array_length_t j = 0; - for (i = 0; i < setting->data.vocabulary.used; ++i) { + for (i = 0; i < main->setting.data.vocabulary.used; ++i) { - if (setting->replace.used) { - setting->map_replaces[i] = setting->replace.used; + if (main->setting.replace.used) { + main->setting.map_replaces[i] = main->setting.replace.used; - j = setting->replace.used - 1; + j = main->setting.replace.used - 1; do { - if (fl_string_dynamic_partial_compare_string(setting->replace.array[j].name.string, setting->buffer, setting->replace.array[j].name.used, setting->data.vocabulary.array[i]) == F_equal_to) { - setting->map_replaces[i] = j; + if (fl_string_dynamic_partial_compare_string(main->setting.replace.array[j].name.string, main->setting.buffer, main->setting.replace.array[j].name.used, main->setting.data.vocabulary.array[i]) == F_equal_to) { + main->setting.map_replaces[i] = j; break; } @@ -31,14 +31,14 @@ extern "C" { } while (j--); } - if (setting->wrap.used) { - setting->map_wraps[i] = setting->wrap.used; + if (main->setting.wrap.used) { + main->setting.map_wraps[i] = main->setting.wrap.used; - j = setting->wrap.used - 1; + j = main->setting.wrap.used - 1; do { - if (fl_string_dynamic_partial_compare_string(setting->wrap.array[j].a.string, setting->buffer, setting->wrap.array[j].a.used, setting->data.vocabulary.array[i]) == F_equal_to) { - setting->map_wraps[i] = j; + if (fl_string_dynamic_partial_compare_string(main->setting.wrap.array[j].a.string, main->setting.buffer, main->setting.wrap.array[j].a.used, main->setting.data.vocabulary.array[i]) == F_equal_to) { + main->setting.map_wraps[i] = j; break; } @@ -48,14 +48,14 @@ extern "C" { } // for } else { - for (i = 0; i < setting->data.vocabulary.used; ++i) { + for (i = 0; i < main->setting.data.vocabulary.used; ++i) { - if (setting->replace.used) { - setting->map_replaces[i] = setting->replace.used; + if (main->setting.replace.used) { + main->setting.map_replaces[i] = main->setting.replace.used; } - if (setting->wrap.used) { - setting->map_wraps[i] = setting->wrap.used; + if (main->setting.wrap.used) { + main->setting.map_wraps[i] = main->setting.wrap.used; } } // for } @@ -63,13 +63,13 @@ extern "C" { #endif // _di_iki_read_identify_alteration_ #ifndef _di_iki_read_identify_substitution_ - f_array_length_t iki_read_identify_substitution(iki_read_setting_t * const setting, const f_string_range_t name, const f_string_range_t value, f_string_triples_t *triple) { + f_array_length_t iki_read_identify_substitution(iki_read_main_t * const main, const f_string_range_t name, const f_string_range_t value, f_string_triples_t *triple) { f_array_length_t i = triple->used - 1; do { - if (fl_string_dynamic_partial_compare_string(triple->array[i].a.string, setting->buffer, triple->array[i].a.used, name) == F_equal_to) { - if (fl_string_dynamic_partial_compare_string(triple->array[i].b.string, setting->buffer, triple->array[i].b.used, value) == F_equal_to) { + if (fl_string_dynamic_partial_compare_string(triple->array[i].a.string, main->setting.buffer, triple->array[i].a.used, name) == F_equal_to) { + if (fl_string_dynamic_partial_compare_string(triple->array[i].b.string, main->setting.buffer, triple->array[i].b.used, value) == F_equal_to) { return i; } } diff --git a/level_3/iki_read/c/main/identify.h b/level_3/iki_read/c/main/identify.h index e8b4b54..e87f1ce 100644 --- a/level_3/iki_read/c/main/identify.h +++ b/level_3/iki_read/c/main/identify.h @@ -22,8 +22,8 @@ extern "C" { * This does not handle substitutions because substitutions must match both name and value (Object and Content). * This function does not know the value (Content). * - * @param setting - * The main program settings. + * @param main + * The program and settings data. * @param replaces * A map to the last matching replacment or a value of setting->data.vocabulary.used if there is no matching replacement. * Must be an array of length setting->data.vocabulary.used. @@ -35,7 +35,7 @@ extern "C" { * The matching setting->data.vocabulary index or if no match then setting->data.vocabulary.used. */ #ifndef _di_iki_read_identify_alteration_ - extern void iki_read_identify_alteration(iki_read_setting_t * const setting); + extern void iki_read_identify_alteration(iki_read_main_t * const main); #endif // _di_iki_read_identify_alteration_ /** @@ -43,8 +43,8 @@ extern "C" { * * This function expects appropriate sanity checks are performed on the reassignments or substitutions array before calling. * - * @param setting - * The main program settings. + * @param main + * The program and settings data. * @param name * A range within setting->buffer representing the name (Object) to match. * @param value @@ -57,7 +57,7 @@ extern "C" { * The value of the triple.used is returned on no match. */ #ifndef _di_iki_read_identify_substitution_ - extern f_array_length_t iki_read_identify_substitution(iki_read_setting_t * const setting, const f_string_range_t name, const f_string_range_t value, f_string_triples_t *triple); + extern f_array_length_t iki_read_identify_substitution(iki_read_main_t * const main, const f_string_range_t name, const f_string_range_t value, f_string_triples_t *triple); #endif // _di_iki_read_identify_substitution_ #ifdef __cplusplus diff --git a/level_3/iki_read/c/main/iki_read.c b/level_3/iki_read/c/main/iki_read.c index 3502ad0..6434205 100644 --- a/level_3/iki_read/c/main/iki_read.c +++ b/level_3/iki_read/c/main/iki_read.c @@ -5,26 +5,25 @@ extern "C" { #endif #ifndef _di_iki_read_main_ - void iki_read_main(fll_program_data_t * const main, iki_read_setting_t * const setting) { + void iki_read_main(iki_read_main_t * const main) { - if (!main || !setting) return; + if (!main) return; - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_read_main_flag_print_last_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_read_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } return; } - if ((setting->flag & iki_read_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_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); } - setting->state.status = F_none; + main->setting.state.status = F_none; if (main->setting.flag & (iki_read_main_flag_help_e | iki_read_main_flag_version_e | iki_read_main_flag_copyright_e)) { - if (main->setting.flag & iki_read_main_flag_help_e) { iki_read_print_message_help(&main->program.message); } @@ -42,68 +41,68 @@ extern "C" { return; } - if (main->pipe & fll_program_data_pipe_input_e) { + if (main->program.pipe & fll_program_data_pipe_input_e) { f_file_t file = f_file_t_initialize; file.id = F_type_descriptor_input_d; - setting->buffer.used = 0; + main->setting.buffer.used = 0; - setting->state.status = f_file_read(file, &setting->buffer); + main->setting.state.status = f_file_read(file, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_read), f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error_file(&main->program.error, macro_iki_read_f(f_file_read), f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); } else { - iki_read_process_buffer(main, setting); + iki_read_process_buffer(main); } } - if (F_status_is_error_not(setting->state.status) && setting->files.used) { + if (F_status_is_error_not(main->setting.state.status) && main->setting.files.used) { f_file_t file = f_file_t_initialize; off_t size_block = 0; off_t size_file = 0; off_t size_read = 0; - for (f_array_length_t i = 0; i < setting->files.used; ++i) { + for (f_array_length_t i = 0; i < main->setting.files.used; ++i) { - if (!((++main->signal_check) % iki_read_signal_check_d)) { + if (!((++main->program.signal_check) % iki_read_signal_check_d)) { if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(&main->warning, main->signal_received); + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); - setting->state.status = F_status_set_error(F_interrupt); + main->setting.state.status = F_status_set_error(F_interrupt); break; } - main->signal_check = 0; + main->program.signal_check = 0; } file.stream = 0; file.id = -1; - setting->state.status = f_file_stream_open(setting->files.array[i], f_string_empty_s, &file); + main->setting.state.status = f_file_stream_open(main->setting.files.array[i], f_string_empty_s, &file); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_stream_open), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error_file(&main->program.error, macro_iki_read_f(f_file_stream_open), main->setting.files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; } - setting->state.status = f_file_descriptor(&file); + main->setting.state.status = f_file_descriptor(&file); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_descriptor), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error_file(&main->program.error, macro_iki_read_f(f_file_descriptor), main->setting.files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; } size_file = 0; - setting->state.status = f_file_size_by_id(file, &size_file); + main->setting.state.status = f_file_size_by_id(file, &size_file); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_size_by_id), setting->files.array[i], f_file_operation_analyze_s, fll_error_file_type_file_e); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error_file(&main->program.error, macro_iki_read_f(f_file_size_by_id), main->setting.files.array[i], f_file_operation_analyze_s, fll_error_file_type_file_e); break; } @@ -127,10 +126,10 @@ extern "C" { } // Pre-allocate entire file buffer plus space for the terminating NULL. - setting->state.status = f_string_dynamic_increase_by(size_file + 1, &setting->buffer); + main->setting.state.status = f_string_dynamic_increase_by(size_file + 1, &main->setting.buffer); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_string_dynamic_increase_by), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error_file(&main->program.error, macro_iki_read_f(f_string_dynamic_increase_by), main->setting.files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; } @@ -139,20 +138,20 @@ extern "C" { // The signal check is always performed on each pass. if (size_file > iki_read_block_max && fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(&main->warning, main->signal_received); + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); - setting->state.status = F_status_set_error(F_interrupt); + main->setting.state.status = F_status_set_error(F_interrupt); break; } - setting->state.status = f_file_stream_read_until(file, size_block, &setting->buffer); - if (F_status_is_error(setting->state.status)) break; + main->setting.state.status = f_file_stream_read_until(file, size_block, &main->setting.buffer); + if (F_status_is_error(main->setting.state.status)) break; } // for - if (F_status_is_error(setting->state.status)) { - if (F_status_set_fine(setting->state.status) != F_interrupt) { - iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_stream_read_until), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + if (F_status_is_error(main->setting.state.status)) { + if (F_status_set_fine(main->setting.state.status) != F_interrupt) { + iki_read_print_error_file(&main->program.error, macro_iki_read_f(f_file_stream_read_until), main->setting.files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); } break; @@ -161,20 +160,20 @@ extern "C" { f_file_stream_flush(file); f_file_stream_close(&file); - iki_read_process_buffer(main, setting); - if (F_status_is_error(setting->state.status)) break; + iki_read_process_buffer(main); + if (F_status_is_error(main->setting.state.status)) break; - setting->buffer.used = 0; + main->setting.buffer.used = 0; } // for - if (F_status_is_error(setting->state.status)) { + if (F_status_is_error(main->setting.state.status)) { f_file_stream_flush(file); f_file_stream_close(&file); } } - if ((setting->flag & iki_read_main_flag_print_last_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_read_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } } #endif // _di_iki_read_main_ diff --git a/level_3/iki_read/c/main/iki_read.h b/level_3/iki_read/c/main/iki_read.h index 7585c31..5a5e67e 100644 --- a/level_3/iki_read/c/main/iki_read.h +++ b/level_3/iki_read/c/main/iki_read.h @@ -93,7 +93,7 @@ extern "C" { * F_failure (with error bit) for any other failure. */ #ifndef _di_iki_read_main_ - extern void iki_read_main(fll_program_data_t * const main, iki_read_setting_t * const setting); + extern void iki_read_main(iki_read_main_t * const main); #endif // _di_iki_read_main_ #ifdef __cplusplus diff --git a/level_3/iki_read/c/main/main.c b/level_3/iki_read/c/main/main.c index 4426b34..5d628b5 100644 --- a/level_3/iki_read/c/main/main.c +++ b/level_3/iki_read/c/main/main.c @@ -4,9 +4,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { iki_read_main_t data = iki_read_main_t_initialize; - setting.state.custom = (void *) &data; - setting.state.handle = &fll_program_standard_signal_handle; - data.program.debug.flag |= iki_read_print_flag_debug_e; data.program.error.flag |= iki_read_print_flag_error_e; data.program.message.flag |= iki_read_print_flag_message_e; @@ -17,30 +14,33 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.warning.custom = (void *) &data; data.program.debug.custom = (void *) &data; + data.setting.state.custom = (void *) &data; + data.setting.state.handle = &fll_program_standard_signal_handle; + f_console_parameter_t parameters[] = iki_read_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = iki_read_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = iki_read_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - iki_read_setting_load(arguments, &data, &setting); + iki_read_setting_load(arguments, &data); } - iki_read_main(&data, &setting); + iki_read_main(&data); - iki_read_setting_unload(&data, &setting); + iki_read_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/iki_read/c/main/print.c b/level_3/iki_read/c/main/print.c deleted file mode 100644 index 2fe4139..0000000 --- a/level_3/iki_read/c/main/print.c +++ /dev/null @@ -1,101 +0,0 @@ -#include "iki_read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_iki_read_print_help_ - f_status_t iki_read_print_help(fl_print_t * const print) { - - if (!setting) return F_status_set_error(F_output_not); - - f_file_stream_lock(print->to); - - fll_program_print_help_header(print, iki_read_program_name_long_s, iki_read_program_version_s); - - fll_program_print_help_option_standard(print); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fll_program_print_help_option(print, iki_read_short_at_s, iki_read_long_at_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Variable at this numeric index."); - fll_program_print_help_option(print, iki_read_short_line_s, iki_read_long_line_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print only the Variables at the given line within the file."); - fll_program_print_help_option(print, iki_read_short_name_s, iki_read_long_name_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Variables with this name."); - fll_program_print_help_option(print, iki_read_short_whole_s, iki_read_long_whole_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print all of the data instead of just the IKI Variable data."); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fll_program_print_help_option(print, iki_read_short_content_s, iki_read_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print the Variable value (aka: Content) (default)"); - fll_program_print_help_option(print, iki_read_short_literal_s, iki_read_long_literal_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print the entire Variable (aka: Object, Content, and syntax)."); - fll_program_print_help_option(print, iki_read_short_object_s, iki_read_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Variable name (aka: Vocabulary) (aka: Object)."); - fll_program_print_help_option(print, iki_read_short_total_s, iki_read_long_total_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of Variables."); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fll_program_print_help_option(print, iki_read_short_reassign_s, iki_read_long_reassign_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Re-assign the Variable for the given name and matching Content value with the given string."); - fll_program_print_help_option(print, iki_read_short_replace_s, iki_read_long_replace_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Simple substitution, replacing the Variable for the given name with the given string."); - fll_program_print_help_option(print, iki_read_short_substitute_s, iki_read_long_substitute_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Substitute the Variable for the given name and matching Content value with the given string."); - fll_program_print_help_option(print, iki_read_short_wrap_s, iki_read_long_wrap_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Prepend and append strings for the given name."); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fll_program_print_help_usage(print, iki_read_program_name_s, fll_program_parameter_filenames_s); - - fl_print_format("%r %[Notes:%]%r", print->to, f_string_eol_s, print->set->important, print->set->important, f_string_eol_s); - fl_print_format(" This program will find and print Variables, Vocabularies, or Content following the IKI standard, without focusing on any particular Vocabulary specification.%r%r", print->to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%] option requires 2 additional parameters:", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable); - fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, print->set->notable); - fl_print_format(" %[<%]%r%[>%].%r", print->to, print->set->notable, print->set->notable, iki_read_substitution_with_s, print->set->notable, print->set->notable, f_string_eol_s); - - fl_print_format(" %[%r%]: The name of the Vocabulary whose content is to be substituted.%r", print->to, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, f_string_eol_s); - fl_print_format(" %[%r%]: The new string to use as the substitute.%r%r", print->to, print->set->notable, iki_read_substitution_with_s, print->set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The Vocabulary is case-sensitive and must exactly match.%r%r", print->to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%] and the", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_reassign_s, print->set->notable); - fl_print_format(" %[%r%r%] options require 3 additional parameters:", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable); - fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, print->set->notable); - fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_replace_s, print->set->notable, print->set->notable); - fl_print_format(" %[<%]%r%[>%].%r", print->to, print->set->notable, print->set->notable, iki_read_substitution_with_s, print->set->notable, print->set->notable, f_string_eol_s); - - fl_print_format(" %[%r%]: The name of the Vocabulary whose content is to be substituted or re-assigned.%r", print->to, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, f_string_eol_s); - fl_print_format(" %[%r%]: The Content matching this exact string will be substituted or re-assigned.%r", print->to, print->set->notable, iki_read_substitution_replace_s, print->set->notable, f_string_eol_s); - fl_print_format(" %[%r%]: The new string to use as the substitute or re-assignment.%r%r", print->to, print->set->notable, iki_read_substitution_with_s, print->set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The Vocabulary and replacement are case-sensitive and must exactly match.%r%r", print->to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%] option requires 3 additional parameters:", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_wrap_s, print->set->notable); - fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, print->set->notable); - fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_before_s, print->set->notable, print->set->notable); - fl_print_format(" %[<%]%r%[>%].%r", print->to, print->set->notable, print->set->notable, iki_read_substitution_after_s, print->set->notable, print->set->notable, f_string_eol_s); - - fl_print_format(" %[%r%]: The name of the Vocabulary whose content is to be wrapped.%r", print->to, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, f_string_eol_s); - fl_print_format(" %[%r%]: The string to prepend.%r", print->to, print->set->notable, iki_read_substitution_before_s, print->set->notable, f_string_eol_s); - fl_print_format(" %[%r%]: The string to append.%r%r", print->to, print->set->notable, iki_read_substitution_after_s, print->set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The Vocabulary is case-sensitive and must exactly match.%r%r", print->to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The difference between %[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable); - fl_print_format(" and %[%r%r%] is that the", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable); - fl_print_format(" %[%r%r%] option substitutes all matching Vocabulary names and the", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable); - fl_print_format(" %[%r%r%] option substitutes all matching Vocabulary names that must also have the given matching Content.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_reassign_s, print->set->notable); - fl_print_format(" option is identical to the %[%r%r%] option", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable); - fl_print_format(" except that the %[%r%r%] option is ignored (not applied).%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_wrap_s, print->set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable); - fl_print_format(" option takes priority over the %[%r%r%] option when matching the same Variable.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The default behavior is to only display Content portion of the IKI Variable.%r", print->to, f_string_eol_s); - - f_file_stream_flush(print->to); - f_file_stream_unlock(print->to); - - return F_none; - } -#endif // _di_iki_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/iki_read/c/main/print.h b/level_3/iki_read/c/main/print.h deleted file mode 100644 index 1318850..0000000 --- a/level_3/iki_read/c/main/print.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: UTF8 - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the print functionality. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _iki_read_print_h -#define _iki_read_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print help. - * - * @param print - * The output structure to print to. - * - * 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. - */ -#ifndef _di_iki_read_print_help_ - extern f_status_t iki_read_print_help(fl_print_t * const print); -#endif // _di_iki_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _iki_read_print_h diff --git a/level_3/iki_read/c/main/print/data.c b/level_3/iki_read/c/main/print/data.c index 1413509..3b0926e 100644 --- a/level_3/iki_read/c/main/print/data.c +++ b/level_3/iki_read/c/main/print/data.c @@ -7,122 +7,120 @@ extern "C" { #ifndef _di_iki_read_print_data_ void iki_read_print_data(fl_print_t * const print, const f_array_length_t index) { - if (!setting) return; + if (!print || !print->custom) return; - if (!main) { - setting->state.status = F_status_set_error(F_parameter); - } + iki_read_main_t * const main = (iki_read_main_t *) print->custom; - f_array_length_t at = setting->reassign.used; + f_array_length_t at = main->setting.reassign.used; - if (setting->reassign.used && (setting->flag & (iki_read_main_flag_content_e | iki_read_main_flag_literal_e))) { - at = iki_read_identify_substitution(setting, setting->data.vocabulary.array[index], setting->data.content.array[index], &setting->reassign); + if (main->setting.reassign.used && (main->setting.flag & (iki_read_main_flag_content_e | iki_read_main_flag_literal_e))) { + at = iki_read_identify_substitution(main, main->setting.data.vocabulary.array[index], main->setting.data.content.array[index], &main->setting.reassign); } - if (at < setting->reassign.used) { - if (setting->flag & iki_read_main_flag_content_e) { - f_print_dynamic(setting->reassign.array[at].c, main->output.to); + if (at < main->setting.reassign.used) { + if (main->setting.flag & iki_read_main_flag_content_e) { + f_print_dynamic(main->setting.reassign.array[at].c, main->program.output.to); } else { - f_string_range_t range = macro_f_string_range_t_initialize(setting->data.variable.array[index].start, setting->data.content.array[index].start - 1); + f_string_range_t range = macro_f_string_range_t_initialize(main->setting.data.variable.array[index].start, main->setting.data.content.array[index].start - 1); - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); - f_print_dynamic(setting->reassign.array[at].c, main->output.to); + f_print_dynamic(main->setting.reassign.array[at].c, main->program.output.to); - range.start = setting->data.content.array[index].stop + 1; - range.stop = setting->data.variable.array[index].stop; + range.start = main->setting.data.content.array[index].stop + 1; + range.stop = main->setting.data.variable.array[index].stop; - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); } return; } - at = setting->substitute.used; + at = main->setting.substitute.used; - if (setting->substitute.used && (setting->flag & (iki_read_main_flag_content_e | iki_read_main_flag_literal_e))) { - at = iki_read_identify_substitution(setting, setting->data.vocabulary.array[index], setting->data.content.array[index], &setting->substitute); + if (main->setting.substitute.used && (main->setting.flag & (iki_read_main_flag_content_e | iki_read_main_flag_literal_e))) { + at = iki_read_identify_substitution(main, main->setting.data.vocabulary.array[index], main->setting.data.content.array[index], &main->setting.substitute); } - if (at < setting->substitute.used) { - if (setting->flag & iki_read_main_flag_content_e) { - iki_read_print_data_wrap_prepend(main, setting, index); + if (at < main->setting.substitute.used) { + if (main->setting.flag & iki_read_main_flag_content_e) { + iki_read_print_data_wrap_prepend(&main->program.output, index); - f_print_dynamic(setting->substitute.array[at].c, main->output.to); + f_print_dynamic(main->setting.substitute.array[at].c, main->program.output.to); - iki_read_print_data_wrap_append(main, setting, index); + iki_read_print_data_wrap_append(&main->program.output, index); } else { - f_string_range_t range = macro_f_string_range_t_initialize(setting->data.variable.array[index].start, setting->data.content.array[index].start - 1); + f_string_range_t range = macro_f_string_range_t_initialize(main->setting.data.variable.array[index].start, main->setting.data.content.array[index].start - 1); - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); - iki_read_print_data_wrap_prepend(main, setting, index); + iki_read_print_data_wrap_prepend(&main->program.output, index); - f_print_dynamic(setting->substitute.array[at].c, main->output.to); + f_print_dynamic(main->setting.substitute.array[at].c, main->program.output.to); - iki_read_print_data_wrap_append(main, setting, index); + iki_read_print_data_wrap_append(&main->program.output, index); - range.start = setting->data.content.array[index].stop + 1; - range.stop = setting->data.variable.array[index].stop; + range.start = main->setting.data.content.array[index].stop + 1; + range.stop = main->setting.data.variable.array[index].stop; - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); } } - else if (setting->replace.used && setting->map_replaces[index] < setting->replace.used) { - if (setting->flag & iki_read_main_flag_content_e) { - iki_read_print_data_wrap_prepend(main, setting, index); + else if (main->setting.replace.used && main->setting.map_replaces[index] < main->setting.replace.used) { + if (main->setting.flag & iki_read_main_flag_content_e) { + iki_read_print_data_wrap_prepend(&main->program.output, index); - f_print_dynamic(setting->replace.array[setting->map_replaces[index]].value, main->output.to); + f_print_dynamic(main->setting.replace.array[main->setting.map_replaces[index]].value, main->program.output.to); - iki_read_print_data_wrap_append(main, setting, index); + iki_read_print_data_wrap_append(&main->program.output, index); } - else if (setting->flag & iki_read_main_flag_object_e) { - f_print_dynamic(setting->replace.array[setting->map_replaces[index]].name, main->output.to); + else if (main->setting.flag & iki_read_main_flag_object_e) { + f_print_dynamic(main->setting.replace.array[main->setting.map_replaces[index]].name, main->program.output.to); } else { - f_string_range_t range = macro_f_string_range_t_initialize(setting->data.variable.array[index].start, setting->data.content.array[index].start - 1); + f_string_range_t range = macro_f_string_range_t_initialize(main->setting.data.variable.array[index].start, main->setting.data.content.array[index].start - 1); - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); - iki_read_print_data_wrap_prepend(main, setting, index); + iki_read_print_data_wrap_prepend(&main->program.output, index); - f_print_dynamic(setting->replace.array[setting->map_replaces[index]].value, main->output.to); + f_print_dynamic(main->setting.replace.array[main->setting.map_replaces[index]].value, main->program.output.to); - iki_read_print_data_wrap_append(main, setting, index); + iki_read_print_data_wrap_append(&main->program.output, index); - range.start = setting->data.content.array[index].stop + 1; - range.stop = setting->data.variable.array[index].stop; + range.start = main->setting.data.content.array[index].stop + 1; + range.stop = main->setting.data.variable.array[index].stop; - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); } } - else if (setting->flag & iki_read_main_flag_content_e) { - iki_read_print_data_wrap_prepend(main, setting, index); + else if (main->setting.flag & iki_read_main_flag_content_e) { + iki_read_print_data_wrap_prepend(&main->program.output, index); - f_print_dynamic_partial(setting->buffer, setting->data.content.array[index], main->output.to); + f_print_dynamic_partial(main->setting.buffer, main->setting.data.content.array[index], main->program.output.to); - iki_read_print_data_wrap_append(main, setting, index); + iki_read_print_data_wrap_append(&main->program.output, index); } - else if (setting->flag & iki_read_main_flag_object_e) { - f_print_dynamic_partial(setting->buffer, setting->data.vocabulary.array[index], main->output.to); + else if (main->setting.flag & iki_read_main_flag_object_e) { + f_print_dynamic_partial(main->setting.buffer, main->setting.data.vocabulary.array[index], main->program.output.to); } else { - f_string_range_t range = macro_f_string_range_t_initialize(setting->data.variable.array[index].start, setting->data.content.array[index].start - 1); + f_string_range_t range = macro_f_string_range_t_initialize(main->setting.data.variable.array[index].start, main->setting.data.content.array[index].start - 1); - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); - iki_read_print_data_wrap_prepend(main, setting, index); + iki_read_print_data_wrap_prepend(&main->program.output, index); - f_print_dynamic_partial(setting->buffer, setting->data.content.array[index], main->output.to); + f_print_dynamic_partial(main->setting.buffer, main->setting.data.content.array[index], main->program.output.to); - iki_read_print_data_wrap_append(main, setting, index); + iki_read_print_data_wrap_append(&main->program.output, index); - range.start = setting->data.content.array[index].stop + 1; - range.stop = setting->data.variable.array[index].stop; + range.start = main->setting.data.content.array[index].stop + 1; + range.stop = main->setting.data.variable.array[index].stop; - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); } } #endif // _di_iki_read_print_data_ @@ -130,40 +128,36 @@ extern "C" { #ifndef _di_iki_read_print_data_wrap_append_ void iki_read_print_data_wrap_append(fl_print_t * const print, const f_array_length_t index) { - if (!setting) return; + if (!print || !print->custom) return; - if (!main) { - setting->state.status = F_status_set_error(F_parameter); - } + iki_read_main_t * const main = (iki_read_main_t *) print->custom; - if (index < setting->data.vocabulary.used && setting->map_wraps[index] < setting->wrap.used) { - if (!setting->wrap.array[setting->map_wraps[index]].c.used) return; + if (index < main->setting.data.vocabulary.used && main->setting.map_wraps[index] < main->setting.wrap.used) { + if (!main->setting.wrap.array[main->setting.map_wraps[index]].c.used) return; } else { return; } - f_print_dynamic(setting->wrap.array[setting->map_wraps[index]].c, main->output.to); + f_print_dynamic(main->setting.wrap.array[main->setting.map_wraps[index]].c, main->program.output.to); } #endif // _di_iki_read_print_data_wrap_append_ #ifndef _di_iki_read_print_data_wrap_prepend_ void iki_read_print_data_wrap_prepend(fl_print_t * const print, const f_array_length_t index) { - if (!setting) return; + if (!print || !print->custom) return; - if (!main) { - setting->state.status = F_status_set_error(F_parameter); - } + iki_read_main_t * const main = (iki_read_main_t *) print->custom; - if (index < setting->data.vocabulary.used && setting->map_wraps[index] < setting->wrap.used) { - if (!setting->wrap.array[setting->map_wraps[index]].b.used) return; + if (index < main->setting.data.vocabulary.used && main->setting.map_wraps[index] < main->setting.wrap.used) { + if (!main->setting.wrap.array[main->setting.map_wraps[index]].b.used) return; } else { return; } - f_print_dynamic(setting->wrap.array[setting->map_wraps[index]].b, main->output.to); + f_print_dynamic(main->setting.wrap.array[main->setting.map_wraps[index]].b, main->program.output.to); } #endif // _di_iki_read_print_data_wrap_prepend_ diff --git a/level_3/iki_read/c/main/print/error.c b/level_3/iki_read/c/main/print/error.c index ca56592..d0d3b8c 100644 --- a/level_3/iki_read/c/main/print/error.c +++ b/level_3/iki_read/c/main/print/error.c @@ -7,9 +7,10 @@ extern "C" { #ifndef _di_iki_read_print_error_ f_status_t iki_read_print_error(fl_print_t * const print, const f_string_t function) { - if (print.verbosity < f_console_verbosity_error_e) return F_output_not; + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(((iki_read_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e); return F_none; } @@ -18,9 +19,12 @@ extern "C" { #ifndef _di_iki_read_print_error_file_ f_status_t iki_read_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { - if (print.verbosity < f_console_verbosity_error_e) return F_output_not; + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type); + iki_read_main_t * const main = (iki_read_main_t *) print->custom; + + fll_error_file_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type); return F_none; } diff --git a/level_3/iki_read/c/main/print/message.c b/level_3/iki_read/c/main/print/message.c index de0e2a3..bddb30c 100644 --- a/level_3/iki_read/c/main/print/message.c +++ b/level_3/iki_read/c/main/print/message.c @@ -4,6 +4,98 @@ extern "C" { #endif +#ifndef _di_iki_read_print_message_help_ + f_status_t iki_read_print_message_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, iki_read_program_name_long_s, iki_read_program_version_s); + + fll_program_print_help_option_standard(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_option(print, iki_read_short_at_s, iki_read_long_at_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Variable at this numeric index."); + fll_program_print_help_option(print, iki_read_short_line_s, iki_read_long_line_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print only the Variables at the given line within the file."); + fll_program_print_help_option(print, iki_read_short_name_s, iki_read_long_name_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Variables with this name."); + fll_program_print_help_option(print, iki_read_short_whole_s, iki_read_long_whole_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print all of the data instead of just the IKI Variable data."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_option(print, iki_read_short_content_s, iki_read_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print the Variable value (aka: Content) (default)"); + fll_program_print_help_option(print, iki_read_short_literal_s, iki_read_long_literal_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print the entire Variable (aka: Object, Content, and syntax)."); + fll_program_print_help_option(print, iki_read_short_object_s, iki_read_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Variable name (aka: Vocabulary) (aka: Object)."); + fll_program_print_help_option(print, iki_read_short_total_s, iki_read_long_total_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of Variables."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_option(print, iki_read_short_reassign_s, iki_read_long_reassign_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Re-assign the Variable for the given name and matching Content value with the given string."); + fll_program_print_help_option(print, iki_read_short_replace_s, iki_read_long_replace_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Simple substitution, replacing the Variable for the given name with the given string."); + fll_program_print_help_option(print, iki_read_short_substitute_s, iki_read_long_substitute_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Substitute the Variable for the given name and matching Content value with the given string."); + fll_program_print_help_option(print, iki_read_short_wrap_s, iki_read_long_wrap_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Prepend and append strings for the given name."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, iki_read_program_name_s, fll_program_parameter_filenames_s); + + fl_print_format("%r %[Notes:%]%r", print->to, f_string_eol_s, print->set->important, print->set->important, f_string_eol_s); + fl_print_format(" This program will find and print Variables, Vocabularies, or Content following the IKI standard, without focusing on any particular Vocabulary specification.%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The %[%r%r%] option requires 2 additional parameters:", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable); + fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, print->set->notable); + fl_print_format(" %[<%]%r%[>%].%r", print->to, print->set->notable, print->set->notable, iki_read_substitution_with_s, print->set->notable, print->set->notable, f_string_eol_s); + + fl_print_format(" %[%r%]: The name of the Vocabulary whose content is to be substituted.%r", print->to, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, f_string_eol_s); + fl_print_format(" %[%r%]: The new string to use as the substitute.%r%r", print->to, print->set->notable, iki_read_substitution_with_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The Vocabulary is case-sensitive and must exactly match.%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The %[%r%r%] and the", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_reassign_s, print->set->notable); + fl_print_format(" %[%r%r%] options require 3 additional parameters:", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable); + fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, print->set->notable); + fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_replace_s, print->set->notable, print->set->notable); + fl_print_format(" %[<%]%r%[>%].%r", print->to, print->set->notable, print->set->notable, iki_read_substitution_with_s, print->set->notable, print->set->notable, f_string_eol_s); + + fl_print_format(" %[%r%]: The name of the Vocabulary whose content is to be substituted or re-assigned.%r", print->to, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, f_string_eol_s); + fl_print_format(" %[%r%]: The Content matching this exact string will be substituted or re-assigned.%r", print->to, print->set->notable, iki_read_substitution_replace_s, print->set->notable, f_string_eol_s); + fl_print_format(" %[%r%]: The new string to use as the substitute or re-assignment.%r%r", print->to, print->set->notable, iki_read_substitution_with_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The Vocabulary and replacement are case-sensitive and must exactly match.%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The %[%r%r%] option requires 3 additional parameters:", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_wrap_s, print->set->notable); + fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, print->set->notable); + fl_print_format(" %[<%]%r%[>%]", print->to, print->set->notable, print->set->notable, iki_read_substitution_before_s, print->set->notable, print->set->notable); + fl_print_format(" %[<%]%r%[>%].%r", print->to, print->set->notable, print->set->notable, iki_read_substitution_after_s, print->set->notable, print->set->notable, f_string_eol_s); + + fl_print_format(" %[%r%]: The name of the Vocabulary whose content is to be wrapped.%r", print->to, print->set->notable, iki_read_substitution_vocabulary_s, print->set->notable, f_string_eol_s); + fl_print_format(" %[%r%]: The string to prepend.%r", print->to, print->set->notable, iki_read_substitution_before_s, print->set->notable, f_string_eol_s); + fl_print_format(" %[%r%]: The string to append.%r%r", print->to, print->set->notable, iki_read_substitution_after_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The Vocabulary is case-sensitive and must exactly match.%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The difference between %[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable); + fl_print_format(" and %[%r%r%] is that the", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable); + fl_print_format(" %[%r%r%] option substitutes all matching Vocabulary names and the", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable); + fl_print_format(" %[%r%r%] option substitutes all matching Vocabulary names that must also have the given matching Content.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The %[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_reassign_s, print->set->notable); + fl_print_format(" option is identical to the %[%r%r%] option", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable); + fl_print_format(" except that the %[%r%r%] option is ignored (not applied).%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_wrap_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The %[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_substitute_s, print->set->notable); + fl_print_format(" option takes priority over the %[%r%r%] option when matching the same Variable.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The default behavior is to only display Content portion of the IKI Variable.%r", print->to, f_string_eol_s); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_iki_read_print_message_help_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/main/print/message.h b/level_3/iki_read/c/main/print/message.h index 41ef415..2bdbf62 100644 --- a/level_3/iki_read/c/main/print/message.h +++ b/level_3/iki_read/c/main/print/message.h @@ -16,6 +16,24 @@ extern "C" { #endif +/** + * Print help. + * + * @param print + * The output structure to print to. + * + * 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. + */ +#ifndef _di_iki_read_print_message_help_ + extern f_status_t iki_read_print_message_help(fl_print_t * const print); +#endif // _di_iki_read_print_message_help_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/main/process.c b/level_3/iki_read/c/main/process.c index bafa47a..79e8d98 100644 --- a/level_3/iki_read/c/main/process.c +++ b/level_3/iki_read/c/main/process.c @@ -5,10 +5,10 @@ extern "C" { #endif #ifndef _di_iki_read_process_line_ - void iki_read_process_line(fll_program_data_t * const main, iki_read_setting_t * const setting, f_string_range_t *range) { + void iki_read_process_line(iki_read_main_t * const main, f_string_range_t *range) { - if (!(setting->flag & iki_read_main_flag_line_e)) { - setting->state.status = F_false; + if (!(main->setting.flag & iki_read_main_flag_line_e)) { + main->setting.state.status = F_false; return; } @@ -16,296 +16,296 @@ extern "C" { f_array_length_t line = 0; range->start = 0; - if (setting->line) { - for (; line < setting->line && range->start < setting->buffer.used; ++range->start) { - if (setting->buffer.string[range->start] == f_string_eol_s.string[0]) ++line; + if (main->setting.line) { + for (; line < main->setting.line && range->start < main->setting.buffer.used; ++range->start) { + if (main->setting.buffer.string[range->start] == f_string_eol_s.string[0]) ++line; } // for } - if (line == setting->line) { + if (line == main->setting.line) { // Find where the found line ends and set that as the range stop. - for (range->stop = range->start; range->stop < setting->buffer.used; ++range->stop) { - if (setting->buffer.string[range->stop] == f_string_eol_s.string[0]) break; + for (range->stop = range->start; range->stop < main->setting.buffer.used; ++range->stop) { + if (main->setting.buffer.string[range->stop] == f_string_eol_s.string[0]) break; } // for - setting->state.status = F_true; + main->setting.state.status = F_true; } else { - setting->state.status = F_data_not; + main->setting.state.status = F_data_not; } } #endif // _di_iki_read_process_line_ #ifndef _di_iki_read_process_buffer_ - void iki_read_process_buffer(fll_program_data_t * const main, iki_read_setting_t * const setting) { + void iki_read_process_buffer(iki_read_main_t * const main) { - if (setting->flag & iki_read_main_flag_total_e) { - iki_read_process_buffer_total(main, setting); + if (main->setting.flag & iki_read_main_flag_total_e) { + iki_read_process_buffer_total(main); - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = F_none; + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = F_none; } return; } - f_string_range_t buffer_range = macro_f_string_range_t_initialize2(setting->buffer.used); + f_string_range_t buffer_range = macro_f_string_range_t_initialize2(main->setting.buffer.used); - iki_read_process_line(main, setting, &buffer_range); + iki_read_process_line(main, &buffer_range); - if (setting->state.status == F_true) { - if (buffer_range.start > setting->buffer.used) { - setting->state.status = F_data_not; + if (main->setting.state.status == F_true) { + if (buffer_range.start > main->setting.buffer.used) { + main->setting.state.status = F_data_not; return; } } - else if (setting->state.status == F_data_not) { - setting->state.status = F_data_not; + else if (main->setting.state.status == F_data_not) { + main->setting.state.status = F_data_not; return; } - if (setting->flag & iki_read_main_flag_whole_e) { - iki_read_process_buffer_ranges_whole(main, setting, buffer_range); + if (main->setting.flag & iki_read_main_flag_whole_e) { + iki_read_process_buffer_ranges_whole(main, buffer_range); } else { - iki_read_process_buffer_ranges(main, setting, &buffer_range); + iki_read_process_buffer_ranges(main, &buffer_range); } - if (F_status_is_error_not(setting->state.status)) { - setting->state.status = F_none; + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = F_none; } } #endif // _di_iki_read_process_buffer_ #ifndef _di_iki_read_process_buffer_ranges_ - void iki_read_process_buffer_ranges(fll_program_data_t * const main, iki_read_setting_t * const setting, f_string_range_t *buffer_range) { + void iki_read_process_buffer_ranges(iki_read_main_t * const main, f_string_range_t *buffer_range) { - fl_iki_read(&setting->buffer, buffer_range, &setting->data, &setting->state); + fl_iki_read(&main->setting.buffer, buffer_range, &main->setting.data, &main->setting.state); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error(&main->program.error, macro_iki_read_f(fl_iki_read)); return; } f_array_length_t i = 0; - f_array_length_t replaces[setting->data.vocabulary.used]; - f_array_length_t wraps[setting->data.vocabulary.used]; + f_array_length_t replaces[main->setting.data.vocabulary.used]; + f_array_length_t wraps[main->setting.data.vocabulary.used]; - memset(replaces, 0, sizeof(f_array_length_t) * setting->data.vocabulary.used); - memset(wraps, 0, sizeof(f_array_length_t) * setting->data.vocabulary.used); + memset(replaces, 0, sizeof(f_array_length_t) * main->setting.data.vocabulary.used); + memset(wraps, 0, sizeof(f_array_length_t) * main->setting.data.vocabulary.used); - setting->map_replaces = replaces; - setting->map_wraps = wraps; + main->setting.map_replaces = replaces; + main->setting.map_wraps = wraps; - for (; i < setting->data.delimits.used; ++i) { - setting->buffer.string[setting->data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + for (; i < main->setting.data.delimits.used; ++i) { + main->setting.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for - iki_read_identify_alteration(setting); + iki_read_identify_alteration(main); - if (setting->flag & iki_read_main_flag_name_e) { + if (main->setting.flag & iki_read_main_flag_name_e) { f_array_length_t j = 0; f_array_length_t matches = 0; bool unmatched = F_true; - f_file_stream_lock(main->output.to); + f_file_stream_lock(main->program.output.to); - for (i = 0; i < setting->data.vocabulary.used; ++i) { + for (i = 0; i < main->setting.data.vocabulary.used; ++i) { - for (j = 0; j < setting->names.used; ++j) { + for (j = 0; j < main->setting.names.used; ++j) { - if (fl_string_dynamic_partial_compare_string(setting->names.array[j].string, setting->buffer, setting->names.array[j].used, setting->data.vocabulary.array[i]) == F_equal_to) { + if (fl_string_dynamic_partial_compare_string(main->setting.names.array[j].string, main->setting.buffer, main->setting.names.array[j].used, main->setting.data.vocabulary.array[i]) == F_equal_to) { unmatched = F_false; - if (setting->flag & iki_read_main_flag_at_e) { - if (matches < setting->at) { + if (main->setting.flag & iki_read_main_flag_at_e) { + if (matches < main->setting.at) { matches++; continue; } - if (matches++ > setting->at) break; + if (matches++ > main->setting.at) break; } - iki_read_print_data(main, setting, i); + iki_read_print_data(&main->program.output, i); - f_print_dynamic_raw(f_string_eol_s, main->output.to); + f_print_dynamic_raw(f_string_eol_s, main->program.output.to); } } // for } // for - f_file_stream_unlock(main->output.to); + f_file_stream_unlock(main->program.output.to); if (unmatched) { - setting->state.status = F_data_not; + main->setting.state.status = F_data_not; } else { - setting->state.status = F_none; + main->setting.state.status = F_none; } } else { - if (setting->data.variable.used) { - if (setting->flag & iki_read_main_flag_at_e) { - if (setting->at < setting->data.variable.used) { - f_file_stream_lock(main->output.to); + if (main->setting.data.variable.used) { + if (main->setting.flag & iki_read_main_flag_at_e) { + if (main->setting.at < main->setting.data.variable.used) { + f_file_stream_lock(main->program.output.to); - iki_read_print_data(main, setting, setting->at); + iki_read_print_data(&main->program.output, main->setting.at); - f_print_dynamic_raw(f_string_eol_s, main->output.to); + f_print_dynamic_raw(f_string_eol_s, main->program.output.to); - f_file_stream_unlock(main->output.to); + f_file_stream_unlock(main->program.output.to); - setting->state.status = F_none; + main->setting.state.status = F_none; } else { - setting->state.status = F_data_not; + main->setting.state.status = F_data_not; } } else { - f_file_stream_lock(main->output.to); + f_file_stream_lock(main->program.output.to); - for (i = 0; i < setting->data.variable.used; ++i) { + for (i = 0; i < main->setting.data.variable.used; ++i) { - iki_read_print_data(main, setting, i); + iki_read_print_data(&main->program.output, i); - f_print_dynamic_raw(f_string_eol_s, main->output.to); + f_print_dynamic_raw(f_string_eol_s, main->program.output.to); } // for - f_file_stream_unlock(main->output.to); + f_file_stream_unlock(main->program.output.to); - setting->state.status = F_none; + main->setting.state.status = F_none; } } else { - setting->state.status = F_data_not; + main->setting.state.status = F_data_not; } } } #endif // _di_iki_read_process_buffer_ranges_ #ifndef _di_iki_read_process_buffer_ranges_whole_ - void iki_read_process_buffer_ranges_whole(fll_program_data_t * const main, iki_read_setting_t * const setting, const f_string_range_t buffer_range) { + void iki_read_process_buffer_ranges_whole(iki_read_main_t * const main, const f_string_range_t buffer_range) { f_string_range_t range = buffer_range; - fl_iki_read(&setting->buffer, &range, &setting->data, &setting->state); + fl_iki_read(&main->setting.buffer, &range, &main->setting.data, &main->setting.state); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error(&main->program.error, macro_iki_read_f(fl_iki_read)); return; } f_array_length_t i = 0; - for (; i < setting->data.delimits.used; ++i) { - setting->buffer.string[setting->data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + for (; i < main->setting.data.delimits.used; ++i) { + main->setting.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for - if (!setting->data.variable.used) { - fll_print_dynamic_partial(setting->buffer, buffer_range, main->output.to); + if (!main->setting.data.variable.used) { + fll_print_dynamic_partial(main->setting.buffer, buffer_range, main->program.output.to); - setting->state.status = F_none; + main->setting.state.status = F_none; return; } - f_array_length_t replaces[setting->data.vocabulary.used]; - f_array_length_t wraps[setting->data.vocabulary.used]; + f_array_length_t replaces[main->setting.data.vocabulary.used]; + f_array_length_t wraps[main->setting.data.vocabulary.used]; - memset(replaces, 0, sizeof(f_array_length_t) * setting->data.vocabulary.used); - memset(wraps, 0, sizeof(f_array_length_t) * setting->data.vocabulary.used); + memset(replaces, 0, sizeof(f_array_length_t) * main->setting.data.vocabulary.used); + memset(wraps, 0, sizeof(f_array_length_t) * main->setting.data.vocabulary.used); - setting->map_replaces = replaces; - setting->map_wraps = wraps; + main->setting.map_replaces = replaces; + main->setting.map_wraps = wraps; - iki_read_identify_alteration(setting); + iki_read_identify_alteration(main); { f_array_length_t j = 0; f_array_length_t k = 0; - f_array_length_t stop = setting->data.variable.used; + f_array_length_t stop = main->setting.data.variable.used; i = buffer_range.start; range = buffer_range; - f_file_stream_lock(main->output.to); + f_file_stream_lock(main->program.output.to); while (i <= range.stop && j < stop) { - if (i < setting->data.variable.array[j].start) { + if (i < main->setting.data.variable.array[j].start) { range.start = i; - range.stop = setting->data.variable.array[j].start - 1; + range.stop = main->setting.data.variable.array[j].start - 1; - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); - range.start = setting->data.variable.array[j].stop + 1; + range.start = main->setting.data.variable.array[j].stop + 1; range.stop = buffer_range.stop; - i = setting->data.variable.array[j].start; + i = main->setting.data.variable.array[j].start; } - if (setting->names.used) { - for (k = 0; k < setting->names.used; ++k) { - if (fl_string_dynamic_partial_compare_string(setting->names.array[k].string, setting->buffer, setting->names.array[k].used, setting->data.vocabulary.array[j]) == F_equal_to) break; + if (main->setting.names.used) { + for (k = 0; k < main->setting.names.used; ++k) { + if (fl_string_dynamic_partial_compare_string(main->setting.names.array[k].string, main->setting.buffer, main->setting.names.array[k].used, main->setting.data.vocabulary.array[j]) == F_equal_to) break; } // for - if (k < setting->names.used) { - iki_read_print_data(main, setting, j); + if (k < main->setting.names.used) { + iki_read_print_data(&main->program.output, j); } } else { - iki_read_print_data(main, setting, j); + iki_read_print_data(&main->program.output, j); } - i = setting->data.variable.array[j].stop + 1; + i = main->setting.data.variable.array[j].stop + 1; ++j; } // while if (i <= buffer_range.stop) { range.start = i; - f_print_dynamic_partial(setting->buffer, range, main->output.to); + f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); } - f_file_stream_unlock(main->output.to); + f_file_stream_unlock(main->program.output.to); } - setting->state.status = F_none; + main->setting.state.status = F_none; } #endif // _di_iki_read_process_buffer_ranges_whole_ #ifndef _di_iki_read_process_buffer_total_ - void iki_read_process_buffer_total(fll_program_data_t * const main, iki_read_setting_t * const setting) { + void iki_read_process_buffer_total(iki_read_main_t * const main) { - f_string_range_t range = macro_f_string_range_t_initialize2(setting->buffer.used); + f_string_range_t range = macro_f_string_range_t_initialize2(main->setting.buffer.used); - iki_read_process_line(main, setting, &range); + iki_read_process_line(main, &range); - if (setting->state.status == F_true) { - if (range.start > setting->buffer.used) { - fll_print_format("%r%r", main->output.to, f_string_ascii_0_s, f_string_eol_s); + if (main->setting.state.status == F_true) { + if (range.start > main->setting.buffer.used) { + fll_print_format("%r%r", main->program.output.to, f_string_ascii_0_s, f_string_eol_s); - setting->state.status = F_none; + main->setting.state.status = F_none; return; } } - else if (setting->state.status == F_data_not) { - fll_print_format("%r%r", main->output.to, f_string_ascii_0_s, f_string_eol_s); + else if (main->setting.state.status == F_data_not) { + fll_print_format("%r%r", main->program.output.to, f_string_ascii_0_s, f_string_eol_s); - setting->state.status = F_none; + main->setting.state.status = F_none; return; } - fl_iki_read(&setting->buffer, &range, &setting->data, &setting->state); + fl_iki_read(&main->setting.buffer, &range, &main->setting.data, &main->setting.state); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error(&main->program.error, macro_iki_read_f(fl_iki_read)); return; } @@ -313,11 +313,11 @@ extern "C" { f_array_length_t i = 0; f_array_length_t total = 0; - for (; i < setting->data.delimits.used; ++i) { - setting->buffer.string[setting->data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + for (; i < main->setting.data.delimits.used; ++i) { + main->setting.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for - if (main->parameters.array[iki_read_parameter_name_e].result & f_console_result_value_e) { + if (main->program.parameters.array[iki_read_parameter_name_e].result & f_console_result_value_e) { f_string_dynamic_t name = f_string_dynamic_t_initialize; f_array_length_t index = 0; @@ -325,29 +325,29 @@ extern "C" { range.start = 0; - for (i = 0; i < main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { + for (i = 0; i < main->program.parameters.array[iki_read_parameter_name_e].values.used; ++i) { - if (!((++main->signal_check) % iki_read_signal_check_d)) { + if (!((++main->program.signal_check) % iki_read_signal_check_d)) { if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(&main->warning, main->signal_received); + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); f_string_dynamic_resize(0, &name); - setting->state.status = F_status_set_error(F_interrupt); + main->setting.state.status = F_status_set_error(F_interrupt); return; } - main->signal_check = 0; + main->program.signal_check = 0; } - index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; + index = main->program.parameters.array[iki_read_parameter_name_e].values.array[i]; name.used = 0; - setting->state.status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); + main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[index], &name); - if (F_status_is_error(setting->state.status)) { - iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_append_nulless)); + if (F_status_is_error(main->setting.state.status)) { + iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_dynamic_append_nulless)); f_string_dynamic_resize(0, &name); @@ -356,23 +356,23 @@ extern "C" { range.stop = name.used - 1; - for (j = 0; j < setting->data.vocabulary.used; ++j) { + for (j = 0; j < main->setting.data.vocabulary.used; ++j) { - setting->state.status = fl_string_dynamic_partial_compare(name, setting->buffer, range, setting->data.vocabulary.array[j]); + main->setting.state.status = fl_string_dynamic_partial_compare(name, main->setting.buffer, range, main->setting.data.vocabulary.array[j]); - if (setting->state.status == F_equal_to) ++total; + if (main->setting.state.status == F_equal_to) ++total; } // for } // for f_string_dynamic_resize(0, &name); } else { - total = setting->data.variable.used; + total = main->setting.data.variable.used; } // If the "at" position is within the actual total, then the total at the given position is 1, otherwise is 0. - if (main->parameters.array[iki_read_parameter_at_e].result & f_console_result_value_e) { - if (setting->at < total) { + if (main->program.parameters.array[iki_read_parameter_at_e].result & f_console_result_value_e) { + if (main->setting.at < total) { total = 1; } else { @@ -380,9 +380,9 @@ extern "C" { } } - fll_print_format("%ul%r", main->output.to, total, f_string_eol_s); + fll_print_format("%ul%r", main->program.output.to, total, f_string_eol_s); - setting->state.status = F_none; + main->setting.state.status = F_none; } #endif // _di_iki_read_process_buffer_total_ diff --git a/level_3/iki_read/c/main/process.h b/level_3/iki_read/c/main/process.h index 94c40a4..c001de3 100644 --- a/level_3/iki_read/c/main/process.h +++ b/level_3/iki_read/c/main/process.h @@ -35,7 +35,7 @@ extern "C" { * The range value to represent the --line values. */ #ifndef _di_iki_read_process_line_ - extern void iki_read_process_line(fll_program_data_t * const main, iki_read_setting_t * const setting, f_string_range_t *range); + extern void iki_read_process_line(iki_read_main_t * const main, f_string_range_t *range); #endif // _di_iki_read_process_line_ /** @@ -63,7 +63,7 @@ extern "C" { * @see iki_read_process_buffer_ranges_whole() */ #ifndef _di_iki_read_process_buffer_ - extern void iki_read_process_buffer(fll_program_data_t * const main, iki_read_setting_t * const setting); + extern void iki_read_process_buffer(iki_read_main_t * const main); #endif // _di_iki_read_process_buffer_ /** @@ -83,7 +83,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ranges_ - extern void iki_read_process_buffer_ranges(fll_program_data_t * const main, iki_read_setting_t * const setting, f_string_range_t *buffer_range); + extern void iki_read_process_buffer_ranges(iki_read_main_t * const main, f_string_range_t *buffer_range); #endif // _di_iki_read_process_buffer_ranges_ /** @@ -105,7 +105,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ranges_whole_ - extern void iki_read_process_buffer_ranges_whole(fll_program_data_t * const main, iki_read_setting_t * const setting, const f_string_range_t buffer_range); + extern void iki_read_process_buffer_ranges_whole(iki_read_main_t * const main, const f_string_range_t buffer_range); #endif // _di_iki_read_process_buffer_ranges_whole_ /** @@ -122,7 +122,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_total_ - extern void iki_read_process_buffer_total(fll_program_data_t * const main, iki_read_setting_t * const setting); + extern void iki_read_process_buffer_total(iki_read_main_t * const main); #endif // _di_iki_read_process_buffer_total_ #ifdef __cplusplus diff --git a/level_3/iki_write/c/main/common.c b/level_3/iki_write/c/main/common.c index b5646f6..2396028 100644 --- a/level_3/iki_write/c/main/common.c +++ b/level_3/iki_write/c/main/common.c @@ -22,37 +22,37 @@ extern "C" { #endif // _di_iki_write_setting_delete_ #ifndef _di_iki_write_setting_load_ - void iki_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_write_setting_t * const setting) { + void iki_write_setting_load(const f_console_arguments_t arguments, iki_write_main_t * const main) { - if (!main || !setting) return; + if (!main) return; - setting->state.step_small = iki_write_allocation_console_d; + main->setting.state.step_small = iki_write_allocation_console_d; - f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - setting->state.step_small = iki_write_allocation_small_d; + main->setting.state.step_small = iki_write_allocation_small_d; // Identify and pocess first/last parameters. - if (main->parameters.array[iki_write_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & iki_write_main_flag_print_first_e; + if (main->program.parameters.array[iki_write_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & iki_write_main_flag_print_first_e; } else { - setting->flag |= iki_write_main_flag_print_first_e; + main->setting.flag |= iki_write_main_flag_print_first_e; } - if (main->parameters.array[iki_write_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & iki_write_main_flag_print_last_e; + if (main->program.parameters.array[iki_write_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & iki_write_main_flag_print_last_e; } else { - setting->flag |= iki_write_main_flag_print_last_e; + main->setting.flag |= iki_write_main_flag_print_last_e; } - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_write_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); } - iki_write_print_error(setting, main->error, macro_iki_write_f(f_console_parameter_process)); + iki_write_print_error(&main->program.error, macro_iki_write_f(f_console_parameter_process)); return; } @@ -68,14 +68,14 @@ extern "C" { const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_write_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); } - iki_write_print_error(setting, main->error, macro_iki_write_f(fll_program_parameter_process_context)); + iki_write_print_error(&main->program.error, macro_iki_write_f(fll_program_parameter_process_context)); return; } @@ -89,220 +89,220 @@ extern "C" { const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_write_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); } - iki_write_print_error(setting, main->error, macro_iki_write_f(fll_program_parameter_process_verbosity)); + iki_write_print_error(&main->program.error, macro_iki_write_f(fll_program_parameter_process_verbosity)); return; } } } - main->output.to.id = F_type_descriptor_output_d; - main->output.to.stream = F_type_output_d; - main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; + main->program.output.to.id = F_type_descriptor_output_d; + 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->parameters.array[iki_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= iki_write_main_flag_help_e; + if (main->program.parameters.array[iki_write_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= iki_write_main_flag_help_e; return; } - if (main->parameters.array[iki_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= iki_write_main_flag_version_e; + if (main->program.parameters.array[iki_write_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= iki_write_main_flag_version_e; return; } - if (main->parameters.array[iki_write_parameter_copyright_e].result & f_console_result_found_e) { - setting->flag |= iki_write_main_flag_copyright_e; + if (main->program.parameters.array[iki_write_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= iki_write_main_flag_copyright_e; return; } - if (main->parameters.array[iki_write_parameter_file_e].result & f_console_result_value_e && main->parameters.array[iki_write_parameter_file_e].values.used) { - if (main->parameters.array[iki_write_parameter_file_e].values.used > 1) { - setting->state.status = F_status_set_error(F_parameter); + if (main->program.parameters.array[iki_write_parameter_file_e].result & f_console_result_value_e && main->program.parameters.array[iki_write_parameter_file_e].values.used) { + if (main->program.parameters.array[iki_write_parameter_file_e].values.used > 1) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_write_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_program_print_error_parameter_must_specify_once(&main->error, f_console_symbol_long_normal_s, iki_write_long_file_s); + fll_program_print_error_parameter_must_specify_once(&main->program.error, f_console_symbol_long_normal_s, iki_write_long_file_s); return; } - const f_array_length_t index = main->parameters.array[iki_write_parameter_file_e].values.array[0]; + const f_array_length_t index = main->program.parameters.array[iki_write_parameter_file_e].values.array[0]; - main->output.to.id = -1; - main->output.to.stream = 0; + main->program.output.to.id = -1; + main->program.output.to.stream = 0; - setting->state.status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); + main->setting.state.status = f_file_stream_open(main->program.parameters.arguments.array[index], f_string_empty_s, &main->program.output.to); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_write_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_file_print(main->error, F_status_set_fine(setting->state.status), "f_file_stream_open", fll_error_file_flag_fallback_e, main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_iki_write_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); return; } - setting->flag |= iki_write_main_flag_file_to_e; + main->setting.flag |= iki_write_main_flag_file_to_e; } - else if (main->parameters.array[iki_write_parameter_file_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[iki_write_parameter_file_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_write_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, iki_write_long_file_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_write_long_file_s); return; } - if (main->parameters.array[iki_write_parameter_object_e].result & f_console_result_value_e) { - f_array_lengths_t * const values = &main->parameters.array[iki_write_parameter_object_e].values; + if (main->program.parameters.array[iki_write_parameter_object_e].result & f_console_result_value_e) { + f_array_lengths_t * const values = &main->program.parameters.array[iki_write_parameter_object_e].values; - setting->objects.used = 0; + main->setting.objects.used = 0; - setting->state.status = f_string_dynamics_resize(values->used, &setting->objects); + main->setting.state.status = f_string_dynamics_resize(values->used, &main->setting.objects); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_write_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); } - iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamics_resize)); + iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamics_resize)); return; } // Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0). - for (f_array_length_t index = 0; setting->objects.used < values->used; ) { + for (f_array_length_t index = 0; main->setting.objects.used < values->used; ) { - index = values->array[setting->objects.used]; + index = values->array[main->setting.objects.used]; - setting->objects.array[setting->objects.used].string = main->parameters.arguments.array[index].string; - setting->objects.array[setting->objects.used].used = main->parameters.arguments.array[index].used; - setting->objects.array[setting->objects.used++].size = 0; + main->setting.objects.array[main->setting.objects.used].string = main->program.parameters.arguments.array[index].string; + main->setting.objects.array[main->setting.objects.used].used = main->program.parameters.arguments.array[index].used; + main->setting.objects.array[main->setting.objects.used++].size = 0; } // for - setting->flag |= iki_write_main_flag_object_e; + main->setting.flag |= iki_write_main_flag_object_e; } - else if (main->parameters.array[iki_write_parameter_object_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[iki_write_parameter_object_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_write_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, iki_write_long_object_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_write_long_object_s); return; } - if (main->parameters.array[iki_write_parameter_content_e].result & f_console_result_value_e) { - f_array_lengths_t * const values = &main->parameters.array[iki_write_parameter_content_e].values; + if (main->program.parameters.array[iki_write_parameter_content_e].result & f_console_result_value_e) { + f_array_lengths_t * const values = &main->program.parameters.array[iki_write_parameter_content_e].values; - setting->contents.used = 0; + main->setting.contents.used = 0; - setting->state.status = f_string_dynamics_resize(values->used, &setting->contents); + main->setting.state.status = f_string_dynamics_resize(values->used, &main->setting.contents); - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_write_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); } - iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamics_resize)); + iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamics_resize)); return; } // Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0). - for (f_array_length_t index = 0; setting->contents.used < values->used; ) { + for (f_array_length_t index = 0; main->setting.contents.used < values->used; ) { - index = values->array[setting->contents.used]; + index = values->array[main->setting.contents.used]; - setting->contents.array[setting->contents.used].string = main->parameters.arguments.array[index].string; - setting->contents.array[setting->contents.used].used = main->parameters.arguments.array[index].used; - setting->contents.array[setting->contents.used++].size = 0; + main->setting.contents.array[main->setting.contents.used].string = main->program.parameters.arguments.array[index].string; + main->setting.contents.array[main->setting.contents.used].used = main->program.parameters.arguments.array[index].used; + main->setting.contents.array[main->setting.contents.used++].size = 0; } // for - setting->flag |= iki_write_main_flag_content_e; + main->setting.flag |= iki_write_main_flag_content_e; } - else if (main->parameters.array[iki_write_parameter_content_e].result & f_console_result_found_e) { - setting->state.status = F_status_set_error(F_parameter); + else if (main->program.parameters.array[iki_write_parameter_content_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_write_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_program_print_error_parameter_missing_value(&main->error, f_console_symbol_long_normal_s, iki_write_long_content_s); + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_write_long_content_s); return; } - if (!(main->pipe & fll_program_data_pipe_input_e) && !(setting->flag & (iki_write_main_flag_content_e | iki_write_parameter_object_e))) { - setting->state.status = F_status_set_error(F_parameter); + if (!(main->program.pipe & fll_program_data_pipe_input_e) && !(main->setting.flag & (iki_write_main_flag_content_e | iki_write_parameter_object_e))) { + main->setting.state.status = F_status_set_error(F_parameter); - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_write_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); } - iki_write_print_error_main_missing(setting, main->error); + iki_write_print_error_main_missing(&main->program.error); return; } - if (main->parameters.array[iki_write_parameter_wrap_e].result & f_console_result_found_e) { - setting->flag |= iki_write_main_flag_wrap_e; + if (main->program.parameters.array[iki_write_parameter_wrap_e].result & f_console_result_found_e) { + main->setting.flag |= iki_write_main_flag_wrap_e; } - setting->quote = f_iki_syntax_quote_double_s; + main->setting.quote = f_iki_syntax_quote_double_s; - if (main->parameters.array[iki_write_parameter_double_e].result & f_console_result_found_e) { - if (main->parameters.array[iki_write_parameter_single_e].result & f_console_result_found_e) { - if (main->parameters.array[iki_write_parameter_double_e].location < main->parameters.array[iki_write_parameter_single_e].location) { - setting->quote = f_iki_syntax_quote_single_s; + if (main->program.parameters.array[iki_write_parameter_double_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_write_parameter_single_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_write_parameter_double_e].location < main->program.parameters.array[iki_write_parameter_single_e].location) { + main->setting.quote = f_iki_syntax_quote_single_s; - if (main->parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { - if (main->parameters.array[iki_write_parameter_single_e].location < main->parameters.array[iki_write_parameter_backtick_e].location) { - setting->quote = f_iki_syntax_quote_backtick_s; + if (main->program.parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_write_parameter_single_e].location < main->program.parameters.array[iki_write_parameter_backtick_e].location) { + main->setting.quote = f_iki_syntax_quote_backtick_s; } } } - else if (main->parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { - if (main->parameters.array[iki_write_parameter_double_e].location < main->parameters.array[iki_write_parameter_backtick_e].location) { - setting->quote = f_iki_syntax_quote_backtick_s; + else if (main->program.parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_write_parameter_double_e].location < main->program.parameters.array[iki_write_parameter_backtick_e].location) { + main->setting.quote = f_iki_syntax_quote_backtick_s; } } } - else if (main->parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { - if (main->parameters.array[iki_write_parameter_double_e].location < main->parameters.array[iki_write_parameter_backtick_e].location) { - setting->quote = f_iki_syntax_quote_backtick_s; + else if (main->program.parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_write_parameter_double_e].location < main->program.parameters.array[iki_write_parameter_backtick_e].location) { + main->setting.quote = f_iki_syntax_quote_backtick_s; } } } - else if (main->parameters.array[iki_write_parameter_single_e].result & f_console_result_found_e) { - setting->quote = f_iki_syntax_quote_single_s; + else if (main->program.parameters.array[iki_write_parameter_single_e].result & f_console_result_found_e) { + main->setting.quote = f_iki_syntax_quote_single_s; - if (main->parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { - if (main->parameters.array[iki_write_parameter_single_e].location < main->parameters.array[iki_write_parameter_backtick_e].location) { - setting->quote = f_iki_syntax_quote_backtick_s; + if (main->program.parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[iki_write_parameter_single_e].location < main->program.parameters.array[iki_write_parameter_backtick_e].location) { + main->setting.quote = f_iki_syntax_quote_backtick_s; } } } - else if (main->parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { - setting->quote = f_iki_syntax_quote_backtick_s; + else if (main->program.parameters.array[iki_write_parameter_backtick_e].result & f_console_result_found_e) { + main->setting.quote = f_iki_syntax_quote_backtick_s; } } #endif // _di_iki_write_setting_load_ diff --git a/level_3/iki_write/c/main/common.h b/level_3/iki_write/c/main/common.h index 5b966e0..3993ef7 100644 --- a/level_3/iki_write/c/main/common.h +++ b/level_3/iki_write/c/main/common.h @@ -43,11 +43,9 @@ extern "C" { * @param arguments * The parameters passed to the process (often referred to as command line arguments). * @param main - * The main program data. - * @param setting - * The main program settings. + * The program and settings data. * - * This alters setting.state.status: + * This alters main.setting.state.status: * F_none on success. * * Errors (with error bit) from: f_console_parameter_process(). @@ -63,7 +61,7 @@ extern "C" { * @see fll_program_parameter_process_verbosity() */ #ifndef _di_iki_write_setting_load_ - extern void iki_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, iki_write_setting_t * const setting); + extern void iki_write_setting_load(const f_console_arguments_t arguments, iki_write_main_t * const main); #endif // _di_iki_write_setting_load_ /** diff --git a/level_3/iki_write/c/main/common/define.h b/level_3/iki_write/c/main/common/define.h index d155120..c1bf1f5 100644 --- a/level_3/iki_write/c/main/common/define.h +++ b/level_3/iki_write/c/main/common/define.h @@ -16,6 +16,21 @@ extern "C" { #endif +/** + * The program defines. + * + * iki_write_*: + * - allocation_console: An allocation step used for small buffers specifically for console parameter. + * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. + * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. + * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. + */ +#ifndef _di_iki_write_d_ + #define iki_write_allocation_console_d 4 + #define iki_write_allocation_large_d 256 + #define iki_write_allocation_small_d 16 + #define iki_write_signal_check_d 20000 +#endif // _di_iki_write_d_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/iki_write/c/main/common/enumeration.h b/level_3/iki_write/c/main/common/enumeration.h index e2d80de..e1dffba 100644 --- a/level_3/iki_write/c/main/common/enumeration.h +++ b/level_3/iki_write/c/main/common/enumeration.h @@ -17,6 +17,93 @@ extern "C" { #endif /** + * Flags passed to the main function or program. + * + * iki_write_main_flag_*_e: + * - none: No flags set. + * - content: The Content being written is specified. + * - copyright: Print copyright. + * - file_to: Using a specified destination file. + * - help: Print help. + * - object: The Object being written is specified. + * - 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. + * - print_last: The Object being written is specified. + * - version: Print version. + * - wrap: Wrap the vocabulary. + */ +#ifndef _di_iki_write_main_flag_e_ + enum { + iki_write_main_flag_none_e = 0x0, + iki_write_main_flag_content_e = 0x1, + iki_write_main_flag_copyright_e = 0x2, + iki_write_main_flag_file_to_e = 0x4, + iki_write_main_flag_help_e = 0x8, + iki_write_main_flag_object_e = 0x10, + iki_write_main_flag_print_first_e = 0x20, + iki_write_main_flag_print_last_e = 0x40, + iki_write_main_flag_version_e = 0x80, + iki_write_main_flag_wrap_e = 0x100, + }; // enum +#endif // _di_iki_write_main_flag_e_ + +/** + * The main program parameters. + */ +#ifndef _di_iki_write_parameter_e_ + enum { + iki_write_parameter_help_e, + iki_write_parameter_copyright_e, + iki_write_parameter_light_e, + iki_write_parameter_dark_e, + iki_write_parameter_no_color_e, + iki_write_parameter_verbosity_quiet_e, + iki_write_parameter_verbosity_error_e, + iki_write_parameter_verbosity_normal_e, + iki_write_parameter_verbosity_verbose_e, + iki_write_parameter_verbosity_debug_e, + iki_write_parameter_version_e, + iki_write_parameter_line_first_no_e, + iki_write_parameter_line_last_no_e, + + iki_write_parameter_backtick_e, + iki_write_parameter_content_e, + iki_write_parameter_double_e, + iki_write_parameter_file_e, + iki_write_parameter_object_e, + iki_write_parameter_single_e, + iki_write_parameter_wrap_e, + }; // enum + + #define iki_write_console_parameter_t_initialize \ + { \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_error_s, f_console_standard_long_error_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_normal_s, f_console_standard_long_normal_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_first_no_s, f_console_standard_long_line_first_no_s, 0, f_console_flag_inverse_e), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_last_no_s, f_console_standard_long_line_last_no_s, 0, f_console_flag_inverse_e), \ + \ + macro_f_console_parameter_t_initialize_3(iki_write_short_backtick_s, iki_write_long_backtick_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_write_short_content_s, iki_write_long_content_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_write_short_double_s, iki_write_long_double_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_write_short_file_s, iki_write_long_file_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_write_short_object_s, iki_write_long_object_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_write_short_single_s, iki_write_long_single_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(iki_write_short_wrap_s, iki_write_long_wrap_s, 0, f_console_flag_normal_e), \ + } + + #define iki_write_total_parameters_d 20 +#endif // _di_iki_write_parameter_e_ + +/** * Flags for fine-tuned print control. * * iki_write_print_flag_*_e: diff --git a/level_3/iki_write/c/main/common/print.c b/level_3/iki_write/c/main/common/print.c index 1a7d323..0b193cb 100644 --- a/level_3/iki_write/c/main/common/print.c +++ b/level_3/iki_write/c/main/common/print.c @@ -8,6 +8,7 @@ extern "C" { const f_string_t iki_write_f_a[] = { "f_console_parameter_process", "f_file_read", + "f_file_stream_open", "f_iki_object_is", "f_string_dynamic_partial_append_nulless", "f_string_dynamic_seek_to", diff --git a/level_3/iki_write/c/main/common/print.h b/level_3/iki_write/c/main/common/print.h index 4fcf11b..55e1773 100644 --- a/level_3/iki_write/c/main/common/print.h +++ b/level_3/iki_write/c/main/common/print.h @@ -41,6 +41,7 @@ extern "C" { enum { iki_write_f_f_console_parameter_process_e, iki_write_f_f_file_read_e, + iki_write_f_f_file_stream_open_e, iki_write_f_f_iki_object_is_e, iki_write_f_f_string_dynamic_partial_append_nulless_e, iki_write_f_f_string_dynamic_seek_to_e, diff --git a/level_3/iki_write/c/main/common/type.h b/level_3/iki_write/c/main/common/type.h index 489bd79..22bbd02 100644 --- a/level_3/iki_write/c/main/common/type.h +++ b/level_3/iki_write/c/main/common/type.h @@ -17,109 +17,6 @@ extern "C" { #endif /** - * The program defines. - * - * iki_write_*: - * - allocation_console: An allocation step used for small buffers specifically for console parameter. - * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. - * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. - * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. - */ -#ifndef _di_iki_write_d_ - #define iki_write_allocation_console_d 4 - #define iki_write_allocation_large_d 256 - #define iki_write_allocation_small_d 16 - #define iki_write_signal_check_d 20000 -#endif // _di_iki_write_d_ - -/** - * Flags passed to the main function or program. - * - * iki_write_main_flag_*_e: - * - none: No flags set. - * - content: The Content being written is specified. - * - copyright: Print copyright. - * - file_to: Using a specified destination file. - * - help: Print help. - * - object: The Object being written is specified. - * - 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. - * - print_last: The Object being written is specified. - * - version: Print version. - * - wrap: Wrap the vocabulary. - */ -#ifndef _di_iki_write_main_flag_e_ - enum { - iki_write_main_flag_none_e = 0x0, - iki_write_main_flag_content_e = 0x1, - iki_write_main_flag_copyright_e = 0x2, - iki_write_main_flag_file_to_e = 0x4, - iki_write_main_flag_help_e = 0x8, - iki_write_main_flag_object_e = 0x10, - iki_write_main_flag_print_first_e = 0x20, - iki_write_main_flag_print_last_e = 0x40, - iki_write_main_flag_version_e = 0x80, - iki_write_main_flag_wrap_e = 0x100, - }; // enum -#endif // _di_iki_write_main_flag_e_ - -/** - * The main program parameters. - */ -#ifndef _di_iki_write_parameter_e_ - enum { - iki_write_parameter_help_e, - iki_write_parameter_copyright_e, - iki_write_parameter_light_e, - iki_write_parameter_dark_e, - iki_write_parameter_no_color_e, - iki_write_parameter_verbosity_quiet_e, - iki_write_parameter_verbosity_error_e, - iki_write_parameter_verbosity_normal_e, - iki_write_parameter_verbosity_verbose_e, - iki_write_parameter_verbosity_debug_e, - iki_write_parameter_version_e, - iki_write_parameter_line_first_no_e, - iki_write_parameter_line_last_no_e, - - iki_write_parameter_backtick_e, - iki_write_parameter_content_e, - iki_write_parameter_double_e, - iki_write_parameter_file_e, - iki_write_parameter_object_e, - iki_write_parameter_single_e, - iki_write_parameter_wrap_e, - }; // enum - - #define iki_write_console_parameter_t_initialize \ - { \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_copyright_s, f_console_standard_long_copyright_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_error_s, f_console_standard_long_error_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_normal_s, f_console_standard_long_normal_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_first_no_s, f_console_standard_long_line_first_no_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_line_last_no_s, f_console_standard_long_line_last_no_s, 0, f_console_flag_inverse_e), \ - \ - macro_f_console_parameter_t_initialize_3(iki_write_short_backtick_s, iki_write_long_backtick_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_write_short_content_s, iki_write_long_content_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_write_short_double_s, iki_write_long_double_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_write_short_file_s, iki_write_long_file_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_write_short_object_s, iki_write_long_object_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_write_short_single_s, iki_write_long_single_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(iki_write_short_wrap_s, iki_write_long_wrap_s, 0, f_console_flag_normal_e), \ - } - - #define iki_write_total_parameters_d 20 -#endif // _di_iki_write_parameter_e_ - -/** * The iki write main program settings. * * This is passed to the program-specific main entry point to designate program settings. diff --git a/level_3/iki_write/c/main/iki_write.c b/level_3/iki_write/c/main/iki_write.c index 43eb845..666db8e 100644 --- a/level_3/iki_write/c/main/iki_write.c +++ b/level_3/iki_write/c/main/iki_write.c @@ -5,26 +5,25 @@ extern "C" { #endif #ifndef _di_iki_write_main_ - void iki_write_main(fll_program_data_t * const main, iki_write_setting_t * const setting) { + void iki_write_main(iki_write_main_t * const main) { - if (!main || !setting) return; + if (!main) return; - if (F_status_is_error(setting->state.status)) { - if ((setting->flag & iki_write_main_flag_print_last_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & iki_write_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } return; } - if ((setting->flag & iki_write_main_flag_print_first_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_write_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); } - setting->state.status = F_none; + main->setting.state.status = F_none; if (main->setting.flag & (iki_write_main_flag_help_e | iki_write_main_flag_version_e | iki_write_main_flag_copyright_e)) { - if (main->setting.flag & iki_write_main_flag_help_e) { iki_write_print_message_help(&main->program.message); } @@ -42,9 +41,9 @@ extern "C" { return; } - setting->escaped.used = 0; + main->setting.escaped.used = 0; - if (main->pipe & fll_program_data_pipe_input_e) { + if (main->program.pipe & fll_program_data_pipe_input_e) { bool object_ended = F_false; f_array_length_t previous = 0; @@ -55,60 +54,60 @@ extern "C" { pipe.id = F_type_descriptor_input_d; pipe.size_read = 1; - setting->buffer.used = 0; - setting->object.used = 0; - setting->content.used = 0; + main->setting.buffer.used = 0; + main->setting.object.used = 0; + main->setting.content.used = 0; range.start = 0; do { - if (!((++main->signal_check) % iki_write_signal_check_d)) { + if (!((++main->program.signal_check) % iki_write_signal_check_d)) { if (fll_program_standard_signal_received(&main->program)) { - setting->state.status = F_status_set_error(F_interrupt); + main->setting.state.status = F_status_set_error(F_interrupt); object_ended = F_false; break; } - main->signal_check = 0; + main->program.signal_check = 0; } if (status != F_none_eof) { - status = f_file_read(pipe, &setting->buffer); + status = f_file_read(pipe, &main->setting.buffer); if (F_status_is_error(status)) { - setting->state.status = F_status_set_error(F_pipe); + main->setting.state.status = F_status_set_error(F_pipe); - iki_write_print_error_file(setting, main->error, macro_iki_write_f(f_file_read), f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + iki_write_print_error_file(&main->program.error, macro_iki_write_f(f_file_read), f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); object_ended = F_false; break; } - if (!setting->buffer.used) { - setting->state.status = F_status_set_error(F_parameter); + if (!main->setting.buffer.used) { + main->setting.state.status = F_status_set_error(F_parameter); - fll_program_print_error_pipe_missing_content(&main->error); + fll_program_print_error_pipe_missing_content(&main->program.error); object_ended = F_false; break; } - range.stop = setting->buffer.used - 1; + range.stop = main->setting.buffer.used - 1; } previous = range.start; - setting->state.status = f_string_dynamic_seek_to(setting->buffer, f_string_ascii_feed_form_s.string[0], &range); + main->setting.state.status = f_string_dynamic_seek_to(main->setting.buffer, f_string_ascii_feed_form_s.string[0], &range); - if (setting->state.status == F_data_not_stop) { - setting->state.status = F_status_set_error(F_parameter); + if (main->setting.state.status == F_data_not_stop) { + main->setting.state.status = F_status_set_error(F_parameter); } - if (F_status_is_error(setting->state.status)) { - iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_seek_to)); + if (F_status_is_error(main->setting.state.status)) { + iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_seek_to)); object_ended = F_false; @@ -116,9 +115,9 @@ extern "C" { } if (object_ended && previous == range.start) { - setting->state.status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - fll_program_print_error_pipe_invalid_form_feed(&main->error); + fll_program_print_error_pipe_invalid_form_feed(&main->program.error); object_ended = F_false; @@ -129,13 +128,13 @@ extern "C" { range.start = previous; if (object_ended) { - setting->content.used = 0; + main->setting.content.used = 0; - if (setting->buffer.used) { - setting->state.status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->content); + if (main->setting.buffer.used) { + main->setting.state.status = f_string_dynamic_partial_append_nulless(main->setting.buffer, range, &main->setting.content); - if (F_status_is_error(setting->state.status)) { - iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_partial_append_nulless)); + if (F_status_is_error(main->setting.state.status)) { + iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_partial_append_nulless)); object_ended = F_false; @@ -143,25 +142,25 @@ extern "C" { } } - iki_write_process(main, setting, setting->object, setting->content); + iki_write_process(main, main->setting.object, main->setting.content); - if (F_status_is_error(setting->state.status)) { + if (F_status_is_error(main->setting.state.status)) { object_ended = F_false; break; } - fll_print_dynamic_raw(f_string_eol_s, main->output.to); + fll_print_dynamic_raw(f_string_eol_s, main->program.output.to); object_ended = F_false; } else { - setting->object.used = 0; + main->setting.object.used = 0; - setting->state.status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->object); + main->setting.state.status = f_string_dynamic_partial_append_nulless(main->setting.buffer, range, &main->setting.object); - if (F_status_is_error(setting->state.status)) { - iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_partial_append_nulless)); + if (F_status_is_error(main->setting.state.status)) { + iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_partial_append_nulless)); object_ended = F_false; @@ -173,45 +172,45 @@ extern "C" { // Restore the range, positioned after the new line. range.start = range.stop + 2; - range.stop = setting->buffer.used - 1; + range.stop = main->setting.buffer.used - 1; // Only clear the buffer and reset the start when the entire buffer has been processed. if (range.start > range.stop) { range.start = 0; - setting->buffer.used = 0; + main->setting.buffer.used = 0; } - } while (status != F_none_eof || setting->buffer.used || object_ended); + } while (status != F_none_eof || main->setting.buffer.used || object_ended); if (object_ended) { - setting->state.status = F_status_set_error(F_parameter); + main->setting.state.status = F_status_set_error(F_parameter); - fll_program_print_error_pipe_object_without_content(&main->error); + fll_program_print_error_pipe_object_without_content(&main->program.error); } } - if (F_status_is_error_not(setting->state.status) && F_status_set_fine(setting->state.status) != F_interrupt) { - for (f_array_length_t i = 0; i < setting->objects.used; ++i) { + if (F_status_is_error_not(main->setting.state.status) && F_status_set_fine(main->setting.state.status) != F_interrupt) { + for (f_array_length_t i = 0; i < main->setting.objects.used; ++i) { - if (!((++main->signal_check) % iki_write_signal_check_d)) { + if (!((++main->program.signal_check) % iki_write_signal_check_d)) { if (fll_program_standard_signal_received(&main->program)) { - setting->state.status = F_status_set_error(F_interrupt); + main->setting.state.status = F_status_set_error(F_interrupt); break; } - main->signal_check = 0; + main->program.signal_check = 0; } - iki_write_process(main, setting, setting->objects.array[i], setting->contents.array[i]); - if (F_status_is_error(setting->state.status)) break; + iki_write_process(main, main->setting.objects.array[i], main->setting.contents.array[i]); + if (F_status_is_error(main->setting.state.status)) break; - fll_print_dynamic_raw(f_string_eol_s, main->output.to); + fll_print_dynamic_raw(f_string_eol_s, main->program.output.to); } // for } - if ((setting->flag & iki_write_main_flag_print_last_e) && main->message.verbosity > f_console_verbosity_error_e) { - fll_print_dynamic_raw(f_string_eol_s, main->message.to); + if ((main->setting.flag & iki_write_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } } #endif // _di_iki_write_main_ diff --git a/level_3/iki_write/c/main/iki_write.h b/level_3/iki_write/c/main/iki_write.h index 64aa8ce..7c3bcfe 100644 --- a/level_3/iki_write/c/main/iki_write.h +++ b/level_3/iki_write/c/main/iki_write.h @@ -77,11 +77,9 @@ extern "C" { * - F_signal_termination * * @param main - * The main program data. - * @param setting - * The main program settings. + * The program and settings data. * - * This alters 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. @@ -97,7 +95,7 @@ extern "C" { * @see fll_iki_content_escape() */ #ifndef _di_iki_write_main_ - extern void iki_write_main(fll_program_data_t * const main, iki_write_setting_t * const setting); + extern void iki_write_main(iki_write_main_t * const main); #endif // _di_iki_write_main_ #ifdef __cplusplus diff --git a/level_3/iki_write/c/main/main.c b/level_3/iki_write/c/main/main.c index f79a08d..309567e 100644 --- a/level_3/iki_write/c/main/main.c +++ b/level_3/iki_write/c/main/main.c @@ -15,29 +15,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.debug.custom = (void *) &data; f_console_parameter_t parameters[] = iki_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = iki_write_total_parameters_d; - data.environment = envp; + data.program.parameters.array = parameters; + data.program.parameters.used = iki_write_total_parameters_d; + data.program.environment = envp; if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; + data.program.pipe = fll_program_data_pipe_input_e; } - fll_program_standard_set_up(&data); + fll_program_standard_set_up(&data.program); { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - iki_write_setting_load(arguments, &data, &setting); + iki_write_setting_load(arguments, &data); } - iki_write_main(&data, &setting); + iki_write_main(&data); - iki_write_setting_unload(&data, &setting); + iki_write_setting_unload(&data); - fll_program_data_delete(&data); + fll_program_data_delete(&data.program); - fll_program_standard_set_down(&data); + fll_program_standard_set_down(&data.program); - return F_status_is_error(setting.state.status) ? 1 : 0; + return F_status_is_error(data.setting.state.status) ? 1 : 0; } diff --git a/level_3/iki_write/c/main/print.c b/level_3/iki_write/c/main/print.c deleted file mode 100644 index 4f5b6fc..0000000 --- a/level_3/iki_write/c/main/print.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "iki_write.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_iki_write_print_help_ - f_status_t iki_write_print_help(fl_print_t * const print) { - - if (!setting) return F_status_set_error(F_output_not); - - f_file_stream_lock(print->to); - - fll_program_print_help_header(print, iki_write_program_name_long_s, iki_write_program_version_s); - - fll_program_print_help_option(print, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print this help message."); - fll_program_print_help_option(print, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(print, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(print, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, "Do not print using color."); - fll_program_print_help_option(print, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Decrease verbosity, silencing most output."); - fll_program_print_help_option(print, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Decrease verbosity, using only error output."); - fll_program_print_help_option(print, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Set verbosity to normal."); - fll_program_print_help_option(print, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Increase verbosity beyond normal output."); - fll_program_print_help_option(print, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Enable debugging, significantly increasing verbosity beyond normal output."); - fll_program_print_help_option(print, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Print only the version number."); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fll_program_print_help_option(print, iki_write_short_backtick_s, iki_write_long_backtick_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Use backtick for quotes."); - fll_program_print_help_option(print, iki_write_short_content_s, iki_write_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Content to write."); - fll_program_print_help_option(print, iki_write_short_double_s, iki_write_long_double_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use double quotes (default)."); - fll_program_print_help_option(print, iki_write_short_file_s, iki_write_long_file_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a file to send data to."); - fll_program_print_help_option(print, iki_write_short_object_s, iki_write_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Object to write."); - fll_program_print_help_option(print, iki_write_short_single_s, iki_write_long_single_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use single quotes."); - fll_program_print_help_option(print, iki_write_short_wrap_s, iki_write_long_wrap_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Wrap the vocabulary name."); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fll_program_print_help_usage(print, iki_write_program_name_s, f_string_empty_s); - - fl_print_format("%r %[Notes:%]%r", print->to, f_string_eol_s, print->set->important, print->set->important, f_string_eol_s); - fl_print_format(" This program will accept Object and Content strings to generate an IKI string, such as %[object:\"content\"%].%r", print->to, print->set->notable, print->set->notable, f_string_eol_s); - fl_print_format(" Each Object must have a Content (and each Content must have an Object).%r%r", print->to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The Object is also called the Vocabulary.%r", print->to, f_string_eol_s); - fl_print_format(" A complete Object and Content set is also called a Variable.%r%r", print->to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When piping main to this program, a single form-feed character (\\f) (U+000C) must be used to separate each Object from each Content.%r", print->to, f_string_eol_s); - fl_print_format(" Furthermore, each Object must be followed by a Content.%r", print->to, f_string_eol_s); - - f_file_stream_flush(print->to); - f_file_stream_unlock(print->to); - - return F_none; - } -#endif // _di_iki_write_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/iki_write/c/main/print.h b/level_3/iki_write/c/main/print.h deleted file mode 100644 index 608c5db..0000000 --- a/level_3/iki_write/c/main/print.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: UTF8 - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the print functionality. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _iki_write_print_h -#define _iki_write_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print help. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - * - * @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. - */ -#ifndef _di_iki_write_print_help_ - extern f_status_t iki_write_print_help(fl_print_t * const print); -#endif // _di_iki_write_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _iki_write_print_h diff --git a/level_3/iki_write/c/main/print/data.c b/level_3/iki_write/c/main/print/data.c deleted file mode 100644 index 192b528..0000000 --- a/level_3/iki_write/c/main/print/data.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "../iki_write.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/iki_write/c/main/print/data.h b/level_3/iki_write/c/main/print/data.h deleted file mode 100644 index 80df6dd..0000000 --- a/level_3/iki_write/c/main/print/data.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: IKI Write - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the print error functionality. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _iki_write_print_data_h -#define _iki_write_print_data_h - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _iki_write_print_data_h diff --git a/level_3/iki_write/c/main/print/error.c b/level_3/iki_write/c/main/print/error.c index 32daaad..2287577 100644 --- a/level_3/iki_write/c/main/print/error.c +++ b/level_3/iki_write/c/main/print/error.c @@ -7,10 +7,10 @@ extern "C" { #ifndef _di_iki_write_print_error_ f_status_t iki_write_print_error(fl_print_t * const print, const f_string_t function) { - if (!print) return F_status_set_error(F_output_not); + if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(((iki_write_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e); return F_none; } @@ -19,10 +19,12 @@ extern "C" { #ifndef _di_iki_write_print_error_file_ f_status_t iki_write_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { - if (!print) return F_status_set_error(F_output_not); + if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type); + iki_write_main_t * const main = (iki_write_main_t *) print->custom; + + fll_error_file_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type); return F_none; } diff --git a/level_3/iki_write/c/main/print/message.c b/level_3/iki_write/c/main/print/message.c index 192b528..5d480d8 100644 --- a/level_3/iki_write/c/main/print/message.c +++ b/level_3/iki_write/c/main/print/message.c @@ -4,6 +4,57 @@ extern "C" { #endif +#ifndef _di_iki_write_print_message_help_ + f_status_t iki_write_print_message_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, iki_write_program_name_long_s, iki_write_program_version_s); + + fll_program_print_help_option(print, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print this help message."); + fll_program_print_help_option(print, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Output using colors that show up better on dark backgrounds."); + fll_program_print_help_option(print, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(print, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, "Do not print using color."); + fll_program_print_help_option(print, f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Decrease verbosity, silencing most output."); + fll_program_print_help_option(print, f_console_standard_short_error_s, f_console_standard_long_error_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Decrease verbosity, using only error output."); + fll_program_print_help_option(print, f_console_standard_short_normal_s, f_console_standard_long_normal_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Set verbosity to normal."); + fll_program_print_help_option(print, f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Increase verbosity beyond normal output."); + fll_program_print_help_option(print, f_console_standard_short_debug_s, f_console_standard_long_debug_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Enable debugging, significantly increasing verbosity beyond normal output."); + fll_program_print_help_option(print, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, " Print only the version number."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_option(print, iki_write_short_backtick_s, iki_write_long_backtick_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Use backtick for quotes."); + fll_program_print_help_option(print, iki_write_short_content_s, iki_write_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Content to write."); + fll_program_print_help_option(print, iki_write_short_double_s, iki_write_long_double_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use double quotes (default)."); + fll_program_print_help_option(print, iki_write_short_file_s, iki_write_long_file_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a file to send data to."); + fll_program_print_help_option(print, iki_write_short_object_s, iki_write_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Object to write."); + fll_program_print_help_option(print, iki_write_short_single_s, iki_write_long_single_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use single quotes."); + fll_program_print_help_option(print, iki_write_short_wrap_s, iki_write_long_wrap_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Wrap the vocabulary name."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, iki_write_program_name_s, f_string_empty_s); + + fl_print_format("%r %[Notes:%]%r", print->to, f_string_eol_s, print->set->important, print->set->important, f_string_eol_s); + fl_print_format(" This program will accept Object and Content strings to generate an IKI string, such as %[object:\"content\"%].%r", print->to, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" Each Object must have a Content (and each Content must have an Object).%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The Object is also called the Vocabulary.%r", print->to, f_string_eol_s); + fl_print_format(" A complete Object and Content set is also called a Variable.%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" When piping main to this program, a single form-feed character (\\f) (U+000C) must be used to separate each Object from each Content.%r", print->to, f_string_eol_s); + fl_print_format(" Furthermore, each Object must be followed by a Content.%r", print->to, f_string_eol_s); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_iki_write_print_message_help_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_write/c/main/print/message.h b/level_3/iki_write/c/main/print/message.h index 1782622..ccccd94 100644 --- a/level_3/iki_write/c/main/print/message.h +++ b/level_3/iki_write/c/main/print/message.h @@ -16,6 +16,24 @@ extern "C" { #endif +/** + * Print help. + * + * @param print + * The output structure to print to. + * + * 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. + */ +#ifndef _di_iki_write_print_message_help_ + extern f_status_t iki_write_print_message_help(fl_print_t * const print); +#endif // _di_iki_write_print_message_help_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_write/c/main/process.c b/level_3/iki_write/c/main/process.c index 04911da..d0b9c24 100644 --- a/level_3/iki_write/c/main/process.c +++ b/level_3/iki_write/c/main/process.c @@ -5,47 +5,47 @@ extern "C" { #endif #ifndef _di_iki_write_process_ - void iki_write_process(fll_program_data_t * const main, iki_write_setting_t * const setting, const f_string_static_t object, const f_string_static_t content) { + void iki_write_process(iki_write_main_t * const main, const f_string_static_t object, const f_string_static_t content) { if (!object.used) { - setting->state.status = F_status_set_error(F_failure); + main->setting.state.status = F_status_set_error(F_failure); - fll_program_print_error_missing_variable_not_zero(&main->error, iki_write_object_s); + fll_program_print_error_missing_variable_not_zero(&main->program.error, iki_write_object_s); return; } - setting->state.status = f_iki_object_is(object); + main->setting.state.status = f_iki_object_is(object); - if (setting->state.status == F_false) { - setting->state.status = F_status_set_error(F_failure); + if (main->setting.state.status == F_false) { + main->setting.state.status = F_status_set_error(F_failure); - iki_write_print_error_object_not_valid(setting, main->error, object); + iki_write_print_error_object_not_valid(&main->program.error, object); return; } - if (F_status_is_error(setting->state.status)) { - iki_write_print_error(setting, main->error, macro_iki_write_f(f_iki_object_is)); + if (F_status_is_error(main->setting.state.status)) { + iki_write_print_error(&main->program.error, macro_iki_write_f(f_iki_object_is)); return; } - setting->escaped.used = 0; + main->setting.escaped.used = 0; - setting->state.status = fll_iki_content_escape(content, setting->quote, &setting->escaped); + main->setting.state.status = fll_iki_content_escape(content, main->setting.quote, &main->setting.escaped); - if (F_status_is_error(setting->state.status)) { - iki_write_print_error(setting, main->error, macro_iki_write_f(fll_iki_content_escape)); + if (F_status_is_error(main->setting.state.status)) { + iki_write_print_error(&main->program.error, macro_iki_write_f(fll_iki_content_escape)); return; } - if (setting->flag & iki_write_main_flag_wrap_e) { - fl_print_format("%r%Q%r%r%r%Q%r", main->output.to, f_iki_syntax_wrap_open_s, object, f_iki_syntax_wrap_close_s, f_iki_syntax_separator_s, setting->quote, setting->escaped, setting->quote); + if (main->setting.flag & iki_write_main_flag_wrap_e) { + fl_print_format("%r%Q%r%r%r%Q%r", main->program.output.to, f_iki_syntax_wrap_open_s, object, f_iki_syntax_wrap_close_s, f_iki_syntax_separator_s, main->setting.quote, main->setting.escaped, main->setting.quote); } else { - fl_print_format("%Q%r%r%Q%r", main->output.to, object, f_iki_syntax_separator_s, setting->quote, setting->escaped, setting->quote); + fl_print_format("%Q%r%r%Q%r", main->program.output.to, object, f_iki_syntax_separator_s, main->setting.quote, main->setting.escaped, main->setting.quote); } } #endif // _di_iki_write_process_ diff --git a/level_3/iki_write/c/main/process.h b/level_3/iki_write/c/main/process.h index 9b01726..f8e2a9e 100644 --- a/level_3/iki_write/c/main/process.h +++ b/level_3/iki_write/c/main/process.h @@ -20,11 +20,9 @@ extern "C" { * Process a given object and content, printing the IKI if valid or an error if invalid. * * @param main - * The main program data. - * @param setting - * The main program settings. + * The program and settings data. * - * This alters setting.state.status: + * This alters main.setting.state.status: * F_none on success. * * Errors (with error bit) from: f_iki_object_is(). @@ -40,7 +38,7 @@ extern "C" { * @see fll_iki_content_escape() */ #ifndef _di_iki_write_process_ - extern void iki_write_process(fll_program_data_t * const main, iki_write_setting_t * const setting, const f_string_static_t object, const f_string_static_t content) F_attribute_visibility_internal_d; + extern void iki_write_process(iki_write_main_t * const main, const f_string_static_t object, const f_string_static_t content) F_attribute_visibility_internal_d; #endif // _di_iki_write_process_ #ifdef __cplusplus diff --git a/level_3/status_code/c/main/common.h b/level_3/status_code/c/main/common.h index d014341..55552fc 100644 --- a/level_3/status_code/c/main/common.h +++ b/level_3/status_code/c/main/common.h @@ -43,7 +43,7 @@ extern "C" { * @param arguments * The parameters passed to the process (often referred to as command line arguments). * @param main - * The main program and settings data. + * The program and settings data. * * This alters setting.state.status: * F_none on success. diff --git a/level_3/status_code/c/main/print/error.c b/level_3/status_code/c/main/print/error.c index aaa50d4..e45ca9d 100644 --- a/level_3/status_code/c/main/print/error.c +++ b/level_3/status_code/c/main/print/error.c @@ -10,9 +10,7 @@ extern "C" { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - status_code_main_t * const main = (status_code_main_t *) print->custom; - - fll_error_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(((status_code_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e); return F_none; } diff --git a/level_3/status_code/c/main/status_code.c b/level_3/status_code/c/main/status_code.c index e8a4518..f1e1af1 100644 --- a/level_3/status_code/c/main/status_code.c +++ b/level_3/status_code/c/main/status_code.c @@ -42,7 +42,6 @@ extern "C" { main->setting.state.status = F_none; if (main->setting.flag & (status_code_main_flag_help_e | status_code_main_flag_version_e | status_code_main_flag_copyright_e)) { - if (main->setting.flag & status_code_main_flag_help_e) { status_code_print_message_help(&main->program.message); } diff --git a/level_3/utf8/c/main/bytesequence.h b/level_3/utf8/c/main/bytesequence.h index 8398a14..81bfb77 100644 --- a/level_3/utf8/c/main/bytesequence.h +++ b/level_3/utf8/c/main/bytesequence.h @@ -22,7 +22,7 @@ extern "C" { * This automatically determines the output format and is also handles the verify process. * * @param main - * The main program and settings data. + * The program and settings data. * * This alters setting.state.status: * F_none on success. @@ -43,7 +43,7 @@ extern "C" { * Process file as a bytesequence input, handling conversion or verification as appropriate. * * @param main - * The main program and settings data. + * The program and settings data. * * This alters setting.state.status: * F_true on success and is valid. diff --git a/level_3/utf8/c/main/codepoint.h b/level_3/utf8/c/main/codepoint.h index d939cac..d27cb52 100644 --- a/level_3/utf8/c/main/codepoint.h +++ b/level_3/utf8/c/main/codepoint.h @@ -22,7 +22,7 @@ extern "C" { * This automatically determines the output format and also handles the verify process. * * @param main - * The main program and settings data. + * The program and settings data. * * This alters setting.state.status: * F_none on success. @@ -48,7 +48,7 @@ extern "C" { * This automatically determines the output format and also handles the verify process. * * @param main - * The main program and settings data. + * The program and settings data. * * This alters setting.state.status: * F_none on success. @@ -72,7 +72,7 @@ extern "C" { * Detect a codepoint character. * * @param main - * The main program and settings data. + * The program and settings data. * * This alters setting.state.status: * F_none on success. @@ -93,7 +93,7 @@ extern "C" { * Process file as a codepoint input, handling conversion or verification as appropriate. * * @param main - * The main program and settings data. + * The program and settings data. * * This alters setting.state.status: * F_true on success and is valid. diff --git a/level_3/utf8/c/main/print/error.c b/level_3/utf8/c/main/print/error.c index eeb3952..79f8c54 100644 --- a/level_3/utf8/c/main/print/error.c +++ b/level_3/utf8/c/main/print/error.c @@ -10,9 +10,7 @@ extern "C" { if (!print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - utf8_main_t * const main = (utf8_main_t *) print->custom; - - fll_error_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(((utf8_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e); return F_none; } diff --git a/level_3/utf8/c/main/process.h b/level_3/utf8/c/main/process.h index c643cce..87cb4b3 100644 --- a/level_3/utf8/c/main/process.h +++ b/level_3/utf8/c/main/process.h @@ -20,7 +20,7 @@ extern "C" { * Convert the text from one format to other another format or verify text. * * @param main - * The main program and settings data. + * The program and settings data. * * This alters setting.state.status: * F_true on success and is valid. diff --git a/level_3/utf8/c/main/utf8.c b/level_3/utf8/c/main/utf8.c index 6986a70..757006d 100644 --- a/level_3/utf8/c/main/utf8.c +++ b/level_3/utf8/c/main/utf8.c @@ -24,7 +24,6 @@ extern "C" { main->setting.state.status = F_none; if (main->setting.flag & (utf8_main_flag_help_e | utf8_main_flag_version_e | utf8_main_flag_copyright_e)) { - if (main->setting.flag & utf8_main_flag_help_e) { utf8_print_message_help(&main->program.message); }