From: Kevin Day Date: Sun, 11 Dec 2022 03:58:49 +0000 (-0600) Subject: Feature: Add support for printing partial data with or without closing data in fss_write. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=d045ea5d970d1b480fb630167c2b75e1d9295194;p=fll Feature: Add support for printing partial data with or without closing data in fss_write. The "complete" "partial" FSS write enumaration settings still prints the end of Object or Content data. This "partial" simply does not print the end of line characters. Change the behavior to act like the newly added feature regarting "complete" "trim". Provide parameters to toggle on printing of the closing data. --- diff --git a/level_3/fss_write/c/basic/fss_write.c b/level_3/fss_write/c/basic/fss_write.c index 9926279..12c8975 100644 --- a/level_3/fss_write/c/basic/fss_write.c +++ b/level_3/fss_write/c/basic/fss_write.c @@ -10,30 +10,42 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_basic_content_write( - *setting->content, - (setting->flag & fss_write_flag_partial_e) - ? f_fss_complete_partial_e - : f_fss_complete_full_e, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->content) { + setting->status = fl_fss_basic_content_write( + *setting->content, + (setting->flag & fss_write_flag_partial_e) + ? f_fss_complete_partial_e + : f_fss_complete_full_e, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_content_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_content_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_content_end_e) { + setting->status = f_string_dynamic_append(f_fss_basic_close_s, &setting->buffer); - return; + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_basic_process_content_ @@ -50,35 +62,49 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_basic_object_write( - *setting->object, - setting->quote.used - ? setting->quote.string[0] - : f_fss_quote_double_s.string[0], - (setting->flag & fss_write_flag_partial_e) - ? (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_partial_trim_e - : f_fss_complete_partial_e - : (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->object) { + setting->status = fl_fss_basic_object_write( + *setting->object, + setting->quote.used + ? setting->quote.string[0] + : f_fss_quote_double_s.string[0], + (setting->flag & fss_write_flag_partial_e) + ? (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_object_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_object_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_object_open_e) { + setting->status = f_string_dynamic_append(f_fss_basic_open_s, &setting->buffer); + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_basic_process_object_ diff --git a/level_3/fss_write/c/basic/print.c b/level_3/fss_write/c/basic/print.c index 09d3e55..aea1076 100644 --- a/level_3/fss_write/c/basic/print.c +++ b/level_3/fss_write/c/basic/print.c @@ -21,6 +21,8 @@ extern "C" { fss_write_print_help_pipe(setting, print); + fss_write_print_help_end_next(setting, 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); 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 544f55f..f80dac2 100644 --- a/level_3/fss_write/c/basic_list/fss_write.c +++ b/level_3/fss_write/c/basic_list/fss_write.c @@ -10,33 +10,45 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_basic_list_content_write( - *setting->content, - (setting->flag & fss_write_flag_partial_e) - ? f_fss_complete_partial_e - : (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - &setting->prepend, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->content) { + setting->status = fl_fss_basic_list_content_write( + *setting->content, + (setting->flag & fss_write_flag_partial_e) + ? f_fss_complete_partial_e + : (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + &setting->prepend, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_content_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_content_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_content_end_e) { + setting->status = f_string_dynamic_append(f_fss_basic_list_close_s, &setting->buffer); - return; + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_basic_list_process_content_ @@ -53,32 +65,50 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_basic_list_object_write( - *setting->object, - (setting->flag & fss_write_flag_partial_e) - ? (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_partial_trim_e - : f_fss_complete_partial_e - : (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->object) { + setting->status = fl_fss_basic_list_object_write( + *setting->object, + (setting->flag & fss_write_flag_partial_e) + ? (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_object_open_e) { + setting->status = f_string_dynamic_append(f_fss_basic_list_open_s, &setting->buffer); + + if (F_status_is_error_not(setting->status)) { + setting->status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &setting->buffer); + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_basic_list_process_object_ diff --git a/level_3/fss_write/c/basic_list/print.c b/level_3/fss_write/c/basic_list/print.c index 00f0e3b..3baec35 100644 --- a/level_3/fss_write/c/basic_list/print.c +++ b/level_3/fss_write/c/basic_list/print.c @@ -21,6 +21,8 @@ extern "C" { fss_write_print_help_pipe(setting, print); + fss_write_print_help_end_next(setting, 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); 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 6d6ee73..543661d 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.c +++ b/level_3/fss_write/c/embedded_list/fss_write.c @@ -10,34 +10,50 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_embedded_list_content_write( - *setting->content, - (setting->flag & fss_write_flag_partial_e) - ? f_fss_complete_partial_e - : last - ? f_fss_complete_end_e - : f_fss_complete_next_e, - &setting->prepend, - setting->ignores, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->content) { + setting->status = fl_fss_embedded_list_content_write( + *setting->content, + (setting->flag & fss_write_flag_partial_e) + ? f_fss_complete_partial_e + : last + ? f_fss_complete_end_e + : f_fss_complete_next_e, + &setting->prepend, + setting->ignores, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_content_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_content_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_content_end_e) { + setting->status = f_string_dynamic_append(f_fss_embedded_list_close_s, &setting->buffer); - return; + if (F_status_is_error_not(setting->status)) { + setting->status = f_string_dynamic_append(f_fss_embedded_list_close_end_s, &setting->buffer); + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_embedded_list_process_content_ @@ -54,32 +70,50 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_embedded_list_object_write( - *setting->object, - (setting->flag & fss_write_flag_partial_e) - ? (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_partial_trim_e - : f_fss_complete_partial_e - : (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->object) { + setting->status = fl_fss_embedded_list_object_write( + *setting->object, + (setting->flag & fss_write_flag_partial_e) + ? (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_object_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_object_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_object_open_e) { + setting->status = f_string_dynamic_append(f_fss_embedded_list_open_s, &setting->buffer); + + if (F_status_is_error_not(setting->status)) { + setting->status = f_string_dynamic_append(f_fss_embedded_list_open_end_s, &setting->buffer); + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_embedded_list_process_object_ diff --git a/level_3/fss_write/c/embedded_list/print.c b/level_3/fss_write/c/embedded_list/print.c index d767899..752add9 100644 --- a/level_3/fss_write/c/embedded_list/print.c +++ b/level_3/fss_write/c/embedded_list/print.c @@ -21,6 +21,8 @@ extern "C" { fss_write_print_help_pipe(setting, print); + fss_write_print_help_end_next(setting, 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); diff --git a/level_3/fss_write/c/extended/fss_write.c b/level_3/fss_write/c/extended/fss_write.c index 44e6508..86ec242 100644 --- a/level_3/fss_write/c/extended/fss_write.c +++ b/level_3/fss_write/c/extended/fss_write.c @@ -10,35 +10,54 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_extended_content_write( - *setting->content, - setting->quote.used - ? setting->quote.string[0] - : f_fss_quote_double_s.string[0], - (setting->flag & fss_write_flag_partial_e) - ? f_fss_complete_partial_e - : last - ? f_fss_complete_end_e - : f_fss_complete_next_e, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->content) { + setting->status = fl_fss_extended_content_write( + *setting->content, + setting->quote.used + ? setting->quote.string[0] + : f_fss_quote_double_s.string[0], + (setting->flag & fss_write_flag_partial_e) + ? f_fss_complete_partial_e + : last + ? f_fss_complete_end_e + : f_fss_complete_next_e, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_content_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_content_write)); - - return; + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_content_end_e) { + setting->status = f_string_dynamic_append(f_fss_extended_close_s, &setting->buffer); + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } + else if (setting->flag & fss_write_flag_content_next_e) { + setting->status = f_string_dynamic_append(f_fss_extended_next_s, &setting->buffer); + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_extended_process_content_ @@ -55,35 +74,48 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_extended_object_write( - *setting->object, - setting->quote.used - ? setting->quote.string[0] - : f_fss_quote_double_s.string[0], - (setting->flag & fss_write_flag_partial_e) - ? (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_partial_trim_e - : f_fss_complete_partial_e - : (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->object) { + setting->status = fl_fss_extended_object_write( + *setting->object, + setting->quote.used + ? setting->quote.string[0] + : f_fss_quote_double_s.string[0], + (setting->flag & fss_write_flag_partial_e) + ? (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_object_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_object_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_object_open_e) { + setting->status = f_string_dynamic_append(f_fss_extended_open_s, &setting->buffer); + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_extended_process_object_ diff --git a/level_3/fss_write/c/extended/print.c b/level_3/fss_write/c/extended/print.c index 428370a..c202009 100644 --- a/level_3/fss_write/c/extended/print.c +++ b/level_3/fss_write/c/extended/print.c @@ -21,6 +21,8 @@ extern "C" { fss_write_print_help_pipe(setting, print); + fss_write_print_help_end_next(setting, 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); 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 33423f2..1496c2f 100644 --- a/level_3/fss_write/c/extended_list/fss_write.c +++ b/level_3/fss_write/c/extended_list/fss_write.c @@ -10,34 +10,50 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_extended_list_content_write( - *setting->content, - (setting->flag & fss_write_flag_partial_e) - ? last - ? f_fss_complete_none_e - : f_fss_complete_partial_e - : f_fss_complete_full_e, - &setting->prepend, - setting->ignores, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); - - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); - - return; + if (setting->content) { + setting->status = fl_fss_extended_list_content_write( + *setting->content, + (setting->flag & fss_write_flag_partial_e) + ? last + ? f_fss_complete_none_e + : f_fss_complete_partial_e + : f_fss_complete_full_e, + &setting->prepend, + setting->ignores, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_list_content_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_list_content_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_content_end_e) { + setting->status = f_string_dynamic_append(f_fss_extended_list_close_s, &setting->buffer); - return; + if (F_status_is_error_not(setting->status)) { + setting->status = f_string_dynamic_append(f_fss_extended_list_close_end_s, &setting->buffer); + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_extended_list_process_content_ @@ -54,32 +70,50 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - setting->status = fl_fss_extended_list_object_write( - *setting->object, - (setting->flag & fss_write_flag_partial_e) - ? (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_partial_trim_e - : f_fss_complete_partial_e - : (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - setting->state, - &setting->range, - &setting->buffer - ); - - if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) { - macro_fss_write_setting(setting)->status = F_status_set_error(F_support_not); + if (setting->object) { + setting->status = fl_fss_extended_list_object_write( + *setting->object, + (setting->flag & fss_write_flag_partial_e) + ? (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) { + macro_fss_write_setting(setting)->status = F_status_set_error(F_support_not); + + fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error); + fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error); + fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error); + + return; + } + + if (F_status_is_error(macro_fss_write_setting(setting)->status)) { + fss_write_print_error(macro_fss_write_setting(setting), main->error, macro_fss_write_f(fl_fss_extended_list_object_write)); + + return; + } + } - fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error); - fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error); - fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_object_open_e) { + setting->status = f_string_dynamic_append(f_fss_extended_list_open_s, &setting->buffer); - return; - } + if (F_status_is_error_not(setting->status)) { + setting->status = f_string_dynamic_append(f_fss_extended_list_open_end_s, &setting->buffer); + } - if (F_status_is_error(macro_fss_write_setting(setting)->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(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + } + } } } #endif // _di_fss_write_extended_list_process_object_ diff --git a/level_3/fss_write/c/extended_list/print.c b/level_3/fss_write/c/extended_list/print.c index f24c56b..3a6d26a 100644 --- a/level_3/fss_write/c/extended_list/print.c +++ b/level_3/fss_write/c/extended_list/print.c @@ -21,6 +21,8 @@ extern "C" { fss_write_print_help_pipe(setting, print); + fss_write_print_help_end_next(setting, 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); diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index b7941fa..4879438 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -27,10 +27,13 @@ extern "C" { const f_string_static_t fss_write_short_as_s = macro_f_string_static_t_initialize(FSS_WRITE_short_as_s, 0, FSS_WRITE_short_as_s_length); const f_string_static_t fss_write_short_backtick_s = macro_f_string_static_t_initialize(FSS_WRITE_short_backtick_s, 0, FSS_WRITE_short_backtick_s_length); const f_string_static_t fss_write_short_content_s = macro_f_string_static_t_initialize(FSS_WRITE_short_content_s, 0, FSS_WRITE_short_content_s_length); + const f_string_static_t fss_write_short_content_end_s = macro_f_string_static_t_initialize(FSS_WRITE_short_content_end_s, 0, FSS_WRITE_short_content_end_s_length); + const f_string_static_t fss_write_short_content_next_s = macro_f_string_static_t_initialize(FSS_WRITE_short_content_next_s, 0, FSS_WRITE_short_content_next_s_length); const f_string_static_t fss_write_short_double_s = macro_f_string_static_t_initialize(FSS_WRITE_short_double_s, 0, FSS_WRITE_short_double_s_length); const f_string_static_t fss_write_short_file_s = macro_f_string_static_t_initialize(FSS_WRITE_short_file_s, 0, FSS_WRITE_short_file_s_length); const f_string_static_t fss_write_short_ignore_s = macro_f_string_static_t_initialize(FSS_WRITE_short_ignore_s, 0, FSS_WRITE_short_ignore_s_length); const f_string_static_t fss_write_short_object_s = macro_f_string_static_t_initialize(FSS_WRITE_short_object_s, 0, FSS_WRITE_short_object_s_length); + const f_string_static_t fss_write_short_object_open_s = macro_f_string_static_t_initialize(FSS_WRITE_short_object_open_s, 0, FSS_WRITE_short_object_open_s_length); const f_string_static_t fss_write_short_partial_s = macro_f_string_static_t_initialize(FSS_WRITE_short_partial_s, 0, FSS_WRITE_short_partial_s_length); const f_string_static_t fss_write_short_prepend_s = macro_f_string_static_t_initialize(FSS_WRITE_short_prepend_s, 0, FSS_WRITE_short_prepend_s_length); const f_string_static_t fss_write_short_single_s = macro_f_string_static_t_initialize(FSS_WRITE_short_single_s, 0, FSS_WRITE_short_single_s_length); @@ -39,10 +42,13 @@ extern "C" { const f_string_static_t fss_write_long_as_s = macro_f_string_static_t_initialize(FSS_WRITE_long_as_s, 0, FSS_WRITE_long_as_s_length); const f_string_static_t fss_write_long_backtick_s = macro_f_string_static_t_initialize(FSS_WRITE_long_backtick_s, 0, FSS_WRITE_long_backtick_s_length); const f_string_static_t fss_write_long_content_s = macro_f_string_static_t_initialize(FSS_WRITE_long_content_s, 0, FSS_WRITE_long_content_s_length); + const f_string_static_t fss_write_long_content_end_s = macro_f_string_static_t_initialize(FSS_WRITE_long_content_end_s, 0, FSS_WRITE_long_content_end_s_length); + const f_string_static_t fss_write_long_content_next_s = macro_f_string_static_t_initialize(FSS_WRITE_long_content_next_s, 0, FSS_WRITE_long_content_next_s_length); const f_string_static_t fss_write_long_double_s = macro_f_string_static_t_initialize(FSS_WRITE_long_double_s, 0, FSS_WRITE_long_double_s_length); const f_string_static_t fss_write_long_file_s = macro_f_string_static_t_initialize(FSS_WRITE_long_file_s, 0, FSS_WRITE_long_file_s_length); const f_string_static_t fss_write_long_ignore_s = macro_f_string_static_t_initialize(FSS_WRITE_long_ignore_s, 0, FSS_WRITE_long_ignore_s_length); const f_string_static_t fss_write_long_object_s = macro_f_string_static_t_initialize(FSS_WRITE_long_object_s, 0, FSS_WRITE_long_object_s_length); + const f_string_static_t fss_write_long_object_open_s = macro_f_string_static_t_initialize(FSS_WRITE_long_object_open_s, 0, FSS_WRITE_long_object_open_s_length); const f_string_static_t fss_write_long_partial_s = macro_f_string_static_t_initialize(FSS_WRITE_long_partial_s, 0, FSS_WRITE_long_partial_s_length); const f_string_static_t fss_write_long_prepend_s = macro_f_string_static_t_initialize(FSS_WRITE_long_prepend_s, 0, FSS_WRITE_long_prepend_s_length); const f_string_static_t fss_write_long_single_s = macro_f_string_static_t_initialize(FSS_WRITE_long_single_s, 0, FSS_WRITE_long_single_s_length); @@ -556,6 +562,89 @@ extern "C" { setting->flag |= fss_write_flag_partial_e; } + { + const uint32_t has[] = { + fss_write_parameter_content_end_e, + fss_write_parameter_content_next_e, + fss_write_parameter_object_open_e, + }; + + const uint16_t has_flag[] = { + fss_write_flag_content_end_e, + fss_write_flag_content_next_e, + fss_write_flag_object_open_e, + }; + + const f_string_static_t has_string[] = { + fss_write_long_content_end_s, + fss_write_long_content_next_s, + fss_write_long_object_open_s, + }; + + const uint16_t has_cannots[][2] = { + { fss_write_parameter_content_next_e, fss_write_parameter_object_open_e }, + { fss_write_parameter_content_end_e, fss_write_parameter_object_open_e }, + { fss_write_parameter_content_end_e, fss_write_parameter_content_next_e }, + }; + + const f_string_static_t has_cannots_string[][2] = { + { fss_write_long_content_next_s, fss_write_long_object_open_s }, + { fss_write_long_content_end_s, fss_write_long_object_open_s }, + { fss_write_long_content_end_s, fss_write_long_content_next_s }, + }; + + 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_flag_object_e | fss_write_flag_content_e)) { + if (!(setting->flag & fss_write_flag_partial_e)) { + setting->status = F_status_set_error(F_parameter); + + fss_write_print_line_first_locked(setting, main->error); + + fll_program_print_error_parameter_cannot_use_with_without( + main->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_flag_object_e) + ? fss_write_long_object_s + : fss_write_long_content_s, + fss_write_long_partial_s + ); + + fss_write_print_line_last_locked(setting, main->error); + + return; + } + } + + if (main->parameters.array[has_cannots[i][0]].result & f_console_result_found_e) { + setting->status = F_status_set_error(F_parameter); + + fss_write_print_line_first_locked(setting, main->error); + 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]); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + if (main->parameters.array[has_cannots[i][1]].result & f_console_result_found_e) { + setting->status = F_status_set_error(F_parameter); + + fss_write_print_line_first_locked(setting, main->error); + 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]); + fss_write_print_line_last_locked(setting, main->error); + + return; + } + + setting->flag |= has_flag[i]; + } + } // for + } + if (setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e)) { if (setting->flag & fss_write_flag_object_e) { if (main->parameters.array[fss_write_parameter_object_e].locations.used != main->parameters.array[fss_write_parameter_object_e].values.used) { diff --git a/level_3/fss_write/c/main/common.h b/level_3/fss_write/c/main/common.h index fcccbed..05b585c 100644 --- a/level_3/fss_write/c/main/common.h +++ b/level_3/fss_write/c/main/common.h @@ -129,61 +129,76 @@ extern "C" { * The main program parameters. */ #ifndef _di_fss_write_parameter_d_ - #define FSS_WRITE_short_as_s "a" - #define FSS_WRITE_short_backtick_s "b" - #define FSS_WRITE_short_content_s "c" - #define FSS_WRITE_short_double_s "d" - #define FSS_WRITE_short_file_s "f" - #define FSS_WRITE_short_ignore_s "I" - #define FSS_WRITE_short_object_s "o" - #define FSS_WRITE_short_partial_s "p" - #define FSS_WRITE_short_prepend_s "P" - #define FSS_WRITE_short_single_s "s" - #define FSS_WRITE_short_trim_s "T" - - #define FSS_WRITE_long_as_s "as" - #define FSS_WRITE_long_backtick_s "backtick" - #define FSS_WRITE_long_content_s "content" - #define FSS_WRITE_long_double_s "double" - #define FSS_WRITE_long_file_s "file" - #define FSS_WRITE_long_ignore_s "ignore" - #define FSS_WRITE_long_object_s "object" - #define FSS_WRITE_long_partial_s "partial" - #define FSS_WRITE_long_prepend_s "prepend" - #define FSS_WRITE_long_single_s "single" - #define FSS_WRITE_long_trim_s "trim" - - #define FSS_WRITE_short_as_s_length 1 - #define FSS_WRITE_short_backtick_s_length 1 - #define FSS_WRITE_short_content_s_length 1 - #define FSS_WRITE_short_double_s_length 1 - #define FSS_WRITE_short_file_s_length 1 - #define FSS_WRITE_short_ignore_s_length 1 - #define FSS_WRITE_short_object_s_length 1 - #define FSS_WRITE_short_partial_s_length 1 - #define FSS_WRITE_short_prepend_s_length 1 - #define FSS_WRITE_short_single_s_length 1 - #define FSS_WRITE_short_trim_s_length 1 - - #define FSS_WRITE_long_as_s_length 2 - #define FSS_WRITE_long_backtick_s_length 8 - #define FSS_WRITE_long_content_s_length 7 - #define FSS_WRITE_long_double_s_length 6 - #define FSS_WRITE_long_file_s_length 4 - #define FSS_WRITE_long_ignore_s_length 6 - #define FSS_WRITE_long_object_s_length 6 - #define FSS_WRITE_long_partial_s_length 7 - #define FSS_WRITE_long_prepend_s_length 7 - #define FSS_WRITE_long_single_s_length 6 - #define FSS_WRITE_long_trim_s_length 4 + #define FSS_WRITE_short_as_s "a" + #define FSS_WRITE_short_backtick_s "b" + #define FSS_WRITE_short_content_s "c" + #define FSS_WRITE_short_content_end_s "E" + #define FSS_WRITE_short_content_next_s "N" + #define FSS_WRITE_short_double_s "d" + #define FSS_WRITE_short_file_s "f" + #define FSS_WRITE_short_ignore_s "I" + #define FSS_WRITE_short_object_s "o" + #define FSS_WRITE_short_object_open_s "O" + #define FSS_WRITE_short_partial_s "p" + #define FSS_WRITE_short_prepend_s "P" + #define FSS_WRITE_short_single_s "s" + #define FSS_WRITE_short_trim_s "T" + + #define FSS_WRITE_long_as_s "as" + #define FSS_WRITE_long_backtick_s "backtick" + #define FSS_WRITE_long_content_s "content" + #define FSS_WRITE_long_content_end_s "content_end" + #define FSS_WRITE_long_content_next_s "content_next" + #define FSS_WRITE_long_double_s "double" + #define FSS_WRITE_long_file_s "file" + #define FSS_WRITE_long_ignore_s "ignore" + #define FSS_WRITE_long_object_s "object" + #define FSS_WRITE_long_object_open_s "object_open" + #define FSS_WRITE_long_partial_s "partial" + #define FSS_WRITE_long_prepend_s "prepend" + #define FSS_WRITE_long_single_s "single" + #define FSS_WRITE_long_trim_s "trim" + + #define FSS_WRITE_short_as_s_length 1 + #define FSS_WRITE_short_backtick_s_length 1 + #define FSS_WRITE_short_content_s_length 1 + #define FSS_WRITE_short_content_end_s_length 1 + #define FSS_WRITE_short_content_next_s_length 1 + #define FSS_WRITE_short_double_s_length 1 + #define FSS_WRITE_short_file_s_length 1 + #define FSS_WRITE_short_ignore_s_length 1 + #define FSS_WRITE_short_object_s_length 1 + #define FSS_WRITE_short_object_open_s_length 1 + #define FSS_WRITE_short_partial_s_length 1 + #define FSS_WRITE_short_prepend_s_length 1 + #define FSS_WRITE_short_single_s_length 1 + #define FSS_WRITE_short_trim_s_length 1 + + #define FSS_WRITE_long_as_s_length 2 + #define FSS_WRITE_long_backtick_s_length 8 + #define FSS_WRITE_long_content_s_length 7 + #define FSS_WRITE_long_content_end_s_length 11 + #define FSS_WRITE_long_content_next_s_length 12 + #define FSS_WRITE_long_double_s_length 6 + #define FSS_WRITE_long_file_s_length 4 + #define FSS_WRITE_long_ignore_s_length 6 + #define FSS_WRITE_long_object_s_length 6 + #define FSS_WRITE_long_object_open_s_length 11 + #define FSS_WRITE_long_partial_s_length 7 + #define FSS_WRITE_long_prepend_s_length 7 + #define FSS_WRITE_long_single_s_length 6 + #define FSS_WRITE_long_trim_s_length 4 extern const f_string_static_t fss_write_short_as_s; extern const f_string_static_t fss_write_short_backtick_s; extern const f_string_static_t fss_write_short_content_s; + extern const f_string_static_t fss_write_short_content_end_s; + extern const f_string_static_t fss_write_short_content_next_s; extern const f_string_static_t fss_write_short_double_s; extern const f_string_static_t fss_write_short_file_s; extern const f_string_static_t fss_write_short_ignore_s; extern const f_string_static_t fss_write_short_object_s; + extern const f_string_static_t fss_write_short_object_open_s; extern const f_string_static_t fss_write_short_partial_s; extern const f_string_static_t fss_write_short_prepend_s; extern const f_string_static_t fss_write_short_single_s; @@ -192,10 +207,13 @@ extern "C" { extern const f_string_static_t fss_write_long_as_s; extern const f_string_static_t fss_write_long_backtick_s; extern const f_string_static_t fss_write_long_content_s; + extern const f_string_static_t fss_write_long_content_end_s; + extern const f_string_static_t fss_write_long_content_next_s; extern const f_string_static_t fss_write_long_double_s; extern const f_string_static_t fss_write_long_file_s; extern const f_string_static_t fss_write_long_ignore_s; extern const f_string_static_t fss_write_long_object_s; + extern const f_string_static_t fss_write_long_object_open_s; extern const f_string_static_t fss_write_long_partial_s; extern const f_string_static_t fss_write_long_prepend_s; extern const f_string_static_t fss_write_long_single_s; @@ -218,10 +236,13 @@ extern "C" { 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, @@ -246,17 +267,20 @@ extern "C" { macro_f_console_parameter_t_initialize2(fss_write_short_as_s.string, fss_write_long_as_s.string, 0, 1, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_backtick_s.string, fss_write_long_backtick_s.string, 0, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_content_s.string, fss_write_long_content_s.string, 0, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize2(fss_write_short_content_end_s.string, fss_write_long_content_end_s.string, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize2(fss_write_short_content_next_s.string, fss_write_long_content_next_s.string, 0, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_double_s.string, fss_write_long_double_s.string, 0, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_file_s.string, fss_write_long_file_s.string, 0, 1, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_ignore_s.string, fss_write_long_ignore_s.string, 0, 2, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_object_s.string, fss_write_long_object_s.string, 0, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize2(fss_write_short_object_open_s.string, fss_write_long_object_open_s.string, 0, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_partial_s.string, fss_write_long_partial_s.string, 0, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_prepend_s.string, fss_write_long_prepend_s.string, 0, 1, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_single_s.string, fss_write_long_single_s.string, 0, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize2(fss_write_short_trim_s.string, fss_write_long_trim_s.string, 0, 0, f_console_flag_normal_e), \ } - #define fss_write_total_parameters_d 23 + #define fss_write_total_parameters_d 26 #endif // _di_fss_write_parameter_d_ /** @@ -265,11 +289,14 @@ extern "C" { * fss_write_flag_*_e: * - none: No modes in use. * - 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. * - 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. * - prepend: Prepend the given white space characters to the start of each multi-line Content. * - trim: Trim Object names. @@ -279,15 +306,18 @@ extern "C" { enum { fss_write_flag_none_e = 0x0, fss_write_flag_content_e = 0x1, - fss_write_flag_content_multiple_e = 0x2, - fss_write_flag_file_to_e = 0x4, - fss_write_flag_help_e = 0x8, - fss_write_flag_ignore_e = 0x10, - fss_write_flag_object_e = 0x20, - fss_write_flag_partial_e = 0x40, - fss_write_flag_prepend_e = 0x80, - fss_write_flag_trim_e = 0x100, - fss_write_flag_version_e = 0x200, + fss_write_flag_content_end_e = 0x2, + fss_write_flag_content_multiple_e = 0x4, + fss_write_flag_content_next_e = 0x8, + fss_write_flag_file_to_e = 0x10, + fss_write_flag_help_e = 0x20, + fss_write_flag_ignore_e = 0x40, + fss_write_flag_object_e = 0x80, + fss_write_flag_object_open_e = 0x100, + fss_write_flag_partial_e = 0x200, + fss_write_flag_prepend_e = 0x400, + fss_write_flag_trim_e = 0x800, + fss_write_flag_version_e = 0x1000, }; // enum #endif // _di_fss_write_flag_e_ diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index 89a82c2..ddefbe8 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -30,7 +30,7 @@ extern "C" { if (F_status_is_error(setting->status)) return; } - if (setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e)) { + if (setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e | fss_write_flag_object_open_e | fss_write_flag_content_next_e | fss_write_flag_content_end_e)) { setting->process_normal(main, setting); if (F_status_is_error(setting->status)) return; } @@ -61,34 +61,45 @@ extern "C" { setting->content = 0; setting->contents = 0; - for (f_array_length_t i = 0; i < length; ++i) { + 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)) { - if (fll_program_standard_signal_received(main)) { - setting->status = F_status_set_error(F_interrupt); + // @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)) { + if (fll_program_standard_signal_received(main)) { + setting->status = F_status_set_error(F_interrupt); - return; + return; + } + + main->signal_check = 0; } - main->signal_check = 0; - } + if (setting->objects.used) { + setting->object = &setting->objects.array[i]; + } - if (setting->objects.used) { - setting->object = &setting->objects.array[i]; - } + if (setting->contentss.used) { + setting->contents = &setting->contentss.array[i]; + } - if (setting->contentss.used) { - setting->contents = &setting->contentss.array[i]; - } + if (setting->ignoress.used) { + setting->ignores = &setting->ignoress.array[i]; + } - if (setting->ignoress.used) { - setting->ignores = &setting->ignoress.array[i]; - } + setting->process_set(main, setting); + if (F_status_is_error(setting->status)) break; + } // for + } + else { + if (setting->flag & (fss_write_flag_object_open_e | fss_write_flag_content_next_e | fss_write_flag_content_end_e)) { + setting->object = 0; + setting->contents = 0; + setting->ignores = 0; - setting->process_set(main, setting); - if (F_status_is_error(setting->status)) break; - } // for + setting->process_set(main, setting); + } + } } #endif // _di_fss_write_process_normal_data_ @@ -406,37 +417,49 @@ extern "C" { setting->buffer.used = 0; - if ((!(setting->flag & fss_write_flag_partial_e) || (setting->flag & fss_write_flag_partial_e) && (setting->flag & fss_write_flag_object_e)) && setting->object) { - if (setting->object->used) { - setting->range.start = 0; - setting->range.stop = setting->object->used - 1; - } - else { - setting->range.start = 1; - setting->range.stop = 0; - } + if ((!(setting->flag & fss_write_flag_partial_e) || (setting->flag & fss_write_flag_partial_e) && (setting->flag & fss_write_flag_object_e)) && setting->object || (setting->flag & fss_write_flag_object_open_e)) { - setting->process_object(main, void_setting); - if (F_status_is_error(setting->status)) return; - } - - if ((!(setting->flag & fss_write_flag_partial_e) || (setting->flag & fss_write_flag_partial_e) && (setting->flag & fss_write_flag_content_e)) && setting->contents) { - for (f_array_length_t i = 0; i < setting->contents->used; ++i) { - - if (setting->contents->array[i].used) { + if (setting->object) { + if (setting->object->used) { setting->range.start = 0; - setting->range.stop = setting->contents->array[i].used - 1; + setting->range.stop = setting->object->used - 1; } else { setting->range.start = 1; setting->range.stop = 0; } + } + + setting->process_object(main, void_setting); + if (F_status_is_error(setting->status)) return; + } + + if ((!(setting->flag & fss_write_flag_partial_e) || (setting->flag & fss_write_flag_partial_e) && (setting->flag & fss_write_flag_content_e)) && setting->contents || (setting->flag & (fss_write_flag_content_next_e | fss_write_flag_content_end_e))) { - setting->content = &setting->contents->array[i]; + if (setting->contents && setting->contents->used) { + for (f_array_length_t i = 0; i < setting->contents->used; ++i) { - setting->process_content(main, void_setting, i + 1 == setting->contents->used); + if (setting->contents->array[i].used) { + setting->range.start = 0; + setting->range.stop = setting->contents->array[i].used - 1; + } + else { + setting->range.start = 1; + setting->range.stop = 0; + } + + setting->content = &setting->contents->array[i]; + + setting->process_content(main, void_setting, i + 1 == setting->contents->used); + if (F_status_is_error(setting->status)) return; + } // for + } + else { + setting->content = 0; + + setting->process_content(main, void_setting, F_true); if (F_status_is_error(setting->status)) return; - } // for + } } if (setting->buffer.used) { diff --git a/level_3/fss_write/c/main/main-print.c b/level_3/fss_write/c/main/main-print.c index 5150f8d..29e94d7 100644 --- a/level_3/fss_write/c/main/main-print.c +++ b/level_3/fss_write/c/main/main-print.c @@ -50,6 +50,8 @@ extern "C" { 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); diff --git a/level_3/fss_write/c/main/print.c b/level_3/fss_write/c/main/print.c index f45278f..aa5f977 100644 --- a/level_3/fss_write/c/main/print.c +++ b/level_3/fss_write/c/main/print.c @@ -120,20 +120,36 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, print.to); - 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_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_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_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_partial_s, fss_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_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."); + 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_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_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) { + + 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) { diff --git a/level_3/fss_write/c/main/print.h b/level_3/fss_write/c/main/print.h index 6ac12f8..e8f67c4 100644 --- a/level_3/fss_write/c/main/print.h +++ b/level_3/fss_write/c/main/print.h @@ -152,6 +152,22 @@ extern "C" { #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.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. diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index ad4a2e1..024b3f6 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -378,8 +378,8 @@ extern "C" { fss_write_setting_t * const setting = macro_fss_write_setting(void_setting); - if ((!(setting->flag & fss_write_flag_partial_e) || (setting->flag & fss_write_flag_partial_e) && (setting->flag & fss_write_flag_object_e)) && setting->object) { - if (!(setting->flag & fss_write_flag_partial_e) && setting->contents && setting->contents->used) { + if ((!(setting->flag & fss_write_flag_partial_e) || (setting->flag & fss_write_flag_partial_e) && (setting->flag & fss_write_flag_object_e))) { + if (setting->object && !(setting->flag & fss_write_flag_partial_e) && setting->contents && setting->contents->used) { if (setting->object->used) { setting->range.start = 0; setting->range.stop = setting->object->used - 1; @@ -417,73 +417,105 @@ extern "C" { } } else { - if (setting->object->used) { - setting->range.start = 0; - setting->range.stop = setting->object->used - 1; - } - else { - setting->range.start = 1; - setting->range.stop = 0; - } + if (setting->object) { + if (setting->object->used) { + setting->range.start = 0; + setting->range.stop = setting->object->used - 1; + } + else { + setting->range.start = 1; + setting->range.stop = 0; + } - setting->status = fl_fss_basic_list_object_write( - *setting->object, - (setting->flag & fss_write_flag_partial_e) - ? (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_partial_trim_e - : f_fss_complete_partial_e - : (setting->flag & fss_write_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - setting->state, - &setting->range, - &setting->buffer - ); + setting->status = fl_fss_basic_list_object_write( + *setting->object, + (setting->flag & fss_write_flag_partial_e) + ? (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (setting->flag & fss_write_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + setting->state, + &setting->range, + &setting->buffer + ); + + if (F_status_set_fine(setting->status) == F_none_eol) { + setting->status = F_status_set_error(F_support_not); - if (F_status_set_fine(setting->status) == F_none_eol) { - setting->status = F_status_set_error(F_support_not); + fss_write_print_line_first_locked(setting, main->error); + fss_write_print_error_unsupported_eol(setting, main->error); + fss_write_print_line_last_locked(setting, main->error); - fss_write_print_line_first_locked(setting, main->error); - fss_write_print_error_unsupported_eol(setting, main->error); - fss_write_print_line_last_locked(setting, main->error); + return; + } - return; + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); + + return; + } } - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_content_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_object_open_e) { + setting->status = f_string_dynamic_append(f_fss_basic_list_open_s, &setting->buffer); - return; + if (F_status_is_error_not(setting->status)) { + setting->status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &setting->buffer); + } + + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); + + return; + } + } } } } - 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; + 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; + + const f_string_static_t *prepend = 0; - const f_string_static_t *prepend = 0; + if (setting->flag & fss_write_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 (setting->flag & fss_write_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]; + prepend = &main->parameters.arguments.array[index]; + } - prepend = &main->parameters.arguments.array[index]; + setting->status = fl_fss_basic_list_content_write( + setting->contents->array[0], + setting->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_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_payload_content_write)); + + return; + } } - setting->status = fl_fss_basic_list_content_write( - setting->contents->array[0], - setting->object - ? f_fss_complete_full_e - : f_fss_complete_none_e, - prepend, - setting->state, - &setting->range, - &setting->buffer - ); + if ((setting->flag & fss_write_flag_partial_e) && !(setting->flag & fss_write_flag_object_e) || !(setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e))) { + if (setting->flag & fss_write_flag_content_end_e) { + setting->status = f_string_dynamic_append(f_fss_basic_list_close_s, &setting->buffer); - if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_payload_content_write)); + if (F_status_is_error(setting->status)) { + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); - return; + return; + } + } } } diff --git a/level_3/fss_write/c/payload/print.c b/level_3/fss_write/c/payload/print.c index 925bd05..b091049 100644 --- a/level_3/fss_write/c/payload/print.c +++ b/level_3/fss_write/c/payload/print.c @@ -38,6 +38,8 @@ extern "C" { fss_write_print_help_pipe(setting, print); + fss_write_print_help_end_next(setting, 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);