From e70e12f0b54842e761459e38d1a1e4c1526418e2 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 14 May 2023 21:18:12 -0500 Subject: [PATCH] Progress: Continue work on refactoring fss_*_read into fss_read. Break out the callbacks into its own type as a sibling to the program and settings structures. Do this in both fss_read and fss_write. Remove unused "escaped" variable from fss_write. --- level_3/fss_extended_read/c/private-read.c | 4 + level_3/fss_read/c/basic/fss_read.c | 109 +++--------- level_3/fss_read/c/basic/fss_read.h | 53 +++--- level_3/fss_read/c/basic/main.c | 24 ++- level_3/fss_read/c/basic_list/fss_read.c | 101 ----------- level_3/fss_read/c/basic_list/fss_read.h | 41 +---- level_3/fss_read/c/basic_list/main.c | 22 ++- level_3/fss_read/c/embedded_list/fss_read.c | 106 ------------ level_3/fss_read/c/embedded_list/fss_read.h | 41 +---- level_3/fss_read/c/embedded_list/main.c | 23 ++- level_3/fss_read/c/extended/fss_read.c | 108 ------------ level_3/fss_read/c/extended/fss_read.h | 12 +- level_3/fss_read/c/extended/main.c | 24 ++- level_3/fss_read/c/extended_list/fss_read.c | 106 ------------ level_3/fss_read/c/extended_list/fss_read.h | 41 +---- level_3/fss_read/c/extended_list/main.c | 23 ++- level_3/fss_read/c/main/common.c | 12 +- level_3/fss_read/c/main/common.h | 4 +- level_3/fss_read/c/main/common/enumeration.h | 12 +- level_3/fss_read/c/main/common/print.c | 3 +- level_3/fss_read/c/main/common/print.h | 3 +- level_3/fss_read/c/main/common/static.c | 13 ++ level_3/fss_read/c/main/common/static.h | 32 ++++ level_3/fss_read/c/main/common/type.c | 61 ++++++- level_3/fss_read/c/main/common/type.h | 171 ++++++++++++++----- level_3/fss_read/c/main/fss_read.c | 112 +++++++++--- level_3/fss_read/c/main/fss_read.h | 77 ++++++++- level_3/fss_read/c/main/main.c | 97 ++++++----- level_3/fss_read/c/main/main.h | 4 +- level_3/fss_read/c/main/print/data.c | 177 +++++++++++++++++-- level_3/fss_read/c/main/print/data.h | 173 +++++++++++++++++-- level_3/fss_read/c/main/process_normal.c | 236 ++++++++++++++++---------- level_3/fss_read/c/main/process_normal.h | 94 +++------- level_3/fss_read/c/main/thread.h | 1 + level_3/fss_read/c/payload/fss_read.h | 14 +- level_3/fss_read/c/payload/main.c | 24 ++- level_3/fss_read/c/payload/print.c | 6 +- level_3/fss_read/data/build/settings | 4 +- level_3/fss_write/c/basic/fss_write.h | 8 +- level_3/fss_write/c/basic/main.c | 13 +- level_3/fss_write/c/basic_list/fss_write.h | 8 +- level_3/fss_write/c/basic_list/main.c | 13 +- level_3/fss_write/c/embedded_list/fss_write.h | 8 +- level_3/fss_write/c/embedded_list/main.c | 18 +- level_3/fss_write/c/extended/fss_write.h | 8 +- level_3/fss_write/c/extended/main.c | 16 +- level_3/fss_write/c/extended_list/fss_write.h | 8 +- level_3/fss_write/c/extended_list/main.c | 14 +- level_3/fss_write/c/main/common/type.c | 1 - level_3/fss_write/c/main/common/type.h | 60 ++++--- level_3/fss_write/c/main/fss_write.c | 34 ++-- level_3/fss_write/c/main/fss_write.h | 12 +- level_3/fss_write/c/main/main.c | 97 ++++++----- level_3/fss_write/c/main/main.h | 2 + level_3/fss_write/c/payload/fss_write.h | 8 +- level_3/fss_write/c/payload/main.c | 13 +- 56 files changed, 1396 insertions(+), 1113 deletions(-) create mode 100644 level_3/fss_read/c/main/common/static.c create mode 100644 level_3/fss_read/c/main/common/static.h diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index b68db62..be48d0d 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -405,6 +405,7 @@ extern "C" { } } else { + // @fixme: is this block correct? It makes no sense here with the print at function below printing both Object and Content. if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_object.array[at]) { f_print_dynamic_raw( data->quotes_object.array[at] == f_fss_quote_type_single_e @@ -418,6 +419,7 @@ extern "C" { fss_extended_read_print_at(main, i, *delimits_object, *delimits_content, data); + // @fixme: is this block correct? It makes no sense here with the print at function above printing both Object and Content. if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_object.array[at]) { f_print_dynamic_raw( data->quotes_object.array[at] == f_fss_quote_type_single_e @@ -439,6 +441,7 @@ extern "C" { } } else { + // @fixme: is this block correct? It makes no sense here with the print at function below printing both Object and Content. if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_content.array[at].array[i]) { f_print_dynamic_raw( data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e @@ -452,6 +455,7 @@ extern "C" { fss_extended_read_print_at(main, i, *delimits_object, *delimits_content, data); + // @fixme: is this block correct? It makes no sense here with the print at function above printing both Object and Content. if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_content.array[at].array[i]) { f_print_dynamic_raw( data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e diff --git a/level_3/fss_read/c/basic/fss_read.c b/level_3/fss_read/c/basic/fss_read.c index 8bca96f..29b4ea1 100644 --- a/level_3/fss_read/c/basic/fss_read.c +++ b/level_3/fss_read/c/basic/fss_read.c @@ -5,51 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_read_basic_process_content_ - void fss_read_basic_process_content(void * const void_main, const bool last) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.content) { - fl_fss_basic_content_write( - *main->setting.content, - (main->setting.flag & fss_read_main_flag_partial_e) - ? f_fss_complete_partial_e - : f_fss_complete_full_e, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_content_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_content_end_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_basic_close_s, &main->setting.buffer); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_basic_process_content_ - #ifndef _di_fss_read_basic_process_help_ void fss_read_basic_process_help(void * const void_main) { @@ -59,57 +14,45 @@ extern "C" { } #endif // _di_fss_read_basic_process_help_ -#ifndef _di_fss_read_basic_process_object_ - void fss_read_basic_process_object(void * const void_main) { +#ifndef _di_fss_read_basic_process_load_ + void fss_read_basic_process_load(fss_read_main_t * const main) { - if (!void_main) return; + if (!main) return; - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.object) { - fl_fss_basic_object_write( - *main->setting.object, - main->setting.quote.used - ? main->setting.quote.string[0] - : f_fss_quote_double_s.string[0], - (main->setting.flag & fss_read_main_flag_partial_e) - ? (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_trim_e - : f_fss_complete_none_e - : (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); + f_string_range_t input = macro_f_string_range_t_initialize_2(main->setting.buffer.used); - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); + main->setting.delimits.used = 0; + main->setting.quotes.used = 0; - fss_read_print_error_unsupported_eol(&main->program.error); + fll_fss_basic_read(main->setting.buffer, &input, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.delimits, 0, &main->setting.state); - return; - } + if (F_status_is_error(data.setting.state.status)) { + if (F_status_set_fine(data.setting.state.status) == F_interrupt) return; - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_object_write)); + fll_error_file_print( + &main->error, + F_status_set_fine(data.setting.state.status), + macro_fss_read_f(fll_fss_basic_read), + fll_error_file_flag_fallback_e, + fss_read_file_identify(input.start, main->setting.files), + f_file_operation_process_s, + fll_error_file_type_file_e + ); - return; - } + return; } - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_object_open_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_basic_open_s, &main->setting.buffer); + if (data.setting.state.status == F_data_not_stop || data.setting.state.status == F_data_not_eos) { + if (!(main->setting.flag & fss_read_main_flag_total_e)) { + data.setting.state.status = F_status_set_warning(status); - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } + return; } } + + data.setting.state.status = F_none; } -#endif // _di_fss_read_basic_process_object_ +#endif // _di_fss_read_basic_process_load_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/basic/fss_read.h b/level_3/fss_read/c/basic/fss_read.h index 1000e10..11d551d 100644 --- a/level_3/fss_read/c/basic/fss_read.h +++ b/level_3/fss_read/c/basic/fss_read.h @@ -43,16 +43,20 @@ #include #include -// FSS Write includes. +// FSS Read includes. #include #include #include +#include #include #include #include -#include #include #include +#include +#include +#include +#include #include #ifdef __cplusplus @@ -60,27 +64,12 @@ extern "C" { #endif /** - * Process a single Content, printing the FSS-0000 (Basic) if valid or an error if invalid. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. - * @param last - * If TRUE, then this is the last Content in the Content set. - * If FALSE, then this is not the last Content in the Content set. - */ -#ifndef _di_fss_read_basic_process_content_ - extern void fss_read_basic_process_content(void * const main, const bool last); -#endif // _di_fss_read_basic_process_content_ - -/** * Process help for FSS-0000 (Basic). * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This does not alter main.setting.state.status. @@ -94,18 +83,30 @@ extern "C" { #endif // _di_fss_read_basic_process_help_ /** - * Process a single Object, printing the FSS-0000 (Basic) if valid or an error if invalid. + * Process the buffer, loading the FSS data. + * + * This will print an error message on error. * * @param main * The program and settings data. - * Must be of type fss_read_main_t. * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. + * Must not be NULL. + * + * This alters main.setting.state.status: + * F_none on success. + * + * F_data_not_stop (with warning bit) on no valid FSS data found and reached stopping point. + * F_data_not_eos (with warning bit) on no valid FSS data found and reached end of string. + * + * Errors (with error bit) from: fll_fss_basic_read() + * + * @see fll_fss_basic_read() + * + * @see fss_read_file_identify() */ -#ifndef _di_fss_read_basic_process_object_ - extern void fss_read_basic_process_object(void * const main); -#endif // _di_fss_read_basic_process_object_ +#ifndef _di_fss_read_basic_process_load_ + extern f_status_t fss_read_basic_process_load(fss_read_main_t * const main); +#endif // _di_fss_read_basic_process_load_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/basic/main.c b/level_3/fss_read/c/basic/main.c index f099e5f..7f7d182 100644 --- a/level_3/fss_read/c/basic/main.c +++ b/level_3/fss_read/c/basic/main.c @@ -16,11 +16,29 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; + data.setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e | fss_read_main_flag_line_single_e; + data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_basic_standard_s; - data.setting.process_help = &fss_read_basic_process_help; - data.setting.process_last_line = &fss_read_process_last_line; - data.setting.process_normal = &fss_read_process_normal; + + data.callback.process_help = &fss_read_basic_process_help; + data.callback.process_last_line = &fss_read_process_last_line; + data.callback.process_load_depth = &fss_read_setting_load_depth; + data.callback.process_normal = &fss_read_process_normal; + + data.callback.process_at = &fss_read_process_normal_at; + data.callback.process_columns = &fss_read_process_normal_columns; + data.callback.process_line = &fss_read_process_normal_line; + data.callback.process_load = &fss_read_basic_process_load; + data.callback.process_name = &fss_read_process_normal_name; + data.callback.process_total = &fss_read_process_normal_total; + + data.callback.print_at = &fss_read_print_at; + data.callback.print_content = &fss_read_print_content; + data.callback.print_content_ignore = 0; + data.callback.print_object = &fss_read_print_object; + data.callback.print_object_end = &fss_read_print_object_end; + data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_read/c/basic_list/fss_read.c b/level_3/fss_read/c/basic_list/fss_read.c index 6e4a750..cef2b09 100644 --- a/level_3/fss_read/c/basic_list/fss_read.c +++ b/level_3/fss_read/c/basic_list/fss_read.c @@ -5,54 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_read_basic_list_process_content_ - void fss_read_basic_list_process_content(void * const void_main, const bool last) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.content) { - fl_fss_basic_list_content_write( - *main->setting.content, - (main->setting.flag & fss_read_main_flag_partial_e) - ? f_fss_complete_partial_e - : (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - &main->setting.prepend, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_list_content_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_content_end_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &main->setting.buffer); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_basic_list_process_content_ - #ifndef _di_fss_read_basic_list_process_help_ void fss_read_basic_list_process_help(void * const void_main) { @@ -62,59 +14,6 @@ extern "C" { } #endif // _di_fss_read_basic_list_process_help_ -#ifndef _di_fss_read_basic_list_process_object_ - void fss_read_basic_list_process_object(void * const void_main) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.object) { - fl_fss_basic_list_object_write( - *main->setting.object, - (main->setting.flag & fss_read_main_flag_partial_e) - ? (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_trim_e - : f_fss_complete_none_e - : (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_list_object_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_object_open_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &main->setting.buffer); - - if (F_status_is_error_not(main->setting.state.status)) { - main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &main->setting.buffer); - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_basic_list_process_object_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/basic_list/fss_read.h b/level_3/fss_read/c/basic_list/fss_read.h index fe2d2b7..2c5a958 100644 --- a/level_3/fss_read/c/basic_list/fss_read.h +++ b/level_3/fss_read/c/basic_list/fss_read.h @@ -44,16 +44,20 @@ #include #include -// FSS Write includes. +// FSS Read includes. #include #include #include +#include #include #include #include -#include #include #include +#include +#include +#include +#include #include #ifdef __cplusplus @@ -61,27 +65,12 @@ extern "C" { #endif /** - * Process a single Content, printing the FSS-0002 (Basic List) if valid or an error if invalid. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. - * @param last - * If TRUE, then this is the last Content in the Content set. - * If FALSE, then this is not the last Content in the Content set. - */ -#ifndef _di_fss_read_basic_list_process_content_ - extern void fss_read_basic_list_process_content(void * const main, const bool last); -#endif // _di_fss_read_basic_list_process_content_ - -/** * Process help for FSS-0002 (Basic List). * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This does not alter main.setting.state.status. @@ -94,20 +83,6 @@ extern "C" { extern void fss_read_basic_list_process_help(void * const main); #endif // _di_fss_read_basic_list_process_help_ -/** - * Process a single Object, printing the FSS-0002 (Basic List) if valid or an error if invalid. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. - */ -#ifndef _di_fss_read_basic_list_process_object_ - extern void fss_read_basic_list_process_object(void * const main); -#endif // _di_fss_read_basic_list_process_object_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/basic_list/main.c b/level_3/fss_read/c/basic_list/main.c index 31d0e36..f373922 100644 --- a/level_3/fss_read/c/basic_list/main.c +++ b/level_3/fss_read/c/basic_list/main.c @@ -18,9 +18,25 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_basic_list_standard_s; - data.setting.process_help = &fss_read_basic_list_process_help; - data.setting.process_last_line = &fss_read_process_last_line; - data.setting.process_normal = &fss_read_process_normal; + + data.callback.process_help = &fss_read_basic_list_process_help; + data.callback.process_last_line = &fss_read_process_last_line; + //data.callback.process_load_depth = &fss_read_setting_load_depth; + data.callback.process_normal = &fss_read_process_normal; + + //data.callback.process_at = &fss_read_process_normal_at; + //data.callback.process_columns = &fss_read_process_normal_columns; + //data.callback.process_line = &fss_read_process_normal_line; + //data.callback.process_load = &fss_read_basic_process_load; + //data.callback.process_name = &fss_read_process_normal_name; + //data.callback.process_total = &fss_read_process_normal_total; + + //data.callback.print_at = &fss_read_print_at; + //data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_ignore = &fss_read_print_content_ignore; + //data.callback.print_object = &fss_read_print_object; + //data.callback.print_object_end = &fss_read_print_object_end; + //data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_read/c/embedded_list/fss_read.c b/level_3/fss_read/c/embedded_list/fss_read.c index a2e0d07..1c1e944 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.c +++ b/level_3/fss_read/c/embedded_list/fss_read.c @@ -5,59 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_read_embedded_list_process_content_ - void fss_read_embedded_list_process_content(void * const void_main, const bool last) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.content) { - fl_fss_embedded_list_content_write( - *main->setting.content, - (main->setting.flag & fss_read_main_flag_partial_e) - ? f_fss_complete_partial_e - : last - ? f_fss_complete_end_e - : f_fss_complete_next_e, - &main->setting.prepend, - main->setting.ignores, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_embedded_list_content_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_content_end_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_close_s, &main->setting.buffer); - - if (F_status_is_error_not(main->setting.state.status)) { - main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_close_end_s, &main->setting.buffer); - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_embedded_list_process_content_ - #ifndef _di_fss_read_embedded_list_process_help_ void fss_read_embedded_list_process_help(void * const void_main) { @@ -67,59 +14,6 @@ extern "C" { } #endif // _di_fss_read_embedded_list_process_help_ -#ifndef _di_fss_read_embedded_list_process_object_ - void fss_read_embedded_list_process_object(void * const void_main) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.object) { - fl_fss_embedded_list_object_write( - *main->setting.object, - (main->setting.flag & fss_read_main_flag_partial_e) - ? (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_trim_e - : f_fss_complete_none_e - : (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_embedded_list_object_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_object_open_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_open_s, &main->setting.buffer); - - if (F_status_is_error_not(main->setting.state.status)) { - main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_open_end_s, &main->setting.buffer); - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_embedded_list_process_object_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/embedded_list/fss_read.h b/level_3/fss_read/c/embedded_list/fss_read.h index 58a3b0f..836c18c 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.h +++ b/level_3/fss_read/c/embedded_list/fss_read.h @@ -43,16 +43,20 @@ #include #include -// FSS Write includes. +// FSS Read includes. #include #include #include +#include #include #include #include -#include #include #include +#include +#include +#include +#include #include #ifdef __cplusplus @@ -60,27 +64,12 @@ extern "C" { #endif /** - * Process a single Content, printing the FSS-0008 (Embedded List) if valid or an error if invalid. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. - * @param last - * If TRUE, then this is the last Content in the Content set. - * If FALSE, then this is not the last Content in the Content set. - */ -#ifndef _di_fss_read_embedded_list_process_content_ - extern void fss_read_embedded_list_process_content(void * const main, const bool last); -#endif // _di_fss_read_embedded_list_process_content_ - -/** * Process help for FSS-0008 (Embedded List). * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This does not alter main.setting.state.status. @@ -93,20 +82,6 @@ extern "C" { extern void fss_read_embedded_list_process_help(void * const main); #endif // _di_fss_read_embedded_list_process_help_ -/** - * Process a single Object, printing the FSS-0008 (Embedded List) if valid or an error if invalid. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. - */ -#ifndef _di_fss_read_embedded_list_process_object_ - extern void fss_read_embedded_list_process_object(void * const main); -#endif // _di_fss_read_embedded_list_process_object_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/embedded_list/main.c b/level_3/fss_read/c/embedded_list/main.c index ea8c84d..7eb9251 100644 --- a/level_3/fss_read/c/embedded_list/main.c +++ b/level_3/fss_read/c/embedded_list/main.c @@ -18,13 +18,30 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_embedded_list_standard_s; - data.setting.process_help = &fss_read_embedded_list_process_help; - data.setting.process_last_line = &fss_read_process_last_line; - data.setting.process_normal = &fss_read_process_normal; + data.setting.flag |= fss_read_main_flag_ignore_e; data.setting.flag |= fss_read_main_flag_content_multiple_e; data.setting.flag |= fss_read_main_flag_depth_support_e | fss_read_main_flag_select_support_e; + data.callback.process_help = &fss_read_embedded_list_process_help; + data.callback.process_last_line = &fss_read_process_last_line; + //data.callback.process_load_depth = &fss_read_setting_load_depth; + data.callback.process_normal = &fss_read_process_normal; + + //data.callback.process_at = &fss_read_process_normal_at; + //data.callback.process_columns = &fss_read_process_normal_columns; + //data.callback.process_line = &fss_read_process_normal_line; + //data.callback.process_load = &fss_read_basic_process_load; + //data.callback.process_name = &fss_read_process_normal_name; + //data.callback.process_total = &fss_read_process_normal_total; + + //data.callback.print_at = &fss_read_print_at; + //data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_ignore = &fss_read_print_content_ignore; + //data.callback.print_object = &fss_read_print_object; + //data.callback.print_object_end = &fss_read_print_object_end; + //data.callback.print_set_end = &fss_read_print_set_end; + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; diff --git a/level_3/fss_read/c/extended/fss_read.c b/level_3/fss_read/c/extended/fss_read.c index 580efe8..899e67f 100644 --- a/level_3/fss_read/c/extended/fss_read.c +++ b/level_3/fss_read/c/extended/fss_read.c @@ -5,63 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_read_extended_process_content_ - void fss_read_extended_process_content(void * const void_main, const bool last) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.content) { - fl_fss_extended_content_write( - *main->setting.content, - main->setting.quote.used - ? main->setting.quote.string[0] - : f_fss_quote_double_s.string[0], - (main->setting.flag & fss_read_main_flag_partial_e) - ? f_fss_complete_partial_e - : last - ? f_fss_complete_end_e - : f_fss_complete_next_e, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_extended_content_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_content_end_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_extended_close_s, &main->setting.buffer); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - else if (main->setting.flag & fss_read_main_flag_content_next_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_extended_next_s, &main->setting.buffer); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_extended_process_content_ - #ifndef _di_fss_read_extended_process_help_ void fss_read_extended_process_help(void * const void_main) { @@ -71,57 +14,6 @@ extern "C" { } #endif // _di_fss_read_extended_process_help_ -#ifndef _di_fss_read_extended_process_object_ - void fss_read_extended_process_object(void * const void_main) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.object) { - fl_fss_extended_object_write( - *main->setting.object, - main->setting.quote.used - ? main->setting.quote.string[0] - : f_fss_quote_double_s.string[0], - (main->setting.flag & fss_read_main_flag_partial_e) - ? (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_trim_e - : f_fss_complete_none_e - : (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_extended_object_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_object_open_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_extended_open_s, &main->setting.buffer); - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_extended_process_object_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/extended/fss_read.h b/level_3/fss_read/c/extended/fss_read.h index e361c6c..9d6c8bd 100644 --- a/level_3/fss_read/c/extended/fss_read.h +++ b/level_3/fss_read/c/extended/fss_read.h @@ -43,16 +43,20 @@ #include #include -// FSS Write includes. +// FSS Read includes. #include #include #include +#include #include #include #include -#include #include #include +#include +#include +#include +#include #include #ifdef __cplusplus @@ -64,6 +68,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status. @@ -81,6 +87,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This does not alter main.setting.state.status. diff --git a/level_3/fss_read/c/extended/main.c b/level_3/fss_read/c/extended/main.c index c75a0ba..28eda37 100644 --- a/level_3/fss_read/c/extended/main.c +++ b/level_3/fss_read/c/extended/main.c @@ -18,10 +18,28 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_extended_standard_s; - data.setting.process_help = &fss_read_extended_process_help; - data.setting.process_last_line = &fss_read_process_last_line; - data.setting.process_normal = &fss_read_process_normal; + data.setting.flag |= fss_read_main_flag_content_multiple_e; + data.setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; + + data.callback.process_help = &fss_read_extended_process_help; + data.callback.process_last_line = &fss_read_process_last_line; + //data.callback.process_load_depth = &fss_read_setting_load_depth; + data.callback.process_normal = &fss_read_process_normal; + + //data.callback.process_at = &fss_read_process_normal_at; + //data.callback.process_columns = &fss_read_process_normal_columns; + //data.callback.process_line = &fss_read_process_normal_line; + //data.callback.process_load = &fss_read_basic_process_load; + //data.callback.process_name = &fss_read_process_normal_name; + //data.callback.process_total = &fss_read_process_normal_total; + + //data.callback.print_at = &fss_read_print_at; + //data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_ignore = &fss_read_print_content_ignore; + //data.callback.print_object = &fss_read_print_object; + //data.callback.print_object_end = &fss_read_print_object_end; + //data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_read/c/extended_list/fss_read.c b/level_3/fss_read/c/extended_list/fss_read.c index e3f18e7..1f786c6 100644 --- a/level_3/fss_read/c/extended_list/fss_read.c +++ b/level_3/fss_read/c/extended_list/fss_read.c @@ -5,59 +5,6 @@ extern "C" { #endif -#ifndef _di_fss_read_extended_list_process_content_ - void fss_read_extended_list_process_content(void * const void_main, const bool last) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.content) { - fl_fss_extended_list_content_write( - *main->setting.content, - (main->setting.flag & fss_read_main_flag_partial_e) - ? last - ? f_fss_complete_none_e - : f_fss_complete_partial_e - : f_fss_complete_full_e, - &main->setting.prepend, - main->setting.ignores, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_extended_list_content_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_content_end_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_close_s, &main->setting.buffer); - - if (F_status_is_error_not(main->setting.state.status)) { - main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_close_end_s, &main->setting.buffer); - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_extended_list_process_content_ - #ifndef _di_fss_read_extended_list_process_help_ void fss_read_extended_list_process_help(void * const void_main) { @@ -67,59 +14,6 @@ extern "C" { } #endif // _di_fss_read_extended_list_process_help_ -#ifndef _di_fss_read_extended_list_process_object_ - void fss_read_extended_list_process_object(void * const void_main) { - - if (!void_main) return; - - fss_read_main_t * const main = (fss_read_main_t *) void_main; - - if (main->setting.object) { - fl_fss_extended_list_object_write( - *main->setting.object, - (main->setting.flag & fss_read_main_flag_partial_e) - ? (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_trim_e - : f_fss_complete_none_e - : (main->setting.flag & fss_read_main_flag_trim_e) - ? f_fss_complete_full_trim_e - : f_fss_complete_full_e, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_set_fine(main->setting.state.status) == F_none_eol) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_unsupported_eol(&main->program.error); - - return; - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_extended_list_object_write)); - - return; - } - } - - if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { - if (main->setting.flag & fss_read_main_flag_object_open_e) { - main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_open_s, &main->setting.buffer); - - if (F_status_is_error_not(main->setting.state.status)) { - main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_open_end_s, &main->setting.buffer); - } - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - } - } - } - } -#endif // _di_fss_read_extended_list_process_object_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/extended_list/fss_read.h b/level_3/fss_read/c/extended_list/fss_read.h index eb22841..d05a015 100644 --- a/level_3/fss_read/c/extended_list/fss_read.h +++ b/level_3/fss_read/c/extended_list/fss_read.h @@ -43,16 +43,20 @@ #include #include -// FSS Write includes. +// FSS Read includes. #include #include #include +#include #include #include #include -#include #include #include +#include +#include +#include +#include #include #ifdef __cplusplus @@ -60,27 +64,12 @@ extern "C" { #endif /** - * Process a single Content, printing the FSS-0003 (Extended List) if valid or an error if invalid. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. - * @param last - * If TRUE, then this is the last Content in the Content set. - * If FALSE, then this is not the last Content in the Content set. - */ -#ifndef _di_fss_read_extended_list_process_content_ - extern void fss_read_extended_list_process_content(void * const main, const bool last); -#endif // _di_fss_read_extended_list_process_content_ - -/** * Process help for FSS-0003 (Extended List). * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This does not alter main.setting.state.status. @@ -93,20 +82,6 @@ extern "C" { extern void fss_read_extended_list_process_help(void * const main); #endif // _di_fss_read_extended_list_process_help_ -/** - * Process a single Object, printing the FSS-0003 (Extended List) if valid or an error if invalid. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. - */ -#ifndef _di_fss_read_extended_list_process_object_ - extern void fss_read_extended_list_process_object(void * const main); -#endif // _di_fss_read_extended_list_process_object_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/extended_list/main.c b/level_3/fss_read/c/extended_list/main.c index b242a69..c630257 100644 --- a/level_3/fss_read/c/extended_list/main.c +++ b/level_3/fss_read/c/extended_list/main.c @@ -18,11 +18,28 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_extended_list_standard_s; - data.setting.process_help = &fss_read_extended_list_process_help; - data.setting.process_last_line = &fss_read_process_last_line; - data.setting.process_normal = &fss_read_process_normal; + data.setting.flag |= fss_read_main_flag_ignore_e; + data.callback.process_help = &fss_read_extended_list_process_help; + data.callback.process_last_line = &fss_read_process_last_line; + //data.callback.process_load_depth = &fss_read_setting_load_depth; + data.callback.process_normal = &fss_read_process_normal; + + //data.callback.process_at = &fss_read_process_normal_at; + //data.callback.process_columns = &fss_read_process_normal_columns; + //data.callback.process_line = &fss_read_process_normal_line; + //data.callback.process_load = &fss_read_basic_process_load; + //data.callback.process_name = &fss_read_process_normal_name; + //data.callback.process_total = &fss_read_process_normal_total; + + //data.callback.print_at = &fss_read_print_at; + //data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_ignore = &fss_read_print_content_ignore; + //data.callback.print_object = &fss_read_print_object; + //data.callback.print_object_end = &fss_read_print_object_end; + //data.callback.print_set_end = &fss_read_print_set_end; + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index d7c81cb..f08f251 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -499,8 +499,8 @@ extern "C" { if (main->setting.buffer.used) { main->setting.files.array[0].range.stop = main->setting.buffer.used - 1; - if (main->setting.process_last_line) { - main->setting.process_last_line((void *) &main); + if (main->callback.process_last_line) { + main->callback.process_last_line((void *) &main); if (F_status_is_error(main->setting.state.status)) return; } } @@ -603,8 +603,8 @@ extern "C" { if (main->setting.buffer.used > main->setting.files.array[main->setting.files.used].range.start) { main->setting.files.array[main->setting.files.used++].range.stop = main->setting.buffer.used - 1; - if (main->setting.process_last_line) { - main->setting.process_last_line((void *) &main); + if (main->callback.process_last_line) { + main->callback.process_last_line((void *) &main); if (F_status_is_error(main->setting.state.status)) break; } } @@ -780,8 +780,8 @@ extern "C" { } // for } // for - if (main->setting.process_load_depth) { - main->setting.process_load_depth(arguments, (void *) main); + if (main->callback.process_load_depth) { + main->callback.process_load_depth(arguments, (void *) main); if (F_status_is_error(main->setting.state.status)) return; } diff --git a/level_3/fss_read/c/main/common.h b/level_3/fss_read/c/main/common.h index 1e90caf..c2d6442 100644 --- a/level_3/fss_read/c/main/common.h +++ b/level_3/fss_read/c/main/common.h @@ -28,7 +28,7 @@ extern "C" { * @param main * The main program data. * - * This calls main.setting.process_last_line() if not NULL. + * This calls main.callback.process_last_line() if not NULL. * * This alters main.setting.range. * @@ -79,7 +79,7 @@ extern "C" { * @param main * The main program data. * - * This calls main.setting.process_load_depth() if not NULL. + * This calls main.callback.process_load_depth() if not NULL. * * This alters main.setting.state.status: * F_none on success. diff --git a/level_3/fss_read/c/main/common/enumeration.h b/level_3/fss_read/c/main/common/enumeration.h index 0a88f7f..365210c 100644 --- a/level_3/fss_read/c/main/common/enumeration.h +++ b/level_3/fss_read/c/main/common/enumeration.h @@ -39,6 +39,8 @@ extern "C" { * - pipe: Print using the special pipe format. * - print_first: When set, print new line to message output on program begin after loading settings. * - print_last: When set, print new line to message output on program end. + * - quote_content: Designate that the standard supports quotes on Content. + * - quote_object: Designate that the standard supports quotes on Objects. * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). * - total: The total lines found and selected is printed instead of the Content. * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). @@ -65,10 +67,12 @@ extern "C" { fss_read_main_flag_pipe_e = 0x8000, fss_read_main_flag_print_first_e = 0x10000, fss_read_main_flag_print_last_e = 0x20000, - fss_read_main_flag_select_e = 0x40000, - fss_read_main_flag_total_e = 0x80000, - fss_read_main_flag_trim_e = 0x100000, - fss_read_main_flag_version_e = 0x200000, + fss_read_main_flag_quote_content_e = 0x40000, + fss_read_main_flag_quote_object_e = 0x80000, + fss_read_main_flag_select_e = 0x100000, + fss_read_main_flag_total_e = 0x200000, + fss_read_main_flag_trim_e = 0x400000, + fss_read_main_flag_version_e = 0x800000, }; // enum #endif // _di_fss_read_main_flag_e_ diff --git a/level_3/fss_read/c/main/common/print.c b/level_3/fss_read/c/main/common/print.c index 4551b8a..1edbe00 100644 --- a/level_3/fss_read/c/main/common/print.c +++ b/level_3/fss_read/c/main/common/print.c @@ -42,9 +42,10 @@ extern "C" { "fl_fss_extended_list_object_read", "fl_fss_extended_object_read", "fl_fss_payload_content_read", + "fll_fss_basic_read", + "fll_fss_payload_read", "fll_program_parameter_process_context", "fll_program_parameter_process_verbosity", - "fll_fss_payload_read", "fss_read_depths_resize", "fss_read_setting_load_depth", }; diff --git a/level_3/fss_read/c/main/common/print.h b/level_3/fss_read/c/main/common/print.h index a8b9573..074aae0 100644 --- a/level_3/fss_read/c/main/common/print.h +++ b/level_3/fss_read/c/main/common/print.h @@ -75,9 +75,10 @@ extern "C" { fss_read_f_fl_fss_extended_list_object_read_e, fss_read_f_fl_fss_extended_object_read_e, fss_read_f_fl_fss_payload_content_read_e, + fss_read_f_fll_fss_basic_read_e, + fss_read_f_fll_fss_payload_read_e, fss_read_f_fll_program_parameter_process_context_e, fss_read_f_fll_program_parameter_process_verbosity_e, - fss_read_f_fll_fss_payload_read_e, fss_read_f_fss_read_depths_resize_e, fss_read_f_fss_read_setting_load_depth_e, }; // enum diff --git a/level_3/fss_read/c/main/common/static.c b/level_3/fss_read/c/main/common/static.c new file mode 100644 index 0000000..e33f99c --- /dev/null +++ b/level_3/fss_read/c/main/common/static.c @@ -0,0 +1,13 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_except_none_c_ + const f_array_lengths_t fss_read_except_none_c = macro_f_array_lengths_t_initialize_1(0, 0, 0); +#endif // _di_fss_read_except_none_c_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/common/static.h b/level_3/fss_read/c/main/common/static.h new file mode 100644 index 0000000..f496fe4 --- /dev/null +++ b/level_3/fss_read/c/main/common/static.h @@ -0,0 +1,32 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common static structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_common_static_h +#define _fss_read_common_static_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Provide a static empty array lengths. + * + * This is intended to represent an empty array lengths structure. + */ +#ifndef _di_fss_read_except_none_c_ + extern const f_array_lengths_t fss_read_except_none_c; +#endif // _di_fss_read_except_none_c_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_common_static_h diff --git a/level_3/fss_read/c/main/common/type.c b/level_3/fss_read/c/main/common/type.c index b414df2..a239727 100644 --- a/level_3/fss_read/c/main/common/type.c +++ b/level_3/fss_read/c/main/common/type.c @@ -13,6 +13,52 @@ extern "C" { } #endif // _di_fss_read_depth_delete_ +#ifndef _di_fss_read_depths_resize_ + f_status_t fss_read_depths_resize(const f_array_length_t length, fss_read_depths_t * const depths) { + + if (!depths) return F_status_set_error(F_parameter); + if (depths->used + length > F_array_length_t_size_d) return F_status_set_error(F_array_too_large); + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < depths->size; ++i) { + + status = private_f_string_ranges_adjust(0, &depths->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(depths->size, length, sizeof(fss_read_file_t), (void **) & depths->array); + if (F_status_is_error(status)) return status; + + depths->size = length; + + if (depths->used > depths->size) { + depths->used = length; + } + + return F_none; + } +#endif // _di_fss_read_depths_resize_ + +#ifndef _di_fss_read_files_resize_ + f_status_t fss_read_files_resize(const f_array_length_t length, fss_read_files_t * const files) { + + if (!files) return F_status_set_error(F_parameter); + if (files->used + length > F_array_length_t_size_d) return F_status_set_error(F_array_too_large); + + const f_status_t status = f_memory_adjust(files->size, length, sizeof(fss_read_file_t), (void **) & files->array); + if (F_status_is_error(status)) return status; + + files->size = length; + + if (files->used > files->size) { + files->used = length; + } + + return F_none; + } +#endif // _di_fss_read_files_resize_ + #ifndef _di_fss_read_main_data_delete_ void fss_read_main_delete(fss_read_main_t * const main) { @@ -33,9 +79,18 @@ extern "C" { f_string_dynamic_resize(0, &setting->buffer); f_string_dynamic_resize(0, &setting->prepend); - f_string_rangess_resize(0, &setting->ignoress); - f_string_dynamics_resize(0, &setting->objects); - f_string_dynamicss_resize(0, &setting->contentss); + fss_read_files_resize(0, &setting->files); + fss_read_depths_resize(0, &setting->depths); + + f_string_ranges_resize(0, &setting->objects); + f_string_ranges_resize(0, &setting->comments); + f_string_rangess_resize(0, &setting->contents); + + f_array_lengths_resize(0, &setting->delimits_object); + f_array_lengths_resize(0, &setting->delimits_content); + + f_uint8s_resize(0, &setting->quotes_object); + f_uint8ss_resize(0, &setting->quotes_content); return F_none; } diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index 72637b4..b14f227 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -117,6 +117,71 @@ extern "C" { #endif // _di_fss_read_files_t_ /** + * The FSS read callbacks. + * + * process_help: Process help (generally printing help). + * process_last_line: Process printing last line if necessary when loading in a file (or pipe). + * process_load_depth: Process loading of the depth related parameters when loading the settings. + * process_normal: Process normally (data from parameters and files). + * + * process_at: Process at parameter, usually called by the process_normal() callback. + * process_columns: Process columns parameter, usually called by the process_normal() callback. + * process_line: Process line parameter, usually called by the process_normal() callback. + * process_load: Process loading of FSS data from buffer (not to be confused with loading settings), usually called by the process_normal() callback. + * process_name: Process name parameter, usually called by the process_normal() callback. + * process_total: Process total parameter, usually called by the process_normal() callback. + * + * 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 Object, 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_object_end: Print the Object end, usually called by several callbacks within the process_normal() callback. + * print_set_end: Print the set end, usually called by several callbacks within the process_normal() callback. + */ +#ifndef _di_fss_read_callback_t_ + typedef struct { + void (*process_help)(void * const main); + void (*process_last_line)(void * const main); + void (*process_load_depth)(const f_console_arguments_t arguments, void * const main); + void (*process_normal)(void * const main); + + void (*process_at)(void * const main, const bool names[], const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); + void (*process_columns)(void * const main, const bool names[]); + void (*process_line)(void * const main, const bool names[]); + void (*process_load)(void * const main); + void (*process_name)(void * const main, bool names[]); + void (*process_total)(void * const main, const bool names[]); + + void (*print_at)(void * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); + void (*print_object)(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits); + void (*print_content)(fl_print_t * const print, const f_array_length_t at, const uint8_t quote, const f_fss_delimits_t delimits); + void (*print_content_ignore)(fl_print_t * const print); + void (*print_object_end)(fl_print_t * const print); + void (*print_set_end)(fl_print_t * const print); + } fss_read_callback_t; + + #define fss_read_callback_t_initialize \ + { \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + } +#endif // _di_fss_read_callback_t_ + +/** * The fss read main program settings. * * This is passed to the program-specific main entry point to designate program settings. @@ -147,19 +212,6 @@ extern "C" { * delimits_object: The positions within the buffer representing Object character delimits. * delimits_content: The positions within the buffer representing Content character delimits. * comments: The positions within the buffer representing comments. - * - * process_help: Process help (generally printing help). - * process_last_line: Process printing last line if necessary when loading in a file (or pipe). - * process_load_depth: Process loading of the depth related parameters when loading the settings. - * process_normal: Process normally (data from parameters and files). - * - * process_at: Process at parameter, usually called by process_normal() callback. - * process_columns: Process columns parameter, usually called by process_normal() callback. - * process_line: Process line parameter, usually called by process_normal() callback. - * process_load: Process loading of FSS data from buffer (not to be confused with loading settings), usually called by process_normal() callback. - * process_name: Process name parameter, usually called by process_normal() callback. - * process_print_at: Process printing a given line, usually called by process_normal() callback. - * process_total: Process total parameter, usually called by process_normal() callback. */ #ifndef _di_fss_read_setting_t_ typedef struct { @@ -186,19 +238,8 @@ extern "C" { f_fss_delimits_t delimits_object; f_fss_delimits_t delimits_content; f_fss_comments_t comments; - - void (*process_help)(void * const main); - void (*process_last_line)(void * const main); - void (*process_load_depth)(const f_console_arguments_t arguments, void * const main); - void (*process_normal)(void * const main); - - void (*process_at)(void * const main, const bool names[], const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); - void (*process_columns)(void * const main, const bool names[]); - void (*process_line)(void * const main, const bool names[]); - void (*process_load)(void * const main); - void (*process_name)(void * const main, bool names[]); - void (*process_print_at)(void * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); - void (*process_total)(void * const main, const bool names[]); + f_uint8s_t quotes_object; + f_uint8ss_t quotes_content; } fss_read_setting_t; #define fss_read_setting_t_initialize \ @@ -220,34 +261,28 @@ extern "C" { f_fss_delimits_t_initialize, \ f_fss_delimits_t_initialize, \ f_fss_comments_t_initialize, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ + f_uint8s_t_initialize, \ + f_uint8ss_t_initialize, \ } #endif // _di_fss_read_setting_t_ /** * The main program data as a single structure. * - * program: The main program data. - * setting: The settings data. + * callback: The callback data. + * program: The main program data. + * setting: The settings data. */ #ifndef _di_fss_read_main_t_ typedef struct { + fss_read_callback_t callback; fll_program_data_t program; fss_read_setting_t setting; } fss_read_main_t; #define fss_read_main_t_initialize \ { \ + fss_read_callback_t_initialize, \ fll_program_data_t_initialize, \ fss_read_setting_t_initialize, \ } @@ -258,18 +293,66 @@ extern "C" { * * @param depth * The depth to deallocate. + * Must not be NULL. */ #ifndef _di_fss_read_depth_delete_ - extern void fss_read_depth_delete(fss_read_depth_t * const depth); + extern f_status_t fss_read_depth_delete(fss_read_depth_t * const depth); #endif // _di_fss_read_depth_delete_ /** + * Resize the program setting depths data. + * + * @param length + * The new size to use. + * @param depths + * The depths to resize. + * Must not be NULL. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + */ +#ifndef _di_fss_read_depths_resize_ + extern f_status_t fss_read_depths_resize(const f_array_length_t length, fss_read_depths_t * const depths); +#endif // _di_fss_read_depths_resize_ + +/** + * Resize the program setting files data. + * + * @param length + * The new size to use. + * @param files + * The files to resize. + * Must not be NULL. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + */ +#ifndef _di_fss_read_files_resize_ + extern f_status_t fss_read_files_resize(const f_array_length_t length, fss_read_files_t * const files); +#endif // _di_fss_read_files_resize_ + +/** * Deallocate main program data. * - * @param setting_make - * The make setting data. + * @param main + * The program and settings data. * - * This does not alter data_make.main.setting.state.status. + * Must not be NULL. + * Must be of type fss_read_main_t. + * + * This does not alter main.setting.state.status. */ #ifndef _di_fss_read_main_data_delete_ extern void fss_read_main_delete(fss_read_main_t * const main); @@ -281,6 +364,8 @@ extern "C" { * @param setting * The program main setting data. * + * Must not be NULL. + * * This does not alter setting.state.status. * * @return diff --git a/level_3/fss_read/c/main/fss_read.c b/level_3/fss_read/c/main/fss_read.c index 9094b02..f5e0f51 100644 --- a/level_3/fss_read/c/main/fss_read.c +++ b/level_3/fss_read/c/main/fss_read.c @@ -4,6 +4,58 @@ extern "C" { #endif +#ifndef _di_fss_read_delimit_content_is_ + f_status_t fss_read_delimit_content_is(fss_read_main_t * const main, const f_array_length_t depth) { + + if (!main) return F_false; + + if (main->setting.delimit_mode == fss_read_delimit_mode_none_e) { + return F_false; + } + + if (main->setting.delimit_mode == fss_read_delimit_mode_all_e) { + return F_true; + } + + if (depth < main->setting.delimit_depth) { + return main->setting.delimit_mode == fss_read_delimit_mode_content_lesser_e; + } + + if (depth == main->setting.delimit_depth) { + return F_true; + } + + return main->setting.delimit_mode == fss_read_delimit_mode_content_greater_e; + } +#endif // _di_fss_read_delimit_content_is_ + +#ifndef _di_fss_read_delimit_object_is_ + f_status_t fss_read_delimit_object_is(fss_read_main_t * const main, const f_array_length_t depth) { + + if (!main) return F_false; + + switch (main->setting.delimit_mode) { + case fss_read_delimit_mode_none_e: + case fss_read_delimit_mode_content_e: + case fss_read_delimit_mode_content_greater_e: + case fss_read_delimit_mode_content_lesser_e: + return F_false; + + case fss_read_delimit_mode_all_e: + case fss_read_delimit_mode_content_object_e: + case fss_read_delimit_mode_content_greater_object_e: + case fss_read_delimit_mode_content_lesser_object_e: + case fss_read_delimit_mode_object_e: + return F_true; + + default: + break; + } + + return depth == main->setting.delimit_depth || main->setting.delimit_mode == fss_read_delimit_mode_content_lesser_e; + } +#endif // _di_fss_read_delimit_object_is_ + #ifndef _di_fss_read_main_ void fss_read_main(void * const void_main) { @@ -27,8 +79,8 @@ extern "C" { if (main->setting.flag & (fss_read_main_flag_help_e | fss_read_main_flag_version_e | fss_read_main_flag_copyright_e)) { if (main->setting.flag & fss_read_main_flag_help_e) { - if (main->setting.process_help) { - main->setting.process_help(void_main); + if (main->callback.process_help) { + main->callback.process_help(void_main); } else { fss_read_print_message_help(&main->program.message); @@ -48,18 +100,16 @@ extern "C" { return; } - main->setting.escaped.used = 0; - if (main->program.pipe & fll_program_data_pipe_input_e) { - if (main->setting.process_pipe) { - main->setting.process_pipe(void_main); + if (main->callback.process_pipe) { + main->callback.process_pipe(void_main); } } if (F_status_is_error_not(main->setting.state.status)) { if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e | fss_read_main_flag_object_open_e | fss_read_main_flag_content_next_e | fss_read_main_flag_content_end_e)) { - if (main->setting.process_normal) { - main->setting.process_normal(void_main); + if (main->callback.process_normal) { + main->callback.process_normal(void_main); } } } @@ -71,22 +121,27 @@ extern "C" { #endif // _di_fss_read_main_ #ifndef _di_fss_read_process_at_line_ - f_status_t fss_read_process_at_line(fss_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t * const line) { + void fss_read_process_at_line(fss_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t * const line) { if (!main || !line) return; if (main->setting.flag & fss_read_main_flag_object_e) { if (*line == main->setting.line) { - f_file_stream_lock(main->program.output.to); if (main->setting.flag & fss_read_main_flag_total_e) { fss_read_print_number(&main->program.output, 1); } else { - fss_read_print_object_at(&main->program.output, at, delimits_object); - } + if (main->callback.print_object) { + main->callback.print_object(&main->program.output, at, delimits_object); + } - f_file_stream_unlock(main->program.output.to); + if (main->setting.flag & fss_read_main_flag_content_e) { + if (main->callback.print_object_end) { + main->callback.print_object_end(&main->program.output); + } + } + } main->setting.state.status = F_success; @@ -121,17 +176,13 @@ extern "C" { if (*line == main->setting.line) { range.stop = i; - f_file_stream_lock(main->program.output.to); - if (main->setting.flag & fss_read_main_flag_total_e) { fss_read_print_number(&main->program.output, 1); } else { - fss_read_print_content(&main->program.output, range, delimits_content); + fss_read_print_content(&main->program.output, range, main->setting.quotes_content.array[at], delimits_content); } - f_file_stream_unlock(main->program.output.to); - main->setting.state.status = F_success; return; @@ -150,20 +201,16 @@ extern "C" { ++(*line); if (*line == main->setting.line) { - f_file_stream_lock(main->program.output.to); - if (main->setting.flag & fss_read_main_flag_total_e) { fss_read_print_number(&main->program.output, 1); } else { range.stop = main->setting.contents.array[at].array[0].stop; - fss_read_print_content(&main->program.output, range, delimits_content); + fss_read_print_content(&main->program.output, range, main->setting.quotes_content.array[at], delimits_content); f_print_dynamic_raw(f_string_eol_s, main->program.output.to); } - f_file_stream_unlock(main->program.output.to); - main->setting.state.status = F_success; return; @@ -175,6 +222,25 @@ extern "C" { } #endif // _di_fss_read_process_at_line_ +#ifndef _di_fss_read_file_identify_ + f_string_static_t fss_read_file_identify(const f_array_length_t at, const fss_read_files_t files) { + + for (f_array_length_t i = 0; i < files.used; ++i) { + + if (at >= files.array[i].range.start && at <= files.array[i].range.stop) { + return files.array[i].name; + } + } // for + + // When stopped after the end of the buffer, the last file in the list is the correct file. + if (at > files.array[files.used - 1].range.stop) { + return files.array[files.used - 1].name; + } + + return f_string_empty_s; + } +#endif // _di_fss_read_file_identify_ + #ifndef _di_fss_read_process_last_line_ void fss_read_process_last_line(void * const void_main) { diff --git a/level_3/fss_read/c/main/fss_read.h b/level_3/fss_read/c/main/fss_read.h index 85cf661..25c5f9f 100644 --- a/level_3/fss_read/c/main/fss_read.h +++ b/level_3/fss_read/c/main/fss_read.h @@ -46,17 +46,16 @@ #include #include -// FSS Write includes. +// FSS Read includes. #include #include #include +#include #include #include #include -#include #include #include -#include #include #include #include @@ -66,6 +65,46 @@ extern "C" { #endif /** + * Determine if the given depth is to be delimited or not for Content. + * + * @param main + * The program and settings data. + * + * Must not be NULL. + * + * This does not alter main.setting.state.status. + * @param depth + * The depth to check. + * + * @return + * F_true if to apply delimits. + * F_false if to not apply delimits (fallback when main is NULL). + */ +#ifndef _di_fss_read_delimit_content_is_ + extern f_status_t fss_read_delimit_content_is(fss_read_main_t * const main, const f_array_length_t depth) F_attribute_visibility_internal_d; +#endif // _di_fss_read_delimit_content_is_ + +/** + * Determine if the given depth is to be delimited or not for an Object. + * + * @param main + * The program and settings data. + * + * Must not be NULL. + * + * This does not alter main.setting.state.status. + * @param depth + * The depth to check. + * + * @return + * F_true if to apply delimits. + * F_false if to not apply delimits (fallback when main is NULL). + */ +#ifndef _di_fss_read_delimit_object_is_ + extern f_status_t fss_read_delimit_object_is(fss_read_main_t * const main, const f_array_length_t depth) F_attribute_visibility_internal_d; +#endif // _di_fss_read_delimit_object_is_ + +/** * Execute main program. * * If main.signal is non-zero, then this blocks and handles the following signals: @@ -78,6 +117,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: @@ -93,10 +134,12 @@ extern "C" { #endif // _di_fss_read_main_ /** - * Process based on at parameter. + * Process based on at parameter for a specific line. * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: @@ -122,12 +165,28 @@ extern "C" { * * @return * F_none on success. + */ +#ifndef _di_fss_read_process_at_line_ + extern void fss_read_process_at_line(fss_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t * const line); +#endif // _di_fss_read_process_at_line_ + +/** + * Get the name of the file the given position represents within the buffer. + * + * @param at + * The position within the buffer. + * @param files + * The representation of files and their respective ranges within the buffer. * - * @see fss_read_process_at_line() + * @return + * A string with the name when found. + * NULL is returned if the range represents the STDIN pipe. + * + * On failure to identify, an empty string is returned. */ -#ifndef _di_fss_read_process_at_ - extern f_status_t fss_read_process_at_line(fss_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t * const line); -#endif // _di_fss_read_process_at_ +#ifndef _di_fss_read_file_identify_ + extern f_string_static_t fss_read_file_identify(const f_array_length_t at, const fss_read_files_t files) F_attribute_visibility_internal_d; +#endif // _di_fss_read_file_identify_ /** * Process the current buffer, guarantee that a newline exists at the end of the buffer. @@ -137,6 +196,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index 8a81e2e..2a66c2b 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -96,12 +96,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { if (!main || F_status_is_error(main->setting.state.status) || (main->setting.flag & fss_read_main_flag_version_e)) return; main->setting.standard = fss_read_basic_standard_s; - main->setting.process_content = &fss_read_basic_process_content; - main->setting.process_help = &fss_read_main_process_help; - main->setting.process_load_depth = 0; - main->setting.process_normal = &fss_read_process_normal; - main->setting.process_object = &fss_read_basic_process_object; - main->setting.process_set = &fss_read_process_set; + + main->callback.process_content = &fss_read_basic_process_content; + main->callback.process_help = &fss_read_main_process_help; + main->callback.process_load_depth = 0; + main->callback.process_normal = &fss_read_process_normal; + main->callback.process_object = &fss_read_basic_process_object; + main->callback.process_set = &fss_read_process_set; if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_read_parameter_as_e].values.used) { @@ -118,14 +119,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_read_format_code_machine_0000_s) == F_equal_to) { main->setting.standard = fss_read_basic_standard_s; - main->setting.process_content = &fss_read_basic_process_content; - main->setting.process_help = &fss_read_basic_process_help; - main->setting.process_load_depth = 0; - main->setting.process_object = &fss_read_basic_process_object; - main->setting.process_normal = &fss_read_process_normal; - main->setting.process_set = &fss_read_process_set; + main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by basic. main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by basic. + + main->callback.process_content = &fss_read_basic_process_content; + main->callback.process_help = &fss_read_basic_process_help; + main->callback.process_load_depth = 0; + main->callback.process_object = &fss_read_basic_process_object; + main->callback.process_normal = &fss_read_process_normal; + main->callback.process_set = &fss_read_process_set; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0001_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_0001_s) == F_equal_to || @@ -133,14 +136,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_read_format_code_machine_0001_s) == F_equal_to) { main->setting.standard = fss_read_extended_standard_s; - main->setting.process_content = &fss_read_extended_process_content; - main->setting.process_help = &fss_read_extended_process_help; - main->setting.process_load_depth = 0; - main->setting.process_object = &fss_read_extended_process_object; - main->setting.process_normal = &fss_read_process_normal; - main->setting.process_set = &fss_read_process_set; + main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by extended. main->setting.flag |= fss_read_main_flag_content_multiple_e; + + main->callback.process_content = &fss_read_extended_process_content; + main->callback.process_help = &fss_read_extended_process_help; + main->callback.process_load_depth = 0; + main->callback.process_object = &fss_read_extended_process_object; + main->callback.process_normal = &fss_read_process_normal; + main->callback.process_set = &fss_read_process_set; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0002_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_0002_s) == F_equal_to || @@ -148,14 +153,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_read_format_code_machine_0002_s) == F_equal_to) { main->setting.standard = fss_read_basic_list_standard_s; - main->setting.process_content = &fss_read_basic_list_process_content; - main->setting.process_help = &fss_read_basic_list_process_help; - main->setting.process_load_depth = 0; - main->setting.process_object = &fss_read_basic_list_process_object; - main->setting.process_normal = &fss_read_process_normal; - main->setting.process_set = &fss_read_process_set; + main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by basic list. main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by basic list. + + main->callback.process_content = &fss_read_basic_list_process_content; + main->callback.process_help = &fss_read_basic_list_process_help; + main->callback.process_load_depth = 0; + main->callback.process_object = &fss_read_basic_list_process_object; + main->callback.process_normal = &fss_read_process_normal; + main->callback.process_set = &fss_read_process_set; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0003_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_0003_s) == F_equal_to || @@ -163,14 +170,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_read_format_code_machine_0003_s) == F_equal_to) { main->setting.standard = fss_read_extended_list_standard_s; - main->setting.process_content = &fss_read_extended_list_process_content; - main->setting.process_help = &fss_read_extended_list_process_help; - main->setting.process_load_depth = 0; - main->setting.process_object = &fss_read_extended_list_process_object; - main->setting.process_normal = &fss_read_process_normal; - main->setting.process_set = &fss_read_process_set; + main->setting.flag |= fss_read_main_flag_ignore_e; main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by extended list. + + main->callback.process_content = &fss_read_extended_list_process_content; + main->callback.process_help = &fss_read_extended_list_process_help; + main->callback.process_load_depth = 0; + main->callback.process_object = &fss_read_extended_list_process_object; + main->callback.process_normal = &fss_read_process_normal; + main->callback.process_set = &fss_read_process_set; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0008_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_0008_s) == F_equal_to || @@ -178,14 +187,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_read_format_code_machine_0008_s) == F_equal_to) { main->setting.standard = fss_read_embedded_list_standard_s; - main->setting.process_content = &fss_read_embedded_list_process_content; - main->setting.process_help = &fss_read_embedded_list_process_help; - main->setting.process_load_depth = 0; - main->setting.process_object = &fss_read_embedded_list_process_object; - main->setting.process_normal = &fss_read_process_normal; - main->setting.process_set = &fss_read_process_set; + main->setting.flag |= fss_read_main_flag_ignore_e; main->setting.flag |= fss_read_main_flag_content_multiple_e; + + main->callback.process_content = &fss_read_embedded_list_process_content; + main->callback.process_help = &fss_read_embedded_list_process_help; + main->callback.process_load_depth = 0; + main->callback.process_object = &fss_read_embedded_list_process_object; + main->callback.process_normal = &fss_read_process_normal; + main->callback.process_set = &fss_read_process_set; } else if (f_compare_dynamic(argv[index], fss_read_format_code_short_000e_s) == F_equal_to || f_compare_dynamic(argv[index], fss_read_format_code_long_000e_s) == F_equal_to || @@ -193,14 +204,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_read_format_code_machine_000e_s) == F_equal_to) { main->setting.standard = fss_read_payload_standard_s; - main->setting.process_content = 0; // Not used by payload. - main->setting.process_help = &fss_read_payload_process_help; - main->setting.process_load_depth = 0; - main->setting.process_normal = &fss_read_process_normal; - main->setting.process_object = 0; // Not used by payload. - main->setting.process_set = &fss_read_payload_process_set; + main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by payload. main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by payload. + + main->callback.process_content = 0; // Not used by payload. + main->callback.process_help = &fss_read_payload_process_help; + main->callback.process_load_depth = 0; + main->callback.process_normal = &fss_read_process_normal; + main->callback.process_object = 0; // Not used by payload. + main->callback.process_set = &fss_read_payload_process_set; } else { if (main->setting.flag & fss_read_main_flag_help_e) { diff --git a/level_3/fss_read/c/main/main.h b/level_3/fss_read/c/main/main.h index 614cf6a..86e79b9 100644 --- a/level_3/fss_read/c/main/main.h +++ b/level_3/fss_read/c/main/main.h @@ -36,6 +36,8 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This does not alter main.setting.state.status. @@ -60,7 +62,7 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * @param main * The main program and settings data. * - * This alters main.setting.process_help, main.setting.process_normal, and main.setting.process_pipe. + * This alters main.callback.process_help, main.callback.process_normal, and main.callback.process_pipe. * * This alters main.setting.state.status: * F_none on success. diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index 63136a6..1e823f1 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -4,19 +4,89 @@ extern "C" { #endif +#ifndef _di_fss_read_print_at_ + void fss_read_print_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + if (at >= main->setting.contents.used) return F_output_not; + + if ((main->setting.flag & fss_read_main_flag_object_e) || (main->setting.flag & fss_read_main_flag_content_e) && (main->setting.contents.array[at].used || (main->setting.flag & fss_read_main_flag_empty_e))) { + if (main->setting.flag & fss_read_main_flag_object_e) { + if (main->callback.print_object) { + main->callback.print_object(&main->program.output, at, delimits_object); + } + + if (main->setting.flag & fss_read_main_flag_content_e) { + if (main->callback.print_object_end) { + main->callback.print_object_end(&main->program.output); + } + } + } + + if ((main->setting.flag & fss_read_main_flag_content_e) && main->setting.contents.array[at].used) { + if (main->callback.print_content) { + main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at], delimits_content); + } + } + + if (main->callback.print_set_end) { + main->callback.print_set_end(&main->program.output); + } + } + + return F_none; + } +#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_string_range_t range, const f_fss_delimits_t delimits) { + f_status_t fss_read_print_content(fl_print_t * const print, const f_string_range_t range, const uint8_t quote, const f_fss_delimits_t delimits) { if (!print || !print->custom) return F_status_set_error(F_output_not); - fss_read_main_t * const main = (fss_read_main_t *) print->custom, + fss_read_main_t * const main = (fss_read_main_t *) print->custom; - f_print_except_in_dynamic_partial(main->setting.buffer, range, delimits, main->setting.comments, print->to); + if (data.callback.print_content_ignore) { + data.callback.print_content_ignore(&main->program.output); + } + + if (main->setting.flag & fss_read_main_flag_original_e) { + if ((main->setting.flag & fss_read_main_flag_quote_content_e) && quote) { + 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_e) { + if ((main->setting.flag & fss_read_main_flag_quote_content_e) && quote) { + fss_read_print_quote(&main->program.output, quote); + } + } + + if (data.callback.print_content_ignore) { + data.callback.print_content_ignore(&main->program.output); + } return F_none; } #endif _di_fss_read_print_content_ +#ifndef _di_fss_read_print_content_ignore_ + void fss_read_print_content_ignore(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, + + if (main->setting.flag & fss_read_main_flag_pipe_e) { + fll_print_dynamic_raw(fss_read_pipe_content_ignore_s, print->to); + } + } +#endif // _di_fss_read_print_content_ignore_ + #ifndef _di_fss_read_print_number_ f_status_t fss_read_print_number(fl_print_t * const print, const f_number_unsigned_t number) { @@ -28,8 +98,8 @@ extern "C" { } #endif // _di_fss_read_print_number_ -#ifndef _di_fss_read_print_object_at_ - f_status_t fss_read_print_object_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits) { +#ifndef _di_fss_read_print_object_ + f_status_t fss_read_print_object(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -37,18 +107,105 @@ extern "C" { if (at >= main->setting.objects.used) return F_output_not; - if (main->setting.flag & fss_read_main_flag_trim_e) { - fl_print_trim_except_dynamic_partial(main->setting.buffer, main->setting.array[at], delimits, print->to); + if (main->setting.flag & fss_read_data_option_trim_d) { + if (main->setting.flag & fss_read_data_option_original_d) { + if (main->setting.quotes.array[at]) { + fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); + } + + fll_print_trim_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], main->program.output.to); + + if (main->setting.quotes.array[at]) { + fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); + } + } + else { + fll_print_trim_except_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], delimits_object, main->program.output.to); + } } else { - f_print_except_dynamic_partial(main->setting.buffer, main->setting.array[at], delimits, print->to); + if (main->setting.flag & fss_read_main_flag_original_e) { + if (main->setting.quotes.array[at]) { + fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); + } + + fll_print_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], main->program.output.to); + + if (main->setting.quotes.array[at]) { + fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); + } + } + else { + fll_print_except_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], delimits_object, main->program.output.to); + } } - fss_read_print_object_end(print); // @todo replace with a callback because each standard may have a different Object end. + return F_none; + } +#endif // _di_fss_read_print_object_ + +#ifndef _di_fss_read_print_object_end_ + f_status_t fss_read_print_object_end(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, + + if (main->setting.flag & fss_read_main_flag_pipe_e) { + fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + fll_print_dynamic_raw(f_fss_space_s, main->program.output.to); + + // @todo this is basic list read, move this appropriately and use "basic" for the common object end, which is a space. + /* + if (main->parameters.array[fss_read_parameter_content_e].result & f_console_result_found_e) { + f_print_dynamic_raw(f_fss_basic_list_open_s, print->to); + f_print_dynamic_raw(f_fss_basic_list_open_end_s, print->to); + } + else { + f_print_dynamic_raw(f_fss_eol_s, print->to); + } + */ + } + } +#endif // _di_fss_read_print_object_end_ + +#ifndef _di_fss_read_print_quote_ + f_status_t fss_read_print_quote(fl_print_t * const print, const uint8_t type) { + + if (!print) return F_status_set_error(F_output_not); + + fll_print_dynamic_raw( + type == f_fss_quote_type_single_e + ? f_fss_quote_single_s + : type == f_fss_quote_type_backtick_e + ? f_fss_quote_backtick_s + : f_fss_quote_double_s, + print->to + ); + + return F_none; + } +#endif // _di_fss_read_print_quote_ + +#ifndef _di_fss_read_print_set_end_ + f_status_t fss_read_print_set_end(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, + + if (main->setting.flag & fss_read_main_flag_pipe_e) { + fll_print_dynamic_raw(fss_read_pipe_content_end_s, print->to); + } + else { + fll_print_dynamic_raw(f_string_eol_s, main->program.output.to); + } return F_none; } -#endif // _di_fss_read_print_object_at_ +#endif // _di_fss_read_print_set_end_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/main/print/data.h b/level_3/fss_read/c/main/print/data.h index 14d83c4..500a281 100644 --- a/level_3/fss_read/c/main/print/data.h +++ b/level_3/fss_read/c/main/print/data.h @@ -17,9 +17,50 @@ extern "C" { #endif /** + * Process printing the buffer according to "at" position and given delimits. + * + * 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. + * @param at + * The "at" position to be printed. + * @param delimits_object + * The delimits array representing a delimited Object. + * This represents the positions within the current Object at the "at" position. + * @param delimits_content + * The delimits array representing a delimited Content. + * This represents the positions within the current Content at the "at" position. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_dynamic_partial() + * @see fll_print_except_dynamic_partial() + * @see fll_print_trim_dynamic_partial() + * @see fll_print_trim_except_dynamic_partial() + * + * @see fss_read_print_quote() + * @see fss_read_signal_check() + * @see main.callback.print_object() + * @see main.callback.print_object_end() + * @see main.callback.print_set_end() + */ +#ifndef _di_fss_read_print_at_ + extern f_status_t fss_read_print_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); +#endif // _di_fss_read_print_at_ + +/** * Print the Content. * - * This does not lock the stream. + * This locks, uses, and unlocks the file stream. * * This does not print a new line after the Content. * @@ -31,6 +72,8 @@ extern "C" { * 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 in use, if any. * @param delimits * The delimits array representing a delimited Content. * @@ -40,16 +83,43 @@ extern "C" { * * F_output_not (with error bit) if a parameter is NULL. * - * @see f_print_except_in_dynamic_partial() + * @see fll_print_except_in_dynamic_partial() + * @see main.callback.print_content() + * @see main.callback.print_object_end() + * @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_array_length_t at, const f_fss_delimits_t delimits); + extern f_status_t fss_read_print_content(fl_print_t * const print, const f_array_length_t at, const uint8_t quote, const f_fss_delimits_t delimits); #endif // _di_fss_read_print_content_ /** + * Print the ignore character for 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_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_dynamic_raw() + */ +#ifndef _di_fss_read_print_content_ignore_ + extern f_status_t fss_read_print_content_ignore(fl_print_t * const print); +#endif // _di_fss_read_print_content_ignore_ + +/** * Print the number and a newline. * - * This does not lock the stream. + * This locks, uses, and unlocks the file stream. * * @param print * The output structure to print to. @@ -75,7 +145,9 @@ extern "C" { /** * Print the Object at the given position. * - * This does not lock the stream. + * This locks, uses, and unlocks the file stream. + * + * Different standards may want to call this before they perform their final printing. * * @param print * The output structure to print to. @@ -95,14 +167,93 @@ extern "C" { * * F_output_not (with error bit) if a parameter is NULL. * - * @see f_print_except_dynamic_partial() - * @see fl_print_trim_except_dynamic_partial() + * @see fll_print_dynamic_partial() + * @see fll_print_except_dynamic_partial() + * @see fll_print_trim_dynamic_partial() + * @see fll_print_trim_except_dynamic_partial() + * + * @see fss_read_print_quote() + */ +#ifndef _di_fss_read_print_object_ + extern f_status_t fss_read_print_object(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits); +#endif // _di_fss_read_print_object_ + +/** + * 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_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_dynamic_raw() + */ +#ifndef _di_fss_read_print_object_end_ + extern f_status_t fss_read_print_object_end(fl_print_t * const print); +#endif // _di_fss_read_print_object_end_ + +/** + * Print the Object at the given position. + * + * 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. + * @param at + * The "at" position to be printed. + * @param delimits + * The delimits array representing a delimited Object. + * This represents the positions within the current Object at the "at" position. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_dynamic_raw() + */ +#ifndef _di_fss_read_print_quote_ + extern f_status_t fss_read_print_quote(fl_print_t * const print, const uint8_t type); +#endif // _di_fss_read_print_quote_ + +/** + * Print the end of an Object/Content set. + * + * 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_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. * - * @see fss_read_print_object_end() @todo replace this with appropriate print callback. + * @see fll_print_dynamic_raw() */ -#ifndef _di_fss_read_print_object_at_ - extern f_status_t fss_read_print_object_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits); -#endif // _di_fss_read_print_object_at_ +#ifndef _di_fss_read_print_set_end_ + extern f_status_t fss_read_print_set_end(fl_print_t * const print); +#endif // _di_fss_read_print_set_end_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/main/process_normal.c b/level_3/fss_read/c/main/process_normal.c index 07ddf06..93512c7 100644 --- a/level_3/fss_read/c/main/process_normal.c +++ b/level_3/fss_read/c/main/process_normal.c @@ -18,11 +18,7 @@ extern "C" { // For select, most standards do not support multiple select, so any select greater than 0 can be predicted without processing the buffer. if (!(main->setting.flag & fss_read_main_flag_depth_multiple_e) && main->setting.depths.array[0].depth || !(main->setting.flag & fss_read_main_flag_content_multiple_e) && ((main->setting.flag & fss_read_main_flag_select_e) && data->select)) { if (main->setting.flag & fss_read_main_flag_total_e) { - f_file_stream_lock(main->program.output.to); - fss_read_print_number(&main->program.output, 0); - - f_file_stream_unlock(main->program.output.to); } main->setting.state.status = F_none; @@ -31,61 +27,57 @@ extern "C" { } // The process_load() callback is required to be non-NULL. - if (!main->setting.process_load) return; + if (!main->callback.process_load) return; - main->setting.process_load(main); + main->callback.process_load(main); if (F_status_is_error(main->setting.state.status)) return; - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_read_delimit_object_is(main, 0) ? &main->setting.delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_read_delimit_content_is(main, 0) ? &main->setting.delimits_content : &except_none; - - if (main->setting.flag & fss_read_main_flag_original_e) { - delimits_object = &except_none; - delimits_content = &except_none; - } + const f_array_lengths_t * const delimits_object = !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_object_is(main, 0) ? &main->setting.delimits_object : &fss_read_except_none_c; + const f_array_lengths_t * const delimits_content = !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_content_is(main, 0) ? &main->setting.delimits_content : &fss_read_except_none_c; bool names[main->setting.objects.used]; - if (main->setting.process_name) { - main->setting.process_name(main, names); + if (main->callback.process_name) { + main->callback.process_name(main, names); if (F_status_is_error(main->setting.state.status)) return; } else if (main->setting.objects.used) { - memset(names, 0, sizeof(bool) * main->setting.objects.used); + + // If no processing is enabled, then default to F_true to enable all names. + memset(names, F_true, sizeof(bool) * main->setting.objects.used); } - if (main->setting.process_at) { - main->setting.process_at(main, names, *delimits_object, *delimits_content); + if (main->callback.process_at) { + main->callback.process_at(main, names, *delimits_object, *delimits_content); return; } - if ((main->setting.flag & fss_read_main_flag_columns_e) && main->setting.process_columns) { - main->setting.process_columns(main, names); + if ((main->setting.flag & fss_read_main_flag_columns_e) && main->callback.process_columns) { + main->callback.process_columns(main, names); return; } - if ((main->setting.flag & fss_read_main_flag_total_e) && main->setting.process_total) { - main->setting.process_total(main, names); + if ((main->setting.flag & fss_read_main_flag_total_e) && main->callback.process_total) { + main->callback.process_total(main, names); return; } - if ((main->setting.flag & fss_read_main_flag_line_e) && main->setting.process_line) { - main->setting.process_line(main, names); + if ((main->setting.flag & fss_read_main_flag_line_e) && main->callback.process_line) { + main->callback.process_line(main, names); return; } - if (main->setting.process_print_at) { + if (main->callback.print_at) { for (f_array_length_t i = 0; i < main->setting.contents.used; ++i) { if (!names[i]) continue; if (fss_read_signal_check(main)) return; - main->setting.process_print_at(main, i, *delimits_object, *delimits_content); + main->callback.print_at(main, i, *delimits_object, *delimits_content); } // for } @@ -102,11 +94,7 @@ extern "C" { if (main->setting.depths.array[0].value_at >= main->setting.objects.used) { if (main->setting.flag & (fss_read_main_flag_columns_e | fss_read_main_flag_total_e)) { - f_file_stream_lock(main->program.output.to); - fss_read_print_number(&main->program.output, 0); - - f_file_stream_unlock(main->program.output.to); } main->setting.state.status = F_none; @@ -118,11 +106,7 @@ extern "C" { if (main->setting.flag & (fss_read_main_flag_line_e | fss_read_main_flag_line_single_e) == (fss_read_main_flag_line_e | fss_read_main_flag_line_single_e)) { if (main->setting.line) { if (main->setting.flag & fss_read_main_flag_total_e) { - f_file_stream_lock(main->program.output.to); - fss_read_print_zero(main); - - f_file_stream_unlock(main->program.output.to); } main->setting.state.status = F_none; @@ -138,19 +122,6 @@ extern "C" { f_array_length_t line = 0; f_array_length_t total = 0; - // @todo this is originally from basic list, compare this against extended and determine what else needs to be done when it comes to quotes (consider checking if flags exist and performing appropriate modifications, or perhaps custom callback). There probably should be a standard flag for designating that quotes should be printed around Objects and the same for Contents. - // Example: - /* - f_print_dynamic_raw( - data->quotes_object.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->program.output.to - ); - */ - for (; i < main->setting.objects.used; ++i) { if (!names[i]) continue; @@ -183,31 +154,34 @@ extern "C" { fss_read_print_number(&main->program.output, main->setting.contents.array[i].used); } else if (main->setting.flag & fss_read_main_flag_total_e) { - total = 0; - k = 0; - - // @todo this is originally from basic list, compare this against extended list and determine what else needs to be done. + if (main->setting.flag & fss_read_main_flag_line_single_e) { + fss_read_print_number(main, main->setting.contents.array[i].used ? 1 : 0); + } + else { + total = 0; + k = 0; - // Count each new line. - for (j = 0; j < main->setting.contents.array[i].used; ++j) { + // Count each new line. + for (j = 0; j < main->setting.contents.array[i].used; ++j) { - if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue; - if (main->setting.contents.array[i].array[j].start > main->setting.buffer.used) continue; + if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue; + if (main->setting.contents.array[i].array[j].start > main->setting.buffer.used) continue; - for (k = main->setting.contents.array[i].array[j].start; k <= main->setting.contents.array[i].array[j].stop && k < main->setting.buffer.used; ++k) { - if (main->setting.buffer.string[k] == f_string_eol_s.string[0]) ++total; + for (k = main->setting.contents.array[i].array[j].start; k <= main->setting.contents.array[i].array[j].stop && k < main->setting.buffer.used; ++k) { + if (main->setting.buffer.string[k] == f_string_eol_s.string[0]) ++total; + } // for } // for - } // for - // If there are no newline characters but there is data, then this represents a single line. - if (main->setting.contents.array[i].used && !total) { - total = 1; - } + // If there are no newline characters but there is data, then this represents a single line. + if (main->setting.contents.array[i].used && !total) { + total = 1; + } - fss_read_print_number(&main->program.output, total); + fss_read_print_number(&main->program.output, total); + } } - else if (main->setting.process_print_at) { - main->setting.process_print_at(main, i, delimits_object, delimits_content); + else if (main->callback.print_at) { + main->callback.print_at(main, i, delimits_object, delimits_content); } main->setting.state.status = F_none; @@ -219,11 +193,7 @@ extern "C" { } // for if (main->setting.flag & fss_read_main_flag_total_e) { - f_file_stream_lock(main->program.output.to); - fss_read_print_number(&main->program.output, 0); - - f_file_stream_unlock(main->program.output.to); } main->setting.state.status = F_none; @@ -237,6 +207,28 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; + if (!(main->setting.flag & fss_read_main_flag_content_e)) { + fss_read_print_number(&main->program.output, 0); + + main->setting.state.status = F_none; + + return; + } + + f_array_length_t max = 0; + + for (f_array_length_t at = 0; at < main->setting.contents.used; ++at) { + + if (!names[at]) continue; + if (fss_read_signal_check(main)) return; + + if (main->setting.contents.array[at].used > max) { + max = main->setting.contents.array[at].used; + } + } // for + + fss_read_print_number(&main->program.output, max); + main->setting.state.status = F_none; } #endif // _di_fss_read_process_normal_columns_ @@ -248,20 +240,47 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; - main->setting.state.status = F_none; - } -#endif // _di_fss_read_process_normal_line_ + const f_array_lengths_t * const delimits = !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_object_is(main, 0) ? &main->setting.delimits : &fss_read_except_none_c; + + f_array_length_t line = 0; -#ifndef _di_fss_read_process_normal_load_ - void fss_read_process_normal_load(void * const main) { + for (f_array_length_t i = 0; i < main->setting.contents.used; ++i) { - if (!void_main) return; + if (!names[i]) continue; + if (fss_read_signal_check(main)) return; - fss_read_main_t * const main = (fss_read_main_t *) void_main; + if (!(main->setting.flag & fss_read_main_flag_object_e) && (main->setting.flag & fss_read_main_flag_content_e)) { + if (!main->setting.contents.array[i].used) { + if (main->setting.flag & fss_read_main_flag_empty_e) { + if (line == main->setting.line) { + if (main->callback.print_set_end) { + main->callback.print_set_end(&main->program.output); + } + + break; + } + + ++line; + } + + continue; + } + } + + if (line == main->setting.line) { + if (main->callback.print_at) { + main->callback.print_at(main, i, *delimits, fss_read_except_none_c); + } + + break; + } + + ++line; + } // for main->setting.state.status = F_none; } -#endif // _di_fss_read_process_normal_load_ +#endif // _di_fss_read_process_normal_line_ #ifndef _di_fss_read_process_normal_name_ void fss_read_process_normal_name(void * const main, const bool names[]) { @@ -270,31 +289,39 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; - main->setting.state.status = F_none; - } -#endif // _di_fss_read_process_normal_name_ - -#ifndef _di_fss_read_process_normal_print_at_ - void fss_read_process_normal_print_at(void * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content) { + if (main->setting.depths.array[0].index_name) { + f_array_length_t i = 0; - if (!void_main) return; + memset(names, F_false, sizeof(bool) * main->setting.objects.used); - fss_read_main_t * const main = (fss_read_main_t *) void_main; + if (main->setting.flag & fss_read_main_flag_trim_e) { + for (i = 0; i < main->setting.objects.used; ++i) { - main->setting.state.status = F_none; - } -#endif // _di_fss_read_process_normal_print_at_ + if (fss_read_signal_check(main)) return; -#ifndef _di_fss_read_process_normal_read_ - void fss_read_process_normal_read(void * const main, const bool names[]) { + if (f_compare_dynamic_partial_except_trim_dynamic(main->setting.depths.array[0].value_name, main->setting.buffer, main->setting.objects.array[i], fss_read_except_none_c, main->setting.delimits) == F_equal_to) { + names[i] = F_true; + } + } // for + } + else { + for (i = 0; i < main->setting.objects.used; ++i) { - if (!void_main) return; + if (fss_read_signal_check(main)) return; - fss_read_main_t * const main = (fss_read_main_t *) void_main; + if (f_compare_dynamic_partial_except_dynamic(main->setting.depths.array[0].value_name, main->setting.buffer, main->setting.objects.array[i], fss_read_except_none_c, main->setting.delimits) == F_equal_to) { + names[i] = F_true; + } + } // for + } + } + else { + memset(names, F_true, sizeof(bool) * main->setting.objects.used); + } main->setting.state.status = F_none; } -#endif // _di_fss_read_process_normal_read_ +#endif // _di_fss_read_process_normal_name_ #ifndef _di_fss_read_process_normal_total_ void fss_read_process_normal_total(void * const main, const bool names[]) { @@ -303,6 +330,27 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; + f_array_length_t total = 0; + + for (f_array_length_t i = 0; i < main->setting.objects.used; ++i) { + + if (!names[i]) continue; + if (fss_read_signal_check(main)) return; + + if (!(main->setting.flag & fss_read_main_flag_object_e) && main->setting.flag & fss_read_main_flag_content_e) { + if (!(main->setting.contents.array[i].used || (main->setting.flag & fss_read_main_flag_empty_e))) continue; + } + + ++total; + } // for + + fss_read_print_number( + &main->program.output, + main->setting.flag & fss_read_main_flag_line_e + ? main->setting.line < total ? 1 : 0 + : total + ); + main->setting.state.status = F_none; } #endif // _di_fss_read_process_normal_total_ diff --git a/level_3/fss_read/c/main/process_normal.h b/level_3/fss_read/c/main/process_normal.h index 7c745ee..177a1d7 100644 --- a/level_3/fss_read/c/main/process_normal.h +++ b/level_3/fss_read/c/main/process_normal.h @@ -21,19 +21,21 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: * F_none on success. * - * Errors (with error bit) from: main.setting.process_at(). - * Errors (with error bit) from: main.setting.process_columns(). - * Errors (with error bit) from: main.setting.process_line(). - * Errors (with error bit) from: main.setting.process_load(). - * Errors (with error bit) from: main.setting.process_name(). - * Errors (with error bit) from: main.setting.process_print_at(). - * Errors (with error bit) from: main.setting.process_read(). - * Errors (with error bit) from: main.setting.process_total(). + * Errors (with error bit) from: main.callback.process_at(). + * Errors (with error bit) from: main.callback.process_columns(). + * Errors (with error bit) from: main.callback.process_line(). + * Errors (with error bit) from: main.callback.process_load(). + * Errors (with error bit) from: main.callback.process_name(). + * Errors (with error bit) from: main.callback.print_at(). + * Errors (with error bit) from: main.callback.process_read(). + * Errors (with error bit) from: main.callback.process_total(). * * Errors (with error bit) from: fss_read_signal_check(). * @@ -48,6 +50,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: @@ -75,6 +79,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: @@ -96,6 +102,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: @@ -107,34 +115,19 @@ extern "C" { * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) * * @see fss_read_signal_check() + * @see main.callback.print_set_end() */ #ifndef _di_fss_read_process_normal_line_ extern void fss_read_process_normal_line(void * const main, const bool names[]); #endif // _di_fss_read_process_normal_line_ /** - * Process buffer according to "load" parameter rules. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status: - * F_none on success. - * - * Errors (with error bit) from: fss_read_signal_check(). - * - * @see fss_read_signal_check() - */ -#ifndef _di_fss_read_process_normal_load_ - extern void fss_read_process_normal_load(void * const main); -#endif // _di_fss_read_process_normal_load_ - -/** * Process buffer according to "name" parameter rules. * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: @@ -152,57 +145,12 @@ extern "C" { #endif // _di_fss_read_process_normal_name_ /** - * Process printing the buffer according to "at" position and given delimits. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status: - * F_none on success. - * - * Errors (with error bit) from: fss_read_signal_check(). - * @param at - * The "at" position to be printed. - * @param delimits_object - * The delimits array representing a delimited Object. - * This represents the positions within the current Object at the "at" position. - * @param delimits_content - * The delimits array representing a delimited Content. - * This represents the positions within the current Content at the "at" position. - * - * @see fss_read_signal_check() - */ -#ifndef _di_fss_read_process_normal_print_at_ - extern void fss_read_process_normal_print_at(void * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); -#endif // _di_fss_read_process_normal_print_at_ - -/** - * Process buffer according to "read" parameter rules. - * - * @param main - * The program and settings data. - * Must be of type fss_read_main_t. - * - * This alters main.setting.state.status: - * F_none on success. - * - * Errors (with error bit) from: fss_read_signal_check(). - * @param names - * An array of booleans representing if the name at a given index is enabled. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @see fss_read_signal_check() - */ -#ifndef _di_fss_read_process_normal_read_ - extern void fss_read_process_normal_read(void * const main, const bool names[]); -#endif // _di_fss_read_process_normal_read_ - -/** * Process buffer according to "total" parameter rules. * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: diff --git a/level_3/fss_read/c/main/thread.h b/level_3/fss_read/c/main/thread.h index e4b6682..156b594 100644 --- a/level_3/fss_read/c/main/thread.h +++ b/level_3/fss_read/c/main/thread.h @@ -26,6 +26,7 @@ * @param main * The program and settings data. * + * Must not be NULL. * Must be of type fss_read_main_t. * * @return diff --git a/level_3/fss_read/c/payload/fss_read.h b/level_3/fss_read/c/payload/fss_read.h index 6033db7..618b1c4 100644 --- a/level_3/fss_read/c/payload/fss_read.h +++ b/level_3/fss_read/c/payload/fss_read.h @@ -44,16 +44,20 @@ #include #include -// FSS Write includes. +// FSS Read includes. #include #include #include +#include #include #include #include -#include #include #include +#include +#include +#include +#include #include #ifdef __cplusplus @@ -65,6 +69,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This does not alter main.setting.state.status. @@ -82,6 +88,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: @@ -105,6 +113,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_read_main_t. * * This alters main.setting.state.status: diff --git a/level_3/fss_read/c/payload/main.c b/level_3/fss_read/c/payload/main.c index af54ccf..a629b5e 100644 --- a/level_3/fss_read/c/payload/main.c +++ b/level_3/fss_read/c/payload/main.c @@ -18,10 +18,26 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_payload_standard_s; - data.setting.process_help = &fss_read_payload_process_help; - data.setting.process_last_line = &fss_read_process_last_line; - data.setting.process_normal = &fss_read_process_normal; - data.setting.process_pipe = &fss_read_payload_process_pipe; + + // @todo see if there needs to be this: data.callback.process_pipe = &fss_read_payload_process_pipe; + data.callback.process_help = &fss_read_payload_process_help; + data.callback.process_last_line = &fss_read_process_last_line; + //data.callback.process_load_depth = &fss_read_setting_load_depth; + data.callback.process_normal = &fss_read_process_normal; + + //data.callback.process_at = &fss_read_process_normal_at; + //data.callback.process_columns = &fss_read_process_normal_columns; + //data.callback.process_line = &fss_read_process_normal_line; + //data.callback.process_load = &fss_read_basic_process_load; + //data.callback.process_name = &fss_read_process_normal_name; + //data.callback.process_total = &fss_read_process_normal_total; + + //data.callback.print_at = &fss_read_print_at; + //data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_ignore = &fss_read_print_content_ignore; + //data.callback.print_object = &fss_read_print_object; + //data.callback.print_object_end = &fss_read_print_object_end; + //data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_read/c/payload/print.c b/level_3/fss_read/c/payload/print.c index 3f0cdff..ffd9c10 100644 --- a/level_3/fss_read/c/payload/print.c +++ b/level_3/fss_read/c/payload/print.c @@ -10,11 +10,7 @@ extern "C" { if (!print) return F_status_set_error(F_output_not); if (!print || print->verbosity == f_console_verbosity_quiet_e) return F_output_not; - f_file_stream_lock(print->to); - - fl_print_format("%r%[%QThe payload may only be specified last.%]%r", print->to, f_string_eol_s, print->set->error, print->prefix, print->set->error, f_string_eol_s); - - f_file_stream_unlock(print->to); + fll_print_format("%r%[%QThe payload may only be specified last.%]%r", print->to, f_string_eol_s, print->set->error, print->prefix, print->set->error, f_string_eol_s); return F_none; } diff --git a/level_3/fss_read/data/build/settings b/level_3/fss_read/data/build/settings index 7988c53..fb7a0c2 100644 --- a/level_3/fss_read/data/build/settings +++ b/level_3/fss_read/data/build/settings @@ -37,7 +37,7 @@ build_libraries-individual_thread -lf_thread build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library main/fss_read.c main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c main/print/error.c main/print/message.c main/process_normal.c main/signal.c main/thread.c +build_sources_library main/fss_read.c main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/static.c main/common/string.c main/common/type.c main/print/error.c main/print/message.c main/process_normal.c main/signal.c main/thread.c build_sources_library basic/fss_read.c basic/common.c basic/print.c build_sources_library basic_list/fss_read.c basic_list/common.c basic_list/print.c build_sources_library embedded_list/fss_read.c embedded_list/common.c embedded_list/print.c @@ -45,7 +45,7 @@ build_sources_library extended/fss_read.c extended/common.c extended/print.c build_sources_library extended_list/fss_read.c extended_list/common.c extended_list/print.c build_sources_library payload/fss_read.c payload/common.c payload/print.c -build_sources_headers main/fss_read.h main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h main/print/error.h main/print/message.h main/process_normal.h main/signal.h main/thread.h +build_sources_headers main/fss_read.h main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/static.h main/common/string.h main/common/type.h main/print/error.h main/print/message.h main/process_normal.h main/signal.h main/thread.h build_sources_headers basic/fss_read.h basic/common.h basic/print.h basic/private-common.h build_sources_headers basic_list/fss_read.h basic_list/common.h basic_list/print.h build_sources_headers embedded_list/fss_read.h embedded_list/common.h embedded_list/print.h diff --git a/level_3/fss_write/c/basic/fss_write.h b/level_3/fss_write/c/basic/fss_write.h index 93fdfa8..c1b9e4b 100644 --- a/level_3/fss_write/c/basic/fss_write.h +++ b/level_3/fss_write/c/basic/fss_write.h @@ -50,9 +50,9 @@ #include #include #include -#include #include #include +#include #include #ifdef __cplusplus @@ -64,6 +64,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. @@ -81,6 +83,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This does not alter main.setting.state.status. @@ -98,6 +102,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. diff --git a/level_3/fss_write/c/basic/main.c b/level_3/fss_write/c/basic/main.c index 15d11d0..0e8f713 100644 --- a/level_3/fss_write/c/basic/main.c +++ b/level_3/fss_write/c/basic/main.c @@ -18,12 +18,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_write_basic_standard_s; - data.setting.process_content = &fss_write_basic_process_content; - data.setting.process_help = &fss_write_basic_process_help; - data.setting.process_normal = &fss_write_process_normal; - data.setting.process_object = &fss_write_basic_process_object; - data.setting.process_pipe = &fss_write_process_pipe; - data.setting.process_set = &fss_write_process_set; + + data.callback.process_content = &fss_write_basic_process_content; + data.callback.process_help = &fss_write_basic_process_help; + data.callback.process_normal = &fss_write_process_normal; + data.callback.process_object = &fss_write_basic_process_object; + data.callback.process_pipe = &fss_write_process_pipe; + data.callback.process_set = &fss_write_process_set; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_write/c/basic_list/fss_write.h b/level_3/fss_write/c/basic_list/fss_write.h index b311f8d..ff46c2d 100644 --- a/level_3/fss_write/c/basic_list/fss_write.h +++ b/level_3/fss_write/c/basic_list/fss_write.h @@ -51,9 +51,9 @@ #include #include #include -#include #include #include +#include #include #ifdef __cplusplus @@ -65,6 +65,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. @@ -82,6 +84,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This does not alter main.setting.state.status. @@ -99,6 +103,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. diff --git a/level_3/fss_write/c/basic_list/main.c b/level_3/fss_write/c/basic_list/main.c index 7eb63a1..58eab57 100644 --- a/level_3/fss_write/c/basic_list/main.c +++ b/level_3/fss_write/c/basic_list/main.c @@ -18,12 +18,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_write_basic_list_standard_s; - data.setting.process_content = &fss_write_basic_list_process_content; - data.setting.process_help = &fss_write_basic_list_process_help; - data.setting.process_normal = &fss_write_process_normal; - data.setting.process_object = &fss_write_basic_list_process_object; - data.setting.process_pipe = &fss_write_process_pipe; - data.setting.process_set = &fss_write_process_set; + + data.callback.process_content = &fss_write_basic_list_process_content; + data.callback.process_help = &fss_write_basic_list_process_help; + data.callback.process_normal = &fss_write_process_normal; + data.callback.process_object = &fss_write_basic_list_process_object; + data.callback.process_pipe = &fss_write_process_pipe; + data.callback.process_set = &fss_write_process_set; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_write/c/embedded_list/fss_write.h b/level_3/fss_write/c/embedded_list/fss_write.h index ff1fe6d..68c4456 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.h +++ b/level_3/fss_write/c/embedded_list/fss_write.h @@ -50,9 +50,9 @@ #include #include #include -#include #include #include +#include #include #ifdef __cplusplus @@ -64,6 +64,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. @@ -81,6 +83,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This does not alter main.setting.state.status. @@ -98,6 +102,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. diff --git a/level_3/fss_write/c/embedded_list/main.c b/level_3/fss_write/c/embedded_list/main.c index 7d03863..4d12014 100644 --- a/level_3/fss_write/c/embedded_list/main.c +++ b/level_3/fss_write/c/embedded_list/main.c @@ -16,17 +16,19 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; - data.setting.state.custom = (void *) &data; - data.setting.standard = fss_write_embedded_list_standard_s; - data.setting.process_content = &fss_write_embedded_list_process_content; - data.setting.process_help = &fss_write_embedded_list_process_help; - data.setting.process_normal = &fss_write_process_normal; - data.setting.process_object = &fss_write_embedded_list_process_object; - data.setting.process_pipe = &fss_write_process_pipe; - data.setting.process_set = &fss_write_process_set; data.setting.flag |= fss_write_main_flag_ignore_e; data.setting.flag |= fss_write_main_flag_content_multiple_e; + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_write_embedded_list_standard_s; + + data.callback.process_content = &fss_write_embedded_list_process_content; + data.callback.process_help = &fss_write_embedded_list_process_help; + data.callback.process_normal = &fss_write_process_normal; + data.callback.process_object = &fss_write_embedded_list_process_object; + data.callback.process_pipe = &fss_write_process_pipe; + data.callback.process_set = &fss_write_process_set; + f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.program.parameters.array = parameters; data.program.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; diff --git a/level_3/fss_write/c/extended/fss_write.h b/level_3/fss_write/c/extended/fss_write.h index ecec609..cc9e01c 100644 --- a/level_3/fss_write/c/extended/fss_write.h +++ b/level_3/fss_write/c/extended/fss_write.h @@ -50,9 +50,9 @@ #include #include #include -#include #include #include +#include #include #ifdef __cplusplus @@ -64,6 +64,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. @@ -81,6 +83,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This does not alter main.setting.state.status. @@ -98,6 +102,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. diff --git a/level_3/fss_write/c/extended/main.c b/level_3/fss_write/c/extended/main.c index 408ea35..c99ffa5 100644 --- a/level_3/fss_write/c/extended/main.c +++ b/level_3/fss_write/c/extended/main.c @@ -16,15 +16,17 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; + data.setting.flag |= fss_write_main_flag_content_multiple_e; + data.setting.state.custom = (void *) &data; data.setting.standard = fss_write_extended_standard_s; - data.setting.process_content = &fss_write_extended_process_content; - data.setting.process_help = &fss_write_extended_process_help; - data.setting.process_normal = &fss_write_process_normal; - data.setting.process_object = &fss_write_extended_process_object; - data.setting.process_pipe = &fss_write_process_pipe; - data.setting.process_set = &fss_write_process_set; - data.setting.flag |= fss_write_main_flag_content_multiple_e; + + data.callback.process_content = &fss_write_extended_process_content; + data.callback.process_help = &fss_write_extended_process_help; + data.callback.process_normal = &fss_write_process_normal; + data.callback.process_object = &fss_write_extended_process_object; + data.callback.process_pipe = &fss_write_process_pipe; + data.callback.process_set = &fss_write_process_set; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fss_write/c/extended_list/fss_write.h b/level_3/fss_write/c/extended_list/fss_write.h index 6742a8d..c91afc8 100644 --- a/level_3/fss_write/c/extended_list/fss_write.h +++ b/level_3/fss_write/c/extended_list/fss_write.h @@ -50,9 +50,9 @@ #include #include #include -#include #include #include +#include #include #ifdef __cplusplus @@ -64,6 +64,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. @@ -81,6 +83,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This does not alter main.setting.state.status. @@ -98,6 +102,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status. diff --git a/level_3/fss_write/c/extended_list/main.c b/level_3/fss_write/c/extended_list/main.c index fa5d19f..71d77dd 100644 --- a/level_3/fss_write/c/extended_list/main.c +++ b/level_3/fss_write/c/extended_list/main.c @@ -18,14 +18,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_write_extended_list_standard_s; - data.setting.process_content = &fss_write_extended_list_process_content; - data.setting.process_help = &fss_write_extended_list_process_help; - data.setting.process_normal = &fss_write_process_normal; - data.setting.process_object = &fss_write_extended_list_process_object; - data.setting.process_pipe = &fss_write_process_pipe; - data.setting.process_set = &fss_write_process_set; + data.setting.flag |= fss_write_main_flag_ignore_e; + data.callback.process_content = &fss_write_extended_list_process_content; + data.callback.process_help = &fss_write_extended_list_process_help; + data.callback.process_normal = &fss_write_process_normal; + data.callback.process_object = &fss_write_extended_list_process_object; + data.callback.process_pipe = &fss_write_process_pipe; + data.callback.process_set = &fss_write_process_set; + f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.program.parameters.array = parameters; data.program.parameters.array[fss_write_parameter_as_e].flag |= f_console_flag_disable_e; diff --git a/level_3/fss_write/c/main/common/type.c b/level_3/fss_write/c/main/common/type.c index e2075a0..6870cb9 100644 --- a/level_3/fss_write/c/main/common/type.c +++ b/level_3/fss_write/c/main/common/type.c @@ -19,7 +19,6 @@ extern "C" { if (!setting) return F_status_set_error(F_parameter); - f_string_dynamic_resize(0, &setting->escaped); f_string_dynamic_resize(0, &setting->block); f_string_dynamic_resize(0, &setting->buffer); f_string_dynamic_resize(0, &setting->prepend); diff --git a/level_3/fss_write/c/main/common/type.h b/level_3/fss_write/c/main/common/type.h index 4a290bd..6754cb5 100644 --- a/level_3/fss_write/c/main/common/type.h +++ b/level_3/fss_write/c/main/common/type.h @@ -17,6 +17,37 @@ extern "C" { #endif /** + * The FSS write callbacks. + * + * process_content: Process a single Content. + * process_help: Process help (generally printing help). + * process_normal: Process normally (data from parameters and files). + * process_object: Process a single Object. + * process_pipe: Process using the data from input pipe. + * process_set: Process a set of Object and one or more Content. + */ +#ifndef _di_fss_write_callback_t_ + typedef struct { + void (*process_content)(void * const main, const bool last); + void (*process_help)(void * const main); + void (*process_normal)(void * const main); + void (*process_object)(void * const main); + void (*process_pipe)(void * const main); + void (*process_set)(void * const main); + } fss_write_callback_t; + + #define fss_write_callback_t_initialize \ + { \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + } +#endif // _di_fss_write_callback_t_ + +/** * The fss write main program settings. * * This is passed to the program-specific main entry point to designate program settings. @@ -46,13 +77,6 @@ extern "C" { * object: A pointer to a specific Object used during processing. * content: A pointer to a specific Content used during processing. * contents: A pointer to a specific set of Content used during processing. - * - * process_content: Process a single Content. - * process_help: Process help (generally printing help). - * process_normal: Process normally (data from parameters and files). - * process_object: Process a single Object. - * process_pipe: Process using the data from input pipe. - * process_set: Process a set of Object and one or more Content. */ #ifndef _di_fss_write_setting_t_ typedef struct { @@ -66,7 +90,6 @@ extern "C" { f_string_static_t quote; f_string_static_t standard; - f_string_dynamic_t escaped; f_string_dynamic_t block; f_string_dynamic_t buffer; f_string_dynamic_t prepend; @@ -79,13 +102,6 @@ extern "C" { f_string_static_t *object; f_string_static_t *content; f_string_statics_t *contents; - - void (*process_content)(void * const main, const bool last); - void (*process_help)(void * const main); - void (*process_normal)(void * const main); - void (*process_object)(void * const main); - void (*process_pipe)(void * const main); - void (*process_set)(void * const main); } fss_write_setting_t; #define fss_write_setting_t_initialize \ @@ -99,7 +115,6 @@ extern "C" { f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ f_string_rangess_t_initialize, \ f_string_dynamics_t_initialize, \ f_string_dynamicss_t_initialize, \ @@ -107,29 +122,26 @@ extern "C" { 0, \ 0, \ 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ } #endif // _di_fss_write_setting_t_ /** * The main program data as a single structure. * - * program: The main program data. - * setting: The settings data. + * callback: The callback data. + * program: The main program data. + * setting: The settings data. */ #ifndef _di_fss_write_main_t_ typedef struct { + fss_write_callback_t callback; fll_program_data_t program; fss_write_setting_t setting; } fss_write_main_t; #define fss_write_main_t_initialize \ { \ + fss_write_callback_t_initialize, \ fll_program_data_t_initialize, \ fss_write_setting_t_initialize, \ } diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index 17208c0..a85cce6 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -27,8 +27,8 @@ extern "C" { if (main->setting.flag & (fss_write_main_flag_help_e | fss_write_main_flag_version_e | fss_write_main_flag_copyright_e)) { if (main->setting.flag & fss_write_main_flag_help_e) { - if (main->setting.process_help) { - main->setting.process_help(void_main); + if (main->callback.process_help) { + main->callback.process_help(void_main); } else { fss_write_print_message_help(&main->program.message); @@ -48,18 +48,16 @@ extern "C" { return; } - main->setting.escaped.used = 0; - if (main->program.pipe & fll_program_data_pipe_input_e) { - if (main->setting.process_pipe) { - main->setting.process_pipe(void_main); + if (main->callback.process_pipe) { + main->callback.process_pipe(void_main); } } if (F_status_is_error_not(main->setting.state.status)) { if (main->setting.flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e | fss_write_main_flag_object_open_e | fss_write_main_flag_content_next_e | fss_write_main_flag_content_end_e)) { - if (main->setting.process_normal) { - main->setting.process_normal(void_main); + if (main->callback.process_normal) { + main->callback.process_normal(void_main); } } } @@ -122,7 +120,7 @@ extern "C" { main->setting.ignores = &main->setting.ignoress.array[i]; } - main->setting.process_set(void_main); + main->callback.process_set(void_main); if (F_status_is_error(main->setting.state.status)) break; } // for } @@ -132,7 +130,7 @@ extern "C" { main->setting.contents = 0; main->setting.ignores = 0; - main->setting.process_set(void_main); + main->callback.process_set(void_main); } } } @@ -145,7 +143,7 @@ extern "C" { fss_write_main_t * const main = (fss_write_main_t *) void_main; - if (!main->setting.process_set) return; + if (!main->callback.process_set) return; if (main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); @@ -416,7 +414,7 @@ extern "C" { // End Object or Content set. if (state == 0x3) { - main->setting.process_set(void_main); + main->callback.process_set(void_main); if (F_status_is_error(main->setting.state.status)) break; state = 0; @@ -433,7 +431,7 @@ extern "C" { // If the pipe ended before finishing, then attempt to wrap up. if (F_status_is_error_not(main->setting.state.status) && status_pipe == F_none_eof && state) { - main->setting.process_set(void_main); + main->callback.process_set(void_main); flag |= 0x1; } @@ -475,15 +473,15 @@ extern "C" { } } - if (main->setting.process_object) { - main->setting.process_object(void_main); + if (main->callback.process_object) { + main->callback.process_object(void_main); if (F_status_is_error(main->setting.state.status)) return; } } if ((!(main->setting.flag & fss_write_main_flag_partial_e) || (main->setting.flag & fss_write_main_flag_partial_e) && (main->setting.flag & fss_write_main_flag_content_e)) && main->setting.contents || (main->setting.flag & (fss_write_main_flag_content_next_e | fss_write_main_flag_content_end_e))) { - if (main->setting.process_content) { + if (main->callback.process_content) { if (main->setting.contents && main->setting.contents->used) { for (f_array_length_t i = 0; i < main->setting.contents->used; ++i) { @@ -498,14 +496,14 @@ extern "C" { main->setting.content = &main->setting.contents->array[i]; - main->setting.process_content(void_main, i + 1 == main->setting.contents->used); + main->callback.process_content(void_main, i + 1 == main->setting.contents->used); if (F_status_is_error(main->setting.state.status)) return; } // for } else { main->setting.content = 0; - main->setting.process_content(void_main, F_true); + main->callback.process_content(void_main, F_true); if (F_status_is_error(main->setting.state.status)) return; } } diff --git a/level_3/fss_write/c/main/fss_write.h b/level_3/fss_write/c/main/fss_write.h index d107650..d4b2725 100644 --- a/level_3/fss_write/c/main/fss_write.h +++ b/level_3/fss_write/c/main/fss_write.h @@ -53,10 +53,8 @@ #include #include #include -#include #include #include -#include #include #include @@ -77,6 +75,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.custom.setting.state.status: @@ -96,6 +96,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.custom.setting.state.status: @@ -114,6 +116,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.custom.setting.state.status: @@ -131,6 +135,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status: @@ -150,6 +156,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status: diff --git a/level_3/fss_write/c/main/main.c b/level_3/fss_write/c/main/main.c index 592b32a..f9e2d5b 100644 --- a/level_3/fss_write/c/main/main.c +++ b/level_3/fss_write/c/main/main.c @@ -96,12 +96,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { if (!main || F_status_is_error(main->setting.state.status) || (main->setting.flag & fss_write_main_flag_version_e)) return; main->setting.standard = fss_write_basic_standard_s; - main->setting.process_content = &fss_write_basic_process_content; - main->setting.process_help = &fss_write_main_process_help; - main->setting.process_normal = &fss_write_process_normal; - main->setting.process_object = &fss_write_basic_process_object; - main->setting.process_pipe = &fss_write_process_pipe; - main->setting.process_set = &fss_write_process_set; + + main->callback.process_content = &fss_write_basic_process_content; + main->callback.process_help = &fss_write_main_process_help; + main->callback.process_normal = &fss_write_process_normal; + main->callback.process_object = &fss_write_basic_process_object; + main->callback.process_pipe = &fss_write_process_pipe; + main->callback.process_set = &fss_write_process_set; if (main->program.parameters.array[fss_write_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_write_parameter_as_e].values.used) { @@ -118,14 +119,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_write_format_code_machine_0000_s) == F_equal_to) { main->setting.standard = fss_write_basic_standard_s; - main->setting.process_content = &fss_write_basic_process_content; - main->setting.process_help = &fss_write_basic_process_help; - main->setting.process_object = &fss_write_basic_process_object; - main->setting.process_pipe = &fss_write_process_pipe; - main->setting.process_normal = &fss_write_process_normal; - main->setting.process_set = &fss_write_process_set; + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by basic. main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; // Not supported by basic. + + main->callback.process_content = &fss_write_basic_process_content; + main->callback.process_help = &fss_write_basic_process_help; + main->callback.process_object = &fss_write_basic_process_object; + main->callback.process_pipe = &fss_write_process_pipe; + main->callback.process_normal = &fss_write_process_normal; + main->callback.process_set = &fss_write_process_set; } else if (f_compare_dynamic(argv[index], fss_write_format_code_short_0001_s) == F_equal_to || f_compare_dynamic(argv[index], fss_write_format_code_long_0001_s) == F_equal_to || @@ -133,14 +136,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_write_format_code_machine_0001_s) == F_equal_to) { main->setting.standard = fss_write_extended_standard_s; - main->setting.process_content = &fss_write_extended_process_content; - main->setting.process_help = &fss_write_extended_process_help; - main->setting.process_object = &fss_write_extended_process_object; - main->setting.process_pipe = &fss_write_process_pipe; - main->setting.process_normal = &fss_write_process_normal; - main->setting.process_set = &fss_write_process_set; + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by extended. main->setting.flag |= fss_write_main_flag_content_multiple_e; + + main->callback.process_content = &fss_write_extended_process_content; + main->callback.process_help = &fss_write_extended_process_help; + main->callback.process_object = &fss_write_extended_process_object; + main->callback.process_pipe = &fss_write_process_pipe; + main->callback.process_normal = &fss_write_process_normal; + main->callback.process_set = &fss_write_process_set; } else if (f_compare_dynamic(argv[index], fss_write_format_code_short_0002_s) == F_equal_to || f_compare_dynamic(argv[index], fss_write_format_code_long_0002_s) == F_equal_to || @@ -148,14 +153,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_write_format_code_machine_0002_s) == F_equal_to) { main->setting.standard = fss_write_basic_list_standard_s; - main->setting.process_content = &fss_write_basic_list_process_content; - main->setting.process_help = &fss_write_basic_list_process_help; - main->setting.process_object = &fss_write_basic_list_process_object; - main->setting.process_pipe = &fss_write_process_pipe; - main->setting.process_normal = &fss_write_process_normal; - main->setting.process_set = &fss_write_process_set; + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by basic list. main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; // Not supported by basic list. + + main->callback.process_content = &fss_write_basic_list_process_content; + main->callback.process_help = &fss_write_basic_list_process_help; + main->callback.process_object = &fss_write_basic_list_process_object; + main->callback.process_pipe = &fss_write_process_pipe; + main->callback.process_normal = &fss_write_process_normal; + main->callback.process_set = &fss_write_process_set; } else if (f_compare_dynamic(argv[index], fss_write_format_code_short_0003_s) == F_equal_to || f_compare_dynamic(argv[index], fss_write_format_code_long_0003_s) == F_equal_to || @@ -163,14 +170,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_write_format_code_machine_0003_s) == F_equal_to) { main->setting.standard = fss_write_extended_list_standard_s; - main->setting.process_content = &fss_write_extended_list_process_content; - main->setting.process_help = &fss_write_extended_list_process_help; - main->setting.process_object = &fss_write_extended_list_process_object; - main->setting.process_pipe = &fss_write_process_pipe; - main->setting.process_normal = &fss_write_process_normal; - main->setting.process_set = &fss_write_process_set; + main->setting.flag |= fss_write_main_flag_ignore_e; main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; // Not supported by extended list. + + main->callback.process_content = &fss_write_extended_list_process_content; + main->callback.process_help = &fss_write_extended_list_process_help; + main->callback.process_object = &fss_write_extended_list_process_object; + main->callback.process_pipe = &fss_write_process_pipe; + main->callback.process_normal = &fss_write_process_normal; + main->callback.process_set = &fss_write_process_set; } else if (f_compare_dynamic(argv[index], fss_write_format_code_short_0008_s) == F_equal_to || f_compare_dynamic(argv[index], fss_write_format_code_long_0008_s) == F_equal_to || @@ -178,14 +187,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_write_format_code_machine_0008_s) == F_equal_to) { main->setting.standard = fss_write_embedded_list_standard_s; - main->setting.process_content = &fss_write_embedded_list_process_content; - main->setting.process_help = &fss_write_embedded_list_process_help; - main->setting.process_object = &fss_write_embedded_list_process_object; - main->setting.process_pipe = &fss_write_process_pipe; - main->setting.process_normal = &fss_write_process_normal; - main->setting.process_set = &fss_write_process_set; + main->setting.flag |= fss_write_main_flag_ignore_e; main->setting.flag |= fss_write_main_flag_content_multiple_e; + + main->callback.process_content = &fss_write_embedded_list_process_content; + main->callback.process_help = &fss_write_embedded_list_process_help; + main->callback.process_object = &fss_write_embedded_list_process_object; + main->callback.process_pipe = &fss_write_process_pipe; + main->callback.process_normal = &fss_write_process_normal; + main->callback.process_set = &fss_write_process_set; } else if (f_compare_dynamic(argv[index], fss_write_format_code_short_000e_s) == F_equal_to || f_compare_dynamic(argv[index], fss_write_format_code_long_000e_s) == F_equal_to || @@ -193,14 +204,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_compare_dynamic(argv[index], fss_write_format_code_machine_000e_s) == F_equal_to) { main->setting.standard = fss_write_payload_standard_s; - main->setting.process_content = 0; // Not used by payload. - main->setting.process_help = &fss_write_payload_process_help; - main->setting.process_normal = &fss_write_process_normal; - main->setting.process_object = 0; // Not used by payload. - main->setting.process_pipe = &fss_write_payload_process_pipe; - main->setting.process_set = &fss_write_payload_process_set; + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by payload. main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; // Not supported by payload. + + main->callback.process_content = 0; + main->callback.process_help = &fss_write_payload_process_help; + main->callback.process_normal = &fss_write_process_normal; + main->callback.process_object = 0; + main->callback.process_pipe = &fss_write_payload_process_pipe; + main->callback.process_set = &fss_write_payload_process_set; } else { if (main->setting.flag & fss_write_main_flag_help_e) { diff --git a/level_3/fss_write/c/main/main.h b/level_3/fss_write/c/main/main.h index f467646..f7e5fa50 100644 --- a/level_3/fss_write/c/main/main.h +++ b/level_3/fss_write/c/main/main.h @@ -36,6 +36,8 @@ extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This does not alter main.setting.state.status. diff --git a/level_3/fss_write/c/payload/fss_write.h b/level_3/fss_write/c/payload/fss_write.h index 9ac3fd5..8aa5dc5 100644 --- a/level_3/fss_write/c/payload/fss_write.h +++ b/level_3/fss_write/c/payload/fss_write.h @@ -51,9 +51,9 @@ #include #include #include -#include #include #include +#include #include #ifdef __cplusplus @@ -65,6 +65,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This does not alter main.setting.state.status. @@ -82,6 +84,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status: @@ -101,6 +105,8 @@ extern "C" { * * @param main * The program and settings data. + * + * Must not be NULL. * Must be of type fss_write_main_t. * * This alters main.setting.state.status: diff --git a/level_3/fss_write/c/payload/main.c b/level_3/fss_write/c/payload/main.c index 9fa4273..9e2bd11 100644 --- a/level_3/fss_write/c/payload/main.c +++ b/level_3/fss_write/c/payload/main.c @@ -18,12 +18,13 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.state.custom = (void *) &data; data.setting.standard = fss_write_payload_standard_s; - data.setting.process_content = 0; // Not used by payload. - data.setting.process_help = &fss_write_payload_process_help; - data.setting.process_normal = &fss_write_process_normal; - data.setting.process_object = 0; // Not used by payload. - data.setting.process_pipe = &fss_write_payload_process_pipe; - data.setting.process_set = &fss_write_payload_process_set; + + data.callback.process_content = 0; + data.callback.process_help = &fss_write_payload_process_help; + data.callback.process_normal = &fss_write_process_normal; + data.callback.process_object = 0; + data.callback.process_pipe = &fss_write_payload_process_pipe; + data.callback.process_set = &fss_write_payload_process_set; f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize; data.program.parameters.array = parameters; -- 1.8.3.1