From 974141f8bcabb46c1fe3f37745ebc890c69555fe Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 25 May 2023 23:23:07 -0500 Subject: [PATCH] Progress: Continue work on refactoring fss_*_read into fss_read. This gets the programs compiling. I decided not to get everything correct and instead decided to get everything compiling. The memory allocation needs to be fixed. There are a lot of fixme and todo comments to address. The payload and embedded list need special handling and are very much not implemented. Individual standard differences need to be handled (and some are stubbed out or copied over, making them invalid). --- level_3/fss_read/c/basic/fss_read.c | 21 +- level_3/fss_read/c/basic/fss_read.h | 3 +- level_3/fss_read/c/basic/main.c | 4 +- level_3/fss_read/c/basic/print.c | 2 + level_3/fss_read/c/basic_list/fss_read.c | 53 +++ level_3/fss_read/c/basic_list/fss_read.h | 27 ++ level_3/fss_read/c/basic_list/main.c | 31 +- level_3/fss_read/c/basic_list/print.c | 30 ++ level_3/fss_read/c/basic_list/print.h | 26 ++ level_3/fss_read/c/embedded_list/fss_read.c | 53 +++ level_3/fss_read/c/embedded_list/fss_read.h | 27 ++ level_3/fss_read/c/embedded_list/main.c | 35 +- level_3/fss_read/c/embedded_list/print.c | 2 + level_3/fss_read/c/extended/fss_read.c | 53 +++ level_3/fss_read/c/extended/fss_read.h | 25 +- level_3/fss_read/c/extended/main.c | 35 +- level_3/fss_read/c/extended/print.c | 41 +++ level_3/fss_read/c/extended/print.h | 39 +++ level_3/fss_read/c/extended_list/fss_read.c | 53 +++ level_3/fss_read/c/extended_list/fss_read.h | 27 ++ level_3/fss_read/c/extended_list/main.c | 33 +- level_3/fss_read/c/extended_list/print.c | 16 + level_3/fss_read/c/extended_list/print.h | 24 ++ level_3/fss_read/c/main/common.c | 35 +- level_3/fss_read/c/main/common.h | 5 +- level_3/fss_read/c/main/common/enumeration.h | 38 +- level_3/fss_read/c/main/common/print.c | 6 + level_3/fss_read/c/main/common/print.h | 6 + level_3/fss_read/c/main/common/string.c | 2 + level_3/fss_read/c/main/common/string.h | 6 + level_3/fss_read/c/main/common/type.c | 2 + level_3/fss_read/c/main/common/type.h | 39 ++- level_3/fss_read/c/main/fss_read.c | 14 +- level_3/fss_read/c/main/main.c | 131 ++++--- level_3/fss_read/c/main/main/print.c | 2 + level_3/fss_read/c/main/print/data.c | 38 +- level_3/fss_read/c/main/print/data.h | 29 +- level_3/fss_read/c/main/print/message.c | 2 +- level_3/fss_read/c/main/process_normal.c | 35 +- level_3/fss_read/c/payload/fss_read.c | 504 ++------------------------- level_3/fss_read/c/payload/fss_read.h | 26 +- level_3/fss_read/c/payload/main.c | 32 +- level_3/fss_read/c/payload/print.c | 2 + level_3/fss_write/c/main/main.c | 24 +- level_3/fss_write/c/payload/main.c | 1 + 45 files changed, 916 insertions(+), 723 deletions(-) diff --git a/level_3/fss_read/c/basic/fss_read.c b/level_3/fss_read/c/basic/fss_read.c index de01cdd..e29857a 100644 --- a/level_3/fss_read/c/basic/fss_read.c +++ b/level_3/fss_read/c/basic/fss_read.c @@ -15,18 +15,29 @@ extern "C" { #endif // _di_fss_read_basic_process_help_ #ifndef _di_fss_read_basic_process_load_ - void fss_read_basic_process_load(fss_read_main_t * const main) { + void fss_read_basic_process_load(void * const void_main) { - if (!main) return; + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; - f_string_range_t input = macro_f_string_range_t_initialize_2(main->setting.buffer.used); + if (main->setting.buffer.used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.buffer.used; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + main->setting.comments.used = 0; main->setting.delimits_object.used = 0; main->setting.delimits_content.used = 0; + main->setting.nest.used = 0; main->setting.quotes_object.used = 0; main->setting.quotes_content.used = 0; - fll_fss_basic_read(main->setting.buffer, &input, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state); + fll_fss_basic_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { if (F_status_set_fine(main->setting.state.status) == F_interrupt) return; @@ -36,7 +47,7 @@ extern "C" { F_status_set_fine(main->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), + fss_read_file_identify(main->setting.range.start, main->setting.files), f_file_operation_process_s, fll_error_file_type_file_e ); diff --git a/level_3/fss_read/c/basic/fss_read.h b/level_3/fss_read/c/basic/fss_read.h index 8775908..3d89735 100644 --- a/level_3/fss_read/c/basic/fss_read.h +++ b/level_3/fss_read/c/basic/fss_read.h @@ -93,6 +93,7 @@ extern "C" { * 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. @@ -107,7 +108,7 @@ extern "C" { * @see fss_read_file_identify() */ #ifndef _di_fss_read_basic_process_load_ - extern void fss_read_basic_process_load(fss_read_main_t * const main); + extern void fss_read_basic_process_load(void * const main); #endif // _di_fss_read_basic_process_load_ #ifdef __cplusplus diff --git a/level_3/fss_read/c/basic/main.c b/level_3/fss_read/c/basic/main.c index 7f7d182..a46a8f7 100644 --- a/level_3/fss_read/c/basic/main.c +++ b/level_3/fss_read/c/basic/main.c @@ -10,13 +10,15 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_read_print_flag_out_e; data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; 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.flag |= fss_read_main_flag_line_single_e; + data.setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_basic_standard_s; diff --git a/level_3/fss_read/c/basic/print.c b/level_3/fss_read/c/basic/print.c index d3eee9e..e71324a 100644 --- a/level_3/fss_read/c/basic/print.c +++ b/level_3/fss_read/c/basic/print.c @@ -19,6 +19,8 @@ extern "C" { fll_program_print_help_usage(print, fss_read_basic_program_name_s, f_string_empty_s); + f_print_dynamic_raw(f_string_eol_s, print->to); + fss_read_print_message_help_note_header(print, fss_read_format_code_short_0000_s, fss_read_format_code_name_0000_s); fss_read_print_message_help_pipe(print); 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 cef2b09..36574dd 100644 --- a/level_3/fss_read/c/basic_list/fss_read.c +++ b/level_3/fss_read/c/basic_list/fss_read.c @@ -14,6 +14,59 @@ extern "C" { } #endif // _di_fss_read_basic_list_process_help_ +#ifndef _di_fss_read_basic_list_process_load_ + void fss_read_basic_list_process_load(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.buffer.used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.buffer.used; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + + main->setting.comments.used = 0; + main->setting.delimits_object.used = 0; + main->setting.delimits_content.used = 0; + main->setting.nest.used = 0; + main->setting.quotes_object.used = 0; + main->setting.quotes_content.used = 0; + + fll_fss_basic_list_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state); + + if (F_status_is_error(main->setting.state.status)) { + if (F_status_set_fine(main->setting.state.status) == F_interrupt) return; + + fll_error_file_print( + &main->program.error, + F_status_set_fine(main->setting.state.status), + macro_fss_read_f(fll_fss_basic_list_read), + fll_error_file_flag_fallback_e, + fss_read_file_identify(main->setting.range.start, main->setting.files), + f_file_operation_process_s, + fll_error_file_type_file_e + ); + + return; + } + + if (main->setting.state.status == F_data_not_stop || main->setting.state.status == F_data_not_eos) { + if (!(main->setting.flag & fss_read_main_flag_total_e)) { + main->setting.state.status = F_status_set_warning(main->setting.state.status); + + return; + } + } + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_basic_list_process_load_ + #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 08f31a9..5ff936b 100644 --- a/level_3/fss_read/c/basic_list/fss_read.h +++ b/level_3/fss_read/c/basic_list/fss_read.h @@ -84,6 +84,33 @@ extern "C" { extern void fss_read_basic_list_process_help(void * const main); #endif // _di_fss_read_basic_list_process_help_ +/** + * Process the buffer, loading the FSS data. + * + * This will print an error message on error. + * + * @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. + * + * 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_list_read() + * + * @see fll_fss_basic_list_read() + * + * @see fss_read_file_identify() + */ +#ifndef _di_fss_read_basic_list_process_load_ + extern void fss_read_basic_list_process_load(void * const main); +#endif // _di_fss_read_basic_list_process_load_ + #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 f373922..d12db00 100644 --- a/level_3/fss_read/c/basic_list/main.c +++ b/level_3/fss_read/c/basic_list/main.c @@ -10,33 +10,36 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_read_print_flag_out_e; data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; + data.setting.flag |= fss_read_main_flag_trim_object_e; + data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_basic_list_standard_s; 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_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; + 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_list_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_basic_list_print_object_end; + data.callback.print_set_end = &fss_read_print_set_end_no_eol; 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/print.c b/level_3/fss_read/c/basic_list/print.c index 66f64e4..21c45d5 100644 --- a/level_3/fss_read/c/basic_list/print.c +++ b/level_3/fss_read/c/basic_list/print.c @@ -19,6 +19,8 @@ extern "C" { fll_program_print_help_usage(print, fss_read_basic_list_program_name_s, f_string_empty_s); + f_print_dynamic_raw(f_string_eol_s, print->to); + fss_read_print_message_help_note_header(print, fss_read_format_code_short_0002_s, fss_read_format_code_name_0002_s); fss_read_print_message_help_pipe(print); @@ -32,6 +34,34 @@ extern "C" { } #endif // _di_fss_read_basic_list_print_help_ +#ifndef _di_fss_read_basic_list_print_object_end_ + f_status_t fss_read_basic_list_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; + + f_file_stream_lock(print->to); + + if (main->setting.flag & fss_read_main_flag_pipe_e) { + f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + if (main->setting.flag & fss_read_main_flag_content_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); + } + } + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_basic_list_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/basic_list/print.h b/level_3/fss_read/c/basic_list/print.h index 6115a2c..f99fb8b 100644 --- a/level_3/fss_read/c/basic_list/print.h +++ b/level_3/fss_read/c/basic_list/print.h @@ -30,6 +30,32 @@ extern "C" { extern f_status_t fss_read_basic_list_print_help(fl_print_t * const print); #endif // _di_fss_read_basic_list_print_help_ +/** + * 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 f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() + */ +#ifndef _di_fss_read_basic_list_print_object_end_ + extern f_status_t fss_read_basic_list_print_object_end(fl_print_t * const print); +#endif // _di_fss_read_basic_list_print_object_end_ + #ifdef __cplusplus } // extern "C" #endif 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 1c1e944..e6a1434 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.c +++ b/level_3/fss_read/c/embedded_list/fss_read.c @@ -14,6 +14,59 @@ extern "C" { } #endif // _di_fss_read_embedded_list_process_help_ +#ifndef _di_fss_read_embedded_list_process_load_ + void fss_read_embedded_list_process_load(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.buffer.used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.buffer.used; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + + main->setting.comments.used = 0; + main->setting.delimits_object.used = 0; + main->setting.delimits_content.used = 0; + main->setting.nest.used = 0; + main->setting.quotes_object.used = 0; + main->setting.quotes_content.used = 0; + + fll_fss_embedded_list_read(main->setting.buffer, &main->setting.range, &main->setting.nest, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state); + + if (F_status_is_error(main->setting.state.status)) { + if (F_status_set_fine(main->setting.state.status) == F_interrupt) return; + + fll_error_file_print( + &main->program.error, + F_status_set_fine(main->setting.state.status), + macro_fss_read_f(fll_fss_embedded_list_read), + fll_error_file_flag_fallback_e, + fss_read_file_identify(main->setting.range.start, main->setting.files), + f_file_operation_process_s, + fll_error_file_type_file_e + ); + + return; + } + + if (main->setting.state.status == F_data_not_stop || main->setting.state.status == F_data_not_eos) { + if (!(main->setting.flag & fss_read_main_flag_total_e)) { + main->setting.state.status = F_status_set_warning(main->setting.state.status); + + return; + } + } + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_embedded_list_process_load_ + #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 a41e739..ea7b932 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.h +++ b/level_3/fss_read/c/embedded_list/fss_read.h @@ -84,6 +84,33 @@ extern "C" { extern void fss_read_embedded_list_process_help(void * const main); #endif // _di_fss_read_embedded_list_process_help_ +/** + * Process the buffer, loading the FSS data. + * + * This will print an error message on error. + * + * @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. + * + * 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_embedded_list_read() + * + * @see fll_fss_embedded_list_read() + * + * @see fss_read_file_identify() + */ +#ifndef _di_fss_read_embedded_list_process_load_ + extern void fss_read_embedded_list_process_load(void * const main); +#endif // _di_fss_read_embedded_list_process_load_ + #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 7eb9251..f07e183 100644 --- a/level_3/fss_read/c/embedded_list/main.c +++ b/level_3/fss_read/c/embedded_list/main.c @@ -10,37 +10,36 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_read_print_flag_out_e; data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; + data.setting.flag |= fss_read_main_flag_depth_multiple_e; + data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_embedded_list_standard_s; - 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_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; + 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_embedded_list_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/print.c b/level_3/fss_read/c/embedded_list/print.c index bac7ecf..5ea1df9 100644 --- a/level_3/fss_read/c/embedded_list/print.c +++ b/level_3/fss_read/c/embedded_list/print.c @@ -19,6 +19,8 @@ extern "C" { fll_program_print_help_usage(print, fss_read_embedded_list_program_name_s, f_string_empty_s); + f_print_dynamic_raw(f_string_eol_s, print->to); + fss_read_print_message_help_note_header(print, fss_read_format_code_short_0008_s, fss_read_format_code_name_0008_s); fss_read_print_message_help_pipe(print); diff --git a/level_3/fss_read/c/extended/fss_read.c b/level_3/fss_read/c/extended/fss_read.c index 899e67f..d79b7bb 100644 --- a/level_3/fss_read/c/extended/fss_read.c +++ b/level_3/fss_read/c/extended/fss_read.c @@ -14,6 +14,59 @@ extern "C" { } #endif // _di_fss_read_extended_process_help_ +#ifndef _di_fss_read_extended_process_load_ + void fss_read_extended_process_load(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.buffer.used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.buffer.used; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + + main->setting.comments.used = 0; + main->setting.delimits_object.used = 0; + main->setting.delimits_content.used = 0; + main->setting.nest.used = 0; + main->setting.quotes_object.used = 0; + main->setting.quotes_content.used = 0; + + fll_fss_extended_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.quotes_content, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state); + + if (F_status_is_error(main->setting.state.status)) { + if (F_status_set_fine(main->setting.state.status) == F_interrupt) return; + + fll_error_file_print( + &main->program.error, + F_status_set_fine(main->setting.state.status), + macro_fss_read_f(fll_fss_extended_read), + fll_error_file_flag_fallback_e, + fss_read_file_identify(main->setting.range.start, main->setting.files), + f_file_operation_process_s, + fll_error_file_type_file_e + ); + + return; + } + + if (main->setting.state.status == F_data_not_stop || main->setting.state.status == F_data_not_eos) { + if (!(main->setting.flag & fss_read_main_flag_total_e)) { + main->setting.state.status = F_status_set_warning(main->setting.state.status); + + return; + } + } + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_extended_process_load_ + #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 dd5ac86..477f27b 100644 --- a/level_3/fss_read/c/extended/fss_read.h +++ b/level_3/fss_read/c/extended/fss_read.h @@ -104,18 +104,31 @@ extern "C" { #endif // _di_fss_read_extended_process_help_ /** - * Process a single Object, printing the FSS-0001 (Extended) 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 not be NULL. * Must be of type fss_read_main_t. * - * This alters main.setting.state.status. - * This uses and alters main.setting.buffer. + * 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_extended_read() + * + * @see fll_fss_extended_read() + * + * @see fss_read_file_identify() */ -#ifndef _di_fss_read_extended_process_object_ - extern void fss_read_extended_process_object(void * const main); -#endif // _di_fss_read_extended_process_object_ +#ifndef _di_fss_read_extended_process_load_ + extern void fss_read_extended_process_load(void * const main); +#endif // _di_fss_read_extended_process_load_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/extended/main.c b/level_3/fss_read/c/extended/main.c index 28eda37..0c78dd5 100644 --- a/level_3/fss_read/c/extended/main.c +++ b/level_3/fss_read/c/extended/main.c @@ -10,36 +10,37 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_read_print_flag_out_e; data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; + data.setting.flag |= fss_read_main_flag_line_single_e | 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.setting.state.custom = (void *) &data; data.setting.standard = fss_read_extended_standard_s; - 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_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; + 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_extended_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_extended_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/print.c b/level_3/fss_read/c/extended/print.c index cc763dd..7f321e2 100644 --- a/level_3/fss_read/c/extended/print.c +++ b/level_3/fss_read/c/extended/print.c @@ -4,6 +4,45 @@ extern "C" { #endif +#ifndef _di_fss_read_extended_print_at_ + f_status_t fss_read_extended_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; + + // @todo This is copied from fss_read_print_at() and needs to be updated to handle multiple content. + + 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].array[0], delimits_content); + } + } + + if (main->callback.print_set_end) { + main->callback.print_set_end(&main->program.output); + } + } + + return F_none; + } +#endif // _di_fss_read_extended_print_at_ + #ifndef _di_fss_read_extended_print_help_ f_status_t fss_read_extended_print_help(fl_print_t * const print) { @@ -19,6 +58,8 @@ extern "C" { fll_program_print_help_usage(print, fss_read_extended_program_name_s, f_string_empty_s); + f_print_dynamic_raw(f_string_eol_s, print->to); + fss_read_print_message_help_note_header(print, fss_read_format_code_short_0001_s, fss_read_format_code_name_0001_s); fss_read_print_message_help_pipe(print); diff --git a/level_3/fss_read/c/extended/print.h b/level_3/fss_read/c/extended/print.h index de3b7e8..51d60a9 100644 --- a/level_3/fss_read/c/extended/print.h +++ b/level_3/fss_read/c/extended/print.h @@ -13,6 +13,45 @@ 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 main.callback.print_object() + * @see main.callback.print_object_end() + * @see main.callback.print_set_end() + */ +#ifndef _di_fss_read_extended_print_at_ + extern f_status_t fss_read_extended_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_extended_print_at_ + +/** * Print help for FSS-0001 (Extended). * * @param print 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 1f786c6..d332ce5 100644 --- a/level_3/fss_read/c/extended_list/fss_read.c +++ b/level_3/fss_read/c/extended_list/fss_read.c @@ -14,6 +14,59 @@ extern "C" { } #endif // _di_fss_read_extended_list_process_help_ +#ifndef _di_fss_read_extended_list_process_load_ + void fss_read_extended_list_process_load(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.buffer.used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.buffer.used; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + + main->setting.comments.used = 0; + main->setting.delimits_object.used = 0; + main->setting.delimits_content.used = 0; + main->setting.nest.used = 0; + main->setting.quotes_object.used = 0; + main->setting.quotes_content.used = 0; + + fll_fss_extended_list_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state); + + if (F_status_is_error(main->setting.state.status)) { + if (F_status_set_fine(main->setting.state.status) == F_interrupt) return; + + fll_error_file_print( + &main->program.error, + F_status_set_fine(main->setting.state.status), + macro_fss_read_f(fll_fss_extended_list_read), + fll_error_file_flag_fallback_e, + fss_read_file_identify(main->setting.range.start, main->setting.files), + f_file_operation_process_s, + fll_error_file_type_file_e + ); + + return; + } + + if (main->setting.state.status == F_data_not_stop || main->setting.state.status == F_data_not_eos) { + if (!(main->setting.flag & fss_read_main_flag_total_e)) { + main->setting.state.status = F_status_set_warning(main->setting.state.status); + + return; + } + } + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_extended_list_process_load_ + #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 5b0c76d..0a3a4d8 100644 --- a/level_3/fss_read/c/extended_list/fss_read.h +++ b/level_3/fss_read/c/extended_list/fss_read.h @@ -84,6 +84,33 @@ extern "C" { extern void fss_read_extended_list_process_help(void * const main); #endif // _di_fss_read_extended_list_process_help_ +/** + * Process the buffer, loading the FSS data. + * + * This will print an error message on error. + * + * @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. + * + * 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_extended_list_read() + * + * @see fll_fss_extended_list_read() + * + * @see fss_read_file_identify() + */ +#ifndef _di_fss_read_extended_list_process_load_ + extern void fss_read_extended_list_process_load(void * const main); +#endif // _di_fss_read_extended_list_process_load_ + #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 c630257..3adffc5 100644 --- a/level_3/fss_read/c/extended_list/main.c +++ b/level_3/fss_read/c/extended_list/main.c @@ -10,35 +10,36 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_read_print_flag_out_e; data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; + data.setting.flag |= fss_read_main_flag_trim_object_e; + data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_extended_list_standard_s; - 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_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; + 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_extended_list_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_extended_list_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/print.c b/level_3/fss_read/c/extended_list/print.c index 5652239..391a1e3 100644 --- a/level_3/fss_read/c/extended_list/print.c +++ b/level_3/fss_read/c/extended_list/print.c @@ -19,6 +19,8 @@ extern "C" { fll_program_print_help_usage(print, fss_read_extended_list_program_name_s, f_string_empty_s); + f_print_dynamic_raw(f_string_eol_s, print->to); + fss_read_print_message_help_note_header(print, fss_read_format_code_short_0003_s, fss_read_format_code_name_0003_s); fss_read_print_message_help_pipe(print); @@ -32,6 +34,20 @@ extern "C" { } #endif // _di_fss_read_extended_list_print_help_ +#ifndef _di_fss_read_extended_list_print_set_end_ + f_status_t fss_read_extended_list_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; + + // @todo + //fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_end_s : f_string_eol_s, print->to); + + return F_none; + } +#endif // _di_fss_read_extended_list_print_set_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/extended_list/print.h b/level_3/fss_read/c/extended_list/print.h index aef9744..c3d655d 100644 --- a/level_3/fss_read/c/extended_list/print.h +++ b/level_3/fss_read/c/extended_list/print.h @@ -30,6 +30,30 @@ extern "C" { extern f_status_t fss_read_extended_list_print_help(fl_print_t * const print); #endif // _di_fss_read_extended_list_print_help_ +/** + * 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 fll_print_dynamic_raw() + */ +#ifndef _di_fss_read_extended_list_print_set_end_ + extern f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print); +#endif // _di_fss_read_extended_list_print_set_end_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index 2e7acb9..0ed95ce 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -480,20 +480,34 @@ extern "C" { f_file_t file = f_file_t_initialize; + fss_read_files_resize(((main->program.pipe & fll_program_data_pipe_input_e) ? 1 : 0) + parameters->remaining.used, &main->setting.files); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_files_resize)); + + return; + } + if (main->program.pipe & fll_program_data_pipe_input_e) { file.id = F_type_descriptor_input_d; file.stream = F_type_input_d; main->setting.files.array[0].range.start = 0; - main->setting.state.status = f_file_stream_read(file, &main->setting.buffer); + while (main->setting.state.status != F_none_eof) { + + if (fss_read_signal_check(main)) break; + + main->setting.state.status = f_file_stream_read_block(file, &main->setting.buffer); + if (F_status_is_error(main->setting.state.status)) break; + } // while if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_read), fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_stream_read_block), fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); return; } @@ -627,9 +641,11 @@ extern "C" { #endif // _di_fss_read_setting_load_ #ifndef _di_fss_read_setting_load_depth_ - void fss_read_setting_load_depth(const f_console_arguments_t arguments, fss_read_main_t * const main, f_console_parameters_t * const parameters) { + void fss_read_setting_load_depth(const f_console_arguments_t arguments, void * const void_main, f_console_parameters_t * const parameters) { - if (!main || !parameters) return; + if (!void_main || !parameters) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; f_array_length_t i = 1; @@ -637,8 +653,9 @@ extern "C" { i = parameters->array[fss_read_parameter_depth_e].values.used; } - if (i > main->setting.depths.size) { - main->setting.state.status = fss_read_depths_resize(i, &main->setting.depths); + // @fixme: much of the logic in this depths handling was static and is now dynamic, this needs to be reviewed and updated. + if (i + 1 > main->setting.depths.size) { + main->setting.state.status = fss_read_depths_resize(i + 1, &main->setting.depths); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { @@ -665,9 +682,7 @@ extern "C" { main->setting.depths.array[i].index_at = 0; main->setting.depths.array[i].index_name = 0; main->setting.depths.array[i].value_at = 0; - - // This dynamic string is actually a static string, so clear it between loops. - macro_f_string_dynamic_t_clear(main->setting.depths.array[i].value_name); + main->setting.depths.array[i].value_name.used = 0; // @fixme this needs to be fully reset to 0. if (!parameters->array[fss_read_parameter_depth_e].values.used) { position_depth = 0; @@ -783,7 +798,7 @@ extern "C" { } // for if (main->callback.process_load_depth) { - main->callback.process_load_depth(arguments, (void *) main); + main->callback.process_load_depth(arguments, (void *) main, parameters); 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 c2d6442..a4f96dc 100644 --- a/level_3/fss_read/c/main/common.h +++ b/level_3/fss_read/c/main/common.h @@ -79,6 +79,9 @@ extern "C" { * @param main * The main program data. * + * Must not be NULL. + * Must be of type fss_read_main_t. + * * This calls main.callback.process_load_depth() if not NULL. * * This alters main.setting.state.status: @@ -106,7 +109,7 @@ extern "C" { * @see fss_read_setting_load() */ #ifndef _di_fss_read_setting_load_depth_ - extern void fss_read_setting_load_depth(const f_console_arguments_t arguments, fss_read_main_t * const main, f_console_parameters_t * const parameters); + extern void fss_read_setting_load_depth(const f_console_arguments_t arguments, void * const main, f_console_parameters_t * const parameters); #endif // _di_fss_read_setting_load_depth_ #ifdef __cplusplus diff --git a/level_3/fss_read/c/main/common/enumeration.h b/level_3/fss_read/c/main/common/enumeration.h index 365210c..7fee9bd 100644 --- a/level_3/fss_read/c/main/common/enumeration.h +++ b/level_3/fss_read/c/main/common/enumeration.h @@ -44,6 +44,7 @@ extern "C" { * - 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). + * - trim_object: Empty space before and after Objects (but not Content) will not be printed (They will be trimmed). * - version: Print version. */ #ifndef _di_fss_read_main_flag_e_ @@ -72,12 +73,11 @@ extern "C" { 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, + fss_read_main_flag_trim_object_e = 0x800000, + fss_read_main_flag_version_e = 0x1000000, }; // enum #endif // _di_fss_read_main_flag_e_ -//@todo figure out if fss_read_main_flag_ignore_e is needed - /** * The main program parameters. */ @@ -97,6 +97,7 @@ extern "C" { fss_read_parameter_line_first_no_e, fss_read_parameter_line_last_no_e, + fss_read_parameter_as_e, fss_read_parameter_at_e, fss_read_parameter_content_e, fss_read_parameter_columns_e, @@ -117,23 +118,24 @@ extern "C" { { \ macro_fll_program_console_parameter_standard_initialize, \ \ - macro_f_console_parameter_t_initialize_3(fss_read_short_at_s, fss_read_long_at_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_content_s, fss_read_long_content_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_columns_s, fss_read_long_columns_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_delimit_s, fss_read_long_delimit_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_depth_s, fss_read_long_depth_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_empty_s, fss_read_long_empty_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_line_s, fss_read_long_line_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_name_s, fss_read_long_name_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_object_s, fss_read_long_object_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_pipe_s, fss_read_long_pipe_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_original_s, fss_read_long_original_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_select_s, fss_read_long_select_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_total_s, fss_read_long_total_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_read_short_trim_s, fss_read_long_trim_s, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_as_s, fss_read_long_as_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_at_s, fss_read_long_at_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_content_s, fss_read_long_content_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_columns_s, fss_read_long_columns_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_delimit_s, fss_read_long_delimit_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_depth_s, fss_read_long_depth_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_empty_s, fss_read_long_empty_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_line_s, fss_read_long_line_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_name_s, fss_read_long_name_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_object_s, fss_read_long_object_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_pipe_s, fss_read_long_pipe_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_original_s, fss_read_long_original_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_select_s, fss_read_long_select_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_total_s, fss_read_long_total_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_trim_s, fss_read_long_trim_s, 0, f_console_flag_normal_e), \ } - #define fss_read_total_parameters_d 27 + #define fss_read_total_parameters_d 28 #endif // _di_fss_read_parameter_e_ /** diff --git a/level_3/fss_read/c/main/common/print.c b/level_3/fss_read/c/main/common/print.c index 1edbe00..b773af0 100644 --- a/level_3/fss_read/c/main/common/print.c +++ b/level_3/fss_read/c/main/common/print.c @@ -11,6 +11,7 @@ extern "C" { "f_file_size_by_id", "f_file_stream_open", "f_file_stream_read", + "f_file_stream_read_block", "f_file_stream_read_until", "f_fss_is_space", "f_rip_dynamic", @@ -43,10 +44,15 @@ extern "C" { "fl_fss_extended_object_read", "fl_fss_payload_content_read", "fll_fss_basic_read", + "fll_fss_basic_list_read", + "fll_fss_embedded_list_read", + "fll_fss_extended_read", + "fll_fss_extended_list_read", "fll_fss_payload_read", "fll_program_parameter_process_context", "fll_program_parameter_process_verbosity", "fss_read_depths_resize", + "fss_read_files_resize", "fss_read_setting_load_depth", }; #endif // _di_fss_read_f_a_ diff --git a/level_3/fss_read/c/main/common/print.h b/level_3/fss_read/c/main/common/print.h index 074aae0..d49f1cf 100644 --- a/level_3/fss_read/c/main/common/print.h +++ b/level_3/fss_read/c/main/common/print.h @@ -44,6 +44,7 @@ extern "C" { fss_read_f_f_file_size_by_id_e, fss_read_f_f_file_stream_open_e, fss_read_f_f_file_stream_read_e, + fss_read_f_f_file_stream_read_block_e, fss_read_f_f_file_stream_read_until_e, fss_read_f_f_fss_is_space_e, fss_read_f_f_rip_dynamic_e, @@ -76,10 +77,15 @@ extern "C" { 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_basic_list_read_e, + fss_read_f_fll_fss_embedded_list_read_e, + fss_read_f_fll_fss_extended_read_e, + fss_read_f_fll_fss_extended_list_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_fss_read_depths_resize_e, + fss_read_f_fss_read_files_resize_e, fss_read_f_fss_read_setting_load_depth_e, }; // enum #endif // _di_fss_read_f_e_ diff --git a/level_3/fss_read/c/main/common/string.c b/level_3/fss_read/c/main/common/string.c index 3c65073..987a896 100644 --- a/level_3/fss_read/c/main/common/string.c +++ b/level_3/fss_read/c/main/common/string.c @@ -32,6 +32,7 @@ extern "C" { #endif // _di_fss_read_delimit_mode_s_ #ifndef _di_fss_read_parameter_s_ + const f_string_static_t fss_read_short_as_s = macro_f_string_static_t_initialize_1(FSS_READ_short_as_s, 0, FSS_READ_short_as_s_length); const f_string_static_t fss_read_short_at_s = macro_f_string_static_t_initialize_1(FSS_READ_short_at_s, 0, FSS_READ_short_at_s_length); const f_string_static_t fss_read_short_content_s = macro_f_string_static_t_initialize_1(FSS_READ_short_content_s, 0, FSS_READ_short_content_s_length); const f_string_static_t fss_read_short_columns_s = macro_f_string_static_t_initialize_1(FSS_READ_short_columns_s, 0, FSS_READ_short_columns_s_length); @@ -47,6 +48,7 @@ extern "C" { const f_string_static_t fss_read_short_total_s = macro_f_string_static_t_initialize_1(FSS_READ_short_total_s, 0, FSS_READ_short_total_s_length); const f_string_static_t fss_read_short_trim_s = macro_f_string_static_t_initialize_1(FSS_READ_short_trim_s, 0, FSS_READ_short_trim_s_length); + const f_string_static_t fss_read_long_as_s = macro_f_string_static_t_initialize_1(FSS_READ_long_as_s, 0, FSS_READ_long_as_s_length); const f_string_static_t fss_read_long_at_s = macro_f_string_static_t_initialize_1(FSS_READ_long_at_s, 0, FSS_READ_long_at_s_length); const f_string_static_t fss_read_long_content_s = macro_f_string_static_t_initialize_1(FSS_READ_long_content_s, 0, FSS_READ_long_content_s_length); const f_string_static_t fss_read_long_columns_s = macro_f_string_static_t_initialize_1(FSS_READ_long_columns_s, 0, FSS_READ_long_columns_s_length); diff --git a/level_3/fss_read/c/main/common/string.h b/level_3/fss_read/c/main/common/string.h index 08c4dd7..154ea9a 100644 --- a/level_3/fss_read/c/main/common/string.h +++ b/level_3/fss_read/c/main/common/string.h @@ -136,6 +136,7 @@ extern "C" { * The main program parameters. */ #ifndef _di_fss_read_parameter_s_ + #define FSS_READ_short_as_s "A" #define FSS_READ_short_at_s "a" #define FSS_READ_short_content_s "c" #define FSS_READ_short_columns_s "C" @@ -151,6 +152,7 @@ extern "C" { #define FSS_READ_short_total_s "t" #define FSS_READ_short_trim_s "T" + #define FSS_READ_long_as_s "as" #define FSS_READ_long_at_s "at" #define FSS_READ_long_content_s "content" #define FSS_READ_long_columns_s "columns" @@ -166,6 +168,7 @@ extern "C" { #define FSS_READ_long_total_s "total" #define FSS_READ_long_trim_s "trim" + #define FSS_READ_short_as_s_length 1 #define FSS_READ_short_at_s_length 1 #define FSS_READ_short_content_s_length 1 #define FSS_READ_short_columns_s_length 1 @@ -181,6 +184,7 @@ extern "C" { #define FSS_READ_short_total_s_length 1 #define FSS_READ_short_trim_s_length 1 + #define FSS_READ_long_as_s_length 2 #define FSS_READ_long_at_s_length 2 #define FSS_READ_long_content_s_length 7 #define FSS_READ_long_columns_s_length 7 @@ -196,6 +200,7 @@ extern "C" { #define FSS_READ_long_total_s_length 5 #define FSS_READ_long_trim_s_length 4 + extern const f_string_static_t fss_read_short_as_s; extern const f_string_static_t fss_read_short_at_s; extern const f_string_static_t fss_read_short_content_s; extern const f_string_static_t fss_read_short_columns_s; @@ -211,6 +216,7 @@ extern "C" { extern const f_string_static_t fss_read_short_total_s; extern const f_string_static_t fss_read_short_trim_s; + extern const f_string_static_t fss_read_long_as_s; extern const f_string_static_t fss_read_long_at_s; extern const f_string_static_t fss_read_long_content_s; extern const f_string_static_t fss_read_long_columns_s; diff --git a/level_3/fss_read/c/main/common/type.c b/level_3/fss_read/c/main/common/type.c index d520513..5315e61 100644 --- a/level_3/fss_read/c/main/common/type.c +++ b/level_3/fss_read/c/main/common/type.c @@ -81,6 +81,8 @@ extern "C" { f_string_ranges_resize(0, &setting->comments); f_string_rangess_resize(0, &setting->contents); + f_fss_nest_resize(0, &setting->nest); + f_array_lengths_resize(0, &setting->delimits_object); f_array_lengths_resize(0, &setting->delimits_content); diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index dc18df2..e239c4f 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -123,7 +123,6 @@ extern "C" { * 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_pipe: Process data piped to the program from standard input (stdin). * * process_at: Process at parameter, usually called by the process_normal() callback. * process_columns: Process columns parameter, usually called by the process_normal() callback. @@ -134,18 +133,17 @@ extern "C" { * * print_at: Print at the given location, usually called by the process_normal() callback. * print_object: Print the Object, usually called by the process_normal() callback. - * print_content: Print the Object, usually called by the process_normal() callback. + * print_content: Print the Content, usually called by the process_normal() callback. * print_content_ignore: Print the Content ignore character, usually called by several callbacks within the process_normal() callback for a pipe. * print_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. + * print_set_end: Print the Content 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_load_depth)(const f_console_arguments_t arguments, void * const main, f_console_parameters_t * const parameters); void (*process_normal)(void * const main); - void (*process_pipe)(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[]); @@ -154,12 +152,12 @@ extern "C" { 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_string_range_t range, 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); + f_status_t (*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); + f_status_t (*print_object)(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits); + f_status_t (*print_content)(fl_print_t * const print, const f_string_range_t range, const uint8_t quote, const f_fss_delimits_t delimits); + f_status_t (*print_content_ignore)(fl_print_t * const print); + f_status_t (*print_object_end)(fl_print_t * const print); + f_status_t (*print_set_end)(fl_print_t * const print); } fss_read_callback_t; #define fss_read_callback_t_initialize \ @@ -179,7 +177,6 @@ extern "C" { 0, \ 0, \ 0, \ - 0, \ } #endif // _di_fss_read_callback_t_ @@ -209,11 +206,14 @@ extern "C" { * standard: A human-friendly string describing the standard in use, such as "FSS-0000 (Basic)". * buffer: The buffer containing all loaded files (and STDIN pipe). * - * objects: The positions within the buffer representing Objects. + * comments: The positions within the buffer representing comments. * contents: The positions within the buffer representing Contents. * 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. + * nests: The positions within the buffer representing nested Objects and Contents. + * objects: The positions within the buffer representing Objects. + * quotes_object: The quotes within the Object structure. + * quotes_content: The quotes within the Content structure. */ #ifndef _di_fss_read_setting_t_ typedef struct { @@ -235,11 +235,13 @@ extern "C" { f_string_static_t standard; f_string_dynamic_t buffer; - f_fss_objects_t objects; + f_fss_comments_t comments; f_fss_contents_t contents; f_fss_delimits_t delimits_object; f_fss_delimits_t delimits_content; - f_fss_comments_t comments; + f_fss_nest_t nest; + f_fss_objects_t objects; + f_uint8s_t quotes_object; f_uint8ss_t quotes_content; } fss_read_setting_t; @@ -258,11 +260,12 @@ extern "C" { fss_read_depths_t_initialize, \ f_string_static_t_initialize, \ f_string_dynamic_t_initialize, \ - f_fss_objects_t_initialize, \ + f_fss_comments_t_initialize, \ f_fss_contents_t_initialize, \ f_fss_delimits_t_initialize, \ f_fss_delimits_t_initialize, \ - f_fss_comments_t_initialize, \ + f_fss_nest_t_initialize, \ + f_fss_objects_t_initialize, \ f_uint8s_t_initialize, \ f_uint8ss_t_initialize, \ } diff --git a/level_3/fss_read/c/main/fss_read.c b/level_3/fss_read/c/main/fss_read.c index 3053a80..5c2d4c8 100644 --- a/level_3/fss_read/c/main/fss_read.c +++ b/level_3/fss_read/c/main/fss_read.c @@ -89,17 +89,9 @@ extern "C" { return; } - if (main->program.pipe & fll_program_data_pipe_input_e) { - 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)) { - if (main->callback.process_normal) { - main->callback.process_normal(void_main); - } + if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e)) { + if (main->callback.process_normal) { + main->callback.process_normal(void_main); } } diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index 2a66c2b..ff36084 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -17,6 +17,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_read_print_flag_out_e; data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; @@ -97,12 +98,24 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_basic_standard_s; - 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_last_line = &fss_read_process_last_line; + main->callback.process_load_depth = &fss_read_setting_load_depth; 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; + + main->callback.process_at = &fss_read_process_normal_at; + main->callback.process_columns = &fss_read_process_normal_columns; + main->callback.process_line = &fss_read_process_normal_line; + main->callback.process_load = 0; + main->callback.process_name = &fss_read_process_normal_name; + main->callback.process_total = &fss_read_process_normal_total; + + main->callback.print_at = &fss_read_print_at; + main->callback.print_content = &fss_read_print_content; + main->callback.print_content_ignore = &fss_read_print_content_ignore; + main->callback.print_object = &fss_read_print_object; + main->callback.print_object_end = &fss_read_print_object_end; + main->callback.print_set_end = &fss_read_print_set_end; 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) { @@ -120,15 +133,19 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_basic_standard_s; - 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. + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_trim_object_e; + + main->setting.flag |= fss_read_main_flag_line_single_e; + main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; - 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; + main->callback.process_load = &fss_read_basic_process_load; + main->callback.print_set_end = &fss_read_print_set_end; + + main->callback.print_object_end = &fss_read_print_object_end; } 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 || @@ -137,15 +154,18 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_extended_standard_s; - 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; + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_trim_object_e; + + main->setting.flag |= fss_read_main_flag_line_single_e | fss_read_main_flag_content_multiple_e; + main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_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; + main->callback.process_load = &fss_read_extended_process_load; + main->callback.print_set_end = &fss_read_print_set_end_no_eol; + + main->callback.print_object_end = &fss_read_print_object_end; } 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 || @@ -154,15 +174,20 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_basic_list_standard_s; - 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. + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; + + main->setting.flag |= fss_read_main_flag_trim_object_e; - 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; + main->callback.process_load = &fss_read_basic_list_process_load; + main->callback.print_set_end = &fss_read_print_set_end; + + main->callback.print_object_end = &fss_read_basic_list_print_object_end; } 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 || @@ -171,15 +196,20 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_extended_list_standard_s; - 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. + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; + + main->setting.flag |= fss_read_main_flag_trim_object_e; - 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; + main->callback.process_load = &fss_read_extended_list_process_load; + main->callback.print_set_end = &fss_read_print_set_end; + + main->callback.print_object_end = &fss_read_print_object_end; } 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 || @@ -188,15 +218,19 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_embedded_list_standard_s; - main->setting.flag |= fss_read_main_flag_ignore_e; - main->setting.flag |= fss_read_main_flag_content_multiple_e; + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; + + main->setting.flag |= fss_read_main_flag_trim_object_e; + main->setting.flag |= fss_read_main_flag_content_multiple_e | fss_read_main_flag_depth_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; + main->callback.process_load = &fss_read_embedded_list_process_load; + main->callback.print_set_end = &fss_read_print_set_end; + + main->callback.print_object_end = &fss_read_print_object_end; } 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 || @@ -205,15 +239,20 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_payload_standard_s; - 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. + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; + + main->setting.flag |= fss_read_main_flag_trim_object_e; - 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; + main->callback.process_load = &fss_read_payload_process_load; + main->callback.print_set_end = &fss_read_print_set_end; + + main->callback.print_object_end = &fss_read_print_object_end; } else { if (main->setting.flag & fss_read_main_flag_help_e) { diff --git a/level_3/fss_read/c/main/main/print.c b/level_3/fss_read/c/main/main/print.c index 3647488..8165784 100644 --- a/level_3/fss_read/c/main/main/print.c +++ b/level_3/fss_read/c/main/main/print.c @@ -48,6 +48,8 @@ extern "C" { fll_program_print_help_usage(print, fss_read_program_name_s, f_string_empty_s); + f_print_dynamic_raw(f_string_eol_s, print->to); + fss_read_print_message_help_note_header(print, f_string_empty_s, f_string_empty_s); fss_read_print_message_help_pipe(print); diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index 8b95673..a7cd1b2 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -109,7 +109,7 @@ extern "C" { if (at >= main->setting.objects.used) return F_output_not; - if (main->setting.flag & fss_read_main_flag_trim_e) { + if (main->setting.flag & (fss_read_main_flag_trim_e | fss_read_main_flag_trim_object_e)) { if (main->setting.flag & fss_read_main_flag_original_e) { if (main->setting.quotes_object.array[at]) { fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]); @@ -153,23 +153,7 @@ extern "C" { 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); - } - */ - } + fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_start_s : f_fss_space_s, print->to); return F_none; } @@ -200,16 +184,26 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) print->custom; + fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_end_s : f_string_eol_s, print->to); + + return F_none; + } +#endif // _di_fss_read_print_set_end_ + +#ifndef _di_fss_read_print_set_end_no_eol_ + f_status_t fss_read_print_set_end_no_eol(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_set_end_ +#endif // _di_fss_read_print_set_end_no_eol_ #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 da206d2..d013f09 100644 --- a/level_3/fss_read/c/main/print/data.h +++ b/level_3/fss_read/c/main/print/data.h @@ -47,8 +47,7 @@ extern "C" { * @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_content() * @see main.callback.print_object() * @see main.callback.print_object_end() * @see main.callback.print_set_end() @@ -255,6 +254,32 @@ extern "C" { extern f_status_t fss_read_print_set_end(fl_print_t * const print); #endif // _di_fss_read_print_set_end_ +/** + * Print the end of an Object/Content set. + * + * This is a variation of fss_read_print_set_end() that does not print the EOL. + * + * 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_set_end_no_eol_ + extern f_status_t fss_read_print_set_end_no_eol(fl_print_t * const print); +#endif // _di_fss_read_print_set_end_no_eol_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_read/c/main/print/message.c b/level_3/fss_read/c/main/print/message.c index 6af6032..9f7f282 100644 --- a/level_3/fss_read/c/main/print/message.c +++ b/level_3/fss_read/c/main/print/message.c @@ -35,7 +35,7 @@ extern "C" { if (!print) return; - fl_print_format(" %[Notes:%]%r This program will print the data associated with the given Object and Content based on the FSS", print->to, f_string_eol_s); + fl_print_format(" %[Notes:%]%r This program will print the data associated with the given Object and Content based on the FSS", print->to, print->set->notable, print->set->notable, f_string_eol_s); if (number.used) { fl_print_format("-%Q", print->to, number); diff --git a/level_3/fss_read/c/main/process_normal.c b/level_3/fss_read/c/main/process_normal.c index f39c25f..09ac7da 100644 --- a/level_3/fss_read/c/main/process_normal.c +++ b/level_3/fss_read/c/main/process_normal.c @@ -77,7 +77,7 @@ extern "C" { if (!names[i]) continue; if (fss_read_signal_check(main)) return; - main->callback.print_at(main, i, *delimits_object, *delimits_content); + main->callback.print_at(&main->program.output, i, *delimits_object, *delimits_content); } // for } @@ -181,7 +181,7 @@ extern "C" { } } else if (main->callback.print_at) { - main->callback.print_at(main, i, delimits_object, delimits_content); + main->callback.print_at(&main->program.output, i, delimits_object, delimits_content); } main->setting.state.status = F_none; @@ -217,15 +217,28 @@ extern "C" { f_array_length_t max = 0; - for (f_array_length_t at = 0; at < main->setting.contents.used; ++at) { + if (main->setting.flag & fss_read_main_flag_content_multiple_e) { + 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 (!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 + if (main->setting.contents.array[at].used > max) { + max = main->setting.contents.array[at].used; + } + } // for + } + else { + for (f_array_length_t at = 0; at < main->setting.contents.used; ++at) { + + if (names[at]) { + max = 1; + break; + } + + if (fss_read_signal_check(main)) return; + } // for + } fss_read_print_number(&main->program.output, max); @@ -268,7 +281,7 @@ extern "C" { if (line == main->setting.line) { if (main->callback.print_at) { main->callback.print_at( - main, + &main->program.output, i, !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_object_is(main, 0) ? main->setting.delimits_object @@ -301,7 +314,7 @@ extern "C" { memset(names, F_false, sizeof(bool) * main->setting.objects.used); - if (main->setting.flag & fss_read_main_flag_trim_e) { + if (main->setting.flag & (fss_read_main_flag_trim_e | fss_read_main_flag_trim_object_e)) { for (i = 0; i < main->setting.objects.used; ++i) { if (fss_read_signal_check(main)) return; diff --git a/level_3/fss_read/c/payload/fss_read.c b/level_3/fss_read/c/payload/fss_read.c index fb2073d..5a69c75 100644 --- a/level_3/fss_read/c/payload/fss_read.c +++ b/level_3/fss_read/c/payload/fss_read.c @@ -14,346 +14,58 @@ extern "C" { } #endif // _di_fss_read_payload_process_help_ -#ifndef _di_fss_read_payload_process_pipe_ - void fss_read_payload_process_pipe(void * const void_main) { +#ifndef _di_fss_read_payload_process_load_ + void fss_read_payload_process_load(void * const void_main) { if (!void_main) return; fss_read_main_t * const main = (fss_read_main_t *) void_main; - f_status_t status_pipe = F_none; - f_file_t input = f_file_t_initialize; - input.id = F_type_descriptor_input_d; - input.size_read = fss_read_allocation_large_d; - - f_array_length_t total = 0; - f_array_length_t length = 0; - f_string_range_t range = f_string_range_t_initialize; - - // @todo much of this is copied from fss_write and needs to be updated or removed accordingly. - - const f_array_length_t used_objects = main->setting.objects.used; - const f_array_length_t used_contents = main->setting.contents.used; - - // @fixme really? why am I setting a pointer to the used position, which may not even be allocated? Review this and perhaps first pre-allocate the space so the used is within the size. - main->setting.object = &main->setting.objects.array[used_objects]; - main->setting.contents = &main->setting.contents.array[used_contents]; - - // 0x0 = nothing printed, 0x1 = something printed, 0x2 = ignore enabled, 0x4 = added Content for Object, 0x8 = "payload" matched. - uint8_t flag = 0; - - // 0x0 = start new object/content set, 0x1 = processing object, 0x2 = processing content, 0x3 = end object/content set, 0x4 = processing payload content. - uint8_t state = 0; - - // This is processed in a single set, so there is only ever one Object added. - main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, &main->setting.objects); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); - - return; + if (main->setting.buffer.used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.buffer.used; } - - // This is processed in a single set, so there is only ever one Content added. - main->setting.state.status = f_string_dynamicss_increase(main->setting.state.step_small, &main->setting.contentss); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamicss_increase)); - - return; + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; } - main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); + main->setting.comments.used = 0; + main->setting.delimits_object.used = 0; + main->setting.delimits_content.used = 0; + main->setting.nest.used = 0; + main->setting.quotes_object.used = 0; + main->setting.quotes_content.used = 0; + + fll_fss_payload_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); + if (F_status_set_fine(main->setting.state.status) == F_interrupt) return; + + fll_error_file_print( + &main->program.error, + F_status_set_fine(main->setting.state.status), + macro_fss_read_f(fll_fss_payload_read), + fll_error_file_flag_fallback_e, + fss_read_file_identify(main->setting.range.start, main->setting.files), + f_file_operation_process_s, + fll_error_file_type_file_e + ); return; } - // Reset all of the used data before starting the loop. - main->setting.object->used = 0; - main->setting.contents->used = 0; - - for (;;) { - - if (fss_read_signal_check(main)) return; - - if (range.start > range.stop) { - if (status_pipe == F_none_eof) break; - - main->setting.block.used = 0; - - status_pipe = f_file_read_block(input, &main->setting.block); - - if (F_status_is_error(status_pipe)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_file_read_block)); - - status_pipe = F_status_set_error(F_pipe); - - break; - } - - if (!main->setting.block.used) break; - - range.start = 0; - range.stop = main->setting.block.used - 1; - status_pipe = F_none; - } - - // Start Object. - if (!state || state == 0x1) { - if (!state) { - main->setting.object->used = 0; - - state = 0x1; - } - - // Reset the "has Content for Object" flag and associated contents array used length. - flag -= flag | 0x4; - main->setting.contents->used = 0; - - main->setting.state.status = f_string_dynamic_increase_by(main->setting.block.used, main->setting.object); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); - - break; - } - - for (; range.start <= range.stop && range.start < main->setting.block.used; ++range.start) { - - // Do not handle start/end while inside an ignore set. - if (!(flag & 0x2)) { - if (main->setting.block.string[range.start] == fss_read_pipe_content_start_s.string[0]) { - state = 0x2; - ++range.start; - - break; - } - - if (main->setting.block.string[range.start] == fss_read_pipe_content_end_s.string[0]) { - state = 0x3; - ++range.start; - - break; - } - } - - // There currently is no support for "ignore" in Objects, but the Ignore should still be processed. - if (main->setting.block.string[range.start] == fss_read_pipe_content_ignore_s.string[0]) { - - // Ignore is enabled. - if (flag & 0x2) { - flag -= 0x2; - } - else { - flag |= 0x2; - } - - continue; - } - - main->setting.object->string[main->setting.object->used++] = main->setting.block.string[range.start]; - } // for - - if (F_status_is_error(main->setting.state.status)) break; - - // If the start of Content was not found, then fetch the next block. - if (state == 0x1) continue; - - // If the end of the current block is reached, fetch the next block. - if (range.start > range.stop) continue; - } - - // Begin Content. - if (state == 0x2) { - - // Check to see if the Content supports multiple Content per Object. - if (flag & 0x4) { - if (!(main->setting.flag & fss_read_main_flag_content_multiple_e)) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_one_content_only(&main->program.error); - - break; - } - - main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); - - break; - } - } - - if (range.start <= range.stop) { - total = (range.stop - range.start) + 1; - } - else { - total = 0; - } - - // When payload is provided, all data at this point is part of the payload until the end of the pipe. - if (f_compare_dynamic(f_fss_payload_s, *main->setting.object) == F_equal_to) { - if (total > 1) { - main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); - - break; - } - - memcpy(main->setting.contents->array[main->setting.contents->used].string, main->setting.block.string + range.start, sizeof(f_char_t) * total); - - main->setting.contents->array[main->setting.contents->used].used += total; - } - - state = 0x4; - flag |= 0x8; - - // Designate to read next block from pipe. - range.start = 1; - range.stop = 0; - - continue; - } - - if (total) { - main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); - - break; - } - - for (; range.start <= range.stop && range.start < main->setting.block.used; ++range.start) { - - // Do not handle start/end while inside an ignore set. - if (!(flag & 0x2)) { - if (main->setting.block.string[range.start] == fss_read_pipe_content_start_s.string[0]) { - main->setting.state.status = F_status_set_error(F_support_not); - - fss_read_print_error_one_content_only(&main->program.error); - - break; - } - - if (main->setting.block.string[range.start] == fss_read_pipe_content_end_s.string[0]) { - state = 0x3; - ++range.start; - - break; - } - } - - // There currently is no support for "ignore" in Contents, but the Ignore should still be processed. - if (main->setting.block.string[range.start] == fss_read_pipe_content_ignore_s.string[0]) { - - // Ignore is enabled. - if (flag & 0x2) { - flag -= 0x2; - } - else { - flag |= 0x2; - } - - continue; - } - - main->setting.contents->array[main->setting.contents->used].string[main->setting.contents->array[main->setting.contents->used].used++] = main->setting.block.string[range.start]; - } // for + if (main->setting.state.status == F_data_not_stop || main->setting.state.status == F_data_not_eos) { + if (!(main->setting.flag & fss_read_main_flag_total_e)) { + main->setting.state.status = F_status_set_warning(main->setting.state.status); - if (F_status_is_error(main->setting.state.status)) break; - - ++main->setting.contents->used; - flag |= 0x4; - } - else { - state = 0x3; - } - } - - // End Object or Content set. - if (state == 0x3) { - fss_read_payload_process_set(void_main); - if (F_status_is_error(main->setting.state.status)) break; - - state = 0; - flag |= 0x1; - - // Reset all of the used data for next set. - main->setting.object->used = 0; - main->setting.contents->used = 0; - - continue; - } - - // Payload Object. - if (state == 0x4) { - if (main->setting.block.used && range.start <= range.stop) { - length = (range.stop - range.start) + 1; - - main->setting.state.status = f_string_dynamic_increase_by(length + 1, &main->setting.contents->array[main->setting.contents->used]); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); - - break; - } - - memcpy(main->setting.contents->array[main->setting.contents->used].string + range.start, main->setting.block.string, sizeof(f_char_t) * length); - - main->setting.contents->array[main->setting.contents->used].used += length; - } - - // Designate to read next block from pipe. - range.start = 1; - range.stop = 0; - - // Reset all of the used data for next set. - main->setting.object->used = 0; - main->setting.contents->used = 0; + return; } - } // for - - // 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) { - fss_read_payload_process_set(void_main); - - flag |= 0x1; } - main->setting.block.used = 0; - main->setting.buffer.used = 0; - main->setting.object->used = 0; - main->setting.contents->used = 0; - main->setting.objects.used = used_objects; - main->setting.contentss.used = used_contents; - - if (F_status_is_error_not(main->setting.state.status)) { - if (flag & 0x1) { - if (flag & 0x8) { - main->setting.state.status = F_payload; - } - else { - main->setting.state.status = F_none; - } - } - else { - main->setting.state.status = F_data_not; - } - - // Payload. - if (main->setting.contentss.used && (flag & 0x8)) { - fll_print_dynamic(f_fss_payload_header_close_s, main->program.output.to); - } - } + main->setting.state.status = F_none; } -#endif // _di_fss_read_payload_process_pipe_ +#endif // _di_fss_read_payload_process_load_ #ifndef _di_fss_read_payload_process_set_ void fss_read_payload_process_set(void * const void_main) { @@ -362,154 +74,6 @@ extern "C" { fss_read_main_t * const main = (fss_read_main_t *) void_main; - if ((!(main->setting.flag & fss_read_main_flag_partial_e) || (main->setting.flag & fss_read_main_flag_partial_e) && (main->setting.flag & fss_read_main_flag_object_e))) { - if (main->setting.object && !(main->setting.flag & fss_read_main_flag_partial_e) && main->setting.contents && main->setting.contents->used) { - if (main->setting.object->used) { - main->setting.range.start = 0; - main->setting.range.stop = main->setting.object->used - 1; - } - else { - main->setting.range.start = 1; - main->setting.range.stop = 0; - } - - fll_fss_payload_write( - *main->setting.object, - main->setting.contents->array[0], - (main->setting.flag & fss_read_main_flag_trim_e), - (main->setting.flag & fss_read_main_flag_prepend_e) - ? &main->setting.prepend - : 0, - &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(fll_fss_payload_write)); - - return; - } - } - else { - if (main->setting.object) { - if (main->setting.object->used) { - main->setting.range.start = 0; - main->setting.range.stop = main->setting.object->used - 1; - } - else { - main->setting.range.start = 1; - main->setting.range.stop = 0; - } - - 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)); - - return; - } - } - } - } - } - else { - if (main->setting.contents && main->setting.contents->used && main->setting.contents->array[0].used) { - main->setting.range.start = 0; - main->setting.range.stop = main->setting.contents->array[0].used - 1; - - const f_string_static_t *prepend = 0; - - if (main->setting.flag & fss_read_main_flag_prepend_e) { - const f_array_length_t index = main->program.parameters.array[fss_read_parameter_prepend_e].values.array[main->program.parameters.array[fss_read_parameter_prepend_e].location]]; - - prepend = &main->program.parameters.arguments.array[index]; - } - - fl_fss_basic_list_content_write( - main->setting.contents->array[0], - main->setting.object - ? f_fss_complete_full_e - : f_fss_complete_none_e, - prepend, - &main->setting.range, - &main->setting.buffer, - &main->setting.state - ); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_payload_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))) { - 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)); - - return; - } - } - } - - if (!main->setting.object || !(main->setting.contents && main->setting.contents->used)) { - main->setting.state.status = f_string_dynamic_append(f_string_eol_s, &main->setting.buffer); - - if (F_status_is_error(main->setting.state.status)) { - fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); - - return; - } - } - - fll_print_dynamic(main->setting.buffer, main->program.output.to); - - main->setting.buffer.used = 0; main->setting.state.status = F_none; } #endif // _di_fss_read_payload_process_set_ @@ -525,6 +89,8 @@ extern "C" { if ((main->program.parameters.array[fss_read_parameter_object_e].result & f_console_result_value_e) && values->used) { for (f_array_length_t i = 0; i < values->used; ++i) { + if (fss_read_signal_check(main)) return; + if (f_compare_dynamic(argv[values->array[i]], fss_read_payload_s) == F_equal_to && i + 1 < values->used) { main->setting.state.status = F_status_set_error(F_parameter); diff --git a/level_3/fss_read/c/payload/fss_read.h b/level_3/fss_read/c/payload/fss_read.h index b68c29b..1d71748 100644 --- a/level_3/fss_read/c/payload/fss_read.h +++ b/level_3/fss_read/c/payload/fss_read.h @@ -86,7 +86,9 @@ extern "C" { #endif // _di_fss_read_payload_process_help_ /** - * Process the pipe, reading from the pipe and writing to the output. + * Process the buffer, loading the FSS data. + * + * This will print an error message on error. * * @param main * The program and settings data. @@ -96,19 +98,19 @@ extern "C" { * * This alters main.setting.state.status: * F_none on success. - * F_data_not on success but pipe contained no relevant data. - * F_payload on success and the payload has been printed. - * F_interrupt on (exit) signal received. * - * F_parameter (with error bit) if main is NULL or setting is NULL. + * 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: fss_read_signal_check(). + * Errors (with error bit) from: fll_fss_payload_read() * - * @see fss_read_signal_check() + * @see fll_fss_payload_read() + * + * @see fss_read_file_identify() */ -#ifndef _di_fss_read_payload_process_pipe_ - extern void fss_read_payload_process_pipe(void * const main); -#endif // _di_fss_read_payload_process_pipe_ +#ifndef _di_fss_read_payload_process_load_ + extern void fss_read_payload_process_load(void * const main); +#endif // _di_fss_read_payload_process_load_ /** * Process a given object and content, printing the FSS if valid or an error if invalid. @@ -143,11 +145,8 @@ extern "C" { * @param setting * The main program settings. * - * This alters setting.process_help, setting.process_normal, and setting.process_pipe. - * * This alters setting.state.status: * F_none on success. - * F_interrupt on (exit) signal received. * * F_parameter (with error bit) if main is NULL or setting is NULL. * F_parameter (with error bit) on parameter error. @@ -157,6 +156,7 @@ extern "C" { * F_data_not on success but nothing was provided to operate with. * * @see fss_read_setting_load() + * @see fss_read_signal_check() */ #ifndef _di_fss_read_payload_setting_load_ extern void fss_read_payload_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main); diff --git a/level_3/fss_read/c/payload/main.c b/level_3/fss_read/c/payload/main.c index c967562..5ee4ae4 100644 --- a/level_3/fss_read/c/payload/main.c +++ b/level_3/fss_read/c/payload/main.c @@ -10,34 +10,36 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_read_print_flag_out_e; data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; + data.setting.flag |= fss_read_main_flag_trim_object_e; + data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_payload_standard_s; - 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_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; + 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_payload_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 ffd9c10..2b5ccca 100644 --- a/level_3/fss_read/c/payload/print.c +++ b/level_3/fss_read/c/payload/print.c @@ -41,11 +41,13 @@ extern "C" { // //The Content of the explicit Object of 'payload' will not contain any Content close pipe control codes when using --pipe. + /* fl_print_format("%r The FSS-000E (Payload) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_single_s, print->set->notable); fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_ignore_s, print->set->notable, f_string_eol_s); fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + */ f_file_stream_flush(print->to); f_file_stream_unlock(print->to); diff --git a/level_3/fss_write/c/main/main.c b/level_3/fss_write/c/main/main.c index f9e2d5b..78f5d98 100644 --- a/level_3/fss_write/c/main/main.c +++ b/level_3/fss_write/c/main/main.c @@ -17,6 +17,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_write_print_flag_out_e; data.program.message.flag |= fss_write_print_flag_message_e | fss_write_print_flag_out_e; data.program.warning.flag |= fss_write_print_flag_warning_e | fss_write_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; @@ -120,8 +121,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_basic_standard_s; - 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. + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; + main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; main->callback.process_content = &fss_write_basic_process_content; main->callback.process_help = &fss_write_basic_process_help; @@ -137,7 +139,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_extended_standard_s; - main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; // Not supported by extended. + // Remove flags not supported for this standard. + main->setting.flag -= 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_extended_process_content; @@ -154,8 +158,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_basic_list_standard_s; - 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. + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; + main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; main->callback.process_content = &fss_write_basic_list_process_content; main->callback.process_help = &fss_write_basic_list_process_help; @@ -171,8 +176,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_extended_list_standard_s; + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; + 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; @@ -205,8 +212,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_payload_standard_s; - 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. + // Remove flags not supported for this standard. + main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; + main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; main->callback.process_content = 0; main->callback.process_help = &fss_write_payload_process_help; diff --git a/level_3/fss_write/c/payload/main.c b/level_3/fss_write/c/payload/main.c index 9e2bd11..06b01cb 100644 --- a/level_3/fss_write/c/payload/main.c +++ b/level_3/fss_write/c/payload/main.c @@ -10,6 +10,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.flag |= fss_write_print_flag_out_e; data.program.message.flag |= fss_write_print_flag_message_e | fss_write_print_flag_out_e; data.program.warning.flag |= fss_write_print_flag_warning_e | fss_write_print_flag_out_e; + data.program.error.custom = (void *) &data; data.program.debug.custom = (void *) &data; data.program.message.custom = (void *) &data; -- 1.8.3.1