From: Kevin Day Date: Thu, 27 Apr 2023 03:36:48 +0000 (-0500) Subject: Progress: Initial setup of fss_read for merging all fss_*_read programs. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=d22453dd25f80ed540b6bcd89b6e02e1ef2e418c;p=fll Progress: Initial setup of fss_read for merging all fss_*_read programs. This is just a copy and paste of fss_write with some very basic initial changes and refactoring. This is not expected to work anytime soon and will be slowly converted. Expect major changes. I suspect that I will be working outward in to slowly add the needed functionality and to match the behavior with the fss_*_read programs. All of the fss_*_read programs will be removed and replaced with this once this project is complete just like was done with the fss_*_write programs and fss_write. Also fix an incorrect comment in fss_write that references "payload" when it should not. --- diff --git a/level_3/fss_read/c/basic/common.c b/level_3/fss_read/c/basic/common.c new file mode 100644 index 0000000..6e6619b --- /dev/null +++ b/level_3/fss_read/c/basic/common.c @@ -0,0 +1,21 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_basic_s_ + const f_string_static_t fss_read_basic_standard_s = macro_f_string_static_t_initialize_1(FSS_READ_basic_standard_s, 0, FSS_READ_basic_standard_s_length); + + const f_string_static_t fss_read_basic_program_name_s = macro_f_string_static_t_initialize_1(FSS_READ_basic_program_name_s, 0, FSS_READ_basic_program_name_s_length); + const f_string_static_t fss_read_basic_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_READ_basic_program_name_long_s, 0, FSS_READ_basic_program_name_long_s_length); + + const f_string_static_t fss_read_format_code_short_0000_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_short_0000_s, 0, FSS_READ_format_code_short_0000_s_length); + const f_string_static_t fss_read_format_code_long_0000_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_long_0000_s, 0, FSS_READ_format_code_long_0000_s_length); + const f_string_static_t fss_read_format_code_human_0000_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_human_0000_s, 0, FSS_READ_format_code_human_0000_s_length); + const f_string_static_t fss_read_format_code_machine_0000_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_machine_0000_s, 0, FSS_READ_format_code_machine_0000_s_length); +#endif // _di_fss_read_basic_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/basic/common.h b/level_3/fss_read/c/basic/common.h new file mode 100644 index 0000000..2b0c72a --- /dev/null +++ b/level_3/fss_read/c/basic/common.h @@ -0,0 +1,58 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_basic_common_h +#define _fss_read_basic_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The FSS-0000 (Basic) specific strings. + */ +#ifndef _di_fss_read_basic_s_ + #define FSS_READ_basic_standard_s "FSS-0000 (Basic)" + + #define FSS_READ_basic_program_name_s "fss_basic_read" + #define FSS_READ_basic_program_name_long_s "FSS Basic Read" + + #define FSS_READ_format_code_short_0000_s "0000" + #define FSS_READ_format_code_long_0000_s "fss-0000" + #define FSS_READ_format_code_human_0000_s "basic" + #define FSS_READ_format_code_machine_0000_s "basic" + + #define FSS_READ_basic_standard_s_length 16 + + #define FSS_READ_basic_program_name_s_length 14 + #define FSS_READ_basic_program_name_long_s_length 14 + + #define FSS_READ_format_code_short_0000_s_length 4 + #define FSS_READ_format_code_long_0000_s_length 8 + #define FSS_READ_format_code_human_0000_s_length 5 + #define FSS_READ_format_code_machine_0000_s_length 5 + + extern const f_string_static_t fss_read_basic_standard_s; + + extern const f_string_static_t fss_read_basic_program_name_s; + extern const f_string_static_t fss_read_basic_program_name_long_s; + + extern const f_string_static_t fss_read_format_code_short_0000_s; + extern const f_string_static_t fss_read_format_code_long_0000_s; + extern const f_string_static_t fss_read_format_code_human_0000_s; + extern const f_string_static_t fss_read_format_code_machine_0000_s; +#endif // _di_fss_read_basic_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_basic_common_h diff --git a/level_3/fss_read/c/basic/fss_read.c b/level_3/fss_read/c/basic/fss_read.c new file mode 100644 index 0000000..8bca96f --- /dev/null +++ b/level_3/fss_read/c/basic/fss_read.c @@ -0,0 +1,116 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_basic_process_content_ + void fss_read_basic_process_content(void * const void_main, const bool last) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.content) { + fl_fss_basic_content_write( + *main->setting.content, + (main->setting.flag & fss_read_main_flag_partial_e) + ? f_fss_complete_partial_e + : f_fss_complete_full_e, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_content_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_close_s, &main->setting.buffer); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_basic_process_content_ + +#ifndef _di_fss_read_basic_process_help_ + void fss_read_basic_process_help(void * const void_main) { + + if (!void_main) return; + + fss_read_basic_print_help(&((fss_read_main_t *) void_main)->program.message); + } +#endif // _di_fss_read_basic_process_help_ + +#ifndef _di_fss_read_basic_process_object_ + void fss_read_basic_process_object(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.object) { + fl_fss_basic_object_write( + *main->setting.object, + main->setting.quote.used + ? main->setting.quote.string[0] + : f_fss_quote_double_s.string[0], + (main->setting.flag & fss_read_main_flag_partial_e) + ? (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_object_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_open_s, &main->setting.buffer); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_basic_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/basic/fss_read.h b/level_3/fss_read/c/basic/fss_read.h new file mode 100644 index 0000000..1000e10 --- /dev/null +++ b/level_3/fss_read/c/basic/fss_read.h @@ -0,0 +1,114 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * This program provides FSS write functionality for the FSS-0000 Basic. + */ +#ifndef _fss_read_basic_h +#define _fss_read_basic_h + +// Libc includes. +#include +#include +#include +#include + +// FLL-0 includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// FLL-1 includes. +#include +#include +#include + +// FLL-2 includes. +#include +#include +#include + +// FSS Write includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Process a single Content, printing the FSS-0000 (Basic) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + * @param last + * If TRUE, then this is the last Content in the Content set. + * If FALSE, then this is not the last Content in the Content set. + */ +#ifndef _di_fss_read_basic_process_content_ + extern void fss_read_basic_process_content(void * const main, const bool last); +#endif // _di_fss_read_basic_process_content_ + +/** + * Process help for FSS-0000 (Basic). + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This does not alter main.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_read_basic_process_help_ + extern void fss_read_basic_process_help(void * const main); +#endif // _di_fss_read_basic_process_help_ + +/** + * Process a single Object, printing the FSS-0000 (Basic) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + */ +#ifndef _di_fss_read_basic_process_object_ + extern void fss_read_basic_process_object(void * const main); +#endif // _di_fss_read_basic_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_basic_h diff --git a/level_3/fss_read/c/basic/main.c b/level_3/fss_read/c/basic/main.c new file mode 100644 index 0000000..b740c36 --- /dev/null +++ b/level_3/fss_read/c/basic/main.c @@ -0,0 +1,83 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + fss_read_main_t data = fss_read_main_t_initialize; + + data.program.debug.flag |= fss_read_print_flag_debug_e | fss_read_print_flag_out_e; + data.program.error.flag |= fss_read_print_flag_error_e | fss_read_print_flag_out_e; + data.program.output.flag |= fss_read_print_flag_out_e; + data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; + data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; + data.program.debug.custom = (void *) &data; + data.program.message.custom = (void *) &data; + data.program.output.custom = (void *) &data; + data.program.warning.custom = (void *) &data; + + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_read_basic_standard_s; + data.setting.process_content = &fss_read_basic_process_content; + data.setting.process_help = &fss_read_basic_process_help; + data.setting.process_normal = &fss_read_process_normal; + data.setting.process_object = &fss_read_basic_process_object; + data.setting.process_pipe = &fss_read_process_pipe; + data.setting.process_set = &fss_read_process_set; + + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_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); + + f_file_umask_get(&data.program.umask); + + #ifdef _di_thread_support_ + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + fss_read_main(&data); + #else + { + f_thread_id_t id_signal; + + memset(&id_signal, 0, sizeof(f_thread_id_t)); + + data.setting.state.status = f_thread_create(0, &id_signal, &fss_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + fss_read_print_error(&data.program.error, macro_fss_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + if (!fss_read_signal_check(&data)) { + fss_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + fss_read_main_delete(&data); + + fll_program_standard_set_down(&data.program); + + return F_status_is_error(data.setting.state.status) ? 1 : 0; +} diff --git a/level_3/fss_read/c/basic/main.h b/level_3/fss_read/c/basic/main.h new file mode 100644 index 0000000..5b35af8 --- /dev/null +++ b/level_3/fss_read/c/basic/main.h @@ -0,0 +1,38 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_write" program functionality in some manner. + */ +#ifndef _fss_read_basic_main_h +#define _fss_read_basic_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_read_basic_main_h diff --git a/level_3/fss_read/c/basic/print.c b/level_3/fss_read/c/basic/print.c new file mode 100644 index 0000000..a87aac9 --- /dev/null +++ b/level_3/fss_read/c/basic/print.c @@ -0,0 +1,41 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_basic_print_help_ + f_status_t fss_read_basic_print_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_basic_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_basic_program_name_s, f_string_empty_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_end_next(print); + + fl_print_format("%r The FSS-0000 (Basic) specification does not support multi-line Content, therefore the parameter '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_prepend_s, print->set->notable); + fl_print_format(" does nothing.%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_basic_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/basic/print.h b/level_3/fss_read/c/basic/print.h new file mode 100644 index 0000000..d153b6e --- /dev/null +++ b/level_3/fss_read/c/basic/print.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + */ +#ifndef _fss_read_basic_print_h +#define _fss_read_basic_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print help for FSS-0000 (Basic). + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_basic_print_help_ + extern f_status_t fss_read_basic_print_help(fl_print_t * const print); +#endif // _di_fss_read_basic_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_basic_print_h diff --git a/level_3/fss_read/c/basic_list/common.c b/level_3/fss_read/c/basic_list/common.c new file mode 100644 index 0000000..6674ef0 --- /dev/null +++ b/level_3/fss_read/c/basic_list/common.c @@ -0,0 +1,21 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_basic_list_s_ + const f_string_static_t fss_read_basic_list_standard_s = macro_f_string_static_t_initialize_1(FSS_READ_basic_list_standard_s, 0, FSS_READ_basic_list_standard_s_length); + + const f_string_static_t fss_read_basic_list_program_name_s = macro_f_string_static_t_initialize_1(FSS_READ_basic_list_program_name_s, 0, FSS_READ_basic_list_program_name_s_length); + const f_string_static_t fss_read_basic_list_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_READ_basic_list_program_name_long_s, 0, FSS_READ_basic_list_program_name_long_s_length); + + const f_string_static_t fss_read_format_code_short_0002_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_short_0002_s, 0, FSS_READ_format_code_short_0002_s_length); + const f_string_static_t fss_read_format_code_long_0002_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_long_0002_s, 0, FSS_READ_format_code_long_0002_s_length); + const f_string_static_t fss_read_format_code_human_0002_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_human_0002_s, 0, FSS_READ_format_code_human_0002_s_length); + const f_string_static_t fss_read_format_code_machine_0002_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_machine_0002_s, 0, FSS_READ_format_code_machine_0002_s_length); +#endif // _di_fss_read_basic_list_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/basic_list/common.h b/level_3/fss_read/c/basic_list/common.h new file mode 100644 index 0000000..78d201f --- /dev/null +++ b/level_3/fss_read/c/basic_list/common.h @@ -0,0 +1,58 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_basic_list_common_h +#define _fss_read_basic_list_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The FSS-0002 (Basic List) specific strings. + */ +#ifndef _di_fss_read_basic_list_s_ + #define FSS_READ_basic_list_standard_s "FSS-0002 (Basic List)" + + #define FSS_READ_basic_list_program_name_s "fss_basic_list_read" + #define FSS_READ_basic_list_program_name_long_s "FSS Basic List Read" + + #define FSS_READ_format_code_short_0002_s "0002" + #define FSS_READ_format_code_long_0002_s "fss-0002" + #define FSS_READ_format_code_human_0002_s "basic list" + #define FSS_READ_format_code_machine_0002_s "basic_list" + + #define FSS_READ_basic_list_standard_s_length 21 + + #define FSS_READ_basic_list_program_name_s_length 19 + #define FSS_READ_basic_list_program_name_long_s_length 19 + + #define FSS_READ_format_code_short_0002_s_length 4 + #define FSS_READ_format_code_long_0002_s_length 8 + #define FSS_READ_format_code_human_0002_s_length 10 + #define FSS_READ_format_code_machine_0002_s_length 10 + + extern const f_string_static_t fss_read_basic_list_standard_s; + + extern const f_string_static_t fss_read_basic_list_program_name_s; + extern const f_string_static_t fss_read_basic_list_program_name_long_s; + + extern const f_string_static_t fss_read_format_code_short_0002_s; + extern const f_string_static_t fss_read_format_code_long_0002_s; + extern const f_string_static_t fss_read_format_code_human_0002_s; + extern const f_string_static_t fss_read_format_code_machine_0002_s; +#endif // _di_fss_read_basic_list_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_basic_list_common_h diff --git a/level_3/fss_read/c/basic_list/fss_read.c b/level_3/fss_read/c/basic_list/fss_read.c new file mode 100644 index 0000000..6e4a750 --- /dev/null +++ b/level_3/fss_read/c/basic_list/fss_read.c @@ -0,0 +1,120 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_basic_list_process_content_ + void fss_read_basic_list_process_content(void * const void_main, const bool last) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.content) { + fl_fss_basic_list_content_write( + *main->setting.content, + (main->setting.flag & fss_read_main_flag_partial_e) + ? f_fss_complete_partial_e + : (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + &main->setting.prepend, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_list_content_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &main->setting.buffer); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_basic_list_process_content_ + +#ifndef _di_fss_read_basic_list_process_help_ + void fss_read_basic_list_process_help(void * const void_main) { + + if (!void_main) return; + + fss_read_basic_list_print_help(&((fss_read_main_t *) void_main)->program.message); + } +#endif // _di_fss_read_basic_list_process_help_ + +#ifndef _di_fss_read_basic_list_process_object_ + void fss_read_basic_list_process_object(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.object) { + fl_fss_basic_list_object_write( + *main->setting.object, + (main->setting.flag & fss_read_main_flag_partial_e) + ? (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_list_object_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &main->setting.buffer); + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &main->setting.buffer); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_basic_list_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/basic_list/fss_read.h b/level_3/fss_read/c/basic_list/fss_read.h new file mode 100644 index 0000000..fe2d2b7 --- /dev/null +++ b/level_3/fss_read/c/basic_list/fss_read.h @@ -0,0 +1,115 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * This program provides FSS write functionality for the FSS-0002 Basic List. + */ +#ifndef _fss_read_basic_list_h +#define _fss_read_basic_list_h + +// Libc includes. +#include +#include +#include +#include + +// FLL-0 includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// FLL-1 includes. +#include +#include +#include + +// FLL-2 includes. +#include +#include +#include +#include + +// FSS Write includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Process a single Content, printing the FSS-0002 (Basic List) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + * @param last + * If TRUE, then this is the last Content in the Content set. + * If FALSE, then this is not the last Content in the Content set. + */ +#ifndef _di_fss_read_basic_list_process_content_ + extern void fss_read_basic_list_process_content(void * const main, const bool last); +#endif // _di_fss_read_basic_list_process_content_ + +/** + * Process help for FSS-0002 (Basic List). + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This does not alter main.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_read_basic_list_process_help_ + extern void fss_read_basic_list_process_help(void * const main); +#endif // _di_fss_read_basic_list_process_help_ + +/** + * Process a single Object, printing the FSS-0002 (Basic List) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + */ +#ifndef _di_fss_read_basic_list_process_object_ + extern void fss_read_basic_list_process_object(void * const main); +#endif // _di_fss_read_basic_list_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_basic_list_h diff --git a/level_3/fss_read/c/basic_list/main.c b/level_3/fss_read/c/basic_list/main.c new file mode 100644 index 0000000..cc3c031 --- /dev/null +++ b/level_3/fss_read/c/basic_list/main.c @@ -0,0 +1,83 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + fss_read_main_t data = fss_read_main_t_initialize; + + data.program.debug.flag |= fss_read_print_flag_debug_e | fss_read_print_flag_out_e; + data.program.error.flag |= fss_read_print_flag_error_e | fss_read_print_flag_out_e; + data.program.output.flag |= fss_read_print_flag_out_e; + data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; + data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; + data.program.debug.custom = (void *) &data; + data.program.message.custom = (void *) &data; + data.program.output.custom = (void *) &data; + data.program.warning.custom = (void *) &data; + + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_read_basic_list_standard_s; + data.setting.process_content = &fss_read_basic_list_process_content; + data.setting.process_help = &fss_read_basic_list_process_help; + data.setting.process_normal = &fss_read_process_normal; + data.setting.process_object = &fss_read_basic_list_process_object; + data.setting.process_pipe = &fss_read_process_pipe; + data.setting.process_set = &fss_read_process_set; + + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_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); + + f_file_umask_get(&data.program.umask); + + #ifdef _di_thread_support_ + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + fss_read_main(&data); + #else + { + f_thread_id_t id_signal; + + memset(&id_signal, 0, sizeof(f_thread_id_t)); + + data.setting.state.status = f_thread_create(0, &id_signal, &fss_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + fss_read_print_error(&data.program.error, macro_fss_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + if (!fss_read_signal_check(&data)) { + fss_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + fss_read_main_delete(&data); + + fll_program_standard_set_down(&data.program); + + return F_status_is_error(data.setting.state.status) ? 1 : 0; +} diff --git a/level_3/fss_read/c/basic_list/main.h b/level_3/fss_read/c/basic_list/main.h new file mode 100644 index 0000000..537f119 --- /dev/null +++ b/level_3/fss_read/c/basic_list/main.h @@ -0,0 +1,38 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_write" program functionality in some manner. + */ +#ifndef _fss_read_basic_list_main_h +#define _fss_read_basic_list_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_read_basic_list_main_h diff --git a/level_3/fss_read/c/basic_list/print.c b/level_3/fss_read/c/basic_list/print.c new file mode 100644 index 0000000..1f8a055 --- /dev/null +++ b/level_3/fss_read/c/basic_list/print.c @@ -0,0 +1,41 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_basic_list_print_help_ + f_status_t fss_read_basic_list_print_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_basic_list_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_basic_list_program_name_s, f_string_empty_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_end_next(print); + + fl_print_format("%r The FSS-0002 (Basic List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_single_s, print->set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_basic_list_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/basic_list/print.h b/level_3/fss_read/c/basic_list/print.h new file mode 100644 index 0000000..6115a2c --- /dev/null +++ b/level_3/fss_read/c/basic_list/print.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + */ +#ifndef _fss_read_basic_list_print_h +#define _fss_read_basic_list_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print help for FSS-0002 (Basic List). + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_basic_list_print_help_ + extern f_status_t fss_read_basic_list_print_help(fl_print_t * const print); +#endif // _di_fss_read_basic_list_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_basic_list_print_h diff --git a/level_3/fss_read/c/embedded_list/common.c b/level_3/fss_read/c/embedded_list/common.c new file mode 100644 index 0000000..dce430f --- /dev/null +++ b/level_3/fss_read/c/embedded_list/common.c @@ -0,0 +1,21 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_embedded_list_s_ + const f_string_static_t fss_read_embedded_list_standard_s = macro_f_string_static_t_initialize_1(FSS_READ_embedded_list_standard_s, 0, FSS_READ_embedded_list_standard_s_length); + + const f_string_static_t fss_read_embedded_list_program_name_s = macro_f_string_static_t_initialize_1(FSS_READ_embedded_list_program_name_s, 0, FSS_READ_embedded_list_program_name_s_length); + const f_string_static_t fss_read_embedded_list_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_READ_embedded_list_program_name_long_s, 0, FSS_READ_embedded_list_program_name_long_s_length); + + const f_string_static_t fss_read_format_code_short_0008_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_short_0008_s, 0, FSS_READ_format_code_short_0008_s_length); + const f_string_static_t fss_read_format_code_long_0008_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_long_0008_s, 0, FSS_READ_format_code_long_0008_s_length); + const f_string_static_t fss_read_format_code_human_0008_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_human_0008_s, 0, FSS_READ_format_code_human_0008_s_length); + const f_string_static_t fss_read_format_code_machine_0008_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_machine_0008_s, 0, FSS_READ_format_code_machine_0008_s_length); +#endif // _di_fss_read_embedded_list_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/embedded_list/common.h b/level_3/fss_read/c/embedded_list/common.h new file mode 100644 index 0000000..8f97e8a --- /dev/null +++ b/level_3/fss_read/c/embedded_list/common.h @@ -0,0 +1,58 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_embedded_list_common_h +#define _fss_read_embedded_list_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The FSS-0008 (Embedded List) specific strings. + */ +#ifndef _di_fss_read_embedded_list_s_ + #define FSS_READ_embedded_list_standard_s "FSS-0008 (Embedded List)" + + #define FSS_READ_embedded_list_program_name_s "fss_embedded_list_read" + #define FSS_READ_embedded_list_program_name_long_s "FSS Embedded List Read" + + #define FSS_READ_format_code_short_0008_s "0008" + #define FSS_READ_format_code_long_0008_s "fss-0008" + #define FSS_READ_format_code_human_0008_s "embedded list" + #define FSS_READ_format_code_machine_0008_s "embedded_list" + + #define FSS_READ_embedded_list_standard_s_length 24 + + #define FSS_READ_embedded_list_program_name_s_length 22 + #define FSS_READ_embedded_list_program_name_long_s_length 22 + + #define FSS_READ_format_code_short_0008_s_length 4 + #define FSS_READ_format_code_long_0008_s_length 8 + #define FSS_READ_format_code_human_0008_s_length 13 + #define FSS_READ_format_code_machine_0008_s_length 13 + + extern const f_string_static_t fss_read_embedded_list_standard_s; + + extern const f_string_static_t fss_read_embedded_list_program_name_s; + extern const f_string_static_t fss_read_embedded_list_program_name_long_s; + + extern const f_string_static_t fss_read_format_code_short_0008_s; + extern const f_string_static_t fss_read_format_code_long_0008_s; + extern const f_string_static_t fss_read_format_code_human_0008_s; + extern const f_string_static_t fss_read_format_code_machine_0008_s; +#endif // _di_fss_read_embedded_list_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_embedded_list_common_h diff --git a/level_3/fss_read/c/embedded_list/fss_read.c b/level_3/fss_read/c/embedded_list/fss_read.c new file mode 100644 index 0000000..a2e0d07 --- /dev/null +++ b/level_3/fss_read/c/embedded_list/fss_read.c @@ -0,0 +1,125 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_embedded_list_process_content_ + void fss_read_embedded_list_process_content(void * const void_main, const bool last) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.content) { + fl_fss_embedded_list_content_write( + *main->setting.content, + (main->setting.flag & fss_read_main_flag_partial_e) + ? f_fss_complete_partial_e + : last + ? f_fss_complete_end_e + : f_fss_complete_next_e, + &main->setting.prepend, + main->setting.ignores, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_embedded_list_content_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_close_s, &main->setting.buffer); + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_close_end_s, &main->setting.buffer); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_embedded_list_process_content_ + +#ifndef _di_fss_read_embedded_list_process_help_ + void fss_read_embedded_list_process_help(void * const void_main) { + + if (!void_main) return; + + fss_read_embedded_list_print_help(&((fss_read_main_t *) void_main)->program.message); + } +#endif // _di_fss_read_embedded_list_process_help_ + +#ifndef _di_fss_read_embedded_list_process_object_ + void fss_read_embedded_list_process_object(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.object) { + fl_fss_embedded_list_object_write( + *main->setting.object, + (main->setting.flag & fss_read_main_flag_partial_e) + ? (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_embedded_list_object_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_open_s, &main->setting.buffer); + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_embedded_list_open_end_s, &main->setting.buffer); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_embedded_list_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/embedded_list/fss_read.h b/level_3/fss_read/c/embedded_list/fss_read.h new file mode 100644 index 0000000..58a3b0f --- /dev/null +++ b/level_3/fss_read/c/embedded_list/fss_read.h @@ -0,0 +1,114 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * This program provides FSS write functionality for the FSS-0008 Embedded List. + */ +#ifndef _fss_read_embedded_list_h +#define _fss_read_embedded_list_h + +// Libc includes. +#include +#include +#include +#include + +// FLL-0 includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// FLL-1 includes. +#include +#include +#include + +// FLL-2 includes. +#include +#include +#include + +// FSS Write includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Process a single Content, printing the FSS-0008 (Embedded List) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + * @param last + * If TRUE, then this is the last Content in the Content set. + * If FALSE, then this is not the last Content in the Content set. + */ +#ifndef _di_fss_read_embedded_list_process_content_ + extern void fss_read_embedded_list_process_content(void * const main, const bool last); +#endif // _di_fss_read_embedded_list_process_content_ + +/** + * Process help for FSS-0008 (Embedded List). + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This does not alter main.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_read_embedded_list_process_help_ + extern void fss_read_embedded_list_process_help(void * const main); +#endif // _di_fss_read_embedded_list_process_help_ + +/** + * Process a single Object, printing the FSS-0008 (Embedded List) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + */ +#ifndef _di_fss_read_embedded_list_process_object_ + extern void fss_read_embedded_list_process_object(void * const main); +#endif // _di_fss_read_embedded_list_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_embedded_list_h diff --git a/level_3/fss_read/c/embedded_list/main.c b/level_3/fss_read/c/embedded_list/main.c new file mode 100644 index 0000000..499eb8b --- /dev/null +++ b/level_3/fss_read/c/embedded_list/main.c @@ -0,0 +1,85 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + fss_read_main_t data = fss_read_main_t_initialize; + + data.program.debug.flag |= fss_read_print_flag_debug_e | fss_read_print_flag_out_e; + data.program.error.flag |= fss_read_print_flag_error_e | fss_read_print_flag_out_e; + data.program.output.flag |= fss_read_print_flag_out_e; + data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; + data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; + data.program.debug.custom = (void *) &data; + data.program.message.custom = (void *) &data; + data.program.output.custom = (void *) &data; + data.program.warning.custom = (void *) &data; + + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_read_embedded_list_standard_s; + data.setting.process_content = &fss_read_embedded_list_process_content; + data.setting.process_help = &fss_read_embedded_list_process_help; + data.setting.process_normal = &fss_read_process_normal; + data.setting.process_object = &fss_read_embedded_list_process_object; + data.setting.process_pipe = &fss_read_process_pipe; + data.setting.process_set = &fss_read_process_set; + data.setting.flag |= fss_read_main_flag_ignore_e; + data.setting.flag |= fss_read_main_flag_content_multiple_e; + + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_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); + + f_file_umask_get(&data.program.umask); + + #ifdef _di_thread_support_ + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + fss_read_main(&data); + #else + { + f_thread_id_t id_signal; + + memset(&id_signal, 0, sizeof(f_thread_id_t)); + + data.setting.state.status = f_thread_create(0, &id_signal, &fss_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + fss_read_print_error(&data.program.error, macro_fss_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + if (!fss_read_signal_check(&data)) { + fss_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + fss_read_main_delete(&data); + + fll_program_standard_set_down(&data.program); + + return F_status_is_error(data.setting.state.status) ? 1 : 0; +} diff --git a/level_3/fss_read/c/embedded_list/main.h b/level_3/fss_read/c/embedded_list/main.h new file mode 100644 index 0000000..d729398 --- /dev/null +++ b/level_3/fss_read/c/embedded_list/main.h @@ -0,0 +1,38 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_embedded_list_write" program functionality in some manner. + */ +#ifndef _fss_read_embedded_list_main_h +#define _fss_read_embedded_list_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_read_embedded_list_main_h diff --git a/level_3/fss_read/c/embedded_list/print.c b/level_3/fss_read/c/embedded_list/print.c new file mode 100644 index 0000000..a363b41 --- /dev/null +++ b/level_3/fss_read/c/embedded_list/print.c @@ -0,0 +1,44 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_embedded_list_print_help_ + f_status_t fss_read_embedded_list_print_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_embedded_list_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_embedded_list_program_name_s, f_string_empty_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_end_next(print); + + fl_print_format("%r The FSS-0008 (Embedded List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_single_s, print->set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The parameter '%[%r%r%]' designates to not escape any valid nested Object or Content within some Content.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%r", print->to, f_string_eol_s); + fl_print_format(" This parameter must be specified after a '%[%r%r%]'", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_content_s, print->set->notable); + fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%r%r%]' parameter.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_content_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_read_embedded_list_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/embedded_list/print.h b/level_3/fss_read/c/embedded_list/print.h new file mode 100644 index 0000000..39efef1 --- /dev/null +++ b/level_3/fss_read/c/embedded_list/print.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + */ +#ifndef _fss_read_embedded_list_print_h +#define _fss_read_embedded_list_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print help for FSS-0008 (Embedded List). + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_embedded_list_print_help_ + extern f_status_t fss_read_embedded_list_print_help(fl_print_t * const print); +#endif // _di_fss_read_embedded_list_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_embedded_list_print_h diff --git a/level_3/fss_read/c/extended/common.c b/level_3/fss_read/c/extended/common.c new file mode 100644 index 0000000..7b3a453 --- /dev/null +++ b/level_3/fss_read/c/extended/common.c @@ -0,0 +1,21 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_extended_s_ + const f_string_static_t fss_read_extended_standard_s = macro_f_string_static_t_initialize_1(FSS_READ_extended_standard_s, 0, FSS_READ_extended_standard_s_length); + + const f_string_static_t fss_read_extended_program_name_s = macro_f_string_static_t_initialize_1(FSS_READ_extended_program_name_s, 0, FSS_READ_extended_program_name_s_length); + const f_string_static_t fss_read_extended_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_READ_extended_program_name_long_s, 0, FSS_READ_extended_program_name_long_s_length); + + const f_string_static_t fss_read_format_code_short_0001_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_short_0001_s, 0, FSS_READ_format_code_short_0001_s_length); + const f_string_static_t fss_read_format_code_long_0001_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_long_0001_s, 0, FSS_READ_format_code_long_0001_s_length); + const f_string_static_t fss_read_format_code_human_0001_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_human_0001_s, 0, FSS_READ_format_code_human_0001_s_length); + const f_string_static_t fss_read_format_code_machine_0001_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_machine_0001_s, 0, FSS_READ_format_code_machine_0001_s_length); +#endif // _di_fss_read_extended_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/extended/common.h b/level_3/fss_read/c/extended/common.h new file mode 100644 index 0000000..29a8fef --- /dev/null +++ b/level_3/fss_read/c/extended/common.h @@ -0,0 +1,58 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_extended_common_h +#define _fss_read_extended_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The FSS-0001 (Extended) specific strings. + */ +#ifndef _di_fss_read_extended_s_ + #define FSS_READ_extended_standard_s "FSS-0001 (Extended)" + + #define FSS_READ_extended_program_name_s "fss_extended_read" + #define FSS_READ_extended_program_name_long_s "FSS Extended Read" + + #define FSS_READ_format_code_short_0001_s "0001" + #define FSS_READ_format_code_long_0001_s "fss-0001" + #define FSS_READ_format_code_human_0001_s "extended" + #define FSS_READ_format_code_machine_0001_s "extended" + + #define FSS_READ_extended_standard_s_length 19 + + #define FSS_READ_extended_program_name_s_length 18 + #define FSS_READ_extended_program_name_long_s_length 18 + + #define FSS_READ_format_code_short_0001_s_length 4 + #define FSS_READ_format_code_long_0001_s_length 8 + #define FSS_READ_format_code_human_0001_s_length 8 + #define FSS_READ_format_code_machine_0001_s_length 8 + + extern const f_string_static_t fss_read_extended_standard_s; + + extern const f_string_static_t fss_read_extended_program_name_s; + extern const f_string_static_t fss_read_extended_program_name_long_s; + + extern const f_string_static_t fss_read_format_code_short_0001_s; + extern const f_string_static_t fss_read_format_code_long_0001_s; + extern const f_string_static_t fss_read_format_code_human_0001_s; + extern const f_string_static_t fss_read_format_code_machine_0001_s; +#endif // _di_fss_read_extended_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_extended_common_h diff --git a/level_3/fss_read/c/extended/fss_read.c b/level_3/fss_read/c/extended/fss_read.c new file mode 100644 index 0000000..580efe8 --- /dev/null +++ b/level_3/fss_read/c/extended/fss_read.c @@ -0,0 +1,127 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_extended_process_content_ + void fss_read_extended_process_content(void * const void_main, const bool last) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.content) { + fl_fss_extended_content_write( + *main->setting.content, + main->setting.quote.used + ? main->setting.quote.string[0] + : f_fss_quote_double_s.string[0], + (main->setting.flag & fss_read_main_flag_partial_e) + ? f_fss_complete_partial_e + : last + ? f_fss_complete_end_e + : f_fss_complete_next_e, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_extended_content_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_close_s, &main->setting.buffer); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + else if (main->setting.flag & fss_read_main_flag_content_next_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_next_s, &main->setting.buffer); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_extended_process_content_ + +#ifndef _di_fss_read_extended_process_help_ + void fss_read_extended_process_help(void * const void_main) { + + if (!void_main) return; + + fss_read_extended_print_help(&((fss_read_main_t *) void_main)->program.message); + } +#endif // _di_fss_read_extended_process_help_ + +#ifndef _di_fss_read_extended_process_object_ + void fss_read_extended_process_object(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.object) { + fl_fss_extended_object_write( + *main->setting.object, + main->setting.quote.used + ? main->setting.quote.string[0] + : f_fss_quote_double_s.string[0], + (main->setting.flag & fss_read_main_flag_partial_e) + ? (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_extended_object_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_open_s, &main->setting.buffer); + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_extended_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/extended/fss_read.h b/level_3/fss_read/c/extended/fss_read.h new file mode 100644 index 0000000..e361c6c --- /dev/null +++ b/level_3/fss_read/c/extended/fss_read.h @@ -0,0 +1,114 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * This program provides FSS write functionality for the FSS-0001 Extended. + */ +#ifndef _fss_read_extended_h +#define _fss_read_extended_h + +// Libc includes. +#include +#include +#include +#include + +// FLL-0 includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// FLL-1 includes. +#include +#include +#include + +// FLL-2 includes. +#include +#include +#include + +// FSS Write includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Process a single Content, printing the FSS-0001 (Extended) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + * @param last + * If TRUE, then this is the last Content in the Content set. + * If FALSE, then this is not the last Content in the Content set. + */ +#ifndef _di_fss_read_extended_process_content_ + extern void fss_read_extended_process_content(void * const main, const bool last); +#endif // _di_fss_read_extended_process_content_ + +/** + * Process help for FSS-0001 (Extended). + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This does not alter main.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_read_extended_process_help_ + extern void fss_read_extended_process_help(void * const main); +#endif // _di_fss_read_extended_process_help_ + +/** + * Process a single Object, printing the FSS-0001 (Extended) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + */ +#ifndef _di_fss_read_extended_process_object_ + extern void fss_read_extended_process_object(void * const main); +#endif // _di_fss_read_extended_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_extended_h diff --git a/level_3/fss_read/c/extended/main.c b/level_3/fss_read/c/extended/main.c new file mode 100644 index 0000000..f0a733f --- /dev/null +++ b/level_3/fss_read/c/extended/main.c @@ -0,0 +1,84 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + fss_read_main_t data = fss_read_main_t_initialize; + + data.program.debug.flag |= fss_read_print_flag_debug_e | fss_read_print_flag_out_e; + data.program.error.flag |= fss_read_print_flag_error_e | fss_read_print_flag_out_e; + data.program.output.flag |= fss_read_print_flag_out_e; + data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; + data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; + data.program.debug.custom = (void *) &data; + data.program.message.custom = (void *) &data; + data.program.output.custom = (void *) &data; + data.program.warning.custom = (void *) &data; + + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_read_extended_standard_s; + data.setting.process_content = &fss_read_extended_process_content; + data.setting.process_help = &fss_read_extended_process_help; + data.setting.process_normal = &fss_read_process_normal; + data.setting.process_object = &fss_read_extended_process_object; + data.setting.process_pipe = &fss_read_process_pipe; + data.setting.process_set = &fss_read_process_set; + data.setting.flag |= fss_read_main_flag_content_multiple_e; + + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_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); + + f_file_umask_get(&data.program.umask); + + #ifdef _di_thread_support_ + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + fss_read_main(&data); + #else + { + f_thread_id_t id_signal; + + memset(&id_signal, 0, sizeof(f_thread_id_t)); + + data.setting.state.status = f_thread_create(0, &id_signal, &fss_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + fss_read_print_error(&data.program.error, macro_fss_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + if (!fss_read_signal_check(&data)) { + fss_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + fss_read_main_delete(&data); + + fll_program_standard_set_down(&data.program); + + return F_status_is_error(data.setting.state.status) ? 1 : 0; +} diff --git a/level_3/fss_read/c/extended/main.h b/level_3/fss_read/c/extended/main.h new file mode 100644 index 0000000..c4d5864 --- /dev/null +++ b/level_3/fss_read/c/extended/main.h @@ -0,0 +1,38 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_write" program functionality in some manner. + */ +#ifndef _fss_read_extended_main_h +#define _fss_read_extended_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_read_extended_main_h diff --git a/level_3/fss_read/c/extended/print.c b/level_3/fss_read/c/extended/print.c new file mode 100644 index 0000000..9975144 --- /dev/null +++ b/level_3/fss_read/c/extended/print.c @@ -0,0 +1,41 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_extended_print_help_ + f_status_t fss_read_extended_print_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_extended_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_extended_program_name_s, f_string_empty_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_end_next(print); + + fl_print_format("%r The FSS-0001 (Extended) specification does not support multi-line Content, therefore the parameter '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_prepend_s, print->set->notable); + fl_print_format(" does nothing.%r%r", print->to, f_string_eol_s, f_string_eol_s); + + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_extended_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/extended/print.h b/level_3/fss_read/c/extended/print.h new file mode 100644 index 0000000..de3b7e8 --- /dev/null +++ b/level_3/fss_read/c/extended/print.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + */ +#ifndef _fss_read_extended_print_h +#define _fss_read_extended_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print help for FSS-0001 (Extended). + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_extended_print_help_ + extern f_status_t fss_read_extended_print_help(fl_print_t * const print); +#endif // _di_fss_read_extended_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_extended_print_h diff --git a/level_3/fss_read/c/extended_list/common.c b/level_3/fss_read/c/extended_list/common.c new file mode 100644 index 0000000..d4bc37e --- /dev/null +++ b/level_3/fss_read/c/extended_list/common.c @@ -0,0 +1,21 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_extended_list_s_ + const f_string_static_t fss_read_extended_list_standard_s = macro_f_string_static_t_initialize_1(FSS_READ_extended_list_standard_s, 0, FSS_READ_extended_list_standard_s_length); + + const f_string_static_t fss_read_extended_list_program_name_s = macro_f_string_static_t_initialize_1(FSS_READ_extended_list_program_name_s, 0, FSS_READ_extended_list_program_name_s_length); + const f_string_static_t fss_read_extended_list_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_READ_extended_list_program_name_long_s, 0, FSS_READ_extended_list_program_name_long_s_length); + + const f_string_static_t fss_read_format_code_short_0003_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_short_0003_s, 0, FSS_READ_format_code_short_0003_s_length); + const f_string_static_t fss_read_format_code_long_0003_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_long_0003_s, 0, FSS_READ_format_code_long_0003_s_length); + const f_string_static_t fss_read_format_code_human_0003_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_human_0003_s, 0, FSS_READ_format_code_human_0003_s_length); + const f_string_static_t fss_read_format_code_machine_0003_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_machine_0003_s, 0, FSS_READ_format_code_machine_0003_s_length); +#endif // _di_fss_read_extended_list_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/extended_list/common.h b/level_3/fss_read/c/extended_list/common.h new file mode 100644 index 0000000..7663d52 --- /dev/null +++ b/level_3/fss_read/c/extended_list/common.h @@ -0,0 +1,58 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_extended_list_common_h +#define _fss_read_extended_list_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The FSS-0001 (Extended List) specific strings. + */ +#ifndef _di_fss_read_extended_list_s_ + #define FSS_READ_extended_list_standard_s "FSS-0003 (Extended List)" + + #define FSS_READ_extended_list_program_name_s "fss_extended_list_read" + #define FSS_READ_extended_list_program_name_long_s "FSS Extended List Read" + + #define FSS_READ_format_code_short_0003_s "0003" + #define FSS_READ_format_code_long_0003_s "fss-0003" + #define FSS_READ_format_code_human_0003_s "extended list" + #define FSS_READ_format_code_machine_0003_s "extended_list" + + #define FSS_READ_extended_list_standard_s_length 24 + + #define FSS_READ_extended_list_program_name_s_length 22 + #define FSS_READ_extended_list_program_name_long_s_length 22 + + #define FSS_READ_format_code_short_0003_s_length 4 + #define FSS_READ_format_code_long_0003_s_length 8 + #define FSS_READ_format_code_human_0003_s_length 13 + #define FSS_READ_format_code_machine_0003_s_length 13 + + extern const f_string_static_t fss_read_extended_list_standard_s; + + extern const f_string_static_t fss_read_extended_list_program_name_s; + extern const f_string_static_t fss_read_extended_list_program_name_long_s; + + extern const f_string_static_t fss_read_format_code_short_0003_s; + extern const f_string_static_t fss_read_format_code_long_0003_s; + extern const f_string_static_t fss_read_format_code_human_0003_s; + extern const f_string_static_t fss_read_format_code_machine_0003_s; +#endif // _di_fss_read_extended_list_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_extended_list_common_h diff --git a/level_3/fss_read/c/extended_list/fss_read.c b/level_3/fss_read/c/extended_list/fss_read.c new file mode 100644 index 0000000..e3f18e7 --- /dev/null +++ b/level_3/fss_read/c/extended_list/fss_read.c @@ -0,0 +1,125 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_extended_list_process_content_ + void fss_read_extended_list_process_content(void * const void_main, const bool last) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.content) { + fl_fss_extended_list_content_write( + *main->setting.content, + (main->setting.flag & fss_read_main_flag_partial_e) + ? last + ? f_fss_complete_none_e + : f_fss_complete_partial_e + : f_fss_complete_full_e, + &main->setting.prepend, + main->setting.ignores, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_extended_list_content_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_close_s, &main->setting.buffer); + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_close_end_s, &main->setting.buffer); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_extended_list_process_content_ + +#ifndef _di_fss_read_extended_list_process_help_ + void fss_read_extended_list_process_help(void * const void_main) { + + if (!void_main) return; + + fss_read_extended_list_print_help(&((fss_read_main_t *) void_main)->program.message); + } +#endif // _di_fss_read_extended_list_process_help_ + +#ifndef _di_fss_read_extended_list_process_object_ + void fss_read_extended_list_process_object(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (main->setting.object) { + fl_fss_extended_list_object_write( + *main->setting.object, + (main->setting.flag & fss_read_main_flag_partial_e) + ? (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_extended_list_object_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_open_s, &main->setting.buffer); + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_extended_list_open_end_s, &main->setting.buffer); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + } + } + } +#endif // _di_fss_read_extended_list_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/extended_list/fss_read.h b/level_3/fss_read/c/extended_list/fss_read.h new file mode 100644 index 0000000..eb22841 --- /dev/null +++ b/level_3/fss_read/c/extended_list/fss_read.h @@ -0,0 +1,114 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * This program provides FSS write functionality for the FSS-0003 Extended List. + */ +#ifndef _fss_read_extended_list_h +#define _fss_read_extended_list_h + +// Libc includes. +#include +#include +#include +#include + +// FLL-0 includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// FLL-1 includes. +#include +#include +#include + +// FLL-2 includes. +#include +#include +#include + +// FSS Write includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Process a single Content, printing the FSS-0003 (Extended List) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + * @param last + * If TRUE, then this is the last Content in the Content set. + * If FALSE, then this is not the last Content in the Content set. + */ +#ifndef _di_fss_read_extended_list_process_content_ + extern void fss_read_extended_list_process_content(void * const main, const bool last); +#endif // _di_fss_read_extended_list_process_content_ + +/** + * Process help for FSS-0003 (Extended List). + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This does not alter main.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_read_extended_list_process_help_ + extern void fss_read_extended_list_process_help(void * const main); +#endif // _di_fss_read_extended_list_process_help_ + +/** + * Process a single Object, printing the FSS-0003 (Extended List) if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status. + * This uses and alters main.setting.buffer. + */ +#ifndef _di_fss_read_extended_list_process_object_ + extern void fss_read_extended_list_process_object(void * const main); +#endif // _di_fss_read_extended_list_process_object_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_extended_list_h diff --git a/level_3/fss_read/c/extended_list/main.c b/level_3/fss_read/c/extended_list/main.c new file mode 100644 index 0000000..87cd830 --- /dev/null +++ b/level_3/fss_read/c/extended_list/main.c @@ -0,0 +1,84 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + fss_read_main_t data = fss_read_main_t_initialize; + + data.program.debug.flag |= fss_read_print_flag_debug_e | fss_read_print_flag_out_e; + data.program.error.flag |= fss_read_print_flag_error_e | fss_read_print_flag_out_e; + data.program.output.flag |= fss_read_print_flag_out_e; + data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; + data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; + data.program.debug.custom = (void *) &data; + data.program.message.custom = (void *) &data; + data.program.output.custom = (void *) &data; + data.program.warning.custom = (void *) &data; + + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_read_extended_list_standard_s; + data.setting.process_content = &fss_read_extended_list_process_content; + data.setting.process_help = &fss_read_extended_list_process_help; + data.setting.process_normal = &fss_read_process_normal; + data.setting.process_object = &fss_read_extended_list_process_object; + data.setting.process_pipe = &fss_read_process_pipe; + data.setting.process_set = &fss_read_process_set; + data.setting.flag |= fss_read_main_flag_ignore_e; + + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_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); + + f_file_umask_get(&data.program.umask); + + #ifdef _di_thread_support_ + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + fss_read_main(&data); + #else + { + f_thread_id_t id_signal; + + memset(&id_signal, 0, sizeof(f_thread_id_t)); + + data.setting.state.status = f_thread_create(0, &id_signal, &fss_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + fss_read_print_error(&data.program.error, macro_fss_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + if (!fss_read_signal_check(&data)) { + fss_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + fss_read_main_delete(&data); + + fll_program_standard_set_down(&data.program); + + return F_status_is_error(data.setting.state.status) ? 1 : 0; +} diff --git a/level_3/fss_read/c/extended_list/main.h b/level_3/fss_read/c/extended_list/main.h new file mode 100644 index 0000000..916a48b --- /dev/null +++ b/level_3/fss_read/c/extended_list/main.h @@ -0,0 +1,38 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_list_write" program functionality in some manner. + */ +#ifndef _fss_read_extended_list_main_h +#define _fss_read_extended_list_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_read_extended_list_main_h diff --git a/level_3/fss_read/c/extended_list/print.c b/level_3/fss_read/c/extended_list/print.c new file mode 100644 index 0000000..7170b6e --- /dev/null +++ b/level_3/fss_read/c/extended_list/print.c @@ -0,0 +1,44 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_extended_list_print_help_ + f_status_t fss_read_extended_list_print_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_extended_list_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_extended_list_program_name_s, f_string_empty_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_end_next(print); + + fl_print_format("%r The FSS-0003 (Extended List) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_single_s, print->set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" The parameter '%[%r%r%]' designates to not escape any valid nested Object or Content within some Content.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + fl_print_format(" This parameter is not used for ignoring anything from the input pipe.%r", print->to, f_string_eol_s); + fl_print_format(" This parameter must be specified after a '%[%r%r%]'", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_content_s, print->set->notable); + fl_print_format(" parameter and this applies only to the Content represented by that specific '%[%r%r%]' parameter.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_content_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_read_extended_list_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/extended_list/print.h b/level_3/fss_read/c/extended_list/print.h new file mode 100644 index 0000000..aef9744 --- /dev/null +++ b/level_3/fss_read/c/extended_list/print.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + */ +#ifndef _fss_read_extended_list_print_h +#define _fss_read_extended_list_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print help for FSS-0003 (Extended List). + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_extended_list_print_help_ + extern f_status_t fss_read_extended_list_print_help(fl_print_t * const print); +#endif // _di_fss_read_extended_list_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_extended_list_print_h diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c new file mode 100644 index 0000000..f45451f --- /dev/null +++ b/level_3/fss_read/c/main/common.c @@ -0,0 +1,740 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_setting_load_ + void fss_read_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main, void (*callback)(const f_console_arguments_t arguments, fss_read_main_t * const main)) { + + if (!main) return; + + main->setting.state.step_small = fss_read_allocation_console_d; + + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + + main->setting.state.step_small = fss_read_allocation_small_d; + + // Identify and pocess first/last parameters. + if (main->program.parameters.array[fss_read_parameter_line_first_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_read_main_flag_print_first_e; + } + else { + main->setting.flag |= fss_read_main_flag_print_first_e; + } + + if (main->program.parameters.array[fss_read_parameter_line_last_no_e].result & f_console_result_found_e) { + main->setting.flag -= main->setting.flag & fss_read_main_flag_print_last_e; + } + else { + main->setting.flag |= fss_read_main_flag_print_last_e; + } + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(f_console_parameter_process)); + + return; + } + + { + f_uint16s_t choices = f_uint16s_t_initialize; + + // Identify and prioritize "color context" parameters. + { + uint16_t choices_array[3] = { fss_read_parameter_no_color_e, fss_read_parameter_light_e, fss_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 }; + + main->setting.state.status = fll_program_parameter_process_context(choices, modes, F_true, &main->program); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(fll_program_parameter_process_context)); + + return; + } + } + + // Identify and prioritize "verbosity" parameters. + { + uint16_t choices_array[5] = { fss_read_parameter_verbosity_quiet_e, fss_read_parameter_verbosity_error_e, fss_read_parameter_verbosity_verbose_e, fss_read_parameter_verbosity_debug_e, fss_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 }; + + main->setting.state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, &main->program); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(fll_program_parameter_process_verbosity)); + + 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_read_parameter_help_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_help_e; + } + + if (main->program.parameters.array[fss_read_parameter_version_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_version_e; + } + + if (main->program.parameters.array[fss_read_parameter_copyright_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_copyright_e; + } + + if (callback) { + callback(arguments, main); + if (F_status_is_error(main->setting.state.status)) return; + + if (main->setting.state.status == F_done) { + main->setting.state.status = F_none; + + return; + } + } + + if (main->program.parameters.array[fss_read_parameter_help_e].result & f_console_result_found_e) return; + if (main->program.parameters.array[fss_read_parameter_version_e].result & f_console_result_found_e) return; + + if ((main->program.parameters.array[fss_read_parameter_file_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_file_e].values.used) { + if (main->program.parameters.array[fss_read_parameter_file_e].values.used > 1) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_must_specify_once(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_file_s); + + return; + } + + const f_array_length_t index = main->program.parameters.array[fss_read_parameter_file_e].values.array[0]; + + main->program.output.to.id = -1; + main->program.output.to.stream = 0; + + main->setting.state.status = f_file_stream_open(main->program.parameters.arguments.array[index], f_string_empty_s, &main->program.output.to); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error_file(&main->program.error, macro_fss_read_f(f_file_stream_open), main->program.parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + + return; + } + + main->setting.flag |= fss_read_main_flag_file_to_e; + } + else if (main->program.parameters.array[fss_read_parameter_file_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_file_s); + + return; + } + + if ((main->program.parameters.array[fss_read_parameter_object_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_object_e].values.used) { + f_array_lengths_t * const values = &main->program.parameters.array[fss_read_parameter_object_e].values; + + main->setting.objects.used = 0; + + main->setting.state.status = f_string_dynamics_resize(values->used, &main->setting.objects); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_resize)); + + return; + } + + // Construct the array without allocating any more memory for the string data by setting this as a static string (used > 0, size = 0). + for (f_array_length_t index = 0; main->setting.objects.used < values->used; ) { + + index = values->array[main->setting.objects.used]; + + main->setting.objects.array[main->setting.objects.used].string = main->program.parameters.arguments.array[index].string; + main->setting.objects.array[main->setting.objects.used].used = main->program.parameters.arguments.array[index].used; + main->setting.objects.array[main->setting.objects.used++].size = 0; + } // for + + main->setting.flag |= fss_read_main_flag_object_e; + } + else if (main->program.parameters.array[fss_read_parameter_object_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_object_s); + + return; + } + + if ((main->program.parameters.array[fss_read_parameter_content_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_content_e].values.used) { + + if (main->setting.flag & fss_read_main_flag_object_e) { + if (!(main->setting.flag & fss_read_main_flag_content_multiple_e)) { + if (main->program.parameters.array[fss_read_parameter_content_e].values.used > main->program.parameters.array[fss_read_parameter_object_e].values.used) { + main->setting.state.status = F_status_set_error(F_support_not); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error_one_content_only(&main->program.error); + + return; + } + } + } + + f_array_length_t stub_object_array[1] = { 0 }; + f_array_lengths_t stub_object = macro_f_array_lengths_t_initialize_1(stub_object_array, 0, 1); + + f_array_lengths_t * const values_content = &main->program.parameters.array[fss_read_parameter_content_e].values; + f_array_lengths_t * const values_object = main->program.parameters.array[fss_read_parameter_object_e].values.used + ? &main->program.parameters.array[fss_read_parameter_object_e].values + : &stub_object; + + main->setting.contentss.used = 0; + + main->setting.state.status = f_string_dynamicss_increase_by(values_object->used, &main->setting.contentss); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamicss_increase_by)); + + return; + } + + f_array_length_t i = 0; // For Contents. + f_array_length_t j = 0; // For Objects. + f_array_length_t k = 0; + f_array_length_t total = 0; + f_array_length_t index = 0; + + // Construct the array without allocating any more memory for the string data by setting this as a static string (used > 0, size = 0). + while (i < values_content->used) { + + // Determine the total Content associated with the given Object. + for (total = 0; i + total < values_content->used && (j + 1 >= values_object->used || values_content->array[i + total] < values_object->array[j + 1]); ++total) { + // Do nothing. + } // for + + + if (!total) { + ++main->setting.contentss.used; + + if (++j < values_object->used) continue; + + break; + } + + main->setting.state.status = f_string_dynamics_increase_by(total, &main->setting.contentss.array[j]); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase_by)); + + return; + } + + for (k = 0; k < total; ++k) { + + index = values_content->array[i++]; + + main->setting.contentss.array[j].array[main->setting.contentss.array[j].used].string = main->program.parameters.arguments.array[index].string; + main->setting.contentss.array[j].array[main->setting.contentss.array[j].used].used = main->program.parameters.arguments.array[index].used; + main->setting.contentss.array[j].array[main->setting.contentss.array[j].used++].size = 0; + } // for + } // while + + if (total) { + ++main->setting.contentss.used; + } + + main->setting.flag |= fss_read_main_flag_content_e; + } + else if (main->program.parameters.array[fss_read_parameter_content_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_content_s); + + return; + } + + if ((main->program.parameters.array[fss_read_parameter_prepend_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_prepend_e].values.used) { + const f_array_length_t index = main->program.parameters.array[fss_read_parameter_prepend_e].values.array[main->program.parameters.array[fss_read_parameter_prepend_e].values.used - 1]; + + main->setting.prepend.used = 0; + + main->setting.state.status = f_string_dynamic_append_nulless(main->program.parameters.arguments.array[index], &main->setting.prepend); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append_nulless)); + + return; + } + + if (main->program.parameters.arguments.array[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize_2(main->program.parameters.arguments.array[index].used); + + for (; range.start < main->program.parameters.arguments.array[index].used; range.start++) { + + if (f_fss_is_space(main->program.parameters.arguments.array[index], range, &main->setting.state) == F_false) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_fss_is_space)); + } + else { + main->setting.state.status = F_status_set_error(F_parameter); + + fss_read_print_error_prepend_only_whitespace(&main->program.error); + } + + return; + } + } // for + } + + main->setting.flag |= fss_read_main_flag_prepend_e; + } + else if (main->program.parameters.array[fss_read_parameter_prepend_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_prepend_s); + + return; + } + + if ((main->program.parameters.array[fss_read_parameter_ignore_e].result & f_console_result_value_e) && main->program.parameters.array[fss_read_parameter_ignore_e].values.used) { + if (main->program.parameters.array[fss_read_parameter_ignore_e].values.used % 2 != 0) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, fss_read_string_two_s); + + return; + } + + // Only process if the standard designates that the ingore is supported. + if (main->setting.flag & fss_read_main_flag_ignore_e) { + f_array_length_t stub_data_array[1] = { 0 }; + f_array_lengths_t stub_data = macro_f_array_lengths_t_initialize_1(stub_data_array, 0, 1); + + f_array_lengths_t * const values_ignore = &main->program.parameters.array[fss_read_parameter_ignore_e].values; + f_array_lengths_t * const values_data = main->program.parameters.array[fss_read_parameter_object_e].values.used + ? &main->program.parameters.array[fss_read_parameter_object_e].values + : main->program.parameters.array[fss_read_parameter_content_e].values.used + ? &main->program.parameters.array[fss_read_parameter_content_e].values + : &stub_data; + + main->setting.ignoress.used = 0; + + main->setting.state.status = f_string_rangess_increase_by(values_data->used, &main->setting.ignoress); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_rangess_increase_by)); + + return; + } + + f_array_length_t i = 0; // For Ignores. + f_array_length_t j = 0; // For Objects/Contents. + f_array_length_t k = 0; + f_array_length_t total = 0; + f_array_length_t index = 0; + + // Construct the array without allocating any more memory for the string data by setting this as a static string (used > 0, size = 0). + while (i < values_ignore->used) { + + // Determine the total Ignore associated with the given Object/Content. + for (total = 0; i + total < values_ignore->used && (j + 1 >= values_data->used || values_ignore->array[i + total] < values_data->array[j + 1]); ++total) { + // Do nothing. + } // for + + if (!total) { + ++main->setting.ignoress.used; + + if (++j < values_data->used) continue; + + break; + } + + main->setting.state.status = f_string_ranges_increase_by(total, &main->setting.ignoress.array[j]); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_ranges_increase_by)); + + return; + } + + for (k = 0; k < total; ++k) { + + index = values_ignore->array[i++]; + + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].start); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, main->program.parameters.arguments.array[index]); + + return; + } + + index = values_ignore->array[i++]; + + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].stop); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, main->program.parameters.arguments.array[index]); + + return; + } + + if (main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].stop > main->setting.ignoress.array[j].array[main->setting.ignoress.array[j].used].start) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_range_start_before_stop( + &main->program.error, + f_console_symbol_long_normal_s, + fss_read_long_ignore_s, + main->program.parameters.arguments.array[values_ignore->array[i - 1]], + main->program.parameters.arguments.array[index] + ); + + return; + } + + ++main->setting.ignoress.array[j].used; + } // for + } // while + + if (total) { + ++main->setting.ignoress.used; + } + } + else { + + // Still validate the parameters, even if not being used. + f_array_length_t i = 0; + f_array_length_t index = 0; + f_string_range_t number = f_string_range_t_initialize; + + while (i < main->program.parameters.array[fss_read_parameter_ignore_e].values.used) { + + index = main->program.parameters.array[fss_read_parameter_ignore_e].values.array[i++]; + + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number.start); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, main->program.parameters.arguments.array[index]); + + return; + } + + index = main->program.parameters.array[fss_read_parameter_ignore_e].values.array[i++]; + + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &number.stop); + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s, main->program.parameters.arguments.array[index]); + + return; + } + + if (number.start > number.stop) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_range_start_before_stop( + &main->program.error, + f_console_symbol_long_normal_s, + fss_read_long_ignore_s, + main->program.parameters.arguments.array[main->program.parameters.array[fss_read_parameter_ignore_e].values.array[i - 1]], + main->program.parameters.arguments.array[index] + ); + + return; + } + } // while + } + } + else if (main->program.parameters.array[fss_read_parameter_ignore_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_ignore_s); + + return; + } + else { + + // There is no Object or Content, so remove ignores if set. + if (main->setting.flag & fss_read_main_flag_ignore_e) { + main->setting.flag -= fss_read_main_flag_ignore_e; + } + } + + if (main->program.parameters.array[fss_read_parameter_partial_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_partial_e; + } + + { + const uint32_t has[] = { + fss_read_parameter_content_end_e, + fss_read_parameter_content_next_e, + fss_read_parameter_object_open_e, + }; + + const uint16_t has_flag[] = { + fss_read_main_flag_content_end_e, + fss_read_main_flag_content_next_e, + fss_read_main_flag_object_open_e, + }; + + const f_string_static_t has_string[] = { + fss_read_long_content_end_s, + fss_read_long_content_next_s, + fss_read_long_object_open_s, + }; + + const uint16_t has_cannots[][2] = { + { fss_read_parameter_content_next_e, fss_read_parameter_object_open_e }, + { fss_read_parameter_content_end_e, fss_read_parameter_object_open_e }, + { fss_read_parameter_content_end_e, fss_read_parameter_content_next_e }, + }; + + const f_string_static_t has_cannots_string[][2] = { + { fss_read_long_content_next_s, fss_read_long_object_open_s }, + { fss_read_long_content_end_s, fss_read_long_object_open_s }, + { fss_read_long_content_end_s, fss_read_long_content_next_s }, + }; + + for (uint8_t i = 0; i < 3; ++i) { + + if (main->program.parameters.array[has[i]].result & f_console_result_found_e) { + if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e)) { + if (!(main->setting.flag & fss_read_main_flag_partial_e)) { + main->setting.state.status = F_status_set_error(F_parameter); + + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error.to); + } + + fll_program_print_error_parameter_cannot_use_with_without( + &main->program.error, + f_console_symbol_long_normal_s, + f_console_symbol_long_normal_s, + f_console_symbol_long_normal_s, + has_string[i], + (main->setting.flag & fss_read_main_flag_object_e) + ? fss_read_long_object_s + : fss_read_long_content_s, + fss_read_long_partial_s + ); + + return; + } + } + + if (main->program.parameters.array[has_cannots[i][0]].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][0]); + + return; + } + + if (main->program.parameters.array[has_cannots[i][1]].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, has_string[i], has_cannots_string[i][1]); + + return; + } + + main->setting.flag |= has_flag[i]; + } + } // for + } + + if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e)) { + if (main->setting.flag & fss_read_main_flag_object_e) { + if (main->setting.flag & fss_read_main_flag_content_multiple_e) { + if (main->program.parameters.array[fss_read_parameter_object_e].locations_sub.used > main->program.parameters.array[fss_read_parameter_content_e].locations_sub.used && !(main->setting.flag & fss_read_main_flag_partial_e)) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fss_read_print_error_parameter_same_times_at_least(&main->program.error); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_content_e) && (main->setting.flag & fss_read_main_flag_partial_e)) { + if (main->program.parameters.array[fss_read_parameter_content_e].result & f_console_result_value_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + fll_program_print_error_parameter_cannot_use_with_xor(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, fss_read_long_partial_s, fss_read_long_object_s, fss_read_long_content_s); + + return; + } + } + } + } + + main->setting.quote = f_fss_quote_double_s; + + if (main->program.parameters.array[fss_read_parameter_double_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_read_parameter_single_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_read_parameter_double_e].location < main->program.parameters.array[fss_read_parameter_single_e].location) { + main->setting.quote = f_fss_quote_single_s; + + if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_read_parameter_single_e].location < main->program.parameters.array[fss_read_parameter_backtick_e].location) { + main->setting.quote = f_fss_quote_backtick_s; + } + } + } + else if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_read_parameter_double_e].location < main->program.parameters.array[fss_read_parameter_backtick_e].location) { + main->setting.quote = f_fss_quote_backtick_s; + } + } + } + else if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_read_parameter_double_e].location < main->program.parameters.array[fss_read_parameter_backtick_e].location) { + main->setting.quote = f_fss_quote_backtick_s; + } + } + } + else if (main->program.parameters.array[fss_read_parameter_single_e].result & f_console_result_found_e) { + main->setting.quote = f_fss_quote_single_s; + + if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { + if (main->program.parameters.array[fss_read_parameter_single_e].location < main->program.parameters.array[fss_read_parameter_backtick_e].location) { + main->setting.quote = f_fss_quote_backtick_s; + } + } + } + else if (main->program.parameters.array[fss_read_parameter_backtick_e].result & f_console_result_found_e) { + main->setting.quote = f_fss_quote_backtick_s; + } + + if (main->program.parameters.array[fss_read_parameter_trim_e].result & f_console_result_found_e) { + main->setting.flag |= fss_read_main_flag_trim_e; + } + + if (!(main->setting.flag & (fll_program_data_pipe_input_e | fss_read_main_flag_content_e | fss_read_parameter_object_e))) { + main->setting.state.status = F_data_not; + } + } +#endif // _di_fss_read_setting_load_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/common.h b/level_3/fss_read/c/main/common.h new file mode 100644 index 0000000..c7324e0 --- /dev/null +++ b/level_3/fss_read/c/main/common.h @@ -0,0 +1,63 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_common_h +#define _fss_read_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * 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. + * F_data_not on success but nothing was provided to operate with. + * + * F_parameter (with error bit) on parameter error. + * + * Errors (with error bit) from: f_console_parameter_process(). + * Errors (with error bit) from: f_file_stream_open(). + * Errors (with error bit) from: f_string_dynamics_resize(). + * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_verbosity(). + * @param callback + * (optional) Designate a function to call after performing the initial processing, but before printing help. + * If the function returns F_done, then this function immediately returns, resetting status to F_none. + * Set to NULL to disable. + * + * @see f_console_parameter_process() + * @see f_file_stream_open() + * @see f_string_dynamics_resize() + * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_verbosity() + */ +#ifndef _di_fss_read_setting_load_ + extern void fss_read_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main, void (*callback)(const f_console_arguments_t arguments, fss_read_main_t * const main)); +#endif // _di_fss_read_setting_load_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_common_h diff --git a/level_3/fss_read/c/main/common/define.c b/level_3/fss_read/c/main/common/define.c new file mode 100644 index 0000000..69d4cff --- /dev/null +++ b/level_3/fss_read/c/main/common/define.c @@ -0,0 +1,9 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/common/define.h b/level_3/fss_read/c/main/common/define.h new file mode 100644 index 0000000..e192d83 --- /dev/null +++ b/level_3/fss_read/c/main/common/define.h @@ -0,0 +1,55 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_common_define_h +#define _fss_read_common_define_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The program allocation defines. + * + * fss_read_allocation_*_d: + * - console: An allocation step used for small buffers specifically for console parameter. + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - pipe: A buffer size used for processing piped data. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_read_allocation_d_ + #define fss_read_allocation_console_d 4 + #define fss_read_allocation_large_d 2048 + #define fss_read_allocation_pipe_d 16384 + #define fss_read_allocation_small_d 128 +#endif // _di_fss_read_allocation_d_ + +/** + * The program signal defines. + * + * fss_read_signal_*_d: + * - check: Number of iterations before performing signal check in non-threaded signal handling. + * - check_failsafe: When using threads, how many consecutive failures to check signal before aborting (as a recursion failsafe). + * - check_tiny: The tiny check. + * - check_short: The short signal check. + */ +#ifndef _di_fss_read_signal_d_ + #define fss_read_signal_check_d 500000 + #define fss_read_signal_check_failsafe_d 20000 + #define fss_read_signal_check_tiny_d 4 + #define fss_read_signal_check_short_d 16 +#endif // _di_fss_read_signal_d_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_common_define_h diff --git a/level_3/fss_read/c/main/common/enumeration.c b/level_3/fss_read/c/main/common/enumeration.c new file mode 100644 index 0000000..69d4cff --- /dev/null +++ b/level_3/fss_read/c/main/common/enumeration.c @@ -0,0 +1,9 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/common/enumeration.h b/level_3/fss_read/c/main/common/enumeration.h new file mode 100644 index 0000000..639c750 --- /dev/null +++ b/level_3/fss_read/c/main/common/enumeration.h @@ -0,0 +1,130 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common enumeration structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_common_enumeration_h +#define _fss_read_common_enumeration_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Flags passed to the main function or program. + * + * fss_read_main_flag_*_e: + * - none: No flags set. + * - copyright: Print copyright. + * - help: Print help. + * - 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. + * - trim: Trim Object names. + * - version: Print version. + */ +#ifndef _di_fss_read_main_flag_e_ + enum { + fss_read_main_flag_none_e = 0x0, + fss_read_main_flag_copyright_e = 0x10, + fss_read_main_flag_help_e = 0x40, + fss_read_main_flag_print_first_e = 0x1000, + fss_read_main_flag_print_last_e = 0x2000, + fss_read_main_flag_trim_e = 0x4000, + fss_read_main_flag_version_e = 0x8000, + }; // enum +#endif // _di_fss_read_main_flag_e_ + +/** + * The main program parameters. + */ +#ifndef _di_fss_read_parameter_e_ + enum { + fss_read_parameter_help_e, + fss_read_parameter_copyright_e, + fss_read_parameter_light_e, + fss_read_parameter_dark_e, + fss_read_parameter_no_color_e, + fss_read_parameter_verbosity_quiet_e, + fss_read_parameter_verbosity_error_e, + fss_read_parameter_verbosity_normal_e, + fss_read_parameter_verbosity_verbose_e, + fss_read_parameter_verbosity_debug_e, + fss_read_parameter_version_e, + fss_read_parameter_line_first_no_e, + fss_read_parameter_line_last_no_e, + + fss_read_parameter_at_e, + fss_read_parameter_content_e, + fss_read_parameter_columns_e, + fss_read_parameter_delimit_e, + fss_read_parameter_depth_e, + fss_read_parameter_empty_e, + fss_read_parameter_line_e, + fss_read_parameter_name_e, + fss_read_parameter_object_e, + fss_read_parameter_pipe_e, + fss_read_parameter_original_e, + fss_read_parameter_select_e, + fss_read_parameter_total_e, + fss_read_parameter_trim_e, + }; // enum + + #define fss_read_console_parameter_t_initialize \ + { \ + macro_fll_program_console_parameter_standard_initialize, \ + \ + macro_f_console_parameter_t_initialize_3(fss_read_short_at_s, fss_read_long_at_s, 0, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_content_s, fss_read_long_content_s, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_columns_s, fss_read_long_columns_s, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_delimit_s, fss_read_long_delimit_s, 0, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_depth_s, fss_read_long_depth_s, 0, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_empty_s, fss_read_long_empty_s, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_line_s, fss_read_long_line_s, 0, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_name_s, fss_read_long_name_s, 0, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_object_s, fss_read_long_object_s, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_pipe_s, fss_read_long_pipe_s, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_original_s, fss_read_long_original_s, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_select_s, fss_read_long_select_s, 0, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_total_s, fss_read_long_total_s, 0, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_trim_s, fss_read_long_trim_s, 0, 0, f_console_flag_normal_e), \ + } + + #define fss_read_total_parameters_d 27 +#endif // _di_fss_read_parameter_e_ + +/** + * Flags for fine-tuned print control. + * + * fss_read_print_flag_*_e: + * - none: No flags set. + * - debug: Stream is for debug printing. + * - error: Stream is for error printing. + * - in: Stream is a source file. + * - message: Stream is for message printing. + * - out: Stream is a destination file. + * - warning: Stream is for warning printing. + */ +#ifndef _di_fss_read_print_flag_e_ + enum { + fss_read_print_flag_none_e = 0x0, + fss_read_print_flag_debug_e = 0x1, + fss_read_print_flag_error_e = 0x2, + fss_read_print_flag_file_e = 0x4, + fss_read_print_flag_in_e = 0x8, + fss_read_print_flag_out_e = 0x10, + fss_read_print_flag_message_e = 0x20, + fss_read_print_flag_warning_e = 0x40, + }; // enum +#endif // _di_fss_read_print_flag_e_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_common_enumeration_h diff --git a/level_3/fss_read/c/main/common/print.c b/level_3/fss_read/c/main/common/print.c new file mode 100644 index 0000000..65862b9 --- /dev/null +++ b/level_3/fss_read/c/main/common/print.c @@ -0,0 +1,46 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_f_a_ + const f_string_t fss_read_f_a[] = { + "f_console_parameter_process", + "f_file_read_block", + "f_file_stream_open", + "f_fss_is_space", + "f_string_dynamic_append", + "f_string_dynamic_append_nulless", + "f_string_dynamic_increase_by", + "f_string_dynamics_increase", + "f_string_dynamics_increase_by", + "f_string_dynamics_resize", + "f_string_dynamicss_increase", + "f_string_dynamicss_increase_by", + "f_string_ranges_increase", + "f_string_ranges_increase_by", + "f_string_rangess_increase", + "f_string_rangess_increase_by", + "f_string_read_block_increase", + "f_thread_create", + "fl_fss_basic_content_read", + "fl_fss_basic_list_content_read", + "fl_fss_basic_list_object_read", + "fl_fss_basic_object_read", + "fl_fss_embedded_list_content_read", + "fl_fss_embedded_list_object_read", + "fl_fss_extended_content_read", + "fl_fss_extended_list_content_read", + "fl_fss_extended_list_object_read", + "fl_fss_extended_object_read", + "fl_fss_payload_content_read", + "fll_program_parameter_process_context", + "fll_program_parameter_process_verbosity", + "fll_fss_payload_read", + }; +#endif // _di_fss_read_f_a_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/common/print.h b/level_3/fss_read/c/main/common/print.h new file mode 100644 index 0000000..f55bb14 --- /dev/null +++ b/level_3/fss_read/c/main/common/print.h @@ -0,0 +1,81 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common print functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_common_print_h +#define _fss_read_common_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A special array of strings intended for representing funciton names. + * + * These are primarily used for printing errors with the function names. + * + * The macro macro_fss_read_f() is used to reference the array index by the enum name. + * + * macro_fss_read_f(): + * - name: The name of the function. + */ +#ifndef _di_fss_read_f_a_ + extern const f_string_t fss_read_f_a[]; + + #define macro_fss_read_f(name) fss_read_f_a[fss_read_f_##name##_e] +#endif // _di_fss_read_f_a_ + +/** + * An enum representing specific indexes within the above array. + * + * This is a convenience enum used to make code slightly more readable. + */ +#ifndef _di_fss_read_f_e_ + enum { + fss_read_f_f_console_parameter_process_e, + fss_read_f_f_file_read_block_e, + fss_read_f_f_file_stream_open_e, + fss_read_f_f_fss_is_space_e, + fss_read_f_f_string_dynamic_append_e, + fss_read_f_f_string_dynamic_append_nulless_e, + fss_read_f_f_string_dynamic_increase_by_e, + fss_read_f_f_string_dynamics_increase_e, + fss_read_f_f_string_dynamics_increase_by_e, + fss_read_f_f_string_dynamics_resize_e, + fss_read_f_f_string_dynamicss_increase_e, + fss_read_f_f_string_dynamicss_increase_by_e, + fss_read_f_f_string_ranges_increase_e, + fss_read_f_f_string_ranges_increase_by_e, + fss_read_f_f_string_rangess_increase_e, + fss_read_f_f_string_rangess_increase_by_e, + fss_read_f_f_string_read_block_increase_e, + fss_read_f_f_thread_create_e, + fss_read_f_fl_fss_basic_content_read_e, + fss_read_f_fl_fss_basic_list_content_read_e, + fss_read_f_fl_fss_basic_list_object_read_e, + fss_read_f_fl_fss_basic_object_read_e, + fss_read_f_fl_fss_embedded_list_content_read_e, + fss_read_f_fl_fss_embedded_list_object_read_e, + fss_read_f_fl_fss_extended_content_read_e, + fss_read_f_fl_fss_extended_list_content_read_e, + fss_read_f_fl_fss_extended_list_object_read_e, + fss_read_f_fl_fss_extended_object_read_e, + fss_read_f_fl_fss_payload_content_read_e, + fss_read_f_fll_program_parameter_process_context_e, + fss_read_f_fll_program_parameter_process_verbosity_e, + fss_read_f_fll_fss_payload_read_e, + }; // enum +#endif // _di_fss_read_f_e_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_common_print_h diff --git a/level_3/fss_read/c/main/common/string.c b/level_3/fss_read/c/main/common/string.c new file mode 100644 index 0000000..77e6753 --- /dev/null +++ b/level_3/fss_read/c/main/common/string.c @@ -0,0 +1,60 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_program_version_s_ + const f_string_static_t fss_read_program_version_s = macro_f_string_static_t_initialize_1(FSS_READ_program_version_s, 0, FSS_READ_program_version_s_length); +#endif // _di_fss_read_program_version_s_ + +#ifndef _di_fss_read_program_name_s_ + const f_string_static_t fss_read_program_name_s = macro_f_string_static_t_initialize_1(FSS_READ_program_name_s, 0, FSS_READ_program_name_s_length); + const f_string_static_t fss_read_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_READ_program_name_long_s, 0, FSS_READ_program_name_long_s_length); +#endif // _di_fss_read_program_name_s_ + +#ifndef _di_fss_read_pipe_s_ + const f_string_static_t fss_read_pipe_content_end_s = macro_f_string_static_t_initialize_1(FSS_READ_pipe_content_end_s, 0, FSS_READ_pipe_content_end_s_length); + const f_string_static_t fss_read_pipe_content_ignore_s = macro_f_string_static_t_initialize_1(FSS_READ_pipe_content_ignore_s, 0, FSS_READ_pipe_content_ignore_s_length); + const f_string_static_t fss_read_pipe_content_start_s = macro_f_string_static_t_initialize_1(FSS_READ_pipe_content_start_s, 0, FSS_READ_pipe_content_start_s_length); +#endif // _di_fss_read_pipe_s_ + +#ifndef _di_fss_read_s_ + const f_string_static_t fss_read_string_two_s = macro_f_string_static_t_initialize_1(FSS_READ_string_two_s, 0, FSS_READ_string_two_s_length); +#endif // _di_fss_read_s_ + +#ifndef _di_fss_read_parameter_s_ + const f_string_static_t fss_read_short_at_s = macro_f_string_static_t_initialize_1(FSS_READ_short_at_s, 0, FSS_READ_short_at_s_length); + const f_string_static_t fss_read_short_content_s = macro_f_string_static_t_initialize_1(FSS_READ_short_content_s, 0, FSS_READ_short_content_s_length); + const f_string_static_t fss_read_short_columns_s = macro_f_string_static_t_initialize_1(FSS_READ_short_columns_s, 0, FSS_READ_short_columns_s_length); + const f_string_static_t fss_read_short_delimit_s = macro_f_string_static_t_initialize_1(FSS_READ_short_delimit_s, 0, FSS_READ_short_delimit_s_length); + const f_string_static_t fss_read_short_depth_s = macro_f_string_static_t_initialize_1(FSS_READ_short_depth_s, 0, FSS_READ_short_depth_s_length); + const f_string_static_t fss_read_short_empty_s = macro_f_string_static_t_initialize_1(FSS_READ_short_empty_s, 0, FSS_READ_short_empty_s_length); + const f_string_static_t fss_read_short_line_s = macro_f_string_static_t_initialize_1(FSS_READ_short_line_s, 0, FSS_READ_short_line_s_length); + const f_string_static_t fss_read_short_name_s = macro_f_string_static_t_initialize_1(FSS_READ_short_name_s, 0, FSS_READ_short_name_s_length); + const f_string_static_t fss_read_short_object_s = macro_f_string_static_t_initialize_1(FSS_READ_short_object_s, 0, FSS_READ_short_object_s_length); + const f_string_static_t fss_read_short_pipe_s = macro_f_string_static_t_initialize_1(FSS_READ_short_pipe_s, 0, FSS_READ_short_pipe_s_length); + const f_string_static_t fss_read_short_original_s = macro_f_string_static_t_initialize_1(FSS_READ_short_original_s, 0, FSS_READ_short_original_s_length); + const f_string_static_t fss_read_short_select_s = macro_f_string_static_t_initialize_1(FSS_READ_short_select_s, 0, FSS_READ_short_select_s_length); + const f_string_static_t fss_read_short_total_s = macro_f_string_static_t_initialize_1(FSS_READ_short_total_s, 0, FSS_READ_short_total_s_length); + const f_string_static_t fss_read_short_trim_s = macro_f_string_static_t_initialize_1(FSS_READ_short_trim_s, 0, FSS_READ_short_trim_s_length); + + const f_string_static_t fss_read_long_at_s = macro_f_string_static_t_initialize_1(FSS_READ_long_at_s, 0, FSS_READ_long_at_s_length); + const f_string_static_t fss_read_long_content_s = macro_f_string_static_t_initialize_1(FSS_READ_long_content_s, 0, FSS_READ_long_content_s_length); + const f_string_static_t fss_read_long_columns_s = macro_f_string_static_t_initialize_1(FSS_READ_long_columns_s, 0, FSS_READ_long_columns_s_length); + const f_string_static_t fss_read_long_delimit_s = macro_f_string_static_t_initialize_1(FSS_READ_long_delimit_s, 0, FSS_READ_long_delimit_s_length); + const f_string_static_t fss_read_long_depth_s = macro_f_string_static_t_initialize_1(FSS_READ_long_depth_s, 0, FSS_READ_long_depth_s_length); + const f_string_static_t fss_read_long_empty_s = macro_f_string_static_t_initialize_1(FSS_READ_long_empty_s, 0, FSS_READ_long_empty_s_length); + const f_string_static_t fss_read_long_line_s = macro_f_string_static_t_initialize_1(FSS_READ_long_line_s, 0, FSS_READ_long_line_s_length); + const f_string_static_t fss_read_long_name_s = macro_f_string_static_t_initialize_1(FSS_READ_long_name_s, 0, FSS_READ_long_name_s_length); + const f_string_static_t fss_read_long_object_s = macro_f_string_static_t_initialize_1(FSS_READ_long_object_s, 0, FSS_READ_long_object_s_length); + const f_string_static_t fss_read_long_pipe_s = macro_f_string_static_t_initialize_1(FSS_READ_long_pipe_s, 0, FSS_READ_long_pipe_s_length); + const f_string_static_t fss_read_long_original_s = macro_f_string_static_t_initialize_1(FSS_READ_long_original_s, 0, FSS_READ_long_original_s_length); + const f_string_static_t fss_read_long_select_s = macro_f_string_static_t_initialize_1(FSS_READ_long_select_s, 0, FSS_READ_long_select_s_length); + const f_string_static_t fss_read_long_total_s = macro_f_string_static_t_initialize_1(FSS_READ_long_total_s, 0, FSS_READ_long_total_s_length); + const f_string_static_t fss_read_long_trim_s = macro_f_string_static_t_initialize_1(FSS_READ_long_trim_s, 0, FSS_READ_long_trim_s_length); +#endif // _di_fss_read_parameter_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/common/string.h b/level_3/fss_read/c/main/common/string.h new file mode 100644 index 0000000..df09115 --- /dev/null +++ b/level_3/fss_read/c/main/common/string.h @@ -0,0 +1,201 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_common_string_h +#define _fss_read_common_string_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The program version. + */ +#ifndef _di_fss_read_program_version_s_ + #define FSS_READ_program_version_major_s F_string_ascii_0_s + #define FSS_READ_program_version_minor_s F_string_ascii_7_s + #define FSS_READ_program_version_micro_s F_string_ascii_0_s + + #define FSS_READ_program_version_major_s_length F_string_ascii_0_s_length + #define FSS_READ_program_version_minor_s_length F_string_ascii_7_s_length + #define FSS_READ_program_version_micro_s_length F_string_ascii_0_s_length + + #if !(defined(FSS_READ_program_version_nano_prefix_s) && defined(FSS_READ_program_version_nano_prefix_s_length)) + #define FSS_READ_program_version_nano_prefix_s + #define FSS_READ_program_version_nano_prefix_s_length 0 + #endif // !(defined(FSS_READ_program_version_nano_prefix_s) && defined(FSS_READ_program_version_nano_prefix_s_length)) + + #if !(defined(FSS_READ_program_version_nano_s) && defined(FSS_READ_program_version_nano_s_length)) + #define FSS_READ_program_version_nano_s + #define FSS_READ_program_version_nano_s_length 0 + #endif // !(defined(FSS_READ_program_version_nano_s) && defined(FSS_READ_program_version_nano_s_length)) + + #define FSS_READ_program_version_s FSS_READ_program_version_major_s F_string_ascii_period_s FSS_READ_program_version_minor_s F_string_ascii_period_s FSS_READ_program_version_micro_s FSS_READ_program_version_nano_prefix_s FSS_READ_program_version_nano_s + + #define FSS_READ_program_version_s_length FSS_READ_program_version_major_s_length + F_string_ascii_period_s_length + FSS_READ_program_version_minor_s_length + F_string_ascii_period_s_length + FSS_READ_program_version_micro_s_length + FSS_READ_program_version_nano_prefix_s_length + FSS_READ_program_version_nano_s_length + + extern const f_string_static_t fss_read_program_version_s; +#endif // _di_fss_read_program_version_s_ + +/** + * The program name. + */ +#ifndef _di_fss_read_program_name_s_ + #define FSS_READ_program_name_s "fss_read" + #define FSS_READ_program_name_long_s "FSS Read" + + #define FSS_READ_program_name_s_length 8 + #define FSS_READ_program_name_long_s_length 8 + + extern const f_string_static_t fss_read_program_name_s; + extern const f_string_static_t fss_read_program_name_long_s; +#endif // _di_fss_read_program_name_s_ + +/** + * The program pipe strings. + * + * The fss_read_pipe_content_*_s strings are strings rather than characters to allow for wide characters. + * + * fss_read_pipe_content_*_s: + * - end: The character representing the end of content. + * - ignore: The character representing the start of or end of a set of characters to ignore. + * - start: The character representing the start of content. + * + * macro_fss_read_setting: + * - Used to represent a cast to ((fss_read_setting_t *) setting). + * - Simplifies the number of parenthesis used to make code slightly cleaner. + * - Is wrapped in a parenthesis and not a block. + */ +#ifndef _di_fss_read_pipe_s_ + #define FSS_READ_pipe_content_end_s "\f" + #define FSS_READ_pipe_content_ignore_s "\v" + #define FSS_READ_pipe_content_start_s "\b" + + #define FSS_READ_pipe_content_end_s_length 1 + #define FSS_READ_pipe_content_ignore_s_length 1 + #define FSS_READ_pipe_content_start_s_length 1 + + extern const f_string_static_t fss_read_pipe_content_end_s; + extern const f_string_static_t fss_read_pipe_content_ignore_s; + extern const f_string_static_t fss_read_pipe_content_start_s; +#endif // _di_fss_read_pipe_s_ + +/** + * A collection of static strings associated with FSS Payload Write. + */ +#ifndef _di_fss_read_s_ + #define FSS_READ_string_two_s "two" + + #define FSS_READ_string_two_s_length 3 + + extern const f_string_static_t fss_read_string_two_s; +#endif // _di_fss_read_s_ + +/** + * The main program parameters. + */ +#ifndef _di_fss_read_parameter_s_ + #define FSS_READ_short_at_s "a" + #define FSS_READ_short_content_s "c" + #define FSS_READ_short_columns_s "C" + #define FSS_READ_short_delimit_s "D" + #define FSS_READ_short_depth_s "d" + #define FSS_READ_short_empty_s "e" + #define FSS_READ_short_line_s "l" + #define FSS_READ_short_name_s "n" + #define FSS_READ_short_object_s "o" + #define FSS_READ_short_pipe_s "p" + #define FSS_READ_short_original_s "O" + #define FSS_READ_short_select_s "s" + #define FSS_READ_short_total_s "t" + #define FSS_READ_short_trim_s "T" + + #define FSS_READ_long_at_s "at" + #define FSS_READ_long_content_s "content" + #define FSS_READ_long_columns_s "columns" + #define FSS_READ_long_delimit_s "delimit" + #define FSS_READ_long_depth_s "depth" + #define FSS_READ_long_empty_s "empty" + #define FSS_READ_long_line_s "line" + #define FSS_READ_long_name_s "name" + #define FSS_READ_long_object_s "object" + #define FSS_READ_long_pipe_s "pipe" + #define FSS_READ_long_original_s "original" + #define FSS_READ_long_select_s "select" + #define FSS_READ_long_total_s "total" + #define FSS_READ_long_trim_s "trim" + + #define FSS_READ_short_at_s_length 1 + #define FSS_READ_short_content_s_length 1 + #define FSS_READ_short_columns_s_length 1 + #define FSS_READ_short_delimit_s_length 1 + #define FSS_READ_short_depth_s_length 1 + #define FSS_READ_short_empty_s_length 1 + #define FSS_READ_short_line_s_length 1 + #define FSS_READ_short_name_s_length 1 + #define FSS_READ_short_object_s_length 1 + #define FSS_READ_short_pipe_s_length 1 + #define FSS_READ_short_original_s_length 1 + #define FSS_READ_short_select_s_length 1 + #define FSS_READ_short_total_s_length 1 + #define FSS_READ_short_trim_s_length 1 + + #define FSS_READ_long_at_s_length 2 + #define FSS_READ_long_content_s_length 7 + #define FSS_READ_long_columns_s_length 8 + #define FSS_READ_long_delimit_s_length 7 + #define FSS_READ_long_depth_s_length 5 + #define FSS_READ_long_empty_s_length 5 + #define FSS_READ_long_line_s_length 4 + #define FSS_READ_long_name_s_length 4 + #define FSS_READ_long_object_s_length 6 + #define FSS_READ_long_pipe_s_length 4 + #define FSS_READ_long_original_s_length 8 + #define FSS_READ_long_select_s_length 6 + #define FSS_READ_long_total_s_length 5 + #define FSS_READ_long_trim_s_length 4 + + extern const f_string_static_t fss_read_short_at_s; + extern const f_string_static_t fss_read_short_content_s; + extern const f_string_static_t fss_read_short_columns_s; + extern const f_string_static_t fss_read_short_delimit_s; + extern const f_string_static_t fss_read_short_depth_s; + extern const f_string_static_t fss_read_short_empty_s; + extern const f_string_static_t fss_read_short_line_s; + extern const f_string_static_t fss_read_short_name_s; + extern const f_string_static_t fss_read_short_object_s; + extern const f_string_static_t fss_read_short_pipe_s; + extern const f_string_static_t fss_read_short_original_s; + extern const f_string_static_t fss_read_short_select_s; + extern const f_string_static_t fss_read_short_total_s; + extern const f_string_static_t fss_read_short_trim_s; + + extern const f_string_static_t fss_read_long_at_s; + extern const f_string_static_t fss_read_long_content_s; + extern const f_string_static_t fss_read_long_columns_s; + extern const f_string_static_t fss_read_long_delimit_s; + extern const f_string_static_t fss_read_long_depth_s; + extern const f_string_static_t fss_read_long_empty_s; + extern const f_string_static_t fss_read_long_line_s; + extern const f_string_static_t fss_read_long_name_s; + extern const f_string_static_t fss_read_long_object_s; + extern const f_string_static_t fss_read_long_pipe_s; + extern const f_string_static_t fss_read_long_original_s; + extern const f_string_static_t fss_read_long_select_s; + extern const f_string_static_t fss_read_long_total_s; + extern const f_string_static_t fss_read_long_trim_s; +#endif // _di_fss_read_parameter_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_common_string_h diff --git a/level_3/fss_read/c/main/common/type.c b/level_3/fss_read/c/main/common/type.c new file mode 100644 index 0000000..50abdaf --- /dev/null +++ b/level_3/fss_read/c/main/common/type.c @@ -0,0 +1,37 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_main_data_delete_ + void fss_read_main_delete(fss_read_main_t * const main) { + + if (!main) return; + + fll_program_data_delete(&main->program); + fss_read_setting_delete(&main->setting); + } +#endif // _di_fss_read_main_data_delete_ + +#ifndef _di_fss_read_setting_delete_ + f_status_t fss_read_setting_delete(fss_read_setting_t * const setting) { + + if (!setting) return F_status_set_error(F_parameter); + + f_string_dynamic_resize(0, &setting->escaped); + f_string_dynamic_resize(0, &setting->block); + f_string_dynamic_resize(0, &setting->buffer); + f_string_dynamic_resize(0, &setting->prepend); + + f_string_rangess_resize(0, &setting->ignoress); + f_string_dynamics_resize(0, &setting->objects); + f_string_dynamicss_resize(0, &setting->contentss); + + return F_none; + } +#endif // _di_fss_read_setting_delete_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h new file mode 100644 index 0000000..dcecf1c --- /dev/null +++ b/level_3/fss_read/c/main/common/type.h @@ -0,0 +1,171 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_common_type_h +#define _fss_read_common_type_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The fss 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). + * + * For all function pointers on this structure, the main variable must be of type fss_read_main_t. + * + * flag: Flags passed to the main function. + * + * status_thread: A status used eclusively by the threaded signal handler. + * state: The state data used when processing the FSS data. + * + * range: A range used as a buffer during processing. + * + * quote: This holds the quote used during processing. + * standard: A human-friendly string describing the standard in use, such as "FSS-0000 (Basic)". + * + * escaped: A buffer used for escaping strings during processing. + * block: A buffer used to storing one or more blocks while processing a file line by line. + * buffer: A buffer used during processing the file. + * prepend: A string to prepend to each multi-line Content. + * + * ignoress: An array of range sets passed as values to the "--ignore" parameter or via the input pipe. + * objects: An array of objects passed as values to the "--object" parameter or via the input pipe. + * contentss: An array of content sets passed as values to the "--content" parameter or via the input pipe. + * + * object: A pointer to a specific Object used during processing. + * content: A pointer to a specific Content used during processing. + * contents: A pointer to a specific set of Content used during processing. + * + * process_content: Process a single Content. + * process_help: Process help (generally printing help). + * process_normal: Process normally (data from parameters and files). + * process_object: Process a single Object. + * process_pipe: Process using the data from input pipe. + * process_set: Process a set of Object and one or more Content. + */ +#ifndef _di_fss_read_setting_t_ + typedef struct { + uint16_t flag; + + f_status_t status_thread; + f_state_t state; + + f_string_range_t range; + + f_string_static_t quote; + f_string_static_t standard; + + f_string_dynamic_t escaped; + f_string_dynamic_t block; + f_string_dynamic_t buffer; + f_string_dynamic_t prepend; + + f_string_rangess_t ignoress; + f_string_dynamics_t objects; + f_string_dynamicss_t contentss; + + f_string_ranges_t *ignores; + f_string_static_t *object; + f_string_static_t *content; + f_string_statics_t *contents; + + void (*process_content)(void * const main, const bool last); + void (*process_help)(void * const main); + void (*process_normal)(void * const main); + void (*process_object)(void * const main); + void (*process_pipe)(void * const main); + void (*process_set)(void * const main); + } fss_read_setting_t; + + #define fss_read_setting_t_initialize \ + { \ + fss_read_main_flag_none_e, \ + F_none, \ + macro_f_state_t_initialize_1(fss_read_allocation_large_d, fss_read_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0, 0), \ + f_string_range_t_initialize, \ + f_string_static_t_initialize, \ + f_string_static_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_dynamic_t_initialize, \ + f_string_rangess_t_initialize, \ + f_string_dynamics_t_initialize, \ + f_string_dynamicss_t_initialize, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + } +#endif // _di_fss_read_setting_t_ + +/** + * The main program data as a single structure. + * + * program: The main program data. + * setting: The settings data. + */ +#ifndef _di_fss_read_main_t_ + typedef struct { + fll_program_data_t program; + fss_read_setting_t setting; + } fss_read_main_t; + + #define fss_read_main_t_initialize \ + { \ + fll_program_data_t_initialize, \ + fss_read_setting_t_initialize, \ + } +#endif // _di_fss_read_main_t_ + +/** + * Deallocate main program data. + * + * @param setting_make + * The make setting data. + * + * This does not alter data_make.main.setting.state.status. + */ +#ifndef _di_fss_read_main_data_delete_ + extern void fss_read_main_delete(fss_read_main_t * const main); +#endif // _di_fss_read_main_data_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_read_setting_delete_ + extern f_status_t fss_read_setting_delete(fss_read_setting_t * const setting); +#endif // _di_fss_read_setting_delete_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_common_type_h diff --git a/level_3/fss_read/c/main/fss_read.c b/level_3/fss_read/c/main/fss_read.c new file mode 100644 index 0000000..930dad3 --- /dev/null +++ b/level_3/fss_read/c/main/fss_read.c @@ -0,0 +1,522 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_main_ + void fss_read_main(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (F_status_is_error(main->setting.state.status)) { + if ((main->setting.flag & fss_read_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + return; + } + + if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + main->setting.state.status = F_none; + + if (main->setting.flag & (fss_read_main_flag_help_e | fss_read_main_flag_version_e | fss_read_main_flag_copyright_e)) { + if (main->setting.flag & fss_read_main_flag_help_e) { + if (main->setting.process_help) { + main->setting.process_help(void_main); + } + else { + fss_read_print_message_help(&main->program.message); + } + } + else if (main->setting.flag & fss_read_main_flag_version_e) { + fll_program_print_version(&main->program.message, fss_read_program_version_s); + } + else if (main->setting.flag & fss_read_main_flag_copyright_e) { + fll_program_print_copyright(&main->program.message); + } + + if ((main->setting.flag & fss_read_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + return; + } + + main->setting.escaped.used = 0; + + if (main->program.pipe & fll_program_data_pipe_input_e) { + if (main->setting.process_pipe) { + main->setting.process_pipe(void_main); + } + } + + if (F_status_is_error_not(main->setting.state.status)) { + if (main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e | fss_read_main_flag_object_open_e | fss_read_main_flag_content_next_e | fss_read_main_flag_content_end_e)) { + if (main->setting.process_normal) { + main->setting.process_normal(void_main); + } + } + } + + if ((main->setting.flag & fss_read_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + } +#endif // _di_fss_read_main_ + +#ifndef _di_fss_read_process_normal_ + void fss_read_process_normal(void * const void_main) { + + if (!void_main) return; + + fss_read_process_normal_data( + (fss_read_main_t *) void_main, + (((fss_read_main_t *) void_main)->setting.flag & fss_read_main_flag_object_e) + ? ((fss_read_main_t *) void_main)->setting.objects.used + : ((fss_read_main_t *) void_main)->setting.contentss.used + ); + } +#endif // _di_fss_read_process_normal_ + +#ifndef _di_fss_read_process_normal_data_ + void fss_read_process_normal_data(void * const void_main, const f_array_length_t length) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.ignores = 0; + main->setting.object = 0; + main->setting.content = 0; + main->setting.contents = 0; + + if (length) { + for (f_array_length_t i = 0; i < length; ++i) { + + // @todo replace all signal checks with forked main process that independently checks and assigns main->program.signal_received. + if (!((++main->program.signal_check) % fss_read_signal_check_d)) { + if (fll_program_standard_signal_received(&main->program)) { + main->setting.state.status = F_status_set_error(F_interrupt); + + return; + } + + main->program.signal_check = 0; + } + + if (main->setting.objects.used) { + main->setting.object = &main->setting.objects.array[i]; + } + + if (main->setting.contentss.used) { + main->setting.contents = &main->setting.contentss.array[i]; + } + + if (main->setting.ignoress.used) { + main->setting.ignores = &main->setting.ignoress.array[i]; + } + + main->setting.process_set(void_main); + if (F_status_is_error(main->setting.state.status)) break; + } // for + } + else { + if (main->setting.flag & (fss_read_main_flag_object_open_e | fss_read_main_flag_content_next_e | fss_read_main_flag_content_end_e)) { + main->setting.object = 0; + main->setting.contents = 0; + main->setting.ignores = 0; + + main->setting.process_set(void_main); + } + } + } +#endif // _di_fss_read_process_normal_data_ + +#ifndef _di_fss_read_process_pipe_ + void fss_read_process_pipe(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if (!main->setting.process_set) return; + + if (main->program.message.verbosity > f_console_verbosity_error_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); + } + + const f_array_length_t used_objects = main->setting.objects.used; + const f_array_length_t used_contentss = main->setting.contentss.used; + const f_array_length_t used_ignoress = main->setting.ignoress.used; + + main->setting.object = &main->setting.objects.array[used_objects]; + main->setting.contents = &main->setting.contentss.array[used_contentss]; + main->setting.ignores = &main->setting.ignoress.array[used_ignoress]; + + // 0x0 = nothing printed, 0x1 = something printed, 0x2 = ignore enabled, 0x4 = added Content for Object. + uint8_t flag = 0; + + // 0x0 = start new object/content set, 0x1 = processing object, 0x2 = processing content, 0x3 = end object/content set. + uint8_t state = 0; + + // This is processed in a single set, so there is only ever one Object added. + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, &main->setting.objects); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); + + return; + } + + // This is processed in a single set, so there is only ever one Content added. + main->setting.state.status = f_string_dynamicss_increase(main->setting.state.step_small, &main->setting.contentss); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamicss_increase)); + + return; + } + + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); + + return; + } + + // This is processed in a single set, so there is only ever one Ignores added. + main->setting.state.status = f_string_rangess_increase(main->setting.state.step_small, &main->setting.ignoress); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_rangess_increase)); + + return; + } + + f_status_t status_pipe = F_none; + + f_file_t input = f_file_t_initialize; + input.id = F_type_descriptor_input_d; + input.size_read = main->setting.state.step_large; + + f_array_length_t total = 0; + f_array_length_t ignore = 0; + f_string_range_t range = f_string_range_t_initialize; + + // Reset all of the used data before starting the loop. + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; + + for (;;) { + + if (!((++main->program.signal_check) % fss_read_signal_check_d)) { + if (fll_program_standard_signal_received(&main->program)) { + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); + + main->setting.state.status = F_status_set_error(F_interrupt); + + break; + } + + main->program.signal_check = 0; + } + + if (range.start > range.stop) { + if (status_pipe == F_none_eof) break; + + main->setting.block.used = 0; + + status_pipe = f_file_read_block(input, &main->setting.block); + + if (F_status_is_error(status_pipe)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_file_read_block)); + + status_pipe = F_status_set_error(F_pipe); + + break; + } + + if (!main->setting.block.used) break; + + range.start = 0; + range.stop = main->setting.block.used - 1; + } + + // Start Object. + if (!state || state == 0x1) { + if (!state) { + main->setting.object->used = 0; + + state = 0x1; + } + + // Reset the "has Content for Object" flag and associated contents array used length. + flag -= flag | 0x4; + main->setting.contents->used = 0; + + main->setting.state.status = f_string_dynamic_increase_by(main->setting.block.used, main->setting.object); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); + + break; + } + + for (; range.start <= range.stop; ++range.start) { + + // Do not handle start/end while inside an ignore set. + if (!(flag & 0x2)) { + if (main->setting.block.string[range.start] == fss_read_pipe_content_start_s.string[0]) { + state = 0x2; + ++range.start; + + break; + } + + if (main->setting.block.string[range.start] == fss_read_pipe_content_end_s.string[0]) { + state = 0x3; + ++range.start; + + break; + } + } + + // There currently is no support for "ignore" in Objects, but the Ignore should still be processed. + if (main->setting.block.string[range.start] == fss_read_pipe_content_ignore_s.string[0]) { + + // Ignore is enabled. + if (flag & 0x2) { + flag -= 0x2; + } + else { + flag |= 0x2; + } + + continue; + } + + main->setting.object->string[main->setting.object->used++] = main->setting.block.string[range.start]; + } // for + + if (F_status_is_error(main->setting.state.status)) break; + + // If the start of Content is not found, then fetch the next block. + if (state == 0x1) continue; + + // If the end of the current block is reached, fetch the next block. + if (range.start > range.stop) continue; + } + + // Start Content. + if (state == 0x2) { + + // Check to see if the Content supports multiple Content per Object. + if (flag & 0x4) { + if (!(main->setting.flag & fss_read_main_flag_content_multiple_e)) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_one_content_only(&main->program.error); + + break; + } + + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); + + break; + } + } + + if (range.start <= range.stop) { + total = (range.stop - range.start) + 1; + } + else { + total = 0; + } + + if (total) { + main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); + + break; + } + + for (; range.start <= range.stop; ++range.start) { + + // Do not handle start/end while inside an ignore set. + if (!(flag & 0x2)) { + if (main->setting.block.string[range.start] == fss_read_pipe_content_start_s.string[0]) { + if (!(main->setting.flag & fss_read_main_flag_content_multiple_e)) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_one_content_only(&main->program.error); + + break; + } + } + + if (main->setting.block.string[range.start] == fss_read_pipe_content_end_s.string[0]) { + state = 0x3; + ++range.start; + + break; + } + } + + if (main->setting.block.string[range.start] == fss_read_pipe_content_ignore_s.string[0]) { + + // Ignore is enabled. + if (flag & 0x2) { + main->setting.state.status = f_string_ranges_increase(main->setting.state.step_small, main->setting.ignores); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_ranges_increase)); + + break; + } + + main->setting.ignores->array[main->setting.ignores->used].start = main->setting.contents->array[main->setting.contents->used].used; + main->setting.ignores->array[main->setting.ignores->used].stop = range.start; + + flag -= 0x2; + } + else { + ignore = main->setting.contents->array[main->setting.contents->used].used; + + flag |= 0x2; + } + + continue; + } + + main->setting.contents->array[main->setting.contents->used].string[main->setting.contents->array[main->setting.contents->used].used++] = main->setting.block.string[range.start]; + } // for + + if (F_status_is_error(main->setting.state.status)) break; + + ++main->setting.contents->used; + flag |= 0x4; + } + else { + state = 0x3; + } + } + + // End Object or Content set. + if (state == 0x3) { + main->setting.process_set(void_main); + if (F_status_is_error(main->setting.state.status)) break; + + state = 0; + flag |= 0x1; + + // Reset all of the used data for next set. + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; + + continue; + } + } // for + + // If the pipe ended before finishing, then attempt to wrap up. + if (F_status_is_error_not(main->setting.state.status) && status_pipe == F_none_eof && state) { + main->setting.process_set(void_main); + + flag |= 0x1; + } + + main->setting.block.used = 0; + main->setting.buffer.used = 0; + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; + main->setting.ignoress.used = used_ignoress; + main->setting.objects.used = used_objects; + main->setting.contentss.used = used_contentss; + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = (flag & 0x1) ? F_none : F_data_not; + } + } +#endif // _di_fss_read_process_pipe_ + +#ifndef _di_fss_read_process_set_ + void fss_read_process_set(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + main->setting.buffer.used = 0; + + if ((!(main->setting.flag & fss_read_main_flag_partial_e) || (main->setting.flag & fss_read_main_flag_partial_e) && (main->setting.flag & fss_read_main_flag_object_e)) && main->setting.object || (main->setting.flag & fss_read_main_flag_object_open_e)) { + + if (main->setting.object) { + if (main->setting.object->used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.object->used - 1; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + } + + if (main->setting.process_object) { + main->setting.process_object(void_main); + if (F_status_is_error(main->setting.state.status)) return; + } + } + + if ((!(main->setting.flag & fss_read_main_flag_partial_e) || (main->setting.flag & fss_read_main_flag_partial_e) && (main->setting.flag & fss_read_main_flag_content_e)) && main->setting.contents || (main->setting.flag & (fss_read_main_flag_content_next_e | fss_read_main_flag_content_end_e))) { + + if (main->setting.process_content) { + if (main->setting.contents && main->setting.contents->used) { + for (f_array_length_t i = 0; i < main->setting.contents->used; ++i) { + + if (main->setting.contents->array[i].used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.contents->array[i].used - 1; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + + main->setting.content = &main->setting.contents->array[i]; + + main->setting.process_content(void_main, i + 1 == main->setting.contents->used); + if (F_status_is_error(main->setting.state.status)) return; + } // for + } + else { + main->setting.content = 0; + + main->setting.process_content(void_main, F_true); + if (F_status_is_error(main->setting.state.status)) return; + } + } + } + + if (main->setting.buffer.used) { + fll_print_dynamic(main->setting.buffer, main->program.output.to); + } + } +#endif // _di_fss_read_process_set_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/fss_read.h b/level_3/fss_read/c/main/fss_read.h new file mode 100644 index 0000000..1b2f244 --- /dev/null +++ b/level_3/fss_read/c/main/fss_read.h @@ -0,0 +1,169 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * This program provides FSS write functionality for several FSS formats. + */ +#ifndef _fss_read_h +#define _fss_read_h + +// Libc includes. +#include +#include +#include +#include + +// FLL-0 includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _di_thread_support_ + #include +#endif // _di_thread_support_ + +// FLL-1 includes. +#include +#include + +// FLL-2 includes. +#include +#include +#include + +// FSS Write includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.custom.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_read_main_ + extern void fss_read_main(void * const main); +#endif // _di_fss_read_main_ + +/** + * Process normally, writing to the output for the assigned FSS format. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.custom.setting.state.status: + * status from fss_read_process_normal_data(). + * + * Errors (with error bit) from fss_read_process_normal_data(). + * + * @see fss_read_process_normal_data() + */ +#ifndef _di_fss_read_process_normal_ + extern void fss_read_process_normal(void * const main); +#endif // _di_fss_read_process_normal_ + +/** + * Process the data normally, writing to the output for the assigned FSS format. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.custom.setting.state.status: + * F_none on success. + * F_interrupt on (exit) signal received. + * + * F_parameter (with error bit) if main is NULL or setting is NULL. + */ +#ifndef _di_fss_read_process_normal_data_ + void fss_read_process_normal_data(void * const main, const f_array_length_t length); +#endif // _di_fss_read_process_normal_data_ + +/** + * Process the pipe, reading from the pipe and writing to the output for the assigned FSS format. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * F_data_not on success but pipe contained no relevant data. + * F_basic on success and the basic has been printed. + * F_interrupt on (exit) signal received. + * + * F_parameter (with error bit) if main is NULL or setting is NULL. + */ +#ifndef _di_fss_read_process_pipe_ + extern void fss_read_process_pipe(void * const main); +#endif // _di_fss_read_process_pipe_ + +/** + * Process a given Object and Content, printing the assigned FSS format if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * F_interrupt on (exit) signal received. + * + * F_parameter (with error bit) if main is NULL or setting is NULL. + */ +#ifndef _di_fss_read_process_set_ + extern void fss_read_process_set(void * const main); +#endif // _di_fss_read_process_set_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_h diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c new file mode 100644 index 0000000..72fdb3c --- /dev/null +++ b/level_3/fss_read/c/main/main.c @@ -0,0 +1,244 @@ +#include "fss_read.h" +#include "main.h" +#include "main/print.h" +#include "../basic/fss_read.h" +#include "../basic_list/fss_read.h" +#include "../extended/fss_read.h" +#include "../extended_list/fss_read.h" +#include "../embedded_list/fss_read.h" +#include "../payload/fss_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + fss_read_main_t data = fss_read_main_t_initialize; + + data.program.debug.flag |= fss_read_print_flag_debug_e | fss_read_print_flag_out_e; + data.program.error.flag |= fss_read_print_flag_error_e | fss_read_print_flag_out_e; + data.program.output.flag |= fss_read_print_flag_out_e; + data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; + data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; + data.program.debug.custom = (void *) &data; + data.program.message.custom = (void *) &data; + data.program.output.custom = (void *) &data; + data.program.warning.custom = (void *) &data; + + data.setting.state.custom = (void *) &data; + + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.used = fss_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); + + f_file_umask_get(&data.program.umask); + + #ifdef _di_thread_support_ + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + fss_read_main(&data); + #else + { + f_thread_id_t id_signal; + + memset(&id_signal, 0, sizeof(f_thread_id_t)); + + data.setting.state.status = f_thread_create(0, &id_signal, &fss_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + fss_read_print_error(&data.program.error, macro_fss_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, &fss_read_main_setting_load_as); + } + + if (!fss_read_signal_check(&data)) { + fss_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + fss_read_main_delete(&data); + + fll_program_standard_set_down(&data.program); + + return F_status_is_error(data.setting.state.status) ? 1 : 0; +} + +#ifndef _di_fss_read_main_process_help_ + void fss_read_main_process_help(void * const void_main) { + + if (!main) return; + + fss_read_main_print_help(&((fss_read_main_t *) void_main)->program.message); + } +#endif // _di_fss_read_main_process_help_ + +#ifndef _di_fss_read_main_setting_load_as_ + void fss_read_main_setting_load_as(const f_console_arguments_t arguments, fss_read_main_t * const main) { + + if (!main || F_status_is_error(main->setting.state.status) || (main->setting.flag & fss_read_main_flag_version_e)) return; + + main->setting.standard = fss_read_basic_standard_s; + main->setting.process_content = &fss_read_basic_process_content; + main->setting.process_help = &fss_read_main_process_help; + main->setting.process_normal = &fss_read_process_normal; + main->setting.process_object = &fss_read_basic_process_object; + main->setting.process_pipe = &fss_read_process_pipe; + main->setting.process_set = &fss_read_process_set; + + if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_read_parameter_as_e].values.used) { + + f_array_length_t index = 0; + f_string_static_t *argv = main->program.parameters.arguments.array; + + for (f_array_length_t i = 0; i < main->program.parameters.array[fss_read_parameter_as_e].values.used; ++i) { + + index = main->program.parameters.array[fss_read_parameter_as_e].values.array[i]; + + if (f_compare_dynamic(argv[index], fss_read_format_code_short_0000_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_long_0000_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_human_0000_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_machine_0000_s) == F_equal_to) { + + main->setting.standard = fss_read_basic_standard_s; + main->setting.process_content = &fss_read_basic_process_content; + main->setting.process_help = &fss_read_basic_process_help; + main->setting.process_object = &fss_read_basic_process_object; + main->setting.process_pipe = &fss_read_process_pipe; + main->setting.process_normal = &fss_read_process_normal; + main->setting.process_set = &fss_read_process_set; + main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by basic. + main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by basic. + } + else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0001_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_long_0001_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_human_0001_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_machine_0001_s) == F_equal_to) { + + main->setting.standard = fss_read_extended_standard_s; + main->setting.process_content = &fss_read_extended_process_content; + main->setting.process_help = &fss_read_extended_process_help; + main->setting.process_object = &fss_read_extended_process_object; + main->setting.process_pipe = &fss_read_process_pipe; + main->setting.process_normal = &fss_read_process_normal; + main->setting.process_set = &fss_read_process_set; + main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by extended. + main->setting.flag |= fss_read_main_flag_content_multiple_e; + } + else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0002_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_long_0002_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_human_0002_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_machine_0002_s) == F_equal_to) { + + main->setting.standard = fss_read_basic_list_standard_s; + main->setting.process_content = &fss_read_basic_list_process_content; + main->setting.process_help = &fss_read_basic_list_process_help; + main->setting.process_object = &fss_read_basic_list_process_object; + main->setting.process_pipe = &fss_read_process_pipe; + main->setting.process_normal = &fss_read_process_normal; + main->setting.process_set = &fss_read_process_set; + main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by basic list. + main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by basic list. + } + else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0003_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_long_0003_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_human_0003_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_machine_0003_s) == F_equal_to) { + + main->setting.standard = fss_read_extended_list_standard_s; + main->setting.process_content = &fss_read_extended_list_process_content; + main->setting.process_help = &fss_read_extended_list_process_help; + main->setting.process_object = &fss_read_extended_list_process_object; + main->setting.process_pipe = &fss_read_process_pipe; + main->setting.process_normal = &fss_read_process_normal; + main->setting.process_set = &fss_read_process_set; + main->setting.flag |= fss_read_main_flag_ignore_e; + main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by extended list. + } + else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0008_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_long_0008_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_human_0008_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_machine_0008_s) == F_equal_to) { + + main->setting.standard = fss_read_embedded_list_standard_s; + main->setting.process_content = &fss_read_embedded_list_process_content; + main->setting.process_help = &fss_read_embedded_list_process_help; + main->setting.process_object = &fss_read_embedded_list_process_object; + main->setting.process_pipe = &fss_read_process_pipe; + main->setting.process_normal = &fss_read_process_normal; + main->setting.process_set = &fss_read_process_set; + main->setting.flag |= fss_read_main_flag_ignore_e; + main->setting.flag |= fss_read_main_flag_content_multiple_e; + } + else if (f_compare_dynamic(argv[index], fss_read_format_code_short_000e_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_long_000e_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_human_000e_s) == F_equal_to || + f_compare_dynamic(argv[index], fss_read_format_code_machine_000e_s) == F_equal_to) { + + main->setting.standard = fss_read_payload_standard_s; + main->setting.process_content = 0; // Not used by payload. + main->setting.process_help = &fss_read_payload_process_help; + main->setting.process_normal = &fss_read_process_normal; + main->setting.process_object = 0; // Not used by payload. + main->setting.process_pipe = &fss_read_payload_process_pipe; + main->setting.process_set = &fss_read_payload_process_set; + main->setting.flag -= main->setting.flag & fss_read_main_flag_ignore_e; // Not supported by payload. + main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; // Not supported by payload. + } + else { + if (main->setting.flag & fss_read_main_flag_help_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + break; + } + + main->setting.state.status = F_status_set_error(F_parameter); + + fss_read_main_print_error_format_unknown(&main->program.error, argv[index]); + } + } // for + + if (F_status_is_error(main->setting.state.status)) { + if (main->setting.flag & fss_read_main_flag_help_e) { + fss_read_main_process_help((void *) main); + } + + return; + } + } + else if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_found_e) { + main->setting.state.status = F_status_set_error(F_parameter); + + if (main->setting.flag & fss_read_main_flag_help_e) { + fss_read_main_process_help((void *) main); + + return; + } + + if (main->program.error.verbosity > f_console_verbosity_quiet_e) { + fll_print_dynamic_raw(f_string_eol_s, main->program.error.to); + } + + fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_as_s); + + return; + } + } +#endif // _di_fss_read_main_setting_load_as_ diff --git a/level_3/fss_read/c/main/main.h b/level_3/fss_read/c/main/main.h new file mode 100644 index 0000000..2f17d8e --- /dev/null +++ b/level_3/fss_read/c/main/main.h @@ -0,0 +1,97 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read" program functionality in some manner. + */ +#ifndef _fss_read_main_h +#define _fss_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); + +/** + * Process printing help for when not specifying "--as". + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This does not alter main.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_read_main_process_help_ + extern void fss_read_main_process_help(void * const main); +#endif // _di_fss_read_main_process_help_ + +/** + * Perform the standard program setting load process for the "--as" parameter. + * + * 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 and settings data. + * + * This alters main.setting.process_help, main.setting.process_normal, and main.setting.process_pipe. + * + * This alters main.setting.state.status: + * F_none on success. + * F_interrupt on (exit) signal received. + * + * F_parameter (with error bit) if main is NULL or setting is NULL. + * + * This alters setting.state.status: + * F_none on success. + * F_data_not on success but nothing was provided to operate with. + * + * Errors (with error bit) from: f_console_parameter_process(). + * Errors (with error bit) from: f_file_stream_open(). + * Errors (with error bit) from: f_string_dynamics_resize(). + * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_verbosity(). + * + * @see f_console_parameter_process() + * @see f_file_stream_open() + * @see f_string_dynamics_resize() + * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_verbosity() + * + * @see fss_read_setting_load() + */ +#ifndef _di_fss_read_main_setting_load_as_ + extern void fss_read_main_setting_load_as(const f_console_arguments_t arguments, fss_read_main_t * const main); +#endif // _di_fss_read_main_setting_load_as_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_main_h diff --git a/level_3/fss_read/c/main/main/print.c b/level_3/fss_read/c/main/main/print.c new file mode 100644 index 0000000..1111539 --- /dev/null +++ b/level_3/fss_read/c/main/main/print.c @@ -0,0 +1,112 @@ +#include "../fss_read.h" +#include "print.h" +#include "../../basic/fss_read.h" +#include "../../basic_list/fss_read.h" +#include "../../extended/fss_read.h" +#include "../../extended_list/fss_read.h" +#include "../../embedded_list/fss_read.h" +#include "../../payload/fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_main_print_error_format_unknown_ + f_status_t fss_read_main_print_error_format_unknown(fl_print_t * const print, const f_string_static_t value) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe format '%]", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%Q%]", print->to, print->set->notable, value, print->set->notable); + fl_print_format("%[' is not known for the parameter%] ", print->to, print->set->error, print->set->error); + fl_print_format("%[%Q%Q%]", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_as_s, print->set->notable); + fl_print_format("%[.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_main_print_error_format_unknown_ + +#ifndef _di_fss_read_main_main_print_help_ + f_status_t fss_read_main_print_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + fll_program_print_help_option(print, fss_read_short_as_s, fss_read_long_as_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Designate the supported format to write as."); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_program_name_s, f_string_empty_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_end_next(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fl_print_format(" The '%[%r%r%]' parameter supports the following standards with the specified possible case-sensitive values:%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_as_s, print->set->notable, f_string_eol_s); + + // FSS-0000 (Basic) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_read_basic_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_short_0000_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_read_format_code_long_0000_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_read_format_code_machine_0000_s, print->set->notable, f_string_eol_s); + + // FSS-0001 (Extended) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_read_extended_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_short_0001_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_read_format_code_long_0001_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_read_format_code_machine_0001_s, print->set->notable, f_string_eol_s); + + // FSS-0002 (Basic List) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_read_basic_list_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_short_0002_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_long_0002_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_read_format_code_human_0002_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_read_format_code_machine_0002_s, print->set->notable, f_string_eol_s); + + // FSS-0003 (Extended List) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_read_extended_list_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_short_0003_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_read_format_code_long_0003_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_human_0003_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_read_format_code_machine_0003_s, print->set->notable, f_string_eol_s); + + // FSS-0008 (Embedded List) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_read_embedded_list_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_short_0008_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_long_0008_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_read_format_code_human_0008_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_read_format_code_machine_0008_s, print->set->notable, f_string_eol_s); + + // FSS-000E (Payload) + fl_print_format(" - As %[%r%] format: ", print->to, print->set->notable, fss_read_payload_standard_s, print->set->notable); + fl_print_format("'%[%r%]', ", print->to, print->set->notable, fss_read_format_code_short_000e_s, print->set->notable); + fl_print_format("'%[%r%]', or ", print->to, print->set->notable, fss_read_format_code_long_000e_s, print->set->notable); + fl_print_format("'%[%r%]'.%r", print->to, print->set->notable, fss_read_format_code_machine_000e_s, print->set->notable, f_string_eol_s); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fl_print_format(" The %[%r%] format is the default when no ", print->to, print->set->notable, fss_read_basic_standard_s, print->set->notable); + fl_print_format("'%[%r%r%]' is specified.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_as_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_read_main_main_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/main/print.h b/level_3/fss_read/c/main/main/print.h new file mode 100644 index 0000000..e885561 --- /dev/null +++ b/level_3/fss_read/c/main/main/print.h @@ -0,0 +1,57 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + */ +#ifndef _fss_read_main_print_h +#define _fss_read_main_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print an error message about a value given to the --as parameter being unknown. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * @param value + * A string representing the value that is of an unknown format. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_main_print_error_format_unknown_ + extern f_status_t fss_read_main_print_error_format_unknown(fl_print_t * const print, const f_string_static_t value); +#endif // _di_fss_read_main_print_error_format_unknown_ + +/** + * Print help for "main" fss_read. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_print_main_help_ + extern f_status_t fss_read_main_print_help(fl_print_t * const print); +#endif // _di_fss_read_print_main_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_main_print_h diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c new file mode 100644 index 0000000..69d4cff --- /dev/null +++ b/level_3/fss_read/c/main/print/data.c @@ -0,0 +1,9 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/print/data.h b/level_3/fss_read/c/main/print/data.h new file mode 100644 index 0000000..740b03d --- /dev/null +++ b/level_3/fss_read/c/main/print/data.h @@ -0,0 +1,23 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print data functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_print_data_h +#define _fss_read_print_data_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_print_data_h diff --git a/level_3/fss_read/c/main/print/error.c b/level_3/fss_read/c/main/print/error.c new file mode 100644 index 0000000..9333887 --- /dev/null +++ b/level_3/fss_read/c/main/print/error.c @@ -0,0 +1,113 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_print_error_ + f_status_t fss_read_print_error(fl_print_t * const print, const f_string_t function) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + fll_error_print(print, F_status_set_fine(((fss_read_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e); + + return F_none; + } +#endif // _di_fss_read_print_error_ + +#ifndef _di_fss_read_print_error_file_ + f_status_t fss_read_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + fll_error_file_print(print, F_status_set_fine(((fss_read_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type); + + return F_none; + } +#endif // _di_fss_read_print_error_file_ + +#ifndef _di_fss_read_print_error_parameter_same_times_at_least_ + f_status_t fss_read_print_error_parameter_same_times_at_least(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QMust specify the '%]", print->to, print->context, print->prefix, print->context); + fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_read_long_content_s, print->notable); + fl_print_format("%[' parameter at least the same number of times as the '%]", print->to, print->context, print->context); + fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_read_long_object_s, print->notable); + fl_print_format("%[' parameter when not specifying the '%]", print->to, print->context, print->context); + fl_print_format("%[%r%r%]", print->to, print->notable, f_console_symbol_long_normal_s, fss_read_long_partial_s, print->notable); + fl_print_format("%[' parameter.%]%r", print->to, print->context, print->context, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_print_error_parameter_same_times_at_least_ + +#ifndef _di_fss_read_print_error_one_content_only_ + f_status_t fss_read_print_error_one_content_only(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe%] ", print->to, print->context, print->prefix, print->context); + fl_print_format("%[%r%]", print->to, print->notable, ((fss_read_main_t *) print->custom)->setting.standard, print->notable); + fl_print_format(" %[standard only supports one Content per Object.%]%r", print->to, print->context, print->context, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_print_error_one_content_only_ + +#ifndef _fss_read_print_error_prepend_only_whitespace_ + f_status_t fss_read_print_error_prepend_only_whitespace(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe value for the parameter '%]", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format("%[%r%r%]", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_prepend_s, print->set->notable); + fl_print_format("%[' must only contain white space.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _fss_read_print_error_prepend_only_whitespace_ + +#ifndef _di_fss_read_print_error_unsupported_eol_ + f_status_t fss_read_print_error_unsupported_eol(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe%] ", print->to, print->context, print->prefix, print->context); + fl_print_format("%[%r%]", print->to, print->notable, ((fss_read_main_t *) print->custom)->setting.standard, print->notable); + fl_print_format(" %[standard does not support end of line character '%]", print->to, print->context, print->context); + fl_print_format("%[\\n%]", print->to, print->set->notable, print->set->notable); + fl_print_format("%[' (%]", print->to, print->set->error, print->set->error); + fl_print_format("%[U+000A%]", print->to, print->set->notable, print->set->notable); + fl_print_format("%[) in Objects.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_print_error_unsupported_eol_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/print/error.h b/level_3/fss_read/c/main/print/error.h new file mode 100644 index 0000000..e823560 --- /dev/null +++ b/level_3/fss_read/c/main/print/error.h @@ -0,0 +1,146 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print error functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_print_error_h +#define _fss_read_print_error_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print generic error message regarding a function failing in some way. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_print() + */ +#ifndef _di_fss_read_print_error_ + extern f_status_t fss_read_print_error(fl_print_t * const print, const f_string_t function); +#endif // _di_fss_read_print_error_ + +/** + * Print file related error or warning messages. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param type + * A valid file type code from the fll_error_file_type enum. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_file_print() + */ +#ifndef _di_fss_read_print_error_file_ + extern f_status_t fss_read_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type); +#endif // _di_fss_read_print_error_file_ + +/** + * Print an error message about the object and content parameters not being specified at least the same number of times when partial is not requested. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_print() + */ +#ifndef _di_fss_read_print_error_parameter_same_times_at_least_ + extern f_status_t fss_read_print_error_parameter_same_times_at_least(fl_print_t * const print); +#endif // _di_fss_read_print_error_parameter_same_times_at_least_ + +/** + * Print an message about a multiple Content being unsupported for a particular standard. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_print_error_one_content_only_ + extern f_status_t fss_read_print_error_one_content_only(fl_print_t * const print); +#endif // _di_fss_read_print_error_one_content_only_ + +/** + * Print error when prepend parameter has something other than white space. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _fss_read_print_error_prepend_only_whitespace_ + extern f_status_t fss_read_print_error_prepend_only_whitespace(fl_print_t * const print); +#endif // _fss_read_print_error_prepend_only_whitespace_ + +/** + * Print an error message about a parameter New Line character '\n' (U+000A) being unsupported. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_print_error_unsupported_eol_ + extern f_status_t fss_read_print_error_unsupported_eol(fl_print_t * const print); +#endif // _di_fss_read_print_error_unsupported_eol_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_print_error_h diff --git a/level_3/fss_read/c/main/print/message.c b/level_3/fss_read/c/main/print/message.c new file mode 100644 index 0000000..cac0653 --- /dev/null +++ b/level_3/fss_read/c/main/print/message.c @@ -0,0 +1,63 @@ +#include "../fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_print_message_help_ + void fss_read_print_message_help(fl_print_t * const print) { + + if (!print) return; + + fll_program_print_help_option_standard(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_option(print, fss_read_short_backtick_s, fss_read_long_backtick_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use backticks to quote."); + fll_program_print_help_option(print, fss_read_short_content_s, fss_read_long_content_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Content to write."); + fll_program_print_help_option(print, fss_read_short_content_end_s, fss_read_long_content_end_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Write the end of Content characters."); + fll_program_print_help_option(print, fss_read_short_content_next_s, fss_read_long_content_next_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Write the next Content characters (separates multi-Content apart)."); + fll_program_print_help_option(print, fss_read_short_double_s, fss_read_long_double_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use double quotes (default)."); + fll_program_print_help_option(print, fss_read_short_file_s, fss_read_long_file_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Specify a file to send data to."); + fll_program_print_help_option(print, fss_read_short_ignore_s, fss_read_long_ignore_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Ignore a given range within a Content."); + fll_program_print_help_option(print, fss_read_short_object_s, fss_read_long_object_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " The Object to write."); + fll_program_print_help_option(print, fss_read_short_object_open_s, fss_read_long_object_open_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Write the open Object characters."); + fll_program_print_help_option(print, fss_read_short_partial_s, fss_read_long_partial_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Do not write a complete Object and Content set."); + fll_program_print_help_option(print, fss_read_short_prepend_s, fss_read_long_prepend_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Prepend the given white space characters to the start of each multi-line Content."); + fll_program_print_help_option(print, fss_read_short_single_s, fss_read_long_single_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Use single quotes."); + fll_program_print_help_option(print, fss_read_short_trim_s, fss_read_long_trim_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, " Trim Object names."); + } +#endif // _di_fss_read_print_message_help_ + +#ifndef _di_fss_read_print_message_help_end_next_ + void fss_read_print_message_help_end_next(fl_print_t * const print) { + + if (!print) return; + + fl_print_format(" The '%[%r%r%]',", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_object_open_s, print->set->notable); + fl_print_format(" '%[%r%r%]', and", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_content_next_s, print->set->notable); + fl_print_format(" '%[%r%r%]' help facilitate writing the designated data for when using", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_content_end_s, print->set->notable); + fl_print_format(" '%[%r%r%]'.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_partial_s, print->set->notable, f_string_eol_s); + + fl_print_format(" These may also be used when there is no '%[%r%r%]' or", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_object_s, print->set->notable); + fl_print_format(" '%[%r%r%]' specified to only print the designated data.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_content_s, print->set->notable, f_string_eol_s); + } +#endif // _di_fss_read_print_message_help_end_next_ + +#ifndef _di_fss_read_print_message_help_pipe_ + void fss_read_print_message_help_pipe(fl_print_t * const print) { + + if (!print) return; + + fl_print_format("%r The pipe uses the Backspace character '%[\\b%]' (%[U+0008%]) to designate the start of a Content.%r", print->to, f_string_eol_s, print->set->notable, print->set->notable, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" The pipe uses the Form Feed character '%[\\f%]' (%[U+000C%]) to designate the end of the last Content.%r", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" The pipe uses the Vertical Line character '%[\\v%]' (%[U+000B%]) is used to ignore a Content range (use this both before and after the range).%r", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" For the pipe, an Object is terminated by either a Backspace character '%[\\b%]' (%[U+0008%])", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable); + fl_print_format(" or a Form Feed character '%[\\f%]' (%[U+000C%]).%r", print->to, print->set->notable, print->set->notable, print->set->notable, print->set->notable, f_string_eol_s); + fl_print_format(" The end of the pipe represents the end of any Object or Content.%r", print->to, f_string_eol_s); + } +#endif // _di_fss_read_print_message_help_pipe_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/print/message.h b/level_3/fss_read/c/main/print/message.h new file mode 100644 index 0000000..587e7e0 --- /dev/null +++ b/level_3/fss_read/c/main/print/message.h @@ -0,0 +1,65 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print message functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_print_message_h +#define _fss_read_print_message_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print standard parts of the help. + * + * This is expected to be called as part of the help printing and does not perform any locking. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_fss_read_print_message_help_ + extern void fss_read_print_message_help(fl_print_t * const print); +#endif // _di_fss_read_print_message_help_ + +/** + * Print standard parts of the help regarding Object End, Content Next, and Content End usage. + * + * This is expected to be called as part of the help printing and does not perform any locking. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_fss_read_print_message_help_end_next_ + extern void fss_read_print_message_help_end_next(fl_print_t * const print); +#endif // _di_fss_read_print_message_help_end_next_ + +/** + * Print standard parts of the help regarding pipe usage. + * + * This is expected to be called as part of the help printing and does not perform any locking. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_fss_read_print_message_help_pipe_ + extern void fss_read_print_message_help_pipe(fl_print_t * const print); +#endif // _di_fss_read_print_message_help_pipe_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_print_message_h diff --git a/level_3/fss_read/c/main/signal.c b/level_3/fss_read/c/main/signal.c new file mode 100644 index 0000000..5015838 --- /dev/null +++ b/level_3/fss_read/c/main/signal.c @@ -0,0 +1,113 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_fss_read_signal_check_) && defined(_di_thread_support_) + f_status_t fss_read_signal_check(fss_read_main_t * const main) { + + if (!main) return F_false; + if (main->program.signal.id == -1) return F_false; + + if (!((++main->program.signal_check) % fss_read_signal_check_d)) { + if (fll_program_standard_signal_received(&main->program)) { + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); + + main->setting.state.status = F_status_set_error(F_interrupt); + + return F_true; + } + + main->program.signal_check = 0; + } + + return F_false; + } +#endif // !defined(_di_fss_read_signal_check_) && defined(_di_thread_support_) + +#if !defined(_di_fss_read_signal_check_) && !defined(_di_thread_support_) + f_status_t fss_read_signal_check(fss_read_main_t * const main) { + + if (!main) return F_false; + if (main->program.signal.id == -1) return F_false; + + if (main->program.signal_received) { + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); + + main->setting.state.status = F_status_set_error(F_interrupt); + + return F_true; + } + + return F_false; + } +#endif // !defined(_di_fss_read_signal_check_) && !defined(_di_thread_support_) + +#if !defined(_di_fss_read_signal_handler_) && !defined(_di_thread_support_) + void fss_read_signal_handler(fss_read_main_t * const main) { + + if (!main) return; + + siginfo_t information; + f_array_length_t failsafe = 0; + + memset(&information, 0, sizeof(siginfo_t)); + + main->program.signal_received = 0; + + f_signal_set_empty(&main->program.signal.set); + f_signal_set_add(F_signal_abort, &main->program.signal.set); + f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set); + f_signal_set_add(F_signal_hangup, &main->program.signal.set); + f_signal_set_add(F_signal_interrupt, &main->program.signal.set); + f_signal_set_add(F_signal_quit, &main->program.signal.set); + f_signal_set_add(F_signal_termination, &main->program.signal.set); + + if (main->program.signal.id == -1) { + main->setting.status_thread = f_signal_open(&main->program.signal); + + if (F_status_is_error(main->setting.status_thread)) { + main->program.signal_received = F_signal_abort; + + return; + } + } + + do { + memset(&information, 0, sizeof(siginfo_t)); + + main->setting.status_thread = f_signal_wait(&main->program.signal.set, &information); + + if (F_status_is_error(main->setting.status_thread) && F_status_set_fine(main->setting.status_thread) != F_interrupt) { + if (++failsafe >= fss_read_signal_check_failsafe_d) break; + } + + switch (information.si_signo) { + case F_signal_abort: + case F_signal_broken_pipe: + case F_signal_hangup: + case F_signal_interrupt: + case F_signal_quit: + case F_signal_termination: + main->program.signal_received = information.si_signo; + + break; + } + + failsafe = 0; + main->setting.status_thread = F_none; + + } while (!main->program.signal_received); + + f_signal_close(&main->program.signal); + + if (F_status_is_error(main->setting.status_thread)) { + main->program.signal_received = F_signal_abort; + } + } +#endif // !defined(_di_fss_read_signal_handler_) && !defined(_di_thread_support_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/signal.h b/level_3/fss_read/c/main/signal.h new file mode 100644 index 0000000..68aeb51 --- /dev/null +++ b/level_3/fss_read/c/main/signal.h @@ -0,0 +1,86 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides signal functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_signal_h +#define _fss_read_signal_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Check to see if a signal is received. + * + * If main.signal is non-zero, then this handles the following signals: + * - F_signal_abort + * - F_signal_broken_pipe + * - F_signal_hangup + * - F_signal_interrupt + * - F_signal_quit + * - F_signal_termination + * + * There is a threaded and a non-threaded version of this. + * The non-threaded version checks periodically using fss_read_signal_check_d and updates main->signal_check as needed. + * The threaded version checks the flag state which is set by a separate thread that is blocking until signal is received. + * + * @param main + * The main program and settings data. + * + * This does not alter main.setting.state.status. + * + * @return + * F_true on signal received. + * F_false otherwise. + * + * @see fss_read_signal_handler() + * + * @see fll_program_standard_signal_received() + */ +#ifndef _di_fss_read_signal_check_ + extern f_status_t fss_read_signal_check(fss_read_main_t * const main); +#endif // _di_fss_read_signal_check_ + +/** + * Signal handler for signals/interrupts. + * + * This blocks until an expected signal is recieved. + * When an expected signal is received it then sets the + * + * If main.signal is non-zero, then this 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 and settings data. + * + * This alters main.program.signal_received, setting it to a received signal. + * + * This alters setting.status: + * Errors with (error bit set) from: f_signal_open() + * Errors with (error bit set) from: f_signal_wait() + * + * @see f_signal_close() + * @see f_signal_open() + * @see f_signal_wait() + */ +#if !defined(_di_fss_read_signal_handler_) && !defined(_di_thread_support_) + extern void fss_read_signal_handler(fss_read_main_t * const main); +#endif // !defined(_di_fss_read_signal_handler_) && !defined(_di_thread_support_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_signal_h diff --git a/level_3/fss_read/c/main/thread.c b/level_3/fss_read/c/main/thread.c new file mode 100644 index 0000000..e817d02 --- /dev/null +++ b/level_3/fss_read/c/main/thread.c @@ -0,0 +1,26 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_fss_read_thread_signal_) && !defined(_di_thread_support_) + void * fss_read_thread_signal(void * const main) { + + f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0); + + if (main) { + fss_read_signal_handler((fss_read_main_t *) main); + } + + return 0; + } +#endif // !defined(_di_fss_read_thread_signal_) && !defined(_di_thread_support_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/main/thread.h b/level_3/fss_read/c/main/thread.h new file mode 100644 index 0000000..e4b6682 --- /dev/null +++ b/level_3/fss_read/c/main/thread.h @@ -0,0 +1,46 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides thread functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_read_thread_h +#define _fss_read_thread_h + +/** + * Thread handler for signals/interrupts. + * + * If main.signal is non-zero, then this 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 program and settings data. + * + * Must be of type fss_read_main_t. + * + * @return + * 0, always. + * + * @see f_thread_cancel_state_set() + * + * @see fss_read_signal_handler() + */ +#if !defined(_di_fss_read_thread_signal_) && !defined(_di_thread_support_) + extern void * fss_read_thread_signal(void * const main); +#endif // !defined(_di_fss_read_thread_signal_) && !defined(_di_thread_support_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_thread_h diff --git a/level_3/fss_read/c/payload/common.c b/level_3/fss_read/c/payload/common.c new file mode 100644 index 0000000..eafdb0c --- /dev/null +++ b/level_3/fss_read/c/payload/common.c @@ -0,0 +1,23 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_payload_s_ + const f_string_static_t fss_read_payload_s = macro_f_string_static_t_initialize_1(FSS_READ_payload_s, 0, FSS_READ_payload_s_length); + + const f_string_static_t fss_read_payload_standard_s = macro_f_string_static_t_initialize_1(FSS_READ_payload_standard_s, 0, FSS_READ_payload_standard_s_length); + + const f_string_static_t fss_read_payload_program_name_s = macro_f_string_static_t_initialize_1(FSS_READ_payload_program_name_s, 0, FSS_READ_payload_program_name_s_length); + const f_string_static_t fss_read_payload_program_name_long_s = macro_f_string_static_t_initialize_1(FSS_READ_payload_program_name_long_s, 0, FSS_READ_payload_program_name_long_s_length); + + const f_string_static_t fss_read_format_code_short_000e_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_short_000e_s, 0, FSS_READ_format_code_short_000e_s_length); + const f_string_static_t fss_read_format_code_long_000e_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_long_000e_s, 0, FSS_READ_format_code_long_000e_s_length); + const f_string_static_t fss_read_format_code_human_000e_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_human_000e_s, 0, FSS_READ_format_code_human_000e_s_length); + const f_string_static_t fss_read_format_code_machine_000e_s = macro_f_string_static_t_initialize_1(FSS_READ_format_code_machine_000e_s, 0, FSS_READ_format_code_machine_000e_s_length); +#endif // _di_fss_read_payload_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/payload/common.h b/level_3/fss_read/c/payload/common.h new file mode 100644 index 0000000..7b762e8 --- /dev/null +++ b/level_3/fss_read/c/payload/common.h @@ -0,0 +1,64 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_read_payload_common_h +#define _fss_read_payload_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The FSS-000E (Payload) specific strings. + */ +#ifndef _di_fss_read_payload_s_ + #define FSS_READ_payload_s "payload" + + #define FSS_READ_payload_standard_s "FSS-000E (Payload)" + + #define FSS_READ_payload_program_name_s "fss_payload_read" + #define FSS_READ_payload_program_name_long_s "FSS Payload Read" + + #define FSS_READ_format_code_short_000e_s "000e" + #define FSS_READ_format_code_long_000e_s "fss-000e" + #define FSS_READ_format_code_human_000e_s "payload" + #define FSS_READ_format_code_machine_000e_s "payload" + + #define FSS_READ_payload_s_length 7 + + #define FSS_READ_payload_standard_s_length 18 + + #define FSS_READ_payload_program_name_s_length 16 + #define FSS_READ_payload_program_name_long_s_length 16 + + #define FSS_READ_format_code_short_000e_s_length 4 + #define FSS_READ_format_code_long_000e_s_length 8 + #define FSS_READ_format_code_human_000e_s_length 7 + #define FSS_READ_format_code_machine_000e_s_length 7 + + extern const f_string_static_t fss_read_payload_s; + + extern const f_string_static_t fss_read_payload_standard_s; + + extern const f_string_static_t fss_read_payload_program_name_s; + extern const f_string_static_t fss_read_payload_program_name_long_s; + + extern const f_string_static_t fss_read_format_code_short_000e_s; + extern const f_string_static_t fss_read_format_code_long_000e_s; + extern const f_string_static_t fss_read_format_code_human_000e_s; + extern const f_string_static_t fss_read_format_code_machine_000e_s; +#endif // _di_fss_read_payload_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_payload_common_h diff --git a/level_3/fss_read/c/payload/fss_read.c b/level_3/fss_read/c/payload/fss_read.c new file mode 100644 index 0000000..bcd85d1 --- /dev/null +++ b/level_3/fss_read/c/payload/fss_read.c @@ -0,0 +1,567 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_payload_process_help_ + void fss_read_payload_process_help(void * const void_main) { + + if (!void_main) return; + + fss_read_payload_print_help(&((fss_read_main_t *) void_main)->program.message); + } +#endif // _di_fss_read_payload_process_help_ + +#ifndef _di_fss_read_payload_process_pipe_ + void fss_read_payload_process_pipe(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + f_status_t status_pipe = F_none; + f_file_t input = f_file_t_initialize; + input.id = F_type_descriptor_input_d; + input.size_read = fss_read_allocation_large_d; + + f_array_length_t total = 0; + f_array_length_t length = 0; + f_string_range_t range = f_string_range_t_initialize; + + const f_array_length_t used_objects = main->setting.objects.used; + const f_array_length_t used_contentss = main->setting.contentss.used; + const f_array_length_t used_ignoress = main->setting.ignoress.used; + + main->setting.object = &main->setting.objects.array[used_objects]; + main->setting.contents = &main->setting.contentss.array[used_contentss]; + main->setting.ignores = &main->setting.ignoress.array[used_ignoress]; + + // 0x0 = nothing printed, 0x1 = something printed, 0x2 = ignore enabled, 0x4 = added Content for Object, 0x8 = "payload" matched. + uint8_t flag = 0; + + // 0x0 = start new object/content set, 0x1 = processing object, 0x2 = processing content, 0x3 = end object/content set, 0x4 = processing payload content. + uint8_t state = 0; + + // This is processed in a single set, so there is only ever one Object added. + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, &main->setting.objects); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); + + return; + } + + // This is processed in a single set, so there is only ever one Content added. + main->setting.state.status = f_string_dynamicss_increase(main->setting.state.step_small, &main->setting.contentss); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamicss_increase)); + + return; + } + + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); + + return; + } + + // This is processed in a single set, so there is only ever one Ignores added. + main->setting.state.status = f_string_rangess_increase(main->setting.state.step_small, &main->setting.ignoress); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_rangess_increase)); + + return; + } + + // Reset all of the used data before starting the loop. + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; + + for (;;) { + + if (!((++main->program.signal_check) % fss_read_signal_check_d)) { + if (fll_program_standard_signal_received(&main->program)) { + fll_program_print_signal_received(&main->program.warning, main->program.signal_received); + + main->setting.state.status = F_status_set_error(F_interrupt); + + break; + } + + main->program.signal_check = 0; + } + + if (range.start > range.stop) { + if (status_pipe == F_none_eof) break; + + main->setting.block.used = 0; + + status_pipe = f_file_read_block(input, &main->setting.block); + + if (F_status_is_error(status_pipe)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_file_read_block)); + + status_pipe = F_status_set_error(F_pipe); + + break; + } + + if (!main->setting.block.used) break; + + range.start = 0; + range.stop = main->setting.block.used - 1; + status_pipe = F_none; + } + + // Start Object. + if (!state || state == 0x1) { + if (!state) { + main->setting.object->used = 0; + + state = 0x1; + } + + // Reset the "has Content for Object" flag and associated contents array used length. + flag -= flag | 0x4; + main->setting.contents->used = 0; + + main->setting.state.status = f_string_dynamic_increase_by(main->setting.block.used, main->setting.object); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); + + break; + } + + for (; range.start <= range.stop && range.start < main->setting.block.used; ++range.start) { + + // Do not handle start/end while inside an ignore set. + if (!(flag & 0x2)) { + if (main->setting.block.string[range.start] == fss_read_pipe_content_start_s.string[0]) { + state = 0x2; + ++range.start; + + break; + } + + if (main->setting.block.string[range.start] == fss_read_pipe_content_end_s.string[0]) { + state = 0x3; + ++range.start; + + break; + } + } + + // There currently is no support for "ignore" in Objects, but the Ignore should still be processed. + if (main->setting.block.string[range.start] == fss_read_pipe_content_ignore_s.string[0]) { + + // Ignore is enabled. + if (flag & 0x2) { + flag -= 0x2; + } + else { + flag |= 0x2; + } + + continue; + } + + main->setting.object->string[main->setting.object->used++] = main->setting.block.string[range.start]; + } // for + + if (F_status_is_error(main->setting.state.status)) break; + + // If the start of Content was not found, then fetch the next block. + if (state == 0x1) continue; + + // If the end of the current block is reached, fetch the next block. + if (range.start > range.stop) continue; + } + + // Begin Content. + if (state == 0x2) { + + // Check to see if the Content supports multiple Content per Object. + if (flag & 0x4) { + if (!(main->setting.flag & fss_read_main_flag_content_multiple_e)) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_one_content_only(&main->program.error); + + break; + } + + main->setting.state.status = f_string_dynamics_increase(main->setting.state.step_small, main->setting.contents); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamics_increase)); + + break; + } + } + + if (range.start <= range.stop) { + total = (range.stop - range.start) + 1; + } + else { + total = 0; + } + + // When payload is provided, all data at this point is part of the payload until the end of the pipe. + if (f_compare_dynamic(f_fss_payload_s, *main->setting.object) == F_equal_to) { + if (total > 1) { + main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); + + break; + } + + memcpy(main->setting.contents->array[main->setting.contents->used].string, main->setting.block.string + range.start, sizeof(f_char_t) * total); + + main->setting.contents->array[main->setting.contents->used].used += total; + } + + state = 0x4; + flag |= 0x8; + + // Designate to read next block from pipe. + range.start = 1; + range.stop = 0; + + continue; + } + + if (total) { + main->setting.state.status = f_string_dynamic_increase_by(total, &main->setting.contents->array[main->setting.contents->used]); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); + + break; + } + + for (; range.start <= range.stop && range.start < main->setting.block.used; ++range.start) { + + // Do not handle start/end while inside an ignore set. + if (!(flag & 0x2)) { + if (main->setting.block.string[range.start] == fss_read_pipe_content_start_s.string[0]) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_one_content_only(&main->program.error); + + break; + } + + if (main->setting.block.string[range.start] == fss_read_pipe_content_end_s.string[0]) { + state = 0x3; + ++range.start; + + break; + } + } + + // There currently is no support for "ignore" in Contents, but the Ignore should still be processed. + if (main->setting.block.string[range.start] == fss_read_pipe_content_ignore_s.string[0]) { + + // Ignore is enabled. + if (flag & 0x2) { + flag -= 0x2; + } + else { + flag |= 0x2; + } + + continue; + } + + main->setting.contents->array[main->setting.contents->used].string[main->setting.contents->array[main->setting.contents->used].used++] = main->setting.block.string[range.start]; + } // for + + if (F_status_is_error(main->setting.state.status)) break; + + ++main->setting.contents->used; + flag |= 0x4; + } + else { + state = 0x3; + } + } + + // End Object or Content set. + if (state == 0x3) { + fss_read_payload_process_set(void_main); + if (F_status_is_error(main->setting.state.status)) break; + + state = 0; + flag |= 0x1; + + // Reset all of the used data for next set. + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; + + continue; + } + + // Payload Object. + if (state == 0x4) { + if (main->setting.block.used && range.start <= range.stop) { + length = (range.stop - range.start) + 1; + + main->setting.state.status = f_string_dynamic_increase_by(length + 1, &main->setting.contents->array[main->setting.contents->used]); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_increase_by)); + + break; + } + + memcpy(main->setting.contents->array[main->setting.contents->used].string + range.start, main->setting.block.string, sizeof(f_char_t) * length); + + main->setting.contents->array[main->setting.contents->used].used += length; + } + + // Designate to read next block from pipe. + range.start = 1; + range.stop = 0; + + // Reset all of the used data for next set. + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; + } + } // for + + // If the pipe ended before finishing, then attempt to wrap up. + if (F_status_is_error_not(main->setting.state.status) && status_pipe == F_none_eof && state) { + fss_read_payload_process_set(void_main); + + flag |= 0x1; + } + + main->setting.block.used = 0; + main->setting.buffer.used = 0; + main->setting.object->used = 0; + main->setting.contents->used = 0; + main->setting.ignores->used = 0; + main->setting.objects.used = used_objects; + main->setting.contentss.used = used_contentss; + main->setting.ignoress.used = used_ignoress; + + if (F_status_is_error_not(main->setting.state.status)) { + if (flag & 0x1) { + if (flag & 0x8) { + main->setting.state.status = F_payload; + } + else { + main->setting.state.status = F_none; + } + } + else { + main->setting.state.status = F_data_not; + } + + // Payload. + if (main->setting.contentss.used && (flag & 0x8)) { + fll_print_dynamic(f_fss_payload_header_close_s, main->program.output.to); + } + } + } +#endif // _di_fss_read_payload_process_pipe_ + +#ifndef _di_fss_read_payload_process_set_ + void fss_read_payload_process_set(void * const void_main) { + + if (!void_main) return; + + fss_read_main_t * const main = (fss_read_main_t *) void_main; + + if ((!(main->setting.flag & fss_read_main_flag_partial_e) || (main->setting.flag & fss_read_main_flag_partial_e) && (main->setting.flag & fss_read_main_flag_object_e))) { + if (main->setting.object && !(main->setting.flag & fss_read_main_flag_partial_e) && main->setting.contents && main->setting.contents->used) { + if (main->setting.object->used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.object->used - 1; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + + fll_fss_payload_write( + *main->setting.object, + main->setting.contents->array[0], + (main->setting.flag & fss_read_main_flag_trim_e), + (main->setting.flag & fss_read_main_flag_prepend_e) + ? &main->setting.prepend + : 0, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fll_fss_payload_write)); + + return; + } + } + else { + if (main->setting.object) { + if (main->setting.object->used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.object->used - 1; + } + else { + main->setting.range.start = 1; + main->setting.range.stop = 0; + } + + fl_fss_basic_list_object_write( + *main->setting.object, + (main->setting.flag & fss_read_main_flag_partial_e) + ? (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_trim_e + : f_fss_complete_none_e + : (main->setting.flag & fss_read_main_flag_trim_e) + ? f_fss_complete_full_trim_e + : f_fss_complete_full_e, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_set_fine(main->setting.state.status) == F_none_eol) { + main->setting.state.status = F_status_set_error(F_support_not); + + fss_read_print_error_unsupported_eol(&main->program.error); + + return; + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_basic_list_object_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_content_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_object_open_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_s, &main->setting.buffer); + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_open_end_s, &main->setting.buffer); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + + return; + } + } + } + } + } + else { + if (main->setting.contents && main->setting.contents->used && main->setting.contents->array[0].used) { + main->setting.range.start = 0; + main->setting.range.stop = main->setting.contents->array[0].used - 1; + + const f_string_static_t *prepend = 0; + + if (main->setting.flag & fss_read_main_flag_prepend_e) { + const f_array_length_t index = main->program.parameters.array[fss_read_parameter_prepend_e].values.array[main->program.parameters.array[fss_read_parameter_prepend_e].values.used - 1]; + + prepend = &main->program.parameters.arguments.array[index]; + } + + fl_fss_basic_list_content_write( + main->setting.contents->array[0], + main->setting.object + ? f_fss_complete_full_e + : f_fss_complete_none_e, + prepend, + &main->setting.range, + &main->setting.buffer, + &main->setting.state + ); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fl_fss_payload_content_write)); + + return; + } + } + + if ((main->setting.flag & fss_read_main_flag_partial_e) && !(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & (fss_read_main_flag_object_e | fss_read_main_flag_content_e))) { + if (main->setting.flag & fss_read_main_flag_content_end_e) { + main->setting.state.status = f_string_dynamic_append(f_fss_basic_list_close_s, &main->setting.buffer); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + + return; + } + } + } + } + + if (!main->setting.object || !(main->setting.contents && main->setting.contents->used)) { + main->setting.state.status = f_string_dynamic_append(f_string_eol_s, &main->setting.buffer); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + + return; + } + } + + fll_print_dynamic(main->setting.buffer, main->program.output.to); + + main->setting.buffer.used = 0; + main->setting.state.status = F_none; + } +#endif // _di_fss_read_payload_process_set_ + +#ifndef _di_fss_read_payload_setting_load_ + void fss_read_payload_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main) { + + if (!main) return; + + f_array_lengths_t * const values = &main->program.parameters.array[fss_read_parameter_object_e].values; + f_string_static_t * const argv = main->program.parameters.arguments.array; + + if ((main->program.parameters.array[fss_read_parameter_object_e].result & f_console_result_value_e) && values->used) { + for (f_array_length_t i = 0; i < values->used; ++i) { + + if (f_compare_dynamic(argv[values->array[i]], fss_read_payload_s) == F_equal_to && i + 1 < values->used) { + main->setting.state.status = F_status_set_error(F_parameter); + + fss_read_payload_print_error_payload_not_last(&main->program.error); + + return; + } + } // for + } + } +#endif // _di_fss_read_payload_setting_load_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/payload/fss_read.h b/level_3/fss_read/c/payload/fss_read.h new file mode 100644 index 0000000..31db3a3 --- /dev/null +++ b/level_3/fss_read/c/payload/fss_read.h @@ -0,0 +1,153 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * This program provides FSS write functionality for the FSS-000E Payload. + */ +#ifndef _fss_read_payload_h +#define _fss_read_payload_h + +// Libc includes. +#include +#include +#include +#include + +// FLL-0 includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// FLL-1 includes. +#include +#include +#include + +// FLL-2 includes. +#include +#include +#include +#include + +// FSS Write includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Process help for FSS-000E (Payload). + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This does not alter main.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fss_read_payload_process_help_ + extern void fss_read_payload_process_help(void * const main); +#endif // _di_fss_read_payload_process_help_ + +/** + * Process the pipe, reading from the pipe and writing to the output. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * F_data_not on success but pipe contained no relevant data. + * F_payload on success and the payload has been printed. + * F_interrupt on (exit) signal received. + * + * F_parameter (with error bit) if main is NULL or setting is NULL. + */ +#ifndef _di_fss_read_payload_process_pipe_ + extern void fss_read_payload_process_pipe(void * const main); +#endif // _di_fss_read_payload_process_pipe_ + +/** + * Process a given object and content, printing the FSS if valid or an error if invalid. + * + * @param main + * The program and settings data. + * Must be of type fss_read_main_t. + * + * This alters main.setting.state.status: + * F_none on success. + * F_interrupt on (exit) signal received. + * + * F_parameter (with error bit) if main is NULL or setting is NULL. + */ +#ifndef _di_fss_read_payload_process_set_ + extern void fss_read_payload_process_set(void * const main); +#endif // _di_fss_read_payload_process_set_ + +/** + * Perform the payload-specific 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.process_help, setting.process_normal, and setting.process_pipe. + * + * This alters setting.state.status: + * F_none on success. + * F_interrupt on (exit) signal received. + * + * F_parameter (with error bit) if main is NULL or setting is NULL. + * F_parameter (with error bit) on parameter error. + * + * This alters setting.state.status: + * F_none on success. + * F_data_not on success but nothing was provided to operate with. + * + * @see fss_read_setting_load() + */ +#ifndef _di_fss_read_payload_setting_load_ + extern void fss_read_payload_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main); +#endif // _di_fss_read_payload_setting_load_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_payload_h diff --git a/level_3/fss_read/c/payload/main.c b/level_3/fss_read/c/payload/main.c new file mode 100644 index 0000000..ce4b54b --- /dev/null +++ b/level_3/fss_read/c/payload/main.c @@ -0,0 +1,83 @@ +#include "fss_read.h" +#include "../main/fss_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + fss_read_main_t data = fss_read_main_t_initialize; + + data.program.debug.flag |= fss_read_print_flag_debug_e | fss_read_print_flag_out_e; + data.program.error.flag |= fss_read_print_flag_error_e | fss_read_print_flag_out_e; + data.program.output.flag |= fss_read_print_flag_out_e; + data.program.message.flag |= fss_read_print_flag_message_e | fss_read_print_flag_out_e; + data.program.warning.flag |= fss_read_print_flag_warning_e | fss_read_print_flag_out_e; + data.program.error.custom = (void *) &data; + data.program.debug.custom = (void *) &data; + data.program.message.custom = (void *) &data; + data.program.output.custom = (void *) &data; + data.program.warning.custom = (void *) &data; + + data.setting.state.custom = (void *) &data; + data.setting.standard = fss_read_payload_standard_s; + data.setting.process_content = 0; // Not used by payload. + data.setting.process_help = &fss_read_payload_process_help; + data.setting.process_normal = &fss_read_process_normal; + data.setting.process_object = 0; // Not used by payload. + data.setting.process_pipe = &fss_read_payload_process_pipe; + data.setting.process_set = &fss_read_payload_process_set; + + f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.used = fss_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); + + f_file_umask_get(&data.program.umask); + + #ifdef _di_thread_support_ + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, 0); + } + + fss_read_main(&data); + #else + { + f_thread_id_t id_signal; + + memset(&id_signal, 0, sizeof(f_thread_id_t)); + + data.setting.state.status = f_thread_create(0, &id_signal, &fss_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + fss_read_print_error(&data.program.error, macro_fss_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + fss_read_setting_load(arguments, &data, &fss_read_payload_setting_load); + } + + if (!fss_read_signal_check(&data)) { + fss_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + fss_read_main_delete(&data); + + fll_program_standard_set_down(&data.program); + + return F_status_is_error(data.setting.state.status) ? 1 : 0; +} diff --git a/level_3/fss_read/c/payload/main.h b/level_3/fss_read/c/payload/main.h new file mode 100644 index 0000000..b15b15b --- /dev/null +++ b/level_3/fss_read/c/payload/main.h @@ -0,0 +1,38 @@ +/** + * FLL - Level 3 + * + * Project: FSS 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_write" program functionality in some manner. + */ +#ifndef _fss_read_payload_main_h +#define _fss_read_payload_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_read_payload_main_h diff --git a/level_3/fss_read/c/payload/print.c b/level_3/fss_read/c/payload/print.c new file mode 100644 index 0000000..0e83576 --- /dev/null +++ b/level_3/fss_read/c/payload/print.c @@ -0,0 +1,57 @@ +#include "fss_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_read_payload_print_error_payload_not_last_ + f_status_t fss_read_payload_print_error_payload_not_last(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + if (!print || print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%r%[%QThe payload may only be specified last.%]%r", print->to, f_string_eol_s, print->set->error, print->prefix, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_payload_print_error_payload_not_last_ + +#ifndef _di_fss_read_payload_print_help_ + f_status_t fss_read_payload_print_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_payload_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_payload_program_name_s, f_string_empty_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_end_next(print); + + fl_print_format("%r The FSS-000E (Payload) specification does not support quoted names, therefore the parameters '%[%r%r%]'", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_single_s, print->set->notable); + fl_print_format(" and '%[%r%r%]' do nothing.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_double_s, print->set->notable, f_string_eol_s, f_string_eol_s); + + fl_print_format(" This program does not use the parameter '%[%r%r%]', which therefore does nothing.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_ignore_s, print->set->notable, f_string_eol_s); + fl_print_format(" This parameter requires two values.%r", print->to, f_string_eol_s); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_none; + } +#endif // _di_fss_read_payload_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_read/c/payload/print.h b/level_3/fss_read/c/payload/print.h new file mode 100644 index 0000000..a2240d6 --- /dev/null +++ b/level_3/fss_read/c/payload/print.h @@ -0,0 +1,57 @@ +/** + * FLL - Level 3 + * + * Project: FSS Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + */ +#ifndef _fss_read_payload_print_h +#define _fss_read_payload_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print error message about the "payload" not being specified last (when it is specified at all). + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + * + * @see fll_error_print() + */ +#ifndef _di_fss_read_payload_print_error_payload_not_last_ + extern f_status_t fss_read_payload_print_error_payload_not_last(fl_print_t * const print); +#endif // _di_fss_read_payload_print_error_payload_not_last_ + +/** + * Print help for FSS-000E (Payload). + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_payload_print_help_ + extern f_status_t fss_read_payload_print_help(fl_print_t * const print); +#endif // _di_fss_read_payload_print_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_read_payload_print_h diff --git a/level_3/fss_read/data/build/defines b/level_3/fss_read/data/build/defines new file mode 100644 index 0000000..490da41 --- /dev/null +++ b/level_3/fss_read/data/build/defines @@ -0,0 +1,6 @@ +# 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_read/data/build/dependencies b/level_3/fss_read/data/build/dependencies new file mode 100644 index 0000000..22cdeb6 --- /dev/null +++ b/level_3/fss_read/data/build/dependencies @@ -0,0 +1,31 @@ +# 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_read/data/build/fakefile b/level_3/fss_read/data/build/fakefile new file mode 100644 index 0000000..9b0ae47 --- /dev/null +++ b/level_3/fss_read/data/build/fakefile @@ -0,0 +1,44 @@ +# fss-0005 iki-0002 +# +# Builds the fss_read library and all programs. +# + +settings: + fail exit + modes individual level monolithic clang test + + 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 settings + build settings.main + build settings.basic + build settings.basic_list + build settings.extended + build settings.extended_list + build settings.embedded_list + build settings.payload + +install: + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.main + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.basic + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.basic_list + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.extended + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.extended_list + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.embedded_list + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.payload + +help: + print + print context:'title'Fakefile Options for FSS 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_read/data/build/settings b/level_3/fss_read/data/build/settings new file mode 100644 index 0000000..935c4f1 --- /dev/null +++ b/level_3/fss_read/data/build/settings @@ -0,0 +1,86 @@ +# fss-0001 +# +# Builds the main library of the project with all parts except "main" program related. +# +# 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_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 main/fss_read.c main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c main/print/error.c main/print/message.c main/signal.c main/thread.c +build_sources_library basic/fss_read.c basic/common.c basic/print.c +build_sources_library basic_list/fss_read.c basic_list/common.c basic_list/print.c +build_sources_library embedded_list/fss_read.c embedded_list/common.c embedded_list/print.c +build_sources_library extended/fss_read.c extended/common.c extended/print.c +build_sources_library extended_list/fss_read.c extended_list/common.c extended_list/print.c +build_sources_library payload/fss_read.c payload/common.c payload/print.c + +build_sources_headers main/fss_read.h main/common.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h main/print/error.h main/print/message.h main/signal.h main/thread.h +build_sources_headers basic/fss_read.h basic/common.h basic/print.h basic/private-common.h +build_sources_headers basic_list/fss_read.h basic_list/common.h basic_list/print.h +build_sources_headers embedded_list/fss_read.h embedded_list/common.h embedded_list/print.h +build_sources_headers extended/fss_read.h extended/common.h extended/print.h +build_sources_headers extended_list/fss_read.h extended_list/common.h extended_list/print.h +build_sources_headers payload/fss_read.h payload/common.h payload/print.h + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_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_read/data/build/settings.basic b/level_3/fss_read/data/build/settings.basic new file mode 100644 index 0000000..3fadcfa --- /dev/null +++ b/level_3/fss_read/data/build/settings.basic @@ -0,0 +1,63 @@ +# fss-0001 +# +# Builds the "basic" program (fss_basic_read). +# This must be called after the "setting". +# + +build_name fss_basic_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test fanalyzer thread individual-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 -lfss_read +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_program basic/main.c + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_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-threadless -D_di_thread_support_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_libcap_legacy_only_ + +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-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_read/data/build/settings.basic_list b/level_3/fss_read/data/build/settings.basic_list new file mode 100644 index 0000000..09fa085 --- /dev/null +++ b/level_3/fss_read/data/build/settings.basic_list @@ -0,0 +1,63 @@ +# fss-0001 +# +# Builds the "basic_list" program (fss_basic_list_read). +# This must be called after the "setting". +# + +build_name fss_basic_list_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test fanalyzer thread individual-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 -lfss_read +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_program basic_list/main.c + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_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-threadless -D_di_thread_support_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_libcap_legacy_only_ + +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-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_read/data/build/settings.embedded_list b/level_3/fss_read/data/build/settings.embedded_list new file mode 100644 index 0000000..d2ac525 --- /dev/null +++ b/level_3/fss_read/data/build/settings.embedded_list @@ -0,0 +1,63 @@ +# fss-0001 +# +# Builds the "embedded_list" program (fss_embedded_list_read). +# This must be called after the "setting". +# + +build_name fss_embedded_list_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test fanalyzer thread individual-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 -lfss_read +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_program embedded_list/main.c + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_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-threadless -D_di_thread_support_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_libcap_legacy_only_ + +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-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_read/data/build/settings.extended b/level_3/fss_read/data/build/settings.extended new file mode 100644 index 0000000..d6bd610 --- /dev/null +++ b/level_3/fss_read/data/build/settings.extended @@ -0,0 +1,63 @@ +# fss-0001 +# +# Builds the "extended" program (fss_extended_read). +# This must be called after the "setting". +# + +build_name fss_extended_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test fanalyzer thread individual-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 -lfss_read +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_program extended/main.c + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_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-threadless -D_di_thread_support_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_libcap_legacy_only_ + +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-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_read/data/build/settings.extended_list b/level_3/fss_read/data/build/settings.extended_list new file mode 100644 index 0000000..d82b6d9 --- /dev/null +++ b/level_3/fss_read/data/build/settings.extended_list @@ -0,0 +1,63 @@ +# fss-0001 +# +# Builds the "extended_list" program (fss_extended_list_read). +# This must be called after the "setting". +# + +build_name fss_extended_list_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test fanalyzer thread individual-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 -lfss_read +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_program extended_list/main.c + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_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-threadless -D_di_thread_support_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_libcap_legacy_only_ + +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-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_read/data/build/settings.main b/level_3/fss_read/data/build/settings.main new file mode 100644 index 0000000..3e46e8a --- /dev/null +++ b/level_3/fss_read/data/build/settings.main @@ -0,0 +1,63 @@ +# fss-0001 +# +# Builds the "main" program (fss_read). +# This must be called after the "setting". +# + +build_name fss_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test fanalyzer thread individual-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 -lfss_read +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_program main/main.c main/main/print.c + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_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-threadless -D_di_thread_support_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_libcap_legacy_only_ + +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-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_read/data/build/settings.payload b/level_3/fss_read/data/build/settings.payload new file mode 100644 index 0000000..0c5c957 --- /dev/null +++ b/level_3/fss_read/data/build/settings.payload @@ -0,0 +1,63 @@ +# fss-0001 +# +# Builds the "payload" program (fss_payload_read). +# This must be called after the "setting". +# + +build_name fss_payload_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual level monolithic clang test fanalyzer thread individual-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 -lfss_read +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_program payload/main.c + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/fss_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-threadless -D_di_thread_support_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_libcap_legacy_only_ + +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-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_read/data/documentation/man/man1/fss_basic_list_read.1 b/level_3/fss_read/data/documentation/man/man1/fss_basic_list_read.1 new file mode 100644 index 0000000..03d3bbb --- /dev/null +++ b/level_3/fss_read/data/documentation/man/man1/fss_basic_list_read.1 @@ -0,0 +1,145 @@ +.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_read/data/documentation/man/man1/fss_basic_read.1 b/level_3/fss_read/data/documentation/man/man1/fss_basic_read.1 new file mode 100644 index 0000000..d5710d7 --- /dev/null +++ b/level_3/fss_read/data/documentation/man/man1/fss_basic_read.1 @@ -0,0 +1,145 @@ +.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_read/data/documentation/man/man1/fss_embedded_list_read.1 b/level_3/fss_read/data/documentation/man/man1/fss_embedded_list_read.1 new file mode 100644 index 0000000..adae22d --- /dev/null +++ b/level_3/fss_read/data/documentation/man/man1/fss_embedded_list_read.1 @@ -0,0 +1,144 @@ +.TH FSS_EMBEDDED_LIST_READ "1" "March 2023" "FLL - FSS Embedded List Read 0.7.0" "User Commands" +.SH NAME +fss_embedded_list_read \- Read data in \fBFSS-0008 (Embedded List)\fR format. +.SH SYNOPSIS +.B fss_embedded_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-0008 Embedded 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. + \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_read/data/documentation/man/man1/fss_extended_list_read.1 b/level_3/fss_read/data/documentation/man/man1/fss_extended_list_read.1 new file mode 100644 index 0000000..d30cf34 --- /dev/null +++ b/level_3/fss_read/data/documentation/man/man1/fss_extended_list_read.1 @@ -0,0 +1,145 @@ +.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_read/data/documentation/man/man1/fss_extended_read.1 b/level_3/fss_read/data/documentation/man/man1/fss_extended_read.1 new file mode 100644 index 0000000..73887e9 --- /dev/null +++ b/level_3/fss_read/data/documentation/man/man1/fss_extended_read.1 @@ -0,0 +1,145 @@ +.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_read/data/documentation/man/man1/fss_payload_read.1 b/level_3/fss_read/data/documentation/man/man1/fss_payload_read.1 new file mode 100644 index 0000000..4b72316 --- /dev/null +++ b/level_3/fss_read/data/documentation/man/man1/fss_payload_read.1 @@ -0,0 +1,150 @@ +.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. diff --git a/level_3/fss_write/c/main/common/type.h b/level_3/fss_write/c/main/common/type.h index ef7a094..2985fea 100644 --- a/level_3/fss_write/c/main/common/type.h +++ b/level_3/fss_write/c/main/common/type.h @@ -17,7 +17,7 @@ extern "C" { #endif /** - * The fss payload write main program settings. + * The fss write 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).