From: Kevin Day Date: Sat, 3 Dec 2022 01:30:28 +0000 (-0600) Subject: Cleanup: Remove fss_payload_write. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=45adb848d3eed0dcc61b5d2dc112ad6ae0ef9283;p=fll Cleanup: Remove fss_payload_write. This is now part of fss_write. --- diff --git a/level_3/fss_payload_write/c/common.c b/level_3/fss_payload_write/c/common.c deleted file mode 100644 index 1dfcb4e..0000000 --- a/level_3/fss_payload_write/c/common.c +++ /dev/null @@ -1,494 +0,0 @@ -#include "fss_payload_write.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_write_program_version_ - const f_string_static_t fss_payload_write_program_version_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_version_s, 0, FSS_PAYLOAD_WRITE_program_version_s_length); -#endif // _di_fss_payload_write_program_version_ - -#ifndef _di_fss_payload_write_program_name_ - const f_string_static_t fss_payload_write_program_name_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_name_s, 0, FSS_PAYLOAD_WRITE_program_name_s_length); - const f_string_static_t fss_payload_write_program_name_long_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_program_name_long_s, 0, FSS_PAYLOAD_WRITE_program_name_long_s_length); -#endif // _di_fss_payload_write_program_name_ - -#ifndef _di_fss_payload_write_defines_ - const f_string_static_t fss_payload_write_pipe_content_end_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_pipe_content_end_s, 0, FSS_PAYLOAD_WRITE_pipe_content_end_s_length); - const f_string_static_t fss_payload_write_pipe_content_ignore_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_pipe_content_ignore_s, 0, FSS_PAYLOAD_WRITE_pipe_content_ignore_s_length); - const f_string_static_t fss_payload_write_pipe_content_start_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_pipe_content_start_s, 0, FSS_PAYLOAD_WRITE_pipe_content_start_s_length); -#endif // _di_fss_payload_write_defines_ - -#ifndef _di_fss_payload_write_strings_ - const f_string_static_t fss_payload_write_string_two_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_string_two_s, 0, FSS_PAYLOAD_WRITE_string_two_s_length); -#endif // _di_fss_payload_write_strings_ - -#ifndef _di_fss_payload_write_parameters_ - const f_string_static_t fss_payload_write_short_file_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_file_s, 0, FSS_PAYLOAD_WRITE_short_file_s_length); - const f_string_static_t fss_payload_write_short_content_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_content_s, 0, FSS_PAYLOAD_WRITE_short_content_s_length); - const f_string_static_t fss_payload_write_short_double_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_double_s, 0, FSS_PAYLOAD_WRITE_short_double_s_length); - const f_string_static_t fss_payload_write_short_ignore_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_ignore_s, 0, FSS_PAYLOAD_WRITE_short_ignore_s_length); - const f_string_static_t fss_payload_write_short_object_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_object_s, 0, FSS_PAYLOAD_WRITE_short_object_s_length); - const f_string_static_t fss_payload_write_short_partial_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_partial_s, 0, FSS_PAYLOAD_WRITE_short_partial_s_length); - const f_string_static_t fss_payload_write_short_prepend_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_prepend_s, 0, FSS_PAYLOAD_WRITE_short_prepend_s_length); - const f_string_static_t fss_payload_write_short_single_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_single_s, 0, FSS_PAYLOAD_WRITE_short_single_s_length); - const f_string_static_t fss_payload_write_short_trim_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_short_trim_s, 0, FSS_PAYLOAD_WRITE_short_trim_s_length); - - const f_string_static_t fss_payload_write_long_file_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_file_s, 0, FSS_PAYLOAD_WRITE_long_file_s_length); - const f_string_static_t fss_payload_write_long_content_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_content_s, 0, FSS_PAYLOAD_WRITE_long_content_s_length); - const f_string_static_t fss_payload_write_long_double_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_double_s, 0, FSS_PAYLOAD_WRITE_long_double_s_length); - const f_string_static_t fss_payload_write_long_ignore_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_ignore_s, 0, FSS_PAYLOAD_WRITE_long_ignore_s_length); - const f_string_static_t fss_payload_write_long_object_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_object_s, 0, FSS_PAYLOAD_WRITE_long_object_s_length); - const f_string_static_t fss_payload_write_long_partial_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_partial_s, 0, FSS_PAYLOAD_WRITE_long_partial_s_length); - const f_string_static_t fss_payload_write_long_prepend_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_prepend_s, 0, FSS_PAYLOAD_WRITE_long_prepend_s_length); - const f_string_static_t fss_payload_write_long_single_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_single_s, 0, FSS_PAYLOAD_WRITE_long_single_s_length); - const f_string_static_t fss_payload_write_long_trim_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_trim_s, 0, FSS_PAYLOAD_WRITE_long_trim_s_length); -#endif // _di_fss_payload_write_parameters_ - -#ifndef _di_fss_payload_write_setting_delete_ - f_status_t fss_payload_write_setting_delete(fss_payload_write_setting_t * const setting) { - - if (!setting) return F_status_set_error(F_parameter); - - f_string_dynamic_resize(0, &setting->escaped); - f_string_dynamic_resize(0, &setting->block); - f_string_dynamic_resize(0, &setting->buffer); - f_string_dynamic_resize(0, &setting->object); - f_string_dynamic_resize(0, &setting->content); - f_string_dynamic_resize(0, &setting->prepend); - - f_string_ranges_resize(0, &setting->ignores); - f_string_dynamics_resize(0, &setting->objects); - f_string_dynamics_resize(0, &setting->contents); - - return F_none; - } -#endif // _di_fss_payload_write_setting_delete_ - -#ifndef _di_fss_payload_write_setting_load_ - void fss_payload_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_write_setting_t * const setting) { - - if (!main || !setting) return; - - setting->flag = 0; - - // Load parameters. - setting->status = f_console_parameter_process(arguments, &main->parameters); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "f_console_parameter_process"); - - return; - } - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_payload_write_parameter_no_color_e, fss_payload_write_parameter_light_e, fss_payload_write_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - const uint8_t modes[3] = { f_color_mode_color_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "fll_program_parameter_process_context"); - - return; - } - } - - if (main->parameters.array[fss_payload_write_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->line_first = f_string_empty_s; - } - else { - setting->line_first = f_string_eol_s; - } - - if (main->parameters.array[fss_payload_write_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->line_last = f_string_empty_s; - } - else { - setting->line_last = f_string_eol_s; - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_payload_write_parameter_verbosity_quiet_e, fss_payload_write_parameter_verbosity_error_e, fss_payload_write_parameter_verbosity_verbose_e, fss_payload_write_parameter_verbosity_debug_e, fss_payload_write_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - 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->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "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; - - if (main->parameters.array[fss_payload_write_parameter_help_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_write_main_flag_help_e; - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_version_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_write_main_flag_version_e; - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_file_e].result & f_console_result_value_e && main->parameters.array[fss_payload_write_parameter_file_e].values.used) { - if (main->parameters.array[fss_payload_write_parameter_file_e].values.used > 1) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_must_specify_once(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_file_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_file_e].values.array[0]; - - main->output.to.id = -1; - main->output.to.stream = 0; - - setting->status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error_file(setting, main->error, "f_file_stream_open", main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); - - return; - } - - setting->flag |= fss_payload_write_main_flag_file_to_e; - } - else if (main->parameters.array[fss_payload_write_parameter_file_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_file_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_object_e].result & f_console_result_value_e && main->parameters.array[fss_payload_write_parameter_object_e].values.used) { - f_array_lengths_t * const values = &main->parameters.array[fss_payload_write_parameter_object_e].values; - - setting->objects.used = 0; - - setting->status = f_string_dynamics_resize(values->used, &setting->objects); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "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; ) { - - index = values->array[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; - } // for - - setting->flag |= fss_payload_write_main_flag_object_e; - } - else if (main->parameters.array[fss_payload_write_parameter_object_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_object_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_content_e].result & f_console_result_value_e && main->parameters.array[fss_payload_write_parameter_content_e].values.used) { - f_array_lengths_t * const values = &main->parameters.array[fss_payload_write_parameter_content_e].values; - - setting->contents.used = 0; - - setting->status = f_string_dynamics_resize(values->used, &setting->contents); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "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; ) { - - index = values->array[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; - } // for - - setting->flag |= fss_payload_write_main_flag_content_e; - } - else if (main->parameters.array[fss_payload_write_parameter_content_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_content_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_prepend_e].result & f_console_result_value_e && main->parameters.array[fss_payload_write_parameter_prepend_e].values.used) { - const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_prepend_e].values.array[main->parameters.array[fss_payload_write_parameter_prepend_e].values.used - 1]; - - setting->prepend.used = 0; - - setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->prepend); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "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); - f_state_t state = f_state_t_initialize; - - for (; range.start < main->parameters.arguments.array[index].used; range.start++) { - - setting->status = f_fss_is_space(state, main->parameters.arguments.array[index], range); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "f_fss_is_space"); - - return; - } - - if (setting->status == F_false) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_error_prepend_only_whitespace(setting, main->error); - - return; - } - } // for - } - - setting->flag |= fss_payload_write_main_flag_prepend_e; - } - else if (main->parameters.array[fss_payload_write_parameter_prepend_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_prepend_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_ignore_e].result & f_console_result_value_e && main->parameters.array[fss_payload_write_parameter_ignore_e].values.used) { - - if (main->parameters.array[fss_payload_write_parameter_ignore_e].values.used % 2 != 0) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value_requires_amount(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_ignore_s, fss_payload_write_string_two_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - setting->ignores.used = 0; - - setting->status = f_string_ranges_increase_by(main->parameters.array[fss_payload_write_parameter_ignore_e].values.used / 2, &setting->ignores); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "f_string_ranges_increase_by"); - - return; - } - - f_array_length_t index = 0; - - for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_write_parameter_ignore_e].values.used; i += 2) { - - index = main->parameters.array[fss_payload_write_parameter_ignore_e].values.array[i]; - - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->ignores.array[setting->ignores.used].start); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_integer_not(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_ignore_s, main->parameters.arguments.array[index]); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - index = main->parameters.array[fss_payload_write_parameter_ignore_e].values.array[i + 1]; - - setting->status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->parameters.arguments.array[index], &setting->ignores.array[setting->ignores.used].stop); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_integer_not(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_ignore_s, main->parameters.arguments.array[index]); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (setting->ignores.array[setting->ignores.used].stop > setting->ignores.array[setting->ignores.used].start) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_range_start_before_stop(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_ignore_s, main->parameters.arguments.array[main->parameters.array[fss_payload_write_parameter_ignore_e].values.array[i]], main->parameters.arguments.array[index]); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - ++setting->ignores.used; - } // for - - setting->flag |= fss_payload_write_main_flag_ignore_e; - } - else if (main->parameters.array[fss_payload_write_parameter_ignore_e].result & f_console_result_found_e) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_ignore_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_partial_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_write_main_flag_partial_e; - } - - if (setting->flag & (fss_payload_write_main_flag_object_e | fss_payload_write_main_flag_content_e)) { - if (setting->flag & fss_payload_write_main_flag_object_e) { - if (main->parameters.array[fss_payload_write_parameter_object_e].locations.used != main->parameters.array[fss_payload_write_parameter_object_e].values.used) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_object_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_content_e].locations.used != main->parameters.array[fss_payload_write_parameter_content_e].values.used) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, fss_payload_write_long_content_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (main->parameters.array[fss_payload_write_parameter_object_e].locations.used != main->parameters.array[fss_payload_write_parameter_content_e].locations.used && !(setting->flag & fss_payload_write_main_flag_partial_e)) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_both_specified_same_amount_without(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_payload_write_long_object_s, fss_payload_write_long_content_s, fss_payload_write_long_partial_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if ((setting->flag & fss_payload_write_main_flag_content_e) && (setting->flag & fss_payload_write_main_flag_partial_e)) { - if (main->parameters.array[fss_payload_write_parameter_content_e].result & f_console_result_value_e) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - 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_payload_write_long_partial_s, fss_payload_write_long_object_s, fss_payload_write_long_content_s); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - } - - if (setting->flag & fss_payload_write_main_flag_content_e) { - f_array_length_t location_object = 0; - f_array_length_t location_content = 0; - f_array_length_t location_sub_object = 0; - f_array_length_t location_sub_content = 0; - - for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_write_parameter_object_e].locations.used; ++i) { - - location_object = main->parameters.array[fss_payload_write_parameter_object_e].locations.array[i]; - location_content = main->parameters.array[fss_payload_write_parameter_content_e].locations.array[i]; - location_sub_object = main->parameters.array[fss_payload_write_parameter_object_e].locations_sub.array[i]; - location_sub_content = main->parameters.array[fss_payload_write_parameter_content_e].locations_sub.array[i]; - - if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) { - setting->status = F_status_set_error(F_parameter); - - fss_payload_write_print_line_first_locked(setting, main->error); - fss_payload_write_print_error_object_not_before_content(setting, main->error); - fss_payload_write_print_line_last_locked(setting, main->error); - - break; - } - } // for - } - } - } - - setting->quote = f_fss_quote_double_s; - - if (main->parameters.array[fss_payload_write_parameter_double_e].result & f_console_result_found_e) { - if (main->parameters.array[fss_payload_write_parameter_single_e].result & f_console_result_found_e) { - if (main->parameters.array[fss_payload_write_parameter_double_e].location < main->parameters.array[fss_payload_write_parameter_single_e].location) { - setting->quote = f_fss_quote_single_s; - } - } - } - else if (main->parameters.array[fss_payload_write_parameter_single_e].result & f_console_result_found_e) { - setting->quote = f_fss_quote_single_s; - } - - if (main->parameters.array[fss_payload_write_parameter_trim_e].result & f_console_result_found_e) { - setting->flag |= fss_payload_write_main_flag_trim_e; - } - - if (!(setting->flag & (fll_program_data_pipe_input_e | fss_payload_write_main_flag_content_e | fss_payload_write_parameter_object_e))) { - setting->status = F_data_not; - } - } -#endif // _di_fss_payload_write_setting_load_ - -#ifndef _di_fss_payload_write_setting_unload_ - f_status_t fss_payload_write_setting_unload(fll_program_data_t * const main, fss_payload_write_setting_t * const setting) { - - if (!main || !setting) return F_status_set_error(F_parameter); - - fss_payload_write_setting_delete(setting); - - return F_none; - } -#endif // _di_fss_payload_write_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_write/c/common.h b/level_3/fss_payload_write/c/common.h deleted file mode 100644 index 72a9596..0000000 --- a/level_3/fss_payload_write/c/common.h +++ /dev/null @@ -1,405 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Payload 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_payload_write_common_h -#define _fss_payload_write_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The program version. - */ -#ifndef _di_fss_payload_write_program_version_ - #define FSS_PAYLOAD_WRITE_program_version_major_s F_string_ascii_0_s - #define FSS_PAYLOAD_WRITE_program_version_minor_s F_string_ascii_7_s - #define FSS_PAYLOAD_WRITE_program_version_micro_s F_string_ascii_0_s - - #define FSS_PAYLOAD_WRITE_program_version_major_s_length F_string_ascii_0_s_length - #define FSS_PAYLOAD_WRITE_program_version_minor_s_length F_string_ascii_7_s_length - #define FSS_PAYLOAD_WRITE_program_version_micro_s_length F_string_ascii_0_s_length - - #if !(defined(FSS_PAYLOAD_WRITE_program_version_nano_prefix_s) && defined(FSS_PAYLOAD_WRITE_program_version_nano_prefix_s_length)) - #define FSS_PAYLOAD_WRITE_program_version_nano_prefix_s - #define FSS_PAYLOAD_WRITE_program_version_nano_prefix_s_length 0 - #endif // !(defined(FSS_PAYLOAD_WRITE_program_version_nano_prefix_s) && defined(FSS_PAYLOAD_WRITE_program_version_nano_prefix_s_length)) - - #if !(defined(FSS_PAYLOAD_WRITE_program_version_nano_s) && defined(FSS_PAYLOAD_WRITE_program_version_nano_s_length)) - #define FSS_PAYLOAD_WRITE_program_version_nano_s - #define FSS_PAYLOAD_WRITE_program_version_nano_s_length 0 - #endif // !(defined(FSS_PAYLOAD_WRITE_program_version_nano_s) && defined(FSS_PAYLOAD_WRITE_program_version_nano_s_length)) - - #define FSS_PAYLOAD_WRITE_program_version_s FSS_PAYLOAD_WRITE_program_version_major_s F_string_ascii_period_s FSS_PAYLOAD_WRITE_program_version_minor_s F_string_ascii_period_s FSS_PAYLOAD_WRITE_program_version_micro_s FSS_PAYLOAD_WRITE_program_version_nano_prefix_s FSS_PAYLOAD_WRITE_program_version_nano_s - - #define FSS_PAYLOAD_WRITE_program_version_s_length FSS_PAYLOAD_WRITE_program_version_major_s_length + F_string_ascii_period_s_length + FSS_PAYLOAD_WRITE_program_version_minor_s_length + F_string_ascii_period_s_length + FSS_PAYLOAD_WRITE_program_version_micro_s_length + FSS_PAYLOAD_WRITE_program_version_nano_prefix_s_length + FSS_PAYLOAD_WRITE_program_version_nano_s_length - - extern const f_string_static_t fss_payload_write_program_version_s; -#endif // _di_fss_payload_write_program_version_ - -/** - * The program name. - */ -#ifndef _di_fss_payload_write_program_name_ - #define FSS_PAYLOAD_WRITE_program_name_s "fss_payload_write" - #define FSS_PAYLOAD_WRITE_program_name_long_s "FSS Payload Write" - - #define FSS_PAYLOAD_WRITE_program_name_s_length 17 - #define FSS_PAYLOAD_WRITE_program_name_long_s_length 17 - - extern const f_string_static_t fss_payload_write_program_name_s; - extern const f_string_static_t fss_payload_write_program_name_long_s; -#endif // _di_fss_payload_write_program_name_ - -/** - * The program defines. - * - * payload_write_common_allocation_*: - * - large: An allocation step used for buffers that are anticipated to have large buffers. - * - small: An allocation step used for buffers that are anticipated to have small buffers. - */ -#ifndef _di_fss_payload_write_defines_ - #define fss_payload_write_signal_check_d 20000 - - #define fss_payload_write_common_allocation_large_d 2048 - #define fss_payload_write_common_allocation_small_d 128 - - #define FSS_PAYLOAD_WRITE_pipe_content_end_s "\f" - #define FSS_PAYLOAD_WRITE_pipe_content_ignore_s "\v" - #define FSS_PAYLOAD_WRITE_pipe_content_start_s "\b" - - #define FSS_PAYLOAD_WRITE_pipe_content_end_s_length 1 - #define FSS_PAYLOAD_WRITE_pipe_content_ignore_s_length 1 - #define FSS_PAYLOAD_WRITE_pipe_content_start_s_length 1 - - extern const f_string_static_t fss_payload_write_pipe_content_end_s; - extern const f_string_static_t fss_payload_write_pipe_content_ignore_s; - extern const f_string_static_t fss_payload_write_pipe_content_start_s; -#endif // _di_fss_payload_write_defines_ - -/** - * A collection of static strings associated with FSS Payload Write. - */ -#ifndef _di_fss_payload_write_strings_ - #define FSS_PAYLOAD_WRITE_string_two_s "two" - - #define FSS_PAYLOAD_WRITE_string_two_s_length 3 - - extern const f_string_static_t fss_payload_write_string_two_s; -#endif // _di_fss_payload_write_strings_ - -/** - * The main program parameters. - */ -#ifndef _di_fss_payload_write_parameters_ - #define FSS_PAYLOAD_WRITE_short_file_s "f" - #define FSS_PAYLOAD_WRITE_short_content_s "c" - #define FSS_PAYLOAD_WRITE_short_double_s "d" - #define FSS_PAYLOAD_WRITE_short_ignore_s "I" - #define FSS_PAYLOAD_WRITE_short_object_s "o" - #define FSS_PAYLOAD_WRITE_short_partial_s "p" - #define FSS_PAYLOAD_WRITE_short_prepend_s "P" - #define FSS_PAYLOAD_WRITE_short_single_s "s" - #define FSS_PAYLOAD_WRITE_short_trim_s "T" - - #define FSS_PAYLOAD_WRITE_long_file_s "file" - #define FSS_PAYLOAD_WRITE_long_content_s "content" - #define FSS_PAYLOAD_WRITE_long_double_s "double" - #define FSS_PAYLOAD_WRITE_long_ignore_s "ignore" - #define FSS_PAYLOAD_WRITE_long_object_s "object" - #define FSS_PAYLOAD_WRITE_long_partial_s "partial" - #define FSS_PAYLOAD_WRITE_long_prepend_s "prepend" - #define FSS_PAYLOAD_WRITE_long_single_s "single" - #define FSS_PAYLOAD_WRITE_long_trim_s "trim" - - #define FSS_PAYLOAD_WRITE_short_file_s_length 1 - #define FSS_PAYLOAD_WRITE_short_content_s_length 1 - #define FSS_PAYLOAD_WRITE_short_double_s_length 1 - #define FSS_PAYLOAD_WRITE_short_ignore_s_length 1 - #define FSS_PAYLOAD_WRITE_short_object_s_length 1 - #define FSS_PAYLOAD_WRITE_short_partial_s_length 1 - #define FSS_PAYLOAD_WRITE_short_prepend_s_length 1 - #define FSS_PAYLOAD_WRITE_short_single_s_length 1 - #define FSS_PAYLOAD_WRITE_short_trim_s_length 1 - - #define FSS_PAYLOAD_WRITE_long_file_s_length 4 - #define FSS_PAYLOAD_WRITE_long_content_s_length 7 - #define FSS_PAYLOAD_WRITE_long_double_s_length 6 - #define FSS_PAYLOAD_WRITE_long_ignore_s_length 6 - #define FSS_PAYLOAD_WRITE_long_object_s_length 6 - #define FSS_PAYLOAD_WRITE_long_partial_s_length 7 - #define FSS_PAYLOAD_WRITE_long_prepend_s_length 7 - #define FSS_PAYLOAD_WRITE_long_single_s_length 6 - #define FSS_PAYLOAD_WRITE_long_trim_s_length 4 - - extern const f_string_static_t fss_payload_write_short_file_s; - extern const f_string_static_t fss_payload_write_short_content_s; - extern const f_string_static_t fss_payload_write_short_double_s; - extern const f_string_static_t fss_payload_write_short_ignore_s; - extern const f_string_static_t fss_payload_write_short_object_s; - extern const f_string_static_t fss_payload_write_short_partial_s; - extern const f_string_static_t fss_payload_write_short_prepend_s; - extern const f_string_static_t fss_payload_write_short_single_s; - extern const f_string_static_t fss_payload_write_short_trim_s; - - extern const f_string_static_t fss_payload_write_long_file_s; - extern const f_string_static_t fss_payload_write_long_content_s; - extern const f_string_static_t fss_payload_write_long_double_s; - extern const f_string_static_t fss_payload_write_long_ignore_s; - extern const f_string_static_t fss_payload_write_long_object_s; - extern const f_string_static_t fss_payload_write_long_partial_s; - extern const f_string_static_t fss_payload_write_long_prepend_s; - extern const f_string_static_t fss_payload_write_long_single_s; - extern const f_string_static_t fss_payload_write_long_trim_s; - - enum { - fss_payload_write_parameter_help_e, - fss_payload_write_parameter_light_e, - fss_payload_write_parameter_dark_e, - fss_payload_write_parameter_no_color_e, - fss_payload_write_parameter_verbosity_quiet_e, - fss_payload_write_parameter_verbosity_error_e, - fss_payload_write_parameter_verbosity_normal_e, - fss_payload_write_parameter_verbosity_verbose_e, - fss_payload_write_parameter_verbosity_debug_e, - fss_payload_write_parameter_version_e, - fss_payload_write_parameter_line_first_no_e, - fss_payload_write_parameter_line_last_no_e, - - fss_payload_write_parameter_file_e, - fss_payload_write_parameter_content_e, - fss_payload_write_parameter_double_e, - fss_payload_write_parameter_ignore_e, - fss_payload_write_parameter_object_e, - fss_payload_write_parameter_partial_e, - fss_payload_write_parameter_prepend_e, - fss_payload_write_parameter_single_e, - fss_payload_write_parameter_trim_e, - }; - - #define fss_payload_write_console_parameter_t_initialize \ - { \ - macro_f_console_parameter_t_initialize4(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize4(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize4(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize4(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_initialize4(f_console_standard_short_quiet_s, f_console_standard_long_quiet_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize4(f_console_standard_short_error_s, f_console_standard_long_error_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize4(f_console_standard_short_normal_s, f_console_standard_long_normal_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize4(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize4(f_console_standard_short_debug_s, f_console_standard_long_debug_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize4(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, f_console_flag_inverse_e), \ - macro_f_console_parameter_t_initialize4(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_initialize4(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_initialize2(fss_payload_write_short_file_s.string, fss_payload_write_long_file_s.string, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize2(fss_payload_write_short_content_s.string, fss_payload_write_long_content_s.string, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize2(fss_payload_write_short_double_s.string, fss_payload_write_long_double_s.string, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize2(fss_payload_write_short_ignore_s.string, fss_payload_write_long_ignore_s.string, 0, 2, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize2(fss_payload_write_short_object_s.string, fss_payload_write_long_object_s.string, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize2(fss_payload_write_short_partial_s.string, fss_payload_write_long_partial_s.string, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize2(fss_payload_write_short_prepend_s.string, fss_payload_write_long_prepend_s.string, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize2(fss_payload_write_short_single_s.string, fss_payload_write_long_single_s.string, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize2(fss_payload_write_short_trim_s.string, fss_payload_write_long_trim_s.string, 0, 0, f_console_flag_normal_e), \ - } - - #define fss_payload_write_total_parameters_d 21 -#endif // _di_fss_payload_write_parameters_ - -/** - * Flags used to represent flags passed to the main function. - * - * fss_payload_write_main_flag_*_e: - * - none: No modes in use. - * - content: The Content being written is specified. - * - double: Operate using double quotes. - * - file_to: Using a specified destination file. - * - help: Print help. - * - ignore: Ignore a given range within a Content. - * - object: The Object being written is specified. - * - partial: Do not write end of Object/Content character. - * - prepend: Prepend the given white space characters to the start of each multi-line Content. - * - single: Operate using single quotes. - * - trim: Trim Object names. - * - version: Print version. - */ -#ifndef _di_fss_payload_write_main_flag_e_ - enum { - fss_payload_write_main_flag_none_e = 0x0, - fss_payload_write_main_flag_content_e = 0x1, - fss_payload_write_main_flag_double_e = 0x2, - fss_payload_write_main_flag_file_to_e = 0x4, - fss_payload_write_main_flag_help_e = 0x8, - fss_payload_write_main_flag_ignore_e = 0x10, - fss_payload_write_main_flag_object_e = 0x20, - fss_payload_write_main_flag_partial_e = 0x40, - fss_payload_write_main_flag_prepend_e = 0x80, - fss_payload_write_main_flag_single_e = 0x100, - fss_payload_write_main_flag_trim_e = 0x200, - fss_payload_write_main_flag_version_e = 0x400, - }; -#endif // _di_fss_payload_write_main_flag_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. - * - * status: The main status code, generally used by the load settings and main functions. - * - * state: The state data used when processing the FSS data. - * range: A range used as a buffer during processing. - * - * line_first: A string expected to represent either "\n" or NULL to allow for easy handling of when to print first new line or not. - * line_last: A string expected to represent either "\n" or NULL to allow for easy handling of when to print last new line or not. - * - * quote: This holds the quote used during processing. - * - * 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. - * object: A buffer used to hold an Object during processing. - * content: A buffer used to hold a Content during processing. - * prepend: A string to prepend to each multi-line Content. - * - * ignores: An array of ranges passed as values to the "--ignore" parameter. - * objects: An array of objects passed as values to the "--object" parameter. - * contents: An array of objects passed as values to the "--content" parameter and must match the length of objects. - */ -#ifndef _di_fss_payload_write_setting_t_ - typedef struct { - uint16_t flag; - - f_status_t status; - - f_state_t state; - f_string_range_t range; - - f_string_static_t line_first; - f_string_static_t line_last; - - f_string_static_t quote; - - f_string_dynamic_t escaped; - f_string_dynamic_t block; - f_string_dynamic_t buffer; - f_string_dynamic_t object; - f_string_dynamic_t content; - f_string_dynamic_t prepend; - - f_string_ranges_t ignores; - f_string_dynamics_t objects; - f_string_dynamics_t contents; - } fss_payload_write_setting_t; - - #define fss_payload_write_setting_t_initialize \ - { \ - fss_payload_write_main_flag_none_e, \ - F_none, \ - macro_f_state_t_initialize(fss_payload_write_common_allocation_large_d, fss_payload_write_common_allocation_small_d, 0, 0, &fll_program_standard_signal_state, 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_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_ranges_t_initialize, \ - f_string_dynamics_t_initialize, \ - f_string_dynamics_t_initialize, \ - } -#endif // _di_fss_payload_write_setting_t_ - -/** - * Delete the program main setting data. - * - * @param setting - * The program main setting data. - * - * This does not alter setting.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fss_payload_write_setting_delete_ - extern f_status_t fss_payload_write_setting_delete(fss_payload_write_setting_t * const setting); -#endif // _di_fss_payload_write_setting_delete_ - -/** - * Perform the standard program setting load process. - * - * This prints error messages as appropriate. - * - * If either main or setting is NULL, then this immediately retuns without doing anything. - * - * @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. - * - * This alters setting.status: - * F_none on success. - * F_data_not on success but nothing was provided to operate with. - * - * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: f_file_stream_open(). - * Errors (with error bit) from: f_string_dynamics_resize(). - * Errors (with error bit) from: fll_program_parameter_process_context(). - * Errors (with error bit) from: fll_program_parameter_process_verbosity(). - * - * @see f_console_parameter_process() - * @see f_file_stream_open() - * @see f_string_dynamics_resize() - * @see fll_program_parameter_process_context() - * @see fll_program_parameter_process_verbosity() - */ -#ifndef _di_fss_payload_write_setting_load_ - extern void fss_payload_write_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_write_setting_t * const setting); -#endif // _di_fss_payload_write_setting_load_ - -/** - * Perform the standard program setting unload process. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * All buffers are deallocated. - * - * This does not alter setting.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: utf8_setting_delete(). - * - * @see utf8_setting_delete() - */ -#ifndef _di_fss_payload_write_setting_unload_ - extern f_status_t fss_payload_write_setting_unload(fll_program_data_t * const main, fss_payload_write_setting_t * const setting); -#endif // _di_fss_payload_write_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_payload_write_common_h diff --git a/level_3/fss_payload_write/c/fss_payload_write.c b/level_3/fss_payload_write/c/fss_payload_write.c deleted file mode 100644 index cd806aa..0000000 --- a/level_3/fss_payload_write/c/fss_payload_write.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "fss_payload_write.h" -#include "private-common.h" -#include "private-write.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_write_main_ - void fss_payload_write_main(fll_program_data_t * const main, fss_payload_write_setting_t * const setting) { - - if (!main || !setting || F_status_is_error(setting->status)) return; - - setting->status = F_none; - - if (setting->flag & fss_payload_write_main_flag_help_e) { - fss_payload_write_print_help(setting, main->message); - - return; - } - - if (setting->flag & fss_payload_write_main_flag_version_e) { - fll_program_print_version(main->message, fss_payload_write_program_version_s); - - return; - } - - setting->escaped.used = 0; - - if (main->pipe & fll_program_data_pipe_input_e) { - fss_payload_write_process_pipe(main, setting); - if (F_status_is_error(setting->status)) return; - - // Print newline character to separate data printed from pipe. - if (setting->status == F_none) { - if ((setting->flag & fss_payload_write_main_flag_partial_e) && setting->objects.used) { - fll_print_dynamic(f_string_eol_s, main->output.to); - } - else if (setting->contents.used) { - fll_print_dynamic(f_fss_payload_header_close_s, main->output.to); - } - } - } - - if (setting->flag & (fss_payload_write_main_flag_object_e | fss_payload_write_main_flag_content_e)) { - f_string_statics_t *objects = &setting->objects; - f_string_statics_t *contents = &setting->contents; - f_string_statics_t *data = &setting->objects; - - if (setting->flag & fss_payload_write_main_flag_partial_e) { - if (setting->flag & fss_payload_write_main_flag_content_e) { - data = &setting->contents; - objects = 0; - } - else { - contents = 0; - } - } - - for (f_array_length_t i = 0; i < data->used; ++i) { - - if (!((++main->signal_check) % fss_payload_write_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - setting->status = F_status_set_error(F_interrupt); - - return; - } - - main->signal_check = 0; - } - - fss_payload_write_process(main, setting, objects ? &objects->array[i] : 0, contents ? &contents->array[i] : 0); - if (F_status_is_error(setting->status)) return; - } // for - } - - // Ensure a new line is always put at the end of the program execution, unless in quiet mode. - fss_payload_write_print_line_last_locked(setting, main->message); - } -#endif // _di_fss_payload_write_main_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_write/c/fss_payload_write.h b/level_3/fss_payload_write/c/fss_payload_write.h deleted file mode 100644 index 00c3ae0..0000000 --- a/level_3/fss_payload_write/c/fss_payload_write.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This program provides fss basic list write functionality. - */ -#ifndef _fss_payload_write_h -#define _fss_payload_write_h - -// Libc includes. -#include -#include -#include -#include - -// FLL-0 includes. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// FLL-1 includes. -#include -#include -#include -#include - -// FLL-2 includes. -#include -#include -#include -#include - -// FSS Payload Write includes. -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Execute main program. - * - * If main.signal is non-zero, then this blocks and handles the following signals: - * - F_signal_abort - * - F_signal_broken_pipe - * - F_signal_hangup - * - F_signal_interrupt - * - F_signal_quit - * - F_signal_termination - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.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. - * F_interrupt on (exit) signal received. - * - * F_parameter (with error bit) if main is NULL or setting is NULL. - */ -#ifndef _di_fss_payload_write_main_ - extern void fss_payload_write_main(fll_program_data_t * const main, fss_payload_write_setting_t * const setting); -#endif // _di_fss_payload_write_main_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_payload_write_h diff --git a/level_3/fss_payload_write/c/main.c b/level_3/fss_payload_write/c/main.c deleted file mode 100644 index 566c938..0000000 --- a/level_3/fss_payload_write/c/main.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "fss_payload_write.h" - -int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - - fll_program_data_t data = fll_program_data_t_initialize; - fss_payload_write_setting_t setting = fss_payload_write_setting_t_initialize; - setting.state.data = (void *) &data; - - f_console_parameter_t parameters[] = fss_payload_write_console_parameter_t_initialize; - data.parameters.array = parameters; - data.parameters.used = fss_payload_write_total_parameters_d; - data.environment = envp; - - if (f_pipe_input_exists()) { - data.pipe = fll_program_data_pipe_input_e; - } - - fll_program_standard_set_up(&data); - - { - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - - fss_payload_write_setting_load(arguments, &data, &setting); - } - - fss_payload_write_main(&data, &setting); - - fss_payload_write_setting_unload(&data, &setting); - - fll_program_data_delete(&data); - - fll_program_standard_set_down(&data); - - return F_status_is_error(setting.status) ? 1 : 0; -} diff --git a/level_3/fss_payload_write/c/print.c b/level_3/fss_payload_write/c/print.c deleted file mode 100644 index bc795f8..0000000 --- a/level_3/fss_payload_write/c/print.c +++ /dev/null @@ -1,214 +0,0 @@ -#include "fss_payload_write.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_write_print_error_ - f_status_t fss_payload_write_print_error(fss_payload_write_setting_t * const setting, const fl_print_t print, const f_string_t function) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - fss_payload_write_print_line_first_locked(setting, print); - fll_error_print(print, F_status_set_fine(setting->status), function, F_true); - fss_payload_write_print_line_last_locked(setting, print); - - return F_none; - } -#endif // _di_fss_payload_write_print_error_ - -#ifndef _di_fss_payload_write_print_error_file_ - f_status_t fss_payload_write_print_error_file(fss_payload_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 (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - fss_payload_write_print_line_first_locked(setting, print); - fll_error_file_print(print, F_status_set_fine(setting->status), function, F_true, name, operation, type); - fss_payload_write_print_line_last_locked(setting, print); - - return F_none; - } -#endif // _di_fss_payload_write_print_error_file_ - -#ifndef _di_fss_payload_write_print_error_object_not_before_content_ - f_status_t fss_payload_write_print_error_object_not_before_content(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - f_file_stream_lock(print.to); - - fl_print_format("%r%[%QEach '%]", 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_payload_write_long_object_s, print.set->notable); - fl_print_format("%[' parameter must be specified before a '%]", print.to, print.set->error, print.set->error); - fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_write_long_content_s, print.set->notable); - fl_print_format("%[' parameter.%]%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_payload_write_print_error_object_not_before_content_ - -#ifndef _di_fss_payload_write_print_error_one_content_only_ - f_status_t fss_payload_write_print_error_one_content_only(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - fll_print_format("%r%[%QThe FSS-000E (Payload) standard only supports one content per object.%]%r", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error, f_string_eol_s); - - return F_none; - } -#endif // _di_fss_payload_write_print_error_one_content_only_ - -#ifndef _fss_payload_write_print_error_prepend_only_whitespace_ - f_status_t fss_payload_write_print_error_prepend_only_whitespace(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - 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_payload_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_payload_write_print_error_prepend_only_whitespace_ - -#ifndef _di_fss_payload_write_print_error_unsupported_eol_ - f_status_t fss_payload_write_print_error_unsupported_eol(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - f_file_stream_lock(print.to); - - fl_print_format("%r%[%QThe FSS-000E (Payload) standard does not support end of line character '%]", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error); - 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_payload_write_print_error_unsupported_eol_ - -#ifndef _di_fss_payload_write_print_help_ - f_status_t fss_payload_write_print_help(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - f_file_stream_lock(print.to); - - f_print_dynamic_raw(setting->line_first, print.to); - - fll_program_print_help_header(print, fss_payload_write_program_name_long_s, fss_payload_write_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, fss_payload_write_short_file_s, fss_payload_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_payload_write_short_content_s, fss_payload_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_payload_write_short_double_s, fss_payload_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_payload_write_short_ignore_s, fss_payload_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_payload_write_short_object_s, fss_payload_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_payload_write_short_partial_s, fss_payload_write_long_partial_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Do not write end of Object/Content character."); - fll_program_print_help_option(print, fss_payload_write_short_prepend_s, fss_payload_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_payload_write_short_single_s, fss_payload_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_payload_write_short_trim_s, fss_payload_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); - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_usage(print, fss_payload_write_program_name_s, f_string_empty_s); - - 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, which does nothing in this program.%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%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The FSS-000E (Payload) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_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_payload_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_payload_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_print_dynamic_raw(setting->line_last, print.to); - - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_payload_write_print_help_ - -#ifndef _di_fss_payload_write_print_line_first_locked_ - f_status_t fss_payload_write_print_line_first_locked(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - if (!F_status_is_error(setting->status)) { - if (print.verbosity == f_console_verbosity_error_e) return F_output_not; - } - - f_print_dynamic_raw(setting->line_first, print.to); - - return F_none; - } -#endif // _di_fss_payload_write_print_line_first_locked_ - -#ifndef _di_fss_payload_write_print_line_first_unlocked_ - f_status_t fss_payload_write_print_line_first_unlocked(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - if (!F_status_is_error(setting->status)) { - if (print.verbosity == f_console_verbosity_error_e) return F_output_not; - } - - fll_print_dynamic_raw(setting->line_first, print.to); - - return F_none; - } -#endif // _di_fss_payload_write_print_line_first_unlocked_ - -#ifndef _di_fss_payload_write_print_line_last_locked_ - f_status_t fss_payload_write_print_line_last_locked(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - if (!F_status_is_error(setting->status)) { - if (print.verbosity == f_console_verbosity_error_e) return F_output_not; - if (setting->flag & fss_payload_write_main_flag_file_to_e) return F_output_not; - } - - fll_print_dynamic_raw(setting->line_last, print.to); - - return F_none; - } -#endif // _di_fss_payload_write_print_line_last_locked_ - -#ifndef _di_fss_payload_write_print_line_last_unlocked_ - f_status_t fss_payload_write_print_line_last_unlocked(fss_payload_write_setting_t * const setting, const fl_print_t print) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - if (!F_status_is_error(setting->status)) { - if (print.verbosity == f_console_verbosity_error_e) return F_output_not; - if (setting->flag & fss_payload_write_main_flag_file_to_e) return F_output_not; - } - - f_print_dynamic_raw(setting->line_last, print.to); - - return F_none; - } -#endif // _di_fss_payload_write_print_line_last_unlocked_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_write/c/print.h b/level_3/fss_payload_write/c/print.h deleted file mode 100644 index 50fc3fa..0000000 --- a/level_3/fss_payload_write/c/print.h +++ /dev/null @@ -1,245 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: UTF-8 - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _fss_payload_write_print_h -#define _fss_payload_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.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_payload_write_print_error_ - extern f_status_t fss_payload_write_print_error(fss_payload_write_setting_t * const setting, const fl_print_t print, const f_string_t function); -#endif // _di_fss_payload_write_print_error_ - -/** - * Print file related error or warning messages. - * - * @param setting - * The main program settings. - * - * This does not alter setting.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_payload_write_print_error_file_ - extern f_status_t fss_payload_write_print_error_file(fss_payload_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_payload_write_print_error_file_ - -/** - * Print error message about each Object parameter not being specified before a Content parameter. - * - * @param setting - * The main program settings. - * - * This does not alter setting.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_payload_write_print_error_object_not_before_content_ - extern f_status_t fss_payload_write_print_error_object_not_before_content(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_write_print_error_object_not_before_content_ - -/** - * Print an message about a multiple Content being unsupported. - * - * @param setting - * The main program settings. - * - * This does not alter setting.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_payload_write_print_error_one_content_only_ - extern f_status_t fss_payload_write_print_error_one_content_only(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_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.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_payload_write_print_error_prepend_only_whitespace_ - extern f_status_t fss_payload_write_print_error_prepend_only_whitespace(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _fss_payload_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.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_payload_write_print_error_unsupported_eol_ - extern f_status_t fss_payload_write_print_error_unsupported_eol(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_write_print_error_unsupported_eol_ - -/** - * Print help. - * - * @param setting - * The main program settings. - * - * This does not alter setting.status. - * @param print - * The output structure to print to. - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_write_print_help_ - extern f_status_t fss_payload_write_print_help(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_write_print_help_ - -/** - * Print first new line, unless verbosity says otherwise. - * - * This is generally either the first line in the program or the first line printed before an error message. - * - * This function locks and then unlocks the input stream when printing. - * - * @param setting - * The main program settings. - * - * This does not alter setting.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_payload_write_print_line_first_locked_ - extern f_status_t fss_payload_write_print_line_first_locked(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_write_print_line_first_locked_ - -/** - * Print first new line, unless verbosity says otherwise. - * - * This is generally either the first line in the program or the first line printed before an error message. - * - * This function neither locks nor unlocks the input stream. - * - * @param setting - * The main program settings. - * - * This does not alter setting.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_payload_write_print_line_first_unlocked_ - extern f_status_t fss_payload_write_print_line_first_unlocked(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_write_print_line_first_unlocked_ - -/** - * Print last new line when the main is complete, unless verbosity says otherwise. - * - * This is generally the very last line printed in the program. - * - * This function locks and then unlocks the input stream when printing. - * - * @param setting - * The main program settings. - * - * This does not alter setting.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_payload_write_print_line_last_locked_ - extern f_status_t fss_payload_write_print_line_last_locked(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_write_print_line_last_locked_ - -/** - * Print last new line when the main is complete, unless verbosity says otherwise. - * - * This is generally the very last line printed in the program. - * - * This function neither locks nor unlocks the input stream. - * - * @param setting - * The main program settings. - * - * This does not alter setting.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_payload_write_print_line_last_unlocked_ - extern f_status_t fss_payload_write_print_line_last_unlocked(fss_payload_write_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_write_print_line_last_unlocked_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_payload_write_print_h diff --git a/level_3/fss_payload_write/c/private-common.c b/level_3/fss_payload_write/c/private-common.c deleted file mode 100644 index 33626b5..0000000 --- a/level_3/fss_payload_write/c/private-common.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "fss_payload_write.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_write/c/private-common.h b/level_3/fss_payload_write/c/private-common.h deleted file mode 100644 index f6a495d..0000000 --- a/level_3/fss_payload_write/c/private-common.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic List Write - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_common_h -#define _PRIVATE_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_common_h diff --git a/level_3/fss_payload_write/c/private-write.c b/level_3/fss_payload_write/c/private-write.c deleted file mode 100644 index db87e09..0000000 --- a/level_3/fss_payload_write/c/private-write.c +++ /dev/null @@ -1,388 +0,0 @@ -#include "fss_payload_write.h" -#include "private-common.h" -#include "private-write.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_write_process_ - void fss_payload_write_process(fll_program_data_t * const main, fss_payload_write_setting_t * const setting, const f_string_static_t *object, const f_string_static_t *content) { - - if (object) { - if (content) { - if (object->used) { - setting->range.start = 0; - setting->range.stop = object->used - 1; - } - else { - setting->range.start = 1; - setting->range.stop = 0; - } - - setting->status = fll_fss_payload_write(*object, *content, setting->flag & fss_payload_write_main_flag_trim_e, setting->flag & fss_payload_write_main_flag_prepend_e ? &setting->prepend : 0, setting->state, &setting->buffer); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_supported_not); - - fss_payload_write_print_line_first_locked(setting, main->error); - fss_payload_write_print_error_unsupported_eol(setting, main->error); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "fll_fss_payload_write"); - - return; - } - } - else { - bool complete = f_fss_complete_none_e; - - if (object->used) { - setting->range.start = 0; - setting->range.stop = object->used - 1; - } - else { - setting->range.start = 1; - setting->range.stop = 0; - } - - if (content) { - if (main->parameters.array[fss_payload_write_parameter_trim_e].result & f_console_result_found_e) { - complete = f_fss_complete_full_trim_e; - } - else { - complete = f_fss_complete_full_e; - } - } - - setting->status = fl_fss_basic_list_object_write(*object, complete, setting->state, &setting->range, &setting->buffer); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_supported_not); - - fss_payload_write_print_line_first_locked(setting, main->error); - fss_payload_write_print_error_unsupported_eol(setting, main->error); - fss_payload_write_print_line_last_locked(setting, main->error); - - return; - } - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "fl_fss_basic_list_object_write"); - - return; - } - } - } - else if (content && content->used) { - setting->range.start = 0; - setting->range.stop = content->used - 1; - - const f_string_static_t *prepend = 0; - - if (setting->flag & fss_payload_write_main_flag_prepend_e) { - const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_prepend_e].values.array[main->parameters.array[fss_payload_write_parameter_prepend_e].values.used - 1]; - - prepend = &main->parameters.arguments.array[index]; - } - - setting->status = fl_fss_basic_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, prepend, setting->state, &setting->range, &setting->buffer); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "fl_fss_payload_content_write"); - - return; - } - } - - if (!object || !content) { - setting->status = f_string_dynamic_append(f_string_eol_s, &setting->buffer); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "f_string_dynamic_append"); - - return; - } - } - - fll_print_dynamic(setting->buffer, main->output.to); - - setting->buffer.used = 0; - setting->status = F_none; - } -#endif // _di_fss_payload_write_process_ - -#ifndef _di_fss_payload_write_process_pipe_ - void fss_payload_write_process_pipe(fll_program_data_t * const main, fss_payload_write_setting_t * const setting) { - - 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_payload_write_common_allocation_large_d; - - f_array_length_t total = 0; - f_array_length_t length = 0; - f_string_range_t range = f_string_range_t_initialize; - - // 0x0 = nothing printed, 0x1 = something printed, 0x2 = "payload" matched. - uint8_t printed = 0; - - // 0x0 = start new object/content set, 0x1 = processing object, 0x2 = processing content, 0x3 = end object/content set, 0x4 = processing payload content. - uint8_t state = 0; - - for (;;) { - - if (!((++main->signal_check) % fss_payload_write_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received); - - setting->status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - if (range.start > range.stop) { - if (status_pipe == F_none_eof) break; - - setting->block.used = 0; - - status_pipe = f_file_read_block(input, &setting->block); - - if (F_status_is_error(status_pipe)) { - fss_payload_write_print_error(setting, main->error, "f_file_read_block"); - - status_pipe = F_status_set_error(F_pipe); - - break; - } - - if (!setting->block.used) break; - - range.start = 0; - range.stop = setting->block.used - 1; - } - - if (!state || state == 0x1) { - if (!state) { - setting->object.used = 0; - setting->content.used = 0; - - state = 0x1; - } - - if (setting->object.used + setting->block.used > setting->object.size) { - setting->status = f_string_dynamic_increase_by(setting->block.used, &setting->object); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); - - break; - } - } - - for (; range.start <= range.stop; ++range.start) { - - if (setting->block.string[range.start] == fss_payload_write_pipe_content_start_s.string[0]) { - state = 0x2; - ++range.start; - - break; - } - - if (setting->block.string[range.start] == fss_payload_write_pipe_content_end_s.string[0]) { - state = 0x3; - ++range.start; - - break; - } - - if (setting->block.string[range.start] == fss_payload_write_pipe_content_ignore_s.string[0]) { - - // This is not used by objects. - continue; - } - - setting->object.string[setting->object.used++] = setting->block.string[range.start]; - } // for - - if (F_status_is_error(setting->status)) break; - - // If the start of content was not found, then fetch the next block. - if (state == 0x1) continue; - - // If the end of the current block is reached, fetch the next block. - if (range.start > range.stop) continue; - } - - if (state == 0x2) { - if (range.start <= range.stop) { - total = (range.stop - range.start) + 1; - } - else { - total = 0; - } - - // 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_string_payload_s, setting->object) == F_equal_to) { - if (total > 1) { - setting->status = f_string_dynamic_increase_by(total, &setting->content); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); - - break; - } - - memcpy(setting->content.string, setting->block.string + range.start, sizeof(f_char_t) * total); - - setting->content.used += total; - } - - state = 0x4; - printed |= 0x2; - - // Designate to read next block from pipe. - range.start = 1; - range.stop = 0; - - continue; - } - - if (total) { - setting->status = f_string_dynamic_increase_by(total, &setting->content); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); - - break; - } - - for (; range.start <= range.stop; ++range.start) { - - if (setting->block.string[range.start] == fss_payload_write_pipe_content_start_s.string[0]) { - setting->status = F_status_set_error(F_supported_not); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fss_payload_write_print_line_first_locked(setting, main->error); - fss_payload_write_print_error_one_content_only(setting, main->error); - fss_payload_write_print_line_last_locked(setting, main->error); - } - - break; - } - - if (setting->block.string[range.start] == fss_payload_write_pipe_content_end_s.string[0]) { - state = 0x3; - ++range.start; - - break; - } - - if (setting->block.string[range.start] == fss_payload_write_pipe_content_ignore_s.string[0]) { - - // This is not used by this program. - continue; - } - - setting->content.string[setting->content.used++] = setting->block.string[range.start]; - } // for - - if (F_status_is_error(setting->status)) break; - } - else { - state = 0x3; - } - } - - if (state == 0x3) { - if (setting->flag & fss_payload_write_main_flag_partial_e) { - if (setting->flag & fss_payload_write_main_flag_content_e) { - fss_payload_write_process(main, setting, 0, &setting->content); - } - else { - fss_payload_write_process(main, setting, &setting->object, 0); - } - } - else { - fss_payload_write_process(main, setting, &setting->object, &setting->content); - } - - if (F_status_is_error(setting->status)) break; - - state = 0; - printed |= 0x1; - - continue; - } - - if (state == 0x4) { - if (setting->block.used && range.start <= range.stop) { - length = (range.stop - range.start) + 1; - - setting->status = f_string_dynamic_increase_by(length + 1, &setting->content); - - if (F_status_is_error(setting->status)) { - fss_payload_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); - - break; - } - - memcpy(setting->content.string + range.start, setting->block.string, sizeof(f_char_t) * length); - - setting->content.used += length; - } - - // Designate to read next block from pipe. - range.start = 1; - range.stop = 0; - } - } // for - - // If the pipe ended before finishing, then attempt to wrap up. - if (F_status_is_error_not(setting->status) && status_pipe == F_none_eof && state) { - if (setting->flag & fss_payload_write_main_flag_partial_e) { - if (setting->flag & fss_payload_write_main_flag_content_e) { - fss_payload_write_process(main, setting, 0, &setting->content); - } - else { - fss_payload_write_process(main, setting, &setting->object, 0); - } - } - else { - fss_payload_write_process(main, setting, &setting->object, &setting->content); - } - - printed |= 0x1; - } - - setting->block.used = 0; - setting->object.used = 0; - setting->content.used = 0; - setting->buffer.used = 0; - - if (F_status_is_error_not(setting->status)) { - if (printed & 0x1) { - if (printed & 0x2) { - setting->status = F_payload; - } - else { - setting->status = F_none; - } - } - else { - setting->status = F_data_not; - } - } - } -#endif // _di_fss_payload_write_process_pipe_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_write/c/private-write.h b/level_3/fss_payload_write/c/private-write.h deleted file mode 100644 index cf73720..0000000 --- a/level_3/fss_payload_write/c/private-write.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_write_h -#define _PRIVATE_write_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * 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. - * - * This alters setting.status: - * F_none on success. - * F_interrupt on (exit) signal received. - * - * F_parameter (with error bit) if main is NULL or setting is NULL. - * @param object - * The object to validate and print. - * Set pointer address to 0 to not use. - * @param content - * The content to escape and print. - * Set pointer address to 0 to not use. - * - * @return - * F_none on success. - * F_failure (with error bit) for any other failure. - */ -#ifndef _di_fss_payload_write_process_ - extern void fss_payload_write_process(fll_program_data_t * const main, fss_payload_write_setting_t * const setting, const f_string_static_t *object, const f_string_static_t *content) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_write_process_ - -/** - * Process the pipe, reading from the pipe and writing to the output. - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.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. - * F_interrupt on (exit) signal received. - * - * F_parameter (with error bit) if main is NULL or setting is NULL. - * - * @return - * F_none on success. - * F_failure (with error bit) for any other failure. - */ -#ifndef _di_fss_payload_write_process_pipe_ - extern void fss_payload_write_process_pipe(fll_program_data_t * const main, fss_payload_write_setting_t * const setting) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_write_process_pipe_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_write_h diff --git a/level_3/fss_payload_write/data/build/defines b/level_3/fss_payload_write/data/build/defines deleted file mode 100644 index c665317..0000000 --- a/level_3/fss_payload_write/data/build/defines +++ /dev/null @@ -1,2 +0,0 @@ -# fss-0000 - diff --git a/level_3/fss_payload_write/data/build/dependencies b/level_3/fss_payload_write/data/build/dependencies deleted file mode 100644 index f853089..0000000 --- a/level_3/fss_payload_write/data/build/dependencies +++ /dev/null @@ -1,26 +0,0 @@ -# fss-0000 - -f_type -f_status -f_memory -f_string -f_utf -f_color -f_console -f_conversion -f_directory -f_environment -f_file -f_fss -f_pipe -f_print -f_signal -fl_conversion -fl_fss -fl_print -fl_string -fll_error -fll_file -fll_fss -fll_print -fll_program diff --git a/level_3/fss_payload_write/data/build/fakefile b/level_3/fss_payload_write/data/build/fakefile deleted file mode 100644 index 5328059..0000000 --- a/level_3/fss_payload_write/data/build/fakefile +++ /dev/null @@ -1,11 +0,0 @@ -# fss-0005 iki-0002 - -settings: - fail exit - modes individual level monolithic clang test - - environment PATH LD_LIBRARY_PATH - -main: - - build diff --git a/level_3/fss_payload_write/data/build/settings b/level_3/fss_payload_write/data/build/settings deleted file mode 100644 index e661405..0000000 --- a/level_3/fss_payload_write/data/build/settings +++ /dev/null @@ -1,56 +0,0 @@ -# fss-0001 - -build_name fss_payload_write - -version_major 0 -version_minor 7 -version_micro 0 -version_file micro -version_target minor - -modes individual level monolithic clang test -modes_default monolithic - -build_compiler gcc -build_compiler-clang clang -build_indexer ar -build_indexer_arguments rcs -build_language c - -build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_signal -lf_status_string -lf_string -lf_type_array -lf_utf -build_libraries-level -lfll_2 -lfll_1 -lfll_0 -build_libraries-monolithic -lfll - -build_sources_library fss_payload_write.c common.c print.c private-common.c private-write.c - -build_sources_program main.c - -build_sources_headers fss_payload_write.h common.h print.h - -build_script yes -build_shared yes -build_static no - -path_headers program/fss_payload_write - -has_path_standard yes -preserve_path_headers yes - -search_exclusive yes -search_shared yes -search_static yes - -environment PATH LD_LIBRARY_PATH - -#defines -D_di_libcap_ -D_di_thread_support_ -defines -D_libcap_legacy_only_ -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ - -flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces -flags-clang -Wno-logical-op-parentheses -flags-test -O0 -fstack-protector -Wall -flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ - -flags_library -fPIC -flags_object -fPIC -flags_program -fPIE