From: Kevin Day Date: Sat, 12 Oct 2024 03:28:04 +0000 (-0500) Subject: Bugfix: The FSS Payload Read is not treating the Payload as raw when printing. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=3b8b0cba03096e764194db8bb889cd94a8d97f5b;p=fll Bugfix: The FSS Payload Read is not treating the Payload as raw when printing. Special handling is needed to process the `payload` section. The content functions all need to have the `at` position to determine this. Update the callbacks to allow for this. The function `fss_read_print_content_empty()` is defined and used but it is used only for the `print_object_end_empty()` callback. Add a `print_content_empty()` callback to provide this. These changes allow for removing redundant functions. --- diff --git a/level_3/fss_read/c/basic/main.c b/level_3/fss_read/c/basic/main.c index fa41f1d..0aaa8db 100644 --- a/level_3/fss_read/c/basic/main.c +++ b/level_3/fss_read/c/basic/main.c @@ -37,11 +37,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + data.callback.print_content_empty = &fss_read_print_content_empty; data.callback.print_content_ignore = 0; data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; data.callback.print_object_end = &fss_read_basic_print_object_end; - data.callback.print_object_end_content = &fss_read_basic_print_object_end_content; + data.callback.print_object_end_content = &fss_read_print_object_end_content; data.callback.print_object_end_empty = &fss_read_print_content_empty; data.callback.print_set_end = &fss_read_print_set_end; diff --git a/level_3/fss_read/c/basic/print.c b/level_3/fss_read/c/basic/print.c index f7dfd20..b452f82 100644 --- a/level_3/fss_read/c/basic/print.c +++ b/level_3/fss_read/c/basic/print.c @@ -22,18 +22,6 @@ extern "C" { } #endif // _di_fss_read_basic_print_object_end_ -#ifndef _di_fss_read_basic_print_object_end_content_ - f_status_t fss_read_basic_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { - - { - const f_status_t status = fss_read_basic_print_object_end(print); - if (F_status_is_error(status) || status == F_output_not) return status; - } - - return fss_read_print_content(print, range, quote, delimits); - } -#endif // _di_fss_read_basic_print_object_end_content_ - #ifndef _di_fss_read_basic_print_message_help_ f_status_t fss_read_basic_print_message_help(fl_print_t * const print) { diff --git a/level_3/fss_read/c/basic/print.h b/level_3/fss_read/c/basic/print.h index 8e6b095..de72387 100644 --- a/level_3/fss_read/c/basic/print.h +++ b/level_3/fss_read/c/basic/print.h @@ -35,37 +35,6 @@ extern "C" { #endif // _di_fss_read_basic_print_object_end_ /** - * Print the end of an Object (which is often the start of Content) and the Content. - * - * This locks, uses, and unlocks the file stream. - * - * This processes single Content range. - * This does not print a new line after the Content. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * @param range - * The range within the buffer representing the Content to print. - * @param quote - * The quote type representing the character to use (from the f_fss_quote_type_*_e). - * @param delimits - * The delimits array representing a delimited Content. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - */ -#ifndef _di_fss_read_basic_print_object_end_content_ - extern f_status_t fss_read_basic_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); -#endif // _di_fss_read_basic_print_object_end_content_ - -/** * Print help for FSS-0000 (Basic). * * @param print diff --git a/level_3/fss_read/c/basic_list/main.c b/level_3/fss_read/c/basic_list/main.c index 9b00243..6b85e52 100644 --- a/level_3/fss_read/c/basic_list/main.c +++ b/level_3/fss_read/c/basic_list/main.c @@ -41,8 +41,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; data.callback.print_object_end = &fss_read_basic_list_print_object_end; - data.callback.print_object_end_content = &fss_read_basic_list_print_object_end_content; - data.callback.print_object_end_empty = &fss_read_basic_list_print_object_end_empty; + data.callback.print_object_end_content = &fss_read_print_object_end_content; + data.callback.print_object_end_empty = &fss_read_print_object_end_empty; data.callback.print_set_end = &fss_read_print_set_end_no_eol; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/basic_list/print.c b/level_3/fss_read/c/basic_list/print.c index 8ee1d00..4dae7c6 100644 --- a/level_3/fss_read/c/basic_list/print.c +++ b/level_3/fss_read/c/basic_list/print.c @@ -30,33 +30,6 @@ extern "C" { } #endif // _di_fss_read_basic_list_print_object_end_ -#ifndef _di_fss_read_basic_list_print_object_end_content_ - f_status_t fss_read_basic_list_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { - - { - const f_status_t status = fss_read_basic_list_print_object_end(print); - if (F_status_is_error(status) || status == F_output_not) return status; - } - - return fss_read_print_content(print, range, quote, delimits); - } -#endif // _di_fss_read_basic_list_print_object_end_content_ - -#ifndef _di_fss_read_basic_list_print_object_end_empty_ - f_status_t fss_read_basic_list_print_object_end_empty(fl_print_t * const print) { - - if (!print) return F_status_set_error(F_output_not); - - const f_status_t status_1 = fss_read_basic_list_print_object_end(print); - const f_status_t status_2 = fss_read_print_content_empty(print); - - if (F_status_is_error(status_1)) return status_1; - if (F_status_is_error(status_2)) return status_2; - - return (status_1 == F_okay || status_2 == F_okay) ? F_okay: F_output_not; - } -#endif // _di_fss_read_basic_list_print_object_end_empty_ - #ifndef _di_fss_read_basic_list_print_message_help_ f_status_t fss_read_basic_list_print_message_help(fl_print_t * const print) { diff --git a/level_3/fss_read/c/basic_list/print.h b/level_3/fss_read/c/basic_list/print.h index 6232420..d54b304 100644 --- a/level_3/fss_read/c/basic_list/print.h +++ b/level_3/fss_read/c/basic_list/print.h @@ -35,61 +35,6 @@ extern "C" { #endif // _di_fss_read_basic_list_print_object_end_ /** - * Print the end of an Object (which is often the start of Content) and the Content. - * - * This locks, uses, and unlocks the file stream. - * - * This processes single Content range. - * This does not print a new line after the Content. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * @param range - * The range within the buffer representing the Content to print. - * @param quote - * The quote type representing the character to use (from the f_fss_quote_type_*_e). - * @param delimits - * The delimits array representing a delimited Content. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - */ -#ifndef _di_fss_read_basic_list_print_object_end_content_ - extern f_status_t fss_read_basic_list_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); -#endif // _di_fss_read_basic_list_print_object_end_content_ - -/** - * Print the end of an Object (which is often the start of Content) and the end of the Content when no Content. - * - * This locks, uses, and unlocks the file stream. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see fss_read_print_content_empty() - */ -#ifndef _di_fss_read_basic_list_print_object_end_empty_ - extern f_status_t fss_read_basic_list_print_object_end_empty(fl_print_t * const print); -#endif // _di_fss_read_basic_list_print_object_end_empty_ - -/** * Print help for FSS-0002 (Basic List). * * @param print diff --git a/level_3/fss_read/c/embedded_list/main.c b/level_3/fss_read/c/embedded_list/main.c index aa8dabe..7855085 100644 --- a/level_3/fss_read/c/embedded_list/main.c +++ b/level_3/fss_read/c/embedded_list/main.c @@ -42,8 +42,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; data.callback.print_object_end = &fss_read_embedded_list_print_object_end; - data.callback.print_object_end_content = &fss_read_embedded_list_print_object_end_content; - data.callback.print_object_end_empty = &fss_read_embedded_list_print_object_end_empty; + data.callback.print_object_end_content = &fss_read_print_object_end_content; + data.callback.print_object_end_empty = &fss_read_print_object_end_empty; data.callback.print_set_end = &fss_read_embedded_list_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/embedded_list/print.c b/level_3/fss_read/c/embedded_list/print.c index cec5896..442a30c 100644 --- a/level_3/fss_read/c/embedded_list/print.c +++ b/level_3/fss_read/c/embedded_list/print.c @@ -30,33 +30,6 @@ extern "C" { } #endif // _di_fss_read_embedded_list_print_object_end_ -#ifndef _di_fss_read_embedded_list_print_object_end_content_ - f_status_t fss_read_embedded_list_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { - - { - const f_status_t status = fss_read_embedded_list_print_object_end(print); - if (F_status_is_error(status) || status == F_output_not) return status; - } - - return fss_read_print_content(print, range, quote, delimits); - } -#endif // _di_fss_read_embedded_list_print_object_end_content_ - -#ifndef _di_fss_read_embedded_list_print_object_end_empty_ - f_status_t fss_read_embedded_list_print_object_end_empty(fl_print_t * const print) { - - if (!print) return F_status_set_error(F_output_not); - - const f_status_t status_1 = fss_read_embedded_list_print_object_end(print); - const f_status_t status_2 = fss_read_print_content_empty(print); - - if (F_status_is_error(status_1)) return status_1; - if (F_status_is_error(status_2)) return status_2; - - return (status_1 == F_okay || status_2 == F_okay) ? F_okay: F_output_not; - } -#endif // _di_fss_read_embedded_list_print_object_end_empty_ - #ifndef _di_fss_read_embedded_list_print_set_end_ f_status_t fss_read_embedded_list_print_set_end(fl_print_t * const print, const f_number_unsigned_t close) { diff --git a/level_3/fss_read/c/embedded_list/print.h b/level_3/fss_read/c/embedded_list/print.h index 8b5a415..6e7b4bf 100644 --- a/level_3/fss_read/c/embedded_list/print.h +++ b/level_3/fss_read/c/embedded_list/print.h @@ -35,61 +35,6 @@ extern "C" { #endif // _di_fss_read_embedded_list_print_object_end_ /** - * Print the end of an Object (which is often the start of Content) and the Content. - * - * This locks, uses, and unlocks the file stream. - * - * This processes single Content range. - * This does not print a new line after the Content. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * @param range - * The range within the buffer representing the Content to print. - * @param quote - * The quote type representing the character to use (from the f_fss_quote_type_*_e). - * @param delimits - * The delimits array representing a delimited Content. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - */ -#ifndef _di_fss_read_embedded_list_print_object_end_content_ - extern f_status_t fss_read_embedded_list_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); -#endif // _di_fss_read_embedded_list_print_object_end_content_ - -/** - * Print the end of an Object (which is often the start of Content) and the end of the Content when no Content. - * - * This locks, uses, and unlocks the file stream. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see fss_read_print_content_empty() - */ -#ifndef _di_fss_read_embedded_list_print_object_end_empty_ - extern f_status_t fss_read_embedded_list_print_object_end_empty(fl_print_t * const print); -#endif // _di_fss_read_embedded_list_print_object_end_empty_ - -/** * Print the end of an Object/Content set. * * This locks, uses, and unlocks the file stream. diff --git a/level_3/fss_read/c/extended/main.c b/level_3/fss_read/c/extended/main.c index 8b61dc1..325bdbc 100644 --- a/level_3/fss_read/c/extended/main.c +++ b/level_3/fss_read/c/extended/main.c @@ -37,11 +37,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + data.callback.print_content_empty = &fss_read_print_content_empty; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_content_next = &fss_read_extended_print_content_next; data.callback.print_object = &fss_read_print_object; data.callback.print_object_end = &fss_read_extended_print_object_end; - data.callback.print_object_end_content = &fss_read_extended_print_object_end_content; + data.callback.print_object_end_content = &fss_read_print_object_end_content; data.callback.print_object_end_empty = &fss_read_print_content_empty; data.callback.print_set_end = &fss_read_print_set_end; diff --git a/level_3/fss_read/c/extended/print.c b/level_3/fss_read/c/extended/print.c index 98d0730..e1a50fb 100644 --- a/level_3/fss_read/c/extended/print.c +++ b/level_3/fss_read/c/extended/print.c @@ -40,18 +40,6 @@ extern "C" { } #endif // _di_fss_read_extended_print_object_end_ -#ifndef _di_fss_read_extended_print_object_end_content_ - f_status_t fss_read_extended_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { - - { - const f_status_t status = fss_read_extended_print_object_end(print); - if (F_status_is_error(status) || status == F_output_not) return status; - } - - return fss_read_print_content(print, range, quote, delimits); - } -#endif // _di_fss_read_extended_print_object_end_content_ - #ifndef _di_fss_read_extended_print_message_help_ f_status_t fss_read_extended_print_message_help(fl_print_t * const print) { diff --git a/level_3/fss_read/c/extended/print.h b/level_3/fss_read/c/extended/print.h index 5c02ffb..cfd62ec 100644 --- a/level_3/fss_read/c/extended/print.h +++ b/level_3/fss_read/c/extended/print.h @@ -59,37 +59,6 @@ extern "C" { #endif // _di_fss_read_extended_print_object_end_ /** - * Print the end of an Object (which is often the start of Content) and the Content. - * - * This locks, uses, and unlocks the file stream. - * - * This processes single Content range. - * This does not print a new line after the Content. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * @param range - * The range within the buffer representing the Content to print. - * @param quote - * The quote type representing the character to use (from the f_fss_quote_type_*_e). - * @param delimits - * The delimits array representing a delimited Content. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - */ -#ifndef _di_fss_read_extended_print_object_end_content_ - extern f_status_t fss_read_extended_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); -#endif // _di_fss_read_extended_print_object_end_content_ - -/** * Print help for FSS-0001 (Extended). * * @param print diff --git a/level_3/fss_read/c/extended_list/main.c b/level_3/fss_read/c/extended_list/main.c index 25f335b..aabf6ab 100644 --- a/level_3/fss_read/c/extended_list/main.c +++ b/level_3/fss_read/c/extended_list/main.c @@ -41,8 +41,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; data.callback.print_object_end = &fss_read_extended_list_print_object_end; - data.callback.print_object_end_content = &fss_read_extended_list_print_object_end_content; - data.callback.print_object_end_empty = &fss_read_extended_list_print_object_end_empty; + data.callback.print_object_end_content = &fss_read_print_object_end_content; + data.callback.print_object_end_empty = &fss_read_print_object_end_empty; data.callback.print_set_end = &fss_read_extended_list_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; diff --git a/level_3/fss_read/c/extended_list/print.c b/level_3/fss_read/c/extended_list/print.c index eeaf18b..e18931f 100644 --- a/level_3/fss_read/c/extended_list/print.c +++ b/level_3/fss_read/c/extended_list/print.c @@ -30,33 +30,6 @@ extern "C" { } #endif // _di_fss_read_extended_list_print_object_end_ -#ifndef _di_fss_read_extended_list_print_object_end_empty_ - f_status_t fss_read_extended_list_print_object_end_empty(fl_print_t * const print) { - - if (!print) return F_status_set_error(F_output_not); - - const f_status_t status_1 = fss_read_extended_list_print_object_end(print); - const f_status_t status_2 = fss_read_print_content_empty(print); - - if (F_status_is_error(status_1)) return status_1; - if (F_status_is_error(status_2)) return status_2; - - return (status_1 == F_okay || status_2 == F_okay) ? F_okay: F_output_not; - } -#endif // _di_fss_read_extended_list_print_object_end_empty_ - -#ifndef _di_fss_read_extended_list_print_object_end_content_ - f_status_t fss_read_extended_list_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { - - { - const f_status_t status = fss_read_extended_list_print_object_end(print); - if (F_status_is_error(status) || status == F_output_not) return status; - } - - return fss_read_print_content(print, range, quote, delimits); - } -#endif // _di_fss_read_extended_list_print_object_end_content_ - #ifndef _di_fss_read_extended_list_print_set_end_ f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print, const f_number_unsigned_t close) { diff --git a/level_3/fss_read/c/extended_list/print.h b/level_3/fss_read/c/extended_list/print.h index 59d896c..86926dd 100644 --- a/level_3/fss_read/c/extended_list/print.h +++ b/level_3/fss_read/c/extended_list/print.h @@ -35,62 +35,6 @@ extern "C" { #endif // _di_fss_read_extended_list_print_object_end_ /** - * Print the end of an Object (which is often the start of Content) and the Content. - * - * This locks, uses, and unlocks the file stream. - * - * This processes single Content range. - * This does not print a new line after the Content. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * @param range - * The range within the buffer representing the Content to print. - * @param quote - * The quote type representing the character to use (from the f_fss_quote_type_*_e). - * @param delimits - * The delimits array representing a delimited Content. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - */ -#ifndef _di_fss_read_extended_list_print_object_end_content_ - extern f_status_t fss_read_extended_list_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); -#endif // _di_fss_read_extended_list_print_object_end_content_ - -/** - * Print the end of an Object (which is often the start of Content) and the end of the Content when no Content. - * - * This locks, uses, and unlocks the file stream. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see fss_read_extended_list_print_object_end() - * @see fss_read_print_content_empty() - */ -#ifndef _di_fss_read_extended_list_print_object_end_empty_ - extern f_status_t fss_read_extended_list_print_object_end_empty(fl_print_t * const print); -#endif // _di_fss_read_extended_list_print_object_end_empty_ - -/** * Print the end of an Object/Content set. * * This locks, uses, and unlocks the file stream. diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index a654d74..005e7ca 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -148,6 +148,7 @@ extern "C" { * print_at: Print at the given location, usually called by the process_normal() callback. * print_object: Print the Object, usually called by the process_normal() callback. * print_content: Print the Content, usually called by the process_normal() callback. + * print_content_empty: Print when there is no Content, usually called by the process_normal() callback. * print_content_ignore: Print the Content ignore character, usually called by several callbacks within the process_normal() callback for a pipe. * print_content_next: Print the Content next (content separator), usually called by several callbacks within the process_normal() callback. * print_object_end: Print the Object end, usually called by several callbacks within the process_normal() callback. @@ -171,8 +172,9 @@ extern "C" { f_status_t (*print_at)(fl_print_t * const print, const f_number_unsigned_t at, const f_number_unsigneds_t delimits_object, const f_number_unsigneds_t delimits_content); f_status_t (*print_object)(fl_print_t * const print, const f_number_unsigned_t at, const f_number_unsigneds_t delimits); - f_status_t (*print_object_end_content)(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); - f_status_t (*print_content)(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); + f_status_t (*print_object_end_content)(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); + f_status_t (*print_content)(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); + f_status_t (*print_content_empty)(fl_print_t * const print); f_status_t (*print_content_ignore)(fl_print_t * const print); f_status_t (*print_content_next)(fl_print_t * const print); f_status_t (*print_object_end)(fl_print_t * const print); @@ -202,6 +204,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ } #endif // _di_fss_read_callback_t_ diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index 5fc4cf0..efa7e11 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -111,11 +111,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.print_at = &fss_read_print_at; main->callback.print_content = &fss_read_print_content; + main->callback.print_content_empty = &fss_read_print_content_empty; main->callback.print_content_ignore = 0; main->callback.print_content_next = 0; main->callback.print_object = &fss_read_print_object; main->callback.print_object_end = &fss_read_basic_print_object_end; - main->callback.print_object_end_content = &fss_read_basic_print_object_end_content; + main->callback.print_object_end_content = &fss_read_print_object_end_content; main->callback.print_object_end_empty = &fss_read_print_content_empty; main->callback.print_set_end = &fss_read_print_set_end; @@ -168,10 +169,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total; + main->callback.print_content = &fss_read_print_content; main->callback.print_content_ignore = 0; main->callback.print_content_next = 0; main->callback.print_object_end = &fss_read_basic_print_object_end; - main->callback.print_object_end_content = &fss_read_basic_print_object_end_content; + main->callback.print_object_end_content = &fss_read_print_object_end_content; main->callback.print_object_end_empty = &fss_read_print_content_empty; main->callback.print_set_end = &fss_read_print_set_end; } @@ -205,9 +207,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total; + main->callback.print_content = &fss_read_print_content; main->callback.print_content_next = &fss_read_extended_print_content_next; main->callback.print_object_end = &fss_read_extended_print_object_end; - main->callback.print_object_end_content = &fss_read_extended_print_object_end_content; + main->callback.print_object_end_content = &fss_read_print_object_end_content; main->callback.print_object_end_empty = &fss_read_print_content_empty; main->callback.print_set_end = &fss_read_print_set_end; } @@ -241,10 +244,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total_multiple; + main->callback.print_content = &fss_read_print_content; main->callback.print_content_next = 0; main->callback.print_object_end = &fss_read_basic_list_print_object_end; - main->callback.print_object_end_content = &fss_read_basic_list_print_object_end_content; - main->callback.print_object_end_empty = &fss_read_basic_list_print_object_end_empty; + main->callback.print_object_end_content = &fss_read_print_object_end_content; + main->callback.print_object_end_empty = &fss_read_print_object_end_empty; main->callback.print_set_end = &fss_read_print_set_end_no_eol; } else if (f_compare_dynamic(as, fss_read_format_code_short_0003_s) == F_equal_to || @@ -271,7 +275,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; - main->callback.process_at = &fss_read_process_normal_at; main->callback.process_at_line = &fss_read_process_normal_at_line; main->callback.process_columns = &fss_read_process_normal_columns; @@ -281,10 +284,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total_multiple; + main->callback.print_content = &fss_read_print_content; main->callback.print_content_next = 0; main->callback.print_object_end = &fss_read_extended_list_print_object_end; - main->callback.print_object_end_content = &fss_read_extended_list_print_object_end_content; - main->callback.print_object_end_empty = &fss_read_extended_list_print_object_end_empty; + main->callback.print_object_end_content = &fss_read_print_object_end_content; + main->callback.print_object_end_empty = &fss_read_print_object_end_empty; main->callback.print_set_end = &fss_read_extended_list_print_set_end; } else if (f_compare_dynamic(as, fss_read_format_code_short_0008_s) == F_equal_to || @@ -319,10 +323,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_normal = &fss_read_embedded_list_process_normal; main->callback.process_total = &fss_read_process_normal_total_multiple; + main->callback.print_content = &fss_read_print_content; main->callback.print_content_next = 0; main->callback.print_object_end = &fss_read_embedded_list_print_object_end; - main->callback.print_object_end_content = &fss_read_embedded_list_print_object_end_content; - main->callback.print_object_end_empty = &fss_read_embedded_list_print_object_end_empty; + main->callback.print_object_end_content = &fss_read_print_object_end_content; + main->callback.print_object_end_empty = &fss_read_print_object_end_empty; main->callback.print_set_end = &fss_read_embedded_list_print_set_end; } else if (f_compare_dynamic(as, fss_read_format_code_short_000e_s) == F_equal_to || @@ -347,7 +352,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->program.parameters.array[fss_read_parameter_payload_e].flag &= ~f_console_flag_disable_e; - main->callback.process_at = &fss_read_process_normal_at; main->callback.process_at_line = &fss_read_process_normal_at_line; main->callback.process_columns = &fss_read_process_normal_columns; @@ -357,10 +361,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_normal = &fss_read_process_normal; main->callback.process_total = &fss_read_process_normal_total_multiple; + main->callback.print_content = &fss_read_payload_print_content; main->callback.print_content_next = 0; main->callback.print_object_end = &fss_read_payload_print_object_end; - main->callback.print_object_end_content = &fss_read_payload_print_object_end_content; - main->callback.print_object_end_empty = &fss_read_payload_print_object_end_empty; + main->callback.print_object_end_content = &fss_read_print_object_end_content; + main->callback.print_object_end_empty = &fss_read_print_object_end_empty; main->callback.print_set_end = &fss_read_print_set_end_no_eol; } else { diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index c74e924..824b204 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -38,6 +38,7 @@ extern "C" { if (F_status_set_fine( main->callback.print_object_end_content( &main->program.output, + at, main->setting.contents.array[at].array[main->setting.select], (at < main->setting.quotes_content.used && main->setting.select < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[main->setting.select] : 0, delimits_content @@ -50,6 +51,7 @@ extern "C" { if (F_status_set_fine( main->callback.print_content( &main->program.output, + at, main->setting.contents.array[at].array[main->setting.select], (at < main->setting.quotes_content.used && main->setting.select < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[main->setting.select] : 0, delimits_content @@ -80,6 +82,7 @@ extern "C" { if (F_status_set_fine( main->callback.print_object_end_content( &main->program.output, + at, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content @@ -91,6 +94,7 @@ extern "C" { else if (F_status_set_fine( main->callback.print_content( &main->program.output, + at, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content @@ -116,6 +120,7 @@ extern "C" { main->callback.print_content( &main->program.output, + at, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content @@ -167,7 +172,7 @@ extern "C" { #endif // _di_fss_read_print_at_ #ifndef _di_fss_read_print_content_ - f_status_t fss_read_print_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { + f_status_t fss_read_print_content(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -371,17 +376,42 @@ extern "C" { } #endif // _di_fss_read_print_object_ -#ifndef _di_fss_read_print_object_content_ - f_status_t fss_read_print_object_content(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits_object, const f_number_unsigneds_t delimits_content) { +#ifndef _di_fss_read_print_object_end_content_ + f_status_t fss_read_print_object_end_content(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { - { - const f_status_t status = fss_read_print_object(print, at, delimits_object); + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + if (main->callback.print_object_end) { + const f_status_t status = main->callback.print_object_end(print); if (F_status_is_error(status) || status == F_output_not) return status; } - return fss_read_print_content(print, range, quote, delimits_content); + if (main->callback.print_content) { + return main->callback.print_content(print, at, range, quote, delimits); + } + + return main->callback.print_object_end ? F_okay : F_output_not; + } +#endif // _di_fss_read_print_object_end_content_ + +#ifndef _di_fss_read_print_object_end_empty_ + f_status_t fss_read_print_object_end_empty(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + const f_status_t status_1 = (main->callback.print_object_end) ? main->callback.print_object_end(print) : F_output_not; + const f_status_t status_2 = (main->callback.print_content_empty) ? main->callback.print_content_empty(print) : F_output_not; + + if (F_status_is_error(status_1)) return status_1; + if (F_status_is_error(status_2)) return status_2; + + return (status_1 == F_okay || status_2 == F_okay) ? F_okay: F_output_not; } -#endif // _di_fss_read_print_object_content_ +#endif // _di_fss_read_print_object_end_empty_ #ifndef _di_fss_read_print_quote_ f_status_t fss_read_print_quote(fl_print_t * const print, const uint8_t type) { diff --git a/level_3/fss_read/c/main/print/data.h b/level_3/fss_read/c/main/print/data.h index 9c00285..b1c3439 100644 --- a/level_3/fss_read/c/main/print/data.h +++ b/level_3/fss_read/c/main/print/data.h @@ -67,6 +67,8 @@ extern "C" { * The print.custom is expected to be of type fss_read_main_t. * * This does not alter print.custom.setting.state.status. + * @param at + * The Object index to be printed. * @param range * The range within the buffer representing the Content to print. * @param quote @@ -85,7 +87,7 @@ extern "C" { * @see main.callback.print_set_end() */ #ifndef _di_fss_read_print_content_ - extern f_status_t fss_read_print_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); + extern f_status_t fss_read_print_content(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); #endif // _di_fss_read_print_content_ /** @@ -193,11 +195,12 @@ extern "C" { #endif // _di_fss_read_print_object_ /** - * Print the Object at the given Object index position and the Content. + * Print the end of an Object (which is often the start of Content) and the Content. * * This locks, uses, and unlocks the file stream. * - * Different standards may want to call this before they perform their final printing. + * This processes single Content range. + * This does not print a new line after the Content. * * @param print * The output structure to print to. @@ -206,15 +209,12 @@ extern "C" { * * This does not alter print.custom.setting.state.status. * @param at - * The Object index to be printed. + * The Object index position to be processed. * @param range * The range within the buffer representing the Content to print. * @param quote * The quote type representing the character to use (from the f_fss_quote_type_*_e). - * @param delimits_object - * The delimits array representing a delimited Object. - * This represents the positions within the current Object at the "at" position. - * @param delimits_content + * @param delimits * The delimits array representing a delimited Content. * * @return @@ -223,9 +223,31 @@ extern "C" { * * F_output_not (with error bit) if a parameter is NULL. */ -#ifndef _di_fss_read_print_object_content_ - extern f_status_t fss_read_print_object_content(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits_object, const f_number_unsigneds_t delimits_content); -#endif // _di_fss_read_print_object_content_ +#ifndef _di_fss_read_print_object_end_content_ + extern f_status_t fss_read_print_object_end_content(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); +#endif // _di_fss_read_print_object_end_content_ + +/** + * Print the end of an Object (which is often the start of Content) and the end of the Content when no Content. + * + * This locks, uses, and unlocks the file stream. + * + * @param print + * The output structure to print to. + * + * The print.custom is expected to be of type fss_read_main_t. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + */ +#ifndef _di_fss_read_print_object_end_empty_ + extern f_status_t fss_read_print_object_end_empty(fl_print_t * const print); +#endif // _di_fss_read_print_object_end_empty_ /** * Print the Object at the given Object index position. diff --git a/level_3/fss_read/c/main/process_normal.c b/level_3/fss_read/c/main/process_normal.c index 0a1c5a1..236dc51 100644 --- a/level_3/fss_read/c/main/process_normal.c +++ b/level_3/fss_read/c/main/process_normal.c @@ -295,14 +295,14 @@ extern "C" { if (main->setting.contents.array[at].array[i].start <= main->setting.contents.array[at].array[i].stop) { if ((print_state & 0x1) && !(print_state & 0x4)) { - printed = main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); + printed = main->callback.print_object_end_content(&main->program.output, at, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); if (F_status_set_fine(printed) != F_output_not) { print_state |= 0x6; } } else { - printed = main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); + printed = main->callback.print_content(&main->program.output, at, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); if (F_status_set_fine(printed) != F_output_not) { print_state |= 0x2; @@ -364,10 +364,10 @@ extern "C" { main->setting.range.stop = j; if ((print_state & 0x1) && !(print_state & 0x4)) { - main->callback.print_object_end_content(&main->program.output, main->setting.range, (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); + main->callback.print_object_end_content(&main->program.output, at, main->setting.range, (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); } else { - main->callback.print_content(&main->program.output, main->setting.range, (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); + main->callback.print_content(&main->program.output, at, main->setting.range, (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content); } main->setting.state.status = F_success; diff --git a/level_3/fss_read/c/payload/main.c b/level_3/fss_read/c/payload/main.c index 7a988c8..16efe0c 100644 --- a/level_3/fss_read/c/payload/main.c +++ b/level_3/fss_read/c/payload/main.c @@ -36,10 +36,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_total = &fss_read_process_normal_total_multiple; data.callback.print_at = &fss_read_print_at; - data.callback.print_content = &fss_read_print_content; + data.callback.print_content = &fss_read_payload_print_content; + data.callback.print_content_empty = &fss_read_print_content_empty; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_content_next = 0; - data.callback.print_object = &fss_read_print_object; + data.callback.print_object = &fss_read_payload_print_object; data.callback.print_object_end = &fss_read_payload_print_object_end; data.callback.print_object_end_content = &fss_read_payload_print_object_end_content; data.callback.print_object_end_empty = &fss_read_payload_print_object_end_empty; diff --git a/level_3/fss_read/c/payload/print.c b/level_3/fss_read/c/payload/print.c index e171fd1..798e7a7 100644 --- a/level_3/fss_read/c/payload/print.c +++ b/level_3/fss_read/c/payload/print.c @@ -4,6 +4,44 @@ extern "C" { #endif +#ifndef _di_fss_read_payload_print_content_ + f_status_t fss_read_payload_print_content(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + // The payload Content is printed raw. + if (main->setting.objects.used && at == main->setting.objects.used - 1) { + return fll_print_dynamic_partial_raw(main->setting.buffer, range, print->to); + } + + if (main->callback.print_content_ignore) { + main->callback.print_content_ignore(&main->program.output); + } + + if (main->setting.flag & fss_read_main_flag_original_d) { + if (main->setting.feature & fss_read_feature_flag_quote_content_d) { + fss_read_print_quote(&main->program.output, quote); + } + } + + fll_print_except_in_dynamic_partial(main->setting.buffer, range, delimits, main->setting.comments, print->to); + + if (main->setting.flag & fss_read_main_flag_original_d) { + if (main->setting.feature & fss_read_feature_flag_quote_content_d) { + fss_read_print_quote(&main->program.output, quote); + } + } + + if (main->callback.print_content_ignore) { + main->callback.print_content_ignore(&main->program.output); + } + + return F_okay; + } +#endif // _di_fss_read_payload_print_content_ + #ifndef _di_fss_read_payload_print_object_end_ f_status_t fss_read_payload_print_object_end(fl_print_t * const print) { @@ -30,33 +68,6 @@ extern "C" { } #endif // _di_fss_read_payload_print_object_end_ -#ifndef _di_fss_read_payload_print_object_end_content_ - f_status_t fss_read_payload_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits) { - - { - const f_status_t status = fss_read_payload_print_object_end(print); - if (F_status_is_error(status) || status == F_output_not) return status; - } - - return fss_read_print_content(print, range, quote, delimits); - } -#endif // _di_fss_read_payload_print_object_end_content_ - -#ifndef _di_fss_read_payload_print_object_end_empty_ - f_status_t fss_read_payload_print_object_end_empty(fl_print_t * const print) { - - if (!print) return F_status_set_error(F_output_not); - - const f_status_t status_1 = fss_read_payload_print_object_end(print); - const f_status_t status_2 = fss_read_print_content_empty(print); - - if (F_status_is_error(status_1)) return status_1; - if (F_status_is_error(status_2)) return status_2; - - return (status_1 == F_okay || status_2 == F_okay) ? F_okay: F_output_not; - } -#endif // _di_fss_read_payload_print_object_end_empty_ - #ifndef _di_fss_read_payload_print_error_parameter_value_payload_ f_status_t fss_read_payload_print_error_parameter_value_payload(fl_print_t * const print, const f_string_static_t value) { diff --git a/level_3/fss_read/c/payload/print.h b/level_3/fss_read/c/payload/print.h index b759675..6f107b3 100644 --- a/level_3/fss_read/c/payload/print.h +++ b/level_3/fss_read/c/payload/print.h @@ -13,29 +13,7 @@ extern "C" { #endif /** - * Print the end of an Object (which is often the start of Content). - * - * This locks, uses, and unlocks the file stream. - * - * @param print - * The output structure to print to. - * - * The print.custom is expected to be of type fss_read_main_t. - * - * This does not alter print.custom.setting.state.status. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. - * - * F_output_not (with error bit) if a parameter is NULL. - */ -#ifndef _di_fss_read_payload_print_object_end_ - extern f_status_t fss_read_payload_print_object_end(fl_print_t * const print); -#endif // _di_fss_read_payload_print_object_end_ - -/** - * Print the end of an Object (which is often the start of Content) and the Content. + * (FSS Payload specific) Print the Content. * * This locks, uses, and unlocks the file stream. * @@ -48,6 +26,8 @@ extern "C" { * The print.custom is expected to be of type fss_read_main_t. * * This does not alter print.custom.setting.state.status. + * @param at + * The Object index position to be processed. * @param range * The range within the buffer representing the Content to print. * @param quote @@ -60,13 +40,17 @@ extern "C" { * F_output_not on success, but no printing is performed. * * F_output_not (with error bit) if a parameter is NULL. + * + * @see main.callback.print_content() + * @see main.callback.print_object_end() + * @see main.callback.print_set_end() */ -#ifndef _di_fss_readpayload_print_data_object_end_content_ - extern f_status_t fss_read_payload_print_object_end_content(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); -#endif // _di_fss_read_payload_print_object_end_content_ +#ifndef _di_fss_read_payload_print_content_ + extern f_status_t fss_read_payload_print_content(fl_print_t * const print, const f_number_unsigned_t at, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); +#endif // _di_fss_read_payload_print_content_ /** - * Print the end of an Object (which is often the start of Content) and the end of the Content when no Content. + * Print the end of an Object (which is often the start of Content). * * This locks, uses, and unlocks the file stream. * @@ -82,13 +66,10 @@ extern "C" { * F_output_not on success, but no printing is performed. * * F_output_not (with error bit) if a parameter is NULL. - * - * @see fss_read_payload_print_object_end() - * @see fss_read_print_content_empty() */ -#ifndef _di_fss_read_payload_print_object_end_empty_ - extern f_status_t fss_read_payload_print_object_end_empty(fl_print_t * const print); -#endif // _di_fss_read_payload_print_object_end_empty_ +#ifndef _di_fss_read_payload_print_object_end_ + extern f_status_t fss_read_payload_print_object_end(fl_print_t * const print); +#endif // _di_fss_read_payload_print_object_end_ /** * Print an error message about the payload parameter not having a valid value.