From ddca149de52bdf00d2e87925f7ea1e166b884670 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 15 Jun 2023 22:13:17 -0500 Subject: [PATCH] Cleanup: Remove no longer needed programs. The fss_read is mostly complete for these programs. Additional review and testing is needed but I can do that slowly over time. The runtime unit tests suggests that these are reasonably complete. The Embedded List Read is not deleted because it is not complete. There are bugs in both the 0.6.x and the 0.7.x versions. A rewrite of that mess is needed (and has been for a long time). I will push this off for now due to it being low priority. --- level_3/fss_basic_list_read/c/common.c | 199 ---- level_3/fss_basic_list_read/c/common.h | 435 ------- .../fss_basic_list_read/c/fss_basic_list_read.c | 555 --------- .../fss_basic_list_read/c/fss_basic_list_read.h | 88 -- level_3/fss_basic_list_read/c/main.c | 44 - level_3/fss_basic_list_read/c/main.h | 38 - level_3/fss_basic_list_read/c/print.c | 116 -- level_3/fss_basic_list_read/c/print.h | 36 - level_3/fss_basic_list_read/c/private-common.c | 61 - level_3/fss_basic_list_read/c/private-common.h | 268 ----- level_3/fss_basic_list_read/c/private-print.c | 119 -- level_3/fss_basic_list_read/c/private-print.h | 107 -- level_3/fss_basic_list_read/c/private-read.c | 806 ------------- level_3/fss_basic_list_read/c/private-read.h | 317 ----- level_3/fss_basic_list_read/data/build/defines | 6 - .../fss_basic_list_read/data/build/dependencies | 31 - level_3/fss_basic_list_read/data/build/fakefile | 27 - level_3/fss_basic_list_read/data/build/settings | 85 -- .../documentation/man/man1/fss_basic_list_read.1 | 145 --- level_3/fss_basic_read/c/common.c | 198 ---- level_3/fss_basic_read/c/common.h | 433 ------- level_3/fss_basic_read/c/fss_basic_read.c | 560 --------- level_3/fss_basic_read/c/fss_basic_read.h | 91 -- level_3/fss_basic_read/c/main.c | 44 - level_3/fss_basic_read/c/main.h | 38 - level_3/fss_basic_read/c/print.c | 116 -- level_3/fss_basic_read/c/print.h | 36 - level_3/fss_basic_read/c/private-common.c | 60 - level_3/fss_basic_read/c/private-common.h | 263 ----- level_3/fss_basic_read/c/private-print.c | 144 --- level_3/fss_basic_read/c/private-print.h | 79 -- level_3/fss_basic_read/c/private-read.c | 683 ----------- level_3/fss_basic_read/c/private-read.h | 274 ----- level_3/fss_basic_read/data/build/defines | 6 - level_3/fss_basic_read/data/build/dependencies | 31 - level_3/fss_basic_read/data/build/fakefile | 27 - level_3/fss_basic_read/data/build/settings | 85 -- .../data/documentation/man/man1/fss_basic_read.1 | 145 --- level_3/fss_extended_list_read/c/common.c | 205 ---- level_3/fss_extended_list_read/c/common.h | 450 -------- .../c/fss_extended_list_read.c | 560 --------- .../c/fss_extended_list_read.h | 91 -- level_3/fss_extended_list_read/c/main.c | 44 - level_3/fss_extended_list_read/c/main.h | 38 - level_3/fss_extended_list_read/c/print.c | 116 -- level_3/fss_extended_list_read/c/print.h | 36 - level_3/fss_extended_list_read/c/private-common.c | 61 - level_3/fss_extended_list_read/c/private-common.h | 269 ----- level_3/fss_extended_list_read/c/private-print.c | 129 --- level_3/fss_extended_list_read/c/private-print.h | 111 -- level_3/fss_extended_list_read/c/private-read.c | 787 ------------- level_3/fss_extended_list_read/c/private-read.h | 313 ----- level_3/fss_extended_list_read/data/build/defines | 6 - .../fss_extended_list_read/data/build/dependencies | 31 - level_3/fss_extended_list_read/data/build/fakefile | 27 - level_3/fss_extended_list_read/data/build/settings | 76 -- .../man/man1/fss_extended_list_read.1 | 145 --- level_3/fss_extended_read/c/common.c | 198 ---- level_3/fss_extended_read/c/common.h | 432 ------- level_3/fss_extended_read/c/fss_extended_read.c | 559 --------- level_3/fss_extended_read/c/fss_extended_read.h | 88 -- level_3/fss_extended_read/c/main.c | 44 - level_3/fss_extended_read/c/main.h | 38 - level_3/fss_extended_read/c/print.c | 116 -- level_3/fss_extended_read/c/print.h | 36 - level_3/fss_extended_read/c/private-common.c | 62 - level_3/fss_extended_read/c/private-common.h | 268 ----- level_3/fss_extended_read/c/private-print.c | 265 ----- level_3/fss_extended_read/c/private-print.h | 107 -- level_3/fss_extended_read/c/private-read.c | 738 ------------ level_3/fss_extended_read/c/private-read.h | 288 ----- level_3/fss_extended_read/data/build/defines | 6 - level_3/fss_extended_read/data/build/dependencies | 31 - level_3/fss_extended_read/data/build/fakefile | 27 - level_3/fss_extended_read/data/build/settings | 85 -- .../documentation/man/man1/fss_extended_read.1 | 145 --- level_3/fss_payload_read/c/common.c | 199 ---- level_3/fss_payload_read/c/common.h | 430 ------- level_3/fss_payload_read/c/fss_payload_read.c | 580 ---------- level_3/fss_payload_read/c/fss_payload_read.h | 89 -- level_3/fss_payload_read/c/main.c | 44 - level_3/fss_payload_read/c/main.h | 38 - level_3/fss_payload_read/c/print.c | 126 -- level_3/fss_payload_read/c/print.h | 36 - level_3/fss_payload_read/c/private-common.c | 67 -- level_3/fss_payload_read/c/private-common.h | 288 ----- level_3/fss_payload_read/c/private-print.c | 368 ------ level_3/fss_payload_read/c/private-print.h | 177 --- level_3/fss_payload_read/c/private-read.c | 1213 -------------------- level_3/fss_payload_read/c/private-read.h | 409 ------- level_3/fss_payload_read/data/build/defines | 6 - level_3/fss_payload_read/data/build/dependencies | 31 - level_3/fss_payload_read/data/build/fakefile | 27 - level_3/fss_payload_read/data/build/settings | 85 -- .../data/documentation/man/man1/fss_payload_read.1 | 150 --- 95 files changed, 18187 deletions(-) delete mode 100644 level_3/fss_basic_list_read/c/common.c delete mode 100644 level_3/fss_basic_list_read/c/common.h delete mode 100644 level_3/fss_basic_list_read/c/fss_basic_list_read.c delete mode 100644 level_3/fss_basic_list_read/c/fss_basic_list_read.h delete mode 100644 level_3/fss_basic_list_read/c/main.c delete mode 100644 level_3/fss_basic_list_read/c/main.h delete mode 100644 level_3/fss_basic_list_read/c/print.c delete mode 100644 level_3/fss_basic_list_read/c/print.h delete mode 100644 level_3/fss_basic_list_read/c/private-common.c delete mode 100644 level_3/fss_basic_list_read/c/private-common.h delete mode 100644 level_3/fss_basic_list_read/c/private-print.c delete mode 100644 level_3/fss_basic_list_read/c/private-print.h delete mode 100644 level_3/fss_basic_list_read/c/private-read.c delete mode 100644 level_3/fss_basic_list_read/c/private-read.h delete mode 100644 level_3/fss_basic_list_read/data/build/defines delete mode 100644 level_3/fss_basic_list_read/data/build/dependencies delete mode 100644 level_3/fss_basic_list_read/data/build/fakefile delete mode 100644 level_3/fss_basic_list_read/data/build/settings delete mode 100644 level_3/fss_basic_list_read/data/documentation/man/man1/fss_basic_list_read.1 delete mode 100644 level_3/fss_basic_read/c/common.c delete mode 100644 level_3/fss_basic_read/c/common.h delete mode 100644 level_3/fss_basic_read/c/fss_basic_read.c delete mode 100644 level_3/fss_basic_read/c/fss_basic_read.h delete mode 100644 level_3/fss_basic_read/c/main.c delete mode 100644 level_3/fss_basic_read/c/main.h delete mode 100644 level_3/fss_basic_read/c/print.c delete mode 100644 level_3/fss_basic_read/c/print.h delete mode 100644 level_3/fss_basic_read/c/private-common.c delete mode 100644 level_3/fss_basic_read/c/private-common.h delete mode 100644 level_3/fss_basic_read/c/private-print.c delete mode 100644 level_3/fss_basic_read/c/private-print.h delete mode 100644 level_3/fss_basic_read/c/private-read.c delete mode 100644 level_3/fss_basic_read/c/private-read.h delete mode 100644 level_3/fss_basic_read/data/build/defines delete mode 100644 level_3/fss_basic_read/data/build/dependencies delete mode 100644 level_3/fss_basic_read/data/build/fakefile delete mode 100644 level_3/fss_basic_read/data/build/settings delete mode 100644 level_3/fss_basic_read/data/documentation/man/man1/fss_basic_read.1 delete mode 100644 level_3/fss_extended_list_read/c/common.c delete mode 100644 level_3/fss_extended_list_read/c/common.h delete mode 100644 level_3/fss_extended_list_read/c/fss_extended_list_read.c delete mode 100644 level_3/fss_extended_list_read/c/fss_extended_list_read.h delete mode 100644 level_3/fss_extended_list_read/c/main.c delete mode 100644 level_3/fss_extended_list_read/c/main.h delete mode 100644 level_3/fss_extended_list_read/c/print.c delete mode 100644 level_3/fss_extended_list_read/c/print.h delete mode 100644 level_3/fss_extended_list_read/c/private-common.c delete mode 100644 level_3/fss_extended_list_read/c/private-common.h delete mode 100644 level_3/fss_extended_list_read/c/private-print.c delete mode 100644 level_3/fss_extended_list_read/c/private-print.h delete mode 100644 level_3/fss_extended_list_read/c/private-read.c delete mode 100644 level_3/fss_extended_list_read/c/private-read.h delete mode 100644 level_3/fss_extended_list_read/data/build/defines delete mode 100644 level_3/fss_extended_list_read/data/build/dependencies delete mode 100644 level_3/fss_extended_list_read/data/build/fakefile delete mode 100644 level_3/fss_extended_list_read/data/build/settings delete mode 100644 level_3/fss_extended_list_read/data/documentation/man/man1/fss_extended_list_read.1 delete mode 100644 level_3/fss_extended_read/c/common.c delete mode 100644 level_3/fss_extended_read/c/common.h delete mode 100644 level_3/fss_extended_read/c/fss_extended_read.c delete mode 100644 level_3/fss_extended_read/c/fss_extended_read.h delete mode 100644 level_3/fss_extended_read/c/main.c delete mode 100644 level_3/fss_extended_read/c/main.h delete mode 100644 level_3/fss_extended_read/c/print.c delete mode 100644 level_3/fss_extended_read/c/print.h delete mode 100644 level_3/fss_extended_read/c/private-common.c delete mode 100644 level_3/fss_extended_read/c/private-common.h delete mode 100644 level_3/fss_extended_read/c/private-print.c delete mode 100644 level_3/fss_extended_read/c/private-print.h delete mode 100644 level_3/fss_extended_read/c/private-read.c delete mode 100644 level_3/fss_extended_read/c/private-read.h delete mode 100644 level_3/fss_extended_read/data/build/defines delete mode 100644 level_3/fss_extended_read/data/build/dependencies delete mode 100644 level_3/fss_extended_read/data/build/fakefile delete mode 100644 level_3/fss_extended_read/data/build/settings delete mode 100644 level_3/fss_extended_read/data/documentation/man/man1/fss_extended_read.1 delete mode 100644 level_3/fss_payload_read/c/common.c delete mode 100644 level_3/fss_payload_read/c/common.h delete mode 100644 level_3/fss_payload_read/c/fss_payload_read.c delete mode 100644 level_3/fss_payload_read/c/fss_payload_read.h delete mode 100644 level_3/fss_payload_read/c/main.c delete mode 100644 level_3/fss_payload_read/c/main.h delete mode 100644 level_3/fss_payload_read/c/print.c delete mode 100644 level_3/fss_payload_read/c/print.h delete mode 100644 level_3/fss_payload_read/c/private-common.c delete mode 100644 level_3/fss_payload_read/c/private-common.h delete mode 100644 level_3/fss_payload_read/c/private-print.c delete mode 100644 level_3/fss_payload_read/c/private-print.h delete mode 100644 level_3/fss_payload_read/c/private-read.c delete mode 100644 level_3/fss_payload_read/c/private-read.h delete mode 100644 level_3/fss_payload_read/data/build/defines delete mode 100644 level_3/fss_payload_read/data/build/dependencies delete mode 100644 level_3/fss_payload_read/data/build/fakefile delete mode 100644 level_3/fss_payload_read/data/build/settings delete mode 100644 level_3/fss_payload_read/data/documentation/man/man1/fss_payload_read.1 diff --git a/level_3/fss_basic_list_read/c/common.c b/level_3/fss_basic_list_read/c/common.c deleted file mode 100644 index 5bca369..0000000 --- a/level_3/fss_basic_list_read/c/common.c +++ /dev/null @@ -1,199 +0,0 @@ -#include "fss_basic_list_read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_list_read_program_version_s_ - const f_string_static_t fss_basic_list_read_program_version_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_program_version_s, 0, FSS_BASIC_LIST_READ_program_version_s_length); -#endif // _di_fss_basic_list_read_program_version_s_ - -#ifndef _di_fss_basic_list_read_program_name_s_ - const f_string_static_t fss_basic_list_read_program_name_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_program_name_s, 0, FSS_BASIC_LIST_READ_program_name_s_length); - const f_string_static_t fss_basic_list_read_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_program_name_long_s, 0, FSS_BASIC_LIST_READ_program_name_long_s_length); -#endif // _di_fss_basic_list_read_program_name_s_ - -#ifndef _di_fss_basic_list_read_pipe_s_ - const f_string_static_t fss_basic_list_read_pipe_name_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_pipe_name_s, 0, FSS_BASIC_LIST_READ_pipe_name_s_length); - - const f_string_static_t fss_basic_list_read_pipe_content_end_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_pipe_content_end_s, 0, FSS_BASIC_LIST_READ_pipe_content_end_s_length); - const f_string_static_t fss_basic_list_read_pipe_content_ignore_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_pipe_content_ignore_s, 0, FSS_BASIC_LIST_READ_pipe_content_ignore_s_length); - const f_string_static_t fss_basic_list_read_pipe_content_start_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_pipe_content_start_s, 0, FSS_BASIC_LIST_READ_pipe_content_start_s_length); -#endif // _di_fss_basic_list_read_pipe_s_ - -#ifndef _di_fss_basic_list_read_parameter_d_ - const f_string_static_t fss_basic_list_read_short_at_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_at_s, 0, FSS_BASIC_LIST_READ_short_at_s_length); - const f_string_static_t fss_basic_list_read_short_content_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_content_s, 0, FSS_BASIC_LIST_READ_short_content_s_length); - const f_string_static_t fss_basic_list_read_short_columns_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_columns_s, 0, FSS_BASIC_LIST_READ_short_columns_s_length); - const f_string_static_t fss_basic_list_read_short_delimit_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_delimit_s, 0, FSS_BASIC_LIST_READ_short_delimit_s_length); - const f_string_static_t fss_basic_list_read_short_depth_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_depth_s, 0, FSS_BASIC_LIST_READ_short_depth_s_length); - const f_string_static_t fss_basic_list_read_short_empty_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_empty_s, 0, FSS_BASIC_LIST_READ_short_empty_s_length); - const f_string_static_t fss_basic_list_read_short_line_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_line_s, 0, FSS_BASIC_LIST_READ_short_line_s_length); - const f_string_static_t fss_basic_list_read_short_name_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_name_s, 0, FSS_BASIC_LIST_READ_short_name_s_length); - const f_string_static_t fss_basic_list_read_short_object_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_object_s, 0, FSS_BASIC_LIST_READ_short_object_s_length); - const f_string_static_t fss_basic_list_read_short_pipe_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_pipe_s, 0, FSS_BASIC_LIST_READ_short_pipe_s_length); - const f_string_static_t fss_basic_list_read_short_original_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_original_s, 0, FSS_BASIC_LIST_READ_short_original_s_length); - const f_string_static_t fss_basic_list_read_short_select_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_select_s, 0, FSS_BASIC_LIST_READ_short_select_s_length); - const f_string_static_t fss_basic_list_read_short_total_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_total_s, 0, FSS_BASIC_LIST_READ_short_total_s_length); - const f_string_static_t fss_basic_list_read_short_trim_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_short_trim_s, 0, FSS_BASIC_LIST_READ_short_trim_s_length); - - const f_string_static_t fss_basic_list_read_long_at_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_at_s, 0, FSS_BASIC_LIST_READ_long_at_s_length); - const f_string_static_t fss_basic_list_read_long_content_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_content_s, 0, FSS_BASIC_LIST_READ_long_content_s_length); - const f_string_static_t fss_basic_list_read_long_columns_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_columns_s, 0, FSS_BASIC_LIST_READ_long_columns_s_length); - const f_string_static_t fss_basic_list_read_long_delimit_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_delimit_s, 0, FSS_BASIC_LIST_READ_long_delimit_s_length); - const f_string_static_t fss_basic_list_read_long_depth_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_depth_s, 0, FSS_BASIC_LIST_READ_long_depth_s_length); - const f_string_static_t fss_basic_list_read_long_empty_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_empty_s, 0, FSS_BASIC_LIST_READ_long_empty_s_length); - const f_string_static_t fss_basic_list_read_long_line_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_line_s, 0, FSS_BASIC_LIST_READ_long_line_s_length); - const f_string_static_t fss_basic_list_read_long_name_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_name_s, 0, FSS_BASIC_LIST_READ_long_name_s_length); - const f_string_static_t fss_basic_list_read_long_object_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_object_s, 0, FSS_BASIC_LIST_READ_long_object_s_length); - const f_string_static_t fss_basic_list_read_long_pipe_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_pipe_s, 0, FSS_BASIC_LIST_READ_long_pipe_s_length); - const f_string_static_t fss_basic_list_read_long_original_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_original_s, 0, FSS_BASIC_LIST_READ_long_original_s_length); - const f_string_static_t fss_basic_list_read_long_select_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_select_s, 0, FSS_BASIC_LIST_READ_long_select_s_length); - const f_string_static_t fss_basic_list_read_long_total_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_total_s, 0, FSS_BASIC_LIST_READ_long_total_s_length); - const f_string_static_t fss_basic_list_read_long_trim_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_long_trim_s, 0, FSS_BASIC_LIST_READ_long_trim_s_length); -#endif // _di_fss_basic_list_read_parameter_d_ - -#ifndef _di_fss_basic_list_read_delimit_mode_s_ - const f_string_static_t fss_basic_list_read_delimit_mode_name_none_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_delimit_mode_name_none_s, 0, FSS_BASIC_LIST_READ_delimit_mode_name_none_s_length); - const f_string_static_t fss_basic_list_read_delimit_mode_name_all_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_delimit_mode_name_all_s, 0, FSS_BASIC_LIST_READ_delimit_mode_name_all_s_length); - const f_string_static_t fss_basic_list_read_delimit_mode_name_object_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_delimit_mode_name_object_s, 0, FSS_BASIC_LIST_READ_delimit_mode_name_object_s_length); - const f_string_static_t fss_basic_list_read_delimit_mode_name_greater_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_delimit_mode_name_greater_s, 0, FSS_BASIC_LIST_READ_delimit_mode_name_greater_s_length); - const f_string_static_t fss_basic_list_read_delimit_mode_name_lesser_s = macro_f_string_static_t_initialize_1(FSS_BASIC_LIST_READ_delimit_mode_name_lesser_s, 0, FSS_BASIC_LIST_READ_delimit_mode_name_lesser_s_length); -#endif // _di_fss_basic_list_read_delimit_mode_s_ - -#ifndef _di_fss_basic_list_read_setting_delete_ - f_status_t fss_basic_list_read_setting_delete(fss_basic_list_read_setting_t * const setting) { - - if (!setting) return F_status_set_error(F_parameter); - - return F_none; - } -#endif // _di_fss_basic_list_read_setting_delete_ - -#ifndef _di_fss_basic_list_read_setting_load_ - void fss_basic_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting) { - - if (!main) return; - - main->setting.state.step_small = fss_basic_list_read_allocation_console_d; - - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - - main->setting.state.step_small = fss_basic_list_read_allocation_small_d; - - // Identify and pocess first/last parameters. - if (main->program.parameters.array[fss_basic_list_read_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_basic_list_read_main_flag_print_first_e; - } - else { - main->setting.flag |= fss_basic_list_read_main_flag_print_first_e; - } - - if (main->program.parameters.array[fss_basic_list_read_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_basic_list_read_main_flag_print_last_e; - } - else { - main->setting.flag |= fss_basic_list_read_main_flag_print_last_e; - } - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_basic_list_read_parameter_no_color_e, fss_basic_list_read_parameter_light_e, fss_basic_list_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_basic_list_read_parameter_verbosity_quiet_e, fss_basic_list_read_parameter_verbosity_error_e, fss_basic_list_read_parameter_verbosity_verbose_e, fss_basic_list_read_parameter_verbosity_debug_e, fss_basic_list_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - static const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - } - - main->program.output.to.id = F_type_descriptor_output_d; - main->program.output.to.stream = F_type_output_d; - main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - - if (main->program.parameters.array[fss_basic_list_read_parameter_help_e].result & f_console_result_found_e) { - main->setting.flag |= fss_basic_list_read_main_flag_help_e; - - return; - } - - if (main->program.parameters.array[fss_basic_list_read_parameter_version_e].result & f_console_result_found_e) { - main->setting.flag |= fss_basic_list_read_main_flag_version_e; - - return; - } - - if (main->program.parameters.array[fss_basic_list_read_parameter_copyright_e].result & f_console_result_found_e) { - main->setting.flag |= fss_basic_list_read_main_flag_copyright_e; - - return; - } - - f_string_static_t * const args = main->program.parameters.arguments.array; - - if (main->program.parameters.array[fss_basic_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - main->setting.flag |= fss_basic_list_read_main_flag_strip_invalid_e; - } - } -#endif // _di_fss_basic_list_read_setting_load_ - -#ifndef _di_fss_basic_list_read_setting_unload_ - f_status_t fss_basic_list_read_setting_unload(fss_basic_list_read_main_t * const main) { - - if (!main) return F_status_set_error(F_parameter); - - fss_basic_list_read_setting_delete(&main->setting); - - return F_none; - } -#endif // _di_fss_basic_list_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_list_read/c/common.h b/level_3/fss_basic_list_read/c/common.h deleted file mode 100644 index 14a7272..0000000 --- a/level_3/fss_basic_list_read/c/common.h +++ /dev/null @@ -1,435 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic List Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the common data structures. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _fss_basic_list_read_common_h -#define _fss_basic_list_read_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The program version. - */ -#ifndef _di_fss_basic_list_read_program_version_s_ - #define FSS_BASIC_LIST_READ_program_version_major_s F_string_ascii_0_s - #define FSS_BASIC_LIST_READ_program_version_minor_s F_string_ascii_7_s - #define FSS_BASIC_LIST_READ_program_version_micro_s F_string_ascii_0_s - - #define FSS_BASIC_LIST_READ_program_version_major_s_length F_string_ascii_0_s_length - #define FSS_BASIC_LIST_READ_program_version_minor_s_length F_string_ascii_7_s_length - #define FSS_BASIC_LIST_READ_program_version_micro_s_length F_string_ascii_0_s_length - - #if !(defined(FSS_BASIC_LIST_READ_program_version_nano_prefix_s) && defined(FSS_BASIC_LIST_READ_program_version_nano_prefix_s_length)) - #define FSS_BASIC_LIST_READ_program_version_nano_prefix_s - #define FSS_BASIC_LIST_READ_program_version_nano_prefix_s_length 0 - #endif // !(defined(FSS_BASIC_LIST_READ_program_version_nano_prefix_s) && defined(FSS_BASIC_LIST_READ_program_version_nano_prefix_s_length)) - - #if !(defined(FSS_BASIC_LIST_READ_program_version_nano_s) && defined(FSS_BASIC_LIST_READ_program_version_nano_s_length)) - #define FSS_BASIC_LIST_READ_program_version_nano_s - #define FSS_BASIC_LIST_READ_program_version_nano_s_length 0 - #endif // !(defined(FSS_BASIC_LIST_READ_program_version_nano_s) && defined(FSS_BASIC_LIST_READ_program_version_nano_s_length)) - - #define FSS_BASIC_LIST_READ_program_version_s FSS_BASIC_LIST_READ_program_version_major_s F_string_ascii_period_s FSS_BASIC_LIST_READ_program_version_minor_s F_string_ascii_period_s FSS_BASIC_LIST_READ_program_version_micro_s FSS_BASIC_LIST_READ_program_version_nano_prefix_s FSS_BASIC_LIST_READ_program_version_nano_s - - #define FSS_BASIC_LIST_READ_program_version_s_length FSS_BASIC_LIST_READ_program_version_major_s_length + F_string_ascii_period_s_length + FSS_BASIC_LIST_READ_program_version_minor_s_length + F_string_ascii_period_s_length + FSS_BASIC_LIST_READ_program_version_micro_s_length + FSS_BASIC_LIST_READ_program_version_nano_prefix_s_length + FSS_BASIC_LIST_READ_program_version_nano_s_length - - extern const f_string_static_t fss_basic_list_read_program_version_s; -#endif // _di_fss_basic_list_read_program_version_s_ - -/** - * The program name. - */ -#ifndef _di_fss_basic_list_read_program_name_s_ - #define FSS_BASIC_LIST_READ_program_name_s "fss_basic_list_read" - #define FSS_BASIC_LIST_READ_program_name_long_s "FSS Basic List Read" - - #define FSS_BASIC_LIST_READ_program_name_s_length 19 - #define FSS_BASIC_LIST_READ_program_name_long_s_length 19 - - extern const f_string_static_t fss_basic_list_read_program_name_s; - extern const f_string_static_t fss_basic_list_read_program_name_long_s; -#endif // _di_fss_basic_list_read_program_name_s_ - -/** - * The program defines. - * - * fss_basic_list_read_*_d: - * - allocation_console: An allocation step used for small buffers specifically for console parameter. - * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. - * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. - * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. - */ -#ifndef _di_fss_basic_list_read_d_ - #define fss_basic_list_read_allocation_console_d 4 - #define fss_basic_list_read_allocation_large_d 256 - #define fss_basic_list_read_allocation_small_d 16 - #define fss_basic_list_read_signal_check_d 20000 -#endif // _di_fss_basic_list_read_d_ - -/** - * The program defines. - * - * fss_basic_list_read_pipe_*: - * - name: A name used to represent the pipe when printing file names. - * - content_end: A code used to represent the end of Content for use in binary formats. - * - content_ignore: A code used to represent the ignoring Content for use in binary formats. - * - content_start: A code used to represent the start of Content for use in binary formats. - */ -#ifndef _di_fss_basic_list_read_pipe_s_ - #define fss_basic_list_read_signal_check_d 20000 - - #define FSS_BASIC_LIST_READ_pipe_name_s "(pipe)" - - #define FSS_BASIC_LIST_READ_pipe_content_end_s "\f" - #define FSS_BASIC_LIST_READ_pipe_content_ignore_s "\v" - #define FSS_BASIC_LIST_READ_pipe_content_start_s "\b" - - #define FSS_BASIC_LIST_READ_pipe_name_s_length 6 - - #define FSS_BASIC_LIST_READ_pipe_content_end_s_length 1 - #define FSS_BASIC_LIST_READ_pipe_content_ignore_s_length 1 - #define FSS_BASIC_LIST_READ_pipe_content_start_s_length 1 - - extern const f_string_static_t fss_basic_list_read_pipe_name_s; - - extern const f_string_static_t fss_basic_list_read_pipe_content_end_s; - extern const f_string_static_t fss_basic_list_read_pipe_content_ignore_s; - extern const f_string_static_t fss_basic_list_read_pipe_content_start_s; -#endif // _di_fss_basic_list_read_pipe_s_ - -/** - * The main program parameters. - */ -#ifndef _di_fss_basic_list_read_parameter_d_ - #define FSS_BASIC_LIST_READ_short_at_s "a" - #define FSS_BASIC_LIST_READ_short_content_s "c" - #define FSS_BASIC_LIST_READ_short_columns_s "C" - #define FSS_BASIC_LIST_READ_short_delimit_s "D" - #define FSS_BASIC_LIST_READ_short_depth_s "d" - #define FSS_BASIC_LIST_READ_short_empty_s "e" - #define FSS_BASIC_LIST_READ_short_line_s "l" - #define FSS_BASIC_LIST_READ_short_name_s "n" - #define FSS_BASIC_LIST_READ_short_object_s "o" - #define FSS_BASIC_LIST_READ_short_pipe_s "p" - #define FSS_BASIC_LIST_READ_short_original_s "O" - #define FSS_BASIC_LIST_READ_short_select_s "s" - #define FSS_BASIC_LIST_READ_short_total_s "t" - #define FSS_BASIC_LIST_READ_short_trim_s "T" - - #define FSS_BASIC_LIST_READ_long_at_s "at" - #define FSS_BASIC_LIST_READ_long_content_s "content" - #define FSS_BASIC_LIST_READ_long_columns_s "columns" - #define FSS_BASIC_LIST_READ_long_delimit_s "delimit" - #define FSS_BASIC_LIST_READ_long_depth_s "depth" - #define FSS_BASIC_LIST_READ_long_empty_s "empty" - #define FSS_BASIC_LIST_READ_long_line_s "line" - #define FSS_BASIC_LIST_READ_long_name_s "name" - #define FSS_BASIC_LIST_READ_long_object_s "object" - #define FSS_BASIC_LIST_READ_long_pipe_s "pipe" - #define FSS_BASIC_LIST_READ_long_original_s "original" - #define FSS_BASIC_LIST_READ_long_select_s "select" - #define FSS_BASIC_LIST_READ_long_total_s "total" - #define FSS_BASIC_LIST_READ_long_trim_s "trim" - - #define FSS_BASIC_LIST_READ_short_at_s_length 1 - #define FSS_BASIC_LIST_READ_short_content_s_length 1 - #define FSS_BASIC_LIST_READ_short_columns_s_length 1 - #define FSS_BASIC_LIST_READ_short_delimit_s_length 1 - #define FSS_BASIC_LIST_READ_short_depth_s_length 1 - #define FSS_BASIC_LIST_READ_short_empty_s_length 1 - #define FSS_BASIC_LIST_READ_short_line_s_length 1 - #define FSS_BASIC_LIST_READ_short_name_s_length 1 - #define FSS_BASIC_LIST_READ_short_object_s_length 1 - #define FSS_BASIC_LIST_READ_short_pipe_s_length 1 - #define FSS_BASIC_LIST_READ_short_original_s_length 1 - #define FSS_BASIC_LIST_READ_short_select_s_length 1 - #define FSS_BASIC_LIST_READ_short_total_s_length 1 - #define FSS_BASIC_LIST_READ_short_trim_s_length 1 - - #define FSS_BASIC_LIST_READ_long_at_s_length 2 - #define FSS_BASIC_LIST_READ_long_content_s_length 7 - #define FSS_BASIC_LIST_READ_long_columns_s_length 8 - #define FSS_BASIC_LIST_READ_long_delimit_s_length 7 - #define FSS_BASIC_LIST_READ_long_depth_s_length 5 - #define FSS_BASIC_LIST_READ_long_empty_s_length 5 - #define FSS_BASIC_LIST_READ_long_line_s_length 4 - #define FSS_BASIC_LIST_READ_long_name_s_length 4 - #define FSS_BASIC_LIST_READ_long_object_s_length 6 - #define FSS_BASIC_LIST_READ_long_pipe_s_length 4 - #define FSS_BASIC_LIST_READ_long_original_s_length 8 - #define FSS_BASIC_LIST_READ_long_select_s_length 6 - #define FSS_BASIC_LIST_READ_long_total_s_length 5 - #define FSS_BASIC_LIST_READ_long_trim_s_length 4 - - extern const f_string_static_t fss_basic_list_read_short_at_s; - extern const f_string_static_t fss_basic_list_read_short_content_s; - extern const f_string_static_t fss_basic_list_read_short_columns_s; - extern const f_string_static_t fss_basic_list_read_short_delimit_s; - extern const f_string_static_t fss_basic_list_read_short_depth_s; - extern const f_string_static_t fss_basic_list_read_short_empty_s; - extern const f_string_static_t fss_basic_list_read_short_line_s; - extern const f_string_static_t fss_basic_list_read_short_name_s; - extern const f_string_static_t fss_basic_list_read_short_object_s; - extern const f_string_static_t fss_basic_list_read_short_pipe_s; - extern const f_string_static_t fss_basic_list_read_short_original_s; - extern const f_string_static_t fss_basic_list_read_short_select_s; - extern const f_string_static_t fss_basic_list_read_short_total_s; - extern const f_string_static_t fss_basic_list_read_short_trim_s; - - extern const f_string_static_t fss_basic_list_read_long_at_s; - extern const f_string_static_t fss_basic_list_read_long_content_s; - extern const f_string_static_t fss_basic_list_read_long_columns_s; - extern const f_string_static_t fss_basic_list_read_long_delimit_s; - extern const f_string_static_t fss_basic_list_read_long_depth_s; - extern const f_string_static_t fss_basic_list_read_long_empty_s; - extern const f_string_static_t fss_basic_list_read_long_line_s; - extern const f_string_static_t fss_basic_list_read_long_name_s; - extern const f_string_static_t fss_basic_list_read_long_object_s; - extern const f_string_static_t fss_basic_list_read_long_pipe_s; - extern const f_string_static_t fss_basic_list_read_long_original_s; - extern const f_string_static_t fss_basic_list_read_long_select_s; - extern const f_string_static_t fss_basic_list_read_long_total_s; - extern const f_string_static_t fss_basic_list_read_long_trim_s; - - enum { - fss_basic_list_read_parameter_help_e, - fss_basic_list_read_parameter_copyright_e, - fss_basic_list_read_parameter_light_e, - fss_basic_list_read_parameter_dark_e, - fss_basic_list_read_parameter_no_color_e, - fss_basic_list_read_parameter_verbosity_quiet_e, - fss_basic_list_read_parameter_verbosity_error_e, - fss_basic_list_read_parameter_verbosity_normal_e, - fss_basic_list_read_parameter_verbosity_verbose_e, - fss_basic_list_read_parameter_verbosity_debug_e, - fss_basic_list_read_parameter_version_e, - fss_basic_list_read_parameter_line_first_no_e, - fss_basic_list_read_parameter_line_last_no_e, - - fss_basic_list_read_parameter_at_e, - fss_basic_list_read_parameter_content_e, - fss_basic_list_read_parameter_columns_e, - fss_basic_list_read_parameter_delimit_e, - fss_basic_list_read_parameter_depth_e, - fss_basic_list_read_parameter_empty_e, - fss_basic_list_read_parameter_line_e, - fss_basic_list_read_parameter_name_e, - fss_basic_list_read_parameter_object_e, - fss_basic_list_read_parameter_pipe_e, - fss_basic_list_read_parameter_original_e, - fss_basic_list_read_parameter_select_e, - fss_basic_list_read_parameter_total_e, - fss_basic_list_read_parameter_trim_e, - }; // enum - - #define fss_basic_list_read_console_parameter_t_initialize \ - { \ - macro_fll_program_console_parameter_standard_initialize, \ - \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_at_s, fss_basic_list_read_long_at_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_content_s, fss_basic_list_read_long_content_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_columns_s, fss_basic_list_read_long_columns_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_delimit_s, fss_basic_list_read_long_delimit_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_depth_s, fss_basic_list_read_long_depth_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_empty_s, fss_basic_list_read_long_empty_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_line_s, fss_basic_list_read_long_line_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_name_s, fss_basic_list_read_long_name_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_object_s, fss_basic_list_read_long_object_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_pipe_s, fss_basic_list_read_long_pipe_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_original_s, fss_basic_list_read_long_original_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_select_s, fss_basic_list_read_long_select_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_total_s, fss_basic_list_read_long_total_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_list_read_short_trim_s, fss_basic_list_read_long_trim_s, 0, 0, f_console_flag_normal_e), \ - } - - #define fss_basic_list_read_total_parameters_d 27 -#endif // _di_fss_basic_list_read_parameter_d_ - -/** - * FSS Delimit Parameter strings. - * - * fss_basic_list_read_delimit_mode_*: - * - all: All delimits are to be applied. - * - content: Content are to have delimits applied. - * - content_greater: Content at this number or higher are to have delimits applied. - * - content_greater_object: Objects and Content at this number or higher are to have delimits applied. - * - content_lesser: Content at this number or lower are to have delimits applied. - * - content_lesser_object: Objects and Content at this number or lower are to have delimits applied. - * - content_object: Objects and Content are to have delimits applied - * - object: Objects arre to have delimits applied. - */ -#ifndef _di_fss_basic_list_read_delimit_mode_s_ - #define FSS_BASIC_LIST_READ_delimit_mode_name_none_s "none" - #define FSS_BASIC_LIST_READ_delimit_mode_name_all_s "all" - #define FSS_BASIC_LIST_READ_delimit_mode_name_object_s "object" - #define FSS_BASIC_LIST_READ_delimit_mode_name_greater_s "+" - #define FSS_BASIC_LIST_READ_delimit_mode_name_lesser_s "-" - - #define FSS_BASIC_LIST_READ_delimit_mode_name_none_s_length 4 - #define FSS_BASIC_LIST_READ_delimit_mode_name_all_s_length 3 - #define FSS_BASIC_LIST_READ_delimit_mode_name_object_s_length 6 - #define FSS_BASIC_LIST_READ_delimit_mode_name_greater_s_length 1 - #define FSS_BASIC_LIST_READ_delimit_mode_name_lesser_s_length 1 - - extern const f_string_static_t fss_basic_list_read_delimit_mode_name_none_s; - extern const f_string_static_t fss_basic_list_read_delimit_mode_name_all_s; - extern const f_string_static_t fss_basic_list_read_delimit_mode_name_object_s; - extern const f_string_static_t fss_basic_list_read_delimit_mode_name_greater_s; - extern const f_string_static_t fss_basic_list_read_delimit_mode_name_lesser_s; -#endif // _di_fss_basic_list_read_delimit_mode_s_ - -/** - * FSS Delimit Parameter enumerations. - */ -#ifndef _di_fss_basic_list_read_delimit_mode_e_ - enum { - fss_basic_list_read_delimit_mode_none_e = 1, - fss_basic_list_read_delimit_mode_all_e, - fss_basic_list_read_delimit_mode_content_e, - fss_basic_list_read_delimit_mode_content_greater_e, - fss_basic_list_read_delimit_mode_content_greater_object_e, - fss_basic_list_read_delimit_mode_content_lesser_e, - fss_basic_list_read_delimit_mode_content_lesser_object_e, - fss_basic_list_read_delimit_mode_content_object_e, - fss_basic_list_read_delimit_mode_object_e, - }; // enum -#endif // _di_fss_basic_list_read_delimit_mode_e_ - -/** - * Flags passed to the main function or program. - * - * fss_basic_list_read_main_flag_*_e: - * - none: No flags set. - * - copyright: Print copyright. - * - file_from: Using a specified source file. - * - file_to: Using a specified destination file. - * - help: Print help. - * - header: Enable printing of headers. - * - print_first: When set, print new line to message output on program begin after loading settings. - * - print_last: When set, print new line to message output on program end. - * - separate: Enable printing of separators. - * - strip_invalid: Using strip invalid character mode. - * - verify: Using verify mode. - * - version: Print version. - */ -#ifndef _di_fss_basic_list_read_main_flag_e_ - enum { - fss_basic_list_read_main_flag_none_e = 0x0, - fss_basic_list_read_main_flag_copyright_e = 0x1, - fss_basic_list_read_main_flag_file_from_e = 0x2, - fss_basic_list_read_main_flag_file_to_e = 0x4, - fss_basic_list_read_main_flag_header_e = 0x8, - fss_basic_list_read_main_flag_help_e = 0x10, - fss_basic_list_read_main_flag_print_first_e = 0x20, - fss_basic_list_read_main_flag_print_last_e = 0x40, - fss_basic_list_read_main_flag_separate_e = 0x80, - fss_basic_list_read_main_flag_strip_invalid_e = 0x100, - fss_basic_list_read_main_flag_verify_e = 0x200, - fss_basic_list_read_main_flag_version_e = 0x400, - }; // enum -#endif // _di_fss_basic_list_read_main_flag_e_ - -/** - * The fss basic list read main program settings. - * - * This is passed to the program-specific main entry point to designate program settings. - * These program settings are often processed from the program arguments (often called the command line arguments). - * - * flag: Flags passed to the main function. - * - * state: The state information. - */ -#ifndef _di_fss_basic_list_read_setting_t_ - typedef struct { - uint16_t flag; - - f_state_t state; - } fss_basic_list_read_setting_t; - - #define fss_basic_list_read_setting_t_initialize \ - { \ - fss_basic_list_read_main_flag_none_e, \ - f_state_t_initialize, \ - } -#endif // _di_fss_basic_list_read_setting_t_ - -/** - * Delete the program main setting data. - * - * @param setting - * The program main setting data. - * - * This does not alter setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fss_basic_list_read_setting_delete_ - extern f_status_t fss_basic_list_read_setting_delete(fss_basic_list_read_setting_t * const setting); -#endif // _di_fss_basic_list_read_setting_delete_ - -/** - * Perform the standard program setting load process. - * - * This prints error messages as appropriate. - * - * If either main or setting is NULL, then this immediately returns without doing anything. - * - * @param arguments - * The parameters passed to the process (often referred to as command line arguments). - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.state.status: - * F_none on success. - * - * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). - * - * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() - */ -#ifndef _di_fss_basic_list_read_setting_load_ - extern void fss_basic_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting); -#endif // _di_fss_basic_list_read_setting_load_ - -/** - * Perform the standard program setting unload process. - * - * @param main - * The main program and setting data. - * All buffers are deallocated. - * - * This does not alter main.setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: fss_basic_list_read_setting_delete(). - * - * @see fss_basic_list_read_setting_delete() - */ -#ifndef _di_fss_basic_list_read_setting_unload_ - extern f_status_t fss_basic_list_read_setting_unload(fss_basic_list_read_main_t * const main); -#endif // _di_fss_basic_list_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_basic_list_read_common_h diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c deleted file mode 100644 index cb5e52e..0000000 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ /dev/null @@ -1,555 +0,0 @@ -#include "fss_basic_list_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_list_read_main_ - f_status_t fss_basic_list_read_main(fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting) { - - f_status_t status = F_none; - - setting->state.step_small = fss_basic_list_read_allocation_console_d; - - status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - - setting->state.step_small = fss_basic_list_read_allocation_small_d; - - if (F_status_is_error(status)) return; - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_basic_list_read_parameter_no_color_e, fss_basic_list_read_parameter_light_e, fss_basic_list_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_basic_list_read_parameter_verbosity_quiet_e, fss_basic_list_read_parameter_verbosity_error_e, fss_basic_list_read_parameter_verbosity_verbose_e, fss_basic_list_read_parameter_verbosity_debug_e, fss_basic_list_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - } - - if (main->parameters.array[fss_basic_list_read_parameter_help_e].result & f_console_result_found_e) { - fss_basic_list_read_print_help(setting, main->message); - - return F_none; - } - - if (main->parameters.array[fss_basic_list_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(&main->message, fss_basic_list_read_program_version_s); - - return F_none; - } - - if (main->parameters.array[fss_basic_list_read_parameter_copyright_e].result & f_console_result_found_e) { - fll_program_print_copyright(&main->message); - - return F_none; - } - - status = F_none; - - // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. - fss_basic_list_read_file_t files_array[main->parameters.remaining.used + 1]; - fss_basic_list_read_data_t data = fss_basic_list_read_data_t_initialize; - - data.argv = main->parameters.arguments.array; - data.files.array = files_array; - data.files.used = 1; - data.files.size = main->parameters.remaining.used + 1; - data.files.array[0].name = fss_basic_list_read_pipe_name_s; - data.files.array[0].range.start = 1; - data.files.array[0].range.stop = 0; - - if (main->parameters.remaining.used || (main->pipe & fll_program_data_pipe_input_e)) { - { - const f_array_length_t parameter_code[] = { - fss_basic_list_read_parameter_at_e, - fss_basic_list_read_parameter_depth_e, - fss_basic_list_read_parameter_line_e, - fss_basic_list_read_parameter_select_e, - fss_basic_list_read_parameter_name_e, - fss_basic_list_read_parameter_delimit_e, - }; - - const f_string_static_t parameter_name[] = { - fss_basic_list_read_long_at_s, - fss_basic_list_read_long_depth_s, - fss_basic_list_read_long_line_s, - fss_basic_list_read_long_select_s, - fss_basic_list_read_long_name_s, - fss_basic_list_read_long_delimit_s, - }; - - const f_string_t message_positive_number = "positive number"; - const f_string_t message_string = "string"; - const f_string_t message_value = "value"; - - const f_string_t parameter_message[] = { - message_positive_number, - message_positive_number, - message_positive_number, - message_positive_number, - message_string, - message_value, - }; - - for (f_array_length_t i = 0; i < 6; ++i) { - - if (main->parameters.array[parameter_code[i]].result & f_console_result_found_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, parameter_name[i], main->error.notable); - fl_print_format("%[' requires a %s.%]%r", main->error.to, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_basic_list_read_parameter_columns_e].result & f_console_result_found_e)) { - const f_array_length_t parameter_code[] = { - fss_basic_list_read_parameter_depth_e, - fss_basic_list_read_parameter_line_e, - fss_basic_list_read_parameter_pipe_e, - fss_basic_list_read_parameter_select_e, - fss_basic_list_read_parameter_total_e, - }; - - const f_string_static_t parameter_name[] = { - fss_basic_list_read_long_depth_s, - fss_basic_list_read_long_line_s, - fss_basic_list_read_long_pipe_s, - fss_basic_list_read_long_select_s, - fss_basic_list_read_long_total_s, - }; - - const uint8_t parameter_match[] = { - f_console_result_value_e, - f_console_result_value_e, - f_console_result_found_e, - f_console_result_value_e, - f_console_result_found_e, - }; - - for (f_array_length_t i = 0; i < 5; ++i) { - - if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_basic_list_read_long_columns_s, parameter_name[i]); - } - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_basic_list_read_parameter_pipe_e].result & f_console_result_found_e)) { - if (main->parameters.array[fss_basic_list_read_parameter_total_e].result & f_console_result_found_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_basic_list_read_long_pipe_s, fss_basic_list_read_long_total_s); - } - - status = F_status_set_error(F_parameter); - } - else if (main->parameters.array[fss_basic_list_read_parameter_line_e].result & f_console_result_value_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_basic_list_read_long_pipe_s, fss_basic_list_read_long_line_s); - } - - status = F_status_set_error(F_parameter); - } - } - - if (F_status_is_error_not(status) && main->parameters.array[fss_basic_list_read_parameter_delimit_e].result & f_console_result_value_e) { - f_array_length_t index = 0; - f_array_length_t length = 0; - - // Set the value to 0 to allow for detecting mode based on what is provided. - data.delimit_mode = 0; - - for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_list_read_parameter_delimit_e].values.used; ++i) { - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - index = main->parameters.array[fss_basic_list_read_parameter_delimit_e].values.array[i]; - length = data.argv[index].used; - - if (!length) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_delimit_s, main->error.notable); - fl_print_format("%[' must not be empty.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - else if (f_compare_dynamic_string(fss_basic_list_read_delimit_mode_name_none_s.string, data.argv[index], fss_basic_list_read_delimit_mode_name_none_s.used) == F_equal_to) { - data.delimit_mode = fss_basic_list_read_delimit_mode_none_e; - } - else if (f_compare_dynamic_string(fss_basic_list_read_delimit_mode_name_all_s.string, data.argv[index], fss_basic_list_read_delimit_mode_name_all_s.used) == F_equal_to) { - data.delimit_mode = fss_basic_list_read_delimit_mode_all_e; - } - else if (f_compare_dynamic_string(fss_basic_list_read_delimit_mode_name_object_s.string, data.argv[index], fss_basic_list_read_delimit_mode_name_object_s.used) == F_equal_to) { - switch (data.delimit_mode) { - case 0: - data.delimit_mode = fss_basic_list_read_delimit_mode_object_e; - break; - - case fss_basic_list_read_delimit_mode_none_e: - case fss_basic_list_read_delimit_mode_all_e: - case fss_basic_list_read_delimit_mode_content_greater_object_e: - case fss_basic_list_read_delimit_mode_content_lesser_object_e: - case fss_basic_list_read_delimit_mode_object_e: - break; - - case fss_basic_list_read_delimit_mode_content_e: - data.delimit_mode = fss_basic_list_read_delimit_mode_content_object_e; - break; - - case fss_basic_list_read_delimit_mode_content_greater_e: - data.delimit_mode = fss_basic_list_read_delimit_mode_content_greater_object_e; - break; - - case fss_basic_list_read_delimit_mode_content_lesser_e: - data.delimit_mode = fss_basic_list_read_delimit_mode_content_lesser_object_e; - break; - - default: - break; - } - } - else { - if (!data.delimit_mode) { - data.delimit_mode = fss_basic_list_read_delimit_mode_content_e; - } - else if (data.delimit_mode == fss_basic_list_read_delimit_mode_object_e) { - data.delimit_mode = fss_basic_list_read_delimit_mode_content_object_e; - } - - if (data.argv[index].string[length - 1] == fss_basic_list_read_delimit_mode_name_greater_s.string[0]) { - if (!(data.delimit_mode == fss_basic_list_read_delimit_mode_none_e || data.delimit_mode == fss_basic_list_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_basic_list_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_basic_list_read_delimit_mode_content_greater_object_e; - } - else { - data.delimit_mode = fss_basic_list_read_delimit_mode_content_greater_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - else if (data.argv[index].string[length - 1] == fss_basic_list_read_delimit_mode_name_lesser_s.string[0]) { - if (!(data.delimit_mode == fss_basic_list_read_delimit_mode_none_e || data.delimit_mode == fss_basic_list_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_basic_list_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_basic_list_read_delimit_mode_content_lesser_object_e; - } - else { - data.delimit_mode = fss_basic_list_read_delimit_mode_content_lesser_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - - f_string_range_t range = macro_f_string_range_t_initialize_2(length); - - // Ignore leading plus sign. - if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { - ++range.start; - } - - status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], range, &data.delimit_depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_unsigned_detect", F_true, fss_basic_list_read_long_delimit_s, data.argv[index]); - - break; - } - - // There can be nothing smaller than 0, so replace '0-' logic with just '0' logic. - if (data.delimit_mode == fss_basic_list_read_delimit_mode_content_lesser_e || data.delimit_mode == fss_basic_list_read_delimit_mode_content_lesser_object_e) { - if (!data.delimit_depth) { - if (data.delimit_mode == fss_basic_list_read_delimit_mode_content_lesser_e) { - data.delimit_mode = fss_basic_list_read_delimit_mode_content_e; - } - else { - data.delimit_mode = fss_basic_list_read_delimit_mode_content_object_e; - } - } - } - } - } // for - - // Guarantee the default value is "all". - if (F_status_is_error_not(status) && !data.delimit_mode) { - data.delimit_mode = fss_basic_list_read_delimit_mode_all_e; - } - } - - if (F_status_is_error_not(status)) { - status = fss_basic_list_read_depth_process(main, &data); - } - - // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. - if (F_status_is_error_not(status) && data.depths.array[0].depth) { - if (main->parameters.array[fss_basic_list_read_parameter_total_e].result & f_console_result_found_e) { - fss_basic_list_read_print_zero(main); - } - - fss_basic_list_read_data_delete_simple(&data); - - return F_none; - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_basic_list_read_parameter_select_e].result & f_console_result_found_e)) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_select_s, main->error.notable); - fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - } - - if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { - f_file_t file = f_file_t_initialize; - - file.id = F_type_descriptor_input_d; - file.stream = F_type_input_d; - - data.files.array[0].range.start = 0; - - status = f_file_stream_read(file, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "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); - } - else if (data.buffer.used) { - data.files.array[0].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - else { - data.files.array[0].range.start = 1; - } - } - - if (F_status_is_error_not(status) && main->parameters.remaining.used) { - f_file_t file = f_file_t_initialize; - off_t size_block = 0; - off_t size_file = 0; - off_t size_read = 0; - - for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; - data.files.array[data.files.used].range.start = data.buffer.used; - file.stream = 0; - file.id = -1; - - status = f_file_stream_open(data.files.array[data.files.used].name, f_string_empty_s, &file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); - - break; - } - - size_file = 0; - - status = f_file_size_by_id(file.id, &size_file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - if (size_file) { - - // Enforce a max block read size to allow for interrupts to be processed between blocks. - if (size_file > fss_basic_list_read_block_max) { - file.size_read = fss_basic_list_read_block_read_large; - size_block = fss_basic_list_read_block_max; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + (size_block - (size_file % size_block)) + 1, &data.buffer); - } - else { - file.size_read = fss_basic_list_read_block_read_small; - size_block = size_file; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + 1, &data.buffer); - } - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - for (size_read = 0; size_read < size_file; size_read += size_block) { - - // The signal check is always performed on each pass. - if (size_file > fss_basic_list_read_block_max && fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - status = f_file_stream_read_until(file, size_block, &data.buffer); - if (F_status_is_error(status)) break; - } // for - - f_file_stream_flush(file); - f_file_stream_close(&file); - - if (F_status_is_error(status)) { - if (F_status_set_fine(status) != F_interrupt) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read_until", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - } - - break; - } - - if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used++].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - } - else { - data.files.array[data.files.used].range.start = 1; - data.files.array[data.files.used].range.stop = 1; - } - } // for - - f_file_stream_flush(file); - f_file_stream_close(&file); - } - - if (F_status_is_error_not(status)) { - status = fss_basic_list_read_process(main, &data); - } - - fss_basic_list_read_data_delete_simple(&data); - } - else { - fll_print_format("%r%[%QYou failed to specify one or more files.%]%r", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - status = F_status_set_error(F_parameter); - } - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - if (F_status_set_fine(status) == F_interrupt) { - f_file_stream_flush(main->output.to); - - fll_print_dynamic_raw(f_string_eol_s, main->output.to); - } - } - - fss_basic_list_read_data_delete_simple(&data); - - return status; - } -#endif // _di_fss_basic_list_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.h b/level_3/fss_basic_list_read/c/fss_basic_list_read.h deleted file mode 100644 index e73a8f5..0000000 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This is the FSS Basic List Read program - * This program utilizes the Featureless Linux Library. - * This program processes files or other input in fss format and stores the results in the fll_program_data_t. - * - * This processes in accordance to the FSS-0002 Basic List specification. - */ -#ifndef _fss_basic_list_read_h -#define _fss_basic_list_read_h - -// Libc includes. -#include -#include -#include -#include -#include - -// FLL-0 includes. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// FLL-1 includes. -#include -#include - -// FLL-2 includes. -#include -#include -#include -#include -#include - -// FSS Basic List Read includes. -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Execute main program. - * - * If main.signal is non-zero, then this blocks and handles the following signals: - * - F_signal_abort - * - F_signal_broken_pipe - * - F_signal_hangup - * - F_signal_interrupt - * - F_signal_quit - * - F_signal_termination - * - * @param arguments - * The parameters passed to the process. - * @param main - * The main program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - */ -#ifndef _di_fss_basic_list_read_main_ - extern f_status_t fss_basic_list_read_main(fll_program_data_t * const main, fss_basic_list_read_setting_t * const setting); -#endif // _di_fss_basic_list_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_basic_list_read_h diff --git a/level_3/fss_basic_list_read/c/main.c b/level_3/fss_basic_list_read/c/main.c deleted file mode 100644 index dec6f20..0000000 --- a/level_3/fss_basic_list_read/c/main.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "fss_basic_list_read.h" - -int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - - fss_basic_list_read_main_t data = fss_basic_list_read_main_t_initialize; - - data.program.debug.flag |= fss_basic_list_read_print_flag_debug_e | fss_basic_list_read_print_flag_out_e; - data.program.error.flag |= fss_basic_list_read_print_flag_error_e | fss_basic_list_read_print_flag_out_e; - data.program.output.flag |= fss_basic_list_read_print_flag_out_e; - data.program.message.flag |= fss_basic_list_read_print_flag_message_e | fss_basic_list_read_print_flag_out_e; - data.program.warning.flag |= fss_basic_list_read_print_flag_warning_e | fss_basic_list_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; - - f_console_parameter_t parameters[] = fss_basic_list_read_console_parameter_t_initialize; - data.program.parameters.array = parameters; - data.program.parameters.used = fss_basic_list_read_total_parameters_d; - data.program.environment = envp; - - if (f_pipe_input_exists()) { - data.program.pipe = fll_program_data_pipe_input_e; - } - - fll_program_standard_set_up(&data.program); - - { - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); - - fss_basic_list_read_setting_load(arguments, &data); - } - - fss_basic_list_read_main(&data); - - fss_basic_list_read_setting_unload(&data); - - fll_program_data_delete(&data.program); - - fll_program_standard_set_down(&data.program); - - return F_status_is_error(data.setting.state.status) ? 1 : 0; -} diff --git a/level_3/fss_basic_list_read/c/main.h b/level_3/fss_basic_list_read/c/main.h deleted file mode 100644 index 060e536..0000000 --- a/level_3/fss_basic_list_read/c/main.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic List Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This file is only ever included by main/main.c and should not normally be included anywhere else. - * Anything that wants to include this should be providing the "fss_basic_list_read" program functionality in some manner. - */ -#ifndef _fss_basic_list_read_main_h -#define _fss_basic_list_read_main_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Standard program entry point. - * - * @param argc - * The number of arguments. - * @param argv - * The array of arguments. - * @param envp - * The array of all environment variables on program start. - * - * @return - * 0 on success. - * 1 on error. - */ -extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_basic_list_read_main_h diff --git a/level_3/fss_basic_list_read/c/print.c b/level_3/fss_basic_list_read/c/print.c deleted file mode 100644 index 358559a..0000000 --- a/level_3/fss_basic_list_read/c/print.c +++ /dev/null @@ -1,116 +0,0 @@ -#include "fss_basic_list_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_list_read_print_help_ - f_status_t fss_basic_list_read_print_help(fss_basic_list_read_setting_t * const setting, const fl_print_t print) { - - f_file_stream_lock(print.to); - - fll_program_print_help_header(print, fss_basic_list_read_program_name_long_s, fss_basic_list_read_program_version_s); - - fll_program_print_help_option_standard(print); - - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_option(print, fss_basic_list_read_short_at_s, fss_basic_list_read_long_at_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric index."); - fll_program_print_help_option(print, fss_basic_list_read_short_content_s, fss_basic_list_read_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Content (default)."); - fll_program_print_help_option(print, fss_basic_list_read_short_columns_s, fss_basic_list_read_long_columns_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of columns."); - fll_program_print_help_option(print, fss_basic_list_read_short_delimit_s, fss_basic_list_read_long_delimit_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Designate how to handle applying delimits."); - fll_program_print_help_option(print, fss_basic_list_read_short_depth_s, fss_basic_list_read_long_depth_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric depth."); - fll_program_print_help_option(print, fss_basic_list_read_short_empty_s, fss_basic_list_read_long_empty_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Include empty Content when processing."); - fll_program_print_help_option(print, fss_basic_list_read_short_line_s, fss_basic_list_read_long_line_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print only the Content at the given line."); - fll_program_print_help_option(print, fss_basic_list_read_short_name_s, fss_basic_list_read_long_name_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object with this name."); - fll_program_print_help_option(print, fss_basic_list_read_short_object_s, fss_basic_list_read_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Object."); - fll_program_print_help_option(print, fss_basic_list_read_short_pipe_s, fss_basic_list_read_long_pipe_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print using the special pipe format."); - fll_program_print_help_option(print, fss_basic_list_read_short_original_s, fss_basic_list_read_long_original_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print with the original quotes and escapes."); - fll_program_print_help_option(print, fss_basic_list_read_short_select_s, fss_basic_list_read_long_select_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select sub-Content at this index."); - fll_program_print_help_option(print, fss_basic_list_read_short_total_s, fss_basic_list_read_long_total_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of lines."); - fll_program_print_help_option(print, fss_basic_list_read_short_trim_s, fss_basic_list_read_long_trim_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Trim Object names on select or print."); - - f_print_dynamic_raw(f_string_eol_s, print.to); - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_usage(print, fss_basic_list_read_program_name_s, fll_program_parameter_filenames_s); - - fl_print_format("%r %[Notes:%]%r", print.to, f_string_eol_s, print.set->important, print.set->important, f_string_eol_s); - - fl_print_format(" This program will print the Content associated with the given Object and Content main based on the FSS-0002 Basic List standard.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" All numeric positions (indexes) start at 0 instead of 1.%r", print.to, f_string_eol_s); - fl_print_format(" For example, a file of 17 lines would range from 0 to 16.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When using the %[%r%r%] option, an order of operations is enforced on the parameters.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_depth_s, print.set->notable, f_string_eol_s); - - fl_print_format(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%r", print.to, f_string_eol_s); - - fl_print_format(" %[%r%r%]: An Object index at the specified depth.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_at_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: A new depth within the specified depth, indexed from the root.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: An Object name at the specified depth.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] must be in numeric order, but values in between may be skipped.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%r", print.to, f_string_eol_s); - fl_print_format(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] selects a Content column.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_select_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" Specify both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_object_s, print.set->notable); - fl_print_format(" and the %[%r%r%] parameters to get the total objects.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_total_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_at_s, print.set->notable); - fl_print_format(" and %[%r%r%] parameters are specified (at the same depth),", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_name_s, print.set->notable); - fl_print_format(" the %[%r%r%] parameter value will be treated as a position relative to the specified", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_at_s, print.set->notable); - fl_print_format(" %[%r%r%] parameter value.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" This program may support parameters, such as %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_depth_s, print.set->notable); - fl_print_format(" or %[%r%r%], even if not supported by the standard.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_select_s, print.set->notable, f_string_eol_s); - fl_print_format(" This is done to help ensure consistency for scripting.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_depth_s, print.set->notable); - fl_print_format(" if the standard doesn't support nested Content, then only a depth of 0 would be valid.%r", print.to, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_select_s, print.set->notable); - fl_print_format(" if the standard doesn't support multiple Content groups, then only a select of 0 would be valid.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_trim_s, print.set->notable); - fl_print_format(" will remove leading and trailing white spaces when selecting objects or when printing objects.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When specifying both the %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_object_s, print.set->notable); - fl_print_format(" parameter and the %[%r%r%] parameter, the entire Object and Content are printed, including the formatting.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_content_s, print.set->notable, f_string_eol_s); - fl_print_format(" Both the Object and Content printed are already escaped.%r", print.to, f_string_eol_s); - fl_print_format(" Both the Object and Content are separated by a New Line character '\\n' (U+000A).%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] accepts the following:%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_delimit_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Do not apply delimits.%r", print.to, print.set->notable, fss_basic_list_read_delimit_mode_name_none_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: (default) Apply all delimits.%r", print.to, print.set->notable, fss_basic_list_read_delimit_mode_name_all_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Apply delimits for Objects.%r", print.to, print.set->notable, fss_basic_list_read_delimit_mode_name_object_s, print.set->notable, f_string_eol_s); - fl_print_format(" - A number, 0 or greater: apply delimits for Content at the specified depth.%r", print.to, f_string_eol_s); - fl_print_format(" - A number, 0 or greater, followed by a %[%r%]: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%r", print.to, print.set->notable, fss_basic_list_read_delimit_mode_name_greater_s, print.set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" - A number, 0 or lesser, followed by a %[%r%]: (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%r%r", print.to, print.set->notable, fss_basic_list_read_delimit_mode_name_lesser_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%] parameter may be specified multiple times to customize the delimit behavior.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_delimit_s, print.set->notable, f_string_eol_s); - - fl_print_format(" The %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_delimit_s, print.set->notable); - fl_print_format(" values %[%r%]", print.to, print.set->notable, fss_basic_list_read_delimit_mode_name_none_s, print.set->notable); - fl_print_format(" and %[%r%],", print.to, print.set->notable, fss_basic_list_read_delimit_mode_name_all_s, print.set->notable); - fl_print_format(" overrule all other delimit values.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameters %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_columns_s, print.set->notable); - fl_print_format(" and %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_select_s, print.set->notable); - fl_print_format(" refer to a Content column.%r", print.to, f_string_eol_s); - fl_print_format(" The word 'column' is being loosely defined to refer to a specific Content.%r", print.to, f_string_eol_s); - fl_print_format(" This is not to be confused with a depth.%r", print.to, f_string_eol_s); - - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_basic_list_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_list_read/c/print.h b/level_3/fss_basic_list_read/c/print.h deleted file mode 100644 index d325598..0000000 --- a/level_3/fss_basic_list_read/c/print.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic List Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _fss_basic_list_read_print_h -#define _fss_basic_list_read_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print help. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_list_read_print_help_ - extern f_status_t fss_basic_list_read_print_help(fss_basic_list_read_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_basic_list_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_basic_list_read_print_h diff --git a/level_3/fss_basic_list_read/c/private-common.c b/level_3/fss_basic_list_read/c/private-common.c deleted file mode 100644 index a1861b3..0000000 --- a/level_3/fss_basic_list_read/c/private-common.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "fss_basic_list_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_list_read_data_delete_simple_ - void fss_basic_list_read_data_delete_simple(fss_basic_list_read_data_t *data) { - - if (!data) return; - - // data->files is expected to be statically loaded and cannot be deallocated. - - fss_basic_list_read_depths_resize(0, &data->depths); - - f_string_dynamic_resize(0, &data->buffer); - macro_f_fss_contents_t_delete_simple(data->contents); - macro_f_fss_objects_t_delete_simple(data->objects); - macro_f_fss_delimits_t_delete_simple(data->delimits_object); - macro_f_fss_delimits_t_delete_simple(data->delimits_content); - macro_f_fss_comments_t_delete_simple(data->comments); - } -#endif // _di_fss_basic_list_read_data_delete_simple_ - -#ifndef _di_fss_basic_list_read_depth_delete_simple_ - void fss_basic_list_read_depth_delete_simple(fss_basic_list_read_depth_t *depth) { - - if (!depth) return; - - f_string_dynamic_resize(0, &depth->value_name); - } -#endif // _di_fss_basic_list_read_depth_delete_simple_ - -#ifndef _di_fss_basic_list_read_depths_resize_ - f_status_t fss_basic_list_read_depths_resize(const f_array_length_t length, fss_basic_list_read_depths_t *depths) { - - if (!depths) { - return F_status_set_error(F_parameter); - } - - for (f_array_length_t i = length; i < depths->size; ++i) { - fss_basic_list_read_depth_delete_simple(&depths->array[i]); - } // for - - const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_basic_list_read_depth_t), (void **) & depths->array); - if (F_status_is_error(status)) return status; - - depths->size = length; - - if (depths->used > depths->size) { - depths->used = length; - } - - return F_none; - } -#endif // _di_fss_basic_list_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_list_read/c/private-common.h b/level_3/fss_basic_list_read/c/private-common.h deleted file mode 100644 index 5f159ee..0000000 --- a/level_3/fss_basic_list_read/c/private-common.h +++ /dev/null @@ -1,268 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic List Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_common_h -#define _PRIVATE_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Provide common/generic definitions. - * - * basic_list_read_common_allocation_*: - * - large: An allocation step used for buffers that are anticipated to have large buffers. - * - small: An allocation step used for buffers that are anticipated to have small buffers. - * - * fss_basic_list_read_block_*: - * - max: The max block read size before checking for interrupt. - * - read_small: The block read size for small files. - * - read_large: The block read size for large files. - */ -#ifndef _di_fss_basic_list_read_common_ - #define fss_basic_list_read_common_allocation_large_d 2048 - #define fss_basic_list_read_common_allocation_small_d 128 - - #define fss_basic_list_read_block_max 16777216 - #define fss_basic_list_read_block_read_small 8192 - #define fss_basic_list_read_block_read_large 65536 -#endif // _di_fss_basic_list_read_common_ - -/** - * A structure of parameters applied at some depth. - * - * depth: The depth number in which this is to be processed at. - * - * index_at: Position of the "--at" parameter value in the argv list, when 0 there is no parameter. - * index_name: Position of the "--name" parameter value in the argv list, when 0 there is no parameter. - * - * value_at: The value of the "--at" parameter, already processed and ready to use, only when index_at > 0. - * value_name: The value of the "--name" parameter, already processed and ready to use, only when index_name > 0. - */ -#ifndef _di_fss_basic_list_read_depth_t_ - typedef struct { - f_array_length_t depth; - - f_array_length_t index_at; - f_array_length_t index_name; - - f_number_unsigned_t value_at; - f_string_dynamic_t value_name; - } fss_basic_list_read_depth_t; - - #define fss_basic_list_read_depth_t_initialize \ - { \ - 0, \ - 0, \ - 0, \ - 0, \ - f_string_dynamic_t_initialize, \ - } - - #define macro_fss_basic_list_read_depth_t_clear(structure) \ - structure.depth = 0; \ - structure.index_at = 0; \ - structure.index_name = 0; \ - structure.value_at = 0; \ - macro_f_string_dynamic_t_clear(structure.value_name) -#endif // _di_fss_basic_list_read_depth_t_ - -/** - * An array of depth parameters. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_basic_list_read_depths_t_ - typedef struct { - fss_basic_list_read_depth_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_basic_list_read_depths_t; - - #define fss_basic_list_read_depths_t_initialize { 0, 0, 0 } - - #define macro_fss_basic_list_read_depths_t_clear(depths) macro_f_memory_structure_clear(depths) -#endif // _di_fss_basic_list_read_depths_t_ - -/** - * A structure for designating where within the buffer a particular file exists, using a statically allocated array. - * - * name: The name of the file representing the range. - * range: A range within the buffer representing the file. - */ -#ifndef _di_fss_basic_list_read_file_t_ - typedef struct { - f_string_static_t name; - f_string_range_t range; - } fss_basic_list_read_file_t; - - #define fss_basic_list_read_file_t_initialize \ - { \ - f_string_static_t_initialize, \ - f_string_range_t_initialize, \ - } -#endif // _di_fss_basic_list_read_file_t_ - -/** - * An array of files. - * - * This is intended to be defined and used statically allocated and as such no dynamic allocation or dynamic deallocation methods are provided. - * - * The STDIN pipe is reserved for index 0 and as such size and used must be initialized to 1. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_basic_list_read_files_t_ - typedef struct { - fss_basic_list_read_file_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_basic_list_read_files_t; - - #define fss_basic_list_read_files_t_initialize { 0, 1, 1 } -#endif // _di_fss_basic_list_read_files_t_ - -/** - * The data structure for FSS Basic Read. - * - * fss_basic_list_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - 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). - * - * argv: The argument structure in the progam data parameters for simplifying syntax. - * options: Bitwise flags representing parameters. - * delimit_mode: The delimit mode. - * delimit_depth: The delimit depth. - * select: The Content to select (column number). - * line: The Content to select (row number). - * files: A statically allocated array of files for designating where in the buffer a file is represented. - * depths: The array of parameters for each given depth. - * buffer: The buffer containing all loaded files (and STDIN pipe). - * objects: The positions within the buffer representing Objects. - * 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. - */ -#ifndef _di_fss_basic_list_read_data_t_ - #define fss_basic_list_read_data_option_at_d 0x1 - #define fss_basic_list_read_data_option_columns_d 0x2 - #define fss_basic_list_read_data_option_content_d 0x4 - #define fss_basic_list_read_data_option_empty_d 0x8 - #define fss_basic_list_read_data_option_line_d 0x10 - #define fss_basic_list_read_data_option_name_d 0x20 - #define fss_basic_list_read_data_option_object_d 0x40 - #define fss_basic_list_read_data_option_original_d 0x80 - #define fss_basic_list_read_data_option_select_d 0x100 - #define fss_basic_list_read_data_option_total_d 0x200 - #define fss_basic_list_read_data_option_trim_d 0x400 - - typedef struct { - uint16_t option; - uint8_t delimit_mode; - f_array_length_t delimit_depth; - f_number_unsigned_t select; - f_number_unsigned_t line; - - f_string_static_t *argv; - - fss_basic_list_read_files_t files; - fss_basic_list_read_depths_t depths; - - f_string_dynamic_t buffer; - f_fss_objects_t objects; - f_fss_contents_t contents; - f_fss_delimits_t delimits_object; - f_fss_delimits_t delimits_content; - f_fss_comments_t comments; - f_uint8s_t quotes; - } fss_basic_list_read_data_t; - - #define fss_basic_list_read_data_t_initialize \ - { \ - 0, \ - fss_basic_list_read_delimit_mode_all_e, \ - 0, \ - 0, \ - 0, \ - 0, \ - fss_basic_list_read_files_t_initialize, \ - fss_basic_list_read_depths_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_fss_objects_t_initialize, \ - f_fss_contents_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_uint8s_t_initialize, \ - f_fss_comments_t_initialize, \ - } -#endif // _di_fss_basic_list_read_data_t_ - -/** - * Fully deallocate all memory for the given data without caring about return status. - * - * @param data - * The data to deallocate. - */ -#ifndef _di_fss_basic_list_read_data_delete_simple_ - extern void fss_basic_list_read_data_delete_simple(fss_basic_list_read_data_t *data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_data_delete_simple_ - -/** - * Fully deallocate all memory for the given depth without caring about return status. - * - * @param depth - * The depth to deallocate. - */ -#ifndef _di_fss_basic_list_read_depth_delete_simple_ - extern void fss_basic_list_read_depth_delete_simple(fss_basic_list_read_depth_t *depth) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_depth_delete_simple_ - -/** - * Resize the depth array. - * - * @param length - * The new size to use. - * @param depths - * The depth array to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * Errors (with error bit) from: fss_basic_list_read_depths_increase(). - * - * @see f_memory_resize() - * - * @see fss_basic_list_read_depth_delete_simple() - * @see fss_basic_list_read_depths_increase() - */ -#ifndef _di_fss_basic_list_read_depths_resize_ - extern f_status_t fss_basic_list_read_depths_resize(const f_array_length_t length, fss_basic_list_read_depths_t *depths) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_common_h diff --git a/level_3/fss_basic_list_read/c/private-print.c b/level_3/fss_basic_list_read/c/private-print.c deleted file mode 100644 index d48271e..0000000 --- a/level_3/fss_basic_list_read/c/private-print.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "fss_basic_list_read.h" -#include "private-common.h" -#include "private-print.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_list_read_print_at_ - void fss_basic_list_read_print_at(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_basic_list_read_data_t * const data) { - - if (at >= data->contents.used) { - return; - } - - if ((data->option & fss_basic_list_read_data_option_object_d) || (data->option & fss_basic_list_read_data_option_content_d) && (data->contents.array[at].used || (data->option & fss_basic_list_read_data_option_empty_d))) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_basic_list_read_data_option_object_d) { - if (data->option & fss_basic_list_read_data_option_trim_d) { - fl_print_trim_except_in_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, data->comments, main->output.to); - } - else { - f_print_except_in_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, data->comments, main->output.to); - } - - fss_basic_list_read_print_object_end(main); - } - - if (data->option & fss_basic_list_read_data_option_content_d) { - if (data->contents.array[at].used) { - fss_basic_list_read_print_content_ignore(main); - - f_print_except_in_dynamic_partial(data->buffer, data->contents.array[at].array[0], delimits_content, data->comments, main->output.to); - - fss_basic_list_read_print_content_ignore(main); - } - } - - fss_basic_list_read_print_set_end(main); - - f_file_stream_unlock(main->output.to); - } - } -#endif // _di_fss_basic_list_read_print_at_ - -#ifndef _di_fss_basic_list_read_print_at_object_ - void fss_basic_list_read_print_at_object(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t at, const f_fss_delimits_t delimits_object) { - - if (at >= data->objects.used) { - return; - } - - if (data->option & fss_basic_list_read_data_option_trim_d) { - fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - else { - f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - - fss_basic_list_read_print_object_end(main); - } -#endif // _di_fss_basic_list_read_print_at_object_ - -#ifndef _di_fss_basic_list_read_print_content_ignore_ - void fss_basic_list_read_print_content_ignore(fll_program_data_t * const main) { - - if (main->parameters.array[fss_basic_list_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_basic_list_read_pipe_content_ignore_s, main->output.to); - } - } -#endif // _di_fss_basic_list_read_print_content_ignore_ - -#ifndef _di_fss_basic_list_read_print_object_end_ - void fss_basic_list_read_print_object_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_basic_list_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_basic_list_read_pipe_content_start_s, main->output.to); - } - else { - if (main->parameters.array[fss_basic_list_read_parameter_content_e].result & f_console_result_found_e) { - f_print_dynamic_raw(f_fss_basic_list_open_s, main->output.to); - f_print_dynamic_raw(f_fss_basic_list_open_end_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_eol_s, main->output.to); - } - } - } -#endif // _di_fss_basic_list_read_print_object_end_ - -#ifndef _di_fss_basic_list_read_print_one_ - void fss_basic_list_read_print_one(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_1_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_basic_list_read_print_one_ - -#ifndef _di_fss_basic_list_read_print_set_end_ - void fss_basic_list_read_print_set_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_basic_list_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_basic_list_read_pipe_content_end_s, main->output.to); - } - } -#endif // _di_fss_basic_list_read_print_set_end_ - -#ifndef _di_fss_basic_list_read_print_zero_ - void fss_basic_list_read_print_zero(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_0_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_basic_list_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_list_read/c/private-print.h b/level_3/fss_basic_list_read/c/private-print.h deleted file mode 100644 index 880ae12..0000000 --- a/level_3/fss_basic_list_read/c/private-print.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_print_h -#define _PRIVATE_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print the Object and Content at the given position. - * - * Only what is requested to print (Object, Content, both, or neither) will be printed, if there is something to print. - * - * @param main - * The main program data. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param data - * The program data. - */ -#ifndef _di_fss_basic_list_read_print_at_ - extern void fss_basic_list_read_print_at(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_basic_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_print_at_ - -/** - * Explicitly print the Object at the given position. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - */ -#ifndef _di_fss_basic_list_read_print_at_object_ - extern void fss_basic_list_read_print_at_object(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t at, const f_fss_delimits_t delimits_object) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_print_at_object_ - -/** - * Print the ignore character for Content. - * - * This is only used in pipe output mode. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_list_read_print_content_ignore_ - extern void fss_basic_list_read_print_content_ignore(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_print_content_ignore_ - -/** - * Print the end of an Object (which is essentially the start of Content). - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_list_read_print_object_end_ - extern void fss_basic_list_read_print_object_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_print_object_end_ - -/** - * Print the number one and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_list_read_print_one_ - extern void fss_basic_list_read_print_one(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_print_one_ - -/** - * Print the end of an Object/Content set. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_list_read_print_set_end_ - extern void fss_basic_list_read_print_set_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_print_set_end_ - -/** - * Print the number zero and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_list_read_print_zero_ - extern void fss_basic_list_read_print_zero(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_print_h diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c deleted file mode 100644 index 5eaa402..0000000 --- a/level_3/fss_basic_list_read/c/private-read.c +++ /dev/null @@ -1,806 +0,0 @@ -#include "fss_basic_list_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_list_read_delimit_content_is_ - f_status_t fss_basic_list_read_delimit_content_is(fss_basic_list_read_data_t * const data, const f_array_length_t depth) { - - if (data->delimit_mode == fss_basic_list_read_delimit_mode_none_e) { - return F_false; - } - - if (data->delimit_mode == fss_basic_list_read_delimit_mode_all_e) { - return F_true; - } - - if (depth < data->delimit_depth) { - return data->delimit_mode == fss_basic_list_read_delimit_mode_content_lesser_e; - } - - if (depth == data->delimit_depth) { - return F_true; - } - - return data->delimit_mode == fss_basic_list_read_delimit_mode_content_greater_e; - } -#endif // _di_fss_basic_list_read_delimit_content_is_ - -#ifndef _di_fss_basic_list_read_delimit_object_is_ - f_status_t fss_basic_list_read_delimit_object_is(fss_basic_list_read_data_t * const data, const f_array_length_t depth) { - - switch (data->delimit_mode) { - case fss_basic_list_read_delimit_mode_none_e: - case fss_basic_list_read_delimit_mode_content_e: - case fss_basic_list_read_delimit_mode_content_greater_e: - case fss_basic_list_read_delimit_mode_content_lesser_e: - return F_false; - - case fss_basic_list_read_delimit_mode_all_e: - case fss_basic_list_read_delimit_mode_content_object_e: - case fss_basic_list_read_delimit_mode_content_greater_object_e: - case fss_basic_list_read_delimit_mode_content_lesser_object_e: - case fss_basic_list_read_delimit_mode_object_e: - return F_true; - - default: - break; - } - - return depth == data->delimit_depth || data->delimit_mode == fss_basic_list_read_delimit_mode_content_lesser_e; - } -#endif // _di_fss_basic_list_read_delimit_object_is_ - -#ifndef _di_fss_basic_list_read_depth_process_ - f_status_t fss_basic_list_read_depth_process(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) { - - f_status_t status = F_none; - - { - f_array_length_t depth_size = 1; - - if (main->parameters.array[fss_basic_list_read_parameter_depth_e].result & f_console_result_value_e) { - depth_size = main->parameters.array[fss_basic_list_read_parameter_depth_e].values.used; - } - - if (depth_size > data->depths.size) { - status = fss_basic_list_read_depths_resize(depth_size, &data->depths); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fss_basic_list_read_depths_resize", fll_error_file_flag_fallback_e); - - return status; - } - } - - data->depths.used = depth_size; - } - - f_array_length_t position_depth = 0; - f_array_length_t position_at = 0; - f_array_length_t position_name = 0; - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - data->depths.array[i].depth = 0; - data->depths.array[i].index_at = 0; - data->depths.array[i].index_name = 0; - data->depths.array[i].value_at = 0; - - macro_f_string_dynamic_t_clear(data->depths.array[i].value_name); - - if (!main->parameters.array[fss_basic_list_read_parameter_depth_e].values.used) { - position_depth = 0; - } - else { - position_depth = main->parameters.array[fss_basic_list_read_parameter_depth_e].values.array[i]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[position_depth], &data->depths.array[i].depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_basic_list_read_long_depth_s, data->argv[position_depth]); - - return status; - } - } - - if (main->parameters.array[fss_basic_list_read_parameter_at_e].result & f_console_result_value_e) { - for (; position_at < main->parameters.array[fss_basic_list_read_parameter_at_e].values.used; ++position_at) { - - if (main->parameters.array[fss_basic_list_read_parameter_at_e].values.array[position_at] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_basic_list_read_parameter_at_e].values.array[position_at] > main->parameters.array[fss_basic_list_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_at = main->parameters.array[fss_basic_list_read_parameter_at_e].values.array[position_at]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[data->depths.array[i].index_at], &data->depths.array[i].value_at); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_basic_list_read_long_at_s, data->argv[data->depths.array[i].index_at]); - - return status; - } - } // for - } - - if (main->parameters.array[fss_basic_list_read_parameter_name_e].result & f_console_result_value_e) { - for (; position_name < main->parameters.array[fss_basic_list_read_parameter_name_e].values.used; ++position_name) { - - if (main->parameters.array[fss_basic_list_read_parameter_name_e].values.array[position_name] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_basic_list_read_parameter_name_e].values.array[position_name] > main->parameters.array[fss_basic_list_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_name = main->parameters.array[fss_basic_list_read_parameter_name_e].values.array[position_name]; - - if (main->parameters.array[fss_basic_list_read_parameter_trim_e].result & f_console_result_found_e) { - status = f_rip_dynamic(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - else { - status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), (main->parameters.array[fss_basic_list_read_parameter_trim_e].result & f_console_result_found_e) ? "f_rip_dynamic" : "f_string_dynamic_append", fll_error_file_flag_fallback_e); - - return status; - } - } // for - } - } // for - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' may only be specified once for the parameter '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_depth_s, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - - if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_basic_list_read_long_depth_s, main->error.notable); - fl_print_format("%[' may not have the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' before the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[j].depth, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - } // for - } // for - - return F_none; - } -#endif // _di_fss_basic_list_read_depth_process_ - -#ifndef _di_fss_basic_list_read_file_identify_ - f_string_static_t fss_basic_list_read_file_identify(const f_array_length_t at, const fss_basic_list_read_files_t files) { - - for (f_array_length_t i = 0; i < files.used; ++i) { - - if (at >= files.array[i].range.start && at <= files.array[i].range.stop) { - return files.array[i].name; - } - } // for - - // When stopped after the end of the buffer, the last file in the list is the correct file. - if (at > files.array[files.used - 1].range.stop) { - return files.array[files.used - 1].name; - } - - return f_string_empty_s; - } -#endif // _di_fss_basic_list_read_file_identify_ - -#ifndef _di_fss_basic_list_read_load_ - f_status_t fss_basic_list_read_load(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) { - - f_state_t state = macro_f_state_t_initialize_1(fss_basic_list_read_common_allocation_large_d, fss_basic_list_read_common_allocation_small_d, F_none, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); - f_string_range_t input = macro_f_string_range_t_initialize_2(data->buffer.used); - - data->delimits_object.used = 0; - data->delimits_content.used = 0; - - const f_status_t status = fll_fss_basic_list_read(data->buffer, state, &input, &data->objects, &data->contents, &data->delimits_object, &data->delimits_content, &data->comments); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_basic_list_read", fll_error_file_flag_fallback_e, fss_basic_list_read_file_identify(input.start, data->files), f_file_operation_process_s, fll_error_file_type_file_e); - - return status; - } - - if (status == F_data_not_stop || status == F_data_not_eos) { - if (data->option & fss_basic_list_read_data_option_total_d) return F_none; - - return F_status_set_warning(status); - } - - return F_none; - } -#endif // _di_fss_basic_list_read_load_ - -#ifndef _di_fss_basic_list_read_load_number_ - f_status_t fss_basic_list_read_load_number(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { - - if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - - const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, name, data->argv[index]); - - return status; - } - - return F_true; - } - - return F_false; - } -#endif // _di_fss_basic_list_read_load_number_ - -#ifndef _di_fss_basic_list_read_process_ - f_status_t fss_basic_list_read_process(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) { - - f_status_t status = fss_basic_list_read_process_option(main, data); - if (F_status_is_error(status)) return status; - - // This standard does not support multiple content groups. - if ((data->option & fss_basic_list_read_data_option_select_d) && data->select) { - if (main->parameters.array[fss_basic_list_read_parameter_total_e].result & f_console_result_found_e) { - f_file_stream_lock(main->output.to); - - fss_basic_list_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - - status = fss_basic_list_read_load(main, data); - if (F_status_is_error(status)) return status; - - bool names[data->objects.used]; - - status = fss_basic_list_read_process_name(data, names); - if (F_status_is_error(status)) return status; - - if (data->depths.array[0].index_at) { - return fss_basic_list_read_process_at(main, data, names); - } - - if (data->option & fss_basic_list_read_data_option_columns_d) { - return fss_basic_list_read_process_columns(main, data, names); - } - - if (data->option & fss_basic_list_read_data_option_total_d) { - return fss_basic_list_read_process_total(main, data, names); - } - - if (data->option & fss_basic_list_read_data_option_line_d) { - return fss_basic_list_read_process_line(main, data, names); - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_basic_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_basic_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - - if (data->option & fss_basic_list_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - fss_basic_list_read_print_at(main, i, *delimits_object, *delimits_content, data); - } // for - - return F_none; - } -#endif // _di_fss_basic_list_read_process_ - -#ifndef _di_fss_basic_list_read_process_at_ - f_status_t fss_basic_list_read_process_at(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) { - - if (data->depths.array[0].value_at >= data->objects.used) { - if (data->option & (fss_basic_list_read_data_option_columns_d | fss_basic_list_read_data_option_total_d)) { - f_file_stream_lock(main->output.to); - - fss_basic_list_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_basic_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_basic_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - - if (data->option & fss_basic_list_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t at = 0; - f_status_t status = F_none; - - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (at == data->depths.array[0].value_at) { - if (data->option & fss_basic_list_read_data_option_line_d) { - f_array_length_t line = 0; - - status = fss_basic_list_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); - if (status == F_success) return F_none; - } - else if (data->option & fss_basic_list_read_data_option_columns_d) { - fll_print_format("%ul%r", main->output.to, data->contents.array[i].used, f_string_eol_s); - } - else if (data->option & fss_basic_list_read_data_option_total_d) { - f_array_length_t total = 0; - f_array_length_t j = 0; - f_array_length_t k = 0; - - // Count each new line. - for (; j < data->contents.array[i].used; ++j) { - - if (data->contents.array[i].array[j].start > data->contents.array[i].array[j].stop) continue; - if (data->contents.array[i].array[j].start > data->buffer.used) continue; - - for (k = data->contents.array[i].array[j].start; k <= data->contents.array[i].array[j].stop && k < data->buffer.used; ++k) { - if (data->buffer.string[k] == f_string_eol_s.string[0]) ++total; - } // for - } // for - - // If there are no newline characters but there is data, then this represents a single line. - if (data->contents.array[i].used && !total) { - total = 1; - } - - fll_print_format("%ul%r", main->output.to, total, f_string_eol_s); - } - else { - fss_basic_list_read_print_at(main, i, *delimits_object, *delimits_content, data); - } - - return F_none; - } - - ++at; - } // for - - if (data->option & fss_basic_list_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_basic_list_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } -#endif // _di_fss_basic_list_read_process_at_ - -#ifndef _di_fss_basic_list_read_process_at_line_ - f_status_t fss_basic_list_read_process_at_line(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) { - - if (data->option & fss_basic_list_read_data_option_object_d) { - if (*line == data->line) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_basic_list_read_data_option_total_d) { - fss_basic_list_read_print_one(main); - } - else { - fss_basic_list_read_print_at_object(main, data, at, delimits_object); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - - ++(*line); - } - - // There is only a single Content column for this standard. - if (data->option & fss_basic_list_read_data_option_content_d) { - if (!data->contents.array[at].used) { - return F_none; - } - - f_string_range_t range = data->contents.array[at].array[0]; - f_array_length_t i = 0; - - // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - return F_none; - } - - for (i = range.start; i <= range.stop; ++i) { - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - if (*line == data->line) { - range.stop = i; - - f_file_stream_lock(main->output.to); - - if (data->option & fss_basic_list_read_data_option_total_d) { - fss_basic_list_read_print_one(main); - } - else { - f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - - range.start = i + 1; - - if (i <= range.stop) { - ++(*line); - } - } - } // for - - // If Content does not end with a newline, it still must be treated as the last line. - if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { - ++(*line); - - if (*line == data->line) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_basic_list_read_data_option_total_d) { - fss_basic_list_read_print_one(main); - } - else { - range.stop = data->contents.array[at].array[0].stop; - - f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - } - } - - return F_none; - } -#endif // _di_fss_basic_list_read_process_at_line_ - -#ifndef _di_fss_basic_list_read_process_columns_ - f_status_t fss_basic_list_read_process_columns(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) { - - if (!(data->option & fss_basic_list_read_data_option_content_d)) { - f_file_stream_lock(main->output.to); - - fss_basic_list_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - - return F_none; - } - - f_array_length_t max = 0; - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->contents.array[i].used > max) { - max = data->contents.array[i].used; - } - } // for - - fll_print_format("%ul%r", main->output.to, max, f_string_eol_s); - - return F_none; - } -#endif // _di_fss_basic_list_read_process_columns_ - -#ifndef _di_fss_basic_list_read_process_line_ - f_status_t fss_basic_list_read_process_line(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_basic_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_basic_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - - if (data->option & fss_basic_list_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t line = 0; - f_status_t status = F_none; - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - status = fss_basic_list_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); - if (status == F_success) break; - } // for - - return F_none; - } -#endif // _di_fss_basic_list_read_process_line_ - -#ifndef _di_fss_basic_list_read_process_name_ - f_status_t fss_basic_list_read_process_name(fss_basic_list_read_data_t *data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - - if (data->depths.array[0].index_name) { - memset(names, F_false, sizeof(bool) * data->objects.used); - - // This standard should always treat selected names as trimmed. - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_except_trim_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits_object) == F_equal_to) { - names[i] = F_true; - } - } // for - } - else { - memset(names, F_true, sizeof(bool) * data->objects.used); - } - - return F_none; - } -#endif // _di_fss_basic_list_read_process_name_ - -#ifndef _di_fss_basic_list_read_process_option_ - f_status_t fss_basic_list_read_process_option(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) { - - f_status_t status = F_none; - - if (main->parameters.array[fss_basic_list_read_parameter_at_e].result & f_console_result_value_e) { - data->option |= fss_basic_list_read_data_option_at_d; - } - - if (main->parameters.array[fss_basic_list_read_parameter_columns_e].result & f_console_result_found_e) { - data->option |= fss_basic_list_read_data_option_columns_d; - } - - if (main->parameters.array[fss_basic_list_read_parameter_content_e].result & f_console_result_found_e) { - data->option |= fss_basic_list_read_data_option_content_d; - } - - if (main->parameters.array[fss_basic_list_read_parameter_empty_e].result & f_console_result_found_e) { - data->option |= fss_basic_list_read_data_option_empty_d; - } - - if (main->parameters.array[fss_basic_list_read_parameter_line_e].result & f_console_result_value_e) { - data->option |= fss_basic_list_read_data_option_line_d; - - status = fss_basic_list_read_load_number(main, data, fss_basic_list_read_parameter_line_e, fss_basic_list_read_long_line_s, &data->line); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_basic_list_read_parameter_name_e].result & f_console_result_value_e) { - data->option |= fss_basic_list_read_data_option_name_d; - } - - if (main->parameters.array[fss_basic_list_read_parameter_object_e].result & f_console_result_found_e) { - data->option |= fss_basic_list_read_data_option_object_d; - } - - if (main->parameters.array[fss_basic_list_read_parameter_original_e].result & f_console_result_found_e) { - data->option |= fss_basic_list_read_data_option_original_d; - } - - if (main->parameters.array[fss_basic_list_read_parameter_select_e].result & f_console_result_value_e) { - data->option |= fss_basic_list_read_data_option_select_d; - - status = fss_basic_list_read_load_number(main, data, fss_basic_list_read_parameter_select_e, fss_basic_list_read_long_select_s, &data->select); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_basic_list_read_parameter_total_e].result & f_console_result_found_e) { - data->option |= fss_basic_list_read_data_option_total_d; - } - - if (main->parameters.array[fss_basic_list_read_parameter_trim_e].result & f_console_result_found_e) { - data->option |= fss_basic_list_read_data_option_trim_d; - } - - // Default to content if neither Object nor Content is explicitly requested. - if (!(data->option & (fss_basic_list_read_data_option_content_d | fss_basic_list_read_data_option_object_d))) { - data->option |= fss_basic_list_read_data_option_content_d; - } - - return F_none; - } -#endif // _di_fss_basic_list_read_process_option_ - -#ifndef _di_fss_basic_list_read_process_total_ - f_status_t fss_basic_list_read_process_total(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) { - - f_array_length_t total = 0; - f_string_range_t range = f_string_range_t_initialize; - f_array_length_t i = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->option & fss_basic_list_read_data_option_object_d) { - ++total; - } - - // There is only a single Content column for this standard. - if (data->option & fss_basic_list_read_data_option_content_d) { - - if (!data->contents.array[at].used) continue; - - range.start = data->contents.array[at].array[0].start; - range.stop = data->contents.array[at].array[0].stop; - - // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) continue; - - for (i = range.start; i <= range.stop; ++i) { - - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - range.start = i + 1; - - if (i <= range.stop) { - ++total; - } - } - } // for - - // If Content does not end with a newline, it still must be treated as the last line. - if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { - ++total; - } - } - } // for - - f_file_stream_lock(main->output.to); - - if (data->option & fss_basic_list_read_data_option_line_d) { - if (data->line < total) { - fss_basic_list_read_print_one(main); - } - else { - fss_basic_list_read_print_zero(main); - } - } - else { - fl_print_format("%ul%r", main->output.to, total, f_string_eol_s); - } - - f_file_stream_unlock(main->output.to); - - return F_none; - } -#endif // _di_fss_basic_list_read_process_total_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_list_read/c/private-read.h b/level_3/fss_basic_list_read/c/private-read.h deleted file mode 100644 index 4b708d4..0000000 --- a/level_3/fss_basic_list_read/c/private-read.h +++ /dev/null @@ -1,317 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_read_h -#define _PRIVATE_read_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Determine if the given depth is to be delimited or not for Content. - * - * @param data - * The program data. - * @param depth - * The depth to check. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_basic_list_read_delimit_content_is_ - extern f_status_t fss_basic_list_read_delimit_content_is(fss_basic_list_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_delimit_content_is_ - -/** - * Determine if the given depth is to be delimited or not for an Object. - * - * @param data - * The program data. - * @param depth - * The depth to check. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_basic_list_read_delimit_object_is_ - extern f_status_t fss_basic_list_read_delimit_object_is(fss_basic_list_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_delimit_object_is_ - -/** - * Process the parameters, parsing out and handling the depth and depth related parameters. - * - * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal. - * - * Errors (with error bit) from: f_string_append(). - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * Errors (with error bit) from: f_rip_dynamic(). - * - * Errors (with error bit) from: fss_basic_list_read_depths_resize(). - * - * @see f_string_append() - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * @see f_rip_dynamic() - * - * @see fss_basic_list_read_depths_resize() - */ -#ifndef _di_fss_basic_list_read_depth_process_ - extern f_status_t fss_basic_list_read_depth_process(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_depth_process_ - -/** - * Get the name of the file the given position represents within the buffer. - * - * @param at - * The position within the buffer. - * @param files - * The representation of files and their respective ranges within the buffer. - * - * @return - * A string with the name when found. - * NULL is returned if the range represents the STDIN pipe. - * - * On failure to identify, an empty string is returned. - */ -#ifndef _di_fss_basic_list_read_file_identify_ - extern f_string_static_t fss_basic_list_read_file_identify(const f_array_length_t at, const fss_basic_list_read_files_t files) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_file_identify_ - -/** - * Process the buffer, loading the FSS data. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * 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_basic_list_read_process_option() - */ -#ifndef _di_fss_basic_list_read_load_ - extern f_status_t fss_basic_list_read_load(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_load_ - -/** - * Load a given number parameter. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param parameter - * An ID representing the parameter. - * @param name - * The parameter name to print on error. - * @param number - * The location to store the loaded number. - * - * @return - * F_true on success and the parameter was found (and is valid). - * F_false on success and the parameter was not found. - * - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * - * @see fss_basic_list_read_depths_resize() - */ -#ifndef _di_fss_basic_list_read_load_number_ - extern f_status_t fss_basic_list_read_load_number(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_load_number_ - -/** - * Perform the basic list read processing on the buffer. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_basic_list_read_load() - * Errors (with error bit) from: fss_basic_list_read_process_option() - * - * @see fss_basic_list_read_load() - * @see fss_basic_list_read_process_option() - */ -#ifndef _di_fss_basic_list_read_process_ - extern f_status_t fss_basic_list_read_process(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_ - -/** - * Process based on at parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - * - * @see fss_basic_list_read_process_at_line() - */ -#ifndef _di_fss_basic_list_read_process_at_ - extern f_status_t fss_basic_list_read_process_at(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_at_ - -/** - * Process based on at parameter for some line. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param at - * The position within the buffer. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param line - * The current line being processed. - * This will be incremented as necessary. - * - * @return - * F_none on success but no line was matched (and possibly printed). - * F_success on success and the line was matched (and possibly printed). - */ -#ifndef _di_fss_basic_list_read_process_at_line_ - extern f_status_t fss_basic_list_read_process_at_line(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_at_line_ - -/** - * Process based on columns parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_list_read_process_columns_ - extern f_status_t fss_basic_list_read_process_columns(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_columns_ - -/** - * Process based on line parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_list_read_process_line_ - extern f_status_t fss_basic_list_read_process_line(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_line_ - -/** - * Process the Objects in the buffer, determining if the Object name is to be used or not. - * - * How an Object name is determined to be used or not is dependent on several parameters, such as --name, --depth, --at, and --line. - * - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_list_read_process_name_ - extern f_status_t fss_basic_list_read_process_name(fss_basic_list_read_data_t *data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_name_ - -/** - * Process the parameters, populating the option property of the program data. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_basic_list_read_load_setting() - * - * @see fll_fss_basic_list_read() - * - * @see fss_basic_list_read_load_setting() - */ -#ifndef _di_fss_basic_list_read_process_option_ - extern f_status_t fss_basic_list_read_process_option(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_option_ - -/** - * Process based on total parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_list_read_process_total_ - extern f_status_t fss_basic_list_read_process_total(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_process_total_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_read_h diff --git a/level_3/fss_basic_list_read/data/build/defines b/level_3/fss_basic_list_read/data/build/defines deleted file mode 100644 index 490da41..0000000 --- a/level_3/fss_basic_list_read/data/build/defines +++ /dev/null @@ -1,6 +0,0 @@ -# fss-0000 - -_di_thread_support_ Disables thread support. - -_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. -_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/fss_basic_list_read/data/build/dependencies b/level_3/fss_basic_list_read/data/build/dependencies deleted file mode 100644 index 22cdeb6..0000000 --- a/level_3/fss_basic_list_read/data/build/dependencies +++ /dev/null @@ -1,31 +0,0 @@ -# fss-0000 - -f_type -f_status -f_memory -f_type_array -f_string -f_utf -f_color -f_compare -f_console -f_conversion -f_directory -f_environment -f_file -f_fss -f_parse -f_pipe -f_print -f_rip -f_signal - -fl_conversion -fl_fss -fl_print - -fll_error -fll_file -fll_fss -fll_print -fll_program diff --git a/level_3/fss_basic_list_read/data/build/fakefile b/level_3/fss_basic_list_read/data/build/fakefile deleted file mode 100644 index 1770d3f..0000000 --- a/level_3/fss_basic_list_read/data/build/fakefile +++ /dev/null @@ -1,27 +0,0 @@ -# fss-0005 iki-0002 - -settings: - fail exit - modes individual individual_thread level monolithic clang test fanalyzer thread threadless - - environment PATH LD_LIBRARY_PATH - environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -main: - build - -install: - shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' - -help: - print - print context:'title'Fakefile Options for FS Basic List Read Software.context:'reset' - - print - print The following operations are available\: - print " - context:'notable'help:context:'reset' Perform the help operation, printing this message." - print " - context:'notable'install:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." - print " - context:'notable'main:context:'reset' The default compilation using the build settings mode." - - print - print The context:'notable'install context:'reset'operation supports the context:'notable'work,context:'reset' context:'notable'verbosity,context:'reset' and context:'notable'color context:'reset'parameters. diff --git a/level_3/fss_basic_list_read/data/build/settings b/level_3/fss_basic_list_read/data/build/settings deleted file mode 100644 index ae97d9e..0000000 --- a/level_3/fss_basic_list_read/data/build/settings +++ /dev/null @@ -1,85 +0,0 @@ -# fss-0001 -# -# Modes: -# - individual: Compile using per project (individual) libraries, does not handle thread or threadless cases. -# - individual_thread: This is required when compiling in individual mode with "thread" mode. -# - level: Compile using per level libraries. -# - monolithic: Compile using per monolithic libraries. -# - clang: Use clang rather than the default, which is generally gcc. -# - test: Compile for a test, such as unit testing. -# - fanalyzer: Compile using GCC's -fanalyzer compile time option. -# - thread: Compile with thread support. -# - threadless: Compile without thread support. -# - -build_name fss_basic_list_read - -version_major 0 -version_minor 7 -version_micro 0 -version_file micro -version_target minor - -modes individual individual_thread level monolithic clang test fanalyzer thread threadless -modes_default monolithic thread - -build_compiler gcc -build_compiler-clang clang -build_indexer ar -build_indexer_arguments rcs -build_language c - -build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_parse -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_status_string -lf_string -lf_type_array -lf_utf -build_libraries-individual_thread -lf_thread -build_libraries-level -lfll_2 -lfll_1 -lfll_0 -build_libraries-monolithic -lfll - -build_sources_library fss_basic_list_read.c common.c print.c private-common.c private-print.c private-read.c - -build_sources_program main.c - -build_sources_headers fss_basic_list_read.h common.h print.h - -build_sources_documentation man - -build_script yes -build_shared yes -build_static no - -path_headers program/fss_basic_list_read -path_library_script script -path_library_shared shared -path_library_static static -path_object_script script -path_object_shared shared -path_object_static static -path_program_script script -path_program_shared shared -path_program_static static - -has_path_standard yes -preserve_path_headers yes - -search_exclusive yes -search_shared yes -search_static yes - -environment PATH LD_LIBRARY_PATH -environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -#defines -D_di_libcap_ -defines -D_libcap_legacy_only_ -defines-threadless -D_di_thread_support_ -defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ - -flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces -flags-thread -pthread -flags-clang -Wno-logical-op-parentheses -flags-test -O0 -fstack-protector -Wall -flags-fanalyzer -fanalyzer -flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ - -flags_library -fPIC -flags_object -fPIC -flags_program -fPIE diff --git a/level_3/fss_basic_list_read/data/documentation/man/man1/fss_basic_list_read.1 b/level_3/fss_basic_list_read/data/documentation/man/man1/fss_basic_list_read.1 deleted file mode 100644 index 03d3bbb..0000000 --- a/level_3/fss_basic_list_read/data/documentation/man/man1/fss_basic_list_read.1 +++ /dev/null @@ -1,145 +0,0 @@ -.TH FSS_BASIC_LIST_READ "1" "March 2023" "FLL - FSS Basic List Read 0.7.0" "User Commands" -.SH NAME -fss_basic_list_read \- Read data in \fBFSS-0003 (Basic List)\fR format. -.SH SYNOPSIS -.B fss_basic_list_read -[\fI\,OPTIONS\/\fR] [\fI\,FILENAMES\/\fR] -.SH DESCRIPTION -.PP -This program will print the Content associated with the given Object and Content main based on the \fBFSS-0002 Basic List\fR standard. - -All numeric positions (indexes) start at 0 instead of 1. -For example, a file of 17 lines would range from 0 to 16. - -When using the \fB\-\-depth\fR option, an order of operations is enforced on the parameters. -When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter: - \fB\-\-at\fR: An Object index at the specified depth. - \fB\-\-depth\fR: A new depth within the specified depth, indexed from the root. - \fB\-\-name\fR: An Object name at the specified depth. - -The parameter \fB\-\-depth\fR must be in numeric order, but values in between may be skipped. - ('\fB\-d 0 \-a 1 \-d 2 \-a 2\fR' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.) - ('\fB\-d 2 \-a 1 \-d 0 \-a 2\fR' would be invalid because depth 2 is before depth 1.) - -The parameter \fB\-\-select\fR selects a Content column. - -Specify both \fB\-\-object\fR and the \fB\-\-total\fR parameters to get the total objects. - -When both \fB\-\-at\fR and \fB\-\-name\fR parameters are specified (at the same depth), the \fB\-\-at\fR parameter value will be treated as a position relative to the specified \fB\-\-name\fR parameter value. - -This program may support parameters, such as \fB\-\-depth\fR or \fB\-\-select\fR, even if not supported by the standard. -This is done to help ensure consistency for scripting. - -For parameters like \fB\-\-depth\fR, if the standard doesn't support nested Content, then only a depth of 0 would be valid. -For parameters like \fB\-\-select\fR, if the standard doesn't support multiple Content groups, then only a select of 0 would be valid. - -The parameter \fB\-\-trim\fR will remove leading and trailing white spaces when selecting objects or when printing objects. - -When specifying both the \fB\-\-object\fR parameter and the \fB\-\-content\fR parameter, the entire Object and Content are printed, including the formatting. -Both the Object and Content printed are already escaped. -Both the Object and Content are separated by a New Line character '\fB\\n\fR' (U+000A). - -The parameter \fB\-\-delimit\fR accepts the following: - \fBnone\fR: Do not apply delimits. - \fBall\fR: (default) Apply all delimits. - \fBobject\fR: Apply delimits for Objects. - \fBA number, 0 or greater\fR: apply delimits for Content at the specified depth. - \fBA number, 0 or greater, followed by a +\fR: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically). - \fBA number, 0 or lesser, followed by a \-\fR: (such as '1\-') apply delimits for Content at the specified depth and any lesser depth (numerically). - -The \fB\-\-delimit\fR parameter may be specified multiple times to customize the delimit behavior. -The \fB\-\-delimit\fR values none and all, overrule all other delimit values. - -The parameters \fB\-\-columns\fR and \fB\-\-select\fR refer to a Content column. -The word '\fBcolumn\fR' is being loosely defined to refer to a specific Content. -This is not to be confused with a depth. -.SH OPTIONS -.TP -\fB\{\-h, \-\-help\fR -Print the help message. -.TP -\fB+C, ++copyright\fR -Print the copyright. -.TP -\fB+d, ++dark\fR -Output using colors that show up better on dark backgrounds. -.TP -\fB+l, ++light\fR -Output using colors that show up better on light backgrounds. -.TP -\fB+n, ++no_color\fR -Do not print using color. -.TP -\fB+Q, ++quiet\fR -Decrease verbosity, silencing most output. -.TP -\fB+E, ++error\fR -Decrease verbosity, using only error output. -.TP -\fB+N, ++normal\fR -Set verbosity to normal. -.TP -\fB+V, ++verbose\fR -Increase verbosity beyond normal output. -.TP -\fB+D, ++debug\fR -Enable debugging, significantly increasing verbosity beyond normal output. -.TP -\fB+v, ++version\fR -Print only the version number. -.TP -\fB+F, ++line_first_no\fR -Disable printing of first line. -.TP -\fB+L, ++line_last_no\fR -Disable printing of last line. -.TP -\fB\-a, \-\-at\fR -Select Object at this numeric index. -.TP -\fB\-c, \-\-content\fR -Print the Content (default). -.TP -\fB\-C, \-\-columns\fR -Print the total number of columns. -.TP -\fB\-D, \-\-delimit\fR -Designate how to handle applying delimits. -.TP -\fB\-d, \-\-depth\fR -Select Object at this numeric depth. -.TP -\fB\-e, \-\-empty\fR -Include empty Content when processing. -.TP -\fB\-l, \-\-line\fR -Print only the Content at the given line. -.TP -\fB\-n, \-\-name\fR -Select Object with this name. -.TP -\fB\-o, \-\-object\fR -Print the Object. -.TP -\fB\-p, \-\-pipe\fR -Print using the special pipe format. -.TP -\fB\-O, \-\-original\fR -Print with the original quotes and escapes. -.TP -\fB\-s, \-\-select\fR -Select sub-Content at this index. -.TP -\fB\-t, \-\-total\fR -Print the total number of lines. -.TP -\fB\-T, \-\-trim\fR -Trim Object names on select or print. -.SH FILENAMES -.TP -Any number of files to read. -.SH AUTHOR -Written by Kevin Day. -.SH COPYRIGHT -.PP -Copyright \(co 2007-2023 Kevin Day, GNU LGPL Version 2.1 or later. diff --git a/level_3/fss_basic_read/c/common.c b/level_3/fss_basic_read/c/common.c deleted file mode 100644 index 9b99afd..0000000 --- a/level_3/fss_basic_read/c/common.c +++ /dev/null @@ -1,198 +0,0 @@ -#include "fss_basic_read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_read_program_version_s_ - const f_string_static_t fss_basic_read_program_version_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_program_version_s, 0, FSS_BASIC_READ_program_version_s_length); -#endif // _di_fss_basic_read_program_version_s_ - -#ifndef _di_fss_basic_read_program_name_s_ - const f_string_static_t fss_basic_read_program_name_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_program_name_s, 0, FSS_BASIC_READ_program_name_s_length); - const f_string_static_t fss_basic_read_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_program_name_long_s, 0, FSS_BASIC_READ_program_name_long_s_length); -#endif // _di_fss_basic_read_program_name_s_ - -#ifndef _di_fss_basic_read_pipe_s_ - const f_string_static_t fss_basic_read_pipe_name_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_pipe_name_s, 0, FSS_BASIC_READ_pipe_name_s_length); - const f_string_static_t fss_basic_read_pipe_content_end_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_pipe_content_end_s, 0, FSS_BASIC_READ_pipe_content_end_s_length); - const f_string_static_t fss_basic_read_pipe_content_ignore_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_pipe_content_ignore_s, 0, FSS_BASIC_READ_pipe_content_ignore_s_length); - const f_string_static_t fss_basic_read_pipe_content_start_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_pipe_content_start_s, 0, FSS_BASIC_READ_pipe_content_start_s_length); -#endif // _di_fss_basic_read_pipe_s_ - -#ifndef _di_fss_basic_read_parameter_d_ - const f_string_static_t fss_basic_read_short_at_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_at_s, 0, FSS_BASIC_READ_short_at_s_length); - const f_string_static_t fss_basic_read_short_content_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_content_s, 0, FSS_BASIC_READ_short_content_s_length); - const f_string_static_t fss_basic_read_short_columns_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_columns_s, 0, FSS_BASIC_READ_short_columns_s_length); - const f_string_static_t fss_basic_read_short_delimit_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_delimit_s, 0, FSS_BASIC_READ_short_delimit_s_length); - const f_string_static_t fss_basic_read_short_depth_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_depth_s, 0, FSS_BASIC_READ_short_depth_s_length); - const f_string_static_t fss_basic_read_short_empty_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_empty_s, 0, FSS_BASIC_READ_short_empty_s_length); - const f_string_static_t fss_basic_read_short_line_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_line_s, 0, FSS_BASIC_READ_short_line_s_length); - const f_string_static_t fss_basic_read_short_name_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_name_s, 0, FSS_BASIC_READ_short_name_s_length); - const f_string_static_t fss_basic_read_short_object_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_object_s, 0, FSS_BASIC_READ_short_object_s_length); - const f_string_static_t fss_basic_read_short_pipe_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_pipe_s, 0, FSS_BASIC_READ_short_pipe_s_length); - const f_string_static_t fss_basic_read_short_original_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_original_s, 0, FSS_BASIC_READ_short_original_s_length); - const f_string_static_t fss_basic_read_short_select_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_select_s, 0, FSS_BASIC_READ_short_select_s_length); - const f_string_static_t fss_basic_read_short_total_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_total_s, 0, FSS_BASIC_READ_short_total_s_length); - const f_string_static_t fss_basic_read_short_trim_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_short_trim_s, 0, FSS_BASIC_READ_short_trim_s_length); - - const f_string_static_t fss_basic_read_long_at_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_at_s, 0, FSS_BASIC_READ_long_at_s_length); - const f_string_static_t fss_basic_read_long_content_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_content_s, 0, FSS_BASIC_READ_long_content_s_length); - const f_string_static_t fss_basic_read_long_columns_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_columns_s, 0, FSS_BASIC_READ_long_columns_s_length); - const f_string_static_t fss_basic_read_long_delimit_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_delimit_s, 0, FSS_BASIC_READ_long_delimit_s_length); - const f_string_static_t fss_basic_read_long_depth_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_depth_s, 0, FSS_BASIC_READ_long_depth_s_length); - const f_string_static_t fss_basic_read_long_empty_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_empty_s, 0, FSS_BASIC_READ_long_empty_s_length); - const f_string_static_t fss_basic_read_long_line_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_line_s, 0, FSS_BASIC_READ_long_line_s_length); - const f_string_static_t fss_basic_read_long_name_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_name_s, 0, FSS_BASIC_READ_long_name_s_length); - const f_string_static_t fss_basic_read_long_object_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_object_s, 0, FSS_BASIC_READ_long_object_s_length); - const f_string_static_t fss_basic_read_long_pipe_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_pipe_s, 0, FSS_BASIC_READ_long_pipe_s_length); - const f_string_static_t fss_basic_read_long_original_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_original_s, 0, FSS_BASIC_READ_long_original_s_length); - const f_string_static_t fss_basic_read_long_select_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_select_s, 0, FSS_BASIC_READ_long_select_s_length); - const f_string_static_t fss_basic_read_long_total_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_total_s, 0, FSS_BASIC_READ_long_total_s_length); - const f_string_static_t fss_basic_read_long_trim_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_long_trim_s, 0, FSS_BASIC_READ_long_trim_s_length); -#endif // _di_fss_basic_read_parameter_d_ - -#ifndef _di_fss_basic_read_delimit_mode_s_ - const f_string_static_t fss_basic_read_delimit_mode_name_none_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_delimit_mode_name_none_s, 0, FSS_BASIC_READ_delimit_mode_name_none_s_length); - const f_string_static_t fss_basic_read_delimit_mode_name_all_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_delimit_mode_name_all_s, 0, FSS_BASIC_READ_delimit_mode_name_all_s_length); - const f_string_static_t fss_basic_read_delimit_mode_name_object_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_delimit_mode_name_object_s, 0, FSS_BASIC_READ_delimit_mode_name_object_s_length); - const f_string_static_t fss_basic_read_delimit_mode_name_greater_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_delimit_mode_name_greater_s, 0, FSS_BASIC_READ_delimit_mode_name_greater_s_length); - const f_string_static_t fss_basic_read_delimit_mode_name_lesser_s = macro_f_string_static_t_initialize_1(FSS_BASIC_READ_delimit_mode_name_lesser_s, 0, FSS_BASIC_READ_delimit_mode_name_lesser_s_length); -#endif // _di_fss_basic_read_delimit_mode_s_ - -#ifndef _di_fss_basic_read_setting_delete_ - f_status_t fss_basic_read_setting_delete(fss_basic_read_setting_t * const setting) { - - if (!setting) return F_status_set_error(F_parameter); - - return F_none; - } -#endif // _di_fss_basic_read_setting_delete_ - -#ifndef _di_fss_basic_read_setting_load_ - void fss_basic_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_read_setting_t * const setting) { - - if (!main) return; - - main->setting.state.step_small = fss_basic_read_allocation_console_d; - - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - - main->setting.state.step_small = fss_basic_read_allocation_small_d; - - // Identify and pocess first/last parameters. - if (main->program.parameters.array[fss_basic_read_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_basic_read_main_flag_print_first_e; - } - else { - main->setting.flag |= fss_basic_read_main_flag_print_first_e; - } - - if (main->program.parameters.array[fss_basic_read_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_basic_read_main_flag_print_last_e; - } - else { - main->setting.flag |= fss_basic_read_main_flag_print_last_e; - } - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_basic_read_parameter_no_color_e, fss_basic_read_parameter_light_e, fss_basic_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_basic_read_parameter_verbosity_quiet_e, fss_basic_read_parameter_verbosity_error_e, fss_basic_read_parameter_verbosity_verbose_e, fss_basic_read_parameter_verbosity_debug_e, fss_basic_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - static const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - } - - main->program.output.to.id = F_type_descriptor_output_d; - main->program.output.to.stream = F_type_output_d; - main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - - if (main->program.parameters.array[fss_basic_read_parameter_help_e].result & f_console_result_found_e) { - main->setting.flag |= fss_basic_read_main_flag_help_e; - - return; - } - - if (main->program.parameters.array[fss_basic_read_parameter_version_e].result & f_console_result_found_e) { - main->setting.flag |= fss_basic_read_main_flag_version_e; - - return; - } - - if (main->program.parameters.array[fss_basic_read_parameter_copyright_e].result & f_console_result_found_e) { - main->setting.flag |= fss_basic_read_main_flag_copyright_e; - - return; - } - - f_string_static_t * const args = main->program.parameters.arguments.array; - - if (main->program.parameters.array[fss_basic_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - main->setting.flag |= fss_basic_read_main_flag_strip_invalid_e; - } - } -#endif // _di_fss_basic_read_setting_load_ - -#ifndef _di_fss_basic_read_setting_unload_ - f_status_t fss_basic_read_setting_unload(fss_basic_read_main_t * const main) { - - if (!main) return F_status_set_error(F_parameter); - - fss_basic_read_setting_delete(&main->setting); - - return F_none; - } -#endif // _di_fss_basic_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_read/c/common.h b/level_3/fss_basic_read/c/common.h deleted file mode 100644 index 465ea77..0000000 --- a/level_3/fss_basic_read/c/common.h +++ /dev/null @@ -1,433 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the common data structures. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _fss_basic_read_common_h -#define _fss_basic_read_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The program version. - */ -#ifndef _di_fss_basic_read_program_version_s_ - #define FSS_BASIC_READ_program_version_major_s F_string_ascii_0_s - #define FSS_BASIC_READ_program_version_minor_s F_string_ascii_7_s - #define FSS_BASIC_READ_program_version_micro_s F_string_ascii_0_s - - #define FSS_BASIC_READ_program_version_major_s_length F_string_ascii_0_s_length - #define FSS_BASIC_READ_program_version_minor_s_length F_string_ascii_7_s_length - #define FSS_BASIC_READ_program_version_micro_s_length F_string_ascii_0_s_length - - #if !(defined(FSS_BASIC_READ_program_version_nano_prefix_s) && defined(FSS_BASIC_READ_program_version_nano_prefix_s_length)) - #define FSS_BASIC_READ_program_version_nano_prefix_s - #define FSS_BASIC_READ_program_version_nano_prefix_s_length 0 - #endif // !(defined(FSS_BASIC_READ_program_version_nano_prefix_s) && defined(FSS_BASIC_READ_program_version_nano_prefix_s_length)) - - #if !(defined(FSS_BASIC_READ_program_version_nano_s) && defined(FSS_BASIC_READ_program_version_nano_s_length)) - #define FSS_BASIC_READ_program_version_nano_s - #define FSS_BASIC_READ_program_version_nano_s_length 0 - #endif // !(defined(FSS_BASIC_READ_program_version_nano_s) && defined(FSS_BASIC_READ_program_version_nano_s_length)) - - #define FSS_BASIC_READ_program_version_s FSS_BASIC_READ_program_version_major_s F_string_ascii_period_s FSS_BASIC_READ_program_version_minor_s F_string_ascii_period_s FSS_BASIC_READ_program_version_micro_s FSS_BASIC_READ_program_version_nano_prefix_s FSS_BASIC_READ_program_version_nano_s - - #define FSS_BASIC_READ_program_version_s_length FSS_BASIC_READ_program_version_major_s_length + F_string_ascii_period_s_length + FSS_BASIC_READ_program_version_minor_s_length + F_string_ascii_period_s_length + FSS_BASIC_READ_program_version_micro_s_length + FSS_BASIC_READ_program_version_nano_prefix_s_length + FSS_BASIC_READ_program_version_nano_s_length - - extern const f_string_static_t fss_basic_read_program_version_s; -#endif // _di_fss_basic_read_program_version_s_ - -/** - * The program name. - */ -#ifndef _di_fss_basic_read_program_name_s_ - #define FSS_BASIC_READ_program_name_s "fss_basic_read" - #define FSS_BASIC_READ_program_name_long_s "FSS Basic Read" - - #define FSS_BASIC_READ_program_name_s_length 14 - #define FSS_BASIC_READ_program_name_long_s_length 14 - - extern const f_string_static_t fss_basic_read_program_name_s; - extern const f_string_static_t fss_basic_read_program_name_long_s; -#endif // _di_fss_basic_read_program_name_s_ - -/** - * The program defines. - * - * fss_basic_read_*_d: - * - allocation_console: An allocation step used for small buffers specifically for console parameter. - * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. - * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. - * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. - */ -#ifndef _di_fss_basic_read_d_ - #define fss_basic_read_allocation_console_d 4 - #define fss_basic_read_allocation_large_d 256 - #define fss_basic_read_allocation_small_d 16 - #define fss_basic_read_signal_check_d 20000 -#endif // _di_fss_basic_read_d_ - -/** - * The program pipe strings. - * - * fss_basic_read_pipe_*: - * - name: A name used to represent the pipe when printing file names. - * - content_end: A code used to represent the end of Content for use in binary formats. - * - content_ignore: A code used to represent the ignoring Content for use in binary formats. - * - content_start: A code used to represent the start of Content for use in binary formats. - */ -#ifndef _di_fss_basic_read_pipe_s_ - #define FSS_BASIC_READ_pipe_name_s "(pipe)" - - #define FSS_BASIC_READ_pipe_content_end_s "\f" - #define FSS_BASIC_READ_pipe_content_ignore_s "\v" - #define FSS_BASIC_READ_pipe_content_start_s "\b" - - #define FSS_BASIC_READ_pipe_name_s_length 6 - - #define FSS_BASIC_READ_pipe_content_end_s_length 1 - #define FSS_BASIC_READ_pipe_content_ignore_s_length 1 - #define FSS_BASIC_READ_pipe_content_start_s_length 1 - - extern const f_string_static_t fss_basic_read_pipe_name_s; - - extern const f_string_static_t fss_basic_read_pipe_content_end_s; - extern const f_string_static_t fss_basic_read_pipe_content_ignore_s; - extern const f_string_static_t fss_basic_read_pipe_content_start_s; -#endif // _di_fss_basic_read_pipe_s_ - -/** - * The main program parameters. - */ -#ifndef _di_fss_basic_read_parameter_d_ - #define FSS_BASIC_READ_short_at_s "a" - #define FSS_BASIC_READ_short_content_s "c" - #define FSS_BASIC_READ_short_columns_s "C" - #define FSS_BASIC_READ_short_delimit_s "D" - #define FSS_BASIC_READ_short_depth_s "d" - #define FSS_BASIC_READ_short_empty_s "e" - #define FSS_BASIC_READ_short_line_s "l" - #define FSS_BASIC_READ_short_name_s "n" - #define FSS_BASIC_READ_short_object_s "o" - #define FSS_BASIC_READ_short_pipe_s "p" - #define FSS_BASIC_READ_short_original_s "O" - #define FSS_BASIC_READ_short_select_s "s" - #define FSS_BASIC_READ_short_total_s "t" - #define FSS_BASIC_READ_short_trim_s "T" - - #define FSS_BASIC_READ_long_at_s "at" - #define FSS_BASIC_READ_long_content_s "content" - #define FSS_BASIC_READ_long_columns_s "columns" - #define FSS_BASIC_READ_long_delimit_s "delimit" - #define FSS_BASIC_READ_long_depth_s "depth" - #define FSS_BASIC_READ_long_empty_s "empty" - #define FSS_BASIC_READ_long_line_s "line" - #define FSS_BASIC_READ_long_name_s "name" - #define FSS_BASIC_READ_long_object_s "object" - #define FSS_BASIC_READ_long_pipe_s "pipe" - #define FSS_BASIC_READ_long_original_s "original" - #define FSS_BASIC_READ_long_select_s "select" - #define FSS_BASIC_READ_long_total_s "total" - #define FSS_BASIC_READ_long_trim_s "trim" - - #define FSS_BASIC_READ_short_at_s_length 1 - #define FSS_BASIC_READ_short_content_s_length 1 - #define FSS_BASIC_READ_short_columns_s_length 1 - #define FSS_BASIC_READ_short_delimit_s_length 1 - #define FSS_BASIC_READ_short_depth_s_length 1 - #define FSS_BASIC_READ_short_empty_s_length 1 - #define FSS_BASIC_READ_short_line_s_length 1 - #define FSS_BASIC_READ_short_name_s_length 1 - #define FSS_BASIC_READ_short_object_s_length 1 - #define FSS_BASIC_READ_short_pipe_s_length 1 - #define FSS_BASIC_READ_short_original_s_length 1 - #define FSS_BASIC_READ_short_select_s_length 1 - #define FSS_BASIC_READ_short_total_s_length 1 - #define FSS_BASIC_READ_short_trim_s_length 1 - - #define FSS_BASIC_READ_long_at_s_length 2 - #define FSS_BASIC_READ_long_content_s_length 7 - #define FSS_BASIC_READ_long_columns_s_length 7 - #define FSS_BASIC_READ_long_delimit_s_length 7 - #define FSS_BASIC_READ_long_depth_s_length 5 - #define FSS_BASIC_READ_long_empty_s_length 5 - #define FSS_BASIC_READ_long_line_s_length 4 - #define FSS_BASIC_READ_long_name_s_length 4 - #define FSS_BASIC_READ_long_object_s_length 6 - #define FSS_BASIC_READ_long_pipe_s_length 4 - #define FSS_BASIC_READ_long_original_s_length 8 - #define FSS_BASIC_READ_long_select_s_length 6 - #define FSS_BASIC_READ_long_total_s_length 5 - #define FSS_BASIC_READ_long_trim_s_length 4 - - extern const f_string_static_t fss_basic_read_short_at_s; - extern const f_string_static_t fss_basic_read_short_content_s; - extern const f_string_static_t fss_basic_read_short_columns_s; - extern const f_string_static_t fss_basic_read_short_delimit_s; - extern const f_string_static_t fss_basic_read_short_depth_s; - extern const f_string_static_t fss_basic_read_short_empty_s; - extern const f_string_static_t fss_basic_read_short_line_s; - extern const f_string_static_t fss_basic_read_short_name_s; - extern const f_string_static_t fss_basic_read_short_object_s; - extern const f_string_static_t fss_basic_read_short_pipe_s; - extern const f_string_static_t fss_basic_read_short_original_s; - extern const f_string_static_t fss_basic_read_short_select_s; - extern const f_string_static_t fss_basic_read_short_total_s; - extern const f_string_static_t fss_basic_read_short_trim_s; - - extern const f_string_static_t fss_basic_read_long_at_s; - extern const f_string_static_t fss_basic_read_long_content_s; - extern const f_string_static_t fss_basic_read_long_columns_s; - extern const f_string_static_t fss_basic_read_long_delimit_s; - extern const f_string_static_t fss_basic_read_long_depth_s; - extern const f_string_static_t fss_basic_read_long_empty_s; - extern const f_string_static_t fss_basic_read_long_line_s; - extern const f_string_static_t fss_basic_read_long_name_s; - extern const f_string_static_t fss_basic_read_long_object_s; - extern const f_string_static_t fss_basic_read_long_pipe_s; - extern const f_string_static_t fss_basic_read_long_original_s; - extern const f_string_static_t fss_basic_read_long_select_s; - extern const f_string_static_t fss_basic_read_long_total_s; - extern const f_string_static_t fss_basic_read_long_trim_s; - - enum { - fss_basic_read_parameter_help_e, - fss_basic_read_parameter_copyright_e, - fss_basic_read_parameter_light_e, - fss_basic_read_parameter_dark_e, - fss_basic_read_parameter_no_color_e, - fss_basic_read_parameter_verbosity_quiet_e, - fss_basic_read_parameter_verbosity_error_e, - fss_basic_read_parameter_verbosity_normal_e, - fss_basic_read_parameter_verbosity_verbose_e, - fss_basic_read_parameter_verbosity_debug_e, - fss_basic_read_parameter_version_e, - fss_basic_read_parameter_line_first_no_e, - fss_basic_read_parameter_line_last_no_e, - - fss_basic_read_parameter_at_e, - fss_basic_read_parameter_content_e, - fss_basic_read_parameter_columns_e, - fss_basic_read_parameter_delimit_e, - fss_basic_read_parameter_depth_e, - fss_basic_read_parameter_empty_e, - fss_basic_read_parameter_line_e, - fss_basic_read_parameter_name_e, - fss_basic_read_parameter_object_e, - fss_basic_read_parameter_pipe_e, - fss_basic_read_parameter_original_e, - fss_basic_read_parameter_select_e, - fss_basic_read_parameter_total_e, - fss_basic_read_parameter_trim_e, - }; // enum - - #define fss_basic_read_console_parameter_t_initialize \ - { \ - macro_fll_program_console_parameter_standard_initialize, \ - \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_at_s, fss_basic_read_long_at_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_content_s, fss_basic_read_long_content_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_columns_s, fss_basic_read_long_columns_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_delimit_s, fss_basic_read_long_delimit_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_depth_s, fss_basic_read_long_depth_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_empty_s, fss_basic_read_long_empty_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_line_s, fss_basic_read_long_line_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_name_s, fss_basic_read_long_name_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_object_s, fss_basic_read_long_object_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_pipe_s, fss_basic_read_long_pipe_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_original_s, fss_basic_read_long_original_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_select_s, fss_basic_read_long_select_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_total_s, fss_basic_read_long_total_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_basic_read_short_trim_s, fss_basic_read_long_trim_s, 0, 0, f_console_flag_normal_e), \ - } - - #define fss_basic_read_total_parameters_d 27 -#endif // _di_fss_basic_read_parameter_d_ - -/** - * FSS Delimit Parameter strings. - * - * fss_basic_read_delimit_mode_*: - * - all: All delimits are to be aplied. - * - content: Content are to have delimits applied. - * - content_greater: Content at this number or higher are to have delimits applied. - * - content_greater_object: Objects and Content at this number or higher are to have delimits applied. - * - content_lesser: Content at this number or lower are to have delimits applied. - * - content_lesser_object: Objects and Content at this number or lower are to have delimits applied. - * - content_object: Objects and Content are to have delimits applied - * - object: Objects arre to have delimits applied. - */ -#ifndef _di_fss_basic_read_delimit_mode_s_ - #define FSS_BASIC_READ_delimit_mode_name_none_s "none" - #define FSS_BASIC_READ_delimit_mode_name_all_s "all" - #define FSS_BASIC_READ_delimit_mode_name_object_s "object" - #define FSS_BASIC_READ_delimit_mode_name_greater_s "+" - #define FSS_BASIC_READ_delimit_mode_name_lesser_s "-" - - #define FSS_BASIC_READ_delimit_mode_name_none_s_length 4 - #define FSS_BASIC_READ_delimit_mode_name_all_s_length 3 - #define FSS_BASIC_READ_delimit_mode_name_object_s_length 6 - #define FSS_BASIC_READ_delimit_mode_name_greater_s_length 1 - #define FSS_BASIC_READ_delimit_mode_name_lesser_s_length 1 - - extern const f_string_static_t fss_basic_read_delimit_mode_name_none_s; - extern const f_string_static_t fss_basic_read_delimit_mode_name_all_s; - extern const f_string_static_t fss_basic_read_delimit_mode_name_object_s; - extern const f_string_static_t fss_basic_read_delimit_mode_name_greater_s; - extern const f_string_static_t fss_basic_read_delimit_mode_name_lesser_s; -#endif // _di_fss_basic_read_delimit_modes_ - -/** - * FSS Delimit Parameter enumerations. - */ -#ifndef _di_fss_basic_read_delimit_mode_e_ - enum { - fss_basic_read_delimit_mode_none_e = 1, - fss_basic_read_delimit_mode_all_e, - fss_basic_read_delimit_mode_content_e, - fss_basic_read_delimit_mode_content_greater_e, - fss_basic_read_delimit_mode_content_greater_object_e, - fss_basic_read_delimit_mode_content_lesser_e, - fss_basic_read_delimit_mode_content_lesser_object_e, - fss_basic_read_delimit_mode_content_object_e, - fss_basic_read_delimit_mode_object_e, - }; // enum -#endif // _di_fss_basic_read_delimit_mode_e_ - -/** - * Flags passed to the main function or program. - * - * fss_basic_read_main_flag_*_e: - * - none: No flags set. - * - copyright: Print copyright. - * - file_from: Using a specified source file. - * - file_to: Using a specified destination file. - * - help: Print help. - * - header: Enable printing of headers. - * - print_first: When set, print new line to message output on program begin after loading settings. - * - print_last: When set, print new line to message output on program end. - * - separate: Enable printing of separators. - * - strip_invalid: Using strip invalid character mode. - * - verify: Using verify mode. - * - version: Print version. - */ -#ifndef _di_fss_basic_read_main_flag_e_ - enum { - fss_basic_read_main_flag_none_e = 0x0, - fss_basic_read_main_flag_copyright_e = 0x1, - fss_basic_read_main_flag_file_from_e = 0x2, - fss_basic_read_main_flag_file_to_e = 0x4, - fss_basic_read_main_flag_header_e = 0x8, - fss_basic_read_main_flag_help_e = 0x10, - fss_basic_read_main_flag_print_first_e = 0x20, - fss_basic_read_main_flag_print_last_e = 0x40, - fss_basic_read_main_flag_separate_e = 0x80, - fss_basic_read_main_flag_strip_invalid_e = 0x100, - fss_basic_read_main_flag_verify_e = 0x200, - fss_basic_read_main_flag_version_e = 0x400, - }; // enum -#endif // _di_fss_basic_read_main_flag_e_ - -/** - * The fss basic read main program settings. - * - * This is passed to the program-specific main entry point to designate program settings. - * These program settings are often processed from the program arguments (often called the command line arguments). - * - * flag: Flags passed to the main function. - * - * state: The state information. - */ -#ifndef _di_fss_basic_read_setting_t_ - typedef struct { - uint16_t flag; - - f_state_t state; - } fss_basic_read_setting_t; - - #define fss_basic_read_setting_t_initialize \ - { \ - fss_basic_read_main_flag_none_e, \ - f_state_t_initialize, \ - } -#endif // _di_fss_basic_read_setting_t_ - -/** - * Delete the program main setting data. - * - * @param setting - * The program main setting data. - * - * This does not alter setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fss_basic_read_setting_delete_ - extern f_status_t fss_basic_read_setting_delete(fss_basic_read_setting_t * const setting); -#endif // _di_fss_basic_read_setting_delete_ - -/** - * Perform the standard program setting load process. - * - * This prints error messages as appropriate. - * - * If either main or setting is NULL, then this immediately returns without doing anything. - * - * @param arguments - * The parameters passed to the process (often referred to as command line arguments). - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.state.status: - * F_none on success. - * - * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). - * - * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() - */ -#ifndef _di_fss_basic_read_setting_load_ - extern void fss_basic_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_basic_read_setting_t * const setting); -#endif // _di_fss_basic_read_setting_load_ - -/** - * Perform the standard program setting unload process. - * - * @param main - * The main program and setting data. - * All buffers are deallocated. - * - * This does not alter main.setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: fss_basic_read_setting_delete(). - * - * @see fss_basic_read_setting_delete() - */ -#ifndef _di_fss_basic_read_setting_unload_ - extern f_status_t fss_basic_read_setting_unload(fss_basic_read_main_t * const main); -#endif // _di_fss_basic_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_basic_read_common_h diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c deleted file mode 100644 index d3c7fce..0000000 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ /dev/null @@ -1,560 +0,0 @@ -#include "fss_basic_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_read_main_ - f_status_t fss_basic_read_main(fll_program_data_t * const main, fss_basic_read_setting_t * const setting) { - - f_status_t status = F_none; - - setting->state.step_small = fss_basic_read_allocation_console_d; - - status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - - setting->state.step_small = fss_basic_read_allocation_small_d; - - if (F_status_is_error(status)) return; - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_basic_read_parameter_no_color_e, fss_basic_read_parameter_light_e, fss_basic_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_basic_read_parameter_verbosity_quiet_e, fss_basic_read_parameter_verbosity_error_e, fss_basic_read_parameter_verbosity_verbose_e, fss_basic_read_parameter_verbosity_debug_e, fss_basic_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - } - - if (main->parameters.array[fss_basic_read_parameter_help_e].result & f_console_result_found_e) { - fss_basic_read_print_help(setting, main->message); - - return F_none; - } - - if (main->parameters.array[fss_basic_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_basic_read_program_version_s); - - return F_none; - } - - if (main->parameters.array[fss_basic_read_parameter_copyright_e].result & f_console_result_found_e) { - fll_program_print_copyright(main->message); - - return F_none; - } - - status = F_none; - - // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. - fss_basic_read_file_t files_array[main->parameters.remaining.used + 1]; - fss_basic_read_data_t data = fss_basic_read_data_t_initialize; - - data.argv = main->parameters.arguments.array; - data.files.array = files_array; - data.files.used = 1; - data.files.size = main->parameters.remaining.used + 1; - data.files.array[0].name = fss_basic_read_pipe_name_s; - data.files.array[0].range.start = 1; - data.files.array[0].range.stop = 0; - - if (main->parameters.remaining.used || (main->pipe & fll_program_data_pipe_input_e)) { - { - const f_array_length_t parameter_code[] = { - fss_basic_read_parameter_at_e, - fss_basic_read_parameter_depth_e, - fss_basic_read_parameter_line_e, - fss_basic_read_parameter_select_e, - fss_basic_read_parameter_name_e, - fss_basic_read_parameter_delimit_e, - }; - - const f_string_static_t parameter_name[] = { - fss_basic_read_long_at_s, - fss_basic_read_long_depth_s, - fss_basic_read_long_line_s, - fss_basic_read_long_select_s, - fss_basic_read_long_name_s, - fss_basic_read_long_delimit_s, - }; - - const f_string_t message_positive_number = "positive number"; - const f_string_t message_string = "string"; - const f_string_t message_value = "value"; - - const f_string_t parameter_message[] = { - message_positive_number, - message_positive_number, - message_positive_number, - message_positive_number, - message_string, - message_value, - }; - - for (f_array_length_t i = 0; i < 6; ++i) { - - if (main->parameters.array[parameter_code[i]].result & f_console_result_found_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, parameter_name[i], main->error.notable); - fl_print_format("%[' requires a %s.%]%r", main->error.to, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_basic_read_parameter_columns_e].result & f_console_result_found_e)) { - const f_array_length_t parameter_code[] = { - fss_basic_read_parameter_depth_e, - fss_basic_read_parameter_line_e, - fss_basic_read_parameter_pipe_e, - fss_basic_read_parameter_select_e, - fss_basic_read_parameter_total_e, - }; - - const f_string_static_t parameter_name[] = { - fss_basic_read_long_depth_s, - fss_basic_read_long_line_s, - fss_basic_read_long_pipe_s, - fss_basic_read_long_select_s, - fss_basic_read_long_total_s, - }; - - const uint8_t parameter_match[] = { - f_console_result_value_e, - f_console_result_value_e, - f_console_result_found_e, - f_console_result_value_e, - f_console_result_found_e, - }; - - for (f_array_length_t i = 0; i < 5; ++i) { - - if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_basic_read_long_columns_s, parameter_name[i]); - } - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_basic_read_parameter_pipe_e].result & f_console_result_found_e)) { - if (main->parameters.array[fss_basic_read_parameter_total_e].result & f_console_result_found_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_basic_read_long_pipe_s, fss_basic_read_long_total_s); - } - - status = F_status_set_error(F_parameter); - } - else if (main->parameters.array[fss_basic_read_parameter_line_e].result & f_console_result_value_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_basic_read_long_pipe_s, fss_basic_read_long_line_s); - } - - status = F_status_set_error(F_parameter); - } - } - - if (F_status_is_error_not(status) && main->parameters.array[fss_basic_read_parameter_delimit_e].result & f_console_result_value_e) { - f_array_length_t index = 0; - f_array_length_t length = 0; - - // Set the value to 0 to allow for detecting mode based on what is provided. - data.delimit_mode = 0; - - for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_read_parameter_delimit_e].values.used; ++i) { - - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - index = main->parameters.array[fss_basic_read_parameter_delimit_e].values.array[i]; - length = data.argv[index].used; - - if (!length) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_basic_read_long_delimit_s, main->error.notable); - fl_print_format("%[' must not be empty.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - else if (f_compare_dynamic(fss_basic_read_delimit_mode_name_none_s, data.argv[index]) == F_equal_to) { - data.delimit_mode = fss_basic_read_delimit_mode_none_e; - } - else if (f_compare_dynamic(fss_basic_read_delimit_mode_name_all_s, data.argv[index]) == F_equal_to) { - data.delimit_mode = fss_basic_read_delimit_mode_all_e; - } - else if (f_compare_dynamic(fss_basic_read_delimit_mode_name_object_s, data.argv[index]) == F_equal_to) { - switch (data.delimit_mode) { - case 0: - data.delimit_mode = fss_basic_read_delimit_mode_object_e; - break; - - case fss_basic_read_delimit_mode_none_e: - case fss_basic_read_delimit_mode_all_e: - case fss_basic_read_delimit_mode_content_greater_object_e: - case fss_basic_read_delimit_mode_content_lesser_object_e: - case fss_basic_read_delimit_mode_object_e: - break; - - case fss_basic_read_delimit_mode_content_e: - data.delimit_mode = fss_basic_read_delimit_mode_content_object_e; - break; - - case fss_basic_read_delimit_mode_content_greater_e: - data.delimit_mode = fss_basic_read_delimit_mode_content_greater_object_e; - break; - - case fss_basic_read_delimit_mode_content_lesser_e: - data.delimit_mode = fss_basic_read_delimit_mode_content_lesser_object_e; - break; - - default: - break; - } - } - else { - if (!data.delimit_mode) { - data.delimit_mode = fss_basic_read_delimit_mode_content_e; - } - else if (data.delimit_mode == fss_basic_read_delimit_mode_object_e) { - data.delimit_mode = fss_basic_read_delimit_mode_content_object_e; - } - - if (data.argv[index].string[length - 1] == fss_basic_read_delimit_mode_name_greater_s.string[0]) { - if (!(data.delimit_mode == fss_basic_read_delimit_mode_none_e || data.delimit_mode == fss_basic_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_basic_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_basic_read_delimit_mode_content_greater_object_e; - } - else { - data.delimit_mode = fss_basic_read_delimit_mode_content_greater_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - else if (data.argv[index].string[length - 1] == fss_basic_read_delimit_mode_name_lesser_s.string[0]) { - if (!(data.delimit_mode == fss_basic_read_delimit_mode_none_e || data.delimit_mode == fss_basic_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_basic_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_basic_read_delimit_mode_content_lesser_object_e; - } - else { - data.delimit_mode = fss_basic_read_delimit_mode_content_lesser_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - - f_string_range_t range = macro_f_string_range_t_initialize_2(length); - - // Ignore leading plus sign. - if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { - ++range.start; - } - - status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], range, &data.delimit_depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_unsigned_detect", F_true, fss_basic_read_long_delimit_s, data.argv[index]); - - break; - } - - // There can be nothing smaller than 0, so replace '0-' logic with just '0' logic. - if (data.delimit_mode == fss_basic_read_delimit_mode_content_lesser_e || data.delimit_mode == fss_basic_read_delimit_mode_content_lesser_object_e) { - if (!data.delimit_depth) { - if (data.delimit_mode == fss_basic_read_delimit_mode_content_lesser_e) { - data.delimit_mode = fss_basic_read_delimit_mode_content_e; - } - else { - data.delimit_mode = fss_basic_read_delimit_mode_content_object_e; - } - } - } - } - } // for - - // Guarantee the default value is "all". - if (!data.delimit_mode) { - data.delimit_mode = fss_basic_read_delimit_mode_all_e; - } - } - - if (F_status_is_error_not(status)) { - status = fss_basic_read_depth_process(main, &data); - } - - // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. - if (F_status_is_error_not(status) && data.depths.array[0].depth > 0) { - if (main->parameters.array[fss_basic_read_parameter_total_e].result & f_console_result_found_e) { - fss_basic_read_print_zero(main); - } - - fss_basic_read_data_delete_simple(&data); - - return F_none; - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_basic_read_parameter_select_e].result & f_console_result_found_e)) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_basic_read_long_select_s, main->error.notable); - fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - fss_basic_read_depths_resize(0, &data.depths); - - status = F_status_set_error(F_parameter); - } - - if (F_status_is_error_not(status)) { - for (f_array_length_t i = 0; i < data.files.used; ++i) { - macro_f_string_range_t_clear(data.files.array[i].range); - } // for - } - - if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { - f_file_t file = f_file_t_initialize; - - file.id = F_type_descriptor_input_d; - file.stream = F_type_input_d; - - data.files.array[0].range.start = 0; - - status = f_file_stream_read(file, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "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); - } - else if (data.buffer.used) { - data.files.array[0].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - else { - data.files.array[0].range.start = 1; - } - } - - if (F_status_is_error_not(status) && main->parameters.remaining.used > 0) { - f_file_t file = f_file_t_initialize; - off_t size_block = 0; - off_t size_file = 0; - off_t size_read = 0; - - for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_signal); - - break; - } - - main->signal_check = 0; - } - - data.files.array[data.files.used].range.start = data.buffer.used; - file.stream = 0; - file.id = -1; - - status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); - - break; - } - - size_file = 0; - - status = f_file_size_by_id(file.id, &size_file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - if (size_file) { - - // Enforce a max block read size to allow for interrupts to be processed between blocks. - if (size_file > fss_basic_read_block_max) { - file.size_read = fss_basic_read_block_read_large; - size_block = fss_basic_read_block_max; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + (size_block - (size_file % size_block)) + 1, &data.buffer); - } - else { - file.size_read = fss_basic_read_block_read_small; - size_block = size_file; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + 1, &data.buffer); - } - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - for (size_read = 0; size_read < size_file; size_read += size_block) { - - // The signal check is always performed on each pass. - if (size_file > fss_basic_read_block_max && fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - status = f_file_stream_read_until(file, size_block, &data.buffer); - if (F_status_is_error(status)) break; - } // for - - f_file_stream_flush(file); - f_file_stream_close(&file); - - if (F_status_is_error(status)) { - if (F_status_set_fine(status) != F_interrupt) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read_until", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - } - - break; - } - - if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; - data.files.array[data.files.used++].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - } - else { - data.files.array[data.files.used].range.start = 1; - data.files.array[data.files.used].range.stop = 0; - } - } // for - } - - if (F_status_is_error_not(status)) { - status = fss_basic_read_process(main, &data); - } - - fss_basic_read_data_delete_simple(&data); - } - else { - fll_print_format("%r%[%QYou failed to specify one or more files.%]%r", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - status = F_status_set_error(F_parameter); - } - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - if (F_status_set_fine(status) == F_interrupt) { - f_file_stream_flush(main->output.to); - - fll_print_dynamic_raw(f_string_eol_s, main->output.to); - } - } - - fss_basic_read_data_delete_simple(&data); - - return status; - } -#endif // _di_fss_basic_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h deleted file mode 100644 index e9b6973..0000000 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This is the FSS Basic Read program - * This program utilizes the Featureless Linux Library. - * This program processes files or other input in fss format and stores the results in the fll_program_data_t. - * - * This processes in accordance to the FSS-0000 Basic specification. - */ -#ifndef _fss_basic_read_h -#define _fss_basic_read_h - -// Libc includes. -#include -#include -#include -#include -#include - -// FLL-0 includes. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// FLL-1 includes. -#include -#include - -// FLL-2 includes. -#include -#include -#include -#include -#include - -// FSS Basic Read includes. -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Execute main program. - * - * If main.signal is non-zero, then this blocks and handles the following signals: - * - F_signal_abort - * - F_signal_broken_pipe - * - F_signal_hangup - * - F_signal_interrupt - * - F_signal_quit - * - F_signal_termination - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.state.status: - * F_none on success. - * F_true on success when performing verification and verify passed. - * F_false on success when performing verification and verify failed. - * F_interrupt on (exit) signal received. - * - * F_parameter (with error bit) if main is NULL or setting is NULL. - */ -#ifndef _di_fss_basic_read_main_ - extern f_status_t fss_basic_read_main(fll_program_data_t * const main, fss_basic_read_setting_t * const setting); -#endif // _di_fss_basic_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_basic_read_h diff --git a/level_3/fss_basic_read/c/main.c b/level_3/fss_basic_read/c/main.c deleted file mode 100644 index b53937f..0000000 --- a/level_3/fss_basic_read/c/main.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "fss_basic_read.h" - -int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - - fss_basic_read_main_t data = fss_basic_read_main_t_initialize; - - data.program.debug.flag |= fss_basic_read_print_flag_debug_e | fss_basic_read_print_flag_out_e; - data.program.error.flag |= fss_basic_read_print_flag_error_e | fss_basic_read_print_flag_out_e; - data.program.output.flag |= fss_basic_read_print_flag_out_e; - data.program.message.flag |= fss_basic_read_print_flag_message_e | fss_basic_read_print_flag_out_e; - data.program.warning.flag |= fss_basic_read_print_flag_warning_e | fss_basic_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; - - f_console_parameter_t parameters[] = fss_basic_read_console_parameter_t_initialize; - data.program.parameters.array = parameters; - data.program.parameters.used = fss_basic_read_total_parameters_d; - data.program.environment = envp; - - if (f_pipe_input_exists()) { - data.program.pipe = fll_program_data_pipe_input_e; - } - - fll_program_standard_set_up(&data.program); - - { - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); - - fss_basic_read_setting_load(arguments, &data); - } - - fss_basic_read_main(&data); - - fss_basic_read_setting_unload(&data); - - fll_program_data_delete(&data.program); - - fll_program_standard_set_down(&data.program); - - return F_status_is_error(data.setting.state.status) ? 1 : 0; -} diff --git a/level_3/fss_basic_read/c/main.h b/level_3/fss_basic_read/c/main.h deleted file mode 100644 index 55d83f4..0000000 --- a/level_3/fss_basic_read/c/main.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This file is only ever included by main/main.c and should not normally be included anywhere else. - * Anything that wants to include this should be providing the "fss_basic_read" program functionality in some manner. - */ -#ifndef _fss_basic_read_main_h -#define _fss_basic_read_main_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Standard program entry point. - * - * @param argc - * The number of arguments. - * @param argv - * The array of arguments. - * @param envp - * The array of all environment variables on program start. - * - * @return - * 0 on success. - * 1 on error. - */ -extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_basic_read_main_h diff --git a/level_3/fss_basic_read/c/print.c b/level_3/fss_basic_read/c/print.c deleted file mode 100644 index 4ff8421..0000000 --- a/level_3/fss_basic_read/c/print.c +++ /dev/null @@ -1,116 +0,0 @@ -#include "fss_basic_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_read_print_help_ - f_status_t fss_basic_read_print_help(fss_basic_read_setting_t * const setting, const fl_print_t print) { - - f_file_stream_lock(print.to); - - fll_program_print_help_header(print, fss_basic_read_program_name_long_s, fss_basic_read_program_version_s); - - fll_program_print_help_option_standard(print); - - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_option(print, fss_basic_read_short_at_s, fss_basic_read_long_at_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric index."); - fll_program_print_help_option(print, fss_basic_read_short_content_s, fss_basic_read_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Content (default)."); - fll_program_print_help_option(print, fss_basic_read_short_columns_s, fss_basic_read_long_columns_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of columns."); - fll_program_print_help_option(print, fss_basic_read_short_delimit_s, fss_basic_read_long_delimit_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Designate how to handle applying delimits."); - fll_program_print_help_option(print, fss_basic_read_short_depth_s, fss_basic_read_long_depth_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric depth."); - fll_program_print_help_option(print, fss_basic_read_short_empty_s, fss_basic_read_long_empty_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Include empty Content when processing."); - fll_program_print_help_option(print, fss_basic_read_short_line_s, fss_basic_read_long_line_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print only the Content at the given line."); - fll_program_print_help_option(print, fss_basic_read_short_name_s, fss_basic_read_long_name_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object with this name."); - fll_program_print_help_option(print, fss_basic_read_short_object_s, fss_basic_read_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Object."); - fll_program_print_help_option(print, fss_basic_read_short_pipe_s, fss_basic_read_long_pipe_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print using the special pipe format."); - fll_program_print_help_option(print, fss_basic_read_short_original_s, fss_basic_read_long_original_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print with the original quotes and escapes."); - fll_program_print_help_option(print, fss_basic_read_short_select_s, fss_basic_read_long_select_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select sub-Content at this index."); - fll_program_print_help_option(print, fss_basic_read_short_total_s, fss_basic_read_long_total_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of lines."); - fll_program_print_help_option(print, fss_basic_read_short_trim_s, fss_basic_read_long_trim_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Trim Object names on select or print."); - - f_print_dynamic_raw(f_string_eol_s, print.to); - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_usage(print, fss_basic_read_program_name_s, fll_program_parameter_filenames_s); - - fl_print_format("%r %[Notes:%]%r", print.to, f_string_eol_s, print.set->important, print.set->important, f_string_eol_s); - - fl_print_format(" This program will print the Content associated with the given Object and Content main based on the FSS-0000 Basic standard.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" All numeric positions (indexes) start at 0 instead of 1.%r", print.to, f_string_eol_s); - fl_print_format(" For example, a file of 17 lines would range from 0 to 16.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When using the %[%r%r%] option, an order of operations is enforced on the parameters.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_depth_s, print.set->notable, f_string_eol_s); - - fl_print_format(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%r", print.to, f_string_eol_s); - - fl_print_format(" %[%r%r%]: An Object index at the specified depth.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_at_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: A new depth within the specified depth, indexed from the root.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: An Object name at the specified depth.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] must be in numeric order, but values in between may be skipped.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%r", print.to, f_string_eol_s); - fl_print_format(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] selects a Content column.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_select_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" Specify both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_object_s, print.set->notable); - fl_print_format(" and the %[%r%r%] parameters to get the total objects.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_total_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_at_s, print.set->notable); - fl_print_format(" and %[%r%r%] parameters are specified (at the same depth),", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_name_s, print.set->notable); - fl_print_format(" the %[%r%r%] parameter value will be treated as a position relative to the specified", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_at_s, print.set->notable); - fl_print_format(" %[%r%r%] parameter value.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" This program may support parameters, such as %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_depth_s, print.set->notable); - fl_print_format(" or %[%r%r%], even if not supported by the standard.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_select_s, print.set->notable, f_string_eol_s); - fl_print_format(" This is done to help ensure consistency for scripting.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_depth_s, print.set->notable); - fl_print_format(" if the standard doesn't support nested Content, then only a depth of 0 would be valid.%r", print.to, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_select_s, print.set->notable); - fl_print_format(" if the standard doesn't support multiple Content groups, then only a select of 0 would be valid.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_trim_s, print.set->notable); - fl_print_format(" will remove leading and trailing white spaces when selecting objects or when printing objects.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When specifying both the %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_object_s, print.set->notable); - fl_print_format(" parameter and the %[%r%r%] parameter, the entire Object and Content are printed, including the formatting.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_content_s, print.set->notable, f_string_eol_s); - fl_print_format(" Both the Object and Content printed are already escaped.%r", print.to, f_string_eol_s); - fl_print_format(" Both the Object and Content are separated by a space.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] accepts the following:%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_delimit_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Do not apply delimits.%r", print.to, print.set->notable, fss_basic_read_delimit_mode_name_none_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: (default) Apply all delimits.%r", print.to, print.set->notable, fss_basic_read_delimit_mode_name_all_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Apply delimits for Objects.%r", print.to, print.set->notable, fss_basic_read_delimit_mode_name_object_s, print.set->notable, f_string_eol_s); - fl_print_format(" - A number, 0 or greater: apply delimits for Content at the specified depth.%r", print.to, f_string_eol_s); - fl_print_format(" - A number, 0 or greater, followed by a %[%r%]: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%r", print.to, print.set->notable, fss_basic_read_delimit_mode_name_greater_s, print.set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" - A number, 0 or lesser, followed by a %[%r%]: (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%r%r", print.to, print.set->notable, fss_basic_read_delimit_mode_name_lesser_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%] parameter may be specified multiple times to customize the delimit behavior.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_delimit_s, print.set->notable, f_string_eol_s); - - fl_print_format(" The %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_delimit_s, print.set->notable); - fl_print_format(" values %[%r%]", print.to, print.set->notable, fss_basic_read_delimit_mode_name_none_s, print.set->notable); - fl_print_format(" and %[%r%],", print.to, print.set->notable, fss_basic_read_delimit_mode_name_all_s, print.set->notable); - fl_print_format(" overrule all other delimit values.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameters %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_columns_s, print.set->notable); - fl_print_format(" and %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_basic_read_long_select_s, print.set->notable); - fl_print_format(" refer to a Content column.%r", print.to, f_string_eol_s); - fl_print_format(" The word 'column' is being loosely defined to refer to a specific Content.%r", print.to, f_string_eol_s); - fl_print_format(" This is not to be confused with a depth.%r", print.to, f_string_eol_s); - - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_basic_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_read/c/print.h b/level_3/fss_basic_read/c/print.h deleted file mode 100644 index 38c2460..0000000 --- a/level_3/fss_basic_read/c/print.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _fss_basic_read_print_h -#define _fss_basic_read_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print help. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_read_print_help_ - extern f_status_t fss_basic_read_print_help(fss_basic_read_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_basic_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_basic_read_print_h diff --git a/level_3/fss_basic_read/c/private-common.c b/level_3/fss_basic_read/c/private-common.c deleted file mode 100644 index 8cec401..0000000 --- a/level_3/fss_basic_read/c/private-common.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "fss_basic_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_read_data_delete_simple_ - void fss_basic_read_data_delete_simple(fss_basic_read_data_t *data) { - - if (!data) return; - - // data->files is expected to be statically loaded and cannot be deallocated. - - fss_basic_read_depths_resize(0, &data->depths); - - f_string_dynamic_resize(0, &data->buffer); - macro_f_fss_contents_t_delete_simple(data->contents); - macro_f_fss_objects_t_delete_simple(data->objects); - macro_f_fss_delimits_t_delete_simple(data->delimits); - macro_f_uint8s_t_delete_simple(data->quotes); - } -#endif // _di_fss_basic_read_data_delete_simple_ - -#ifndef _di_fss_basic_read_depth_delete_simple_ - void fss_basic_read_depth_delete_simple(fss_basic_read_depth_t *depth) { - - if (!depth) return; - - f_string_dynamic_resize(0, &depth->value_name); - } -#endif // _di_fss_basic_read_depth_delete_simple_ - -#ifndef _di_fss_basic_read_depths_resize_ - f_status_t fss_basic_read_depths_resize(const f_array_length_t length, fss_basic_read_depths_t *depths) { - - if (!depths) { - return F_status_set_error(F_parameter); - } - - for (f_array_length_t i = length; i < depths->size; ++i) { - fss_basic_read_depth_delete_simple(&depths->array[i]); - } // for - - const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_basic_read_depth_t), (void **) & depths->array); - if (F_status_is_error(status)) return status; - - depths->size = length; - - if (depths->used > depths->size) { - depths->used = length; - } - - return F_none; - } -#endif // _di_fss_basic_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_read/c/private-common.h b/level_3/fss_basic_read/c/private-common.h deleted file mode 100644 index 7c9cfe7..0000000 --- a/level_3/fss_basic_read/c/private-common.h +++ /dev/null @@ -1,263 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_common_h -#define _PRIVATE_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Provide common/generic definitions. - * - * basic_read_common_allocation_*: - * - large: An allocation step used for buffers that are anticipated to have large buffers. - * - small: An allocation step used for buffers that are anticipated to have small buffers. - * - * fss_basic_read_block_*: - * - max: The max block read size before checking for interrupt. - * - read_small: The block read size for small files. - * - read_large: The block read size for large files. - */ -#ifndef _di_fss_basic_read_common_ - #define fss_basic_read_common_allocation_large_d 2048 - #define fss_basic_read_common_allocation_small_d 128 - - #define fss_basic_read_block_max 16777216 - #define fss_basic_read_block_read_small 8192 - #define fss_basic_read_block_read_large 65536 -#endif // _di_fss_basic_read_common_ - -/** - * A structure of parameters applied at some depth. - * - * depth: The depth number in which this is to be processed at. - * - * index_at: Position of the "--at" parameter value in the argv list, when 0 there is no parameter. - * index_name: Position of the "--name" parameter value in the argv list, when 0 there is no parameter. - * - * value_at: The value of the "--at" parameter, already processed and ready to use, only when index_at > 0. - * value_name: The value of the "--name" parameter, already processed and ready to use, only when index_name > 0. - */ -#ifndef _di_fss_basic_read_depth_t_ - typedef struct { - f_array_length_t depth; - - f_array_length_t index_at; - f_array_length_t index_name; - - f_number_unsigned_t value_at; - f_string_dynamic_t value_name; - } fss_basic_read_depth_t; - - #define fss_basic_read_depth_t_initialize \ - { \ - 0, \ - 0, \ - 0, \ - 0, \ - f_string_dynamic_t_initialize, \ - } - - #define macro_fss_basic_read_depth_t_clear(structure) \ - structure.depth = 0; \ - structure.index_at = 0; \ - structure.index_name = 0; \ - structure.value_at = 0; \ - macro_f_string_dynamic_t_clear(structure.value_name) -#endif // _di_fss_basic_read_depth_t_ - -/** - * An array of depth parameters. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_basic_read_depths_t_ - typedef struct { - fss_basic_read_depth_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_basic_read_depths_t; - - #define fss_basic_read_depths_t_initialize { 0, 0, 0 } - - #define macro_fss_basic_read_depths_t_clear(depths) macro_f_memory_structure_clear(depths) -#endif // _di_fss_basic_read_depths_t_ - -/** - * A structure for designating where within the buffer a particular file exists, using a statically allocated array. - * - * name: The name of the file representing the range. - * range: A range within the buffer representing the file. - */ -#ifndef _di_fss_basic_read_file_t_ - typedef struct { - f_string_static_t name; - f_string_range_t range; - } fss_basic_read_file_t; - - #define fss_basic_read_file_t_initialize \ - { \ - f_string_static_t_initialize, \ - f_string_range_t_initialize, \ - } -#endif // _di_fss_basic_read_file_t_ - -/** - * An array of files. - * - * This is intended to be defined and used statically allocated and as such no dynamic allocation or dynamic deallocation methods are provided. - * - * The STDIN pipe is reserved for index 0 and as such size and used must be initialized to 1. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_basic_read_files_t_ - typedef struct { - fss_basic_read_file_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_basic_read_files_t; - - #define fss_basic_read_files_t_initialize { 0, 1, 1 } -#endif // _di_fss_basic_read_files_t_ - -/** - * The data structure for FSS Basic Read. - * - * fss_basic_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - 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). - * - * argv: The argument structure in the progam data parameters for simplifying syntax. - * options: Bitwise flags representing parameters. - * delimit_mode: The delimit mode. - * delimit_depth: The delimit depth. - * select: The Content to select (column number). - * line: The Content to select (row number). - * files: A statically allocated array of files for designating where in the buffer a file is represented. - * depths: The array of parameters for each given depth. - * buffer: The buffer containing all loaded files (and STDIN pipe). - * objects: The positions within the buffer representing Objects. - * contents: The positions within the buffer representing Contents. - * delimits: The positions within the buffer representing character delimits. - */ -#ifndef _di_fss_basic_read_data_t_ - #define fss_basic_read_data_option_at_d 0x1 - #define fss_basic_read_data_option_columns_d 0x2 - #define fss_basic_read_data_option_content_d 0x4 - #define fss_basic_read_data_option_empty_d 0x8 - #define fss_basic_read_data_option_line_d 0x10 - #define fss_basic_read_data_option_name_d 0x20 - #define fss_basic_read_data_option_object_d 0x40 - #define fss_basic_read_data_option_original_d 0x80 - #define fss_basic_read_data_option_select_d 0x100 - #define fss_basic_read_data_option_total_d 0x200 - #define fss_basic_read_data_option_trim_d 0x400 - - typedef struct { - uint16_t option; - uint8_t delimit_mode; - f_array_length_t delimit_depth; - f_number_unsigned_t select; - f_number_unsigned_t line; - - f_string_static_t *argv; - - fss_basic_read_files_t files; - fss_basic_read_depths_t depths; - - f_string_dynamic_t buffer; - f_fss_objects_t objects; - f_fss_contents_t contents; - f_fss_delimits_t delimits; - f_uint8s_t quotes; - } fss_basic_read_data_t; - - #define fss_basic_read_data_t_initialize \ - { \ - 0, \ - fss_basic_read_delimit_mode_all_e, \ - 0, \ - 0, \ - 0, \ - 0, \ - fss_basic_read_files_t_initialize, \ - fss_basic_read_depths_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_fss_objects_t_initialize, \ - f_fss_contents_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_uint8s_t_initialize, \ - } -#endif // _di_fss_basic_read_data_t_ - -/** - * Fully deallocate all memory for the given data without caring about return status. - * - * @param data - * The data to deallocate. - */ -#ifndef _di_fss_basic_read_data_delete_simple_ - extern void fss_basic_read_data_delete_simple(fss_basic_read_data_t *data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_data_delete_simple_ - -/** - * Fully deallocate all memory for the given depth without caring about return status. - * - * @param depth - * The depth to deallocate. - */ -#ifndef _di_fss_basic_read_depth_delete_simple_ - extern void fss_basic_read_depth_delete_simple(fss_basic_read_depth_t *depth) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_depth_delete_simple_ - -/** - * Resize the depth array. - * - * @param length - * The new size to use. - * @param depths - * The depth array to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * Errors (with error bit) from: fss_basic_read_depths_increase(). - * - * @see f_memory_resize() - * - * @see fss_basic_read_depth_delete_simple() - * @see fss_basic_read_depths_increase() - */ -#ifndef _di_fss_basic_read_depths_resize_ - extern f_status_t fss_basic_read_depths_resize(const f_array_length_t length, fss_basic_read_depths_t *depths) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_common_h diff --git a/level_3/fss_basic_read/c/private-print.c b/level_3/fss_basic_read/c/private-print.c deleted file mode 100644 index 1704ae3..0000000 --- a/level_3/fss_basic_read/c/private-print.c +++ /dev/null @@ -1,144 +0,0 @@ -#include "fss_basic_read.h" -#include "private-common.h" -#include "private-print.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_read_print_at_ - void fss_basic_read_print_at(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_basic_read_data_t * const data) { - - if (at >= data->contents.used) { - return; - } - - if ((data->option & fss_basic_read_data_option_object_d) || (data->option & fss_basic_read_data_option_content_d) && (data->contents.array[at].used || (data->option & fss_basic_read_data_option_empty_d))) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_basic_read_data_option_object_d) { - if (data->option & fss_basic_read_data_option_trim_d) { - if (data->option & fss_basic_read_data_option_original_d) { - if (data->quotes.array[at]) { - f_print_dynamic_raw( - data->quotes.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - - fl_print_trim_dynamic_partial(data->buffer, data->objects.array[at], main->output.to); - - if (data->quotes.array[at]) { - f_print_dynamic_raw( - data->quotes.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - } - else { - fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - } - else { - if (data->option & fss_basic_read_data_option_original_d) { - if (data->quotes.array[at]) { - f_print_dynamic_raw( - data->quotes.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - - f_print_dynamic_partial(data->buffer, data->objects.array[at], main->output.to); - - if (data->quotes.array[at]) { - f_print_dynamic_raw( - data->quotes.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - } - else { - f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - } - - if (data->option & fss_basic_read_data_option_content_d) { - fss_basic_read_print_object_end(main); - } - } - - if ((data->option & fss_basic_read_data_option_content_d) && data->contents.array[at].used) { - if (data->option & fss_basic_read_data_option_original_d) { - f_print_dynamic_partial(data->buffer, data->contents.array[at].array[0], main->output.to); - } - else { - f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[0], delimits_content, main->output.to); - } - } - - fss_basic_read_print_set_end(main); - - f_file_stream_unlock(main->output.to); - } - } -#endif // _di_fss_basic_read_print_at_ - -#ifndef _di_fss_basic_read_print_object_end_ - void fss_basic_read_print_object_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_basic_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_basic_read_pipe_content_start_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_space_s, main->output.to); - } - } -#endif // _di_fss_basic_read_print_object_end_ - -#ifndef _di_fss_basic_read_print_one_ - void fss_basic_read_print_one(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_1_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_basic_read_print_one_ - -#ifndef _di_fss_basic_read_print_set_end_ - void fss_basic_read_print_set_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_basic_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_basic_read_pipe_content_end_s, main->output.to); - } - else { - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } - } -#endif // _di_fss_basic_read_print_set_end_ - -#ifndef _di_fss_basic_read_print_zero_ - void fss_basic_read_print_zero(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_0_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_basic_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_read/c/private-print.h b/level_3/fss_basic_read/c/private-print.h deleted file mode 100644 index 5719790..0000000 --- a/level_3/fss_basic_read/c/private-print.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_print_h -#define _PRIVATE_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print the Object and Content at the given position. - * - * Only what is requested to print (Object, Content, both, or neither) will be printed, if there is something to print. - * - * @param main - * The main program data. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param data - * The program data. - */ -#ifndef _di_fss_basic_read_print_at_ - extern void fss_basic_read_print_at(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_print_at_ - -/** - * Print the end of an Object (which is essentially the start of Content). - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_read_print_object_end_ - extern void fss_basic_read_print_object_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_print_object_end_ - -/** - * Print the number one and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_read_print_one_ - extern void fss_basic_read_print_one(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_print_one_ - -/** - * Print the end of an Object/Content set. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_read_print_set_end_ - extern void fss_basic_read_print_set_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_print_set_end_ - -/** - * Print the number zero and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_basic_read_print_zero_ - extern void fss_basic_read_print_zero(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_print_h diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c deleted file mode 100644 index b69d1da..0000000 --- a/level_3/fss_basic_read/c/private-read.c +++ /dev/null @@ -1,683 +0,0 @@ -#include "fss_basic_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_basic_read_delimit_object_is_ - f_status_t fss_basic_read_delimit_object_is(fss_basic_read_data_t * const data, const f_array_length_t depth) { - - switch (data->delimit_mode) { - case fss_basic_read_delimit_mode_none_e: - case fss_basic_read_delimit_mode_content_e: - case fss_basic_read_delimit_mode_content_greater_e: - case fss_basic_read_delimit_mode_content_lesser_e: - return F_false; - - case fss_basic_read_delimit_mode_all_e: - case fss_basic_read_delimit_mode_content_object_e: - case fss_basic_read_delimit_mode_content_greater_object_e: - case fss_basic_read_delimit_mode_content_lesser_object_e: - case fss_basic_read_delimit_mode_object_e: - return F_true; - - default: - break; - } - - return depth == data->delimit_depth || data->delimit_mode == fss_basic_read_delimit_mode_content_lesser_e; - } -#endif // _di_fss_basic_read_delimit_object_is_ - -#ifndef _di_fss_basic_read_depth_process_ - f_status_t fss_basic_read_depth_process(fll_program_data_t * const main, fss_basic_read_data_t * const data) { - - f_status_t status = F_none; - - { - f_array_length_t depth_size = 1; - - if (main->parameters.array[fss_basic_read_parameter_depth_e].result & f_console_result_value_e) { - depth_size = main->parameters.array[fss_basic_read_parameter_depth_e].values.used; - } - - if (depth_size > data->depths.size) { - status = fss_basic_read_depths_resize(depth_size, &data->depths); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fss_basic_read_depths_resize", fll_error_file_flag_fallback_e); - - return status; - } - } - - data->depths.used = depth_size; - } - - f_array_length_t position_depth = 0; - f_array_length_t position_at = 0; - f_array_length_t position_name = 0; - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - data->depths.array[i].depth = 0; - data->depths.array[i].index_at = 0; - data->depths.array[i].index_name = 0; - data->depths.array[i].value_at = 0; - - macro_f_string_dynamic_t_clear(data->depths.array[i].value_name); - - if (!main->parameters.array[fss_basic_read_parameter_depth_e].values.used) { - position_depth = 0; - } - else { - position_depth = main->parameters.array[fss_basic_read_parameter_depth_e].values.array[i]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[position_depth], &data->depths.array[i].depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_basic_read_long_depth_s, data->argv[position_depth]); - - return status; - } - } - - if (main->parameters.array[fss_basic_read_parameter_at_e].result & f_console_result_value_e) { - for (; position_at < main->parameters.array[fss_basic_read_parameter_at_e].values.used; ++position_at) { - - if (main->parameters.array[fss_basic_read_parameter_at_e].values.array[position_at] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_basic_read_parameter_at_e].values.array[position_at] > main->parameters.array[fss_basic_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_at = main->parameters.array[fss_basic_read_parameter_at_e].values.array[position_at]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[data->depths.array[i].index_at], &data->depths.array[i].value_at); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_basic_read_long_at_s, data->argv[data->depths.array[i].index_at]); - - return status; - } - } // for - } - - if (main->parameters.array[fss_basic_read_parameter_name_e].result & f_console_result_value_e) { - for (; position_name < main->parameters.array[fss_basic_read_parameter_name_e].values.used; position_name++) { - - if (main->parameters.array[fss_basic_read_parameter_name_e].values.array[position_name] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_basic_read_parameter_name_e].values.array[position_name] > main->parameters.array[fss_basic_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_name = main->parameters.array[fss_basic_read_parameter_name_e].values.array[position_name]; - - if (main->parameters.array[fss_basic_read_parameter_trim_e].result & f_console_result_found_e) { - status = f_rip_dynamic(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - else { - status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), (main->parameters.array[fss_basic_read_parameter_trim_e].result & f_console_result_found_e) ? "f_rip_dynamic" : "f_string_dynamic_append", fll_error_file_flag_fallback_e); - - return status; - } - } // for - } - } // for - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' may only be specified once for the parameter '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_basic_read_long_depth_s, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - - if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_basic_read_long_depth_s, main->error.notable); - fl_print_format("%[' may not have the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' before the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[j].depth, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - } // for - } // for - - return F_none; - } -#endif // _di_fss_basic_read_depth_process_ - -#ifndef _di_fss_basic_read_file_identify_ - f_string_static_t fss_basic_read_file_identify(const f_array_length_t at, const fss_basic_read_files_t files) { - - for (f_array_length_t i = 0; i < files.used; ++i) { - - if (at >= files.array[i].range.start && at <= files.array[i].range.stop) { - return files.array[i].name; - } - } // for - - // When stopped after the end of the buffer, the last file in the list is the correct file. - if (at > files.array[files.used - 1].range.stop) { - return files.array[files.used - 1].name; - } - - return f_string_empty_s; - } -#endif // _di_fss_basic_read_file_identify_ - -#ifndef _di_fss_basic_read_load_ - f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t * const data) { - - f_state_t state = macro_f_state_t_initialize_1(fss_basic_read_common_allocation_large_d, fss_basic_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); - f_string_range_t input = macro_f_string_range_t_initialize_2(data->buffer.used); - - data->delimits.used = 0; - data->quotes.used = 0; - - const f_status_t status = fll_fss_basic_read(data->buffer, state, &input, &data->objects, &data->contents, &data->quotes, &data->delimits, 0); - - if (F_status_is_error(status)) { - if (F_status_set_fine(status) == F_interrupt) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return status; - } - - const f_string_static_t file_name = fss_basic_read_file_identify(input.start, data->files); - - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_basic_read", fll_error_file_flag_fallback_e, file_name, f_file_operation_process_s, fll_error_file_type_file_e); - - return status; - } - - if (status == F_data_not_stop || status == F_data_not_eos) { - if (data->option & fss_basic_read_data_option_total_d) return F_none; - - return F_status_set_warning(status); - } - - return F_none; - } -#endif // _di_fss_basic_read_load_ - -#ifndef _di_fss_basic_read_load_number_ - f_status_t fss_basic_read_load_number(fll_program_data_t * const main, fss_basic_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { - - if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - - const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, name, data->argv[index]); - - return status; - } - - return F_true; - } - - return F_false; - } -#endif // _di_fss_basic_read_load_number_ - -#ifndef _di_fss_basic_read_process_ - f_status_t fss_basic_read_process(fll_program_data_t * const main, fss_basic_read_data_t * const data) { - - f_status_t status = fss_basic_read_process_option(main, data); - if (F_status_is_error(status)) return status; - - // This standard does not support multiple content groups. - if ((data->option & fss_basic_read_data_option_select_d) && data->select) { - if (main->parameters.array[fss_basic_read_parameter_total_e].result & f_console_result_found_e) { - f_file_stream_lock(main->output.to); - - fss_basic_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - - status = fss_basic_read_load(main, data); - if (F_status_is_error(status)) return status; - - bool names[data->objects.used]; - - status = fss_basic_read_process_name(data, names); - if (F_status_is_error(status)) return status; - - if (data->depths.array[0].index_at) { - return fss_basic_read_process_at(main, data, names); - } - - if (data->option & fss_basic_read_data_option_columns_d) { - return fss_basic_read_process_columns(main, data, names); - } - - if (data->option & fss_basic_read_data_option_total_d) { - return fss_basic_read_process_total(main, data, names); - } - - if (data->option & fss_basic_read_data_option_line_d) { - return fss_basic_read_process_line(main, data, names); - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(data, 0) ? &data->delimits : &except_none; - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - fss_basic_read_print_at(main, i, *delimits, except_none, data); - } // for - - return F_none; - } -#endif // _di_fss_basic_read_process_ - -#ifndef _di_fss_basic_read_process_at_ - f_status_t fss_basic_read_process_at(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) { - - if (data->depths.array[0].value_at >= data->objects.used) { - if (data->option & (fss_basic_read_data_option_columns_d | fss_basic_read_data_option_total_d)) { - f_file_stream_lock(main->output.to); - - fss_basic_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - - // This standard only has one line per Content; therefore, any line value greater than 0 equates to no line to print. - if (data->option & fss_basic_read_data_option_line_d) { - if (data->line) { - if (data->option & fss_basic_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_basic_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(data, 0) ? &data->delimits : &except_none; - - f_array_length_t at = 0; - - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (at == data->depths.array[0].value_at) { - if (data->option & fss_basic_read_data_option_line_d) { - - // This standard only supports one line per Object so when using "--at", the only valid line is line 0. - if (data->line) break; - - if (data->option & fss_basic_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_basic_read_print_one(main); - - f_file_stream_unlock(main->output.to); - } - else { - fss_basic_read_print_at(main, i, *delimits, except_none, data); - } - } - else if (data->option & fss_basic_read_data_option_columns_d) { - fll_print_format("%ul%r", main->output.to, data->contents.array[i].used, f_string_eol_s); - } - else if (data->option & fss_basic_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - if (data->contents.array[i].used) { - fss_basic_read_print_one(main); - } - else { - fss_basic_read_print_zero(main); - } - - f_file_stream_unlock(main->output.to); - } - else { - fss_basic_read_print_at(main, i, *delimits, except_none, data); - } - - return F_none; - } - - ++at; - } // for - - if (data->option & fss_basic_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_basic_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } -#endif // _di_fss_basic_read_process_at_ - -#ifndef _di_fss_basic_read_process_columns_ - f_status_t fss_basic_read_process_columns(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) { - - if (!(data->option & fss_basic_read_data_option_content_d)) { - f_file_stream_lock(main->output.to); - - fss_basic_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - - return F_none; - } - - f_array_length_t max = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->contents.array[at].used > max) { - max = data->contents.array[at].used; - } - } // for - - fll_print_format("%ul%r", main->output.to, max, f_string_eol_s); - - return F_none; - } -#endif // _di_fss_basic_read_process_columns_ - -#ifndef _di_fss_basic_read_process_line_ - f_status_t fss_basic_read_process_line(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(data, 0) ? &data->delimits : &except_none; - - f_array_length_t line = 0; - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (!(data->option & fss_basic_read_data_option_object_d) && (data->option & fss_basic_read_data_option_content_d)) { - if (!data->contents.array[i].used) { - if (data->option & fss_basic_read_data_option_empty_d) { - if (line == data->line) { - f_file_stream_lock(main->output.to); - - fss_basic_read_print_set_end(main); - - f_file_stream_unlock(main->output.to); - - break; - } - - ++line; - } - - continue; - } - } - - if (line == data->line) { - fss_basic_read_print_at(main, i, *delimits, except_none, data); - - break; - } - - ++line; - } // for - - return F_none; - } -#endif // _di_fss_basic_read_process_line_ - -#ifndef _di_fss_basic_read_process_name_ - f_status_t fss_basic_read_process_name(fss_basic_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - - if (data->depths.array[0].index_name) { - f_array_length_t i = 0; - - memset(names, F_false, sizeof(bool) * data->objects.used); - - if (data->option & fss_basic_read_data_option_trim_d) { - for (i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_except_trim_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits) == F_equal_to) { - names[i] = F_true; - } - } // for - } - else { - for (i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_except_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits) == F_equal_to) { - names[i] = F_true; - } - } // for - } - } - else { - memset(names, F_true, sizeof(bool) * data->objects.used); - } - - return F_none; - } -#endif // _di_fss_basic_read_process_name_ - -#ifndef _di_fss_basic_read_process_option_ - f_status_t fss_basic_read_process_option(fll_program_data_t * const main, fss_basic_read_data_t * const data) { - - f_status_t status = F_none; - - if (main->parameters.array[fss_basic_read_parameter_at_e].result & f_console_result_value_e) { - data->option |= fss_basic_read_data_option_at_d; - } - - if (main->parameters.array[fss_basic_read_parameter_columns_e].result & f_console_result_found_e) { - data->option |= fss_basic_read_data_option_columns_d; - } - - if (main->parameters.array[fss_basic_read_parameter_content_e].result & f_console_result_found_e) { - data->option |= fss_basic_read_data_option_content_d; - } - - if (main->parameters.array[fss_basic_read_parameter_empty_e].result & f_console_result_found_e) { - data->option |= fss_basic_read_data_option_empty_d; - } - - if (main->parameters.array[fss_basic_read_parameter_line_e].result & f_console_result_value_e) { - data->option |= fss_basic_read_data_option_line_d; - - status = fss_basic_read_load_number(main, data, fss_basic_read_parameter_line_e, fss_basic_read_long_line_s, &data->line); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_basic_read_parameter_name_e].result & f_console_result_value_e) { - data->option |= fss_basic_read_data_option_name_d; - } - - if (main->parameters.array[fss_basic_read_parameter_object_e].result & f_console_result_found_e) { - data->option |= fss_basic_read_data_option_object_d; - } - - if (main->parameters.array[fss_basic_read_parameter_original_e].result & f_console_result_found_e) { - data->option |= fss_basic_read_data_option_original_d; - } - - if (main->parameters.array[fss_basic_read_parameter_select_e].result & f_console_result_value_e) { - data->option |= fss_basic_read_data_option_select_d; - - status = fss_basic_read_load_number(main, data, fss_basic_read_parameter_select_e, fss_basic_read_long_select_s, &data->select); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_basic_read_parameter_total_e].result & f_console_result_found_e) { - data->option |= fss_basic_read_data_option_total_d; - } - - if (main->parameters.array[fss_basic_read_parameter_trim_e].result & f_console_result_found_e) { - data->option |= fss_basic_read_data_option_trim_d; - } - - // Default to content if neither Object nor Content is explicitly requested. - if (!(data->option & (fss_basic_read_data_option_content_d | fss_basic_read_data_option_object_d))) { - data->option |= fss_basic_read_data_option_content_d; - } - - return F_none; - } -#endif // _di_fss_basic_read_process_option_ - -#ifndef _di_fss_basic_read_process_total_ - f_status_t fss_basic_read_process_total(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) { - - f_array_length_t total = 0; - - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (!(data->option & fss_basic_read_data_option_object_d) && data->option & fss_basic_read_data_option_content_d) { - if (!(data->contents.array[i].used || (data->option & fss_basic_read_data_option_empty_d))) { - continue; - } - } - - ++total; - } // for - - f_file_stream_lock(main->output.to); - - if (data->option & fss_basic_read_data_option_line_d) { - if (data->line < total) { - fss_basic_read_print_one(main); - } - else { - fss_basic_read_print_zero(main); - } - } - else { - fl_print_format("%ul%r", main->output.to, total, f_string_eol_s); - } - - f_file_stream_unlock(main->output.to); - - return F_none; - } -#endif // _di_fss_basic_read_process_total_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_basic_read/c/private-read.h b/level_3/fss_basic_read/c/private-read.h deleted file mode 100644 index c9b2128..0000000 --- a/level_3/fss_basic_read/c/private-read.h +++ /dev/null @@ -1,274 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_read_h -#define _PRIVATE_read_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Determine if the given depth is to be delimited or not for an Object. - * - * @param data - * The program data. - * @param depth - * The depth to check. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_basic_read_delimit_object_is_ - extern f_status_t fss_basic_read_delimit_object_is(fss_basic_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_delimit_object_is_ - -/** - * Process the parameters, parsing out and handling the depth and depth related parameters. - * - * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). - * - * @param main - * The main program data. - * @param arguments - * The parameters passed to the process. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_string_append(). - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * Errors (with error bit) from: f_rip_dynamic(). - * - * Errors (with error bit) from: fss_basic_read_depths_resize(). - * - * @see f_string_append() - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * @see f_rip_dynamic() - * - * @see fss_basic_read_depths_resize() - */ -#ifndef _di_fss_basic_read_depth_process_ - extern f_status_t fss_basic_read_depth_process(fll_program_data_t * const main, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_depth_process_ - -/** - * Get the name of the file the given position represents within the buffer. - * - * @param at - * The position within the buffer. - * @param files - * The representation of files and their respective ranges within the buffer. - * - * @return - * A string with the name when found. - * NULL is returned if the range represents the STDIN pipe. - * - * On failure to identify, an empty string is returned. - */ -#ifndef _di_fss_basic_read_file_identify_ - extern f_string_static_t fss_basic_read_file_identify(const f_array_length_t at, const fss_basic_read_files_t files) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_file_identify_ - -/** - * Process the buffer, loading the FSS data. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * F_data_not_stop (with warning bit) on no valid FSS data found and reached stopping point. - * F_data_not_eos (with warning bit) on no valid FSS data found and reached end of string. - * - * Errors (with error bit) from: fll_fss_basic_read() - * - * @see fll_fss_basic_read() - * - * @see fss_basic_read_process_option() - */ -#ifndef _di_fss_basic_read_load_ - extern f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_load_ - -/** - * Load a given number parameter. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param parameter - * An ID representing the parameter. - * @param name - * The parameter name to print on error. - * @param number - * The location to store the loaded number. - * - * @return - * F_true on success and the parameter was found (and is valid). - * F_false on success and the parameter was not found. - * - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * - * @see fss_basic_read_depths_resize() - */ -#ifndef _di_fss_basic_read_load_number_ - extern f_status_t fss_basic_read_load_number(fll_program_data_t * const main, fss_basic_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_load_number_ - -/** - * Perform the basic read processing on the buffer. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_basic_read_load() - * Errors (with error bit) from: fss_basic_read_process_option() - * - * @see fss_basic_read_load() - * @see fss_basic_read_process_option() - */ -#ifndef _di_fss_basic_read_process_ - extern f_status_t fss_basic_read_process(fll_program_data_t * const main, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_process_ - -/** - * Process based on at parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_read_process_at_ - extern f_status_t fss_basic_read_process_at(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_process_at_ - -/** - * Process based on columns parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_read_process_columns_ - extern f_status_t fss_basic_read_process_columns(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_process_columns_ - -/** - * Process based on line parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_read_process_line_ - extern f_status_t fss_basic_read_process_line(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_process_line_ - -/** - * Process the Objects in the buffer, determining if the Object name is to be used or not. - * - * How an Object name is determined to be used or not is dependent on several parameters, such as --name, --depth, --at, and --line. - * - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_read_process_name_ - extern f_status_t fss_basic_read_process_name(fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_process_name_ - -/** - * Process the parameters, populating the option property of the program data. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_basic_read_load_setting() - * - * @see fll_fss_basic_read() - * - * @see fss_basic_read_load_setting() - */ -#ifndef _di_fss_basic_read_process_option_ - extern f_status_t fss_basic_read_process_option(fll_program_data_t * const main, fss_basic_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_process_option_ - -/** - * Process based on total parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_basic_read_process_total_ - extern f_status_t fss_basic_read_process_total(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_read_process_total_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_read_h diff --git a/level_3/fss_basic_read/data/build/defines b/level_3/fss_basic_read/data/build/defines deleted file mode 100644 index 490da41..0000000 --- a/level_3/fss_basic_read/data/build/defines +++ /dev/null @@ -1,6 +0,0 @@ -# fss-0000 - -_di_thread_support_ Disables thread support. - -_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. -_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/fss_basic_read/data/build/dependencies b/level_3/fss_basic_read/data/build/dependencies deleted file mode 100644 index 22cdeb6..0000000 --- a/level_3/fss_basic_read/data/build/dependencies +++ /dev/null @@ -1,31 +0,0 @@ -# fss-0000 - -f_type -f_status -f_memory -f_type_array -f_string -f_utf -f_color -f_compare -f_console -f_conversion -f_directory -f_environment -f_file -f_fss -f_parse -f_pipe -f_print -f_rip -f_signal - -fl_conversion -fl_fss -fl_print - -fll_error -fll_file -fll_fss -fll_print -fll_program diff --git a/level_3/fss_basic_read/data/build/fakefile b/level_3/fss_basic_read/data/build/fakefile deleted file mode 100644 index 891d5d6..0000000 --- a/level_3/fss_basic_read/data/build/fakefile +++ /dev/null @@ -1,27 +0,0 @@ -# fss-0005 iki-0002 - -settings: - fail exit - modes individual individual_thread level monolithic clang test fanalyzer thread threadless - - environment PATH LD_LIBRARY_PATH - environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -main: - build - -install: - shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' - -help: - print - print context:'title'Fakefile Options for FSS Basic Read Software.context:'reset' - - print - print The following operations are available\: - print " - context:'notable'help:context:'reset' Perform the help operation, printing this message." - print " - context:'notable'install:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." - print " - context:'notable'main:context:'reset' The default compilation using the build settings mode." - - print - print The context:'notable'install context:'reset'operation supports the context:'notable'work,context:'reset' context:'notable'verbosity,context:'reset' and context:'notable'color context:'reset'parameters. diff --git a/level_3/fss_basic_read/data/build/settings b/level_3/fss_basic_read/data/build/settings deleted file mode 100644 index 7848db0..0000000 --- a/level_3/fss_basic_read/data/build/settings +++ /dev/null @@ -1,85 +0,0 @@ -# fss-0001 -# -# Modes: -# - individual: Compile using per project (individual) libraries, does not handle thread or threadless cases. -# - individual_thread: This is required when compiling in individual mode with "thread" mode. -# - level: Compile using per level libraries. -# - monolithic: Compile using per monolithic libraries. -# - clang: Use clang rather than the default, which is generally gcc. -# - test: Compile for a test, such as unit testing. -# - fanalyzer: Compile using GCC's -fanalyzer compile time option. -# - thread: Compile with thread support. -# - threadless: Compile without thread support. -# - -build_name fss_basic_read - -version_major 0 -version_minor 7 -version_micro 0 -version_file micro -version_target minor - -modes individual individual_thread level monolithic clang test fanalyzer thread threadless -modes_default monolithic thread - -build_compiler gcc -build_compiler-clang clang -build_indexer ar -build_indexer_arguments rcs -build_language c - -build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lf_color -lf_rip -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_parse -lf_path -lf_pipe -lf_print -lf_compare -lf_signal -lf_status_string -lf_string -lf_type_array -lf_utf -build_libraries-individual_thread -lf_thread -build_libraries-level -lfll_2 -lfll_1 -lfll_0 -build_libraries-monolithic -lfll - -build_sources_library fss_basic_read.c common.c print.c private-common.c private-print.c private-read.c - -build_sources_program main.c - -build_sources_headers fss_basic_read.h common.h print.h - -build_sources_documentation man - -build_script yes -build_shared yes -build_static no - -path_headers program/fss_basic_read -path_library_script script -path_library_shared shared -path_library_static static -path_object_script script -path_object_shared shared -path_object_static static -path_program_script script -path_program_shared shared -path_program_static static - -has_path_standard yes -preserve_path_headers yes - -search_exclusive yes -search_shared yes -search_static yes - -environment PATH LD_LIBRARY_PATH -environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -#defines -D_di_libcap_ -defines -D_libcap_legacy_only_ -defines-threadless -D_di_thread_support_ -defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ - -flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces -flags-thread -pthread -flags-clang -Wno-logical-op-parentheses -flags-test -O0 -fstack-protector -Wall -flags-fanalyzer -fanalyzer -flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ - -flags_library -fPIC -flags_object -fPIC -flags_program -fPIE diff --git a/level_3/fss_basic_read/data/documentation/man/man1/fss_basic_read.1 b/level_3/fss_basic_read/data/documentation/man/man1/fss_basic_read.1 deleted file mode 100644 index d5710d7..0000000 --- a/level_3/fss_basic_read/data/documentation/man/man1/fss_basic_read.1 +++ /dev/null @@ -1,145 +0,0 @@ -.TH FSS_BASIC_READ "1" "January 2023" "FLL - FSS Basic Read 0.7.0" "User Commands" -.SH NAME -fss_basic_read \- Read data in \fBFSS-0000 (Basic)\fR format. -.SH SYNOPSIS -.B fss_basic_read -[\fI\,OPTIONS\/\fR] [\fI\,FILENAMES\/\fR] -.SH DESCRIPTION -.PP -This program will print the Content associated with the given Object and Content main based on the \fBFSS-0000 Basic\fR standard. - -All numeric positions (indexes) start at 0 instead of 1. -For example, a file of 17 lines would range from 0 to 16. - -When using the \fB\-\-depth\fR option, an order of operations is enforced on the parameters. -When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter: - \fB\-\-at\fR: An Object index at the specified depth. - \fB\-\-depth\fR: A new depth within the specified depth, indexed from the root. - \fB\-\-name\fR: An Object name at the specified depth. - -The parameter \fB\-\-depth\fR must be in numeric order, but values in between may be skipped. - ('\fB\-d 0 \-a 1 \-d 2 \-a 2\fR' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.) - ('\fB\-d 2 \-a 1 \-d 0 \-a 2\fR' would be invalid because depth 2 is before depth 1.) - -The parameter \fB\-\-select\fR selects a Content column. - -Specify both \fB\-\-object\fR and the \fB\-\-total\fR parameters to get the total objects. - -When both \fB\-\-at\fR and \fB\-\-name\fR parameters are specified (at the same depth), the \fB\-\-at\fR parameter value will be treated as a position relative to the specified \fB\-\-name\fR parameter value. - -This program may support parameters, such as \fB\-\-depth\fR or \fB\-\-select\fR, even if not supported by the standard. -This is done to help ensure consistency for scripting. - -For parameters like \fB\-\-depth\fR, if the standard doesn't support nested Content, then only a depth of 0 would be valid. -For parameters like \fB\-\-select\fR, if the standard doesn't support multiple Content groups, then only a select of 0 would be valid. - -The parameter \fB\-\-trim\fR will remove leading and trailing white spaces when selecting objects or when printing objects. - -When specifying both the \fB\-\-object\fR parameter and the \fB\-\-content\fR parameter, the entire Object and Content are printed, including the formatting. -Both the Object and Content printed are already escaped. -Both the Object and Content are separated by a space. - -The parameter \fB\-\-delimit\fR accepts the following: - \fBnone\fR: Do not apply delimits. - \fBall\fR: (default) Apply all delimits. - \fBobject\fR: Apply delimits for Objects. - \fBA number, 0 or greater\fR: apply delimits for Content at the specified depth. - \fBA number, 0 or greater, followed by a +\fR: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically). - \fBA number, 0 or lesser, followed by a \-\fR: (such as '1\-') apply delimits for Content at the specified depth and any lesser depth (numerically). - -The \fB\-\-delimit\fR parameter may be specified multiple times to customize the delimit behavior. -The \fB\-\-delimit\fR values none and all, overrule all other delimit values. - -The parameters \fB\-\-columns\fR and \fB\-\-select\fR refer to a Content column. -The word '\fBcolumn\fR' is being loosely defined to refer to a specific Content. -This is not to be confused with a depth. -.SH OPTIONS -.TP -\fB\{\-h, \-\-help\fR -Print the help message. -.TP -\fB+C, ++copyright\fR -Print the copyright. -.TP -\fB+d, ++dark\fR -Output using colors that show up better on dark backgrounds. -.TP -\fB+l, ++light\fR -Output using colors that show up better on light backgrounds. -.TP -\fB+n, ++no_color\fR -Do not print using color. -.TP -\fB+Q, ++quiet\fR -Decrease verbosity, silencing most output. -.TP -\fB+E, ++error\fR -Decrease verbosity, using only error output. -.TP -\fB+N, ++normal\fR -Set verbosity to normal. -.TP -\fB+V, ++verbose\fR -Increase verbosity beyond normal output. -.TP -\fB+D, ++debug\fR -Enable debugging, significantly increasing verbosity beyond normal output. -.TP -\fB+v, ++version\fR -Print only the version number. -.TP -\fB+F, ++line_first_no\fR -Disable printing of first line. -.TP -\fB+L, ++line_last_no\fR -Disable printing of last line. -.TP -\fB\-a, \-\-at\fR -Select Object at this numeric index. -.TP -\fB\-c, \-\-content\fR -Print the Content (default). -.TP -\fB\-C, \-\-columns\fR -Print the total number of columns. -.TP -\fB\-D, \-\-delimit\fR -Designate how to handle applying delimits. -.TP -\fB\-d, \-\-depth\fR -Select Object at this numeric depth. -.TP -\fB\-e, \-\-empty\fR -Include empty Content when processing. -.TP -\fB\-l, \-\-line\fR -Print only the Content at the given line. -.TP -\fB\-n, \-\-name\fR -Select Object with this name. -.TP -\fB\-o, \-\-object\fR -Print the Object. -.TP -\fB\-p, \-\-pipe\fR -Print using the special pipe format. -.TP -\fB\-O, \-\-original\fR -Print with the original quotes and escapes. -.TP -\fB\-s, \-\-select\fR -Select sub-Content at this index. -.TP -\fB\-t, \-\-total\fR -Print the total number of lines. -.TP -\fB\-T, \-\-trim\fR -Trim Object names on select or print. -.SH FILENAMES -.TP -Any number of files to read. -.SH AUTHOR -Written by Kevin Day. -.SH COPYRIGHT -.PP -Copyright \(co 2007-2023 Kevin Day, GNU LGPL Version 2.1 or later. diff --git a/level_3/fss_extended_list_read/c/common.c b/level_3/fss_extended_list_read/c/common.c deleted file mode 100644 index f7465ca..0000000 --- a/level_3/fss_extended_list_read/c/common.c +++ /dev/null @@ -1,205 +0,0 @@ -#include "fss_extended_list_read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_list_read_program_version_s_ - const f_string_static_t fss_extended_list_read_program_version_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_program_version_s, 0, FSS_EXTENDED_LIST_READ_program_version_s_length); -#endif // _di_fss_extended_list_read_program_version_s_ - -#ifndef _di_fss_extended_list_read_program_name_s_ - const f_string_static_t fss_extended_list_read_program_name_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_program_name_s, 0, FSS_EXTENDED_LIST_READ_program_name_s_length); - const f_string_static_t fss_extended_list_read_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_program_name_long_s, 0, FSS_EXTENDED_LIST_READ_program_name_long_s_length); -#endif // _di_fss_extended_list_read_program_name_s_ - -#ifndef _di_fss_extended_list_read_pipe_s_ - const f_string_static_t fss_extended_list_read_pipe_name_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_pipe_name_s, 0, FSS_EXTENDED_LIST_READ_pipe_name_s_length); - const f_string_static_t fss_extended_list_read_pipe_content_end_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_pipe_content_end_s, 0, FSS_EXTENDED_LIST_READ_pipe_content_end_s_length); - const f_string_static_t fss_extended_list_read_pipe_content_ignore_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_pipe_content_ignore_s, 0, FSS_EXTENDED_LIST_READ_pipe_content_ignore_s_length); - const f_string_static_t fss_extended_list_read_pipe_content_start_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_pipe_content_start_s, 0, FSS_EXTENDED_LIST_READ_pipe_content_start_s_length); -#endif // _di_fss_extended_list_read_pipe_s_ - -#ifndef _di_fss_extended_list_read_parameter_d_ - const f_string_static_t fss_extended_list_read_short_at_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_at_s, 0, FSS_EXTENDED_LIST_READ_short_at_s_length); - const f_string_static_t fss_extended_list_read_short_content_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_content_s, 0, FSS_EXTENDED_LIST_READ_short_content_s_length); - const f_string_static_t fss_extended_list_read_short_columns_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_columns_s, 0, FSS_EXTENDED_LIST_READ_short_columns_s_length); - const f_string_static_t fss_extended_list_read_short_delimit_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_delimit_s, 0, FSS_EXTENDED_LIST_READ_short_delimit_s_length); - const f_string_static_t fss_extended_list_read_short_depth_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_depth_s, 0, FSS_EXTENDED_LIST_READ_short_depth_s_length); - const f_string_static_t fss_extended_list_read_short_empty_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_empty_s, 0, FSS_EXTENDED_LIST_READ_short_empty_s_length); - const f_string_static_t fss_extended_list_read_short_line_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_line_s, 0, FSS_EXTENDED_LIST_READ_short_line_s_length); - const f_string_static_t fss_extended_list_read_short_name_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_name_s, 0, FSS_EXTENDED_LIST_READ_short_name_s_length); - const f_string_static_t fss_extended_list_read_short_object_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_object_s, 0, FSS_EXTENDED_LIST_READ_short_object_s_length); - const f_string_static_t fss_extended_list_read_short_pipe_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_pipe_s, 0, FSS_EXTENDED_LIST_READ_short_pipe_s_length); - const f_string_static_t fss_extended_list_read_short_original_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_original_s, 0, FSS_EXTENDED_LIST_READ_short_original_s_length); - const f_string_static_t fss_extended_list_read_short_select_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_select_s, 0, FSS_EXTENDED_LIST_READ_short_select_s_length); - const f_string_static_t fss_extended_list_read_short_total_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_total_s, 0, FSS_EXTENDED_LIST_READ_short_total_s_length); - const f_string_static_t fss_extended_list_read_short_trim_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_short_trim_s, 0, FSS_EXTENDED_LIST_READ_short_trim_s_length); - - const f_string_static_t fss_extended_list_read_long_at_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_at_s, 0, FSS_EXTENDED_LIST_READ_long_at_s_length); - const f_string_static_t fss_extended_list_read_long_content_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_content_s, 0, FSS_EXTENDED_LIST_READ_long_content_s_length); - const f_string_static_t fss_extended_list_read_long_columns_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_columns_s, 0, FSS_EXTENDED_LIST_READ_long_columns_s_length); - const f_string_static_t fss_extended_list_read_long_delimit_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_delimit_s, 0, FSS_EXTENDED_LIST_READ_long_delimit_s_length); - const f_string_static_t fss_extended_list_read_long_depth_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_depth_s, 0, FSS_EXTENDED_LIST_READ_long_depth_s_length); - const f_string_static_t fss_extended_list_read_long_empty_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_empty_s, 0, FSS_EXTENDED_LIST_READ_long_empty_s_length); - const f_string_static_t fss_extended_list_read_long_line_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_line_s, 0, FSS_EXTENDED_LIST_READ_long_line_s_length); - const f_string_static_t fss_extended_list_read_long_name_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_name_s, 0, FSS_EXTENDED_LIST_READ_long_name_s_length); - const f_string_static_t fss_extended_list_read_long_object_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_object_s, 0, FSS_EXTENDED_LIST_READ_long_object_s_length); - const f_string_static_t fss_extended_list_read_long_pipe_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_pipe_s, 0, FSS_EXTENDED_LIST_READ_long_pipe_s_length); - const f_string_static_t fss_extended_list_read_long_original_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_original_s, 0, FSS_EXTENDED_LIST_READ_long_original_s_length); - const f_string_static_t fss_extended_list_read_long_select_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_select_s, 0, FSS_EXTENDED_LIST_READ_long_select_s_length); - const f_string_static_t fss_extended_list_read_long_total_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_total_s, 0, FSS_EXTENDED_LIST_READ_long_total_s_length); - const f_string_static_t fss_extended_list_read_long_trim_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_long_trim_s, 0, FSS_EXTENDED_LIST_READ_long_trim_s_length); -#endif // _di_fss_extended_list_read_parameter_d_ - -#ifndef _di_fss_extended_list_read_delimit_mode_s_ - const f_string_static_t fss_extended_list_read_delimit_mode_name_none_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_delimit_mode_name_none_s, 0, FSS_EXTENDED_LIST_READ_delimit_mode_name_none_s_length); - const f_string_static_t fss_extended_list_read_delimit_mode_name_all_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_delimit_mode_name_all_s, 0, FSS_EXTENDED_LIST_READ_delimit_mode_name_all_s_length); - const f_string_static_t fss_extended_list_read_delimit_mode_name_object_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_delimit_mode_name_object_s, 0, FSS_EXTENDED_LIST_READ_delimit_mode_name_object_s_length); - const f_string_static_t fss_extended_list_read_delimit_mode_name_greater_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_delimit_mode_name_greater_s, 0, FSS_EXTENDED_LIST_READ_delimit_mode_name_greater_s_length); - const f_string_static_t fss_extended_list_read_delimit_mode_name_lesser_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_LIST_READ_delimit_mode_name_lesser_s, 0, FSS_EXTENDED_LIST_READ_delimit_mode_name_lesser_s_length); -#endif // _di_fss_extended_list_read_delimit_mode_s_ - -#ifndef _di_fss_extended_list_read_main_delete_ - f_status_t fss_extended_list_read_main_delete(fll_program_data_t *main) { - - return fll_program_data_delete(main); - } -#endif // _di_fss_extended_list_read_main_delete_ - -#ifndef _di_fss_extended_list_read_setting_delete_ - f_status_t fss_extended_list_read_setting_delete(fss_extended_list_read_setting_t * const setting) { - - if (!setting) return F_status_set_error(F_parameter); - - return F_none; - } -#endif // _di_fss_extended_list_read_setting_delete_ - -#ifndef _di_fss_extended_list_read_setting_load_ - void fss_extended_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting) { - - if (!main) return; - - main->setting.state.step_small = fss_extended_list_read_allocation_console_d; - - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - - main->setting.state.step_small = fss_extended_list_read_allocation_small_d; - - // Identify and pocess first/last parameters. - if (main->program.parameters.array[fss_extended_list_read_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_extended_list_read_main_flag_print_first_e; - } - else { - main->setting.flag |= fss_extended_list_read_main_flag_print_first_e; - } - - if (main->program.parameters.array[fss_extended_list_read_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_extended_list_read_main_flag_print_last_e; - } - else { - main->setting.flag |= fss_extended_list_read_main_flag_print_last_e; - } - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_extended_list_read_parameter_no_color_e, fss_extended_list_read_parameter_light_e, fss_extended_list_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_extended_list_read_parameter_verbosity_quiet_e, fss_extended_list_read_parameter_verbosity_error_e, fss_extended_list_read_parameter_verbosity_verbose_e, fss_extended_list_read_parameter_verbosity_debug_e, fss_extended_list_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - static const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - } - - main->program.output.to.id = F_type_descriptor_output_d; - main->program.output.to.stream = F_type_output_d; - main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - - if (main->program.parameters.array[fss_extended_list_read_parameter_help_e].result & f_console_result_found_e) { - main->setting.flag |= fss_extended_list_read_main_flag_help_e; - - return; - } - - if (main->program.parameters.array[fss_extended_list_read_parameter_version_e].result & f_console_result_found_e) { - main->setting.flag |= fss_extended_list_read_main_flag_version_e; - - return; - } - - if (main->program.parameters.array[fss_extended_list_read_parameter_copyright_e].result & f_console_result_found_e) { - main->setting.flag |= fss_extended_list_read_main_flag_copyright_e; - - return; - } - - f_string_static_t * const args = main->program.parameters.arguments.array; - - if (main->program.parameters.array[fss_extended_list_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - main->setting.flag |= fss_extended_list_read_main_flag_strip_invalid_e; - } - } -#endif // _di_fss_extended_list_read_setting_load_ - -#ifndef _di_fss_extended_list_read_setting_unload_ - f_status_t fss_extended_list_read_setting_unload(fss_extended_list_read_main_t * const main) { - - if (!main) return F_status_set_error(F_parameter); - - fss_extended_list_read_setting_delete(&main->setting); - - return F_none; - } -#endif // _di_fss_extended_list_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_list_read/c/common.h b/level_3/fss_extended_list_read/c/common.h deleted file mode 100644 index 112ed18..0000000 --- a/level_3/fss_extended_list_read/c/common.h +++ /dev/null @@ -1,450 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Extended List Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the common data structures. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _fss_extended_list_read_common_h -#define _fss_extended_list_read_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The program version. - */ -#ifndef _di_fss_extended_list_read_program_version_s_ - #define FSS_EXTENDED_LIST_READ_program_version_major_s F_string_ascii_0_s - #define FSS_EXTENDED_LIST_READ_program_version_minor_s F_string_ascii_7_s - #define FSS_EXTENDED_LIST_READ_program_version_micro_s F_string_ascii_0_s - - #define FSS_EXTENDED_LIST_READ_program_version_major_s_length F_string_ascii_0_s_length - #define FSS_EXTENDED_LIST_READ_program_version_minor_s_length F_string_ascii_7_s_length - #define FSS_EXTENDED_LIST_READ_program_version_micro_s_length F_string_ascii_0_s_length - - #if !(defined(FSS_EXTENDED_LIST_READ_program_version_nano_prefix_s) && defined(FSS_EXTENDED_LIST_READ_program_version_nano_prefix_s_length)) - #define FSS_EXTENDED_LIST_READ_program_version_nano_prefix_s - #define FSS_EXTENDED_LIST_READ_program_version_nano_prefix_s_length 0 - #endif // !(defined(FSS_EXTENDED_LIST_READ_program_version_nano_prefix_s) && defined(FSS_EXTENDED_LIST_READ_program_version_nano_prefix_s_length)) - - #if !(defined(FSS_EXTENDED_LIST_READ_program_version_nano_s) && defined(FSS_EXTENDED_LIST_READ_program_version_nano_s_length)) - #define FSS_EXTENDED_LIST_READ_program_version_nano_s - #define FSS_EXTENDED_LIST_READ_program_version_nano_s_length 0 - #endif // !(defined(FSS_EXTENDED_LIST_READ_program_version_nano_s) && defined(FSS_EXTENDED_LIST_READ_program_version_nano_s_length)) - - #define FSS_EXTENDED_LIST_READ_program_version_s FSS_EXTENDED_LIST_READ_program_version_major_s F_string_ascii_period_s FSS_EXTENDED_LIST_READ_program_version_minor_s F_string_ascii_period_s FSS_EXTENDED_LIST_READ_program_version_micro_s FSS_EXTENDED_LIST_READ_program_version_nano_prefix_s FSS_EXTENDED_LIST_READ_program_version_nano_s - - #define FSS_EXTENDED_LIST_READ_program_version_s_length FSS_EXTENDED_LIST_READ_program_version_major_s_length + F_string_ascii_period_s_length + FSS_EXTENDED_LIST_READ_program_version_minor_s_length + F_string_ascii_period_s_length + FSS_EXTENDED_LIST_READ_program_version_micro_s_length + FSS_EXTENDED_LIST_READ_program_version_nano_prefix_s_length + FSS_EXTENDED_LIST_READ_program_version_nano_s_length - - extern const f_string_static_t fss_extended_list_read_program_version_s; -#endif // _di_fss_extended_list_read_program_version_s_ - -/** - * The program name. - * - * fss_extended_list_read_pipe_*: - * - name: A name used to represent the pipe when printing file names. - * - content_end: A code used to represent the end of Content for use in binary formats. - * - content_ignore: A code used to represent the ignoring Content for use in binary formats. - * - content_start: A code used to represent the start of Content for use in binary formats. - */ -#ifndef _di_fss_extended_list_read_program_name_s_ - #define FSS_EXTENDED_LIST_READ_program_name_s "fss_extended_list_read" - #define FSS_EXTENDED_LIST_READ_program_name_long_s "FSS Extended List Read" - - #define FSS_EXTENDED_LIST_READ_program_name_s_length 22 - #define FSS_EXTENDED_LIST_READ_program_name_long_s_length 22 - - extern const f_string_static_t fss_extended_list_read_program_name_s; - extern const f_string_static_t fss_extended_list_read_program_name_long_s; -#endif // _di_fss_extended_list_read_program_name_s_ - -/** - * The program defines. - * - * fss_extended_list_read_*_d: - * - allocation_console: An allocation step used for small buffers specifically for console parameter. - * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. - * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. - * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. - */ -#ifndef _di_fss_extended_list_read_d_ - #define fss_extended_list_read_allocation_console_d 4 - #define fss_extended_list_read_allocation_large_d 256 - #define fss_extended_list_read_allocation_small_d 16 - #define fss_extended_list_read_signal_check_d 20000 -#endif // _di_fss_extended_list_read_d_ - -/** - * The program pipe strings. - */ -#ifndef _di_fss_extended_list_read_pipe_s_ - #define FSS_EXTENDED_LIST_READ_pipe_name_s "(pipe)" - - #define FSS_EXTENDED_LIST_READ_pipe_content_end_s "\f" - #define FSS_EXTENDED_LIST_READ_pipe_content_ignore_s "\v" - #define FSS_EXTENDED_LIST_READ_pipe_content_start_s "\b" - - #define FSS_EXTENDED_LIST_READ_pipe_name_s_length 6 - - #define FSS_EXTENDED_LIST_READ_pipe_content_end_s_length 1 - #define FSS_EXTENDED_LIST_READ_pipe_content_ignore_s_length 1 - #define FSS_EXTENDED_LIST_READ_pipe_content_start_s_length 1 - - extern const f_string_static_t fss_extended_list_read_pipe_name_s; - - extern const f_string_static_t fss_extended_list_read_pipe_content_end_s; - extern const f_string_static_t fss_extended_list_read_pipe_content_ignore_s; - extern const f_string_static_t fss_extended_list_read_pipe_content_start_s; -#endif // _di_fss_extended_list_read_pipe_s_ - -/** - * The main program parameters. - */ -#ifndef _di_fss_extended_list_read_parameter_d_ - #define FSS_EXTENDED_LIST_READ_short_at_s "a" - #define FSS_EXTENDED_LIST_READ_short_content_s "c" - #define FSS_EXTENDED_LIST_READ_short_columns_s "C" - #define FSS_EXTENDED_LIST_READ_short_delimit_s "D" - #define FSS_EXTENDED_LIST_READ_short_depth_s "d" - #define FSS_EXTENDED_LIST_READ_short_empty_s "e" - #define FSS_EXTENDED_LIST_READ_short_line_s "l" - #define FSS_EXTENDED_LIST_READ_short_name_s "n" - #define FSS_EXTENDED_LIST_READ_short_object_s "o" - #define FSS_EXTENDED_LIST_READ_short_pipe_s "p" - #define FSS_EXTENDED_LIST_READ_short_original_s "O" - #define FSS_EXTENDED_LIST_READ_short_select_s "s" - #define FSS_EXTENDED_LIST_READ_short_total_s "t" - #define FSS_EXTENDED_LIST_READ_short_trim_s "T" - - #define FSS_EXTENDED_LIST_READ_long_at_s "at" - #define FSS_EXTENDED_LIST_READ_long_content_s "content" - #define FSS_EXTENDED_LIST_READ_long_columns_s "columns" - #define FSS_EXTENDED_LIST_READ_long_delimit_s "delimit" - #define FSS_EXTENDED_LIST_READ_long_depth_s "depth" - #define FSS_EXTENDED_LIST_READ_long_empty_s "empty" - #define FSS_EXTENDED_LIST_READ_long_line_s "line" - #define FSS_EXTENDED_LIST_READ_long_name_s "name" - #define FSS_EXTENDED_LIST_READ_long_object_s "object" - #define FSS_EXTENDED_LIST_READ_long_pipe_s "pipe" - #define FSS_EXTENDED_LIST_READ_long_original_s "original" - #define FSS_EXTENDED_LIST_READ_long_select_s "select" - #define FSS_EXTENDED_LIST_READ_long_total_s "total" - #define FSS_EXTENDED_LIST_READ_long_trim_s "trim" - - #define FSS_EXTENDED_LIST_READ_short_at_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_content_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_columns_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_delimit_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_depth_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_empty_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_line_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_name_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_object_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_pipe_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_original_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_select_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_total_s_length 1 - #define FSS_EXTENDED_LIST_READ_short_trim_s_length 1 - - #define FSS_EXTENDED_LIST_READ_long_at_s_length 2 - #define FSS_EXTENDED_LIST_READ_long_content_s_length 7 - #define FSS_EXTENDED_LIST_READ_long_columns_s_length 7 - #define FSS_EXTENDED_LIST_READ_long_delimit_s_length 7 - #define FSS_EXTENDED_LIST_READ_long_depth_s_length 5 - #define FSS_EXTENDED_LIST_READ_long_empty_s_length 5 - #define FSS_EXTENDED_LIST_READ_long_line_s_length 4 - #define FSS_EXTENDED_LIST_READ_long_name_s_length 4 - #define FSS_EXTENDED_LIST_READ_long_object_s_length 6 - #define FSS_EXTENDED_LIST_READ_long_pipe_s_length 4 - #define FSS_EXTENDED_LIST_READ_long_original_s_length 8 - #define FSS_EXTENDED_LIST_READ_long_select_s_length 6 - #define FSS_EXTENDED_LIST_READ_long_total_s_length 5 - #define FSS_EXTENDED_LIST_READ_long_trim_s_length 4 - - extern const f_string_static_t fss_extended_list_read_short_at_s; - extern const f_string_static_t fss_extended_list_read_short_content_s; - extern const f_string_static_t fss_extended_list_read_short_columns_s; - extern const f_string_static_t fss_extended_list_read_short_delimit_s; - extern const f_string_static_t fss_extended_list_read_short_depth_s; - extern const f_string_static_t fss_extended_list_read_short_empty_s; - extern const f_string_static_t fss_extended_list_read_short_line_s; - extern const f_string_static_t fss_extended_list_read_short_name_s; - extern const f_string_static_t fss_extended_list_read_short_object_s; - extern const f_string_static_t fss_extended_list_read_short_pipe_s; - extern const f_string_static_t fss_extended_list_read_short_original_s; - extern const f_string_static_t fss_extended_list_read_short_select_s; - extern const f_string_static_t fss_extended_list_read_short_total_s; - extern const f_string_static_t fss_extended_list_read_short_trim_s; - - extern const f_string_static_t fss_extended_list_read_long_at_s; - extern const f_string_static_t fss_extended_list_read_long_content_s; - extern const f_string_static_t fss_extended_list_read_long_columns_s; - extern const f_string_static_t fss_extended_list_read_long_delimit_s; - extern const f_string_static_t fss_extended_list_read_long_depth_s; - extern const f_string_static_t fss_extended_list_read_long_empty_s; - extern const f_string_static_t fss_extended_list_read_long_line_s; - extern const f_string_static_t fss_extended_list_read_long_name_s; - extern const f_string_static_t fss_extended_list_read_long_object_s; - extern const f_string_static_t fss_extended_list_read_long_pipe_s; - extern const f_string_static_t fss_extended_list_read_long_original_s; - extern const f_string_static_t fss_extended_list_read_long_select_s; - extern const f_string_static_t fss_extended_list_read_long_total_s; - extern const f_string_static_t fss_extended_list_read_long_trim_s; - - enum { - fss_extended_list_read_parameter_help_e, - fss_extended_list_read_parameter_copyright_e - fss_extended_list_read_parameter_light_e, - fss_extended_list_read_parameter_dark_e, - fss_extended_list_read_parameter_no_color_e, - fss_extended_list_read_parameter_verbosity_quiet_e, - fss_extended_list_read_parameter_verbosity_error_e, - fss_extended_list_read_parameter_verbosity_normal_e, - fss_extended_list_read_parameter_verbosity_verbose_e, - fss_extended_list_read_parameter_verbosity_debug_e, - fss_extended_list_read_parameter_version_e, - fss_extended_list_read_parameter_line_first_no_e, - fss_extended_list_read_parameter_line_last_no_e, - - fss_extended_list_read_parameter_at_e, - fss_extended_list_read_parameter_content_e, - fss_extended_list_read_parameter_columns_e, - fss_extended_list_read_parameter_delimit_e, - fss_extended_list_read_parameter_depth_e, - fss_extended_list_read_parameter_empty_e, - fss_extended_list_read_parameter_line_e, - fss_extended_list_read_parameter_name_e, - fss_extended_list_read_parameter_object_e, - fss_extended_list_read_parameter_pipe_e, - fss_extended_list_read_parameter_original_e, - fss_extended_list_read_parameter_select_e, - fss_extended_list_read_parameter_total_e, - fss_extended_list_read_parameter_trim_e, - }; // enum - - #define fss_extended_list_read_console_parameter_t_initialize \ - { \ - macro_fll_program_console_parameter_standard_initialize, \ - \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_at_s, fss_extended_list_read_long_at_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_content_s, fss_extended_list_read_long_content_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_columns_s, fss_extended_list_read_long_columns_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_delimit_s, fss_extended_list_read_long_delimit_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_depth_s, fss_extended_list_read_long_depth_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_empty_s, fss_extended_list_read_long_empty_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_line_s, fss_extended_list_read_long_line_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_name_s, fss_extended_list_read_long_name_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_object_s, fss_extended_list_read_long_object_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_pipe_s, fss_extended_list_read_long_pipe_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_original_s, fss_extended_list_read_long_original_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_select_s, fss_extended_list_read_long_select_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_total_s, fss_extended_list_read_long_total_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_list_read_short_trim_s, fss_extended_list_read_long_trim_s, 0, 0, f_console_flag_normal_e), \ - } - - #define fss_extended_list_read_total_parameters_d 27 -#endif // _di_fss_extended_list_read_parameter_d_ - -/** - * FSS Delimit Parameter strings. - * - * fss_extended_list_read_delimit_mode_*: - * - all: All delimits are to be aplied. - * - content: Content are to have delimits applied. - * - content_greater: Content at this number or higher are to have delimits applied. - * - content_greater_object: Objects and Content at this number or higher are to have delimits applied. - * - content_lesser: Content at this number or lower are to have delimits applied. - * - content_lesser_object: Objects and Content at this number or lower are to have delimits applied. - * - content_object: Objects and Content are to have delimits applied - * - object: Objects arre to have delimits applied. - */ -#ifndef _di_fss_extended_list_read_delimit_mode_s_ - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_none_s "none" - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_all_s "all" - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_object_s "object" - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_greater_s "+" - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_lesser_s "-" - - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_none_s_length 4 - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_all_s_length 3 - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_object_s_length 6 - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_greater_s_length 1 - #define FSS_EXTENDED_LIST_READ_delimit_mode_name_lesser_s_length 1 - - extern const f_string_static_t fss_extended_list_read_delimit_mode_name_none_s; - extern const f_string_static_t fss_extended_list_read_delimit_mode_name_all_s; - extern const f_string_static_t fss_extended_list_read_delimit_mode_name_object_s; - extern const f_string_static_t fss_extended_list_read_delimit_mode_name_greater_s; - extern const f_string_static_t fss_extended_list_read_delimit_mode_name_lesser_s; -#endif // _di_fss_extended_list_read_delimit_modes_ - -/** - * FSS Delimit Parameter strings. - */ -#ifndef _di_fss_extended_list_read_delimit_mode_e_ - enum { - fss_extended_list_read_delimit_mode_none_e = 1, - fss_extended_list_read_delimit_mode_all_e, - fss_extended_list_read_delimit_mode_content_e, - fss_extended_list_read_delimit_mode_content_greater_e, - fss_extended_list_read_delimit_mode_content_greater_object_e, - fss_extended_list_read_delimit_mode_content_lesser_e, - fss_extended_list_read_delimit_mode_content_lesser_object_e, - fss_extended_list_read_delimit_mode_content_object_e, - fss_extended_list_read_delimit_mode_object_e, - }; // enum -#endif // _di_fss_extended_list_read_delimit_mode_e_ - -/** - * Flags passed to the main function or program. - * - * fss_extended_list_read_main_flag_*_e: - * - none: No flags set. - * - copyright: Print copyright. - * - file_from: Using a specified source file. - * - file_to: Using a specified destination file. - * - help: Print help. - * - header: Enable printing of headers. - * - print_first: When set, print new line to message output on program begin after loading settings. - * - print_last: When set, print new line to message output on program end. - * - separate: Enable printing of separators. - * - strip_invalid: Using strip invalid character mode. - * - verify: Using verify mode. - * - version: Print version. - */ -#ifndef _di_fss_extended_list_read_main_flag_e_ - enum { - fss_extended_list_read_main_flag_none_e = 0x0, - fss_extended_list_read_main_flag_copyright_e = 0x1, - fss_extended_list_read_main_flag_file_from_e = 0x2, - fss_extended_list_read_main_flag_file_to_e = 0x4, - fss_extended_list_read_main_flag_header_e = 0x8, - fss_extended_list_read_main_flag_help_e = 0x10, - fss_extended_list_read_main_flag_print_first_e = 0x20, - fss_extended_list_read_main_flag_print_last_e = 0x40, - fss_extended_list_read_main_flag_separate_e = 0x80, - fss_extended_list_read_main_flag_strip_invalid_e = 0x100, - fss_extended_list_read_main_flag_verify_e = 0x200, - fss_extended_list_read_main_flag_version_e = 0x400, - }; // enum -#endif // _di_fss_extended_list_read_main_flag_e_ - -/** - * The fss extended list read main program settings. - * - * This is passed to the program-specific main entry point to designate program settings. - * These program settings are often processed from the program arguments (often called the command line arguments). - * - * flag: Flags passed to the main function. - * - * state: The state information. - */ -#ifndef _di_fss_extended_list_read_setting_t_ - typedef struct { - uint16_t flag; - - f_state_t state; - } fss_extended_list_read_setting_t; - - #define fss_extended_list_read_setting_t_initialize \ - { \ - fss_extended_list_read_main_flag_none_e, \ - f_state_t_initialize, \ - } -#endif // _di_fss_extended_list_read_setting_t_ - -/** - * Deallocate main. - * - * @param main - * The main program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - * - * @see fss_extended_list_read_main() - */ -#ifndef _di_fss_extended_list_read_main_delete_ - extern f_status_t fss_extended_list_read_main_delete(fll_program_data_t *main); -#endif // _di_fss_extended_list_read_main_delete_ - -/** - * Delete the program main setting data. - * - * @param setting - * The program main setting data. - * - * This does not alter setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fss_extended_list_read_setting_delete_ - extern f_status_t fss_extended_list_read_setting_delete(fss_extended_list_read_setting_t * const setting); -#endif // _di_fss_extended_list_read_setting_delete_ - -/** - * Perform the standard program setting load process. - * - * This prints error messages as appropriate. - * - * If either main or setting is NULL, then this immediately returns without doing anything. - * - * @param arguments - * The parameters passed to the process (often referred to as command line arguments). - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.state.status: - * F_none on success. - * - * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). - * - * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() - */ -#ifndef _di_fss_extended_list_read_setting_load_ - extern void fss_extended_list_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting); -#endif // _di_fss_extended_list_read_setting_load_ - -/** - * Perform the standard program setting unload process. - * - * @param main - * The main program and setting data. - * All buffers are deallocated. - * - * This does not alter main.setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: fss_extended_list_read_setting_delete(). - * - * @see fss_extended_list_read_setting_delete() - */ -#ifndef _di_fss_extended_list_read_setting_unload_ - extern f_status_t fss_extended_list_read_setting_unload(fss_extended_list_read_main_t * const main); -#endif // _di_fss_extended_list_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_extended_list_read_common_h diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c deleted file mode 100644 index 4691215..0000000 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ /dev/null @@ -1,560 +0,0 @@ -#include "fss_extended_list_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_list_read_main_ - f_status_t fss_extended_list_read_main(fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting) { - - f_status_t status = F_none; - - setting->state.step_small = fss_extended_list_read_allocation_console_d; - - status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - - setting->state.step_small = fss_extended_list_read_allocation_small_d; - - if (F_status_is_error(status)) return; - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_extended_list_read_parameter_no_color_e, fss_extended_list_read_parameter_light_e, fss_extended_list_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_extended_list_read_parameter_verbosity_quiet_e, fss_extended_list_read_parameter_verbosity_error_e, fss_extended_list_read_parameter_verbosity_verbose_e, fss_extended_list_read_parameter_verbosity_debug_e, fss_extended_list_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - } - - if (main->parameters.array[fss_extended_list_read_parameter_help_e].result & f_console_result_found_e) { - fss_extended_list_read_print_help(setting, main->message); - - return status; - } - - if (main->parameters.array[fss_extended_list_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_extended_list_read_program_version_s); - - return status; - } - - if (main->parameters.array[fss_extended_list_read_parameter_copyright_e].result & f_console_result_found_e) { - fll_program_print_copyright(main->message); - - return status; - } - - status = F_none; - - // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. - fss_extended_list_read_file_t files_array[main->parameters.remaining.used + 1]; - fss_extended_list_read_data_t data = fss_extended_list_read_data_t_initialize; - - data.argv = main->parameters.arguments.array; - data.files.array = files_array; - data.files.used = 1; - data.files.size = main->parameters.remaining.used + 1; - data.files.array[0].name = fss_extended_list_read_pipe_name_s; - data.files.array[0].range.start = 1; - data.files.array[0].range.stop = 0; - - if (main->parameters.remaining.used || (main->pipe & fll_program_data_pipe_input_e)) { - { - const f_array_length_t parameter_code[] = { - fss_extended_list_read_parameter_at_e, - fss_extended_list_read_parameter_depth_e, - fss_extended_list_read_parameter_line_e, - fss_extended_list_read_parameter_select_e, - fss_extended_list_read_parameter_name_e, - fss_extended_list_read_parameter_delimit_e, - }; - - const f_string_static_t parameter_name[] = { - fss_extended_list_read_long_at_s, - fss_extended_list_read_long_depth_s, - fss_extended_list_read_long_line_s, - fss_extended_list_read_long_select_s, - fss_extended_list_read_long_name_s, - fss_extended_list_read_long_delimit_s, - }; - - const f_string_t message_positive_number = "positive number"; - const f_string_t message_string = "string"; - const f_string_t message_value = "value"; - - const f_string_t parameter_message[] = { - message_positive_number, - message_positive_number, - message_positive_number, - message_positive_number, - message_string, - message_value, - }; - - for (f_array_length_t i = 0; i < 6; ++i) { - - if (main->parameters.array[parameter_code[i]].result & f_console_result_found_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, parameter_name[i], main->error.notable); - fl_print_format("%[' requires a %s.%]%r", main->error.to, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_extended_list_read_parameter_columns_e].result & f_console_result_found_e)) { - const f_array_length_t parameter_code[] = { - fss_extended_list_read_parameter_depth_e, - fss_extended_list_read_parameter_line_e, - fss_extended_list_read_parameter_pipe_e, - fss_extended_list_read_parameter_select_e, - fss_extended_list_read_parameter_total_e, - }; - - const f_string_static_t parameter_name[] = { - fss_extended_list_read_long_depth_s, - fss_extended_list_read_long_line_s, - fss_extended_list_read_long_pipe_s, - fss_extended_list_read_long_select_s, - fss_extended_list_read_long_total_s, - }; - - const uint8_t parameter_match[] = { - f_console_result_value_e, - f_console_result_value_e, - f_console_result_found_e, - f_console_result_value_e, - f_console_result_found_e, - }; - - for (f_array_length_t i = 0; i < 5; ++i) { - - if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_extended_list_read_long_columns_s, parameter_name[i]); - } - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_extended_list_read_parameter_pipe_e].result & f_console_result_found_e)) { - if (main->parameters.array[fss_extended_list_read_parameter_total_e].result & f_console_result_found_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_extended_list_read_long_pipe_s, fss_extended_list_read_long_total_s); - } - - status = F_status_set_error(F_parameter); - } - else if (main->parameters.array[fss_extended_list_read_parameter_line_e].result & f_console_result_value_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_extended_list_read_long_pipe_s, fss_extended_list_read_long_line_s); - } - - status = F_status_set_error(F_parameter); - } - } - - if (F_status_is_error_not(status) && main->parameters.array[fss_extended_list_read_parameter_delimit_e].result & f_console_result_value_e) { - f_array_length_t index = 0; - f_array_length_t length = 0; - - // Set the value to 0 to allow for detecting mode based on what is provided. - data.delimit_mode = 0; - - for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_list_read_parameter_delimit_e].values.used; ++i) { - - if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - index = main->parameters.array[fss_extended_list_read_parameter_delimit_e].values.array[i]; - length = data.argv[index].used; - - if (!length) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_delimit_s, main->error.notable); - fl_print_format("%[' must not be empty.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - else if (f_compare_dynamic_string(fss_extended_list_read_delimit_mode_name_none_s.string, data.argv[index], fss_extended_list_read_delimit_mode_name_none_s.used) == F_equal_to) { - data.delimit_mode = fss_extended_list_read_delimit_mode_none_e; - } - else if (f_compare_dynamic_string(fss_extended_list_read_delimit_mode_name_all_s.string, data.argv[index], fss_extended_list_read_delimit_mode_name_all_s.used) == F_equal_to) { - data.delimit_mode = fss_extended_list_read_delimit_mode_all_e; - } - else if (f_compare_dynamic_string(fss_extended_list_read_delimit_mode_name_object_s.string, data.argv[index], fss_extended_list_read_delimit_mode_name_object_s.used) == F_equal_to) { - switch (data.delimit_mode) { - case 0: - data.delimit_mode = fss_extended_list_read_delimit_mode_object_e; - break; - - case fss_extended_list_read_delimit_mode_none_e: - case fss_extended_list_read_delimit_mode_all_e: - case fss_extended_list_read_delimit_mode_content_greater_object_e: - case fss_extended_list_read_delimit_mode_content_lesser_object_e: - case fss_extended_list_read_delimit_mode_object_e: - break; - - case fss_extended_list_read_delimit_mode_content_e: - data.delimit_mode = fss_extended_list_read_delimit_mode_content_object_e; - break; - - case fss_extended_list_read_delimit_mode_content_greater_e: - data.delimit_mode = fss_extended_list_read_delimit_mode_content_greater_object_e; - break; - - case fss_extended_list_read_delimit_mode_content_lesser_e: - data.delimit_mode = fss_extended_list_read_delimit_mode_content_lesser_object_e; - break; - - default: - break; - } - } - else { - if (!data.delimit_mode) { - data.delimit_mode = fss_extended_list_read_delimit_mode_content_e; - } - else if (data.delimit_mode == fss_extended_list_read_delimit_mode_object_e) { - data.delimit_mode = fss_extended_list_read_delimit_mode_content_object_e; - } - - if (data.argv[index].string[length - 1] == fss_extended_list_read_delimit_mode_name_greater_s.string[0]) { - if (!(data.delimit_mode == fss_extended_list_read_delimit_mode_none_e || data.delimit_mode == fss_extended_list_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_extended_list_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_extended_list_read_delimit_mode_content_greater_object_e; - } - else { - data.delimit_mode = fss_extended_list_read_delimit_mode_content_greater_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - else if (data.argv[index].string[length - 1] == fss_extended_list_read_delimit_mode_name_lesser_s.string[0]) { - if (!(data.delimit_mode == fss_extended_list_read_delimit_mode_none_e || data.delimit_mode == fss_extended_list_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_extended_list_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_extended_list_read_delimit_mode_content_lesser_object_e; - } - else { - data.delimit_mode = fss_extended_list_read_delimit_mode_content_lesser_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - - f_string_range_t range = macro_f_string_range_t_initialize_2(length); - - // Ignore leading plus sign. - if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { - ++range.start; - } - - status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], range, &data.delimit_depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_unsigned_detect", F_true, fss_extended_list_read_long_delimit_s, data.argv[index]); - - break; - } - - // There can be nothing smaller than 0, so replace '0-' logic with just '0' logic. - if (data.delimit_mode == fss_extended_list_read_delimit_mode_content_lesser_e || data.delimit_mode == fss_extended_list_read_delimit_mode_content_lesser_object_e) { - if (!data.delimit_depth) { - if (data.delimit_mode == fss_extended_list_read_delimit_mode_content_lesser_e) { - data.delimit_mode = fss_extended_list_read_delimit_mode_content_e; - } - else { - data.delimit_mode = fss_extended_list_read_delimit_mode_content_object_e; - } - } - } - } - } // for - - // Guarantee the default value is "all". - if (!data.delimit_mode) { - data.delimit_mode = fss_extended_list_read_delimit_mode_all_e; - } - } - - if (F_status_is_error_not(status)) { - status = fss_extended_list_read_depth_process(main, &data); - } - - // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. - if (F_status_is_error_not(status) && data.depths.array[0].depth > 0) { - if (main->parameters.array[fss_extended_list_read_parameter_total_e].result & f_console_result_found_e) { - fss_extended_list_read_print_zero(main); - } - - fss_extended_list_read_data_delete_simple(&data); - - return F_none; - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_extended_list_read_parameter_select_e].result & f_console_result_found_e)) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_select_s, main->error.notable); - fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - fss_extended_list_read_depths_resize(0, &data.depths); - - status = F_status_set_error(F_parameter); - } - - if (F_status_is_error_not(status)) { - for (f_array_length_t i = 0; i < data.files.used; ++i) { - macro_f_string_range_t_clear(data.files.array[i].range); - } // for - } - - if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { - f_file_t file = f_file_t_initialize; - - file.id = F_type_descriptor_input_d; - file.stream = F_type_input_d; - - data.files.array[0].range.start = 0; - - status = f_file_stream_read(file, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "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); - } - else if (data.buffer.used) { - data.files.array[0].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - else { - data.files.array[0].range.start = 1; - } - } - - if (F_status_is_error_not(status) && main->parameters.remaining.used > 0) { - f_file_t file = f_file_t_initialize; - off_t size_block = 0; - off_t size_file = 0; - off_t size_read = 0; - - for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - - if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - data.files.array[data.files.used].range.start = data.buffer.used; - file.stream = 0; - file.id = -1; - - status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); - - break; - } - - size_file = 0; - - status = f_file_size_by_id(file.id, &size_file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - if (size_file) { - - // Enforce a max block read size to allow for interrupts to be processed between blocks. - if (size_file > fss_extended_list_read_block_max) { - file.size_read = fss_extended_list_read_block_read_large; - size_block = fss_extended_list_read_block_max; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + (size_block - (size_file % size_block)) + 1, &data.buffer); - } - else { - file.size_read = fss_extended_list_read_block_read_small; - size_block = size_file; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + 1, &data.buffer); - } - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - for (size_read = 0; size_read < size_file; size_read += size_block) { - - // The signal check is always performed on each pass. - if (size_file > fss_extended_list_read_block_max && fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - status = f_file_stream_read_until(file, size_block, &data.buffer); - if (F_status_is_error(status)) break; - } // for - - f_file_stream_flush(file); - f_file_stream_close(&file); - - if (F_status_is_error(status)) { - if (F_status_set_fine(status) != F_interrupt) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read_until", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - } - - break; - } - - if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; - data.files.array[data.files.used++].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - } - else { - data.files.array[data.files.used].range.start = 1; - data.files.array[data.files.used].range.stop = 0; - } - } // for - } - - if (F_status_is_error_not(status)) { - status = fss_extended_list_read_process(main, &data); - } - - fss_extended_list_read_data_delete_simple(&data); - } - else { - fll_print_format("%r%[%QYou failed to specify one or more files.%]%r", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - status = F_status_set_error(F_parameter); - } - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - if (F_status_set_fine(status) == F_interrupt) { - f_file_stream_flush(main->output.to); - - fll_print_dynamic_raw(f_string_eol_s, main->output.to); - } - } - - fss_extended_list_read_data_delete_simple(&data); - - return status; - } -#endif // _di_fss_extended_list_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.h b/level_3/fss_extended_list_read/c/fss_extended_list_read.h deleted file mode 100644 index e2c2bcb..0000000 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This is the FSS Extended List Read program - * This program utilizes the Featureless Linux Library. - * This program processes files or other input in fss format and stores the results in the fll_program_data_t. - * - * This processes in accordance to the FSS-0003 Extended List specification. - */ -#ifndef _fss_extended_list_read_h -#define _fss_extended_list_read_h - -// Libc includes. -#include -#include -#include -#include -#include - -// FLL-0 includes. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// FLL-1 includes. -#include -#include - -// FLL-2 includes. -#include -#include -#include -#include -#include - -// FSS Extended List Read includes. -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Execute main program. - * - * If main.signal is non-zero, then this blocks and handles the following signals: - * - F_signal_abort - * - F_signal_broken_pipe - * - F_signal_hangup - * - F_signal_interrupt - * - F_signal_quit - * - F_signal_termination - * - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.state.status: - * F_none on success. - * F_true on success when performing verification and verify passed. - * F_false on success when performing verification and verify failed. - * F_interrupt on (exit) signal received. - * - * F_parameter (with error bit) if main is NULL or setting is NULL. - */ -#ifndef _di_fss_extended_list_read_main_ - extern f_status_t fss_extended_list_read_main(fll_program_data_t * const main, fss_extended_list_read_setting_t * const setting); -#endif // _di_fss_extended_list_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_extended_list_read_h diff --git a/level_3/fss_extended_list_read/c/main.c b/level_3/fss_extended_list_read/c/main.c deleted file mode 100644 index 96590d2..0000000 --- a/level_3/fss_extended_list_read/c/main.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "fss_extended_list_read.h" - -int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - - fss_extended_list_read_main_t data = fss_extended_list_read_main_t_initialize; - - data.program.debug.flag |= fss_extended_list_read_print_flag_debug_e | fss_extended_list_read_print_flag_out_e; - data.program.error.flag |= fss_extended_list_read_print_flag_error_e | fss_extended_list_read_print_flag_out_e; - data.program.output.flag |= fss_extended_list_read_print_flag_out_e; - data.program.message.flag |= fss_extended_list_read_print_flag_message_e | fss_extended_list_read_print_flag_out_e; - data.program.warning.flag |= fss_extended_list_read_print_flag_warning_e | fss_extended_list_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; - - f_console_parameter_t parameters[] = fss_extended_list_read_console_parameter_t_initialize; - data.program.parameters.array = parameters; - data.program.parameters.used = fss_extended_list_read_total_parameters_d; - data.program.environment = envp; - - if (f_pipe_input_exists()) { - data.program.pipe = fll_program_data_pipe_input_e; - } - - fll_program_standard_set_up(&data.program); - - { - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); - - fss_extended_list_read_setting_load(arguments, &data); - } - - fss_extended_list_read_main(&data); - - fss_extended_list_read_setting_unload(&data); - - fll_program_data_delete(&data.program); - - fll_program_standard_set_down(&data.program); - - return F_status_is_error(data.setting.state.status) ? 1 : 0; -} diff --git a/level_3/fss_extended_list_read/c/main.h b/level_3/fss_extended_list_read/c/main.h deleted file mode 100644 index 620a5b7..0000000 --- a/level_3/fss_extended_list_read/c/main.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Extended List - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This file is only ever included by main/main.c and should not normally be included anywhere else. - * Anything that wants to include this should be providing the "fss_extended_list_read" program functionality in some manner. - */ -#ifndef _fss_extended_list_read_main_h -#define _fss_extended_list_read_main_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Standard program entry point. - * - * @param argc - * The number of arguments. - * @param argv - * The array of arguments. - * @param envp - * The array of all environment variables on program start. - * - * @return - * 0 on success. - * 1 on error. - */ -extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_extended_list_read_main_h diff --git a/level_3/fss_extended_list_read/c/print.c b/level_3/fss_extended_list_read/c/print.c deleted file mode 100644 index 6445e27..0000000 --- a/level_3/fss_extended_list_read/c/print.c +++ /dev/null @@ -1,116 +0,0 @@ -#include "fss_embedded_list_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_list_read_print_help_ - f_status_t fss_extended_list_read_print_help(fss_extended_list_read_setting_t * const setting, const fl_print_t print) { - - f_file_stream_lock(print.to); - - fll_program_print_help_header(print, fss_extended_list_read_program_name_long_s, fss_extended_list_read_program_version_s); - - fll_program_print_help_option_standard(print); - - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_option(print, fss_extended_list_read_short_at_s, fss_extended_list_read_long_at_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric index."); - fll_program_print_help_option(print, fss_extended_list_read_short_content_s, fss_extended_list_read_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Content (default)."); - fll_program_print_help_option(print, fss_extended_list_read_short_columns_s, fss_extended_list_read_long_columns_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of columns."); - fll_program_print_help_option(print, fss_extended_list_read_short_delimit_s, fss_extended_list_read_long_delimit_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Designate how to handle applying delimits."); - fll_program_print_help_option(print, fss_extended_list_read_short_depth_s, fss_extended_list_read_long_depth_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric depth."); - fll_program_print_help_option(print, fss_extended_list_read_short_empty_s, fss_extended_list_read_long_empty_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Include empty Content when processing."); - fll_program_print_help_option(print, fss_extended_list_read_short_line_s, fss_extended_list_read_long_line_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print only the Content at the given line."); - fll_program_print_help_option(print, fss_extended_list_read_short_name_s, fss_extended_list_read_long_name_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object with this name."); - fll_program_print_help_option(print, fss_extended_list_read_short_object_s, fss_extended_list_read_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Object."); - fll_program_print_help_option(print, fss_extended_list_read_short_pipe_s, fss_extended_list_read_long_pipe_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print using the special pipe format."); - fll_program_print_help_option(print, fss_extended_list_read_short_original_s, fss_extended_list_read_long_original_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print with the original quotes and escapes."); - fll_program_print_help_option(print, fss_extended_list_read_short_select_s, fss_extended_list_read_long_select_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select sub-Content at this index."); - fll_program_print_help_option(print, fss_extended_list_read_short_total_s, fss_extended_list_read_long_total_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of lines."); - fll_program_print_help_option(print, fss_extended_list_read_short_trim_s, fss_extended_list_read_long_trim_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Trim Object names on select or print."); - - f_print_dynamic_raw(f_string_eol_s, print.to); - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_usage(print, fss_extended_list_read_program_name_s, fll_program_parameter_filenames_s); - - fl_print_format("%r %[Notes:%]%r", print.to, f_string_eol_s, print.set->important, print.set->important, f_string_eol_s); - - fl_print_format(" This program will print the Content associated with the given Object and Content main based on the FSS-0003 Extended List standard.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" All numeric positions (indexes) start at 0 instead of 1.%r", print.to, f_string_eol_s); - fl_print_format(" For example, a file of 17 lines would range from 0 to 16.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When using the %[%r%r%] option, an order of operations is enforced on the parameters.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_depth_s, print.set->notable, f_string_eol_s); - - fl_print_format(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%r", print.to, f_string_eol_s); - - fl_print_format(" %[%r%r%]: An Object index at the specified depth.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_at_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: A new depth within the specified depth, indexed from the root.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: An Object name at the specified depth.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] must be in numeric order, but values in between may be skipped.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%r", print.to, f_string_eol_s); - fl_print_format(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] selects a Content column.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_select_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" Specify both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_object_s, print.set->notable); - fl_print_format(" and the %[%r%r%] parameters to get the total objects.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_total_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_at_s, print.set->notable); - fl_print_format(" and %[%r%r%] parameters are specified (at the same depth),", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_name_s, print.set->notable); - fl_print_format(" the %[%r%r%] parameter value will be treated as a position relative to the specified", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_at_s, print.set->notable); - fl_print_format(" %[%r%r%] parameter value.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" This program may support parameters, such as %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_depth_s, print.set->notable); - fl_print_format(" or %[%r%r%], even if not supported by the standard.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_select_s, print.set->notable, f_string_eol_s); - fl_print_format(" This is done to help ensure consistency for scripting.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_depth_s, print.set->notable); - fl_print_format(" if the standard doesn't support nested Content, then only a depth of 0 would be valid.%r", print.to, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_select_s, print.set->notable); - fl_print_format(" if the standard doesn't support multiple Content groups, then only a select of 0 would be valid.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_trim_s, print.set->notable); - fl_print_format(" will remove leading and trailing white spaces when selecting objects or when printing objects.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When specifying both the %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_object_s, print.set->notable); - fl_print_format(" parameter and the %[%r%r%] parameter, the entire Object and Content are printed, including the formatting.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_content_s, print.set->notable, f_string_eol_s); - fl_print_format(" Both the Object and Content printed are already escaped.%r", print.to, f_string_eol_s); - fl_print_format(" Both the Object and Content are separated by a New Line character '\\n' (U+000A).%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] accepts the following:%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_delimit_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Do not apply delimits.%r", print.to, print.set->notable, fss_extended_list_read_delimit_mode_name_none_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: (default) Apply all delimits.%r", print.to, print.set->notable, fss_extended_list_read_delimit_mode_name_all_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Apply delimits for Objects.%r", print.to, print.set->notable, fss_extended_list_read_delimit_mode_name_object_s, print.set->notable, f_string_eol_s); - fl_print_format(" - A number, 0 or greater: apply delimits for Content at the specified depth.%r", print.to, f_string_eol_s); - fl_print_format(" - A number, 0 or greater, followed by a %[%r%]: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%r", print.to, print.set->notable, fss_extended_list_read_delimit_mode_name_greater_s, print.set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" - A number, 0 or lesser, followed by a %[%r%]: (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%r%r", print.to, print.set->notable, fss_extended_list_read_delimit_mode_name_lesser_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%] parameter may be specified multiple times to customize the delimit behavior.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_delimit_s, print.set->notable, f_string_eol_s); - - fl_print_format(" The %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_delimit_s, print.set->notable); - fl_print_format(" values %[%r%]", print.to, print.set->notable, fss_extended_list_read_delimit_mode_name_none_s, print.set->notable); - fl_print_format(" and %[%r%],", print.to, print.set->notable, fss_extended_list_read_delimit_mode_name_all_s, print.set->notable); - fl_print_format(" overrule all other delimit values.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameters %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_columns_s, print.set->notable); - fl_print_format(" and %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_select_s, print.set->notable); - fl_print_format(" refer to a Content column.%r", print.to, f_string_eol_s); - fl_print_format(" The word 'column' is being loosely defined to refer to a specific Content.%r", print.to, f_string_eol_s); - fl_print_format(" This is not to be confused with a depth.%r", print.to, f_string_eol_s); - - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_extended_list_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_list_read/c/print.h b/level_3/fss_extended_list_read/c/print.h deleted file mode 100644 index a350c54..0000000 --- a/level_3/fss_extended_list_read/c/print.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Embedded List Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _fss_embedded_list_read_print_h -#define _fss_embedded_list_read_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print help. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_list_read_print_help_ - extern f_status_t fss_extended_list_read_print_help(fss_extended_list_read_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_extended_list_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_embedded_list_read_print_h diff --git a/level_3/fss_extended_list_read/c/private-common.c b/level_3/fss_extended_list_read/c/private-common.c deleted file mode 100644 index 46fcfa1..0000000 --- a/level_3/fss_extended_list_read/c/private-common.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "fss_extended_list_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_list_read_data_delete_simple_ - void fss_extended_list_read_data_delete_simple(fss_extended_list_read_data_t *data) { - - if (!data) return; - - // data->files is expected to be statically loaded and cannot be deallocated. - - fss_extended_list_read_depths_resize(0, &data->depths); - - f_string_dynamic_resize(0, &data->buffer); - macro_f_fss_contents_t_delete_simple(data->contents); - macro_f_fss_objects_t_delete_simple(data->objects); - macro_f_fss_delimits_t_delete_simple(data->delimits_object); - macro_f_fss_delimits_t_delete_simple(data->delimits_content); - macro_f_fss_comments_t_delete_simple(data->comments); - } -#endif // _di_fss_extended_list_read_data_delete_simple_ - -#ifndef _di_fss_extended_list_read_depth_delete_simple_ - void fss_extended_list_read_depth_delete_simple(fss_extended_list_read_depth_t *depth) { - - if (!depth) return; - - f_string_dynamic_resize(0, &depth->value_name); - } -#endif // _di_fss_extended_list_read_depth_delete_simple_ - -#ifndef _di_fss_extended_list_read_depths_resize_ - f_status_t fss_extended_list_read_depths_resize(const f_array_length_t length, fss_extended_list_read_depths_t *depths) { - - if (!depths) { - return F_status_set_error(F_parameter); - } - - for (f_array_length_t i = length; i < depths->size; ++i) { - fss_extended_list_read_depth_delete_simple(&depths->array[i]); - } // for - - const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_extended_list_read_depth_t), (void **) & depths->array); - if (F_status_is_error(status)) return status; - - depths->size = length; - - if (depths->used > depths->size) { - depths->used = length; - } - - return F_none; - } -#endif // _di_fss_extended_list_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_list_read/c/private-common.h b/level_3/fss_extended_list_read/c/private-common.h deleted file mode 100644 index 1078cd3..0000000 --- a/level_3/fss_extended_list_read/c/private-common.h +++ /dev/null @@ -1,269 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: Extended List Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_common_h -#define _PRIVATE_common_h - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Provide common/generic definitions. - * - * extended_list_read_common_allocation_*: - * - large: An allocation step used for buffers that are anticipated to have large buffers. - * - small: An allocation step used for buffers that are anticipated to have small buffers. - * - * fss_extended_list_read_block_*: - * - max: The max block read size before checking for interrupt. - * - read_small: The block read size for small files. - * - read_large: The block read size for large files. - */ -#ifndef _di_fss_extended_list_read_common_ - #define fss_extended_list_read_common_allocation_large_d 2048 - #define fss_extended_list_read_common_allocation_small_d 128 - - #define fss_extended_list_read_block_max 16777216 - #define fss_extended_list_read_block_read_small 8192 - #define fss_extended_list_read_block_read_large 65536 -#endif // _di_fss_extended_list_read_common_ - -/** - * A structure of parameters applied at some depth. - * - * depth: The depth number in which this is to be processed at. - * - * index_at: Position of the "--at" parameter value in the argv list, when 0 there is no parameter. - * index_name: Position of the "--name" parameter value in the argv list, when 0 there is no parameter. - * - * value_at: The value of the "--at" parameter, already processed and ready to use, only when index_at > 0. - * value_name: The value of the "--name" parameter, already processed and ready to use, only when index_name > 0. - */ -#ifndef _di_fss_extended_list_read_depth_t_ - typedef struct { - f_array_length_t depth; - - f_array_length_t index_at; - f_array_length_t index_name; - - f_number_unsigned_t value_at; - f_string_dynamic_t value_name; - } fss_extended_list_read_depth_t; - - #define fss_extended_list_read_depth_t_initialize \ - { \ - 0, \ - 0, \ - 0, \ - 0, \ - f_string_dynamic_t_initialize, \ - } - - #define macro_fss_extended_list_read_depth_t_clear(structure) \ - structure.depth = 0; \ - structure.index_at = 0; \ - structure.index_name = 0; \ - structure.value_at = 0; \ - macro_f_string_dynamic_t_clear(structure.value_name) -#endif // _di_fss_extended_list_read_depth_t_ - -/** - * An array of depth parameters. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_extended_list_read_depths_t_ - typedef struct { - fss_extended_list_read_depth_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_extended_list_read_depths_t; - - #define fss_extended_list_read_depths_t_initialize { 0, 0, 0 } - - #define macro_fss_extended_list_read_depths_t_clear(depths) macro_f_memory_structure_clear(depths) -#endif // _di_fss_extended_list_read_depths_t_ - -/** - * A structure for designating where within the buffer a particular file exists, using a statically allocated array. - * - * name: The name of the file representing the range. - * range: A range within the buffer representing the file. - */ -#ifndef _di_fss_extended_list_read_file_t_ - typedef struct { - f_string_static_t name; - f_string_range_t range; - } fss_extended_list_read_file_t; - - #define fss_extended_list_read_file_t_initialize \ - { \ - f_string_static_t_initialize, \ - f_string_range_t_initialize, \ - } -#endif // _di_fss_extended_list_read_file_t_ - -/** - * An array of files. - * - * This is intended to be defined and used statically allocated and as such no dynamic allocation or dynamic deallocation methods are provided. - * - * The STDIN pipe is reserved for index 0 and as such size and used must be initialized to 1. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_extended_list_read_files_t_ - typedef struct { - fss_extended_list_read_file_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_extended_list_read_files_t; - - #define fss_extended_list_read_files_t_initialize { 0, 1, 1 } -#endif // _di_fss_extended_list_read_files_t_ - -/** - * The data structure for FSS Basic Read. - * - * fss_extended_list_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - 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). - * - * argv: The argument structure in the progam data parameters for simplifying syntax. - * options: Bitwise flags representing parameters. - * delimit_mode: The delimit mode. - * delimit_depth: The delimit depth. - * select: The Content to select (column number). - * line: The Content to select (row number). - * files: A statically allocated array of files for designating where in the buffer a file is represented. - * depths: The array of parameters for each given depth. - * buffer: The buffer containing all loaded files (and STDIN pipe). - * objects: The positions within the buffer representing Objects. - * 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. - */ -#ifndef _di_fss_extended_list_read_data_t_ - #define fss_extended_list_read_data_option_at_d 0x1 - #define fss_extended_list_read_data_option_columns_d 0x2 - #define fss_extended_list_read_data_option_content_d 0x4 - #define fss_extended_list_read_data_option_empty_d 0x8 - #define fss_extended_list_read_data_option_line_d 0x10 - #define fss_extended_list_read_data_option_name_d 0x20 - #define fss_extended_list_read_data_option_object_d 0x40 - #define fss_extended_list_read_data_option_original_d 0x80 - #define fss_extended_list_read_data_option_select_d 0x100 - #define fss_extended_list_read_data_option_total_d 0x200 - #define fss_extended_list_read_data_option_trim_d 0x400 - - typedef struct { - uint16_t option; - uint8_t delimit_mode; - f_array_length_t delimit_depth; - f_number_unsigned_t select; - f_number_unsigned_t line; - - f_string_static_t *argv; - - fss_extended_list_read_files_t files; - fss_extended_list_read_depths_t depths; - - f_string_dynamic_t buffer; - f_fss_objects_t objects; - f_fss_contents_t contents; - f_fss_delimits_t delimits_object; - f_fss_delimits_t delimits_content; - f_uint8s_t quotes; - f_fss_comments_t comments; - } fss_extended_list_read_data_t; - - #define fss_extended_list_read_data_t_initialize \ - { \ - 0, \ - fss_extended_list_read_delimit_mode_all_e, \ - 0, \ - 0, \ - 0, \ - 0, \ - fss_extended_list_read_files_t_initialize, \ - fss_extended_list_read_depths_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_fss_objects_t_initialize, \ - f_fss_contents_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_uint8s_t_initialize, \ - f_fss_comments_t_initialize, \ - } -#endif // _di_fss_extended_list_read_data_t_ - -/** - * Fully deallocate all memory for the given data without caring about return status. - * - * @param data - * The data to deallocate. - */ -#ifndef _di_fss_extended_list_read_data_delete_simple_ - extern void fss_extended_list_read_data_delete_simple(fss_extended_list_read_data_t *data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_data_delete_simple_ - -/** - * Fully deallocate all memory for the given depth without caring about return status. - * - * @param depth - * The depth to deallocate. - */ -#ifndef _di_fss_extended_list_read_depth_delete_simple_ - extern void fss_extended_list_read_depth_delete_simple(fss_extended_list_read_depth_t *depth) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_depth_delete_simple_ - -/** - * Resize the depth array. - * - * @param length - * The new size to use. - * @param depths - * The depth array to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * Errors (with error bit) from: fss_extended_list_read_depths_increase(). - * - * @see f_memory_resize() - * - * @see fss_extended_list_read_depth_delete_simple() - * @see fss_extended_list_read_depths_increase() - */ -#ifndef _di_fss_extended_list_read_depths_resize_ - extern f_status_t fss_extended_list_read_depths_resize(const f_array_length_t length, fss_extended_list_read_depths_t *depths) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_common_h diff --git a/level_3/fss_extended_list_read/c/private-print.c b/level_3/fss_extended_list_read/c/private-print.c deleted file mode 100644 index 7404fdd..0000000 --- a/level_3/fss_extended_list_read/c/private-print.c +++ /dev/null @@ -1,129 +0,0 @@ -#include "fss_extended_list_read.h" -#include "private-common.h" -#include "private-print.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_list_read_print_at_ - void fss_extended_list_read_print_at(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_extended_list_read_data_t * const data) { - - if (at >= data->contents.used) { - return; - } - - if ((data->option & fss_extended_list_read_data_option_object_d) || ((data->option & fss_extended_list_read_data_option_content_d) && (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop || (data->option & fss_extended_list_read_data_option_empty_d)))) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_extended_list_read_data_option_object_d) { - if (data->option & fss_extended_list_read_data_option_trim_d) { - fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - else { - f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - - fss_extended_list_read_print_object_end(main, data); - } - - if (data->option & fss_extended_list_read_data_option_content_d) { - if (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) { - if (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) { - fss_extended_list_read_print_content_ignore(main); - - f_print_except_in_dynamic_partial(data->buffer, data->contents.array[at].array[0], delimits_content, data->comments, main->output.to); - - fss_extended_list_read_print_content_ignore(main); - } - } - } - - fss_extended_list_read_print_set_end(main, data); - - f_file_stream_unlock(main->output.to); - } - } -#endif // _di_fss_extended_list_read_print_at_ - -#ifndef _di_fss_extended_list_read_print_at_object_ - void fss_extended_list_read_print_at_object(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t at, const f_fss_delimits_t delimits_object) { - - if (at >= data->objects.used) { - return; - } - - if (data->option & fss_extended_list_read_data_option_trim_d) { - fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - else { - f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - - fss_extended_list_read_print_object_end(main, data); - } -#endif // _di_fss_extended_list_read_print_at_object_ - -#ifndef _di_fss_extended_list_read_print_content_ignore_ - void fss_extended_list_read_print_content_ignore(fll_program_data_t * const main) { - - if (main->parameters.array[fss_extended_list_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_extended_list_read_pipe_content_ignore_s, main->output.to); - } - } -#endif // _di_fss_extended_list_read_print_content_ignore_ - -#ifndef _di_fss_extended_list_read_print_object_end_ - void fss_extended_list_read_print_object_end(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - - if (main->parameters.array[fss_extended_list_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_extended_list_read_pipe_content_start_s, main->output.to); - } - else { - if ((data->option & fss_extended_list_read_data_option_object_d) && (data->option & fss_extended_list_read_data_option_content_d)) { - f_print_dynamic_raw(f_fss_extended_list_open_s, main->output.to); - f_print_dynamic_raw(f_fss_extended_list_open_end_s, main->output.to); - } - } - } -#endif // _di_fss_extended_list_read_print_object_end_ - -#ifndef _di_fss_extended_list_read_print_set_end_ - void fss_extended_list_read_print_set_end(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - - if (main->parameters.array[fss_extended_list_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_extended_list_read_pipe_content_end_s, main->output.to); - } - else { - if (data->option & fss_extended_list_read_data_option_object_d) { - if (data->option & fss_extended_list_read_data_option_content_d) { - f_print_dynamic_raw(f_fss_extended_list_close_s, main->output.to); - f_print_dynamic_raw(f_fss_extended_list_close_end_s, main->output.to); - } - else if (!(data->option & fss_extended_list_read_data_option_content_d)) { - f_print_dynamic_raw(f_fss_eol_s, main->output.to); - } - } - } - } -#endif // _di_fss_extended_list_read_print_set_end_ - -#ifndef _di_fss_extended_list_read_print_one_ - void fss_extended_list_read_print_one(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_1_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_extended_list_read_print_one_ - -#ifndef _di_fss_extended_list_read_print_zero_ - void fss_extended_list_read_print_zero(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_0_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_extended_list_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_list_read/c/private-print.h b/level_3/fss_extended_list_read/c/private-print.h deleted file mode 100644 index 3411d4d..0000000 --- a/level_3/fss_extended_list_read/c/private-print.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_print_h -#define _PRIVATE_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print the Object and Content at the given position. - * - * Only what is requested to print (Object, Content, both, or neither) will be printed, if there is something to print. - * - * @param main - * The main program data. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param data - * The program data. - */ -#ifndef _di_fss_extended_list_read_print_at_ - extern void fss_extended_list_read_print_at(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_print_at_ - -/** - * Explicitly print the Object at the given position. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - */ -#ifndef _di_fss_extended_list_read_print_at_object_ - extern void fss_extended_list_read_print_at_object(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t at, const f_fss_delimits_t delimits_object) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_print_at_object_ - -/** - * Print the ignore character for Content. - * - * This is only used in pipe output mode. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_extended_list_read_print_content_ignore_ - extern void fss_extended_list_read_print_content_ignore(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_print_content_ignore_ - -/** - * Print the end of an Object (which is essentially the start of Content). - * - * @param main - * The main program data. - * @param data - * The program data. - */ -#ifndef _di_fss_extended_list_read_print_object_end_ - extern void fss_extended_list_read_print_object_end(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_print_object_end_ - -/** - * Print the number one and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_extended_list_read_print_one_ - extern void fss_extended_list_read_print_one(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_print_one_ - -/** - * Print the end of an Object/Content set. - * - * @param main - * The main program data. - * @param data - * The program data. - */ -#ifndef _di_fss_extended_list_read_print_set_end_ - extern void fss_extended_list_read_print_set_end(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_print_set_end_ - -/** - * Print the number zero and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_extended_list_read_print_zero_ - extern void fss_extended_list_read_print_zero(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_print_h diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c deleted file mode 100644 index d052169..0000000 --- a/level_3/fss_extended_list_read/c/private-read.c +++ /dev/null @@ -1,787 +0,0 @@ -#include "fss_extended_list_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_list_read_delimit_content_is_ - f_status_t fss_extended_list_read_delimit_content_is(fss_extended_list_read_data_t * const data, const f_array_length_t depth) { - - if (data->delimit_mode == fss_extended_list_read_delimit_mode_none_e) { - return F_false; - } - - if (data->delimit_mode == fss_extended_list_read_delimit_mode_all_e) { - return F_true; - } - - if (depth < data->delimit_depth) { - return data->delimit_mode == fss_extended_list_read_delimit_mode_content_lesser_e; - } - - if (depth == data->delimit_depth) { - return F_true; - } - - return data->delimit_mode == fss_extended_list_read_delimit_mode_content_greater_e; - } -#endif // _di_fss_extended_list_read_delimit_content_is_ - -#ifndef _di_fss_extended_list_read_delimit_object_is_ - f_status_t fss_extended_list_read_delimit_object_is(fss_extended_list_read_data_t * const data, const f_array_length_t depth) { - - switch (data->delimit_mode) { - case fss_extended_list_read_delimit_mode_none_e: - case fss_extended_list_read_delimit_mode_content_e: - case fss_extended_list_read_delimit_mode_content_greater_e: - case fss_extended_list_read_delimit_mode_content_lesser_e: - return F_false; - - case fss_extended_list_read_delimit_mode_all_e: - case fss_extended_list_read_delimit_mode_content_object_e: - case fss_extended_list_read_delimit_mode_content_greater_object_e: - case fss_extended_list_read_delimit_mode_content_lesser_object_e: - case fss_extended_list_read_delimit_mode_object_e: - return F_true; - - default: - break; - } - - return depth == data->delimit_depth || data->delimit_mode == fss_extended_list_read_delimit_mode_content_lesser_e; - } -#endif // _di_fss_extended_list_read_delimit_object_is_ - -#ifndef _di_fss_extended_list_read_depth_process_ - f_status_t fss_extended_list_read_depth_process(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - - f_status_t status = F_none; - - { - f_array_length_t depth_size = 1; - - if (main->parameters.array[fss_extended_list_read_parameter_depth_e].result & f_console_result_value_e) { - depth_size = main->parameters.array[fss_extended_list_read_parameter_depth_e].values.used; - } - - if (depth_size > data->depths.size) { - status = fss_extended_list_read_depths_resize(depth_size, &data->depths); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fss_extended_list_read_depths_resize", fll_error_file_flag_fallback_e); - - return status; - } - } - - data->depths.used = depth_size; - } - - f_array_length_t position_depth = 0; - f_array_length_t position_at = 0; - f_array_length_t position_name = 0; - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - data->depths.array[i].depth = 0; - data->depths.array[i].index_at = 0; - data->depths.array[i].index_name = 0; - data->depths.array[i].value_at = 0; - - macro_f_string_dynamic_t_clear(data->depths.array[i].value_name); - - if (!main->parameters.array[fss_extended_list_read_parameter_depth_e].values.used) { - position_depth = 0; - } - else { - position_depth = main->parameters.array[fss_extended_list_read_parameter_depth_e].values.array[i]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[position_depth], &data->depths.array[i].depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_extended_list_read_long_depth_s, data->argv[position_depth]); - - return status; - } - } - - if (main->parameters.array[fss_extended_list_read_parameter_at_e].result & f_console_result_value_e) { - for (; position_at < main->parameters.array[fss_extended_list_read_parameter_at_e].values.used; ++position_at) { - - if (main->parameters.array[fss_extended_list_read_parameter_at_e].values.array[position_at] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_extended_list_read_parameter_at_e].values.array[position_at] > main->parameters.array[fss_extended_list_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_at = main->parameters.array[fss_extended_list_read_parameter_at_e].values.array[position_at]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[data->depths.array[i].index_at], &data->depths.array[i].value_at); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_extended_list_read_long_at_s, data->argv[data->depths.array[i].index_at]); - - return status; - } - } // for - } - - if (main->parameters.array[fss_extended_list_read_parameter_name_e].result & f_console_result_value_e) { - for (; position_name < main->parameters.array[fss_extended_list_read_parameter_name_e].values.used; ++position_name) { - - if (main->parameters.array[fss_extended_list_read_parameter_name_e].values.array[position_name] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_extended_list_read_parameter_name_e].values.array[position_name] > main->parameters.array[fss_extended_list_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_name = main->parameters.array[fss_extended_list_read_parameter_name_e].values.array[position_name]; - - if (main->parameters.array[fss_extended_list_read_parameter_trim_e].result & f_console_result_found_e) { - status = f_rip_dynamic(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - else { - status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), (main->parameters.array[fss_extended_list_read_parameter_trim_e].result & f_console_result_found_e) ? "f_rip_dynamic" : "f_string_dynamic_append", fll_error_file_flag_fallback_e); - - return status; - } - } // for - } - } // for - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - - if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' may only be specified once for the parameter '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_depth_s, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - else if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_extended_list_read_long_depth_s, main->error.notable); - fl_print_format("%[' may not have the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' before the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[j].depth, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - } // for - } // for - - return F_none; - } -#endif // _di_fss_extended_list_read_depth_process_ - -#ifndef _di_fss_extended_list_read_file_identify_ - f_string_static_t fss_extended_list_read_file_identify(const f_array_length_t at, const fss_extended_list_read_files_t files) { - - for (f_array_length_t i = 0; i < files.used; ++i) { - - if (at >= files.array[i].range.start && at <= files.array[i].range.stop) { - return files.array[i].name; - } - } // for - - // When stopped after the end of the buffer, the last file in the list is the correct file. - if (at > files.array[files.used - 1].range.stop) { - return files.array[files.used - 1].name; - } - - return f_string_empty_s; - } -#endif // _di_fss_extended_list_read_file_identify_ - -#ifndef _di_fss_extended_list_read_load_ - f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - - f_state_t state = macro_f_state_t_initialize_1(fss_extended_list_read_common_allocation_large_d, fss_extended_list_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); - f_string_range_t input = macro_f_string_range_t_initialize_2(data->buffer.used); - - data->delimits_object.used = 0; - data->delimits_content.used = 0; - - const f_status_t status = fll_fss_extended_list_read(data->buffer, state, &input, &data->objects, &data->contents, &data->delimits_object, &data->delimits_content, &data->comments); - - if (F_status_is_error(status)) { - const f_string_static_t file_name = fss_extended_list_read_file_identify(input.start, data->files); - - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_extended_list_read", fll_error_file_flag_fallback_e, file_name, f_file_operation_process_s, fll_error_file_type_file_e); - - return status; - } - - if (status == F_data_not_stop || status == F_data_not_eos) { - if (data->option & fss_extended_list_read_data_option_total_d) return F_none; - - return F_status_set_warning(status); - } - - return F_none; - } -#endif // _di_fss_extended_list_read_load_ - -#ifndef _di_fss_extended_list_read_load_number_ - f_status_t fss_extended_list_read_load_number(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { - - if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - - const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, name, data->argv[index]); - - return status; - } - - return F_true; - } - - return F_false; - } -#endif // _di_fss_extended_list_read_load_number_ - -#ifndef _di_fss_extended_list_read_process_ - f_status_t fss_extended_list_read_process(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - - f_status_t status = fss_extended_list_read_process_option(main, data); - if (F_status_is_error(status)) return status; - - // This standard does not support multiple content groups. - if ((data->option & fss_extended_list_read_data_option_select_d) && data->select) { - if (main->parameters.array[fss_extended_list_read_parameter_total_e].result & f_console_result_found_e) { - fss_extended_list_read_print_zero(main); - } - - return F_none; - } - - status = fss_extended_list_read_load(main, data); - if (F_status_is_error(status)) return status; - - bool names[data->objects.used]; - - status = fss_extended_list_read_process_name(data, names); - if (F_status_is_error(status)) return status; - - if (data->depths.array[0].index_at) { - return fss_extended_list_read_process_at(main, data, names); - } - - if (data->option & fss_extended_list_read_data_option_columns_d) { - return fss_extended_list_read_process_columns(main, data, names); - } - - if (data->option & fss_extended_list_read_data_option_total_d) { - return fss_extended_list_read_process_total(main, data, names); - } - - if (data->option & fss_extended_list_read_data_option_line_d) { - return fss_extended_list_read_process_line(main, data, names); - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - - if (data->option & fss_extended_list_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - fss_extended_list_read_print_at(main, i, *delimits_object, *delimits_content, data); - } // for - - return F_none; - } -#endif // _di_fss_extended_list_read_process_ - -#ifndef _di_fss_extended_list_read_process_at_ - f_status_t fss_extended_list_read_process_at(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { - - if (data->depths.array[0].value_at >= data->objects.used) { - if (data->option & (fss_extended_list_read_data_option_columns_d | fss_extended_list_read_data_option_total_d)) { - f_file_stream_lock(main->output.to); - - fss_extended_list_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - - if (data->option & fss_extended_list_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t at = 0; - f_status_t status = F_none; - - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (!names[i]) continue; - - if (at == data->depths.array[0].value_at) { - if (data->option & fss_extended_list_read_data_option_line_d) { - f_array_length_t line = 0; - - status = fss_extended_list_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); - if (status == F_success) return F_none; - } - else if (data->option & fss_extended_list_read_data_option_columns_d) { - fll_print_format("%ul%r", main->output.to, data->contents.array[i].used, f_string_eol_s); - } - else if (data->option & fss_extended_list_read_data_option_total_d) { - if ((data->option & fss_extended_list_read_data_option_object_d) && !(data->option & fss_extended_list_read_data_option_content_d)) { - f_file_stream_lock(main->output.to); - - if (data->contents.array[i].used) { - fss_extended_list_read_print_one(main); - } - else { - fss_extended_list_read_print_zero(main); - } - - f_file_stream_unlock(main->output.to); - } - else { - f_array_length_t total = 0; - f_array_length_t j = 0; - f_array_length_t k = 0; - - for (; j < data->contents.array[i].used; ++j) { - - if (data->contents.array[i].array[0].start > data->contents.array[i].array[0].stop) { - if (data->option & fss_extended_list_read_data_option_object_d) { - total += 2; - } - } - else { - if (data->option & fss_extended_list_read_data_option_object_d) { - total += 2; - } - - for (k = data->contents.array[i].array[0].start; k <= data->contents.array[i].array[0].stop; ++k) { - if (data->buffer.string[k] == f_string_eol_s.string[0]) ++total; - } // for - - k = data->contents.array[i].array[0].stop; - - while (k >= data->contents.array[i].array[0].start) { - - if (data->buffer.string[k] == f_fss_placeholder_s.string[0]) { - --k; - - continue; - } - - if (data->buffer.string[k] != f_string_eol_s.string[0]) { - ++total; - } - - break; - } // while - } - } // for - - fll_print_format("%ul%r", main->output.to, total, f_string_eol_s); - } - } - else { - fss_extended_list_read_print_at(main, i, *delimits_object, *delimits_content, data); - } - - return F_none; - } - - ++at; - } // for - - if (data->option & fss_extended_list_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_extended_list_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } -#endif // _di_fss_extended_list_read_process_at_ - -#ifndef _di_fss_extended_list_read_process_at_line_ - f_status_t fss_extended_list_read_process_at_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) { - - if (data->option & fss_extended_list_read_data_option_object_d) { - - if (*line == data->line) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_extended_list_read_data_option_total_d) { - fss_extended_list_read_print_one(main); - } - else { - fss_extended_list_read_print_at_object(main, data, at, delimits_object); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - - ++(*line); - } - - // There is only a single Content column for this standard. - if (data->option & fss_extended_list_read_data_option_content_d) { - if (!data->contents.array[at].used) { - return F_none; - } - - f_string_range_t range = f_string_range_t_initialize; - f_array_length_t i = 0; - - range.start = data->contents.array[at].array[0].start; - range.stop = data->contents.array[at].array[0].stop; - - // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - return F_none; - } - - for (i = range.start; i <= range.stop; ++i) { - - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - if (*line == data->line) { - range.stop = i; - - f_file_stream_lock(main->output.to); - - if (data->option & fss_extended_list_read_data_option_total_d) { - fss_extended_list_read_print_one(main); - } - else { - f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - - range.start = i + 1; - - if (i <= range.stop) { - ++(*line); - } - } - } // for - - // If Content does not end with a newline, it still must be treated as the last line. - if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { - ++(*line); - - if (*line == data->line) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_extended_list_read_data_option_total_d) { - fss_extended_list_read_print_one(main); - } - else { - range.stop = data->contents.array[at].array[0].stop; - - f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - } - } - - return F_none; - } -#endif // _di_fss_extended_list_read_process_at_line_ - -#ifndef _di_fss_extended_list_read_process_columns_ - f_status_t fss_extended_list_read_process_columns(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { - - if (!(data->option & fss_extended_list_read_data_option_content_d)) { - f_file_stream_lock(main->output.to); - - fss_extended_list_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - - return F_none; - } - - f_array_length_t max = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (data->contents.array[at].used > max) { - max = data->contents.array[at].used; - } - } // for - - fll_print_format("%ul%r", main->output.to, max, f_string_eol_s); - - return F_none; - } -#endif // _di_fss_extended_list_read_process_columns_ - -#ifndef _di_fss_extended_list_read_process_line_ - f_status_t fss_extended_list_read_process_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_extended_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - - if (data->option & fss_extended_list_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t line = 0; - f_status_t status = F_none; - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - status = fss_extended_list_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); - if (status == F_success) break; - } // for - - return F_none; - } -#endif // _di_fss_extended_list_read_process_line_ - -#ifndef _di_fss_extended_list_read_process_name_ - f_status_t fss_extended_list_read_process_name(fss_extended_list_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - - if (data->depths.array[0].index_name) { - f_array_length_t i = 0; - - memset(names, F_false, sizeof(bool) * data->objects.used); - - // This standard should always treat selected names as trimmed. - for (i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_except_trim_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits_object) == F_equal_to) { - names[i] = F_true; - } - } // for - } - else { - memset(names, F_true, sizeof(bool) * data->objects.used); - } - - return F_none; - } -#endif // _di_fss_extended_list_read_process_name_ - -#ifndef _di_fss_extended_list_read_process_option_ - f_status_t fss_extended_list_read_process_option(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - - f_status_t status = F_none; - - if (main->parameters.array[fss_extended_list_read_parameter_at_e].result & f_console_result_value_e) { - data->option |= fss_extended_list_read_data_option_at_d; - } - - if (main->parameters.array[fss_extended_list_read_parameter_columns_e].result & f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_columns_d; - } - - if (main->parameters.array[fss_extended_list_read_parameter_content_e].result & f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_content_d; - } - - if (main->parameters.array[fss_extended_list_read_parameter_empty_e].result & f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_empty_d; - } - - if (main->parameters.array[fss_extended_list_read_parameter_line_e].result & f_console_result_value_e) { - data->option |= fss_extended_list_read_data_option_line_d; - - status = fss_extended_list_read_load_number(main, data, fss_extended_list_read_parameter_line_e, fss_extended_list_read_long_line_s, &data->line); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_extended_list_read_parameter_name_e].result & f_console_result_value_e) { - data->option |= fss_extended_list_read_data_option_name_d; - } - - if (main->parameters.array[fss_extended_list_read_parameter_object_e].result & f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_object_d; - } - - if (main->parameters.array[fss_extended_list_read_parameter_original_e].result & f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_original_d; - } - - if (main->parameters.array[fss_extended_list_read_parameter_select_e].result & f_console_result_value_e) { - data->option |= fss_extended_list_read_data_option_select_d; - - status = fss_extended_list_read_load_number(main, data, fss_extended_list_read_parameter_select_e, fss_extended_list_read_long_select_s, &data->select); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_extended_list_read_parameter_total_e].result & f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_total_d; - } - - if (main->parameters.array[fss_extended_list_read_parameter_trim_e].result & f_console_result_found_e) { - data->option |= fss_extended_list_read_data_option_trim_d; - } - - // Default to content if neither Object nor Content is explicitly requested. - if (!(data->option & (fss_extended_list_read_data_option_content_d | fss_extended_list_read_data_option_object_d))) { - data->option |= fss_extended_list_read_data_option_content_d; - } - - return F_none; - } -#endif // _di_fss_extended_list_read_process_option_ - -#ifndef _di_fss_extended_list_read_process_total_ - f_status_t fss_extended_list_read_process_total(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { - - f_array_length_t total = 0; - f_string_range_t range = f_string_range_t_initialize; - f_array_length_t i = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (data->option & fss_extended_list_read_data_option_object_d) { - ++total; - - // Include the closing brace in the total count. - if (data->option & fss_extended_list_read_data_option_content_d) { - ++total; - } - } - - // There is only a single Content column for this standard. - if (data->option & fss_extended_list_read_data_option_content_d) { - - if (!data->contents.array[at].used) continue; - - range.start = data->contents.array[at].array[0].start; - range.stop = data->contents.array[at].array[0].stop; - - // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) continue; - - for (i = range.start; i <= range.stop; ++i) { - - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - range.start = i + 1; - - if (i <= range.stop) { - ++total; - } - } - } // for - - // If Content does not end with a newline, it still must be treated as the last line. - if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { - ++total; - } - } - } // for - - f_file_stream_lock(main->output.to); - - if (data->option & fss_extended_list_read_data_option_line_d) { - if (data->line < total) { - fss_extended_list_read_print_one(main); - } - else { - fss_extended_list_read_print_zero(main); - } - } - else { - fl_print_format("%ul%r", main->output.to, total, f_string_eol_s); - } - - f_file_stream_unlock(main->output.to); - - return F_none; - } -#endif // _di_fss_extended_list_read_process_total_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_list_read/c/private-read.h b/level_3/fss_extended_list_read/c/private-read.h deleted file mode 100644 index 5790704..0000000 --- a/level_3/fss_extended_list_read/c/private-read.h +++ /dev/null @@ -1,313 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_read_h -#define _PRIVATE_read_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Determine if the given depth is to be delimited or not for Content. - * - * @param data - * The program data. - * @param depth - * The depth to check. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_extended_list_read_delimit_content_is_ - extern f_status_t fss_extended_list_read_delimit_content_is(fss_extended_list_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_delimit_content_is_ - -/** - * Determine if the given depth is to be delimited or not for an Object. - * - * @param data - * The program data. - * @param depth - * The depth to check. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_extended_list_read_delimit_object_is_ - extern f_status_t fss_extended_list_read_delimit_object_is(fss_extended_list_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_delimit_object_is_ - -/** - * Process the parameters, parsing out and handling the depth and depth related parameters. - * - * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_string_append(). - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * Errors (with error bit) from: f_rip_dynamic(). - * - * Errors (with error bit) from: fss_extended_list_read_depths_resize(). - * - * @see f_string_append() - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * @see f_rip_dynamic() - * - * @see fss_extended_list_read_depths_resize() - */ -#ifndef _di_fss_extended_list_read_depth_process_ - extern f_status_t fss_extended_list_read_depth_process(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_depth_process_ - -/** - * Get the name of the file the given position represents within the buffer. - * - * @param at - * The position within the buffer. - * @param files - * The representation of files and their respective ranges within the buffer. - * - * @return - * A string with the name when found. - * NULL is returned if the range represents the STDIN pipe. - * - * On failure to identify, an empty string is returned. - */ -#ifndef _di_fss_extended_list_read_file_identify_ - extern f_string_static_t fss_extended_list_read_file_identify(const f_array_length_t at, const fss_extended_list_read_files_t files) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_file_identify_ - -/** - * Process the buffer, loading the FSS data. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * 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_extended_list_read_process_option() - */ -#ifndef _di_fss_extended_list_read_load_ - extern f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_load_ - -/** - * Load a given number parameter. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param parameter - * An ID representing the parameter. - * @param name - * The parameter name to print on error. - * @param number - * The location to store the loaded number. - * - * @return - * F_true on success and the parameter was found (and is valid). - * F_false on success and the parameter was not found. - * - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * - * @see fss_extended_list_read_depths_resize() - */ -#ifndef _di_fss_extended_list_read_load_number_ - extern f_status_t fss_extended_list_read_load_number(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_load_number_ - -/** - * Perform the extended list read processing on the buffer. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_extended_list_read_load() - * Errors (with error bit) from: fss_extended_list_read_process_option() - * - * @see fss_extended_list_read_load() - * @see fss_extended_list_read_process_option() - */ -#ifndef _di_fss_extended_list_read_process_ - extern f_status_t fss_extended_list_read_process(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_ - -/** - * Process based on at parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - * - * @see fss_extended_list_read_process_at_line() - */ -#ifndef _di_fss_extended_list_read_process_at_ - extern f_status_t fss_extended_list_read_process_at(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_at_ - -/** - * Process based on at parameter for some line. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param line - * The current line being processed. - * This will be incremented as necessary. - * - * @return - * F_none on success but no line was matched (and possibly printed). - * F_success on success and the line was matched (and possibly printed). - */ -#ifndef _di_fss_extended_list_read_process_at_line_ - extern f_status_t fss_extended_list_read_process_at_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_at_line_ - -/** - * Process based on columns parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_list_read_process_columns_ - extern f_status_t fss_extended_list_read_process_columns(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_columns_ - -/** - * Process based on line parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_list_read_process_line_ - extern f_status_t fss_extended_list_read_process_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_line_ - -/** - * Process the Objects in the buffer, determining if the Object name is to be used or not. - * - * How an Object name is determined to be used or not is dependent on several parameters, such as --name, --depth, --at, and --line. - * - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_list_read_process_name_ - extern f_status_t fss_extended_list_read_process_name(fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_name_ - -/** - * Process the parameters, populating the option property of the program data. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_extended_list_read_load_setting() - * - * @see fll_fss_extended_list_read() - * - * @see fss_extended_list_read_load_setting() - */ -#ifndef _di_fss_extended_list_read_process_option_ - extern f_status_t fss_extended_list_read_process_option(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_option_ - -/** - * Process based on total parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_list_read_process_total_ - extern f_status_t fss_extended_list_read_process_total(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_process_total_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_read_h diff --git a/level_3/fss_extended_list_read/data/build/defines b/level_3/fss_extended_list_read/data/build/defines deleted file mode 100644 index 490da41..0000000 --- a/level_3/fss_extended_list_read/data/build/defines +++ /dev/null @@ -1,6 +0,0 @@ -# fss-0000 - -_di_thread_support_ Disables thread support. - -_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. -_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/fss_extended_list_read/data/build/dependencies b/level_3/fss_extended_list_read/data/build/dependencies deleted file mode 100644 index 22cdeb6..0000000 --- a/level_3/fss_extended_list_read/data/build/dependencies +++ /dev/null @@ -1,31 +0,0 @@ -# fss-0000 - -f_type -f_status -f_memory -f_type_array -f_string -f_utf -f_color -f_compare -f_console -f_conversion -f_directory -f_environment -f_file -f_fss -f_parse -f_pipe -f_print -f_rip -f_signal - -fl_conversion -fl_fss -fl_print - -fll_error -fll_file -fll_fss -fll_print -fll_program diff --git a/level_3/fss_extended_list_read/data/build/fakefile b/level_3/fss_extended_list_read/data/build/fakefile deleted file mode 100644 index 7509601..0000000 --- a/level_3/fss_extended_list_read/data/build/fakefile +++ /dev/null @@ -1,27 +0,0 @@ -# fss-0005 iki-0002 - -settings: - fail exit - modes individual individual_thread level monolithic clang test fanalyzer thread threadless - - environment PATH LD_LIBRARY_PATH - environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -main: - build - -install: - shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' - -help: - print - print context:'title'Fakefile Options for FSS Extended List Read Software.context:'reset' - - print - print The following operations are available\: - print " - context:'notable'help:context:'reset' Perform the help operation, printing this message." - print " - context:'notable'install:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." - print " - context:'notable'main:context:'reset' The default compilation using the build settings mode." - - print - print The context:'notable'install context:'reset'operation supports the context:'notable'work,context:'reset' context:'notable'verbosity,context:'reset' and context:'notable'color context:'reset'parameters. diff --git a/level_3/fss_extended_list_read/data/build/settings b/level_3/fss_extended_list_read/data/build/settings deleted file mode 100644 index 4c0e7b2..0000000 --- a/level_3/fss_extended_list_read/data/build/settings +++ /dev/null @@ -1,76 +0,0 @@ -# fss-0001 -# -# Modes: -# - individual: Compile using per project (individual) libraries, does not handle thread or threadless cases. -# - individual_thread: This is required when compiling in individual mode with "thread" mode. -# - level: Compile using per level libraries. -# - monolithic: Compile using per monolithic libraries. -# - clang: Use clang rather than the default, which is generally gcc. -# - test: Compile for a test, such as unit testing. -# - fanalyzer: Compile using GCC's -fanalyzer compile time option. -# - thread: Compile with thread support. -# - threadless: Compile without thread support. -# - -build_name fss_extended_list_read - -version_major 0 -version_minor 7 -version_micro 0 -version_file micro -version_target minor - -modes individual individual_thread level monolithic clang test fanalyzer thread threadless -modes_default monolithic thread - -build_compiler gcc -build_compiler-clang clang -build_indexer ar -build_indexer_arguments rcs -build_language c - -build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_parse -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_status_string -lf_string -lf_type_array -lf_utf -build_libraries-individual_thread -lf_thread -build_libraries-level -lfll_2 -lfll_1 -lfll_0 -build_libraries-monolithic -lfll - -build_sources_library fss_extended_list_read.c common.c print.c private-common.c private-print.c private-read.c - -build_sources_program main.c - -build_sources_headers fss_extended_list_read.h common.h print.h - -build_sources_documentation man - -build_script yes -build_shared yes -build_static no - -path_headers program/fss_extended_list_read - -has_path_standard yes -preserve_path_headers yes - -search_exclusive yes -search_shared yes -search_static yes - -environment PATH LD_LIBRARY_PATH -environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -#defines -D_di_libcap_ -defines -D_libcap_legacy_only_ -defines-threadless -D_di_thread_support_ -defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ - -flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces -flags-thread -pthread -flags-clang -Wno-logical-op-parentheses -flags-test -O0 -fstack-protector -Wall -flags-fanalyzer -fanalyzer -flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ - -flags_library -fPIC -flags_object -fPIC -flags_program -fPIE diff --git a/level_3/fss_extended_list_read/data/documentation/man/man1/fss_extended_list_read.1 b/level_3/fss_extended_list_read/data/documentation/man/man1/fss_extended_list_read.1 deleted file mode 100644 index d30cf34..0000000 --- a/level_3/fss_extended_list_read/data/documentation/man/man1/fss_extended_list_read.1 +++ /dev/null @@ -1,145 +0,0 @@ -.TH FSS_EMBEDDED_LIST_READ "1" "March 2023" "FLL - FSS Embedded List Write 0.7.0" "User Commands" -.SH NAME -fss_extended_list_read \- Read data in \fBFSS-0003 (Extended List)\fR format. -.SH SYNOPSIS -.B fss_extended_list_read -[\fI\,OPTIONS\/\fR] [\fI\,FILENAMES\/\fR] -.SH DESCRIPTION -.PP -This program will print the Content associated with the given Object and Content main based on the \fBFSS-0003 Extended List\fR standard. - -All numeric positions (indexes) start at 0 instead of 1. -For example, a file of 17 lines would range from 0 to 16. - -When using the \fB\-\-depth\fR option, an order of operations is enforced on the parameters. -When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter: - \fB\-\-at\fR: An Object index at the specified depth. - \fB\-\-depth\fR: A new depth within the specified depth, indexed from the root. - \fB\-\-name\fR: An Object name at the specified depth. - -The parameter \fB\-\-depth\fR must be in numeric order, but values in between may be skipped. - ('\fB\-d 0 \-a 1 \-d 2 \-a 2\fR' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.) - ('\fB\-d 2 \-a 1 \-d 0 \-a 2\fR' would be invalid because depth 2 is before depth 1.) - -The parameter \fB\-\-select\fR selects a Content column. - -Specify both \fB\-\-object\fR and the \fB\-\-total\fR parameters to get the total objects. - -When both \fB\-\-at\fR and \fB\-\-name\fR parameters are specified (at the same depth), the \fB\-\-at\fR parameter value will be treated as a position relative to the specified \fB\-\-name\fR parameter value. - -This program may support parameters, such as \fB\-\-depth\fR or \fB\-\-select\fR, even if not supported by the standard. -This is done to help ensure consistency for scripting. - -For parameters like \fB\-\-depth\fR, if the standard doesn't support nested Content, then only a depth of 0 would be valid. -For parameters like \fB\-\-select\fR, if the standard doesn't support multiple Content groups, then only a select of 0 would be valid. - -The parameter \fB\-\-trim\fR will remove leading and trailing white spaces when selecting objects or when printing objects. - -When specifying both the \fB\-\-object\fR parameter and the \fB\-\-content\fR parameter, the entire Object and Content are printed, including the formatting. -Both the Object and Content printed are already escaped. -Both the Object and Content are separated by a New Line character '\fB\\n\fR' (U+000A). - -The parameter \fB\-\-delimit\fR accepts the following: - \fBnone\fR: Do not apply delimits. - \fBall\fR: (default) Apply all delimits. - \fBobject\fR: Apply delimits for Objects. - \fBA number, 0 or greater\fR: apply delimits for Content at the specified depth. - \fBA number, 0 or greater, followed by a +\fR: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically). - \fBA number, 0 or lesser, followed by a \-\fR: (such as '1\-') apply delimits for Content at the specified depth and any lesser depth (numerically). - -The \fB\-\-delimit\fR parameter may be specified multiple times to customize the delimit behavior. -The \fB\-\-delimit\fR values none and all, overrule all other delimit values. - -The parameters \fB\-\-columns\fR and \fB\-\-select\fR refer to a Content column. -The word '\fBcolumn\fR' is being loosely defined to refer to a specific Content. -This is not to be confused with a depth. -.SH OPTIONS -.TP -\fB\{\-h, \-\-help\fR -Print the help message. -.TP -\fB+C, ++copyright\fR -Print the copyright. -.TP -\fB+d, ++dark\fR -Output using colors that show up better on dark backgrounds. -.TP -\fB+l, ++light\fR -Output using colors that show up better on light backgrounds. -.TP -\fB+n, ++no_color\fR -Do not print using color. -.TP -\fB+Q, ++quiet\fR -Decrease verbosity, silencing most output. -.TP -\fB+E, ++error\fR -Decrease verbosity, using only error output. -.TP -\fB+N, ++normal\fR -Set verbosity to normal. -.TP -\fB+V, ++verbose\fR -Increase verbosity beyond normal output. -.TP -\fB+D, ++debug\fR -Enable debugging, significantly increasing verbosity beyond normal output. -.TP -\fB+v, ++version\fR -Print only the version number. -.TP -\fB+F, ++line_first_no\fR -Disable printing of first line. -.TP -\fB+L, ++line_last_no\fR -Disable printing of last line. -.TP -\fB\-a, \-\-at\fR -Select Object at this numeric index. -.TP -\fB\-c, \-\-content\fR -Print the Content (default). -.TP -\fB\-C, \-\-columns\fR -Print the total number of columns. -.TP -\fB\-D, \-\-delimit\fR -Designate how to handle applying delimits. -.TP -\fB\-d, \-\-depth\fR -Select Object at this numeric depth. -.TP -\fB\-e, \-\-empty\fR -Include empty Content when processing. -.TP -\fB\-l, \-\-line\fR -Print only the Content at the given line. -.TP -\fB\-n, \-\-name\fR -Select Object with this name. -.TP -\fB\-o, \-\-object\fR -Print the Object. -.TP -\fB\-p, \-\-pipe\fR -Print using the special pipe format. -.TP -\fB\-O, \-\-original\fR -Print with the original quotes and escapes. -.TP -\fB\-s, \-\-select\fR -Select sub-Content at this index. -.TP -\fB\-t, \-\-total\fR -Print the total number of lines. -.TP -\fB\-T, \-\-trim\fR -Trim Object names on select or print. -.SH FILENAMES -.TP -Any number of files to read. -.SH AUTHOR -Written by Kevin Day. -.SH COPYRIGHT -.PP -Copyright \(co 2007-2023 Kevin Day, GNU LGPL Version 2.1 or later. diff --git a/level_3/fss_extended_read/c/common.c b/level_3/fss_extended_read/c/common.c deleted file mode 100644 index 93de956..0000000 --- a/level_3/fss_extended_read/c/common.c +++ /dev/null @@ -1,198 +0,0 @@ -#include "fss_extended_read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_read_program_version_s_ - const f_string_static_t fss_extended_read_program_version_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_program_version_s, 0, FSS_EXTENDED_READ_program_version_s_length); -#endif // _di_fss_extended_read_program_version_s_ - -#ifndef _di_fss_extended_read_program_name_s_ - const f_string_static_t fss_extended_read_program_name_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_program_name_s, 0, FSS_EXTENDED_READ_program_name_s_length); - const f_string_static_t fss_extended_read_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_program_name_long_s, 0, FSS_EXTENDED_READ_program_name_long_s_length); -#endif // _di_fss_extended_read_program_name_s_ - -#ifndef _di_fss_extended_read_pipe_s_ - const f_string_static_t fss_extended_read_pipe_name_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_pipe_name_s, 0, FSS_EXTENDED_READ_pipe_name_s_length); - const f_string_static_t fss_extended_read_pipe_content_end_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_pipe_content_end_s, 0, FSS_EXTENDED_READ_pipe_content_end_s_length); - const f_string_static_t fss_extended_read_pipe_content_ignore_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_pipe_content_ignore_s, 0, FSS_EXTENDED_READ_pipe_content_ignore_s_length); - const f_string_static_t fss_extended_read_pipe_content_start_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_pipe_content_start_s, 0, FSS_EXTENDED_READ_pipe_content_start_s_length); -#endif // _di_fss_extended_read_pipe_s_ - -#ifndef _di_fss_extended_read_parameter_d_ - const f_string_static_t fss_extended_read_short_at_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_at_s, 0, FSS_EXTENDED_READ_short_at_s_length); - const f_string_static_t fss_extended_read_short_content_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_content_s, 0, FSS_EXTENDED_READ_short_content_s_length); - const f_string_static_t fss_extended_read_short_columns_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_columns_s, 0, FSS_EXTENDED_READ_short_columns_s_length); - const f_string_static_t fss_extended_read_short_delimit_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_delimit_s, 0, FSS_EXTENDED_READ_short_delimit_s_length); - const f_string_static_t fss_extended_read_short_depth_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_depth_s, 0, FSS_EXTENDED_READ_short_depth_s_length); - const f_string_static_t fss_extended_read_short_empty_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_empty_s, 0, FSS_EXTENDED_READ_short_empty_s_length); - const f_string_static_t fss_extended_read_short_line_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_line_s, 0, FSS_EXTENDED_READ_short_line_s_length); - const f_string_static_t fss_extended_read_short_name_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_name_s, 0, FSS_EXTENDED_READ_short_name_s_length); - const f_string_static_t fss_extended_read_short_object_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_object_s, 0, FSS_EXTENDED_READ_short_object_s_length); - const f_string_static_t fss_extended_read_short_pipe_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_pipe_s, 0, FSS_EXTENDED_READ_short_pipe_s_length); - const f_string_static_t fss_extended_read_short_original_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_original_s, 0, FSS_EXTENDED_READ_short_original_s_length); - const f_string_static_t fss_extended_read_short_select_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_select_s, 0, FSS_EXTENDED_READ_short_select_s_length); - const f_string_static_t fss_extended_read_short_total_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_total_s, 0, FSS_EXTENDED_READ_short_total_s_length); - const f_string_static_t fss_extended_read_short_trim_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_short_trim_s, 0, FSS_EXTENDED_READ_short_trim_s_length); - - const f_string_static_t fss_extended_read_long_at_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_at_s, 0, FSS_EXTENDED_READ_long_at_s_length); - const f_string_static_t fss_extended_read_long_content_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_content_s, 0, FSS_EXTENDED_READ_long_content_s_length); - const f_string_static_t fss_extended_read_long_columns_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_columns_s, 0, FSS_EXTENDED_READ_long_columns_s_length); - const f_string_static_t fss_extended_read_long_delimit_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_delimit_s, 0, FSS_EXTENDED_READ_long_delimit_s_length); - const f_string_static_t fss_extended_read_long_depth_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_depth_s, 0, FSS_EXTENDED_READ_long_depth_s_length); - const f_string_static_t fss_extended_read_long_empty_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_empty_s, 0, FSS_EXTENDED_READ_long_empty_s_length); - const f_string_static_t fss_extended_read_long_line_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_line_s, 0, FSS_EXTENDED_READ_long_line_s_length); - const f_string_static_t fss_extended_read_long_name_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_name_s, 0, FSS_EXTENDED_READ_long_name_s_length); - const f_string_static_t fss_extended_read_long_object_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_object_s, 0, FSS_EXTENDED_READ_long_object_s_length); - const f_string_static_t fss_extended_read_long_pipe_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_pipe_s, 0, FSS_EXTENDED_READ_long_pipe_s_length); - const f_string_static_t fss_extended_read_long_original_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_original_s, 0, FSS_EXTENDED_READ_long_original_s_length); - const f_string_static_t fss_extended_read_long_select_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_select_s, 0, FSS_EXTENDED_READ_long_select_s_length); - const f_string_static_t fss_extended_read_long_total_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_total_s, 0, FSS_EXTENDED_READ_long_total_s_length); - const f_string_static_t fss_extended_read_long_trim_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_long_trim_s, 0, FSS_EXTENDED_READ_long_trim_s_length); -#endif // _di_fss_extended_read_parameter_d_ - -#ifndef _di_fss_extended_read_delimit_mode_s_ - const f_string_static_t fss_extended_read_delimit_mode_name_none_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_delimit_mode_name_none_s, 0, FSS_EXTENDED_READ_delimit_mode_name_none_s_length); - const f_string_static_t fss_extended_read_delimit_mode_name_all_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_delimit_mode_name_all_s, 0, FSS_EXTENDED_READ_delimit_mode_name_all_s_length); - const f_string_static_t fss_extended_read_delimit_mode_name_object_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_delimit_mode_name_object_s, 0, FSS_EXTENDED_READ_delimit_mode_name_object_s_length); - const f_string_static_t fss_extended_read_delimit_mode_name_greater_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_delimit_mode_name_greater_s, 0, FSS_EXTENDED_READ_delimit_mode_name_greater_s_length); - const f_string_static_t fss_extended_read_delimit_mode_name_lesser_s = macro_f_string_static_t_initialize_1(FSS_EXTENDED_READ_delimit_mode_name_lesser_s, 0, FSS_EXTENDED_READ_delimit_mode_name_lesser_s_length); -#endif // _di_fss_extended_read_delimit_mode_s_ - -#ifndef _di_fss_extended_read_setting_delete_ - f_status_t fss_extended_read_setting_delete(fss_extended_read_setting_t * const setting) { - - if (!setting) return F_status_set_error(F_parameter); - - return F_none; - } -#endif // _di_fss_extended_read_setting_delete_ - -#ifndef _di_fss_extended_read_setting_load_ - void fss_extended_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_read_setting_t * const setting) { - - if (!main) return; - - main->setting.state.step_small = fss_extended_read_allocation_console_d; - - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - - main->setting.state.step_small = fss_extended_read_allocation_small_d; - - // Identify and pocess first/last parameters. - if (main->program.parameters.array[fss_extended_read_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_extended_read_main_flag_print_first_e; - } - else { - main->setting.flag |= fss_extended_read_main_flag_print_first_e; - } - - if (main->program.parameters.array[fss_extended_read_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_extended_read_main_flag_print_last_e; - } - else { - main->setting.flag |= fss_extended_read_main_flag_print_last_e; - } - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_extended_read_parameter_no_color_e, fss_extended_read_parameter_light_e, fss_extended_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_extended_read_parameter_verbosity_quiet_e, fss_extended_read_parameter_verbosity_error_e, fss_extended_read_parameter_verbosity_verbose_e, fss_extended_read_parameter_verbosity_debug_e, fss_extended_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - static const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - } - - main->program.output.to.id = F_type_descriptor_output_d; - main->program.output.to.stream = F_type_output_d; - main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - - if (main->program.parameters.array[fss_extended_read_parameter_help_e].result & f_console_result_found_e) { - main->setting.flag |= fss_extended_read_main_flag_help_e; - - return; - } - - if (main->program.parameters.array[fss_extended_read_parameter_version_e].result & f_console_result_found_e) { - main->setting.flag |= fss_extended_read_main_flag_version_e; - - return; - } - - if (main->program.parameters.array[fss_extended_read_parameter_copyright_e].result & f_console_result_found_e) { - main->setting.flag |= fss_extended_read_main_flag_copyright_e; - - return; - } - - f_string_static_t * const args = main->program.parameters.arguments.array; - - if (main->program.parameters.array[fss_extended_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - main->setting.flag |= fss_extended_read_main_flag_strip_invalid_e; - } - } -#endif // _di_fss_extended_read_setting_load_ - -#ifndef _di_fss_extended_read_setting_unload_ - f_status_t fss_extended_read_setting_unload(fss_extended_read_main_t * const main) { - - if (!main) return F_status_set_error(F_parameter); - - fss_extended_read_setting_delete(&main->setting); - - return F_none; - } -#endif // _di_fss_extended_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_read/c/common.h b/level_3/fss_extended_read/c/common.h deleted file mode 100644 index 77ed652..0000000 --- a/level_3/fss_extended_read/c/common.h +++ /dev/null @@ -1,432 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Extended Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the common data structures. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _fss_extended_read_common_h -#define _fss_extended_read_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The program version. - */ -#ifndef _di_fss_extended_read_program_version_s_ - #define FSS_EXTENDED_READ_program_version_major_s F_string_ascii_0_s - #define FSS_EXTENDED_READ_program_version_minor_s F_string_ascii_7_s - #define FSS_EXTENDED_READ_program_version_micro_s F_string_ascii_0_s - - #define FSS_EXTENDED_READ_program_version_major_s_length F_string_ascii_0_s_length - #define FSS_EXTENDED_READ_program_version_minor_s_length F_string_ascii_7_s_length - #define FSS_EXTENDED_READ_program_version_micro_s_length F_string_ascii_0_s_length - - #if !(defined(FSS_EXTENDED_READ_program_version_nano_prefix_s) && defined(FSS_EXTENDED_READ_program_version_nano_prefix_s_length)) - #define FSS_EXTENDED_READ_program_version_nano_prefix_s - #define FSS_EXTENDED_READ_program_version_nano_prefix_s_length 0 - #endif // !(defined(FSS_EXTENDED_READ_program_version_nano_prefix_s) && defined(FSS_EXTENDED_READ_program_version_nano_prefix_s_length)) - - #if !(defined(FSS_EXTENDED_READ_program_version_nano_s) && defined(FSS_EXTENDED_READ_program_version_nano_s_length)) - #define FSS_EXTENDED_READ_program_version_nano_s - #define FSS_EXTENDED_READ_program_version_nano_s_length 0 - #endif // !(defined(FSS_EXTENDED_READ_program_version_nano_s) && defined(FSS_EXTENDED_READ_program_version_nano_s_length)) - - #define FSS_EXTENDED_READ_program_version_s FSS_EXTENDED_READ_program_version_major_s F_string_ascii_period_s FSS_EXTENDED_READ_program_version_minor_s F_string_ascii_period_s FSS_EXTENDED_READ_program_version_micro_s FSS_EXTENDED_READ_program_version_nano_prefix_s FSS_EXTENDED_READ_program_version_nano_s - - #define FSS_EXTENDED_READ_program_version_s_length FSS_EXTENDED_READ_program_version_major_s_length + F_string_ascii_period_s_length + FSS_EXTENDED_READ_program_version_minor_s_length + F_string_ascii_period_s_length + FSS_EXTENDED_READ_program_version_micro_s_length + FSS_EXTENDED_READ_program_version_nano_prefix_s_length + FSS_EXTENDED_READ_program_version_nano_s_length - - extern const f_string_static_t fss_extended_read_program_version_s; -#endif // _di_fss_extended_read_program_version_s_ - -/** - * The program name. - */ -#ifndef _di_fss_extended_read_program_name_s_ - #define FSS_EXTENDED_READ_program_name_s "fss_extended_read" - #define FSS_EXTENDED_READ_program_name_long_s "FSS Extended Read" - - #define FSS_EXTENDED_READ_program_name_s_length 17 - #define FSS_EXTENDED_READ_program_name_long_s_length 17 - - extern const f_string_static_t fss_extended_read_program_name_s; - extern const f_string_static_t fss_extended_read_program_name_long_s; -#endif // _di_fss_extended_read_program_name_s_ - -/** - * The program defines. - * - * fss_extended_read_*: - * - allocation_console: An allocation step used for small buffers specifically for console parameter. - * - allocation_large: An allocation step used for buffers that are anticipated to have large buffers. - * - allocation_small: An allocation step used for buffers that are anticipated to have small buffers. - * - signal_check: Number of iterations before performing signal check in non-threaded signal handling. - */ -#ifndef _di_fss_extended_read_d_ - #define fss_extended_read_allocation_console_d 4 - #define fss_extended_read_allocation_large_d 256 - #define fss_extended_read_allocation_small_d 16 - #define fss_extended_read_signal_check_d 20000 -#endif // _di_fss_extended_read_d_ - -/** - * The program pipe strings. - * - * fss_extended_read_pipe_*_d: - * - name: A name used to represent the pipe when printing file names. - * - content_end: A code used to represent the end of Content for use in binary formats. - * - content_ignore: A code used to represent the ignoring Content for use in binary formats. - * - content_start: A code used to represent the start of Content for use in binary formats. - */ -#ifndef _di_fss_extended_read_pipe_s_ - #define FSS_EXTENDED_READ_pipe_name_s "(pipe)" - - #define FSS_EXTENDED_READ_pipe_content_end_s "\f" - #define FSS_EXTENDED_READ_pipe_content_ignore_s "\v" - #define FSS_EXTENDED_READ_pipe_content_start_s "\b" - - #define FSS_EXTENDED_READ_pipe_name_s_length 6 - - #define FSS_EXTENDED_READ_pipe_content_end_s_length 1 - #define FSS_EXTENDED_READ_pipe_content_ignore_s_length 1 - #define FSS_EXTENDED_READ_pipe_content_start_s_length 1 - - extern const f_string_static_t fss_extended_read_pipe_name_s; - - extern const f_string_static_t fss_extended_read_pipe_content_end_s; - extern const f_string_static_t fss_extended_read_pipe_content_ignore_s; - extern const f_string_static_t fss_extended_read_pipe_content_start_s; -#endif // _di_fss_extended_read_pipe_s_ - -/** - * The main program parameters. - */ -#ifndef _di_fss_extended_read_parameter_d_ - #define FSS_EXTENDED_READ_short_at_s "a" - #define FSS_EXTENDED_READ_short_content_s "c" - #define FSS_EXTENDED_READ_short_columns_s "C" - #define FSS_EXTENDED_READ_short_delimit_s "D" - #define FSS_EXTENDED_READ_short_depth_s "d" - #define FSS_EXTENDED_READ_short_empty_s "e" - #define FSS_EXTENDED_READ_short_line_s "l" - #define FSS_EXTENDED_READ_short_name_s "n" - #define FSS_EXTENDED_READ_short_object_s "o" - #define FSS_EXTENDED_READ_short_pipe_s "p" - #define FSS_EXTENDED_READ_short_original_s "O" - #define FSS_EXTENDED_READ_short_select_s "s" - #define FSS_EXTENDED_READ_short_total_s "t" - #define FSS_EXTENDED_READ_short_trim_s "T" - - #define FSS_EXTENDED_READ_long_at_s "at" - #define FSS_EXTENDED_READ_long_content_s "content" - #define FSS_EXTENDED_READ_long_columns_s "columns" - #define FSS_EXTENDED_READ_long_delimit_s "delimit" - #define FSS_EXTENDED_READ_long_depth_s "depth" - #define FSS_EXTENDED_READ_long_empty_s "empty" - #define FSS_EXTENDED_READ_long_line_s "line" - #define FSS_EXTENDED_READ_long_name_s "name" - #define FSS_EXTENDED_READ_long_object_s "object" - #define FSS_EXTENDED_READ_long_pipe_s "pipe" - #define FSS_EXTENDED_READ_long_original_s "original" - #define FSS_EXTENDED_READ_long_select_s "select" - #define FSS_EXTENDED_READ_long_total_s "total" - #define FSS_EXTENDED_READ_long_trim_s "trim" - - #define FSS_EXTENDED_READ_short_at_s_length 1 - #define FSS_EXTENDED_READ_short_content_s_length 1 - #define FSS_EXTENDED_READ_short_columns_s_length 1 - #define FSS_EXTENDED_READ_short_delimit_s_length 1 - #define FSS_EXTENDED_READ_short_depth_s_length 1 - #define FSS_EXTENDED_READ_short_empty_s_length 1 - #define FSS_EXTENDED_READ_short_line_s_length 1 - #define FSS_EXTENDED_READ_short_name_s_length 1 - #define FSS_EXTENDED_READ_short_object_s_length 1 - #define FSS_EXTENDED_READ_short_pipe_s_length 1 - #define FSS_EXTENDED_READ_short_original_s_length 1 - #define FSS_EXTENDED_READ_short_select_s_length 1 - #define FSS_EXTENDED_READ_short_total_s_length 1 - #define FSS_EXTENDED_READ_short_trim_s_length 1 - - #define FSS_EXTENDED_READ_long_at_s_length 2 - #define FSS_EXTENDED_READ_long_content_s_length 7 - #define FSS_EXTENDED_READ_long_columns_s_length 7 - #define FSS_EXTENDED_READ_long_delimit_s_length 7 - #define FSS_EXTENDED_READ_long_depth_s_length 5 - #define FSS_EXTENDED_READ_long_empty_s_length 5 - #define FSS_EXTENDED_READ_long_line_s_length 4 - #define FSS_EXTENDED_READ_long_name_s_length 4 - #define FSS_EXTENDED_READ_long_object_s_length 6 - #define FSS_EXTENDED_READ_long_pipe_s_length 4 - #define FSS_EXTENDED_READ_long_original_s_length 8 - #define FSS_EXTENDED_READ_long_select_s_length 6 - #define FSS_EXTENDED_READ_long_total_s_length 5 - #define FSS_EXTENDED_READ_long_trim_s_length 4 - - extern const f_string_static_t fss_extended_read_short_at_s; - extern const f_string_static_t fss_extended_read_short_content_s; - extern const f_string_static_t fss_extended_read_short_columns_s; - extern const f_string_static_t fss_extended_read_short_delimit_s; - extern const f_string_static_t fss_extended_read_short_depth_s; - extern const f_string_static_t fss_extended_read_short_empty_s; - extern const f_string_static_t fss_extended_read_short_line_s; - extern const f_string_static_t fss_extended_read_short_name_s; - extern const f_string_static_t fss_extended_read_short_object_s; - extern const f_string_static_t fss_extended_read_short_pipe_s; - extern const f_string_static_t fss_extended_read_short_original_s; - extern const f_string_static_t fss_extended_read_short_select_s; - extern const f_string_static_t fss_extended_read_short_total_s; - extern const f_string_static_t fss_extended_read_short_trim_s; - - extern const f_string_static_t fss_extended_read_long_at_s; - extern const f_string_static_t fss_extended_read_long_content_s; - extern const f_string_static_t fss_extended_read_long_columns_s; - extern const f_string_static_t fss_extended_read_long_delimit_s; - extern const f_string_static_t fss_extended_read_long_depth_s; - extern const f_string_static_t fss_extended_read_long_empty_s; - extern const f_string_static_t fss_extended_read_long_line_s; - extern const f_string_static_t fss_extended_read_long_name_s; - extern const f_string_static_t fss_extended_read_long_object_s; - extern const f_string_static_t fss_extended_read_long_pipe_s; - extern const f_string_static_t fss_extended_read_long_original_s; - extern const f_string_static_t fss_extended_read_long_select_s; - extern const f_string_static_t fss_extended_read_long_total_s; - extern const f_string_static_t fss_extended_read_long_trim_s; - - enum { - fss_extended_read_parameter_help_e, - fss_extended_read_parameter_copyright_e, - fss_extended_read_parameter_light_e, - fss_extended_read_parameter_dark_e, - fss_extended_read_parameter_no_color_e, - fss_extended_read_parameter_verbosity_quiet_e, - fss_extended_read_parameter_verbosity_error_e, - fss_extended_read_parameter_verbosity_normal_e, - fss_extended_read_parameter_verbosity_verbose_e, - fss_extended_read_parameter_verbosity_debug_e, - fss_extended_read_parameter_version_e, - fss_extended_read_parameter_line_first_no_e, - fss_extended_read_parameter_line_last_no_e, - - fss_extended_read_parameter_at_e, - fss_extended_read_parameter_content_e, - fss_extended_read_parameter_columns_e, - fss_extended_read_parameter_delimit_e, - fss_extended_read_parameter_depth_e, - fss_extended_read_parameter_empty_e, - fss_extended_read_parameter_line_e, - fss_extended_read_parameter_name_e, - fss_extended_read_parameter_object_e, - fss_extended_read_parameter_pipe_e, - fss_extended_read_parameter_original_e, - fss_extended_read_parameter_select_e, - fss_extended_read_parameter_total_e, - fss_extended_read_parameter_trim_e, - }; // enum - - #define fss_extended_read_console_parameter_t_initialize \ - { \ - macro_fll_program_console_parameter_standard_initialize, \ - \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_content_s, fss_extended_read_long_content_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_columns_s, fss_extended_read_long_columns_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_delimit_s, fss_extended_read_long_delimit_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_depth_s, fss_extended_read_long_depth_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_empty_s, fss_extended_read_long_empty_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_line_s, fss_extended_read_long_line_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_name_s, fss_extended_read_long_name_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_object_s, fss_extended_read_long_object_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_pipe_s, fss_extended_read_long_pipe_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_original_s, fss_extended_read_long_original_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_select_s, fss_extended_read_long_select_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_total_s, fss_extended_read_long_total_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_extended_read_short_trim_s, fss_extended_read_long_trim_s, 0, 0, f_console_flag_normal_e), \ - } - - #define fss_extended_read_total_parameters_d 27 -#endif // _di_fss_extended_read_parameter_d_ - -/** - * FSS Delimit Parameter strings. - * - * fss_extended_read_delimit_mode_*: - * - all: All delimits are to be aplied. - * - content: Content are to have delimits applied. - * - content_greater: Content at this number or higher are to have delimits applied. - * - content_greater_object: Objects and Content at this number or higher are to have delimits applied. - * - content_lesser: Content at this number or lower are to have delimits applied. - * - content_lesser_object: Objects and Content at this number or lower are to have delimits applied. - * - content_object: Objects and Content are to have delimits applied - * - object: Objects arre to have delimits applied. - */ -#ifndef _di_fss_extended_read_delimit_mode_s_ - #define FSS_EXTENDED_READ_delimit_mode_name_none_s "none" - #define FSS_EXTENDED_READ_delimit_mode_name_all_s "all" - #define FSS_EXTENDED_READ_delimit_mode_name_object_s "object" - #define FSS_EXTENDED_READ_delimit_mode_name_greater_s "+" - #define FSS_EXTENDED_READ_delimit_mode_name_lesser_s "-" - - #define FSS_EXTENDED_READ_delimit_mode_name_none_s_length 4 - #define FSS_EXTENDED_READ_delimit_mode_name_all_s_length 3 - #define FSS_EXTENDED_READ_delimit_mode_name_object_s_length 6 - #define FSS_EXTENDED_READ_delimit_mode_name_greater_s_length 1 - #define FSS_EXTENDED_READ_delimit_mode_name_lesser_s_length 1 - - extern const f_string_static_t fss_extended_read_delimit_mode_name_none_s; - extern const f_string_static_t fss_extended_read_delimit_mode_name_all_s; - extern const f_string_static_t fss_extended_read_delimit_mode_name_object_s; - extern const f_string_static_t fss_extended_read_delimit_mode_name_greater_s; - extern const f_string_static_t fss_extended_read_delimit_mode_name_lesser_s; -#endif // _di_fss_extended_read_delimit_mode_s_ - -/** - * FSS Delimit Parameter enumerations. - */ -#ifndef _di_fss_extended_read_delimit_mode_e_ - enum { - fss_extended_read_delimit_mode_none_e = 1, - fss_extended_read_delimit_mode_all_e, - fss_extended_read_delimit_mode_content_e, - fss_extended_read_delimit_mode_content_greater_e, - fss_extended_read_delimit_mode_content_greater_object_e, - fss_extended_read_delimit_mode_content_lesser_e, - fss_extended_read_delimit_mode_content_lesser_object_e, - fss_extended_read_delimit_mode_content_object_e, - fss_extended_read_delimit_mode_object_e, - }; // enum -#endif // _di_fss_extended_read_delimit_mode_e_ - -/** - * Flags passed to the main function or program. - * - * fss_extended_read_main_flag_*_e: - * - none: No flags set. - * - copyright: Print copyright. - * - file_from: Using a specified source file. - * - file_to: Using a specified destination file. - * - help: Print help. - * - header: Enable printing of headers. - * - print_first: When set, print new line to message output on program begin after loading settings. - * - print_last: When set, print new line to message output on program end. - * - separate: Enable printing of separators. - * - strip_invalid: Using strip invalid character mode. - * - verify: Using verify mode. - * - version: Print version. - */ -#ifndef _di_fss_extended_read_main_flag_e_ - enum { - fss_extended_read_main_flag_none_e = 0x0, - fss_extended_read_main_flag_copyright_e = 0x1, - fss_extended_read_main_flag_file_from_e = 0x2, - fss_extended_read_main_flag_file_to_e = 0x4, - fss_extended_read_main_flag_header_e = 0x8, - fss_extended_read_main_flag_help_e = 0x10, - fss_extended_read_main_flag_print_first_e = 0x20, - fss_extended_read_main_flag_print_last_e = 0x40, - fss_extended_read_main_flag_separate_e = 0x80, - fss_extended_read_main_flag_strip_invalid_e = 0x100, - fss_extended_read_main_flag_verify_e = 0x200, - fss_extended_read_main_flag_version_e = 0x400, - }; // enum -#endif // _di_fss_extended_read_main_flag_e_ - -/** - * The fss extended read main program settings. - * - * This is passed to the program-specific main entry point to designate program settings. - * These program settings are often processed from the program arguments (often called the command line arguments). - * - * flag: Flags passed to the main function. - * - * state: The state information. - */ -#ifndef _di_fss_extended_read_setting_t_ - typedef struct { - uint16_t flag; - - f_state_t state; - } fss_extended_read_setting_t; - - #define fss_extended_read_setting_t_initialize \ - { \ - fss_extended_read_main_flag_none_e, \ - f_state_t_initialize, \ - } -#endif // _di_fss_extended_read_setting_t_ - -/** - * Delete the program main setting data. - * - * @param setting - * The program main setting data. - * - * This does not alter setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fss_extended_read_setting_delete_ - extern f_status_t fss_extended_read_setting_delete(fss_extended_read_setting_t * const setting); -#endif // _di_fss_extended_read_setting_delete_ - -/** - * Perform the standard program setting load process. - * - * This prints error messages as appropriate. - * - * If either main or setting is NULL, then this immediately returns without doing anything. - * - * @param arguments - * The parameters passed to the process (often referred to as command line arguments). - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.state.status: - * F_none on success. - * - * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). - * - * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() - */ -#ifndef _di_fss_extended_read_setting_load_ - extern void fss_extended_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_extended_read_setting_t * const setting); -#endif // _di_fss_extended_read_setting_load_ - -/** - * Perform the standard program setting unload process. - * - * @param main - * The main program and setting data. - * All buffers are deallocated. - * - * This does not alter main.setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: fss_extended_read_setting_delete(). - * - * @see fss_extended_read_setting_delete() - */ -#ifndef _di_fss_extended_read_setting_unload_ - extern f_status_t fss_extended_read_setting_unload(fss_extended_read_main_t * const main); -#endif // _di_fss_extended_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_extended_read_common_h diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c deleted file mode 100644 index b805b31..0000000 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ /dev/null @@ -1,559 +0,0 @@ -#include "fss_extended_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_read_main_ - f_status_t fss_extended_read_main(fll_program_data_t * const main, fss_extended_read_setting_t * const setting) { - - f_status_t status = F_none; - - setting->state.step_small = fss_extended_read_allocation_console_d; - - status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - - setting->state.step_small = fss_extended_read_allocation_small_d; - - if (F_status_is_error(status)) return; - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_extended_read_parameter_no_color_e, fss_extended_read_parameter_light_e, fss_extended_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_extended_read_parameter_verbosity_quiet_e, fss_extended_read_parameter_verbosity_error_e, fss_extended_read_parameter_verbosity_verbose_e, fss_extended_read_parameter_verbosity_debug_e, fss_extended_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - } - - if (main->parameters.array[fss_extended_read_parameter_help_e].result & f_console_result_found_e) { - fss_extended_read_print_help(setting, main->message); - - return status; - } - - if (main->parameters.array[fss_extended_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_extended_read_program_version_s); - - return status; - } - - if (main->parameters.array[fss_extended_read_parameter_copyright_e].result & f_console_result_found_e) { - fll_program_print_copyright(main->message); - - return status; - } - - status = F_none; - - // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. - fss_extended_read_file_t files_array[main->parameters.remaining.used + 1]; - fss_extended_read_data_t data = fss_extended_read_data_t_initialize; - - data.argv = main->parameters.arguments.array; - data.files.array = files_array; - data.files.used = 1; - data.files.size = main->parameters.remaining.used + 1; - data.files.array[0].name = fss_extended_read_pipe_name_s; - data.files.array[0].range.start = 1; - data.files.array[0].range.stop = 0; - - if (main->parameters.remaining.used || (main->pipe & fll_program_data_pipe_input_e)) { - { - const f_array_length_t parameter_code[] = { - fss_extended_read_parameter_at_e, - fss_extended_read_parameter_depth_e, - fss_extended_read_parameter_line_e, - fss_extended_read_parameter_select_e, - fss_extended_read_parameter_name_e, - fss_extended_read_parameter_delimit_e, - }; - - const f_string_static_t parameter_name[] = { - fss_extended_read_long_at_s, - fss_extended_read_long_depth_s, - fss_extended_read_long_line_s, - fss_extended_read_long_select_s, - fss_extended_read_long_name_s, - fss_extended_read_long_delimit_s, - }; - - const f_string_t message_positive_number = "positive number"; - const f_string_t message_string = "string"; - const f_string_t message_value = "value"; - - const f_string_t parameter_message[] = { - message_positive_number, - message_positive_number, - message_positive_number, - message_positive_number, - message_string, - message_value, - }; - - for (f_array_length_t i = 0; i < 6; ++i) { - - if (main->parameters.array[parameter_code[i]].result & f_console_result_found_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, parameter_name[i], main->error.notable); - fl_print_format("%[' requires a %s.%]%r", main->error.to, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_extended_read_parameter_columns_e].result & f_console_result_found_e)) { - const f_array_length_t parameter_code[] = { - fss_extended_read_parameter_depth_e, - fss_extended_read_parameter_line_e, - fss_extended_read_parameter_pipe_e, - fss_extended_read_parameter_select_e, - fss_extended_read_parameter_total_e, - }; - - const f_string_static_t parameter_name[] = { - fss_extended_read_long_depth_s, - fss_extended_read_long_line_s, - fss_extended_read_long_pipe_s, - fss_extended_read_long_select_s, - fss_extended_read_long_total_s, - }; - - const uint8_t parameter_match[] = { - f_console_result_value_e, - f_console_result_value_e, - f_console_result_found_e, - f_console_result_value_e, - f_console_result_found_e, - }; - - for (f_array_length_t i = 0; i < 5; ++i) { - - if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_extended_read_long_columns_s, parameter_name[i]); - } - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_extended_read_parameter_pipe_e].result & f_console_result_found_e)) { - if (main->parameters.array[fss_extended_read_parameter_total_e].result & f_console_result_found_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_extended_read_long_pipe_s, fss_extended_read_long_total_s); - } - - status = F_status_set_error(F_parameter); - } - else if (main->parameters.array[fss_extended_read_parameter_line_e].result & f_console_result_value_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_extended_read_long_pipe_s, fss_extended_read_long_line_s); - } - - status = F_status_set_error(F_parameter); - } - } - - if (F_status_is_error_not(status) && main->parameters.array[fss_extended_read_parameter_delimit_e].result & f_console_result_value_e) { - f_array_length_t index = 0; - f_array_length_t length = 0; - - // Set the value to 0 to allow for detecting mode based on what is provided. - data.delimit_mode = 0; - - for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_read_parameter_delimit_e].values.used; ++i) { - - if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_signal); - - break; - } - - main->signal_check = 0; - } - - index = main->parameters.array[fss_extended_read_parameter_delimit_e].values.array[i]; - length = data.argv[index].used; - - if (!length) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_extended_read_long_delimit_s, main->error.notable); - fl_print_format("%[' must not be empty.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - else if (f_compare_dynamic(data.argv[index], fss_extended_read_delimit_mode_name_none_s) == F_equal_to) { - data.delimit_mode = fss_extended_read_delimit_mode_none_e; - } - else if (f_compare_dynamic(data.argv[index], fss_extended_read_delimit_mode_name_all_s) == F_equal_to) { - data.delimit_mode = fss_extended_read_delimit_mode_all_e; - } - else if (f_compare_dynamic(data.argv[index], fss_extended_read_delimit_mode_name_object_s) == F_equal_to) { - switch (data.delimit_mode) { - case 0: - data.delimit_mode = fss_extended_read_delimit_mode_object_e; - break; - - case fss_extended_read_delimit_mode_none_e: - case fss_extended_read_delimit_mode_all_e: - case fss_extended_read_delimit_mode_content_greater_object_e: - case fss_extended_read_delimit_mode_content_lesser_object_e: - case fss_extended_read_delimit_mode_object_e: - break; - - case fss_extended_read_delimit_mode_content_e: - data.delimit_mode = fss_extended_read_delimit_mode_content_object_e; - break; - - case fss_extended_read_delimit_mode_content_greater_e: - data.delimit_mode = fss_extended_read_delimit_mode_content_greater_object_e; - break; - - case fss_extended_read_delimit_mode_content_lesser_e: - data.delimit_mode = fss_extended_read_delimit_mode_content_lesser_object_e; - break; - - default: - break; - } - } - else { - if (!data.delimit_mode) { - data.delimit_mode = fss_extended_read_delimit_mode_content_e; - } - else if (data.delimit_mode == fss_extended_read_delimit_mode_object_e) { - data.delimit_mode = fss_extended_read_delimit_mode_content_object_e; - } - - if (data.argv[index].string[length - 1] == fss_extended_read_delimit_mode_name_greater_s.string[0]) { - if (!(data.delimit_mode == fss_extended_read_delimit_mode_none_e || data.delimit_mode == fss_extended_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_extended_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_extended_read_delimit_mode_content_greater_object_e; - } - else { - data.delimit_mode = fss_extended_read_delimit_mode_content_greater_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - else if (data.argv[index].string[length - 1] == fss_extended_read_delimit_mode_name_lesser_s.string[0]) { - if (!(data.delimit_mode == fss_extended_read_delimit_mode_none_e || data.delimit_mode == fss_extended_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_extended_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_extended_read_delimit_mode_content_lesser_object_e; - } - else { - data.delimit_mode = fss_extended_read_delimit_mode_content_lesser_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - - f_string_range_t range = macro_f_string_range_t_initialize_2(length); - - // Ignore leading plus sign. - if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { - ++range.start; - } - - status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], range, &data.delimit_depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_unsigned_detect", F_true, fss_extended_read_long_delimit_s, data.argv[index]); - - break; - } - - // There can be nothing smaller than 0, so replace '0-' logic with just '0' logic. - if (data.delimit_mode == fss_extended_read_delimit_mode_content_lesser_e || data.delimit_mode == fss_extended_read_delimit_mode_content_lesser_object_e) { - if (!data.delimit_depth) { - if (data.delimit_mode == fss_extended_read_delimit_mode_content_lesser_e) { - data.delimit_mode = fss_extended_read_delimit_mode_content_e; - } - else { - data.delimit_mode = fss_extended_read_delimit_mode_content_object_e; - } - } - } - } - } // for - - // Guarantee the default value is "all". - if (!data.delimit_mode) { - data.delimit_mode = fss_extended_read_delimit_mode_all_e; - } - } - - if (F_status_is_error_not(status)) { - status = fss_extended_read_depth_process(main, &data); - } - - // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. - if (F_status_is_error_not(status) && data.depths.array[0].depth > 0) { - if (main->parameters.array[fss_extended_read_parameter_total_e].result & f_console_result_found_e) { - fss_extended_read_print_zero(main); - } - - fss_extended_read_data_delete_simple(&data); - - return F_none; - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_extended_read_parameter_select_e].result & f_console_result_found_e)) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_extended_read_long_select_s, main->error.notable); - fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - fss_extended_read_depths_resize(0, &data.depths); - - status = F_status_set_error(F_parameter); - } - - if (F_status_is_error_not(status)) { - for (f_array_length_t i = 0; i < data.files.used; ++i) { - macro_f_string_range_t_clear(data.files.array[i].range); - } // for - } - - if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { - f_file_t file = f_file_t_initialize; - - file.id = F_type_descriptor_input_d; - file.stream = F_type_input_d; - - data.files.array[0].range.start = 0; - - status = f_file_stream_read(file, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "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); - } - else if (data.buffer.used) { - data.files.array[0].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - else { - data.files.array[0].range.start = 1; - } - } - - if (F_status_is_error_not(status) && main->parameters.remaining.used > 0) { - f_file_t file = f_file_t_initialize; - off_t size_block = 0; - off_t size_file = 0; - off_t size_read = 0; - - for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - - if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_signal); - - break; - } - - main->signal_check = 0; - } - - data.files.array[data.files.used].range.start = data.buffer.used; - file.stream = 0; - file.id = -1; - - status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); - - break; - } - - size_file = 0; - - status = f_file_size_by_id(file.id, &size_file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - if (size_file) { - - // Enforce a max block read size to allow for interrupts to be processed between blocks. - if (size_file > fss_extended_read_block_max) { - file.size_read = fss_extended_read_block_read_large; - size_block = fss_extended_read_block_max; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + (size_block - (size_file % size_block)) + 1, &data.buffer); - } - else { - file.size_read = fss_extended_read_block_read_small; - size_block = size_file; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + 1, &data.buffer); - } - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - for (size_read = 0; size_read < size_file; size_read += size_block) { - - // The signal check is always performed on each pass. - if (size_file > fss_extended_read_block_max && fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - status = f_file_stream_read_until(file, size_block, &data.buffer); - if (F_status_is_error(status)) break; - } // for - - f_file_stream_flush(file); - f_file_stream_close(&file); - - if (F_status_is_error(status)) { - if (F_status_set_fine(status) != F_interrupt) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read_until", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - } - - break; - } - - if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; - data.files.array[data.files.used++].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - } - else { - data.files.array[data.files.used].range.start = 1; - data.files.array[data.files.used].range.stop = 0; - } - } // for - } - - if (F_status_is_error_not(status)) { - status = fss_extended_read_process(main, &data); - } - - fss_extended_read_data_delete_simple(&data); - } - else { - fll_print_format("%r%[%QYou failed to specify one or more files.%]%r", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - status = F_status_set_error(F_parameter); - } - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - if (F_status_set_fine(status) == F_interrupt) { - f_file_stream_flush(main->output.to); - - fll_print_dynamic_raw(f_string_eol_s, main->output.to); - } - } - - fss_extended_read_data_delete_simple(&data); - - return status; - } -#endif // _di_fss_extended_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_read/c/fss_extended_read.h b/level_3/fss_extended_read/c/fss_extended_read.h deleted file mode 100644 index 5d03807..0000000 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This is the FSS Basic Read program - * This program utilizes the Featureless Linux Library. - * This program processes files or other input in fss format and stores the results in the fll_program_data_t. - * - * This processes in accordance to the FSS-0001 Extended specification. - */ -#ifndef _fss_extended_read_h -#define _fss_extended_read_h - -// Libc includes. -#include -#include -#include -#include -#include - -// FLL-0 includes. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// FLL-1 includes. -#include -#include - -// FLL-2 includes. -#include -#include -#include -#include -#include - -// FSS Extended Read includes. -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Execute main program. - * - * If main.signal is non-zero, then this blocks and handles the following signals: - * - F_signal_abort - * - F_signal_broken_pipe - * - F_signal_hangup - * - F_signal_interrupt - * - F_signal_quit - * - F_signal_termination - * - * @param arguments - * The parameters passed to the process. - * @param main - * The main program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - */ -#ifndef _di_fss_extended_read_main_ - extern f_status_t fss_extended_read_main(fll_program_data_t * const main, fss_extended_read_setting_t * const setting); -#endif // _di_fss_extended_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_extended_read_h diff --git a/level_3/fss_extended_read/c/main.c b/level_3/fss_extended_read/c/main.c deleted file mode 100644 index 9b1909f..0000000 --- a/level_3/fss_extended_read/c/main.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "fss_extended_read.h" - -int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - - fss_extended_read_main_t data = fss_extended_read_main_t_initialize; - - data.program.debug.flag |= fss_extended_read_print_flag_debug_e | fss_extended_read_print_flag_out_e; - data.program.error.flag |= fss_extended_read_print_flag_error_e | fss_extended_read_print_flag_out_e; - data.program.output.flag |= fss_extended_read_print_flag_out_e; - data.program.message.flag |= fss_extended_read_print_flag_message_e | fss_extended_read_print_flag_out_e; - data.program.warning.flag |= fss_extended_read_print_flag_warning_e | fss_extended_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; - - f_console_parameter_t parameters[] = fss_extended_read_console_parameter_t_initialize; - data.program.parameters.array = parameters; - data.program.parameters.used = fss_extended_read_total_parameters_d; - data.program.environment = envp; - - if (f_pipe_input_exists()) { - data.program.pipe = fll_program_data_pipe_input_e; - } - - fll_program_standard_set_up(&data.program); - - { - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); - - fss_extended_read_setting_load(arguments, &data); - } - - fss_extended_read_main(&data); - - fss_extended_read_setting_unload(&data); - - fll_program_data_delete(&data.program); - - fll_program_standard_set_down(&data.program); - - return F_status_is_error(data.setting.state.status) ? 1 : 0; -} diff --git a/level_3/fss_extended_read/c/main.h b/level_3/fss_extended_read/c/main.h deleted file mode 100644 index dafde16..0000000 --- a/level_3/fss_extended_read/c/main.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Extended Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This file is only ever included by main/main.c and should not normally be included anywhere else. - * Anything that wants to include this should be providing the "fss_extended_read" program functionality in some manner. - */ -#ifndef _fss_extended_read_main_h -#define _fss_extended_read_main_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Standard program entry point. - * - * @param argc - * The number of arguments. - * @param argv - * The array of arguments. - * @param envp - * The array of all environment variables on program start. - * - * @return - * 0 on success. - * 1 on error. - */ -extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_extended_read_main_h diff --git a/level_3/fss_extended_read/c/print.c b/level_3/fss_extended_read/c/print.c deleted file mode 100644 index dc3aa2f..0000000 --- a/level_3/fss_extended_read/c/print.c +++ /dev/null @@ -1,116 +0,0 @@ -#include "fss_extended_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_read_print_help_ - f_status_t fss_extended_read_print_help(fss_extended_read_setting_t * const setting, const fl_print_t print) { - - f_file_stream_lock(print.to); - - fll_program_print_help_header(print, fss_extended_read_program_name_long_s, fss_extended_read_program_version_s); - - fll_program_print_help_option_standard(print); - - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_option(print, fss_extended_read_short_at_s, fss_extended_read_long_at_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric index."); - fll_program_print_help_option(print, fss_extended_read_short_content_s, fss_extended_read_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Content (default)."); - fll_program_print_help_option(print, fss_extended_read_short_columns_s, fss_extended_read_long_columns_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of columns."); - fll_program_print_help_option(print, fss_extended_read_short_delimit_s, fss_extended_read_long_delimit_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Designate how to handle applying delimits."); - fll_program_print_help_option(print, fss_extended_read_short_depth_s, fss_extended_read_long_depth_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric depth."); - fll_program_print_help_option(print, fss_extended_read_short_empty_s, fss_extended_read_long_empty_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Include empty Content when processing."); - fll_program_print_help_option(print, fss_extended_read_short_line_s, fss_extended_read_long_line_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print only the Content at the given line."); - fll_program_print_help_option(print, fss_extended_read_short_name_s, fss_extended_read_long_name_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object with this name."); - fll_program_print_help_option(print, fss_extended_read_short_object_s, fss_extended_read_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Object."); - fll_program_print_help_option(print, fss_extended_read_short_pipe_s, fss_extended_read_long_pipe_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print using the special pipe format."); - fll_program_print_help_option(print, fss_extended_read_short_original_s, fss_extended_read_long_original_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print with the original quotes and escapes."); - fll_program_print_help_option(print, fss_extended_read_short_select_s, fss_extended_read_long_select_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select sub-Content at this index."); - fll_program_print_help_option(print, fss_extended_read_short_total_s, fss_extended_read_long_total_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of lines."); - fll_program_print_help_option(print, fss_extended_read_short_trim_s, fss_extended_read_long_trim_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Trim Object names on select or print."); - - f_print_dynamic_raw(f_string_eol_s, print.to); - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_usage(print, fss_extended_read_program_name_s, fll_program_parameter_filenames_s); - - fl_print_format("%r %[Notes:%]%r", print.to, f_string_eol_s, print.set->important, print.set->important, f_string_eol_s); - - fl_print_format(" This program will print the Content associated with the given Object and Content main based on the FSS-0001 Extended standard.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" All numeric positions (indexes) start at 0 instead of 1.%r", print.to, f_string_eol_s); - fl_print_format(" For example, a file of 17 lines would range from 0 to 16.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When using the %[%r%r%] option, an order of operations is enforced on the parameters.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_depth_s, print.set->notable, f_string_eol_s); - - fl_print_format(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%r", print.to, f_string_eol_s); - - fl_print_format(" %[%r%r%]: An Object index at the specified depth.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_at_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: A new depth within the specified depth, indexed from the root.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: An Object name at the specified depth.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] must be in numeric order, but values in between may be skipped.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%r", print.to, f_string_eol_s); - fl_print_format(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] selects a Content column.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_select_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" Specify both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_object_s, print.set->notable); - fl_print_format(" and the %[%r%r%] parameters to get the total objects.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_total_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_at_s, print.set->notable); - fl_print_format(" and %[%r%r%] parameters are specified (at the same depth),", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_name_s, print.set->notable); - fl_print_format(" the %[%r%r%] parameter value will be treated as a position relative to the specified", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_at_s, print.set->notable); - fl_print_format(" %[%r%r%] parameter value.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" This program may support parameters, such as %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_depth_s, print.set->notable); - fl_print_format(" or %[%r%r%], even if not supported by the standard.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_select_s, print.set->notable, f_string_eol_s); - fl_print_format(" This is done to help ensure consistency for scripting.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_depth_s, print.set->notable); - fl_print_format(" if the standard doesn't support nested Content, then only a depth of 0 would be valid.%r", print.to, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_select_s, print.set->notable); - fl_print_format(" if the standard doesn't support multiple Content groups, then only a select of 0 would be valid.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_trim_s, print.set->notable); - fl_print_format(" will remove leading and trailing white spaces when selecting objects or when printing objects.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When specifying both the %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_object_s, print.set->notable); - fl_print_format(" parameter and the %[%r%r%] parameter, the entire Object and Content are printed, including the formatting.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_content_s, print.set->notable, f_string_eol_s); - fl_print_format(" Both the Object and Content printed are already escaped.%r", print.to, f_string_eol_s); - fl_print_format(" Both the Object and Content are separated by a space.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] accepts the following:%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_delimit_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Do not apply delimits.%r", print.to, print.set->notable, fss_extended_read_delimit_mode_name_none_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: (default) Apply all delimits.%r", print.to, print.set->notable, fss_extended_read_delimit_mode_name_all_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Apply delimits for Objects.%r", print.to, print.set->notable, fss_extended_read_delimit_mode_name_object_s, print.set->notable, f_string_eol_s); - fl_print_format(" - A number, 0 or greater: apply delimits for Content at the specified depth.%r", print.to, f_string_eol_s); - fl_print_format(" - A number, 0 or greater, followed by a %[%r%]: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%r", print.to, print.set->notable, fss_extended_read_delimit_mode_name_greater_s, print.set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" - A number, 0 or lesser, followed by a %[%r%]: (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%r%r", print.to, print.set->notable, fss_extended_read_delimit_mode_name_lesser_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%] parameter may be specified multiple times to customize the delimit behavior.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_delimit_s, print.set->notable, f_string_eol_s); - - fl_print_format(" The %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_delimit_s, print.set->notable); - fl_print_format(" values %[%r%]", print.to, print.set->notable, fss_extended_read_delimit_mode_name_none_s, print.set->notable); - fl_print_format(" and %[%r%],", print.to, print.set->notable, fss_extended_read_delimit_mode_name_all_s, print.set->notable); - fl_print_format(" overrule all other delimit values.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameters %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_columns_s, print.set->notable); - fl_print_format(" and %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_extended_read_long_select_s, print.set->notable); - fl_print_format(" refer to a Content column.%r", print.to, f_string_eol_s); - fl_print_format(" The word 'column' is being loosely defined to refer to a specific Content.%r", print.to, f_string_eol_s); - fl_print_format(" This is not to be confused with a depth.%r", print.to, f_string_eol_s); - - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_extended_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_read/c/print.h b/level_3/fss_extended_read/c/print.h deleted file mode 100644 index 251fb21..0000000 --- a/level_3/fss_extended_read/c/print.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Extended Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _fss_extended_read_print_h -#define _fss_extended_read_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print help. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_read_print_help_ - extern f_status_t fss_extended_read_print_help(fss_extended_read_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_extended_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_extended_read_print_h diff --git a/level_3/fss_extended_read/c/private-common.c b/level_3/fss_extended_read/c/private-common.c deleted file mode 100644 index cd03488..0000000 --- a/level_3/fss_extended_read/c/private-common.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "fss_extended_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_read_data_delete_simple_ - void fss_extended_read_data_delete_simple(fss_extended_read_data_t *data) { - - if (!data) return; - - // data->files is expected to be statically loaded and cannot be deallocated. - - fss_extended_read_depths_resize(0, &data->depths); - - macro_f_string_dynamic_t_delete_simple(data->buffer); - macro_f_fss_contents_t_delete_simple(data->contents); - macro_f_fss_objects_t_delete_simple(data->objects); - macro_f_fss_delimits_t_delete_simple(data->delimits_object); - macro_f_fss_delimits_t_delete_simple(data->delimits_content); - macro_f_uint8s_t_delete_simple(data->quotes_object); - macro_f_uint8ss_t_delete_simple(data->quotes_content); - } -#endif // _di_fss_extended_read_data_delete_simple_ - -#ifndef _di_fss_extended_read_depth_delete_simple_ - void fss_extended_read_depth_delete_simple(fss_extended_read_depth_t *depth) { - - if (!depth) return; - - f_string_dynamic_resize(0, &depth->value_name); - } -#endif // _di_fss_extended_read_depth_delete_simple_ - -#ifndef _di_fss_extended_read_depths_resize_ - f_status_t fss_extended_read_depths_resize(const f_array_length_t length, fss_extended_read_depths_t *depths) { - - if (!depths) { - return F_status_set_error(F_parameter); - } - - for (f_array_length_t i = length; i < depths->size; ++i) { - fss_extended_read_depth_delete_simple(&depths->array[i]); - } // for - - const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_extended_read_depth_t), (void **) & depths->array); - if (F_status_is_error(status)) return status; - - depths->size = length; - - if (depths->used > depths->size) { - depths->used = length; - } - - return F_none; - } -#endif // _di_fss_extended_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_read/c/private-common.h b/level_3/fss_extended_read/c/private-common.h deleted file mode 100644 index 3825736..0000000 --- a/level_3/fss_extended_read/c/private-common.h +++ /dev/null @@ -1,268 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: Extended Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_common_h -#define _PRIVATE_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Provide common/generic definitions. - * - * extended_read_common_allocation_*: - * - large: An allocation step used for buffers that are anticipated to have large buffers. - * - small: An allocation step used for buffers that are anticipated to have small buffers. - * - * fss_extended_read_block_*: - * - max: The max block read size before checking for interrupt. - * - read_small: The block read size for small files. - * - read_large: The block read size for large files. - */ -#ifndef _di_fss_extended_read_common_ - #define fss_extended_read_common_allocation_large_d 2048 - #define fss_extended_read_common_allocation_small_d 128 - - #define fss_extended_read_block_max 16777216 - #define fss_extended_read_block_read_small 8192 - #define fss_extended_read_block_read_large 65536 -#endif // _di_fss_extended_read_common_ - -/** - * A structure of parameters applied at some depth. - * - * depth: The depth number in which this is to be processed at. - * - * index_at: Position of the "--at" parameter value in the argv list, when 0 there is no parameter. - * index_name: Position of the "--name" parameter value in the argv list, when 0 there is no parameter. - * - * value_at: The value of the "--at" parameter, already processed and ready to use, only when index_at > 0. - * value_name: The value of the "--name" parameter, already processed and ready to use, only when index_name > 0. - */ -#ifndef _di_fss_extended_read_depth_t_ - typedef struct { - f_array_length_t depth; - - f_array_length_t index_at; - f_array_length_t index_name; - - f_number_unsigned_t value_at; - f_string_dynamic_t value_name; - } fss_extended_read_depth_t; - - #define fss_extended_read_depth_t_initialize \ - { \ - 0, \ - 0, \ - 0, \ - 0, \ - f_string_dynamic_t_initialize, \ - } - - #define macro_fss_extended_read_depth_t_clear(structure) \ - structure.depth = 0; \ - structure.index_at = 0; \ - structure.index_name = 0; \ - structure.value_at = 0; \ - macro_f_string_dynamic_t_clear(structure.value_name) -#endif // _di_fss_extended_read_depth_t_ - -/** - * An array of depth parameters. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_extended_read_depths_t_ - typedef struct { - fss_extended_read_depth_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_extended_read_depths_t; - - #define fss_extended_read_depths_t_initialize { 0, 0, 0 } - - #define macro_fss_extended_read_depths_t_clear(depths) macro_f_memory_structure_clear(depths) -#endif // _di_fss_extended_read_depths_t_ - -/** - * A structure for designating where within the buffer a particular file exists, using a statically allocated array. - * - * name: The name of the file representing the range. - * range: A range within the buffer representing the file. - */ -#ifndef _di_fss_extended_read_file_t_ - typedef struct { - f_string_static_t name; - f_string_range_t range; - } fss_extended_read_file_t; - - #define fss_extended_read_file_t_initialize \ - { \ - f_string_static_t_initialize, \ - f_string_range_t_initialize, \ - } -#endif // _di_fss_extended_read_file_t_ - -/** - * An array of files. - * - * This is intended to be defined and used statically allocated and as such no dynamic allocation or dynamic deallocation methods are provided. - * - * The STDIN pipe is reserved for index 0 and as such size and used must be initialized to 1. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_extended_read_files_t_ - typedef struct { - fss_extended_read_file_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_extended_read_files_t; - - #define fss_extended_read_files_t_initialize { 0, 1, 1 } -#endif // _di_fss_extended_read_files_t_ - -/** - * The data structure for FSS Basic Read. - * - * fss_extended_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - 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). - * - * argv: The argument structure in the progam data parameters for simplifying syntax. - * options: Bitwise flags representing parameters. - * delimit_mode: The delimit mode. - * delimit_depth: The delimit depth. - * select: The Content to select (column number). - * line: The Content to select (row number). - * files: A statically allocated array of files for designating where in the buffer a file is represented. - * depths: The array of parameters for each given depth. - * buffer: The buffer containing all loaded files (and STDIN pipe). - * objects: The positions within the buffer representing Objects. - * 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. - */ -#ifndef _di_fss_extended_read_data_t_ - #define fss_extended_read_data_option_at_d 0x1 - #define fss_extended_read_data_option_columns_d 0x2 - #define fss_extended_read_data_option_content_d 0x4 - #define fss_extended_read_data_option_empty_d 0x8 - #define fss_extended_read_data_option_line_d 0x10 - #define fss_extended_read_data_option_name_d 0x20 - #define fss_extended_read_data_option_object_d 0x40 - #define fss_extended_read_data_option_original_d 0x80 - #define fss_extended_read_data_option_select_d 0x100 - #define fss_extended_read_data_option_total_d 0x200 - #define fss_extended_read_data_option_trim_d 0x400 - - typedef struct { - uint16_t option; - uint8_t delimit_mode; - f_array_length_t delimit_depth; - f_number_unsigned_t select; - f_number_unsigned_t line; - - f_string_static_t *argv; - - fss_extended_read_files_t files; - fss_extended_read_depths_t depths; - - f_string_dynamic_t buffer; - f_fss_objects_t objects; - f_fss_contents_t contents; - f_fss_delimits_t delimits_object; - f_fss_delimits_t delimits_content; - f_uint8s_t quotes_object; - f_uint8ss_t quotes_content; - } fss_extended_read_data_t; - - #define fss_extended_read_data_t_initialize \ - { \ - 0, \ - fss_extended_read_delimit_mode_all_e, \ - 0, \ - 0, \ - 0, \ - 0, \ - fss_extended_read_files_t_initialize, \ - fss_extended_read_depths_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_fss_objects_t_initialize, \ - f_fss_contents_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_uint8s_t_initialize, \ - f_uint8ss_t_initialize, \ - } -#endif // _di_fss_extended_read_data_t_ - -/** - * Fully deallocate all memory for the given data without caring about return status. - * - * @param data - * The data to deallocate. - */ -#ifndef _di_fss_extended_read_data_delete_simple_ - extern void fss_extended_read_data_delete_simple(fss_extended_read_data_t *data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_data_delete_simple_ - -/** - * Fully deallocate all memory for the given depth without caring about return status. - * - * @param depth - * The depth to deallocate. - */ -#ifndef _di_fss_extended_read_depth_delete_simple_ - extern void fss_extended_read_depth_delete_simple(fss_extended_read_depth_t *depth) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_depth_delete_simple_ - -/** - * Resize the depth array. - * - * @param length - * The new size to use. - * @param depths - * The depth array to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * Errors (with error bit) from: fss_extended_read_depths_increase(). - * - * @see f_memory_resize() - * - * @see fss_extended_read_depth_delete_simple() - * @see fss_extended_read_depths_increase() - */ -#ifndef _di_fss_extended_read_depths_resize_ - extern f_status_t fss_extended_read_depths_resize(const f_array_length_t length, fss_extended_read_depths_t *depths) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_common_h diff --git a/level_3/fss_extended_read/c/private-print.c b/level_3/fss_extended_read/c/private-print.c deleted file mode 100644 index 75eb6e5..0000000 --- a/level_3/fss_extended_read/c/private-print.c +++ /dev/null @@ -1,265 +0,0 @@ -#include "fss_extended_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_read_print_at_ - void fss_extended_read_print_at(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_extended_read_data_t * const data) { - - if (at >= data->contents.used) { - return; - } - - f_file_stream_lock(main->output.to); - - if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (data->contents.array[at].used || (data->option & fss_extended_read_data_option_empty_d))) { - if (data->option & fss_extended_read_data_option_object_d) { - if (data->option & fss_extended_read_data_option_trim_d) { - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_object.array[at]) { - f_print_dynamic_raw( - data->quotes_object.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - - fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_object.array[at]) { - f_print_dynamic_raw( - data->quotes_object.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - } - else { - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_object.array[at]) { - f_print_dynamic_raw( - data->quotes_object.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - - f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_object.array[at]) { - f_print_dynamic_raw( - data->quotes_object.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - } - - if (data->option & fss_extended_read_data_option_content_d) { - fss_extended_read_print_object_end(main); - } - } - - bool content_printed = F_false; - - if ((data->option & fss_extended_read_data_option_content_d) && data->contents.array[at].used) { - if (data->option & fss_extended_read_data_option_select_d) { - if (data->select < data->contents.array[at].used) { - content_printed = F_true; - - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_content.array[at].array[data->select]) { - data->quotes_content.array[at].array[data->select] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content.array[at].array[data->select] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - - f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[data->select], delimits_content, main->output.to); - - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_content.array[at].array[data->select]) { - f_print_dynamic_raw( - data->quotes_content.array[at].array[data->select] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content.array[at].array[data->select] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - } - } - else { - for (f_array_length_t i = 0; i < data->contents.array[at].used; ++i) { - - if (data->contents.array[at].array[i].start > data->contents.array[at].array[i].stop) { - continue; - } - - content_printed = F_true; - - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_content.array[at].array[i]) { - f_print_dynamic_raw( - data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content.array[at].array[i] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - - f_print_except_dynamic_partial(data->buffer, data->contents.array[at].array[i], delimits_content, main->output.to); - - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_content.array[at].array[i]) { - f_print_dynamic_raw( - data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content.array[at].array[i] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - - if (i + 1 < data->contents.array[at].used && data->contents.array[at].array[i + 1].start <= data->contents.array[at].array[i + 1].stop) { - fss_extended_read_print_content_end(main); - } - } // for - } - } - - if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (content_printed || (data->option & fss_extended_read_data_option_empty_d))) { - fss_extended_read_print_set_end(main); - } - - f_file_stream_unlock(main->output.to); - } - } -#endif // _di_fss_extended_read_print_at_ - -#ifndef _di_fss_extended_read_print_at_total_ - f_status_t fss_extended_read_print_at_total(fll_program_data_t * const main, const f_array_length_t at, fss_extended_read_data_t *data) { - - if (data->option & fss_extended_read_data_option_select_d) { - if (data->option & fss_extended_read_data_option_object_d) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_one(main); - - f_file_stream_unlock(main->output.to); - - return F_success; - } - - if (data->select < data->contents.array[at].used) { - if (data->contents.array[at].array[data->select].start <= data->contents.array[at].array[data->select].stop || (data->option & fss_extended_read_data_option_empty_d)) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_one(main); - - f_file_stream_unlock(main->output.to); - - return F_success; - } - } - } - else if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_empty_d)) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_one(main); - - f_file_stream_unlock(main->output.to); - - return F_success; - } - else if (data->contents.array[at].used) { - for (f_array_length_t j = 0; j < data->contents.array[at].used; ++j) { - - if (data->contents.array[at].array[j].start <= data->contents.array[at].array[j].stop) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_one(main); - - f_file_stream_unlock(main->output.to); - - return F_success; - } - } // for - } - - return F_none; - } -#endif // _di_fss_extended_read_print_at_total_ - -#ifndef _di_fss_extended_read_print_content_end_ - void fss_extended_read_print_content_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_extended_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_extended_read_pipe_content_start_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_space_s, main->output.to); - } - } -#endif // _di_fss_extended_read_print_content_end_ - -#ifndef _di_fss_extended_read_print_object_end_ - void fss_extended_read_print_object_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_extended_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_extended_read_pipe_content_end_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_space_s, main->output.to); - } - } -#endif // _di_fss_extended_read_print_object_end_ - -#ifndef _di_fss_extended_read_print_one_ - void fss_extended_read_print_one(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_1_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_extended_read_print_one_ - -#ifndef _di_fss_extended_read_print_set_end_ - void fss_extended_read_print_set_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_extended_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_extended_read_pipe_content_end_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_eol_s, main->output.to); - } - } -#endif // _di_fss_extended_read_print_set_end_ - -#ifndef _di_fss_extended_read_print_zero_ - void fss_extended_read_print_zero(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_0_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_extended_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_read/c/private-print.h b/level_3/fss_extended_read/c/private-print.h deleted file mode 100644 index f24d2f5..0000000 --- a/level_3/fss_extended_read/c/private-print.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_print_h -#define _PRIVATE_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print the Object and Content at the given position. - * - * Only what is requested to print (Object, Content, both, or neither) will be printed, if there is something to print. - * - * @param main - * The main program data. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param data - * The program data. - */ -#ifndef _di_fss_extended_read_print_at_ - extern void fss_extended_read_print_at(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_print_at_ - -/** - * Print total count at the specified Object/Content position. - * - * @param main - * The main program data. - * @param at - * The Object/Content position. - * @param data - * The program data. - * - * @return - * F_none on success but nothig was matched (and total was printed). - * F_success on success and something was matched (and total was printed). - */ -#ifndef _di_fss_extended_read_print_at_total_ - extern f_status_t fss_extended_read_print_at_total(fll_program_data_t * const main, const f_array_length_t at, fss_extended_read_data_t *data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_print_at_total_ - -/** - * Print the end of a Content. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_extended_read_print_content_end_ - extern void fss_extended_read_print_content_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_print_content_end_ - -/** - * Print the end of an Object (which is essentially the start of Content). - * - * @param main - * The main program data. - */ -#ifndef _di_fss_extended_read_print_object_end_ - extern void fss_extended_read_print_object_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_print_object_end_ - -/** - * Print the number one and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_extended_read_print_one_ - extern void fss_extended_read_print_one(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_print_one_ - -/** - * Print the end of an Object/Content set. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_extended_read_print_set_end_ - extern void fss_extended_read_print_set_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_print_set_end_ - -/** - * Print the number zero and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_extended_read_print_zero_ - extern void fss_extended_read_print_zero(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_print_h diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c deleted file mode 100644 index be48d0d..0000000 --- a/level_3/fss_extended_read/c/private-read.c +++ /dev/null @@ -1,738 +0,0 @@ -#include "fss_extended_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_extended_read_delimit_object_is_ - f_status_t fss_extended_read_delimit_object_is(const f_array_length_t depth, fss_extended_read_data_t * const data) { - - switch (data->delimit_mode) { - case fss_extended_read_delimit_mode_none_e: - case fss_extended_read_delimit_mode_content_e: - case fss_extended_read_delimit_mode_content_greater_e: - case fss_extended_read_delimit_mode_content_lesser_e: - return F_false; - - case fss_extended_read_delimit_mode_all_e: - case fss_extended_read_delimit_mode_content_object_e: - case fss_extended_read_delimit_mode_content_greater_object_e: - case fss_extended_read_delimit_mode_content_lesser_object_e: - case fss_extended_read_delimit_mode_object_e: - return F_true; - - default: - break; - } - - return depth == data->delimit_depth || data->delimit_mode == fss_extended_read_delimit_mode_content_lesser_e; - } -#endif // _di_fss_extended_read_delimit_object_is_ - -#ifndef _di_fss_extended_read_delimit_content_is_ - f_status_t fss_extended_read_delimit_content_is(const f_array_length_t depth, fss_extended_read_data_t * const data) { - - switch (data->delimit_mode) { - case fss_extended_read_delimit_mode_none_e: - case fss_extended_read_delimit_mode_object_e: - return F_false; - - case fss_extended_read_delimit_mode_all_e: - return F_true; - - default: - break; - } - - if (depth < data->delimit_depth) { - return data->delimit_mode == fss_extended_read_delimit_mode_content_lesser_e || data->delimit_mode == fss_extended_read_delimit_mode_content_lesser_object_e; - } - - if (depth > data->delimit_depth) { - return data->delimit_mode == fss_extended_read_delimit_mode_content_greater_e || data->delimit_mode == fss_extended_read_delimit_mode_content_greater_object_e; - } - - return depth == data->delimit_depth; - } -#endif // _di_fss_extended_read_delimit_content_is_ - -#ifndef _di_fss_extended_read_depth_process_ - f_status_t fss_extended_read_depth_process(fll_program_data_t * const main, fss_extended_read_data_t * const data) { - - f_status_t status = F_none; - - { - f_array_length_t depth_size = 1; - - if (main->parameters.array[fss_extended_read_parameter_depth_e].result & f_console_result_value_e) { - depth_size = main->parameters.array[fss_extended_read_parameter_depth_e].values.used; - } - - if (depth_size > data->depths.size) { - status = fss_extended_read_depths_resize(depth_size, &data->depths); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fss_extended_read_depths_resize", fll_error_file_flag_fallback_e); - - return status; - } - } - - data->depths.used = depth_size; - } - - f_array_length_t position_depth = 0; - f_array_length_t position_at = 0; - f_array_length_t position_name = 0; - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - data->depths.array[i].depth = 0; - data->depths.array[i].index_at = 0; - data->depths.array[i].index_name = 0; - data->depths.array[i].value_at = 0; - - macro_f_string_dynamic_t_clear(data->depths.array[i].value_name); - - if (!main->parameters.array[fss_extended_read_parameter_depth_e].values.used) { - position_depth = 0; - } - else { - position_depth = main->parameters.array[fss_extended_read_parameter_depth_e].values.array[i]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[position_depth], &data->depths.array[i].depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_extended_read_long_depth_s, data->argv[position_depth]); - - return status; - } - } - - if (main->parameters.array[fss_extended_read_parameter_at_e].result & f_console_result_value_e) { - for (; position_at < main->parameters.array[fss_extended_read_parameter_at_e].values.used; ++position_at) { - - if (main->parameters.array[fss_extended_read_parameter_at_e].values.array[position_at] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_extended_read_parameter_at_e].values.array[position_at] > main->parameters.array[fss_extended_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_at = main->parameters.array[fss_extended_read_parameter_at_e].values.array[position_at]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[data->depths.array[i].index_at], &data->depths.array[i].value_at); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_extended_read_long_at_s, data->argv[data->depths.array[i].index_at]); - - return status; - } - } // for - } - - if (main->parameters.array[fss_extended_read_parameter_name_e].result & f_console_result_value_e) { - for (; position_name < main->parameters.array[fss_extended_read_parameter_name_e].values.used; position_name++) { - - if (main->parameters.array[fss_extended_read_parameter_name_e].values.array[position_name] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_extended_read_parameter_name_e].values.array[position_name] > main->parameters.array[fss_extended_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_name = main->parameters.array[fss_extended_read_parameter_name_e].values.array[position_name]; - - if (main->parameters.array[fss_extended_read_parameter_trim_e].result & f_console_result_found_e) { - status = f_rip_dynamic(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - else { - status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), (main->parameters.array[fss_extended_read_parameter_trim_e].result & f_console_result_found_e) ? "f_rip_dynamic" : "f_string_dynamic_append", fll_error_file_flag_fallback_e); - - return status; - } - } // for - } - } // for - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - - if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' may only be specified once for the parameter '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_extended_read_long_depth_s, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - else if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_extended_read_long_depth_s, main->error.notable); - fl_print_format("%[' may not have the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' before the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[j].depth, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - } // for - } // for - - return F_none; - } -#endif // _di_fss_extended_read_depth_process_ - -#ifndef _di_fss_extended_read_file_identify_ - f_string_static_t fss_extended_read_file_identify(const f_array_length_t at, const fss_extended_read_files_t files) { - - for (f_array_length_t i = 0; i < files.used; ++i) { - - if (at >= files.array[i].range.start && at <= files.array[i].range.stop) { - return files.array[i].name; - } - } // for - - // When stopped after the end of the buffer, the last file in the list is the correct file. - if (at > files.array[files.used - 1].range.stop) { - return files.array[files.used - 1].name; - } - - return f_string_empty_s; - } -#endif // _di_fss_extended_read_file_identify_ - -#ifndef _di_fss_extended_read_load_ - f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t * const data) { - - f_state_t state = macro_f_state_t_initialize_1(fss_extended_read_common_allocation_large_d, fss_extended_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); - f_string_range_t input = macro_f_string_range_t_initialize_2(data->buffer.used); - - data->delimits_object.used = 0; - data->delimits_content.used = 0; - data->quotes_object.used = 0; - data->quotes_content.used = 0; - - const f_status_t status = fll_fss_extended_read(data->buffer, state, &input, &data->objects, &data->contents, &data->quotes_object, &data->quotes_content, &data->delimits_object, &data->delimits_content); - - if (F_status_is_error(status)) { - const f_string_static_t file_name = fss_extended_read_file_identify(input.start, data->files); - - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_extended_read", fll_error_file_flag_fallback_e, file_name, f_file_operation_process_s, fll_error_file_type_file_e); - - return status; - } - - if (status == F_data_not_stop || status == F_data_not_eos) { - if (data->option & fss_extended_read_data_option_total_d) return F_none; - - return F_status_set_warning(status); - } - - return F_none; - } -#endif // _di_fss_extended_read_load_ - -#ifndef _di_fss_extended_read_load_number_ - f_status_t fss_extended_read_load_number(fll_program_data_t * const main, fss_extended_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { - - if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - - const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, name, data->argv[index]); - - return status; - } - - return F_true; - } - - return F_false; - } -#endif // _di_fss_extended_read_load_number_ - -#ifndef _di_fss_extended_read_process_ - f_status_t fss_extended_read_process(fll_program_data_t * const main, fss_extended_read_data_t * const data) { - - f_status_t status = fss_extended_read_process_option(main, data); - if (F_status_is_error(status)) return status; - - status = fss_extended_read_load(main, data); - if (F_status_is_error(status)) return status; - - bool names[data->objects.used]; - - status = fss_extended_read_process_name(data, names); - if (F_status_is_error(status)) return status; - - if (data->depths.array[0].index_at) { - return fss_extended_read_process_at(main, data, names); - } - - if (data->option & fss_extended_read_data_option_columns_d) { - return fss_extended_read_process_columns(main, data, names); - } - - if (data->option & fss_extended_read_data_option_total_d) { - return fss_extended_read_process_total(main, data, names); - } - - if (data->option & fss_extended_read_data_option_line_d) { - return fss_extended_read_process_line(main, data, names); - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content : &except_none; - - if (data->option & fss_extended_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - fss_extended_read_print_at(main, i, *delimits_object, *delimits_content, data); - } // for - - return F_none; - } -#endif // _di_fss_extended_read_process_ - -#ifndef _di_fss_extended_read_process_at_ - f_status_t fss_extended_read_process_at(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) { - - if (data->depths.array[0].value_at >= data->objects.used) { - if (data->option & (fss_extended_read_data_option_columns_d | fss_extended_read_data_option_total_d)) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - - // This standard only has one line per Content; therefore, any line value greater than 0 equates to no line to print. - if (data->option & fss_extended_read_data_option_line_d) { - if (data->line) { - if (data->option & fss_extended_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content : &except_none; - - if (data->option & fss_extended_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t at = 0; - - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (!names[i]) continue; - - if (at == data->depths.array[0].value_at) { - if (data->option & fss_extended_read_data_option_line_d) { - - // This standard only supports one line per Object so when using "--at", the only valid line is line 0. - if (data->line) break; - - if (data->option & fss_extended_read_data_option_total_d) { - if (fss_extended_read_print_at_total(main, i, data) == F_none) { - break; - } - } - else { - // @fixme: is this block correct? It makes no sense here with the print at function below printing both Object and Content. - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_object.array[at]) { - f_print_dynamic_raw( - data->quotes_object.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - - fss_extended_read_print_at(main, i, *delimits_object, *delimits_content, data); - - // @fixme: is this block correct? It makes no sense here with the print at function above printing both Object and Content. - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_object.array[at]) { - f_print_dynamic_raw( - data->quotes_object.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - } - } - else if (data->option & fss_extended_read_data_option_columns_d) { - fll_print_format("%ul%r", main->output.to, data->contents.array[i].used, f_string_eol_s); - } - else if (data->option & fss_extended_read_data_option_total_d) { - if (fss_extended_read_print_at_total(main, i, data) == F_none) { - break; - } - } - else { - // @fixme: is this block correct? It makes no sense here with the print at function below printing both Object and Content. - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_content.array[at].array[i]) { - f_print_dynamic_raw( - data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content.array[at].array[i] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - - fss_extended_read_print_at(main, i, *delimits_object, *delimits_content, data); - - // @fixme: is this block correct? It makes no sense here with the print at function above printing both Object and Content. - if ((data->option & fss_extended_read_data_option_original_d) && data->quotes_content.array[at].array[i]) { - f_print_dynamic_raw( - data->quotes_content.array[at].array[i] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content.array[at].array[i] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - } - - return F_none; - } - - ++at; - } // for - - if (data->option & fss_extended_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } -#endif // _di_fss_extended_read_process_at_ - -#ifndef _di_fss_extended_read_process_columns_ - f_status_t fss_extended_read_process_columns(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) { - - if (!(data->option & fss_extended_read_data_option_content_d)) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - - return F_none; - } - - f_array_length_t max = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (data->contents.array[at].used > max) { - max = data->contents.array[at].used; - } - } // for - - fll_print_format("%ul%r", main->output.to, max, f_string_eol_s); - - return F_none; - } -#endif // _di_fss_extended_read_process_columns_ - -#ifndef _di_fss_extended_read_process_line_ - f_status_t fss_extended_read_process_line(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_extended_read_delimit_object_is(0, data) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_extended_read_delimit_content_is((data->option & fss_extended_read_data_option_select_d) ? data->select : 0, data) ? &data->delimits_content : &except_none; - - if (data->option & fss_extended_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t line = 0; - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - if (!(data->option & fss_extended_read_data_option_object_d) && (data->option & fss_extended_read_data_option_content_d)) { - if (!data->contents.array[i].used) { - if (data->option & fss_extended_read_data_option_empty_d) { - if (line == data->line) { - f_file_stream_lock(main->output.to); - - fss_extended_read_print_set_end(main); - - f_file_stream_unlock(main->output.to); - - break; - } - - ++line; - } - - continue; - } - } - - if (line == data->line) { - fss_extended_read_print_at(main, i, *delimits_object, *delimits_content, data); - - break; - } - - ++line; - } // for - - return F_none; - } -#endif // _di_fss_extended_read_process_line_ - -#ifndef _di_fss_extended_read_process_name_ - f_status_t fss_extended_read_process_name(fss_extended_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - - if (data->depths.array[0].index_name) { - f_array_length_t i = 0; - - memset(names, F_false, sizeof(bool) * data->objects.used); - - if (data->option & fss_extended_read_data_option_trim_d) { - for (i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_except_trim_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits_object) == F_equal_to) { - names[i] = F_true; - } - } // for - } - else { - for (i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_except_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits_content) == F_equal_to) { - names[i] = F_true; - } - } // for - } - } - else { - memset(names, F_true, sizeof(bool) * data->objects.used); - } - - return F_none; - } -#endif // _di_fss_extended_read_process_name_ - -#ifndef _di_fss_extended_read_process_option_ - f_status_t fss_extended_read_process_option(fll_program_data_t * const main, fss_extended_read_data_t * const data) { - - f_status_t status = F_none; - - if (main->parameters.array[fss_extended_read_parameter_at_e].result & f_console_result_value_e) { - data->option |= fss_extended_read_data_option_at_d; - } - - if (main->parameters.array[fss_extended_read_parameter_columns_e].result & f_console_result_found_e) { - data->option |= fss_extended_read_data_option_columns_d; - } - - if (main->parameters.array[fss_extended_read_parameter_content_e].result & f_console_result_found_e) { - data->option |= fss_extended_read_data_option_content_d; - } - - if (main->parameters.array[fss_extended_read_parameter_empty_e].result & f_console_result_found_e) { - data->option |= fss_extended_read_data_option_empty_d; - } - - if (main->parameters.array[fss_extended_read_parameter_line_e].result & f_console_result_value_e) { - data->option |= fss_extended_read_data_option_line_d; - - status = fss_extended_read_load_number(main, data, fss_extended_read_parameter_line_e, fss_extended_read_long_line_s, &data->line); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_extended_read_parameter_name_e].result & f_console_result_value_e) { - data->option |= fss_extended_read_data_option_name_d; - } - - if (main->parameters.array[fss_extended_read_parameter_object_e].result & f_console_result_found_e) { - data->option |= fss_extended_read_data_option_object_d; - } - - if (main->parameters.array[fss_extended_read_parameter_original_e].result & f_console_result_found_e) { - data->option |= fss_extended_read_data_option_original_d; - } - - if (main->parameters.array[fss_extended_read_parameter_select_e].result & f_console_result_value_e) { - data->option |= fss_extended_read_data_option_select_d; - - status = fss_extended_read_load_number(main, data, fss_extended_read_parameter_select_e, fss_extended_read_long_select_s, &data->select); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_extended_read_parameter_total_e].result & f_console_result_found_e) { - data->option |= fss_extended_read_data_option_total_d; - } - - if (main->parameters.array[fss_extended_read_parameter_trim_e].result & f_console_result_found_e) { - data->option |= fss_extended_read_data_option_trim_d; - } - - // Default to content if neither Object nor Content is explicitly requested. - if (!(data->option & (fss_extended_read_data_option_content_d | fss_extended_read_data_option_object_d))) { - data->option |= fss_extended_read_data_option_content_d; - } - - return F_none; - } -#endif // _di_fss_extended_read_process_option_ - -#ifndef _di_fss_extended_read_process_total_ - f_status_t fss_extended_read_process_total(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) { - - f_array_length_t total = 0; - - // This standard only has one Content per line, however it has multiple Contents within that line. - if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (data->option & fss_extended_read_data_option_empty_d)) { - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (!names[i]) continue; - - ++total; - } // for - } - else { - f_array_length_t i = 0; - f_array_length_t j = 0; - - for (; i < data->contents.used; ++i) { - - if (!names[i]) continue; - if (!data->contents.array[i].used) continue; - - if ((data->option & fss_extended_read_data_option_select_d) && data->contents.array[i].used <= data->select) { - continue; - } - - for (j = 0; j < data->contents.array[i].used; ++j) { - - if (data->contents.array[i].array[j].start <= data->contents.array[i].array[j].stop) { - if (data->option & fss_extended_read_data_option_select_d) { - if (j == data->select) { - ++total; - - break; - } - } - else { - ++total; - - break; - } - } - } // for - } // for - } - - f_file_stream_lock(main->output.to); - - if (data->option & fss_extended_read_data_option_line_d) { - if (data->line < total) { - fss_extended_read_print_one(main); - } - else { - fss_extended_read_print_zero(main); - } - } - else { - fl_print_format("%ul%r", main->output.to, total, f_string_eol_s); - } - - f_file_stream_unlock(main->output.to); - - return F_none; - } -#endif // _di_fss_extended_read_process_total_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_extended_read/c/private-read.h b/level_3/fss_extended_read/c/private-read.h deleted file mode 100644 index 4a11337..0000000 --- a/level_3/fss_extended_read/c/private-read.h +++ /dev/null @@ -1,288 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_read_h -#define _PRIVATE_read_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Determine if the given depth is to be delimited or not for Content. - * - * @param depth - * The depth to check. - * @param data - * The program data. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_extended_read_delimit_content_is_ - extern f_status_t fss_extended_read_delimit_content_is(const f_array_length_t depth, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_delimit_content_is_ - -/** - * Determine if the given depth is to be delimited or not for an Object. - * - * @param depth - * The depth to check. - * @param data - * The program data. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_extended_read_delimit_object_is_ - extern f_status_t fss_extended_read_delimit_object_is(const f_array_length_t depth, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_delimit_object_is_ - -/** - * Process the parameters, parsing out and handling the depth and depth related parameters. - * - * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_string_append(). - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * Errors (with error bit) from: f_rip_dynamic(). - * - * Errors (with error bit) from: fss_extended_read_depths_resize(). - * - * @see f_string_append() - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * @see f_rip_dynamic() - * - * @see fss_extended_read_depths_resize() - */ -#ifndef _di_fss_extended_read_depth_process_ - extern f_status_t fss_extended_read_depth_process(fll_program_data_t * const main, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_depth_process_ - -/** - * Get the name of the file the given position represents within the buffer. - * - * @param at - * The position within the buffer. - * @param files - * The representation of files and their respective ranges within the buffer. - * - * @return - * A string with the name when found. - * NULL is returned if the range represents the STDIN pipe. - * - * On failure to identify, an empty string is returned. - */ -#ifndef _di_fss_extended_read_file_identify_ - extern f_string_static_t fss_extended_read_file_identify(const f_array_length_t at, const fss_extended_read_files_t files) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_file_identify_ - -/** - * Process the buffer, loading the FSS data. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * 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_extended_read_process_option() - */ -#ifndef _di_fss_extended_read_load_ - extern f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_load_ - -/** - * Load a given number parameter. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param parameter - * An ID representing the parameter. - * @param name - * The parameter name to print on error. - * @param number - * The location to store the loaded number. - * - * @return - * F_true on success and the parameter was found (and is valid). - * F_false on success and the parameter was not found. - * - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * - * @see fss_extended_read_depths_resize() - */ -#ifndef _di_fss_extended_read_load_number_ - extern f_status_t fss_extended_read_load_number(fll_program_data_t * const main, fss_extended_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_load_number_ - -/** - * Perform the extended read processing on the buffer. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_extended_read_load() - * Errors (with error bit) from: fss_extended_read_process_option() - * - * @see fss_extended_read_load() - * @see fss_extended_read_process_option() - */ -#ifndef _di_fss_extended_read_process_ - extern f_status_t fss_extended_read_process(fll_program_data_t * const main, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_process_ - -/** - * Process based on at parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_read_process_at_ - extern f_status_t fss_extended_read_process_at(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_process_at_ - -/** - * Process based on columns parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_read_process_columns_ - extern f_status_t fss_extended_read_process_columns(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_process_columns_ - -/** - * Process based on line parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_read_process_line_ - extern f_status_t fss_extended_read_process_line(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_process_line_ - -/** - * Process the Objects in the buffer, determining if the Object name is to be used or not. - * - * How an Object name is determined to be used or not is dependent on several parameters, such as --name, --depth, --at, and --line. - * - * @param main - * The main program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_read_process_name_ - extern f_status_t fss_extended_read_process_name(fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_process_name_ - -/** - * Process the parameters, populating the option property of the program data. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_extended_read_load_setting() - * - * @see fll_fss_extended_read() - * - * @see fss_extended_read_load_setting() - */ -#ifndef _di_fss_extended_read_process_option_ - extern f_status_t fss_extended_read_process_option(fll_program_data_t * const main, fss_extended_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_process_option_ - -/** - * Process based on total parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_extended_read_process_total_ - extern f_status_t fss_extended_read_process_total(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_process_total_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_read_h diff --git a/level_3/fss_extended_read/data/build/defines b/level_3/fss_extended_read/data/build/defines deleted file mode 100644 index 490da41..0000000 --- a/level_3/fss_extended_read/data/build/defines +++ /dev/null @@ -1,6 +0,0 @@ -# fss-0000 - -_di_thread_support_ Disables thread support. - -_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. -_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/fss_extended_read/data/build/dependencies b/level_3/fss_extended_read/data/build/dependencies deleted file mode 100644 index 22cdeb6..0000000 --- a/level_3/fss_extended_read/data/build/dependencies +++ /dev/null @@ -1,31 +0,0 @@ -# fss-0000 - -f_type -f_status -f_memory -f_type_array -f_string -f_utf -f_color -f_compare -f_console -f_conversion -f_directory -f_environment -f_file -f_fss -f_parse -f_pipe -f_print -f_rip -f_signal - -fl_conversion -fl_fss -fl_print - -fll_error -fll_file -fll_fss -fll_print -fll_program diff --git a/level_3/fss_extended_read/data/build/fakefile b/level_3/fss_extended_read/data/build/fakefile deleted file mode 100644 index ece5f79..0000000 --- a/level_3/fss_extended_read/data/build/fakefile +++ /dev/null @@ -1,27 +0,0 @@ -# fss-0005 iki-0002 - -settings: - fail exit - modes individual individual_thread level monolithic clang test fanalyzer thread threadless - - environment PATH LD_LIBRARY_PATH - environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -main: - build - -install: - shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' - -help: - print - print context:'title'Fakefile Options for FSS Extended Read Software.context:'reset' - - print - print The following operations are available\: - print " - context:'notable'help:context:'reset' Perform the help operation, printing this message." - print " - context:'notable'install:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." - print " - context:'notable'main:context:'reset' The default compilation using the build settings mode." - - print - print The context:'notable'install context:'reset'operation supports the context:'notable'work,context:'reset' context:'notable'verbosity,context:'reset' and context:'notable'color context:'reset'parameters. diff --git a/level_3/fss_extended_read/data/build/settings b/level_3/fss_extended_read/data/build/settings deleted file mode 100644 index 99e48b2..0000000 --- a/level_3/fss_extended_read/data/build/settings +++ /dev/null @@ -1,85 +0,0 @@ -# fss-0001 -# -# Modes: -# - individual: Compile using per project (individual) libraries, does not handle thread or threadless cases. -# - individual_thread: This is required when compiling in individual mode with "thread" mode. -# - level: Compile using per level libraries. -# - monolithic: Compile using per monolithic libraries. -# - clang: Use clang rather than the default, which is generally gcc. -# - test: Compile for a test, such as unit testing. -# - fanalyzer: Compile using GCC's -fanalyzer compile time option. -# - thread: Compile with thread support. -# - threadless: Compile without thread support. -# - -build_name fss_extended_read - -version_major 0 -version_minor 7 -version_micro 0 -version_file micro -version_target minor - -modes individual individual_thread level monolithic clang test fanalyzer thread threadless -modes_default monolithic thread - -build_compiler gcc -build_compiler-clang clang -build_indexer ar -build_indexer_arguments rcs -build_language c - -build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_parse -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_status_string -lf_string -lf_type_array -lf_utf -build_libraries-individual_thread -lf_thread -build_libraries-level -lfll_2 -lfll_1 -lfll_0 -build_libraries-monolithic -lfll - -build_sources_library fss_extended_read.c common.c print.c private-common.c private-print.c private-read.c - -build_sources_program main.c - -build_sources_headers fss_extended_read.h common.h print.h - -build_sources_documentation man - -build_script yes -build_shared yes -build_static no - -path_headers program/fss_extended_read -path_library_script script -path_library_shared shared -path_library_static static -path_object_script script -path_object_shared shared -path_object_static static -path_program_script script -path_program_shared shared -path_program_static static - -has_path_standard yes -preserve_path_headers yes - -search_exclusive yes -search_shared yes -search_static yes - -environment PATH LD_LIBRARY_PATH -environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -#defines -D_di_libcap_ -defines -D_libcap_legacy_only_ -defines-threadless -D_di_thread_support_ -defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ - -flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces -flags-thread -pthread -flags-clang -Wno-logical-op-parentheses -flags-test -O0 -fstack-protector -Wall -flags-fanalyzer -fanalyzer -flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ - -flags_library -fPIC -flags_object -fPIC -flags_program -fPIE diff --git a/level_3/fss_extended_read/data/documentation/man/man1/fss_extended_read.1 b/level_3/fss_extended_read/data/documentation/man/man1/fss_extended_read.1 deleted file mode 100644 index 73887e9..0000000 --- a/level_3/fss_extended_read/data/documentation/man/man1/fss_extended_read.1 +++ /dev/null @@ -1,145 +0,0 @@ -.TH FSS_EXTENDED_READ "1" "March 2023" "FLL - FSS Extended Read 0.7.0" "User Commands" -.SH NAME -fss_extended_read \- Read data in \fBFSS-0001 (Extended)\fR format. -.SH SYNOPSIS -.B fss_extended_read -[\fI\,OPTIONS\/\fR] [\fI\,FILENAMES\/\fR] -.SH DESCRIPTION -.PP -This program will print the Content associated with the given Object and Content main based on the \fBFSS-0001 Extended\fR standard. - -All numeric positions (indexes) start at 0 instead of 1. -For example, a file of 17 lines would range from 0 to 16. - -When using the \fB\-\-depth\fR option, an order of operations is enforced on the parameters. -When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter: - \fB\-\-at\fR: An Object index at the specified depth. - \fB\-\-depth\fR: A new depth within the specified depth, indexed from the root. - \fB\-\-name\fR: An Object name at the specified depth. - -The parameter \fB\-\-depth\fR must be in numeric order, but values in between may be skipped. - ('\fB\-d 0 \-a 1 \-d 2 \-a 2\fR' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.) - ('\fB\-d 2 \-a 1 \-d 0 \-a 2\fR' would be invalid because depth 2 is before depth 1.) - -The parameter \fB\-\-select\fR selects a Content column. - -Specify both \fB\-\-object\fR and the \fB\-\-total\fR parameters to get the total objects. - -When both \fB\-\-at\fR and \fB\-\-name\fR parameters are specified (at the same depth), the \fB\-\-at\fR parameter value will be treated as a position relative to the specified \fB\-\-name\fR parameter value. - -This program may support parameters, such as \fB\-\-depth\fR or \fB\-\-select\fR, even if not supported by the standard. -This is done to help ensure consistency for scripting. - -For parameters like \fB\-\-depth\fR, if the standard doesn't support nested Content, then only a depth of 0 would be valid. -For parameters like \fB\-\-select\fR, if the standard doesn't support multiple Content groups, then only a select of 0 would be valid. - -The parameter \fB\-\-trim\fR will remove leading and trailing white spaces when selecting objects or when printing objects. - -When specifying both the \fB\-\-object\fR parameter and the \fB\-\-content\fR parameter, the entire Object and Content are printed, including the formatting. -Both the Object and Content printed are already escaped. -Both the Object and Content are separated by a space. - -The parameter \fB\-\-delimit\fR accepts the following: - \fBnone\fR: Do not apply delimits. - \fBall\fR: (default) Apply all delimits. - \fBobject\fR: Apply delimits for Objects. - \fBA number, 0 or greater\fR: apply delimits for Content at the specified depth. - \fBA number, 0 or greater, followed by a +\fR: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically). - \fBA number, 0 or lesser, followed by a \-\fR: (such as '1\-') apply delimits for Content at the specified depth and any lesser depth (numerically). - -The \fB\-\-delimit\fR parameter may be specified multiple times to customize the delimit behavior. -The \fB\-\-delimit\fR values none and all, overrule all other delimit values. - -The parameters \fB\-\-columns\fR and \fB\-\-select\fR refer to a Content column. -The word '\fBcolumn\fR' is being loosely defined to refer to a specific Content. -This is not to be confused with a depth. -.SH OPTIONS -.TP -\fB\{\-h, \-\-help\fR -Print the help message. -.TP -\fB+C, ++copyright\fR -Print the copyright. -.TP -\fB+d, ++dark\fR -Output using colors that show up better on dark backgrounds. -.TP -\fB+l, ++light\fR -Output using colors that show up better on light backgrounds. -.TP -\fB+n, ++no_color\fR -Do not print using color. -.TP -\fB+Q, ++quiet\fR -Decrease verbosity, silencing most output. -.TP -\fB+E, ++error\fR -Decrease verbosity, using only error output. -.TP -\fB+N, ++normal\fR -Set verbosity to normal. -.TP -\fB+V, ++verbose\fR -Increase verbosity beyond normal output. -.TP -\fB+D, ++debug\fR -Enable debugging, significantly increasing verbosity beyond normal output. -.TP -\fB+v, ++version\fR -Print only the version number. -.TP -\fB+F, ++line_first_no\fR -Disable printing of first line. -.TP -\fB+L, ++line_last_no\fR -Disable printing of last line. -.TP -\fB\-a, \-\-at\fR -Select Object at this numeric index. -.TP -\fB\-c, \-\-content\fR -Print the Content (default). -.TP -\fB\-C, \-\-columns\fR -Print the total number of columns. -.TP -\fB\-D, \-\-delimit\fR -Designate how to handle applying delimits. -.TP -\fB\-d, \-\-depth\fR -Select Object at this numeric depth. -.TP -\fB\-e, \-\-empty\fR -Include empty Content when processing. -.TP -\fB\-l, \-\-line\fR -Print only the Content at the given line. -.TP -\fB\-n, \-\-name\fR -Select Object with this name. -.TP -\fB\-o, \-\-object\fR -Print the Object. -.TP -\fB\-p, \-\-pipe\fR -Print using the special pipe format. -.TP -\fB\-O, \-\-original\fR -Print with the original quotes and escapes. -.TP -\fB\-s, \-\-select\fR -Select sub-Content at this index. -.TP -\fB\-t, \-\-total\fR -Print the total number of lines. -.TP -\fB\-T, \-\-trim\fR -Trim Object names on select or print. -.SH FILENAMES -.TP -Any number of files to read. -.SH AUTHOR -Written by Kevin Day. -.SH COPYRIGHT -.PP -Copyright \(co 2007-2023 Kevin Day, GNU LGPL Version 2.1 or later. diff --git a/level_3/fss_payload_read/c/common.c b/level_3/fss_payload_read/c/common.c deleted file mode 100644 index db2f7e6..0000000 --- a/level_3/fss_payload_read/c/common.c +++ /dev/null @@ -1,199 +0,0 @@ -#include "fss_payload_read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_read_program_version_s_ - const f_string_static_t fss_payload_read_program_version_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_program_version_s, 0, FSS_PAYLOAD_READ_program_version_s_length); -#endif // _di_fss_payload_read_program_version_s_ - -#ifndef _di_fss_payload_read_program_name_s_ - const f_string_static_t fss_payload_read_program_name_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_program_name_s, 0, FSS_PAYLOAD_READ_program_name_s_length); - const f_string_static_t fss_payload_read_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_program_name_long_s, 0, FSS_PAYLOAD_READ_program_name_long_s_length); -#endif // _di_fss_payload_read_program_name_s_ - -#ifndef _di_fss_payload_read_pipe_s_ - const f_string_static_t fss_payload_read_pipe_name_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_pipe_name_s, 0, FSS_PAYLOAD_READ_pipe_name_s_length); - - const f_string_static_t fss_payload_read_pipe_content_end_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_pipe_content_end_s, 0, FSS_PAYLOAD_READ_pipe_content_end_s_length); - const f_string_static_t fss_payload_read_pipe_content_ignore_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_pipe_content_ignore_s, 0, FSS_PAYLOAD_READ_pipe_content_ignore_s_length); - const f_string_static_t fss_payload_read_pipe_content_start_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_pipe_content_start_s, 0, FSS_PAYLOAD_READ_pipe_content_start_s_length); -#endif // _di_fss_payload_read_pipe_s_ - -#ifndef _di_fss_payload_read_parameter_d_ - const f_string_static_t fss_payload_read_short_at_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_at_s, 0, FSS_PAYLOAD_READ_short_at_s_length); - const f_string_static_t fss_payload_read_short_content_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_content_s, 0, FSS_PAYLOAD_READ_short_content_s_length); - const f_string_static_t fss_payload_read_short_columns_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_columns_s, 0, FSS_PAYLOAD_READ_short_columns_s_length); - const f_string_static_t fss_payload_read_short_delimit_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_delimit_s, 0, FSS_PAYLOAD_READ_short_delimit_s_length); - const f_string_static_t fss_payload_read_short_depth_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_depth_s, 0, FSS_PAYLOAD_READ_short_depth_s_length); - const f_string_static_t fss_payload_read_short_empty_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_empty_s, 0, FSS_PAYLOAD_READ_short_empty_s_length); - const f_string_static_t fss_payload_read_short_line_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_line_s, 0, FSS_PAYLOAD_READ_short_line_s_length); - const f_string_static_t fss_payload_read_short_name_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_name_s, 0, FSS_PAYLOAD_READ_short_name_s_length); - const f_string_static_t fss_payload_read_short_object_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_object_s, 0, FSS_PAYLOAD_READ_short_object_s_length); - const f_string_static_t fss_payload_read_short_pipe_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_pipe_s, 0, FSS_PAYLOAD_READ_short_pipe_s_length); - const f_string_static_t fss_payload_read_short_original_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_original_s, 0, FSS_PAYLOAD_READ_short_original_s_length); - const f_string_static_t fss_payload_read_short_select_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_select_s, 0, FSS_PAYLOAD_READ_short_select_s_length); - const f_string_static_t fss_payload_read_short_total_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_total_s, 0, FSS_PAYLOAD_READ_short_total_s_length); - const f_string_static_t fss_payload_read_short_trim_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_short_trim_s, 0, FSS_PAYLOAD_READ_short_trim_s_length); - - const f_string_static_t fss_payload_read_long_at_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_at_s, 0, FSS_PAYLOAD_READ_long_at_s_length); - const f_string_static_t fss_payload_read_long_content_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_content_s, 0, FSS_PAYLOAD_READ_long_content_s_length); - const f_string_static_t fss_payload_read_long_columns_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_columns_s, 0, FSS_PAYLOAD_READ_long_columns_s_length); - const f_string_static_t fss_payload_read_long_delimit_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_delimit_s, 0, FSS_PAYLOAD_READ_long_delimit_s_length); - const f_string_static_t fss_payload_read_long_depth_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_depth_s, 0, FSS_PAYLOAD_READ_long_depth_s_length); - const f_string_static_t fss_payload_read_long_empty_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_empty_s, 0, FSS_PAYLOAD_READ_long_empty_s_length); - const f_string_static_t fss_payload_read_long_line_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_line_s, 0, FSS_PAYLOAD_READ_long_line_s_length); - const f_string_static_t fss_payload_read_long_name_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_name_s, 0, FSS_PAYLOAD_READ_long_name_s_length); - const f_string_static_t fss_payload_read_long_object_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_object_s, 0, FSS_PAYLOAD_READ_long_object_s_length); - const f_string_static_t fss_payload_read_long_pipe_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_pipe_s, 0, FSS_PAYLOAD_READ_long_pipe_s_length); - const f_string_static_t fss_payload_read_long_original_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_original_s, 0, FSS_PAYLOAD_READ_long_original_s_length); - const f_string_static_t fss_payload_read_long_select_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_select_s, 0, FSS_PAYLOAD_READ_long_select_s_length); - const f_string_static_t fss_payload_read_long_total_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_total_s, 0, FSS_PAYLOAD_READ_long_total_s_length); - const f_string_static_t fss_payload_read_long_trim_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_long_trim_s, 0, FSS_PAYLOAD_READ_long_trim_s_length); -#endif // _di_fss_payload_read_parameter_d_ - -#ifndef _di_fss_payload_read_delimit_mode_s_ - const f_string_static_t fss_payload_read_delimit_mode_name_none_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_delimit_mode_name_none_s, 0, FSS_PAYLOAD_READ_delimit_mode_name_none_s_length); - const f_string_static_t fss_payload_read_delimit_mode_name_all_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_delimit_mode_name_all_s, 0, FSS_PAYLOAD_READ_delimit_mode_name_all_s_length); - const f_string_static_t fss_payload_read_delimit_mode_name_object_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_delimit_mode_name_object_s, 0, FSS_PAYLOAD_READ_delimit_mode_name_object_s_length); - const f_string_static_t fss_payload_read_delimit_mode_name_greater_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_delimit_mode_name_greater_s, 0, FSS_PAYLOAD_READ_delimit_mode_name_greater_s_length); - const f_string_static_t fss_payload_read_delimit_mode_name_lesser_s = macro_f_string_static_t_initialize_1(FSS_PAYLOAD_READ_delimit_mode_name_lesser_s, 0, FSS_PAYLOAD_READ_delimit_mode_name_lesser_s_length); -#endif // _di_fss_payload_read_delimit_mode_s_ - -#ifndef _di_fss_payload_read_setting_delete_ - f_status_t fss_payload_read_setting_delete(fss_payload_read_setting_t * const setting) { - - if (!setting) return F_status_set_error(F_parameter); - - return F_none; - } -#endif // _di_fss_payload_read_setting_delete_ - -#ifndef _di_fss_payload_read_setting_load_ - void fss_payload_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_read_setting_t * const setting) { - - if (!main) return; - - main->setting.state.step_small = fss_payload_read_allocation_console_d; - - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); - - main->setting.state.step_small = fss_payload_read_allocation_small_d; - - // Identify and pocess first/last parameters. - if (main->program.parameters.array[payload_read_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & payload_read_main_flag_print_first_e; - } - else { - main->setting.flag |= payload_read_main_flag_print_first_e; - } - - if (main->program.parameters.array[payload_read_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & payload_read_main_flag_print_last_e; - } - else { - main->setting.flag |= payload_read_main_flag_print_last_e; - } - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "f_console_parameter_process", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_payload_read_parameter_no_color_e, fss_payload_read_parameter_light_e, fss_payload_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - static const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_payload_read_parameter_verbosity_quiet_e, fss_payload_read_parameter_verbosity_error_e, fss_payload_read_parameter_verbosity_verbose_e, fss_payload_read_parameter_verbosity_debug_e, fss_payload_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - static const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(main->setting.state.status)) { - fll_error_print(&main->program.error, F_status_set_fine(main->setting.state.status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->program.error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->program.error); - } - - return; - } - } - } - - main->program.output.to.id = F_type_descriptor_output_d; - main->program.output.to.stream = F_type_output_d; - main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d; - - if (main->program.parameters.array[fss_payload_read_parameter_help_e].result & f_console_result_found_e) { - main->setting.flag |= fss_payload_read_main_flag_help_e; - - return; - } - - if (main->program.parameters.array[fss_payload_read_parameter_version_e].result & f_console_result_found_e) { - main->setting.flag |= fss_payload_read_main_flag_version_e; - - return; - } - - if (main->program.parameters.array[fss_payload_read_parameter_copyright_e].result & f_console_result_found_e) { - main->setting.flag |= fss_payload_read_main_flag_copyright_e; - - return; - } - - f_string_static_t * const args = main->program.parameters.arguments.array; - - if (main->program.parameters.array[fss_payload_read_parameter_strip_invalid_e].result & f_console_result_found_e) { - main->setting.flag |= fss_payload_read_main_flag_strip_invalid_e; - } - } -#endif // _di_fss_payload_read_setting_load_ - -#ifndef _di_fss_payload_read_setting_unload_ - f_status_t fss_payload_read_setting_unload(fss_payload_read_main_t * const main) { - - if (!main) return F_status_set_error(F_parameter); - - fss_payload_read_setting_delete(&main->setting); - - return F_none; - } -#endif // _di_fss_payload_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_read/c/common.h b/level_3/fss_payload_read/c/common.h deleted file mode 100644 index cb49abf..0000000 --- a/level_3/fss_payload_read/c/common.h +++ /dev/null @@ -1,430 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Payload Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Provides the common data structures. - * - * This is auto-included and should not need to be explicitly included. - */ -#ifndef _fss_payload_read_common_h -#define _fss_payload_read_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The program version. - */ -#ifndef _di_fss_payload_read_program_version_s_ - #define FSS_PAYLOAD_READ_program_version_major_s F_string_ascii_0_s - #define FSS_PAYLOAD_READ_program_version_minor_s F_string_ascii_7_s - #define FSS_PAYLOAD_READ_program_version_micro_s F_string_ascii_0_s - - #define FSS_PAYLOAD_READ_program_version_major_s_length F_string_ascii_0_s_length - #define FSS_PAYLOAD_READ_program_version_minor_s_length F_string_ascii_7_s_length - #define FSS_PAYLOAD_READ_program_version_micro_s_length F_string_ascii_0_s_length - - #if !(defined(FSS_PAYLOAD_READ_program_version_nano_prefix_s) && defined(FSS_PAYLOAD_READ_program_version_nano_prefix_s_length)) - #define FSS_PAYLOAD_READ_program_version_nano_prefix_s - #define FSS_PAYLOAD_READ_program_version_nano_prefix_s_length 0 - #endif // !(defined(FSS_PAYLOAD_READ_program_version_nano_prefix_s) && defined(FSS_PAYLOAD_READ_program_version_nano_prefix_s_length)) - - #if !(defined(FSS_PAYLOAD_READ_program_version_nano_s) && defined(FSS_PAYLOAD_READ_program_version_nano_s_length)) - #define FSS_PAYLOAD_READ_program_version_nano_s - #define FSS_PAYLOAD_READ_program_version_nano_s_length 0 - #endif // !(defined(FSS_PAYLOAD_READ_program_version_nano_s) && defined(FSS_PAYLOAD_READ_program_version_nano_s_length)) - - #define FSS_PAYLOAD_READ_program_version_s FSS_PAYLOAD_READ_program_version_major_s F_string_ascii_period_s FSS_PAYLOAD_READ_program_version_minor_s F_string_ascii_period_s FSS_PAYLOAD_READ_program_version_micro_s FSS_PAYLOAD_READ_program_version_nano_prefix_s FSS_PAYLOAD_READ_program_version_nano_s - - #define FSS_PAYLOAD_READ_program_version_s_length FSS_PAYLOAD_READ_program_version_major_s_length + F_string_ascii_period_s_length + FSS_PAYLOAD_READ_program_version_minor_s_length + F_string_ascii_period_s_length + FSS_PAYLOAD_READ_program_version_micro_s_length + FSS_PAYLOAD_READ_program_version_nano_prefix_s_length + FSS_PAYLOAD_READ_program_version_nano_s_length - - extern const f_string_static_t fss_payload_read_program_version_s; -#endif // _di_fss_payload_read_program_version_s_ - -/** - * The program name. - */ -#ifndef _di_fss_payload_read_program_name_s_ - #define FSS_PAYLOAD_READ_program_name_s "fss_payload_read" - #define FSS_PAYLOAD_READ_program_name_long_s "FSS Payload Read" - - #define FSS_PAYLOAD_READ_program_name_s_length 16 - #define FSS_PAYLOAD_READ_program_name_long_s_length 16 - - extern const f_string_static_t fss_payload_read_program_name_s; - extern const f_string_static_t fss_payload_read_program_name_long_s; -#endif // _di_fss_payload_read_program_name_s_ - -/** - * The program defines. - */ -#ifndef _di_fss_payload_read_d_ - #define fss_payload_read_signal_check_d 20000 -#endif // _di_fss_payload_read_d_ - -/** - * The program pipe strings. - */ -#ifndef _di_fss_payload_read_pipe_s_ - #define FSS_PAYLOAD_READ_pipe_name_s "(pipe)" - - #define FSS_PAYLOAD_READ_pipe_content_end_s "\f" - #define FSS_PAYLOAD_READ_pipe_content_ignore_s "\v" - #define FSS_PAYLOAD_READ_pipe_content_start_s "\b" - - #define FSS_PAYLOAD_READ_pipe_name_s_length 6 - - #define FSS_PAYLOAD_READ_pipe_content_end_s_length 1 - #define FSS_PAYLOAD_READ_pipe_content_ignore_s_length 1 - #define FSS_PAYLOAD_READ_pipe_content_start_s_length 1 - - extern const f_string_static_t fss_payload_read_pipe_name_s; - - extern const f_string_static_t fss_payload_read_pipe_content_end_s; - extern const f_string_static_t fss_payload_read_pipe_content_ignore_s; - extern const f_string_static_t fss_payload_read_pipe_content_start_s; -#endif // _di_fss_payload_read_pipe_s_ - -/** - * The main program parameters. - */ -#ifndef _di_fss_payload_read_parameter_d_ - #define FSS_PAYLOAD_READ_short_at_s "a" - #define FSS_PAYLOAD_READ_short_content_s "c" - #define FSS_PAYLOAD_READ_short_columns_s "C" - #define FSS_PAYLOAD_READ_short_delimit_s "D" - #define FSS_PAYLOAD_READ_short_depth_s "d" - #define FSS_PAYLOAD_READ_short_empty_s "e" - #define FSS_PAYLOAD_READ_short_line_s "l" - #define FSS_PAYLOAD_READ_short_name_s "n" - #define FSS_PAYLOAD_READ_short_object_s "o" - #define FSS_PAYLOAD_READ_short_pipe_s "p" - #define FSS_PAYLOAD_READ_short_original_s "O" - #define FSS_PAYLOAD_READ_short_select_s "s" - #define FSS_PAYLOAD_READ_short_total_s "t" - #define FSS_PAYLOAD_READ_short_trim_s "T" - - #define FSS_PAYLOAD_READ_long_at_s "at" - #define FSS_PAYLOAD_READ_long_content_s "content" - #define FSS_PAYLOAD_READ_long_columns_s "columns" - #define FSS_PAYLOAD_READ_long_delimit_s "delimit" - #define FSS_PAYLOAD_READ_long_depth_s "depth" - #define FSS_PAYLOAD_READ_long_empty_s "empty" - #define FSS_PAYLOAD_READ_long_line_s "line" - #define FSS_PAYLOAD_READ_long_name_s "name" - #define FSS_PAYLOAD_READ_long_object_s "object" - #define FSS_PAYLOAD_READ_long_pipe_s "pipe" - #define FSS_PAYLOAD_READ_long_original_s "original" - #define FSS_PAYLOAD_READ_long_select_s "select" - #define FSS_PAYLOAD_READ_long_total_s "total" - #define FSS_PAYLOAD_READ_long_trim_s "trim" - - #define FSS_PAYLOAD_READ_short_at_s_length 1 - #define FSS_PAYLOAD_READ_short_content_s_length 1 - #define FSS_PAYLOAD_READ_short_columns_s_length 1 - #define FSS_PAYLOAD_READ_short_delimit_s_length 1 - #define FSS_PAYLOAD_READ_short_depth_s_length 1 - #define FSS_PAYLOAD_READ_short_empty_s_length 1 - #define FSS_PAYLOAD_READ_short_line_s_length 1 - #define FSS_PAYLOAD_READ_short_name_s_length 1 - #define FSS_PAYLOAD_READ_short_object_s_length 1 - #define FSS_PAYLOAD_READ_short_pipe_s_length 1 - #define FSS_PAYLOAD_READ_short_original_s_length 1 - #define FSS_PAYLOAD_READ_short_select_s_length 1 - #define FSS_PAYLOAD_READ_short_total_s_length 1 - #define FSS_PAYLOAD_READ_short_trim_s_length 1 - - #define FSS_PAYLOAD_READ_long_at_s_length 2 - #define FSS_PAYLOAD_READ_long_content_s_length 7 - #define FSS_PAYLOAD_READ_long_columns_s_length 7 - #define FSS_PAYLOAD_READ_long_delimit_s_length 7 - #define FSS_PAYLOAD_READ_long_depth_s_length 5 - #define FSS_PAYLOAD_READ_long_empty_s_length 5 - #define FSS_PAYLOAD_READ_long_line_s_length 4 - #define FSS_PAYLOAD_READ_long_name_s_length 4 - #define FSS_PAYLOAD_READ_long_object_s_length 6 - #define FSS_PAYLOAD_READ_long_pipe_s_length 4 - #define FSS_PAYLOAD_READ_long_original_s_length 8 - #define FSS_PAYLOAD_READ_long_select_s_length 6 - #define FSS_PAYLOAD_READ_long_total_s_length 5 - #define FSS_PAYLOAD_READ_long_trim_s_length 4 - - extern const f_string_static_t fss_payload_read_short_at_s; - extern const f_string_static_t fss_payload_read_short_content_s; - extern const f_string_static_t fss_payload_read_short_columns_s; - extern const f_string_static_t fss_payload_read_short_delimit_s; - extern const f_string_static_t fss_payload_read_short_depth_s; - extern const f_string_static_t fss_payload_read_short_empty_s; - extern const f_string_static_t fss_payload_read_short_line_s; - extern const f_string_static_t fss_payload_read_short_name_s; - extern const f_string_static_t fss_payload_read_short_object_s; - extern const f_string_static_t fss_payload_read_short_pipe_s; - extern const f_string_static_t fss_payload_read_short_original_s; - extern const f_string_static_t fss_payload_read_short_select_s; - extern const f_string_static_t fss_payload_read_short_total_s; - extern const f_string_static_t fss_payload_read_short_trim_s; - - extern const f_string_static_t fss_payload_read_long_at_s; - extern const f_string_static_t fss_payload_read_long_content_s; - extern const f_string_static_t fss_payload_read_long_columns_s; - extern const f_string_static_t fss_payload_read_long_delimit_s; - extern const f_string_static_t fss_payload_read_long_depth_s; - extern const f_string_static_t fss_payload_read_long_empty_s; - extern const f_string_static_t fss_payload_read_long_line_s; - extern const f_string_static_t fss_payload_read_long_name_s; - extern const f_string_static_t fss_payload_read_long_object_s; - extern const f_string_static_t fss_payload_read_long_pipe_s; - extern const f_string_static_t fss_payload_read_long_original_s; - extern const f_string_static_t fss_payload_read_long_select_s; - extern const f_string_static_t fss_payload_read_long_total_s; - extern const f_string_static_t fss_payload_read_long_trim_s; - - enum { - fss_payload_read_parameter_help_e, - fss_payload_read_parameter_copyright_e, - fss_payload_read_parameter_light_e, - fss_payload_read_parameter_dark_e, - fss_payload_read_parameter_no_color_e, - fss_payload_read_parameter_verbosity_quiet_e, - fss_payload_read_parameter_verbosity_error_e, - fss_payload_read_parameter_verbosity_normal_e, - fss_payload_read_parameter_verbosity_verbose_e, - fss_payload_read_parameter_verbosity_debug_e, - fss_payload_read_parameter_version_e, - fss_payload_read_parameter_line_first_no_e, - fss_payload_read_parameter_line_last_no_e, - - fss_payload_read_parameter_at_e, - fss_payload_read_parameter_content_e, - fss_payload_read_parameter_columns_e, - fss_payload_read_parameter_delimit_e, - fss_payload_read_parameter_depth_e, - fss_payload_read_parameter_empty_e, - fss_payload_read_parameter_line_e, - fss_payload_read_parameter_name_e, - fss_payload_read_parameter_object_e, - fss_payload_read_parameter_pipe_e, - fss_payload_read_parameter_original_e, - fss_payload_read_parameter_select_e, - fss_payload_read_parameter_total_e, - fss_payload_read_parameter_trim_e, - }; // enum - - #define fss_payload_read_console_parameter_t_initialize \ - { \ - macro_fll_program_console_parameter_standard_initialize, \ - \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_at_s, fss_payload_read_long_at_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_content_s, fss_payload_read_long_content_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_columns_s, fss_payload_read_long_columns_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_delimit_s, fss_payload_read_long_delimit_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_depth_s, fss_payload_read_long_depth_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_empty_s, fss_payload_read_long_empty_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_line_s, fss_payload_read_long_line_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_name_s, fss_payload_read_long_name_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_object_s, fss_payload_read_long_object_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_pipe_s, fss_payload_read_long_pipe_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_original_s, fss_payload_read_long_original_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_select_s, fss_payload_read_long_select_s, 0, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_total_s, fss_payload_read_long_total_s, 0, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(fss_payload_read_short_trim_s, fss_payload_read_long_trim_s, 0, 0, f_console_flag_normal_e), \ - } - - #define fss_payload_read_total_parameters_d 27 -#endif // _di_fss_payload_read_parameter_d_ - -/** - * FSS Delimit Parameter strings. - * - * fss_payload_read_delimit_mode_*: - * - all: All delimits are to be aplied. - * - content: Content are to have delimits applied. - * - content_greater: Content at this number or higher are to have delimits applied. - * - content_greater_object: Objects and Content at this number or higher are to have delimits applied. - * - content_lesser: Content at this number or lower are to have delimits applied. - * - content_lesser_object: Objects and Content at this number or lower are to have delimits applied. - * - content_object: Objects and Content are to have delimits applied - * - object: Objects arre to have delimits applied. - */ -#ifndef _di_fss_payload_read_delimit_mode_s_ - #define FSS_PAYLOAD_READ_delimit_mode_name_none_s "none" - #define FSS_PAYLOAD_READ_delimit_mode_name_all_s "all" - #define FSS_PAYLOAD_READ_delimit_mode_name_object_s "object" - #define FSS_PAYLOAD_READ_delimit_mode_name_greater_s "+" - #define FSS_PAYLOAD_READ_delimit_mode_name_lesser_s "-" - - #define FSS_PAYLOAD_READ_delimit_mode_name_none_s_length 4 - #define FSS_PAYLOAD_READ_delimit_mode_name_all_s_length 3 - #define FSS_PAYLOAD_READ_delimit_mode_name_object_s_length 6 - #define FSS_PAYLOAD_READ_delimit_mode_name_greater_s_length 1 - #define FSS_PAYLOAD_READ_delimit_mode_name_lesser_s_length 1 - - extern const f_string_static_t fss_payload_read_delimit_mode_name_none_s; - extern const f_string_static_t fss_payload_read_delimit_mode_name_all_s; - extern const f_string_static_t fss_payload_read_delimit_mode_name_object_s; - extern const f_string_static_t fss_payload_read_delimit_mode_name_greater_s; - extern const f_string_static_t fss_payload_read_delimit_mode_name_lesser_s; -#endif // _di_fss_payload_read_delimit_mode_s_ - -/** - * FSS Delimit Parameter enumerations. - */ -#ifndef _di_fss_payload_read_delimit_mode_e_ - enum { - fss_payload_read_delimit_mode_none_e = 1, - fss_payload_read_delimit_mode_all_e, - fss_payload_read_delimit_mode_content_e, - fss_payload_read_delimit_mode_content_greater_e, - fss_payload_read_delimit_mode_content_greater_object_e, - fss_payload_read_delimit_mode_content_lesser_e, - fss_payload_read_delimit_mode_content_lesser_object_e, - fss_payload_read_delimit_mode_content_object_e, - fss_payload_read_delimit_mode_object_e, - }; // enum -#endif // _di_fss_payload_read_delimit_mode_e_ - -/** - * Flags passed to the main function or program. - * - * fss_payload_read_main_flag_*_e: - * - none: No flags set. - * - at: Selecting at a specific index. - * - content: Print Contents. - * - copyright: Print copyright. - * - help: Print help. - * - literal: Print as literal data (printing entire variable). - * - line: Selecting at a specific line. - * - name: Selecting using a specific Vocabulary name. - * - object: Print Objects. - * - print_first: When set, print new line to message output on program begin after loading settings. - * - print_last: When set, print new line to message output on program end. - * - replace: Using re-assignments. - * - replace: Using replacements. - * - substitute: Using substitutions. - * - total: Enable printing of "total" count. - * - version: Print version. - * - whole: Print all data. - * - wrap: Using wrapping. - */ -#ifndef _di_fss_payload_read_main_flag_e_ - enum { - fss_payload_read_main_flag_none_e = 0x0, - fss_payload_read_main_flag_at_e = 0x1, - fss_payload_read_main_flag_content_e = 0x2, - fss_payload_read_main_flag_copyright_e = 0x4, - fss_payload_read_main_flag_help_e = 0x8, - fss_payload_read_main_flag_literal_e = 0x10, - fss_payload_read_main_flag_line_e = 0x20, - fss_payload_read_main_flag_name_e = 0x40, - fss_payload_read_main_flag_object_e = 0x80, - fss_payload_read_main_flag_print_first_e = 0x100, - fss_payload_read_main_flag_print_last_e = 0x200, - fss_payload_read_main_flag_reassign_e = 0x400, - fss_payload_read_main_flag_replace_e = 0x800, - fss_payload_read_main_flag_substitute_e = 0x1000, - fss_payload_read_main_flag_total_e = 0x2000, - fss_payload_read_main_flag_version_e = 0x4000, - fss_payload_read_main_flag_whole_e = 0x8000, - fss_payload_read_main_flag_wrap_e = 0x10000, - }; // enum -#endif // _di_fss_payload_read_main_flag_e_ - -/** - * The fss payload read main program settings. - * - * This is passed to the program-specific main entry point to designate program settings. - * These program settings are often processed from the program arguments (often called the command line arguments). - * - * flag: Flags passed to the main function. - * - * state: The state information. - */ -#ifndef _di_fss_payload_read_setting_t_ - typedef struct { - uint16_t flag; - - f_state_t state; - } fss_payload_read_setting_t; - - #define fss_payload_read_setting_t_initialize \ - { \ - fss_payload_read_main_flag_none_e, \ - f_state_t_initialize, \ - } -#endif // _di_fss_payload_read_setting_t_ - -/** - * Delete the program main setting data. - * - * @param setting - * The program main setting data. - * - * This does not alter setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fss_payload_read_setting_delete_ - extern f_status_t fss_payload_read_setting_delete(fss_payload_read_setting_t * const setting); -#endif // _di_fss_payload_read_setting_delete_ - -/** - * Perform the standard program setting load process. - * - * This prints error messages as appropriate. - * - * If either main or setting is NULL, then this immediately returns without doing anything. - * - * @param arguments - * The parameters passed to the process (often referred to as command line arguments). - * @param main - * The main program data. - * @param setting - * The main program settings. - * - * This alters setting.state.status: - * F_none on success. - * - * Errors (with error bit) from: f_console_parameter_process(). - * Errors (with error bit) from: fll_program_parameter_process_context(). - * - * @see f_console_parameter_process() - * @see fll_program_parameter_process_context() - */ -#ifndef _di_fss_payload_read_setting_load_ - extern void fss_payload_read_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_payload_read_setting_t * const setting); -#endif // _di_fss_payload_read_setting_load_ - -/** - * Perform the standard program setting unload process. - * - * @param main - * The main program and setting data. - * All buffers are deallocated. - * - * This does not alter main.setting.state.status. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: fss_payload_read_setting_delete(). - * - * @see fss_payload_read_setting_delete() - */ -#ifndef _di_fss_payload_read_setting_unload_ - extern f_status_t fss_payload_read_setting_unload(fss_payload_read_main_t * const main); -#endif // _di_fss_payload_read_setting_unload_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_payload_read_common_h diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c deleted file mode 100644 index f6655bb..0000000 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ /dev/null @@ -1,580 +0,0 @@ -#include "fss_payload_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_read_main_ - f_status_t fss_payload_read_main(fll_program_data_t * const main, fss_payload_read_setting_t * const setting) { - - f_status_t status = F_none; - - setting->state.step_small = fss_payload_read_allocation_console_d; - - status = f_console_parameter_process(arguments, &main->parameters, &setting->state, 0); - - setting->state.step_small = fss_payload_read_allocation_small_d; - - if (F_status_is_error(status)) return; - - { - f_array_length_t choice = 0; - f_uint16s_t choices = f_uint16s_t_initialize; - - // Identify and prioritize "color context" parameters. - { - uint16_t choices_array[3] = { fss_payload_read_parameter_no_color_e, fss_payload_read_parameter_light_e, fss_payload_read_parameter_dark_e }; - choices.array = choices_array; - choices.used = 3; - - const uint8_t modes[3] = { f_color_mode_not_e, f_color_mode_light_e, f_color_mode_dark_e }; - - status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_context", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - - // Identify and pocess first/last parameters. - if (main->parameters.array[fss_payload_read_parameter_line_first_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_payload_read_main_flag_print_first_e; - } - else { - setting->flag |= fss_payload_read_main_flag_print_first_e; - } - - if (main->parameters.array[fss_payload_read_parameter_line_last_no_e].result & f_console_result_found_e) { - setting->flag -= setting->flag & fss_payload_read_main_flag_print_last_e; - } - else { - setting->flag |= fss_payload_read_main_flag_print_last_e; - } - - // Identify and prioritize "verbosity" parameters. - { - uint16_t choices_array[5] = { fss_payload_read_parameter_verbosity_quiet_e, fss_payload_read_parameter_verbosity_error_e, fss_payload_read_parameter_verbosity_verbose_e, fss_payload_read_parameter_verbosity_debug_e, fss_payload_read_parameter_verbosity_normal_e }; - choices.array = choices_array; - choices.used = 5; - - const uint8_t verbosity[5] = { f_console_verbosity_quiet_e, f_console_verbosity_error_e, f_console_verbosity_verbose_e, f_console_verbosity_debug_e, f_console_verbosity_normal_e }; - - status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process_verbosity", fll_error_file_flag_fallback_e); - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_print_dynamic_raw(f_string_eol_s, main->error); - } - - return; - } - } - } - - if (main->parameters.array[fss_payload_read_parameter_help_e].result & f_console_result_found_e) { - fss_payload_read_print_help(setting, main->message); - - return status; - } - - if (main->parameters.array[fss_payload_read_parameter_version_e].result & f_console_result_found_e) { - fll_program_print_version(main->message, fss_payload_read_program_version_s); - - return status; - } - - if (main->parameters.array[fss_payload_read_parameter_copyright_e].result & f_console_result_found_e) { - fll_program_print_copyright(main->message); - - return status; - } - - status = F_none; - - // Provide a range designating where within the buffer a particular file exists, using a statically allocated array. - fss_payload_read_file_t files_array[main->parameters.remaining.used + 1]; - fss_payload_read_data_t data = fss_payload_read_data_t_initialize; - - data.argv = main->parameters.arguments.array; - data.files.array = files_array; - data.files.used = 1; - data.files.size = main->parameters.remaining.used + 1; - data.files.array[0].name = fss_payload_read_pipe_name_s; - data.files.array[0].range.start = 1; - data.files.array[0].range.stop = 0; - - if (main->parameters.remaining.used || (main->pipe & fll_program_data_pipe_input_e)) { - { - const f_array_length_t parameter_code[] = { - fss_payload_read_parameter_at_e, - fss_payload_read_parameter_depth_e, - fss_payload_read_parameter_line_e, - fss_payload_read_parameter_select_e, - fss_payload_read_parameter_name_e, - fss_payload_read_parameter_delimit_e, - }; - - const f_string_static_t parameter_name[] = { - fss_payload_read_long_at_s, - fss_payload_read_long_depth_s, - fss_payload_read_long_line_s, - fss_payload_read_long_select_s, - fss_payload_read_long_name_s, - fss_payload_read_long_delimit_s, - }; - - const f_string_t message_positive_number = "positive number"; - const f_string_t message_string = "string"; - const f_string_t message_value = "value"; - - const f_string_t parameter_message[] = { - message_positive_number, - message_positive_number, - message_positive_number, - message_positive_number, - message_string, - message_value, - }; - - for (f_array_length_t i = 0; i < 6; ++i) { - - if (main->parameters.array[parameter_code[i]].result & f_console_result_found_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, parameter_name[i], main->error.notable); - fl_print_format("%[' requires a %s.%]%r", main->error.to, main->error.context, parameter_message[i], main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_payload_read_parameter_columns_e].result & f_console_result_found_e)) { - const f_array_length_t parameter_code[] = { - fss_payload_read_parameter_depth_e, - fss_payload_read_parameter_line_e, - fss_payload_read_parameter_pipe_e, - fss_payload_read_parameter_select_e, - fss_payload_read_parameter_total_e, - }; - - const f_string_static_t parameter_name[] = { - fss_payload_read_long_depth_s, - fss_payload_read_long_line_s, - fss_payload_read_long_pipe_s, - fss_payload_read_long_select_s, - fss_payload_read_long_total_s, - }; - - const uint8_t parameter_match[] = { - f_console_result_value_e, - f_console_result_value_e, - f_console_result_found_e, - f_console_result_value_e, - f_console_result_found_e, - }; - - for (f_array_length_t i = 0; i < 5; ++i) { - - if (main->parameters.array[parameter_code[i]].result == parameter_match[i]) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_payload_read_long_columns_s, parameter_name[i]); - } - - status = F_status_set_error(F_parameter); - - break; - } - } // for - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_payload_read_parameter_pipe_e].result & f_console_result_found_e)) { - if (main->parameters.array[fss_payload_read_parameter_total_e].result & f_console_result_found_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_payload_read_long_pipe_s, fss_payload_read_long_total_s); - } - - status = F_status_set_error(F_parameter); - } - else if (main->parameters.array[fss_payload_read_parameter_line_e].result & f_console_result_value_e) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - fll_program_print_error_parameter_cannot_use_with(main->error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_payload_read_long_pipe_s, fss_payload_read_long_line_s); - } - - status = F_status_set_error(F_parameter); - } - } - - if (F_status_is_error_not(status) && main->parameters.array[fss_payload_read_parameter_delimit_e].result & f_console_result_value_e) { - f_array_length_t index = 0; - f_array_length_t length = 0; - - // Set the value to 0 to allow for detecting mode based on what is provided. - data.delimit_mode = 0; - - for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_read_parameter_delimit_e].values.used; ++i) { - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - index = main->parameters.array[fss_payload_read_parameter_delimit_e].values.array[i]; - length = data.argv[index].used; - - if (!length) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_payload_read_long_delimit_s, main->error.notable); - fl_print_format("%[' must not be empty.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - status = F_status_set_error(F_parameter); - - break; - } - else if (f_compare_dynamic(data.argv[index], fss_payload_read_delimit_mode_name_none_s) == F_equal_to) { - data.delimit_mode = fss_payload_read_delimit_mode_none_e; - } - else if (f_compare_dynamic(data.argv[index], fss_payload_read_delimit_mode_name_all_s) == F_equal_to) { - data.delimit_mode = fss_payload_read_delimit_mode_all_e; - } - else if (f_compare_dynamic(data.argv[index], fss_payload_read_delimit_mode_name_object_s) == F_equal_to) { - switch (data.delimit_mode) { - case 0: - data.delimit_mode = fss_payload_read_delimit_mode_object_e; - break; - - case fss_payload_read_delimit_mode_none_e: - case fss_payload_read_delimit_mode_all_e: - case fss_payload_read_delimit_mode_content_greater_object_e: - case fss_payload_read_delimit_mode_content_lesser_object_e: - case fss_payload_read_delimit_mode_object_e: - break; - - case fss_payload_read_delimit_mode_content_e: - data.delimit_mode = fss_payload_read_delimit_mode_content_object_e; - break; - - case fss_payload_read_delimit_mode_content_greater_e: - data.delimit_mode = fss_payload_read_delimit_mode_content_greater_object_e; - break; - - case fss_payload_read_delimit_mode_content_lesser_e: - data.delimit_mode = fss_payload_read_delimit_mode_content_lesser_object_e; - break; - - default: - break; - } - } - else { - if (!data.delimit_mode) { - data.delimit_mode = fss_payload_read_delimit_mode_content_e; - } - else if (data.delimit_mode == fss_payload_read_delimit_mode_object_e) { - data.delimit_mode = fss_payload_read_delimit_mode_content_object_e; - } - - if (data.argv[index].string[length - 1] == fss_payload_read_delimit_mode_name_greater_s.string[0]) { - if (!(data.delimit_mode == fss_payload_read_delimit_mode_none_e || data.delimit_mode == fss_payload_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_payload_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_payload_read_delimit_mode_content_greater_object_e; - } - else { - data.delimit_mode = fss_payload_read_delimit_mode_content_greater_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - else if (data.argv[index].string[length - 1] == fss_payload_read_delimit_mode_name_lesser_s.string[0]) { - if (!(data.delimit_mode == fss_payload_read_delimit_mode_none_e || data.delimit_mode == fss_payload_read_delimit_mode_all_e)) { - if (data.delimit_mode == fss_payload_read_delimit_mode_content_object_e) { - data.delimit_mode = fss_payload_read_delimit_mode_content_lesser_object_e; - } - else { - data.delimit_mode = fss_payload_read_delimit_mode_content_lesser_e; - } - } - - // Shorten the length to better convert the remainder to a number. - --length; - } - - f_string_range_t range = macro_f_string_range_t_initialize_2(length); - - // Ignore leading plus sign. - if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { - ++range.start; - } - - status = fl_conversion_dynamic_partial_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], range, &data.delimit_depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_partial_to_unsigned_detect", F_true, fss_payload_read_long_delimit_s, data.argv[index]); - - break; - } - - // There can be nothing smaller than 0, so replace '0-' logic with just '0' logic. - if (data.delimit_mode == fss_payload_read_delimit_mode_content_lesser_e || data.delimit_mode == fss_payload_read_delimit_mode_content_lesser_object_e) { - if (!data.delimit_depth) { - if (data.delimit_mode == fss_payload_read_delimit_mode_content_lesser_e) { - data.delimit_mode = fss_payload_read_delimit_mode_content_e; - } - else { - data.delimit_mode = fss_payload_read_delimit_mode_content_object_e; - } - } - } - } - } // for - - // Guarantee the default value is "all". - if (F_status_is_error_not(status) && !data.delimit_mode) { - data.delimit_mode = fss_payload_read_delimit_mode_all_e; - } - } - - if (F_status_is_error_not(status)) { - status = fss_payload_read_depth_process(main, &data); - } - - // This standard only partially supports nesting, so any depth greater than 1 can be predicted without processing the file. - if (F_status_is_error_not(status)) { - for (f_array_length_t i = 0; i < data.depths.used; ++i) { - - if (data.depths.array[i].depth == 1) { - data.option |= fss_payload_read_data_option_extended_d; - } - - if (data.depth_max < data.depths.array[i].depth) { - data.depth_max = data.depths.array[i].depth; - } - } // for - - if (data.depth_max > 1) { - if (main->parameters.array[fss_payload_read_parameter_total_e].result & f_console_result_found_e) { - fss_payload_read_print_zero(main); - } - - fss_payload_read_data_delete_simple(&data); - - return F_none; - } - } - - if (F_status_is_error_not(status) && (main->parameters.array[fss_payload_read_parameter_select_e].result & f_console_result_found_e)) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_payload_read_long_select_s, main->error.notable); - fl_print_format("%[' parameter requires a positive number.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - - fss_payload_read_depths_resize(0, &data.depths); - - status = F_status_set_error(F_parameter); - } - - if (F_status_is_error_not(status)) { - for (f_array_length_t i = 0; i < data.files.used; ++i) { - macro_f_string_range_t_clear(data.files.array[i].range); - } // for - } - - if (F_status_is_error_not(status) && (main->pipe & fll_program_data_pipe_input_e)) { - f_file_t file = f_file_t_initialize; - - file.id = F_type_descriptor_input_d; - file.stream = F_type_input_d; - - data.files.array[0].range.start = 0; - - status = f_file_stream_read(file, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "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); - } - else if (data.buffer.used) { - data.files.array[0].range.stop = data.buffer.used - 1; - - // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. - // Guarantee that a newline exists at the end of the buffer. - status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_assure", fll_error_file_flag_fallback_e, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); - } - } - else { - data.files.array[0].range.start = 1; - } - } - - if (F_status_is_error_not(status) && main->parameters.remaining.used > 0) { - f_file_t file = f_file_t_initialize; - off_t size_block = 0; - off_t size_file = 0; - off_t size_read = 0; - - for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - main->signal_check = 0; - } - - data.files.array[data.files.used].range.start = data.buffer.used; - file.stream = 0; - file.id = -1; - - status = f_file_stream_open(data.argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); - - break; - } - - size_file = 0; - - status = f_file_size_by_id(file.id, &size_file); - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - if (size_file) { - - // Enforce a max block read size to allow for interrupts to be processed between blocks. - if (size_file > fss_payload_read_block_max) { - file.size_read = fss_payload_read_block_read_large; - size_block = fss_payload_read_block_max; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + (size_block - (size_file % size_block)) + 1, &data.buffer); - } - else { - file.size_read = fss_payload_read_block_read_small; - size_block = size_file; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + 1, &data.buffer); - } - - if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); - - f_file_stream_flush(file); - f_file_stream_close(&file); - - break; - } - - for (size_read = 0; size_read < size_file; size_read += size_block) { - - // The signal check is always performed on each pass. - if (size_file > fss_payload_read_block_max && fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - status = F_status_set_error(F_interrupt); - - break; - } - - status = f_file_stream_read_until(file, size_block, &data.buffer); - if (F_status_is_error(status)) break; - } // for - - f_file_stream_flush(file); - f_file_stream_close(&file); - - if (F_status_is_error(status)) { - if (F_status_set_fine(status) != F_interrupt) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read_until", fll_error_file_flag_fallback_e, data.argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); - } - - break; - } - - if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; - data.files.array[data.files.used++].range.stop = data.buffer.used - 1; - } - } - else { - data.files.array[data.files.used].range.start = 1; - data.files.array[data.files.used].range.stop = 0; - } - } // for - } - - if (F_status_is_error_not(status)) { - status = fss_payload_read_process(main, &data); - } - - fss_payload_read_data_delete_simple(&data); - } - else { - fll_print_format("%r%[%QYou failed to specify one or more files.%]%r", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - status = F_status_set_error(F_parameter); - } - - if (main->error.verbosity > f_console_verbosity_quiet_e) { - if (F_status_set_fine(status) == F_interrupt) { - f_file_stream_flush(main->output.to); - - fll_print_dynamic_raw(f_string_eol_s, main->output.to); - } - } - - fss_payload_read_data_delete_simple(&data); - - return status; - } -#endif // _di_fss_payload_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_read/c/fss_payload_read.h b/level_3/fss_payload_read/c/fss_payload_read.h deleted file mode 100644 index 81ef3a8..0000000 --- a/level_3/fss_payload_read/c/fss_payload_read.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This is the FSS Basic List Read program - * This program utilizes the Featureless Linux Library. - * This program processes files or other input in fss format and stores the results in the fll_program_data_t. - * - * This processes in accordance to the FSS-0002 Basic List specification. - */ -#ifndef _fss_payload_read_h -#define _fss_payload_read_h - -// Libc includes. -#include -#include -#include -#include -#include - -// FLL-0 includes. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// FLL-1 includes. -#include -#include - -// FLL-2 includes. -#include -#include -#include -#include -#include -#include - -// FSS Payload Read includes. -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Execute main program. - * - * If main.signal is non-zero, then this blocks and handles the following signals: - * - F_signal_abort - * - F_signal_broken_pipe - * - F_signal_hangup - * - F_signal_interrupt - * - F_signal_quit - * - F_signal_termination - * - * @param arguments - * The parameters passed to the process. - * @param main - * The main program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - */ -#ifndef _di_fss_payload_read_main_ - extern f_status_t fss_payload_read_main(fll_program_data_t * const main, fss_payload_read_setting_t * const setting); -#endif // _di_fss_payload_read_main_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_payload_read_h diff --git a/level_3/fss_payload_read/c/main.c b/level_3/fss_payload_read/c/main.c deleted file mode 100644 index 9f49f7b..0000000 --- a/level_3/fss_payload_read/c/main.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "fss_payload_read.h" - -int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - - fss_payload_read_main_t data = fss_payload_read_main_t_initialize; - - data.program.debug.flag |= fss_payload_read_print_flag_debug_e | fss_payload_read_print_flag_out_e; - data.program.error.flag |= fss_payload_read_print_flag_error_e | fss_payload_read_print_flag_out_e; - data.program.output.flag |= fss_payload_read_print_flag_out_e; - data.program.message.flag |= fss_payload_read_print_flag_message_e | fss_payload_read_print_flag_out_e; - data.program.warning.flag |= fss_payload_read_print_flag_warning_e | fss_payload_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; - - f_console_parameter_t parameters[] = fss_payload_read_console_parameter_t_initialize; - data.program.parameters.array = parameters; - data.program.parameters.used = fss_payload_read_total_parameters_d; - data.program.environment = envp; - - if (f_pipe_input_exists()) { - data.program.pipe = fll_program_data_pipe_input_e; - } - - fll_program_standard_set_up(&data.program); - - { - const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); - - fss_payload_read_setting_load(arguments, &data); - } - - fss_payload_read_main(&data); - - fss_payload_read_setting_unload(&data); - - fll_program_data_delete(&data.program); - - fll_program_standard_set_down(&data.program); - - return F_status_is_error(data.setting.state.status) ? 1 : 0; -} diff --git a/level_3/fss_payload_read/c/main.h b/level_3/fss_payload_read/c/main.h deleted file mode 100644 index 9d5f9aa..0000000 --- a/level_3/fss_payload_read/c/main.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Payload Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * This file is only ever included by main/main.c and should not normally be included anywhere else. - * Anything that wants to include this should be providing the "fss_payload_read" program functionality in some manner. - */ -#ifndef _fss_payload_read_main_h -#define _fss_payload_read_main_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Standard program entry point. - * - * @param argc - * The number of arguments. - * @param argv - * The array of arguments. - * @param envp - * The array of all environment variables on program start. - * - * @return - * 0 on success. - * 1 on error. - */ -extern int main(const int argc, const f_string_t *argv, const f_string_t *envp); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_payload_read_main_h diff --git a/level_3/fss_payload_read/c/print.c b/level_3/fss_payload_read/c/print.c deleted file mode 100644 index 950a190..0000000 --- a/level_3/fss_payload_read/c/print.c +++ /dev/null @@ -1,126 +0,0 @@ -#include "fss_payload_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_read_print_help_ - f_status_t fss_payload_read_print_help(fss_payload_read_setting_t * const setting, const fl_print_t print) { - - f_file_stream_lock(print.to); - - fll_program_print_help_header(print, fss_payload_read_program_name_long_s, fss_payload_read_program_version_s); - - fll_program_print_help_option_standard(print); - - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_option(print, fss_payload_read_short_at_s, fss_payload_read_long_at_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric index."); - fll_program_print_help_option(print, fss_payload_read_short_content_s, fss_payload_read_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Content (default)."); - fll_program_print_help_option(print, fss_payload_read_short_columns_s, fss_payload_read_long_columns_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of columns."); - fll_program_print_help_option(print, fss_payload_read_short_delimit_s, fss_payload_read_long_delimit_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Designate how to handle applying delimits."); - fll_program_print_help_option(print, fss_payload_read_short_depth_s, fss_payload_read_long_depth_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object at this numeric depth."); - fll_program_print_help_option(print, fss_payload_read_short_empty_s, fss_payload_read_long_empty_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Include empty Content when processing."); - fll_program_print_help_option(print, fss_payload_read_short_line_s, fss_payload_read_long_line_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print only the Content at the given line."); - fll_program_print_help_option(print, fss_payload_read_short_name_s, fss_payload_read_long_name_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select Object with this name."); - fll_program_print_help_option(print, fss_payload_read_short_object_s, fss_payload_read_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the Object."); - fll_program_print_help_option(print, fss_payload_read_short_pipe_s, fss_payload_read_long_pipe_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print using the special pipe format."); - fll_program_print_help_option(print, fss_payload_read_short_original_s, fss_payload_read_long_original_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Print with the original quotes and escapes."); - fll_program_print_help_option(print, fss_payload_read_short_select_s, fss_payload_read_long_select_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Select sub-Content at this index."); - fll_program_print_help_option(print, fss_payload_read_short_total_s, fss_payload_read_long_total_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Print the total number of lines."); - fll_program_print_help_option(print, fss_payload_read_short_trim_s, fss_payload_read_long_trim_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Trim Object names on select or print."); - - f_print_dynamic_raw(f_string_eol_s, print.to); - f_print_dynamic_raw(f_string_eol_s, print.to); - - fll_program_print_help_usage(print, fss_payload_read_program_name_s, fll_program_parameter_filenames_s); - - fl_print_format("%r %[Notes:%]%r", print.to, f_string_eol_s, print.set->important, print.set->important, f_string_eol_s); - - fl_print_format(" This program will print the Content associated with the given Object and Content main based on the FSS-000E Payload standard.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" All numeric positions (indexes) start at 0 instead of 1.%r", print.to, f_string_eol_s); - fl_print_format(" For example, a file of 17 lines would range from 0 to 16.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When using the %[%r%r%] option, an order of operations is enforced on the parameters.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_depth_s, print.set->notable, f_string_eol_s); - - fl_print_format(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%r", print.to, f_string_eol_s); - - fl_print_format(" %[%r%r%]: An Object index at the specified depth.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_at_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: A new depth within the specified depth, indexed from the root.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" %[%r%r%]: An Object name at the specified depth.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] must be in numeric order, but values in between may be skipped.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_depth_s, print.set->notable, f_string_eol_s); - fl_print_format(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%r", print.to, f_string_eol_s); - fl_print_format(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] selects a Content column.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_select_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" Specify both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_object_s, print.set->notable); - fl_print_format(" and the %[%r%r%] parameters to get the total objects.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_total_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When both %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_at_s, print.set->notable); - fl_print_format(" and %[%r%r%] parameters are specified (at the same depth),", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_name_s, print.set->notable); - fl_print_format(" the %[%r%r%] parameter value will be treated as a position relative to the specified", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_at_s, print.set->notable); - fl_print_format(" %[%r%r%] parameter value.%r%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_name_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" This program may support parameters, such as %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_depth_s, print.set->notable); - fl_print_format(" or %[%r%r%], even if not supported by the standard.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_select_s, print.set->notable, f_string_eol_s); - fl_print_format(" This is done to help ensure consistency for scripting.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_depth_s, print.set->notable); - fl_print_format(" if the standard doesn't support nested Content, then only a depth of 0 would be valid.%r", print.to, f_string_eol_s); - - fl_print_format(" For parameters like %[%r%r%],", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_select_s, print.set->notable); - fl_print_format(" if the standard doesn't support multiple Content groups, then only a select of 0 would be valid.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_trim_s, print.set->notable); - fl_print_format(" will remove leading and trailing white spaces when selecting objects or when printing objects.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" When specifying both the %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_object_s, print.set->notable); - fl_print_format(" parameter and the %[%r%r%] parameter, the entire Object and Content are printed, including the formatting.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_content_s, print.set->notable, f_string_eol_s); - fl_print_format(" Both the Object and Content printed are already escaped.%r", print.to, f_string_eol_s); - fl_print_format(" Both the Object and Content are separated by a New Line character '\\n' (U+000A).%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameter %[%r%r%] accepts the following:%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_delimit_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Do not apply delimits.%r", print.to, print.set->notable, fss_payload_read_delimit_mode_name_none_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: (default) Apply all delimits.%r", print.to, print.set->notable, fss_payload_read_delimit_mode_name_all_s, print.set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Apply delimits for Objects.%r", print.to, print.set->notable, fss_payload_read_delimit_mode_name_object_s, print.set->notable, f_string_eol_s); - fl_print_format(" - A number, 0 or greater: apply delimits for Content at the specified depth.%r", print.to, f_string_eol_s); - fl_print_format(" - A number, 0 or greater, followed by a %[%r%]: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%r", print.to, print.set->notable, fss_payload_read_delimit_mode_name_greater_s, print.set->notable, f_string_eol_s, f_string_eol_s); - fl_print_format(" - A number, 0 or lesser, followed by a %[%r%]: (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%r%r", print.to, print.set->notable, fss_payload_read_delimit_mode_name_lesser_s, print.set->notable, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The %[%r%r%] parameter may be specified multiple times to customize the delimit behavior.%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_delimit_s, print.set->notable, f_string_eol_s); - - fl_print_format(" The %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_delimit_s, print.set->notable); - fl_print_format(" values %[%r%]", print.to, print.set->notable, fss_payload_read_delimit_mode_name_none_s, print.set->notable); - fl_print_format(" and %[%r%],", print.to, print.set->notable, fss_payload_read_delimit_mode_name_all_s, print.set->notable); - fl_print_format(" overrule all other delimit values.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The parameters %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_columns_s, print.set->notable); - fl_print_format(" and %[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_select_s, print.set->notable); - fl_print_format(" refer to a Content column.%r", print.to, f_string_eol_s); - fl_print_format(" The word 'column' is being loosely defined to refer to a specific Content.%r", print.to, f_string_eol_s); - fl_print_format(" This is not to be confused with a depth.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" As an exceptional case, a %[%r%r%] of", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_depth_s, print.set->notable); - fl_print_format(" %[1%] applies only to the explicit Object of", print.to, print.set->notable, print.set->notable); - fl_print_format(" '%[%r%]'.%r", print.to, print.set->notable, f_fss_header_s, print.set->notable, f_string_eol_s); - fl_print_format(" Content at this depth is processed as FSS-0001 Extended.%r%r", print.to, f_string_eol_s, f_string_eol_s); - - fl_print_format(" The Content of the explicit Object of", print.to); - fl_print_format(" '%[%r%]'", print.to, print.set->notable, f_fss_payload_s, print.set->notable, f_string_eol_s); - fl_print_format(" will not contain any Content close pipe control codes when using", print.to); - fl_print_format(" %[%r%r%].%r", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_payload_read_long_pipe_s, print.set->notable, f_string_eol_s); - - f_file_stream_flush(print.to); - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fss_payload_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_read/c/print.h b/level_3/fss_payload_read/c/print.h deleted file mode 100644 index 6667a71..0000000 --- a/level_3/fss_payload_read/c/print.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Payload Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _fss_payload_read_print_h -#define _fss_payload_read_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print help. - * - * @param setting - * The main program settings. - * - * This does not alter setting.state.status. - * @param print - * The output structure to print to. - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_print_help_ - extern f_status_t fss_payload_read_print_help(fss_payload_read_setting_t * const setting, const fl_print_t print); -#endif // _di_fss_payload_read_print_help_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_payload_read_print_h diff --git a/level_3/fss_payload_read/c/private-common.c b/level_3/fss_payload_read/c/private-common.c deleted file mode 100644 index d82b1f9..0000000 --- a/level_3/fss_payload_read/c/private-common.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "fss_payload_read.h" -#include "private-common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_read_data_delete_simple_ - void fss_payload_read_data_delete_simple(fss_payload_read_data_t *data) { - - if (!data) return; - - // data->files is expected to be statically loaded and cannot be deallocated. - - fss_payload_read_depths_resize(0, &data->depths); - - f_string_dynamic_resize(0, &data->buffer); - macro_f_fss_contents_t_delete_simple(data->contents); - macro_f_fss_contents_t_delete_simple(data->contents_header); - macro_f_fss_objects_t_delete_simple(data->objects); - macro_f_fss_objects_t_delete_simple(data->objects_header); - macro_f_uint8s_t_delete_simple(data->quotes_object_header); - macro_f_uint8ss_t_delete_simple(data->quotes_content_header); - macro_f_fss_delimits_t_delete_simple(data->delimits_object); - macro_f_fss_delimits_t_delete_simple(data->delimits_object_header); - macro_f_fss_delimits_t_delete_simple(data->delimits_content); - macro_f_fss_delimits_t_delete_simple(data->delimits_content_header); - macro_f_fss_comments_t_delete_simple(data->comments); - } -#endif // _di_fss_payload_read_data_delete_simple_ - -#ifndef _di_fss_payload_read_depth_delete_simple_ - void fss_payload_read_depth_delete_simple(fss_payload_read_depth_t *depth) { - - if (!depth) return; - - f_string_dynamic_resize(0, &depth->value_name); - } -#endif // _di_fss_payload_read_depth_delete_simple_ - -#ifndef _di_fss_payload_read_depths_resize_ - f_status_t fss_payload_read_depths_resize(const f_array_length_t length, fss_payload_read_depths_t *depths) { - - if (!depths) { - return F_status_set_error(F_parameter); - } - - for (f_array_length_t i = length; i < depths->size; ++i) { - fss_payload_read_depth_delete_simple(&depths->array[i]); - } // for - - const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_payload_read_depth_t), (void **) & depths->array); - if (F_status_is_error(status)) return status; - - depths->size = length; - - if (depths->used > depths->size) { - depths->used = length; - } - - return F_none; - } -#endif // _di_fss_payload_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_read/c/private-common.h b/level_3/fss_payload_read/c/private-common.h deleted file mode 100644 index 66d1ccd..0000000 --- a/level_3/fss_payload_read/c/private-common.h +++ /dev/null @@ -1,288 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS Basic List Read - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_common_h -#define _PRIVATE_common_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Provide common/generic definitions. - * - * payload_read_common_allocation_*: - * - large: An allocation step used for buffers that are anticipated to have large buffers. - * - small: An allocation step used for buffers that are anticipated to have small buffers. - * - * fss_payload_read_block_*: - * - max: The max block read size before checking for interrupt. - * - read_small: The block read size for small files. - * - read_large: The block read size for large files. - */ -#ifndef _di_fss_payload_read_common_ - #define fss_payload_read_common_allocation_large_d 2048 - #define fss_payload_read_common_allocation_small_d 128 - - #define fss_payload_read_block_max 16777216 - #define fss_payload_read_block_read_small 8192 - #define fss_payload_read_block_read_large 65536 -#endif // _di_fss_payload_read_common_ - -/** - * A structure of parameters applied at some depth. - * - * depth: The depth number in which this is to be processed at. - * - * index_at: Position of the "--at" parameter value in the argv list, when 0 there is no parameter. - * index_name: Position of the "--name" parameter value in the argv list, when 0 there is no parameter. - * - * value_at: The value of the "--at" parameter, already processed and ready to use, only when index_at > 0. - * value_name: The value of the "--name" parameter, already processed and ready to use, only when index_name > 0. - */ -#ifndef _di_fss_payload_read_depth_t_ - typedef struct { - f_array_length_t depth; - - f_array_length_t index_at; - f_array_length_t index_name; - - f_number_unsigned_t value_at; - f_string_dynamic_t value_name; - } fss_payload_read_depth_t; - - #define fss_payload_read_depth_t_initialize \ - { \ - 0, \ - 0, \ - 0, \ - 0, \ - f_string_dynamic_t_initialize, \ - } - - #define macro_fss_payload_read_depth_t_clear(structure) \ - structure.depth = 0; \ - structure.index_at = 0; \ - structure.index_name = 0; \ - structure.value_at = 0; \ - macro_f_string_dynamic_t_clear(structure.value_name) -#endif // _di_fss_payload_read_depth_t_ - -/** - * An array of depth parameters. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_payload_read_depths_t_ - typedef struct { - fss_payload_read_depth_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_payload_read_depths_t; - - #define fss_payload_read_depths_t_initialize { 0, 0, 0 } - - #define macro_fss_payload_read_depths_t_clear(depths) macro_f_memory_structure_clear(depths) -#endif // _di_fss_payload_read_depths_t_ - -/** - * A structure for designating where within the buffer a particular file exists, using a statically allocated array. - * - * name: The name of the file representing the range. - * range: A range within the buffer representing the file. - */ -#ifndef _di_fss_payload_read_file_t_ - typedef struct { - f_string_static_t name; - f_string_range_t range; - } fss_payload_read_file_t; - - #define fss_payload_read_file_t_initialize \ - { \ - f_string_static_t_initialize, \ - f_string_range_t_initialize, \ - } -#endif // _di_fss_payload_read_file_t_ - -/** - * An array of files. - * - * This is intended to be defined and used statically allocated and as such no dynamic allocation or dynamic deallocation methods are provided. - * - * The STDIN pipe is reserved for index 0 and as such size and used must be initialized to 1. - * - * array: The array of depths. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_fss_payload_read_files_t_ - typedef struct { - fss_payload_read_file_t *array; - - f_array_length_t size; - f_array_length_t used; - } fss_payload_read_files_t; - - #define fss_payload_read_files_t_initialize { 0, 1, 1 } -#endif // _di_fss_payload_read_files_t_ - -/** - * The data structure for FSS Basic Read. - * - * fss_payload_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - extended: Based on the depth, the extended list is to be processed. - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - 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). - * - * argv: The argument structure in the progam data parameters for simplifying syntax. - * options: Bitwise flags representing parameters. - * delimit_mode: The delimit mode. - * delimit_depth: The delimit depth. - * select: The Content to select (column number). - * line: The Content to select (row number). - * files: A statically allocated array of files for designating where in the buffer a file is represented. - * depths: The array of parameters for each given depth. - * buffer: The buffer containing all loaded files (and STDIN pipe). - * objects: The positions within the buffer representing Objects. - * objects_header: The positions within the buffer representing header Objects. - * contents: The positions within the buffer representing Contents. - * contents_header: The positions within the buffer representing header Contents. - * delimits_object: The positions within the buffer representing Object character delimits. - * delimits_object_header: The positions within the buffer representing header Object character delimits. - * delimits_content: The positions within the buffer representing Content character delimits. - * delimits_content_header: The positions within the buffer representing header Content character delimits. - */ -#ifndef _di_fss_payload_read_data_t_ - #define fss_payload_read_data_option_at_d 0x1 - #define fss_payload_read_data_option_columns_d 0x2 - #define fss_payload_read_data_option_content_d 0x4 - #define fss_payload_read_data_option_empty_d 0x8 - #define fss_payload_read_data_option_extended_d 0x10 - #define fss_payload_read_data_option_line_d 0x20 - #define fss_payload_read_data_option_name_d 0x40 - #define fss_payload_read_data_option_object_d 0x80 - #define fss_payload_read_data_option_original_d 0x100 - #define fss_payload_read_data_option_select_d 0x200 - #define fss_payload_read_data_option_total_d 0x400 - #define fss_payload_read_data_option_trim_d 0x800 - - typedef struct { - uint16_t option; - uint8_t delimit_mode; - f_array_length_t depth_max; - f_array_length_t delimit_depth; - f_number_unsigned_t select; - f_number_unsigned_t line; - - f_string_static_t *argv; - - fss_payload_read_files_t files; - fss_payload_read_depths_t depths; - - f_string_dynamic_t buffer; - f_fss_objects_t objects; - f_fss_objects_t objects_header; - f_fss_contents_t contents; - f_fss_contents_t contents_header; - f_uint8s_t quotes_object_header; - f_uint8ss_t quotes_content_header; - f_fss_delimits_t delimits_object; - f_fss_delimits_t delimits_object_header; - f_fss_delimits_t delimits_content; - f_fss_delimits_t delimits_content_header; - f_fss_comments_t comments; - f_uint8s_t quotes; - } fss_payload_read_data_t; - - #define fss_payload_read_data_t_initialize \ - { \ - 0, \ - fss_payload_read_delimit_mode_all_e, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - fss_payload_read_files_t_initialize, \ - fss_payload_read_depths_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_fss_objects_t_initialize, \ - f_fss_objects_t_initialize, \ - f_fss_contents_t_initialize, \ - f_fss_contents_t_initialize, \ - f_uint8s_t_initialize, \ - f_uint8ss_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_fss_delimits_t_initialize, \ - f_uint8s_t_initialize, \ - f_fss_comments_t_initialize, \ - } -#endif // _di_fss_payload_read_data_t_ - -/** - * Fully deallocate all memory for the given data without caring about return status. - * - * @param data - * The data to deallocate. - */ -#ifndef _di_fss_payload_read_data_delete_simple_ - extern void fss_payload_read_data_delete_simple(fss_payload_read_data_t *data) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_data_delete_simple_ - -/** - * Fully deallocate all memory for the given depth without caring about return status. - * - * @param depth - * The depth to deallocate. - */ -#ifndef _di_fss_payload_read_depth_delete_simple_ - extern void fss_payload_read_depth_delete_simple(fss_payload_read_depth_t *depth) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_depth_delete_simple_ - -/** - * Resize the depth array. - * - * @param length - * The new size to use. - * @param depths - * The depth array to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * Errors (with error bit) from: fss_payload_read_depths_increase(). - * - * @see f_memory_resize() - * - * @see fss_payload_read_depth_delete_simple() - * @see fss_payload_read_depths_increase() - */ -#ifndef _di_fss_payload_read_depths_resize_ - extern f_status_t fss_payload_read_depths_resize(const f_array_length_t length, fss_payload_read_depths_t *depths) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_depths_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_common_h diff --git a/level_3/fss_payload_read/c/private-print.c b/level_3/fss_payload_read/c/private-print.c deleted file mode 100644 index adb201e..0000000 --- a/level_3/fss_payload_read/c/private-print.c +++ /dev/null @@ -1,368 +0,0 @@ -#include "fss_payload_read.h" -#include "private-common.h" -#include "private-print.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_read_print_at_ - void fss_payload_read_print_at(fll_program_data_t * const main, const bool is_payload, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_payload_read_data_t * const data) { - - if (at >= data->contents.used) { - return; - } - - if ((data->option & fss_payload_read_data_option_object_d) || (data->option & fss_payload_read_data_option_content_d) && (data->contents.array[at].used || (data->option & fss_payload_read_data_option_empty_d))) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_payload_read_data_option_object_d) { - if (data->option & fss_payload_read_data_option_trim_d) { - fl_print_trim_except_in_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, data->comments, main->output.to); - } - else { - f_print_except_in_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, data->comments, main->output.to); - } - - fss_payload_read_print_object_end(main); - } - - if (data->option & fss_payload_read_data_option_content_d) { - if (data->contents.array[at].used) { - if (!is_payload) { - fss_payload_read_print_content_ignore(main); - } - - if (is_payload) { - f_print_dynamic_partial_raw(data->buffer, data->contents.array[at].array[0], main->output.to); - } - else { - f_print_except_in_dynamic_partial(data->buffer, data->contents.array[at].array[0], delimits_content, data->comments, main->output.to); - } - - if (!is_payload) { - fss_payload_read_print_content_ignore(main); - } - } - } - - if (!is_payload) { - fss_payload_read_print_set_end(main); - } - - f_file_stream_unlock(main->output.to); - } - } -#endif // _di_fss_payload_read_print_at_ - -#ifndef _di_fss_payload_read_print_at_extended_ - void fss_payload_read_print_at_extended(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_payload_read_data_t * const data) { - - if (at >= data->contents_header.used) { - return; - } - - f_file_stream_lock(main->output.to); - - if ((data->option & fss_payload_read_data_option_object_d) || (data->option & fss_payload_read_data_option_content_d) && (data->contents_header.array[at].used || (data->option & fss_payload_read_data_option_empty_d))) { - if (data->option & fss_payload_read_data_option_object_d) { - if (data->option & fss_payload_read_data_option_trim_d) { - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_object_header.array[at]) { - f_print_dynamic_raw( - data->quotes_object_header.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object_header.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - - fl_print_trim_except_dynamic_partial(data->buffer, data->objects_header.array[at], delimits_object, main->output.to); - - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_object_header.array[at]) { - f_print_dynamic_raw( - data->quotes_object_header.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object_header.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - } - else { - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_object_header.array[at]) { - f_print_dynamic_raw( - data->quotes_object_header.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object_header.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - - f_print_except_dynamic_partial(data->buffer, data->objects_header.array[at], delimits_object, main->output.to); - - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_object_header.array[at]) { - f_print_dynamic_raw( - data->quotes_object_header.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object_header.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s, - : f_fss_quote_double_s, - main->output.to - ); - } - } - - if (data->option & fss_payload_read_data_option_content_d) { - fss_payload_read_print_object_end_extended(main); - } - } - - bool content_printed = F_false; - - if ((data->option & fss_payload_read_data_option_content_d) && data->contents_header.array[at].used) { - if (data->option & fss_payload_read_data_option_select_d) { - if (data->select < data->contents_header.array[at].used) { - content_printed = F_true; - - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_content_header.array[at].array[data->select]) { - f_print_dynamic_raw( - data->quotes_content_header.array[at].array[data->select] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content_header.array[at].array[data->select] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - - f_print_except_dynamic_partial(data->buffer, data->contents_header.array[at].array[data->select], delimits_content, main->output.to); - - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_content_header.array[at].array[data->select]) { - f_print_dynamic_raw( - data->quotes_content_header.array[at].array[data->select] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content_header.array[at].array[data->select] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - } - } - else { - for (f_array_length_t i = 0; i < data->contents_header.array[at].used; ++i) { - - if (data->contents_header.array[at].array[i].start > data->contents_header.array[at].array[i].stop) { - continue; - } - - content_printed = F_true; - - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_content_header.array[at].array[i]) { - f_print_dynamic_raw( - data->quotes_content_header.array[at].array[i] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content_header.array[at].array[i] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - - f_print_except_dynamic_partial(data->buffer, data->contents_header.array[at].array[i], delimits_content, main->output.to); - - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_content_header.array[at].array[i]) { - f_print_dynamic_raw( - data->quotes_content_header.array[at].array[i] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content_header.array[at].array[i] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - - if (i + 1 < data->contents_header.array[at].used && data->contents_header.array[at].array[i + 1].start <= data->contents_header.array[at].array[i + 1].stop) { - fss_payload_read_print_content_end_extended(main); - } - } // for - } - } - - if ((data->option & fss_payload_read_data_option_object_d) || (data->option & fss_payload_read_data_option_content_d) && (content_printed || (data->option & fss_payload_read_data_option_empty_d))) { - fss_payload_read_print_set_end_extended(main); - } - - f_file_stream_unlock(main->output.to); - } - } -#endif // _di_fss_payload_read_print_at_extended_ - -#ifndef _di_fss_payload_read_print_at_object_ - void fss_payload_read_print_at_object(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t at, const f_fss_delimits_t delimits_object) { - - if (at >= data->objects.used) { - return; - } - - if (data->option & fss_payload_read_data_option_trim_d) { - fl_print_trim_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - else { - f_print_except_dynamic_partial(data->buffer, data->objects.array[at], delimits_object, main->output.to); - } - - fss_payload_read_print_object_end(main); - } -#endif // _di_fss_payload_read_print_at_object_ - -#ifndef _di_fss_payload_read_print_at_total_exteded_ - f_status_t fss_payload_read_print_at_total_extended(fll_program_data_t * const main, const f_array_length_t at, fss_payload_read_data_t *data) { - - if (data->option & fss_payload_read_data_option_select_d) { - if (data->option & fss_payload_read_data_option_object_d) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_one(main); - - f_file_stream_unlock(main->output.to); - - return F_success; - } - - if (data->select < data->contents_header.array[at].used) { - if (data->contents_header.array[at].array[data->select].start <= data->contents_header.array[at].array[data->select].stop || (data->option & fss_payload_read_data_option_empty_d)) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_one(main); - - f_file_stream_unlock(main->output.to); - - return F_success; - } - } - } - else if ((data->option & fss_payload_read_data_option_object_d) || (data->option & fss_payload_read_data_option_empty_d)) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_one(main); - - f_file_stream_unlock(main->output.to); - - return F_success; - } - else if (data->contents_header.array[at].used) { - for (f_array_length_t j = 0; j < data->contents_header.array[at].used; ++j) { - - if (data->contents_header.array[at].array[j].start <= data->contents_header.array[at].array[j].stop) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_one(main); - - f_file_stream_unlock(main->output.to); - - return F_success; - } - } // for - } - - return F_none; - } -#endif // _di_fss_payload_read_print_at_total_extended_ - -#ifndef _di_fss_payload_read_print_content_end_extended_ - void fss_payload_read_print_content_end_extended(fll_program_data_t * const main) { - - if (main->parameters.array[fss_payload_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_payload_read_pipe_content_start_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_space_s, main->output.to); - } - } -#endif // _di_fss_payload_read_print_content_end_extended_ - -#ifndef _di_fss_payload_read_print_content_ignore_ - void fss_payload_read_print_content_ignore(fll_program_data_t * const main) { - - if (main->parameters.array[fss_payload_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_payload_read_pipe_content_ignore_s, main->output.to); - } - } -#endif // _di_fss_payload_read_print_content_ignore_ - -#ifndef _di_fss_payload_read_print_object_end_ - void fss_payload_read_print_object_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_payload_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_payload_read_pipe_content_start_s, main->output.to); - } - else { - if (main->parameters.array[fss_payload_read_parameter_content_e].result & f_console_result_found_e) { - f_print_dynamic_raw(f_fss_basic_list_open_s, main->output.to); - f_print_dynamic_raw(f_fss_basic_list_open_end_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_eol_s, main->output.to); - } - } - } -#endif // _di_fss_payload_read_print_object_end_ - -#ifndef _di_fss_payload_read_print_object_end_extended_ - void fss_payload_read_print_object_end_extended(fll_program_data_t * const main) { - - if (main->parameters.array[fss_payload_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_payload_read_pipe_content_end_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_space_s, main->output.to); - } - } -#endif // _di_fss_payload_read_print_object_end_extended_ - -#ifndef _di_fss_payload_read_print_set_end_ - void fss_payload_read_print_set_end(fll_program_data_t * const main) { - - if (main->parameters.array[fss_payload_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_payload_read_pipe_content_end_s, main->output.to); - } - } -#endif // _di_fss_payload_read_print_set_end_ - -#ifndef _di_fss_payload_read_print_set_end_extended_ - void fss_payload_read_print_set_end_extended(fll_program_data_t * const main) { - - if (main->parameters.array[fss_payload_read_parameter_pipe_e].result & f_console_result_found_e) { - f_print_dynamic_raw(fss_payload_read_pipe_content_end_s, main->output.to); - } - else { - f_print_dynamic_raw(f_fss_eol_s, main->output.to); - } - } -#endif // _di_fss_payload_read_print_set_end_extended_ - -#ifndef _di_fss_payload_read_print_one_ - void fss_payload_read_print_one(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_1_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_payload_read_print_one_ - -#ifndef _di_fss_payload_read_print_zero_ - void fss_payload_read_print_zero(fll_program_data_t * const main) { - - f_print_dynamic_raw(f_string_ascii_0_s, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } -#endif // _di_fss_payload_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_read/c/private-print.h b/level_3/fss_payload_read/c/private-print.h deleted file mode 100644 index efc222d..0000000 --- a/level_3/fss_payload_read/c/private-print.h +++ /dev/null @@ -1,177 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_print_h -#define _PRIVATE_print_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Print the Object and Content at the given position. - * - * Only what is requested to print (Object, Content, both, or neither) will be printed, if there is something to print. - * - * @param main - * The main program data. - * @param is_payload - * If TRUE, then this is associated with a "payload" Object. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param data - * The program data. - */ -#ifndef _di_fss_payload_read_print_at_ - extern void fss_payload_read_print_at(fll_program_data_t * const main, const bool is_payload, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_at_ - -/** - * Print the Object and Content at the given position for the FSS-0001 Extended Content at depth 1. - * - * Only what is requested to print (Object, Content, both, or neither) will be printed, if there is something to print. - * - * @param main - * The main program data. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param data - * The program data. - */ -#ifndef _di_fss_payload_read_print_at_extended_ - extern void fss_payload_read_print_at_extended(fll_program_data_t * const main, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_at_extended_ - -/** - * Explicitly print the Object at the given position. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param at - * The index in the Objects and Contents to print. - * @param delimits_object - * The delimits to be applied to an Object. - */ -#ifndef _di_fss_payload_read_print_at_object_ - extern void fss_payload_read_print_at_object(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t at, const f_fss_delimits_t delimits_object) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_at_object_ - -/** - * Print total count at the specified Object/Content position for the FSS-0001 Extended Content at depth 1. - * - * @param main - * The main program data. - * @param at - * The Object/Content position. - * @param data - * The program data. - * - * @return - * F_none on success but nothig was matched (and total was printed). - * F_success on success and something was matched (and total was printed). - */ -#ifndef _di_fss_payload_read_print_at_total_extended_ - extern f_status_t fss_payload_read_print_at_total_extended(fll_program_data_t * const main, const f_array_length_t at, fss_payload_read_data_t *data) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_at_total_extended_ - -/** - * Print the end of a Content for the FSS-0001 Extended Content at depth 1. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_payload_read_print_content_end_extended_ - extern void fss_payload_read_print_content_end_extended(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_content_end_extended_ - -/** - * Print the ignore character for Content. - * - * This is only used in pipe output mode. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_payload_read_print_content_ignore_ - extern void fss_payload_read_print_content_ignore(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_content_ignore_ - -/** - * Print the end of an Object (which is essentially the start of Content). - * - * @param main - * The main program data. - */ -#ifndef _di_fss_payload_read_print_object_end_ - extern void fss_payload_read_print_object_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_object_end_ - -/** - * Print the end of an Object (which is essentially the start of Content) for the FSS-0001 Extended Content at depth 1. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_payload_read_print_object_end_extended_ - extern void fss_payload_read_print_object_end_extended(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_object_end_extended_ - -/** - * Print the number one and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_payload_read_print_one_ - extern void fss_payload_read_print_one(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_one_ - -/** - * Print the end of an Object/Content set. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_payload_read_print_set_end_ - extern void fss_payload_read_print_set_end(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_set_end_ - -/** - * Print the end of an Object/Content set for the FSS-0001 Extended Content at depth 1. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_payload_read_print_set_end_extended_ - extern void fss_payload_read_print_set_end_extended(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_set_end_extended_ - -/** - * Print the number zero and a newline. - * - * @param main - * The main program data. - */ -#ifndef _di_fss_payload_read_print_zero_ - extern void fss_payload_read_print_zero(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_print_zero_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_print_h diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c deleted file mode 100644 index 14d0888..0000000 --- a/level_3/fss_payload_read/c/private-read.c +++ /dev/null @@ -1,1213 +0,0 @@ -#include "fss_payload_read.h" -#include "private-common.h" -#include "private-print.h" -#include "private-read.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_fss_payload_read_delimit_content_is_ - f_status_t fss_payload_read_delimit_content_is(fss_payload_read_data_t * const data, const f_array_length_t depth) { - - if (data->delimit_mode == fss_payload_read_delimit_mode_none_e) { - return F_false; - } - - if (data->delimit_mode == fss_payload_read_delimit_mode_all_e) { - return F_true; - } - - if (depth < data->delimit_depth) { - return data->delimit_mode == fss_payload_read_delimit_mode_content_lesser_e; - } - - if (depth == data->delimit_depth) { - return F_true; - } - - return data->delimit_mode == fss_payload_read_delimit_mode_content_greater_e; - } -#endif // _di_fss_payload_read_delimit_content_is_ - -#ifndef _di_fss_payload_read_delimit_object_is_ - f_status_t fss_payload_read_delimit_object_is(fss_payload_read_data_t * const data, const f_array_length_t depth) { - - switch (data->delimit_mode) { - case fss_payload_read_delimit_mode_none_e: - case fss_payload_read_delimit_mode_content_e: - case fss_payload_read_delimit_mode_content_greater_e: - case fss_payload_read_delimit_mode_content_lesser_e: - return F_false; - - case fss_payload_read_delimit_mode_all_e: - case fss_payload_read_delimit_mode_content_object_e: - case fss_payload_read_delimit_mode_content_greater_object_e: - case fss_payload_read_delimit_mode_content_lesser_object_e: - case fss_payload_read_delimit_mode_object_e: - return F_true; - - default: - break; - } - - return depth == data->delimit_depth || data->delimit_mode == fss_payload_read_delimit_mode_content_lesser_e; - } -#endif // _di_fss_payload_read_delimit_object_is_ - -#ifndef _di_fss_payload_read_depth_process_ - f_status_t fss_payload_read_depth_process(fll_program_data_t * const main, fss_payload_read_data_t * const data) { - - f_status_t status = F_none; - - { - f_array_length_t depth_size = 1; - - if (main->parameters.array[fss_payload_read_parameter_depth_e].result & f_console_result_value_e) { - depth_size = main->parameters.array[fss_payload_read_parameter_depth_e].values.used; - } - - if (depth_size > data->depths.size) { - status = fss_payload_read_depths_resize(depth_size, &data->depths); - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fss_payload_read_depths_resize", fll_error_file_flag_fallback_e); - - return status; - } - } - - data->depths.used = depth_size; - } - - f_array_length_t position_depth = 0; - f_array_length_t position_at = 0; - f_array_length_t position_name = 0; - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - data->depths.array[i].depth = 0; - data->depths.array[i].index_at = 0; - data->depths.array[i].index_name = 0; - data->depths.array[i].value_at = 0; - - macro_f_string_dynamic_t_clear(data->depths.array[i].value_name); - - if (!main->parameters.array[fss_payload_read_parameter_depth_e].values.used) { - position_depth = 0; - } - else { - position_depth = main->parameters.array[fss_payload_read_parameter_depth_e].values.array[i]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[position_depth], &data->depths.array[i].depth); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_payload_read_long_depth_s, data->argv[position_depth]); - - return status; - } - } - - if (main->parameters.array[fss_payload_read_parameter_at_e].result & f_console_result_value_e) { - for (; position_at < main->parameters.array[fss_payload_read_parameter_at_e].values.used; ++position_at) { - - if (main->parameters.array[fss_payload_read_parameter_at_e].values.array[position_at] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_payload_read_parameter_at_e].values.array[position_at] > main->parameters.array[fss_payload_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_at = main->parameters.array[fss_payload_read_parameter_at_e].values.array[position_at]; - - status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[data->depths.array[i].index_at], &data->depths.array[i].value_at); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, fss_payload_read_long_at_s, data->argv[data->depths.array[i].index_at]); - - return status; - } - } // for - } - - if (main->parameters.array[fss_payload_read_parameter_name_e].result & f_console_result_value_e) { - for (; position_name < main->parameters.array[fss_payload_read_parameter_name_e].values.used; ++position_name) { - - if (main->parameters.array[fss_payload_read_parameter_name_e].values.array[position_name] < position_depth) { - continue; - } - - if (i + 1 < data->depths.used && main->parameters.array[fss_payload_read_parameter_name_e].values.array[position_name] > main->parameters.array[fss_payload_read_parameter_depth_e].values.array[i + 1]) { - break; - } - - data->depths.array[i].index_name = main->parameters.array[fss_payload_read_parameter_name_e].values.array[position_name]; - - if (main->parameters.array[fss_payload_read_parameter_trim_e].result & f_console_result_found_e) { - status = f_rip_dynamic(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - else { - status = f_string_dynamic_append(data->argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); - } - - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), (main->parameters.array[fss_payload_read_parameter_trim_e].result & f_console_result_found_e) ? "f_rip_dynamic" : "f_string_dynamic_append", fll_error_file_flag_fallback_e); - - return status; - } - } // for - } - } // for - - for (f_array_length_t i = 0; i < data->depths.used; ++i) { - - for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->depths.array[i].depth == data->depths.array[j].depth) { - if (main->error.verbosity < f_console_verbosity_normal_e) { - fll_program_print_error_parameter_must_specify_once_value(main->error, f_console_symbol_long_normal_s, fss_payload_read_long_depth_s, data->depths.array[i].depth); - } - - return F_status_set_error(F_parameter); - } - else if (data->depths.array[i].depth > data->depths.array[j].depth) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe parameter '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to, main->error.notable, f_console_symbol_long_normal_s, fss_payload_read_long_depth_s, main->error.notable); - fl_print_format("%[' may not have the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[i].depth, main->error.notable); - fl_print_format("%[' before the value '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%ul%]", main->error.to, main->error.notable, data->depths.array[j].depth, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - - return F_status_set_error(F_parameter); - } - } // for - } // for - - return F_none; - } -#endif // _di_fss_payload_read_depth_process_ - -#ifndef _di_fss_payload_read_file_identify_ - f_string_static_t fss_payload_read_file_identify(const f_array_length_t at, const fss_payload_read_files_t files) { - - for (f_array_length_t i = 0; i < files.used; ++i) { - - if (at >= files.array[i].range.start && at <= files.array[i].range.stop) { - return files.array[i].name; - } - } // for - - // When stopped after the end of the buffer, the last file in the list is the correct file. - if (at > files.array[files.used - 1].range.stop) { - return files.array[files.used - 1].name; - } - - return f_string_empty_s; - } -#endif // _di_fss_payload_read_file_identify_ - -#ifndef _di_fss_payload_read_load_ - f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t * const data) { - - f_state_t state = macro_f_state_t_initialize_1(fss_payload_read_common_allocation_large_d, fss_payload_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); - f_string_range_t input = macro_f_string_range_t_initialize_2(data->buffer.used); - - data->delimits_object.used = 0; - data->delimits_content.used = 0; - - f_status_t status = fll_fss_payload_read(data->buffer, state, &input, &data->objects, &data->contents, &data->delimits_object, &data->delimits_content, &data->comments); - - if (F_status_is_error(status)) { - const f_string_static_t file_name = fss_payload_read_file_identify(input.start, data->files); - - if (F_status_set_fine(status) == F_none || F_status_set_fine(status) == F_none_eos || F_status_set_fine(status) == F_none_stop || F_status_set_fine(status) == F_data_not_eos || F_status_set_fine(status) == F_data_not_stop) { - if (main->error.verbosity > f_console_verbosity_quiet_e) { - f_file_stream_lock(main->error.to); - - fl_print_format("%r%[%QThe file '%]", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%]", main->error.to, main->error.notable, file_name, main->error.notable); - fl_print_format("%[' does not have the required Object '%]", main->error.to, main->error.context, main->error.context); - fl_print_format("%[%r%]", main->error.to, main->error.notable, f_fss_payload_s, main->error.notable); - fl_print_format("%['.%]%r", main->error.to, main->error.context, main->error.context, f_string_eol_s); - - f_file_stream_unlock(main->error.to); - } - } - else { - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_payload_read", fll_error_file_flag_fallback_e, file_name, f_file_operation_process_s, fll_error_file_type_file_e); - } - - return status; - } - - if (status == F_data_not_stop || status == F_data_not_eos) { - if (data->option & fss_payload_read_data_option_total_d) return F_none; - - return F_status_set_warning(status); - } - - // Load the "header" information. - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_string(F_fss_header_s, data->buffer, F_fss_string_header_s_length, data->objects.array[i]) == F_equal_to) { - f_string_range_t input_header = data->contents.array[i].array[0]; - - status = fll_fss_extended_read(data->buffer, state, &input_header, &data->objects_header, &data->contents_header, &data->quotes_object_header, &data->quotes_content_header, &data->delimits_object_header, &data->delimits_content_header); - - if (F_status_is_error(status)) { - const f_string_static_t file_name = fss_payload_read_file_identify(input.start, data->files); - - fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_extended_read", fll_error_file_flag_fallback_e, file_name, f_file_operation_process_s, fll_error_file_type_file_e); - - return status; - } - } - } // for - - return F_none; - } -#endif // _di_fss_payload_read_load_ - -#ifndef _di_fss_payload_read_load_number_ - f_status_t fss_payload_read_load_number(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { - - if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - - const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); - - if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_unsigned_detect", F_true, name, data->argv[index]); - - return status; - } - - return F_true; - } - - return F_false; - } -#endif // _di_fss_payload_read_load_number_ - -#ifndef _di_fss_payload_read_process_ - f_status_t fss_payload_read_process(fll_program_data_t * const main, fss_payload_read_data_t * const data) { - - f_status_t status = fss_payload_read_process_option(main, data); - if (F_status_is_error(status)) return status; - - // This standard does not support multiple content groups, except for "headers" FSS-0001 Extended at depth 1. - if (!(data->option & fss_payload_read_data_option_extended_d)) { - if ((data->option & fss_payload_read_data_option_select_d) && data->select) { - if (main->parameters.array[fss_payload_read_parameter_total_e].result & f_console_result_found_e) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - } - - status = fss_payload_read_load(main, data); - if (F_status_is_error(status)) return status; - - bool names[data->objects.used]; - - status = fss_payload_read_process_name(data, names); - if (F_status_is_error(status)) return status; - - if (data->option & fss_payload_read_data_option_extended_d) { - - // For "headers" FSS-0001 Extended, only operate if the "header" name is true. - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_string(F_fss_header_s, data->buffer, F_fss_string_header_s_length, data->objects.array[i]) == F_equal_to) { - if (names[i]) break; - - if (main->parameters.array[fss_payload_read_parameter_total_e].result & f_console_result_found_e) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - } // for - - bool names_header[data->objects_header.used]; - - status = fss_payload_read_process_name_extended(data, names_header); - if (F_status_is_error(status)) return status; - - if (data->depths.array[data->depths.used - 1].index_at) { - return fss_payload_read_process_at_extended(main, data, names_header); - } - - if (data->option & fss_payload_read_data_option_columns_d) { - return fss_payload_read_process_columns_extended(main, data, names_header); - } - - if (data->option & fss_payload_read_data_option_total_d) { - return fss_payload_read_process_total_extended(main, data, names_header); - } - - if (data->option & fss_payload_read_data_option_line_d) { - return fss_payload_read_process_line_extended(main, data, names_header); - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object_header : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, (data->option & fss_payload_read_data_option_select_d) ? data->select : 0) ? &data->delimits_content_header : &except_none; - - if (data->option & fss_payload_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names_header[i]) continue; - - fss_payload_read_print_at_extended(main, i, *delimits_object, *delimits_content, data); - } // for - - return F_none; - } - - if (data->depths.array[0].index_at) { - return fss_payload_read_process_at(main, data, names); - } - - if (data->option & fss_payload_read_data_option_columns_d) { - return fss_payload_read_process_columns(main, data, names); - } - - if (data->option & fss_payload_read_data_option_total_d) { - return fss_payload_read_process_total(main, data, names); - } - - if (data->option & fss_payload_read_data_option_line_d) { - return fss_payload_read_process_line(main, data, names); - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - bool is_payload = F_false; - - if (data->option & fss_payload_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - is_payload = f_compare_dynamic_partial_string(f_fss_payload_s.string, data->buffer, f_fss_payload_s.used, data->objects.array[i]) == F_equal_to; - - fss_payload_read_print_at(main, is_payload, i, *delimits_object, *delimits_content, data); - } // for - - return F_none; - } -#endif // _di_fss_payload_read_process_ - -#ifndef _di_fss_payload_read_process_at_ - f_status_t fss_payload_read_process_at(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { - - if (data->depths.array[0].value_at >= data->objects.used) { - if (data->option & (fss_payload_read_data_option_columns_d | fss_payload_read_data_option_total_d)) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - - if (data->option & fss_payload_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t at = 0; - f_status_t status = F_none; - bool is_payload = F_false; - - for (f_array_length_t i = 0; i < data->objects.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (at == data->depths.array[0].value_at) { - if (data->option & fss_payload_read_data_option_line_d) { - f_array_length_t line = 0; - - status = fss_payload_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); - if (status == F_success) return F_none; - } - else if (data->option & fss_payload_read_data_option_columns_d) { - fll_print_format("%ul%r", main->output.to, data->contents.array[i].used, f_string_eol_s); - } - else if (data->option & fss_payload_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - if (data->contents.array[i].used) { - fss_payload_read_print_one(main); - } - else { - fss_payload_read_print_zero(main); - } - - f_file_stream_unlock(main->output.to); - } - else { - is_payload = f_compare_dynamic_partial_string(f_fss_payload_s.string, data->buffer, f_fss_payload_s.used, data->objects.array[i]) == F_equal_to; - - fss_payload_read_print_at(main, is_payload, i, *delimits_object, *delimits_content, data); - } - - return F_none; - } - - ++at; - } // for - - if (data->option & fss_payload_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } -#endif // _di_fss_payload_read_process_at_ - -#ifndef _di_fss_payload_read_process_at_extended_ - f_status_t fss_payload_read_process_at_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { - - if (data->depths.array[data->depths.used - 1].value_at >= data->objects_header.used) { - if (data->option & (fss_payload_read_data_option_columns_d | fss_payload_read_data_option_total_d)) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - - // This standard only has one line per Content; therefore, any line value greater than 0 equates to no line to print. - if (data->option & fss_payload_read_data_option_line_d) { - if (data->line) { - if (data->option & fss_payload_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } - } - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object_header : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, (data->option & fss_payload_read_data_option_select_d) ? data->select : 0) ? &data->delimits_content_header : &except_none; - - if (data->option & fss_payload_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t at = 0; - - for (f_array_length_t i = 0; i < data->objects_header.used; ++i) { - - if (!names[i]) continue; - - if (at == data->depths.array[data->depths.used - 1].value_at) { - if (data->option & fss_payload_read_data_option_line_d) { - - // This standard only supports one line per Object so when using "--at", the only valid line is line 0. - if (data->line) break; - - if (data->option & fss_payload_read_data_option_total_d) { - if (fss_payload_read_print_at_total_extended(main, i, data) == F_none) { - break; - } - } - else { - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_object_header.array[at]) { - f_print_dynamic_raw( - data->quotes_object_header.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object_header.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - - fss_payload_read_print_at_extended(main, i, *delimits_object, *delimits_content, data); - - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_object_header.array[at]) { - f_print_dynamic_raw( - data->quotes_object_header.array[at] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_object_header.array[at] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - } - } - else if (data->option & fss_payload_read_data_option_columns_d) { - fll_print_format("%ul%r", main->output.to, data->contents_header.array[i].used, f_string_eol_s); - } - else if (data->option & fss_payload_read_data_option_total_d) { - if (fss_payload_read_print_at_total_extended(main, i, data) == F_none) { - break; - } - } - else { - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_content_header.array[at].array[i]) { - f_print_dynamic_raw( - data->quotes_content_header.array[at].array[i] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content_header.array[at].array[i] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - - fss_payload_read_print_at_extended(main, i, *delimits_object, *delimits_content, data); - - if ((data->option & fss_payload_read_data_option_original_d) && data->quotes_content_header.array[at].array[i]) { - f_print_dynamic_raw( - data->quotes_content_header.array[at].array[i] == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : data->quotes_content_header.array[at].array[i] == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - main->output.to - ); - } - } - - return F_none; - } - - ++at; - } // for - - if (data->option & fss_payload_read_data_option_total_d) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - } - - return F_none; - } -#endif // _di_fss_payload_read_process_at_extended_ - -#ifndef _di_fss_payload_read_process_at_line_ - f_status_t fss_payload_read_process_at_line(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) { - - if (data->option & fss_payload_read_data_option_object_d) { - if (*line == data->line) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_payload_read_data_option_total_d) { - fss_payload_read_print_one(main); - } - else { - fss_payload_read_print_at_object(main, data, at, delimits_object); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - - ++(*line); - } - - // There is only a single Content column for this standard. - if (data->option & fss_payload_read_data_option_content_d) { - if (!data->contents.array[at].used) { - return F_none; - } - - f_string_range_t range = f_string_range_t_initialize; - f_array_length_t i = 0; - - range.start = data->contents.array[at].array[0].start; - range.stop = data->contents.array[at].array[0].stop; - - // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - return F_none; - } - - for (i = range.start; i <= range.stop; ++i) { - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - if (*line == data->line) { - range.stop = i; - - f_file_stream_lock(main->output.to); - - if (data->option & fss_payload_read_data_option_total_d) { - fss_payload_read_print_one(main); - } - else { - f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - - range.start = i + 1; - - if (i <= range.stop) { - ++(*line); - } - } - } // for - - // If Content does not end with a newline, it still must be treated as the last line. - if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { - ++(*line); - - if (*line == data->line) { - f_file_stream_lock(main->output.to); - - if (data->option & fss_payload_read_data_option_total_d) { - fss_payload_read_print_one(main); - } - else { - range.stop = data->contents.array[at].array[0].stop; - - f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to); - f_print_dynamic_raw(f_string_eol_s, main->output.to); - } - - f_file_stream_unlock(main->output.to); - - return F_success; - } - } - } - - return F_none; - } -#endif // _di_fss_payload_read_process_at_line_ - -#ifndef _di_fss_payload_read_process_columns_ - f_status_t fss_payload_read_process_columns(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { - - if (!(data->option & fss_payload_read_data_option_content_d)) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - - return F_none; - } - - f_array_length_t max = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->contents.array[at].used > max) { - max = data->contents.array[at].used; - } - } // for - - fll_print_format("%ul%r", main->output.to, max, f_string_eol_s); - - return F_none; - } -#endif // _di_fss_payload_read_process_columns_ - -#ifndef _di_fss_payload_read_process_columns_extended_ - f_status_t fss_payload_read_process_columns_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { - - if (!(data->option & fss_payload_read_data_option_content_d)) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_zero(main); - - f_file_stream_unlock(main->output.to); - - return F_none; - } - - f_array_length_t max = 0; - - for (f_array_length_t at = 0; at < data->contents_header.used; ++at) { - - if (!names[at]) continue; - - if (data->contents_header.array[at].used > max) { - max = data->contents_header.array[at].used; - } - } // for - - fll_print_format("%ul%r", main->output.to, max, f_string_eol_s); - - return F_none; - } -#endif // _di_fss_payload_read_process_columns_extended_ - -#ifndef _di_fss_payload_read_process_line_ - f_status_t fss_payload_read_process_line(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - - if (data->option & fss_payload_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t line = 0; - f_status_t status = F_none; - - for (f_array_length_t i = 0; i < data->contents.used; ++i) { - - if (!names[i]) continue; - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - status = fss_payload_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); - if (status == F_success) break; - } // for - - return F_none; - } -#endif // _di_fss_payload_read_process_line_ - -#ifndef _di_fss_payload_read_process_line_extended_ - f_status_t fss_payload_read_process_line_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object_header : &except_none; - f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, (data->option & fss_payload_read_data_option_select_d) ? data->select : 0) ? &data->delimits_content_header : &except_none; - - if (data->option & fss_payload_read_data_option_original_d) { - delimits_object = &except_none; - delimits_content = &except_none; - } - - f_array_length_t line = 0; - - for (f_array_length_t i = 0; i < data->contents_header.used; ++i) { - - if (!names[i]) continue; - - if (!(data->option & fss_payload_read_data_option_object_d) && (data->option & fss_payload_read_data_option_content_d)) { - if (!data->contents_header.array[i].used) { - if (data->option & fss_payload_read_data_option_empty_d) { - if (line == data->line) { - f_file_stream_lock(main->output.to); - - fss_payload_read_print_set_end_extended(main); - - f_file_stream_unlock(main->output.to); - - break; - } - - ++line; - } - - continue; - } - } - - if (line == data->line) { - fss_payload_read_print_at_extended(main, i, *delimits_object, *delimits_content, data); - - break; - } - - ++line; - } // for - - return F_none; - } -#endif // _di_fss_payload_read_process_line_extended_ - -#ifndef _di_fss_payload_read_process_name_ - f_status_t fss_payload_read_process_name(fss_payload_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - - if (data->depths.array[0].index_name) { - f_array_length_t i = 0; - - memset(names, F_false, sizeof(bool) * data->objects.used); - - // This standard should always treat selected names as trimmed. - for (i = 0; i < data->objects.used; ++i) { - - if (f_compare_dynamic_partial_except_trim_dynamic(data->depths.array[0].value_name, data->buffer, data->objects.array[i], except_none, data->delimits_object) == F_equal_to) { - names[i] = F_true; - } - } // for - } - else { - memset(names, F_true, sizeof(bool) * data->objects.used); - } - - return F_none; - } -#endif // _di_fss_payload_read_process_name_ - -#ifndef _di_fss_payload_read_process_name_extended_ - f_status_t fss_payload_read_process_name_extended(fss_payload_read_data_t * const data, bool names[]) { - - f_array_lengths_t except_none = f_array_lengths_t_initialize; - - if (data->depths.array[data->depths.used - 1].index_name) { - f_array_length_t i = 0; - - memset(names, F_false, sizeof(bool) * data->objects_header.used); - - if (data->option & fss_payload_read_data_option_trim_d) { - for (i = 0; i < data->objects_header.used; ++i) { - - if (f_compare_dynamic_partial_except_trim_dynamic(data->depths.array[data->depths.used - 1].value_name, data->buffer, data->objects_header.array[i], except_none, data->delimits_object_header) == F_equal_to) { - names[i] = F_true; - } - } // for - } - else { - for (i = 0; i < data->objects_header.used; ++i) { - - if (f_compare_dynamic_partial_except_dynamic(data->depths.array[data->depths.used - 1].value_name, data->buffer, data->objects_header.array[i], except_none, data->delimits_content_header) == F_equal_to) { - names[i] = F_true; - } - } // for - } - } - else { - memset(names, F_true, sizeof(bool) * data->objects_header.used); - } - - return F_none; - } -#endif // _di_fss_payload_read_process_name_extended_ - -#ifndef _di_fss_payload_read_process_option_ - f_status_t fss_payload_read_process_option(fll_program_data_t * const main, fss_payload_read_data_t * const data) { - - f_status_t status = F_none; - - if (main->parameters.array[fss_payload_read_parameter_at_e].result & f_console_result_value_e) { - data->option |= fss_payload_read_data_option_at_d; - } - - if (main->parameters.array[fss_payload_read_parameter_columns_e].result & f_console_result_found_e) { - data->option |= fss_payload_read_data_option_columns_d; - } - - if (main->parameters.array[fss_payload_read_parameter_content_e].result & f_console_result_found_e) { - data->option |= fss_payload_read_data_option_content_d; - } - - if (main->parameters.array[fss_payload_read_parameter_empty_e].result & f_console_result_found_e) { - data->option |= fss_payload_read_data_option_empty_d; - } - - if (main->parameters.array[fss_payload_read_parameter_line_e].result & f_console_result_value_e) { - data->option |= fss_payload_read_data_option_line_d; - - status = fss_payload_read_load_number(main, data, fss_payload_read_parameter_line_e, fss_payload_read_long_line_s, &data->line); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_payload_read_parameter_name_e].result & f_console_result_value_e) { - data->option |= fss_payload_read_data_option_name_d; - } - - if (main->parameters.array[fss_payload_read_parameter_object_e].result & f_console_result_found_e) { - data->option |= fss_payload_read_data_option_object_d; - } - - if (main->parameters.array[fss_payload_read_parameter_original_e].result & f_console_result_found_e) { - data->option |= fss_payload_read_data_option_original_d; - } - - if (main->parameters.array[fss_payload_read_parameter_select_e].result & f_console_result_value_e) { - data->option |= fss_payload_read_data_option_select_d; - - status = fss_payload_read_load_number(main, data, fss_payload_read_parameter_select_e, fss_payload_read_long_select_s, &data->select); - if (F_status_is_error(status)) return status; - } - - if (main->parameters.array[fss_payload_read_parameter_total_e].result & f_console_result_found_e) { - data->option |= fss_payload_read_data_option_total_d; - } - - if (main->parameters.array[fss_payload_read_parameter_trim_e].result & f_console_result_found_e) { - data->option |= fss_payload_read_data_option_trim_d; - } - - // Default to content if neither Object nor Content is explicitly requested. - if (!(data->option & (fss_payload_read_data_option_content_d | fss_payload_read_data_option_object_d))) { - data->option |= fss_payload_read_data_option_content_d; - } - - return F_none; - } -#endif // _di_fss_payload_read_process_option_ - -#ifndef _di_fss_payload_read_process_total_ - f_status_t fss_payload_read_process_total(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { - - f_array_length_t total = 0; - f_string_range_t range = f_string_range_t_initialize; - f_array_length_t i = 0; - - for (f_array_length_t at = 0; at < data->contents.used; ++at) { - - if (!names[at]) continue; - - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(&main->program)) { - fll_program_print_signal_received(main->warning, main->signal_received); - - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - if (data->option & fss_payload_read_data_option_object_d) { - ++total; - } - - // There is only a single Content column for this standard. - if (data->option & fss_payload_read_data_option_content_d) { - - if (!data->contents.array[at].used) continue; - - range.start = data->contents.array[at].array[0].start; - range.stop = data->contents.array[at].array[0].stop; - - // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - continue; - } - - for (i = range.start; i <= range.stop; ++i) { - - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - range.start = i + 1; - - if (i <= range.stop) { - ++total; - } - } - } // for - - // If Content does not end with a newline, it still must be treated as the last line. - if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { - ++total; - } - } - } // for - - f_file_stream_lock(main->output.to); - - if (data->option & fss_payload_read_data_option_line_d) { - if (data->line < total) { - fss_payload_read_print_one(main); - } - else { - fss_payload_read_print_zero(main); - } - } - else { - fl_print_format("%ul%r", main->output.to, total, f_string_eol_s); - } - - f_file_stream_unlock(main->output.to); - - return F_none; - } -#endif // _di_fss_payload_read_process_total_ - -#ifndef _di_fss_payload_read_process_total_extended_ - f_status_t fss_payload_read_process_total_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { - - f_array_length_t total = 0; - - // This standard only has one Content per line, however it has multiple Contents within that line. - if ((data->option & fss_payload_read_data_option_object_d) || (data->option & fss_payload_read_data_option_content_d) && (data->option & fss_payload_read_data_option_empty_d)) { - for (f_array_length_t i = 0; i < data->objects_header.used; ++i) { - - if (!names[i]) continue; - - ++total; - } // for - } - else { - f_array_length_t i = 0; - f_array_length_t j = 0; - - for (; i < data->contents_header.used; ++i) { - - if (!names[i]) continue; - if (!data->contents_header.array[i].used) continue; - - if ((data->option & fss_payload_read_data_option_select_d) && data->contents_header.array[i].used <= data->select) { - continue; - } - - for (j = 0; j < data->contents_header.array[i].used; ++j) { - - if (data->contents_header.array[i].array[j].start <= data->contents_header.array[i].array[j].stop) { - if (data->option & fss_payload_read_data_option_select_d) { - if (j == data->select) { - ++total; - - break; - } - } - else { - ++total; - - break; - } - } - } // for - } // for - } - - f_file_stream_lock(main->output.to); - - if (data->option & fss_payload_read_data_option_line_d) { - if (data->line < total) { - fss_payload_read_print_one(main); - } - else { - fss_payload_read_print_zero(main); - } - } - else { - fl_print_format("%ul%r", main->output.to, total, f_string_eol_s); - } - - f_file_stream_unlock(main->output.to); - - return F_none; - } -#endif // _di_fss_payload_read_process_total_extended_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/fss_payload_read/c/private-read.h b/level_3/fss_payload_read/c/private-read.h deleted file mode 100644 index 0c94992..0000000 --- a/level_3/fss_payload_read/c/private-read.h +++ /dev/null @@ -1,409 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: FSS - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - */ -#ifndef _PRIVATE_read_h -#define _PRIVATE_read_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Determine if the given depth is to be delimited or not for Content. - * - * @param depth - * The depth to check. - * @param data - * The program data. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_payload_read_delimit_content_is_ - extern f_status_t fss_payload_read_delimit_content_is(fss_payload_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_delimit_content_is_ - -/** - * Determine if the given depth is to be delimited or not for an Object. - * - * @param data - * The program data. - * @param depth - * The depth to check. - * - * @return - * F_true if to apply delimits. - * F_false if to not apply delimits. - */ -#ifndef _di_fss_payload_read_delimit_object_is_ - extern f_status_t fss_payload_read_delimit_object_is(fss_payload_read_data_t * const data, const f_array_length_t depth) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_delimit_object_is_ - -/** - * Process the parameters, parsing out and handling the depth and depth related parameters. - * - * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed). - * - * @param main - * The main program data. - * @param arguments - * The parameters passed to the process. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal. - * - * Errors (with error bit) from: f_rip_dynamic(). - * Errors (with error bit) from: f_string_append(). - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * - * Errors (with error bit) from: fss_payload_read_depths_resize(). - * - * @see f_rip_dynamic() - * @see f_string_append() - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * - * @see fss_payload_read_depths_resize() - */ -#ifndef _di_fss_payload_read_depth_process_ - extern f_status_t fss_payload_read_depth_process(fll_program_data_t * const main, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_depth_process_ - -/** - * Get the name of the file the given position represents within the buffer. - * - * @param at - * The position within the buffer. - * @param files - * The representation of files and their respective ranges within the buffer. - * - * @return - * A string with the name when found. - * NULL is returned if the range represents the STDIN pipe. - * - * On failure to identify, an empty string is returned. - */ -#ifndef _di_fss_payload_read_file_identify_ - extern f_string_static_t fss_payload_read_file_identify(const f_array_length_t at, const fss_payload_read_files_t files) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_file_identify_ - -/** - * Process the buffer, loading the FSS data. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * 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_payload_read() - * - * @see fll_fss_payload_read() - * - * @see fss_payload_read_process_option() - */ -#ifndef _di_fss_payload_read_load_ - extern f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_load_ - -/** - * Load a given number parameter. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param parameter - * An ID representing the parameter. - * @param name - * The parameter name to print on error. - * @param number - * The location to store the loaded number. - * - * @return - * F_true on success and the parameter was found (and is valid). - * F_false on success and the parameter was not found. - * - * Errors (with error bit) from: fl_conversion_dynamic_partial_to_unsigned_detect(). - * - * @see fl_conversion_dynamic_partial_to_unsigned_detect() - * - * @see fss_payload_read_depths_resize() - */ -#ifndef _di_fss_payload_read_load_number_ - extern f_status_t fss_payload_read_load_number(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_load_number_ - -/** - * Perform the payload read processing on the buffer. - * - * This will print an error message on error. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_payload_read_load() - * Errors (with error bit) from: fss_payload_read_process_option() - * - * @see fss_payload_read_load() - * @see fss_payload_read_process_option() - */ -#ifndef _di_fss_payload_read_process_ - extern f_status_t fss_payload_read_process(fll_program_data_t * const main, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_ - -/** - * Process based on at parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - * - * @see fss_payload_read_process_at_line() - */ -#ifndef _di_fss_payload_read_process_at_ - extern f_status_t fss_payload_read_process_at(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_at_ - -/** - * Process based on at parameter for the FSS-0001 Extended Content at depth 1. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - * - * @see fss_payload_read_process_at_line() - */ -#ifndef _di_fss_payload_read_process_at_extended_ - extern f_status_t fss_payload_read_process_at_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_at_extended_ - -/** - * Process based on at parameter for some line. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param delimits_object - * The delimits to be applied to an Object. - * @param delimits_content - * The delimits to be applied to Content. - * @param line - * The current line being processed. - * This will be incremented as necessary. - * - * @return - * F_none on success but no line was matched (and possibly printed). - * F_success on success and the line was matched (and possibly printed). - */ -#ifndef _di_fss_payload_read_process_at_line_ - extern f_status_t fss_payload_read_process_at_line(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_at_line_ - -/** - * Process based on columns parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_process_columns_ - extern f_status_t fss_payload_read_process_columns(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_columns_ - -/** - * Process based on columns parameter for the FSS-0001 Extended Content at depth 1. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_process_columns_extended_ - extern f_status_t fss_payload_read_process_columns_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_columns_extended_ - -/** - * Process based on line parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_process_line_ - extern f_status_t fss_payload_read_process_line(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_line_ - -/** - * Process based on line parameter for the FSS-0001 Extended Content at depth 1. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_process_line_extended_ - extern f_status_t fss_payload_read_process_line_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_line_extended_ - -/** - * Process the Objects in the buffer, determining if the Object name is to be used or not. - * - * How an Object name is determined to be used or not is dependent on several parameters, such as --name, --depth, --at, and --line. - * - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_process_name_ - extern f_status_t fss_payload_read_process_name(fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_name_ - -/** - * Process the Objects in the buffer, determining if the Object name is to be used or not for the FSS-0001 Extended Content at depth 1. - * - * How an Object name is determined to be used or not is dependent on several parameters, such as --name, --depth, --at, and --line. - * - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_process_name_extended_ - extern f_status_t fss_payload_read_process_name_extended(fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_name_extended_ - -/** - * Process the parameters, populating the option property of the program data. - * - * @param main - * The main program data. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: fss_payload_read_load_setting() - * - * @see fll_fss_payload_read() - * - * @see fss_payload_read_load_setting() - */ -#ifndef _di_fss_payload_read_process_option_ - extern f_status_t fss_payload_read_process_option(fll_program_data_t * const main, fss_payload_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_option_ - -/** - * Process based on total parameter. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_process_total_ - extern f_status_t fss_payload_read_process_total(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_total_ - -/** - * Process based on total parameter for the FSS-0001 Extended Content at depth 1. - * - * @param main - * The main program data. - * @param data - * The program data. - * @param names - * An array of booleans representing whether or not some Object name is to be used. - * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.) - * - * @return - * F_none on success. - */ -#ifndef _di_fss_payload_read_process_total_extended_ - extern f_status_t fss_payload_read_process_total_extended(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_process_total_extended_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_read_h diff --git a/level_3/fss_payload_read/data/build/defines b/level_3/fss_payload_read/data/build/defines deleted file mode 100644 index 490da41..0000000 --- a/level_3/fss_payload_read/data/build/defines +++ /dev/null @@ -1,6 +0,0 @@ -# fss-0000 - -_di_thread_support_ Disables thread support. - -_pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. -_pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). diff --git a/level_3/fss_payload_read/data/build/dependencies b/level_3/fss_payload_read/data/build/dependencies deleted file mode 100644 index 22cdeb6..0000000 --- a/level_3/fss_payload_read/data/build/dependencies +++ /dev/null @@ -1,31 +0,0 @@ -# fss-0000 - -f_type -f_status -f_memory -f_type_array -f_string -f_utf -f_color -f_compare -f_console -f_conversion -f_directory -f_environment -f_file -f_fss -f_parse -f_pipe -f_print -f_rip -f_signal - -fl_conversion -fl_fss -fl_print - -fll_error -fll_file -fll_fss -fll_print -fll_program diff --git a/level_3/fss_payload_read/data/build/fakefile b/level_3/fss_payload_read/data/build/fakefile deleted file mode 100644 index 1bce122..0000000 --- a/level_3/fss_payload_read/data/build/fakefile +++ /dev/null @@ -1,27 +0,0 @@ -# fss-0005 iki-0002 - -settings: - fail exit - modes individual individual_thread level monolithic clang test fanalyzer thread threadless - - environment PATH LD_LIBRARY_PATH - environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -main: - build - -install: - shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' - -help: - print - print context:'title'Fakefile Options for FSS Payload Read Software.context:'reset' - - print - print The following operations are available\: - print " - context:'notable'help:context:'reset' Perform the help operation, printing this message." - print " - context:'notable'install:context:'reset' A helper operation that simply calls the ./install.sh script with default settings." - print " - context:'notable'main:context:'reset' The default compilation using the build settings mode." - - print - print The context:'notable'install context:'reset'operation supports the context:'notable'work,context:'reset' context:'notable'verbosity,context:'reset' and context:'notable'color context:'reset'parameters. diff --git a/level_3/fss_payload_read/data/build/settings b/level_3/fss_payload_read/data/build/settings deleted file mode 100644 index 3ace09b..0000000 --- a/level_3/fss_payload_read/data/build/settings +++ /dev/null @@ -1,85 +0,0 @@ -# fss-0001 -# -# Modes: -# - individual: Compile using per project (individual) libraries, does not handle thread or threadless cases. -# - individual_thread: This is required when compiling in individual mode with "thread" mode. -# - level: Compile using per level libraries. -# - monolithic: Compile using per monolithic libraries. -# - clang: Use clang rather than the default, which is generally gcc. -# - test: Compile for a test, such as unit testing. -# - fanalyzer: Compile using GCC's -fanalyzer compile time option. -# - thread: Compile with thread support. -# - threadless: Compile without thread support. -# - -build_name fss_payload_read - -version_major 0 -version_minor 7 -version_micro 0 -version_file micro -version_target minor - -modes individual individual_thread level monolithic clang test fanalyzer thread threadless -modes_default monolithi threadc - -build_compiler gcc -build_compiler-clang clang -build_indexer ar -build_indexer_arguments rcs -build_language c - -build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_program -lfl_conversion -lfl_directory -lfl_fss -lfl_print -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_parse -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_status_string -lf_string -lf_type_array -lf_utf -build_libraries-individual_thread -lf_thread -build_libraries-level -lfll_2 -lfll_1 -lfll_0 -build_libraries-monolithic -lfll - -build_sources_library fss_payload_read.c common.c print.c private-common.c private-print.c private-read.c - -build_sources_program main.c - -build_sources_headers fss_payload_read.h common.h print.h - -build_sources_documentation man - -build_script yes -build_shared yes -build_static no - -path_headers program/fss_payload_read -path_library_script script -path_library_shared shared -path_library_static static -path_object_script script -path_object_shared shared -path_object_static static -path_program_script script -path_program_shared shared -path_program_static static - -has_path_standard yes -preserve_path_headers yes - -search_exclusive yes -search_shared yes -search_static yes - -environment PATH LD_LIBRARY_PATH -environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH - -#defines -D_di_libcap_ -defines -D_libcap_legacy_only_ -defines-threadless -D_di_thread_support_ -defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ - -flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces -flags-thread -pthread -flags-clang -Wno-logical-op-parentheses -flags-test -O0 -fstack-protector -Wall -flags-fanalyzer -fanalyzer -flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ - -flags_library -fPIC -flags_object -fPIC -flags_program -fPIE diff --git a/level_3/fss_payload_read/data/documentation/man/man1/fss_payload_read.1 b/level_3/fss_payload_read/data/documentation/man/man1/fss_payload_read.1 deleted file mode 100644 index 4b72316..0000000 --- a/level_3/fss_payload_read/data/documentation/man/man1/fss_payload_read.1 +++ /dev/null @@ -1,150 +0,0 @@ -.TH FSS_PAYLOAD_READ "1" "March 2023" "FLL - FSS Payload Read 0.7.0" "User Commands" -.SH NAME -fss_payload_read \- Read data in \fBFSS-000E (Payload)\fR format. -.SH SYNOPSIS -.B fss_payload_read -[\fI\,OPTIONS\/\fR] [\fI\,FILENAMES\/\fR] -.SH DESCRIPTION -.PP -This program will print the Content associated with the given Object and Content main based on the \fBFSS-000E Payload\fR standard. - -All numeric positions (indexes) start at 0 instead of 1. -For example, a file of 17 lines would range from 0 to 16. - -When using the \fB\-\-depth\fR option, an order of operations is enforced on the parameters. -When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter: - \fB\-\-at\fR: An Object index at the specified depth. - \fB\-\-depth\fR: A new depth within the specified depth, indexed from the root. - \fB\-\-name\fR: An Object name at the specified depth. - -The parameter \fB\-\-depth\fR must be in numeric order, but values in between may be skipped. - ('\fB\-d 0 \-a 1 \-d 2 \-a 2\fR' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.) - ('\fB\-d 2 \-a 1 \-d 0 \-a 2\fR' would be invalid because depth 2 is before depth 1.) - -The parameter \fB\-\-select\fR selects a Content column. - -Specify both \fB\-\-object\fR and the \fB\-\-total\fR parameters to get the total objects. - -When both \fB\-\-at\fR and \fB\-\-name\fR parameters are specified (at the same depth), the \fB\-\-at\fR parameter value will be treated as a position relative to the specified \fB\-\-name\fR parameter value. - -This program may support parameters, such as \fB\-\-depth\fR or \fB\-\-select\fR, even if not supported by the standard. -This is done to help ensure consistency for scripting. - -For parameters like \fB\-\-depth\fR, if the standard doesn't support nested Content, then only a depth of 0 would be valid. -For parameters like \fB\-\-select\fR, if the standard doesn't support multiple Content groups, then only a select of 0 would be valid. - -The parameter \fB\-\-trim\fR will remove leading and trailing white spaces when selecting objects or when printing objects. - -When specifying both the \fB\-\-object\fR parameter and the \fB\-\-content\fR parameter, the entire Object and Content are printed, including the formatting. -Both the Object and Content printed are already escaped. -Both the Object and Content are separated by a New Line character '\fB\\n\fR' (U+000A). - -The parameter \fB\-\-delimit\fR accepts the following: -- none: Do not apply delimits. -- all: (default) Apply all delimits. -- object: Apply delimits for Objects. -- A number, 0 or greater: apply delimits for Content at the specified depth. -- A number, 0 or greater, followed by a +: (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically). -- A number, 0 or lesser, followed by a \-: (such as '1\-') apply delimits for Content at the specified depth and any lesser depth (numerically). - -The \fB\-\-delimit\fR parameter may be specified multiple times to customize the delimit behavior. -The \fB\-\-delimit\fR values none and all, overrule all other delimit values. - -The parameters \fB\-\-columns\fR and \fB\-\-select\fR refer to a Content column. -The word "column" is being loosely defined to refer to a specific Content. -This is not to be confused with a depth. - -As an exceptional case, a \fB\-\-depth\fR of 1 applies only to the explicit Object of 'header'. -Content at this depth is processed as \fBFSS-0001 Extended\fR. - -The Content of the explicit Object of 'payload' will not contain any Content close pipe control codes when using \fB\-\-pipe\fR. -.SH OPTIONS -.TP -\fB\{\-h, \-\-help\fR -Print the help message. -.TP -\fB+C, ++copyright\fR -Print the copyright. -.TP -\fB+d, ++dark\fR -Output using colors that show up better on dark backgrounds. -.TP -\fB+l, ++light\fR -Output using colors that show up better on light backgrounds. -.TP -\fB+n, ++no_color\fR -Do not print using color. -.TP -\fB+Q, ++quiet\fR -Decrease verbosity, silencing most output. -.TP -\fB+E, ++error\fR -Decrease verbosity, using only error output. -.TP -\fB+N, ++normal\fR -Set verbosity to normal. -.TP -\fB+V, ++verbose\fR -Increase verbosity beyond normal output. -.TP -\fB+D, ++debug\fR -Enable debugging, significantly increasing verbosity beyond normal output. -.TP -\fB+v, ++version\fR -Print only the version number. -.TP -\fB+F, ++line_first_no\fR -Disable printing of first line. -.TP -\fB+L, ++line_last_no\fR -Disable printing of last line. -.TP -\fB\-a, \-\-at\fR -Select Object at this numeric index. -.TP -\fB\-c, \-\-content\fR -Print the Content (default). -.TP -\fB\-C, \-\-columns\fR -Print the total number of columns. -.TP -\fB\-D, \-\-delimit\fR -Designate how to handle applying delimits. -.TP -\fB\-d, \-\-depth\fR -Select Object at this numeric depth. -.TP -\fB\-e, \-\-empty\fR -Include empty Content when processing. -.TP -\fB\-l, \-\-line\fR -Print only the Content at the given line. -.TP -\fB\-n, \-\-name\fR -Select Object with this name. -.TP -\fB\-o, \-\-object\fR -Print the Object. -.TP -\fB\-p, \-\-pipe\fR -Print using the special pipe format. -.TP -\fB\-O, \-\-original\fR -Print with the original quotes and escapes. -.TP -\fB\-s, \-\-select\fR -Select sub-Content at this index. -.TP -\fB\-t, \-\-total\fR -Print the total number of lines. -.TP -\fB\-T, \-\-trim\fR -Trim Object names on select or print. -.SH FILENAMES -.TP -Any number of files to read. -.SH AUTHOR -Written by Kevin Day. -.SH COPYRIGHT -.PP -Copyright \(co 2007-2023 Kevin Day, GNU LGPL Version 2.1 or later. -- 1.8.3.1