From: Kevin Day Date: Wed, 4 Dec 2024 02:37:07 +0000 (-0600) Subject: Progress: Begin adding eki_read program by extending iki_read. X-Git-Tag: 0.7.0~18 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=21ae35744a1cfc7703fe3ac13b25ff7a71fa2d59;p=fll Progress: Begin adding eki_read program by extending iki_read. Setup the most basic functionality. Currently they are both performing iki_read functionality. The two programs require a different data structure. I need to plan on how to handle this. I may end up using callbacks and possibly a void pointer for data. --- diff --git a/level_3/iki_read/c/eki/common.c b/level_3/iki_read/c/eki/common.c new file mode 100644 index 0000000..13f9a64 --- /dev/null +++ b/level_3/iki_read/c/eki/common.c @@ -0,0 +1,25 @@ +#include "eki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_iki_read_eki_s_ + const f_string_static_t iki_read_program_name_s = macro_f_string_static_t_initialize_1(IKI_READ_program_name_s, 0, IKI_READ_program_name_s_length); + const f_string_static_t iki_read_program_name_long_s = macro_f_string_static_t_initialize_1(IKI_READ_program_name_long_s, 0, IKI_READ_program_name_long_s_length); +#endif // _di_iki_read_eki_s_ + +#ifndef _di_iki_read_eki_setting_load_ + void iki_read_eki_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main) { + + if (!main) return; + + if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) return; + if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) return; + if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) return; + } +#endif // _di_iki_read_eki_setting_load_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/eki/common.h b/level_3/iki_read/c/eki/common.h new file mode 100644 index 0000000..ded06f1 --- /dev/null +++ b/level_3/iki_read/c/eki/common.h @@ -0,0 +1,66 @@ +/** + * FLL - Level 3 + * + * Project: IKI 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 _iki_read_eki_common_h +#define _iki_read_eki_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The IKI read specific strings. + */ +#ifndef _di_iki_read_eki_s_ + #define IKI_READ_program_name_s "eki_read" + #define IKI_READ_program_name_long_s "EKI Read" + + #define IKI_READ_program_name_s_length 8 + #define IKI_READ_program_name_long_s_length 8 + + extern const f_string_static_t iki_read_program_name_s; + extern const f_string_static_t iki_read_program_name_long_s; +#endif // _di_iki_read_eki_s_ + +/** + * Perform the program setting load process for IKI. + * + * 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 program and settings data. + * + * This alters main.setting.state.status: + * F_okay on success. + * + * Errors (with error bit) from: f_console_parameter_process(). + * Errors (with error bit) from: f_file_stream_open(). + * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). + * + * @see f_console_parameter_process() + * @see f_file_stream_open() + * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_verbosity_standard() + */ +#ifndef _di_iki_read_eki_setting_load_ + extern void iki_read_eki_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main); +#endif // _di_iki_read_eki_setting_load_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_eki_common_h diff --git a/level_3/iki_read/c/eki/eki_read.c b/level_3/iki_read/c/eki/eki_read.c new file mode 100644 index 0000000..4adb66a --- /dev/null +++ b/level_3/iki_read/c/eki/eki_read.c @@ -0,0 +1,9 @@ +#include "eki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/eki/eki_read.h b/level_3/iki_read/c/eki/eki_read.h new file mode 100644 index 0000000..6519e3d --- /dev/null +++ b/level_3/iki_read/c/eki/eki_read.h @@ -0,0 +1,80 @@ +/** + * FLL - Level 3 + * + * Project: IKI Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the eki_read functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_eki_eki_read_h +#define _iki_read_eki_eki_read_h + +#ifdef __cplusplus +extern "C" { +#endif + +// Libc includes. +#include +#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 +#include + +// FLL-2 includes. +#include +#include +#include +#include + +// IKI Read includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_eki_eki_read_h diff --git a/level_3/iki_read/c/eki/main.c b/level_3/iki_read/c/eki/main.c new file mode 100644 index 0000000..12dfdb9 --- /dev/null +++ b/level_3/iki_read/c/eki/main.c @@ -0,0 +1,79 @@ +#include "eki_read.h" +#include "../main/iki_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + iki_read_main_t data = iki_read_main_t_initialize; + + data.program.debug.flag |= iki_read_print_flag_debug_d | iki_read_print_flag_out_d; + data.program.error.flag |= iki_read_print_flag_error_d | iki_read_print_flag_out_d; + data.program.output.flag |= iki_read_print_flag_out_d; + data.program.message.flag |= iki_read_print_flag_message_d | iki_read_print_flag_out_d; + data.program.warning.flag |= iki_read_print_flag_warning_d | iki_read_print_flag_out_d; + 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.state.handle = &fll_program_standard_signal_handle; + + data.callback.print_help = &iki_read_eki_print_message_help; + //data.callback.process_objects_content = &iki_read_eki_process_objects_content; + + f_console_parameter_t parameters[] = iki_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.used = iki_read_parameter_total_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); + + iki_read_setting_load(arguments, &data, &iki_read_eki_setting_load); + } + + iki_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, &iki_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + iki_read_print_error(&data.program.error, macro_iki_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + iki_read_setting_load(arguments, &data, &iki_read_eki_setting_load); + } + + if (!iki_read_signal_check(&data)) { + iki_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + iki_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/iki_read/c/eki/main.h b/level_3/iki_read/c/eki/main.h new file mode 100644 index 0000000..9ead84d --- /dev/null +++ b/level_3/iki_read/c/eki/main.h @@ -0,0 +1,23 @@ +/** + * FLL - Level 3 + * + * Project: IKI Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the main functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_eki_main_h +#define _iki_read_eki_main_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_eki_main_h diff --git a/level_3/iki_read/c/eki/print.c b/level_3/iki_read/c/eki/print.c new file mode 100644 index 0000000..1e992f7 --- /dev/null +++ b/level_3/iki_read/c/eki/print.c @@ -0,0 +1,31 @@ +#include "eki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_iki_read_eki_print_message_help_ + void iki_read_eki_print_message_help(fl_print_t * const print) { + + if (!print) return; + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, iki_read_program_name_long_s, iki_read_program_version_s); + + iki_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, iki_read_program_name_s, f_string_empty_s); + + iki_read_print_message_help_note(print); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + } +#endif // _di_iki_read_eki_print_message_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/eki/print.h b/level_3/iki_read/c/eki/print.h new file mode 100644 index 0000000..7a92e6e --- /dev/null +++ b/level_3/iki_read/c/eki/print.h @@ -0,0 +1,35 @@ +/** + * FLL - Level 3 + * + * Project: IKI Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_eki_print_h +#define _iki_read_eki_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print help for EKI read. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_iki_read_eki_print_message_help_ + extern void iki_read_eki_print_message_help(fl_print_t * const print); +#endif // _di_iki_read_eki_print_message_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_eki_print_h diff --git a/level_3/iki_read/c/eki/process.c b/level_3/iki_read/c/eki/process.c new file mode 100644 index 0000000..4adb66a --- /dev/null +++ b/level_3/iki_read/c/eki/process.c @@ -0,0 +1,9 @@ +#include "eki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/eki/process.h b/level_3/iki_read/c/eki/process.h new file mode 100644 index 0000000..9a8adff --- /dev/null +++ b/level_3/iki_read/c/eki/process.h @@ -0,0 +1,23 @@ +/** + * FLL - Level 3 + * + * Project: IKI Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the process functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_eki_process_h +#define _iki_read_eki_process_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_eki_process_h diff --git a/level_3/iki_read/c/iki/common.c b/level_3/iki_read/c/iki/common.c new file mode 100644 index 0000000..74d70b1 --- /dev/null +++ b/level_3/iki_read/c/iki/common.c @@ -0,0 +1,25 @@ +#include "iki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_iki_read_iki_s_ + const f_string_static_t iki_read_program_name_s = macro_f_string_static_t_initialize_1(IKI_READ_program_name_s, 0, IKI_READ_program_name_s_length); + const f_string_static_t iki_read_program_name_long_s = macro_f_string_static_t_initialize_1(IKI_READ_program_name_long_s, 0, IKI_READ_program_name_long_s_length); +#endif // _di_iki_read_iki_s_ + +#ifndef _di_iki_read_iki_setting_load_ + void iki_read_iki_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main) { + + if (!main) return; + + if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) return; + if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) return; + if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) return; + } +#endif // _di_iki_read_iki_setting_load_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/iki/common.h b/level_3/iki_read/c/iki/common.h new file mode 100644 index 0000000..5c831ce --- /dev/null +++ b/level_3/iki_read/c/iki/common.h @@ -0,0 +1,66 @@ +/** + * FLL - Level 3 + * + * Project: IKI 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 _iki_read_iki_common_h +#define _iki_read_iki_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The IKI read specific strings. + */ +#ifndef _di_iki_read_iki_s_ + #define IKI_READ_program_name_s "iki_read" + #define IKI_READ_program_name_long_s "IKI Read" + + #define IKI_READ_program_name_s_length 8 + #define IKI_READ_program_name_long_s_length 8 + + extern const f_string_static_t iki_read_program_name_s; + extern const f_string_static_t iki_read_program_name_long_s; +#endif // _di_iki_read_iki_s_ + +/** + * Perform the program setting load process for IKI. + * + * 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 program and settings data. + * + * This alters main.setting.state.status: + * F_okay on success. + * + * Errors (with error bit) from: f_console_parameter_process(). + * Errors (with error bit) from: f_file_stream_open(). + * Errors (with error bit) from: fll_program_parameter_process_context(). + * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). + * + * @see f_console_parameter_process() + * @see f_file_stream_open() + * @see fll_program_parameter_process_context() + * @see fll_program_parameter_process_verbosity_standard() + */ +#ifndef _di_iki_read_iki_setting_load_ + extern void iki_read_iki_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main); +#endif // _di_iki_read_iki_setting_load_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_iki_common_h diff --git a/level_3/iki_read/c/iki/iki_read.c b/level_3/iki_read/c/iki/iki_read.c new file mode 100644 index 0000000..827d0df --- /dev/null +++ b/level_3/iki_read/c/iki/iki_read.c @@ -0,0 +1,9 @@ +#include "iki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/iki/iki_read.h b/level_3/iki_read/c/iki/iki_read.h new file mode 100644 index 0000000..1b95376 --- /dev/null +++ b/level_3/iki_read/c/iki/iki_read.h @@ -0,0 +1,80 @@ +/** + * FLL - Level 3 + * + * Project: IKI Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the iki_read functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_iki_iki_read_h +#define _iki_read_iki_iki_read_h + +#ifdef __cplusplus +extern "C" { +#endif + +// Libc includes. +#include +#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 +#include + +// FLL-2 includes. +#include +#include +#include +#include + +// IKI Read includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_iki_iki_read_h diff --git a/level_3/iki_read/c/iki/main.c b/level_3/iki_read/c/iki/main.c new file mode 100644 index 0000000..ab3796a --- /dev/null +++ b/level_3/iki_read/c/iki/main.c @@ -0,0 +1,79 @@ +#include "iki_read.h" +#include "../main/iki_read.h" + +int main(const int argc, const f_string_t *argv, const f_string_t *envp) { + + iki_read_main_t data = iki_read_main_t_initialize; + + data.program.debug.flag |= iki_read_print_flag_debug_d | iki_read_print_flag_out_d; + data.program.error.flag |= iki_read_print_flag_error_d | iki_read_print_flag_out_d; + data.program.output.flag |= iki_read_print_flag_out_d; + data.program.message.flag |= iki_read_print_flag_message_d | iki_read_print_flag_out_d; + data.program.warning.flag |= iki_read_print_flag_warning_d | iki_read_print_flag_out_d; + 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.state.handle = &fll_program_standard_signal_handle; + + data.callback.print_help = &iki_read_iki_print_message_help; + //data.callback.process_objects_content = &iki_read_iki_process_objects_content; + + f_console_parameter_t parameters[] = iki_read_console_parameter_t_initialize; + data.program.parameters.array = parameters; + data.program.parameters.used = iki_read_parameter_total_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); + + iki_read_setting_load(arguments, &data, &iki_read_iki_setting_load); + } + + iki_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, &iki_read_thread_signal, (void *) &data); + + if (F_status_is_error(data.setting.state.status)) { + iki_read_print_error(&data.program.error, macro_iki_read_f(f_thread_create)); + } + else { + { + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp); + + iki_read_setting_load(arguments, &data, &iki_read_iki_setting_load); + } + + if (!iki_read_signal_check(&data)) { + iki_read_main(&data); + } + + f_thread_cancel(id_signal); + f_thread_join(id_signal, 0); + } + } + #endif // _di_thread_support_ + + iki_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/iki_read/c/iki/main.h b/level_3/iki_read/c/iki/main.h new file mode 100644 index 0000000..6321ad8 --- /dev/null +++ b/level_3/iki_read/c/iki/main.h @@ -0,0 +1,23 @@ +/** + * FLL - Level 3 + * + * Project: IKI Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the main functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_iki_main_h +#define _iki_read_iki_main_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_iki_main_h diff --git a/level_3/iki_read/c/iki/print.c b/level_3/iki_read/c/iki/print.c new file mode 100644 index 0000000..4a254f1 --- /dev/null +++ b/level_3/iki_read/c/iki/print.c @@ -0,0 +1,31 @@ +#include "iki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_iki_read_iki_print_message_help_ + void iki_read_iki_print_message_help(fl_print_t * const print) { + + if (!print) return; + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, iki_read_program_name_long_s, iki_read_program_version_s); + + iki_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, iki_read_program_name_s, f_string_empty_s); + + iki_read_print_message_help_note(print); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + } +#endif // _di_iki_read_iki_print_message_help_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/iki/print.h b/level_3/iki_read/c/iki/print.h new file mode 100644 index 0000000..9c33b2f --- /dev/null +++ b/level_3/iki_read/c/iki/print.h @@ -0,0 +1,35 @@ +/** + * FLL - Level 3 + * + * Project: IKI Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_iki_print_h +#define _iki_read_iki_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print help for IKI read. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_iki_read_iki_print_message_help_ + extern void iki_read_iki_print_message_help(fl_print_t * const print); +#endif // _di_iki_read_iki_print_message_help_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_iki_print_h diff --git a/level_3/iki_read/c/iki/process.c b/level_3/iki_read/c/iki/process.c new file mode 100644 index 0000000..827d0df --- /dev/null +++ b/level_3/iki_read/c/iki/process.c @@ -0,0 +1,9 @@ +#include "iki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/iki/process.h b/level_3/iki_read/c/iki/process.h new file mode 100644 index 0000000..6b1c64c --- /dev/null +++ b/level_3/iki_read/c/iki/process.h @@ -0,0 +1,23 @@ +/** + * FLL - Level 3 + * + * Project: IKI Read + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the process functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_iki_process_h +#define _iki_read_iki_process_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_iki_process_h diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index 5d409ff..0bd534a 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -5,13 +5,19 @@ extern "C" { #endif #ifndef _di_iki_read_setting_load_ - void iki_read_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main) { + void iki_read_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main, void (*callback)(const f_console_arguments_t arguments, iki_read_main_t * const main)) { if (!main) 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; + + f_console_parameters_t * const parameters = &main->program.parameters; + main->setting.state.step_small = iki_read_allocation_console_d; - f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); + f_console_parameter_process(arguments, parameters, &main->setting.state, 0); main->setting.state.step_small = iki_read_allocation_small_d; @@ -37,19 +43,30 @@ extern "C" { return; } - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_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_okay; + + return; + } + } + + if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { main->setting.flag |= iki_read_main_flag_help_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { main->setting.flag |= iki_read_main_flag_version_d; return; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { main->setting.flag |= iki_read_main_flag_copyright_d; return; @@ -62,7 +79,7 @@ extern "C" { main->setting.flag &= ~iki_read_main_flag_pipe_d; } - if (!(main->program.parameters.remaining.used || (main->program.pipe & fll_program_data_pipe_input_e))) { + if (!(parameters->remaining.used || (main->program.pipe & fll_program_data_pipe_input_e))) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_missing_file(&main->program.error); @@ -70,8 +87,13 @@ extern "C" { return; } - if (main->program.parameters.array[iki_read_parameter_at_e].result & f_console_result_value_e) { - if (main->program.parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { + f_number_unsigned_t index = 0; + f_number_unsigned_t at = 0; + f_number_unsigned_t i = 0; + f_number_unsigned_t j = 0; + + if (parameters->array[iki_read_parameter_at_e].result & f_console_result_value_e) { + if (parameters->array[iki_read_parameter_whole_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_at_s, iki_read_long_whole_s); @@ -79,11 +101,11 @@ extern "C" { return; } - const f_number_unsigned_t index = main->program.parameters.array[iki_read_parameter_at_e].values.array[main->program.parameters.array[iki_read_parameter_at_e].values.used - 1]; + index = parameters->array[iki_read_parameter_at_e].values.array[parameters->array[iki_read_parameter_at_e].values.used - 1]; main->setting.at = 0; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.at); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], &main->setting.at); // Negative numbers are not supported. if (main->setting.state.status == F_number_negative) { @@ -93,14 +115,14 @@ extern "C" { if (F_status_is_error(main->setting.state.status)) { main->setting.state.status = F_status_set_error(F_parameter); - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_at_s, main->program.parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_at_s, parameters->arguments.array[index]); return; } main->setting.flag |= iki_read_main_flag_at_d; } - else if (main->program.parameters.array[iki_read_parameter_at_e].result & f_console_result_found_e) { + else if (parameters->array[iki_read_parameter_at_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_at_s); @@ -108,12 +130,12 @@ extern "C" { return; } - if (main->program.parameters.array[iki_read_parameter_line_e].result & f_console_result_value_e) { - const f_number_unsigned_t index = main->program.parameters.array[iki_read_parameter_line_e].values.array[main->program.parameters.array[iki_read_parameter_line_e].values.used - 1]; + if (parameters->array[iki_read_parameter_line_e].result & f_console_result_value_e) { + index = parameters->array[iki_read_parameter_line_e].values.array[parameters->array[iki_read_parameter_line_e].values.used - 1]; main->setting.line = 0; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, main->program.parameters.arguments.array[index], &main->setting.line); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], &main->setting.line); // Negative numbers are not supported. if (main->setting.state.status == F_number_negative) { @@ -123,14 +145,14 @@ extern "C" { if (F_status_is_error(main->setting.state.status)) { main->setting.state.status = F_status_set_error(F_parameter); - fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_line_s, main->program.parameters.arguments.array[index]); + fll_program_print_error_parameter_integer_not(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_line_s, parameters->arguments.array[index]); return; } main->setting.flag |= iki_read_main_flag_line_d; } - else if (main->program.parameters.array[iki_read_parameter_line_e].result & f_console_result_found_e) { + else if (parameters->array[iki_read_parameter_line_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_line_s); @@ -138,10 +160,10 @@ extern "C" { return; } - if (main->program.parameters.array[iki_read_parameter_name_e].result & f_console_result_value_e) { + if (parameters->array[iki_read_parameter_name_e].result & f_console_result_value_e) { main->setting.names.used = 0; - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.array[iki_read_parameter_name_e].values.used, sizeof(f_string_dynamic_t), (void **) &main->setting.names.array, &main->setting.names.used, &main->setting.names.size); + main->setting.state.status = f_memory_array_increase_by(parameters->array[iki_read_parameter_name_e].values.used, sizeof(f_string_dynamic_t), (void **) &main->setting.names.array, &main->setting.names.used, &main->setting.names.size); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error(&main->program.error, macro_iki_read_f(f_memory_array_increase_by)); @@ -150,22 +172,22 @@ extern "C" { } // Distinctly append all names. - f_number_unsigned_t i = 0; - f_number_unsigned_t j = 0; - f_number_unsigneds_t *values = &main->program.parameters.array[iki_read_parameter_name_e].values; + f_number_unsigneds_t *values = ¶meters->array[iki_read_parameter_name_e].values; + + j = 0; - for (; i < values->used; ++i) { + for (i = 0; i < values->used; ++i) { for (j = 0; j < main->setting.names.used; ++j) { - if (f_compare_dynamic(main->program.parameters.arguments.array[values->array[i]], main->setting.names.array[j]) == F_equal_to) break; + if (f_compare_dynamic(parameters->arguments.array[values->array[i]], main->setting.names.array[j]) == F_equal_to) break; } // for if (j < main->setting.names.used) continue; main->setting.names.array[main->setting.names.used].used = 0; - if (main->program.parameters.arguments.array[values->array[i]].used) { - main->setting.state.status = f_string_dynamics_append(main->program.parameters.arguments.array[values->array[i]], &main->setting.names); + if (parameters->arguments.array[values->array[i]].used) { + main->setting.state.status = f_string_dynamics_append(parameters->arguments.array[values->array[i]], &main->setting.names); if (F_status_is_error(main->setting.state.status)) break; } else { @@ -182,7 +204,7 @@ extern "C" { main->setting.flag |= iki_read_main_flag_name_d; } - else if (main->program.parameters.array[iki_read_parameter_name_e].result & f_console_result_found_e) { + else if (parameters->array[iki_read_parameter_name_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_name_s); @@ -190,8 +212,8 @@ extern "C" { return; } - if (main->program.parameters.array[iki_read_parameter_replace_e].result & f_console_result_found_e) { - if (!(main->program.parameters.array[iki_read_parameter_replace_e].result & f_console_result_value_e) || (main->program.parameters.array[iki_read_parameter_replace_e].values.used % 2)) { + if (parameters->array[iki_read_parameter_replace_e].result & f_console_result_found_e) { + if (!(parameters->array[iki_read_parameter_replace_e].result & f_console_result_value_e) || (parameters->array[iki_read_parameter_replace_e].values.used % 2)) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_replace_s, iki_read_string_two_s); @@ -201,7 +223,7 @@ extern "C" { main->setting.replace.used = 0; - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.array[iki_read_parameter_replace_e].values.used / 2, sizeof(f_string_map_t), (void **) &main->setting.replace.array, &main->setting.replace.used, &main->setting.replace.size); + main->setting.state.status = f_memory_array_increase_by(parameters->array[iki_read_parameter_replace_e].values.used / 2, sizeof(f_string_map_t), (void **) &main->setting.replace.array, &main->setting.replace.used, &main->setting.replace.size); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error(&main->program.error, macro_iki_read_f(f_memory_array_increase_by)); @@ -209,21 +231,16 @@ extern "C" { return; } - f_number_unsigned_t at = 0; - f_number_unsigned_t index = 0; - f_number_unsigned_t i = 0; - f_number_unsigned_t j = 0; + at = 0; + j = 0; - for (; i < main->program.parameters.array[iki_read_parameter_replace_e].values.used; ++i) { + for (i = 0; i < parameters->array[iki_read_parameter_replace_e].values.used; ++i) { - index = main->program.parameters.array[iki_read_parameter_replace_e].values.array[i]; + index = parameters->array[iki_read_parameter_replace_e].values.array[i]; // Replace any existing value so that each name exists only once. for (j = 0; j < main->setting.replace.used; ++j) { - - if (f_compare_dynamic(main->program.parameters.arguments.array[index], main->setting.replace.array[j].key) == F_equal_to) { - break; - } + if (f_compare_dynamic(parameters->arguments.array[index], main->setting.replace.array[j].key) == F_equal_to) break; } // for at = j; @@ -243,14 +260,14 @@ extern "C" { return; } - main->setting.replace.array[at].key.string = main->program.parameters.arguments.array[index].string; - main->setting.replace.array[at].key.used = main->program.parameters.arguments.array[index].used; + main->setting.replace.array[at].key.string = parameters->arguments.array[index].string; + main->setting.replace.array[at].key.used = parameters->arguments.array[index].used; main->setting.replace.array[at].key.size = 0; - index = main->program.parameters.array[iki_read_parameter_replace_e].values.array[++i]; + index = parameters->array[iki_read_parameter_replace_e].values.array[++i]; - main->setting.replace.array[at].value.string = main->program.parameters.arguments.array[index].string; - main->setting.replace.array[at].value.used = main->program.parameters.arguments.array[index].used; + main->setting.replace.array[at].value.string = parameters->arguments.array[index].string; + main->setting.replace.array[at].value.used = parameters->arguments.array[index].used; main->setting.replace.array[at].value.size = 0; if (at == main->setting.replace.used) { @@ -261,20 +278,20 @@ extern "C" { main->setting.flag |= iki_read_main_flag_replace_d; } - if (iki_read_setting_load_parameter_substitution(main, main->program.parameters.array[iki_read_parameter_reassign_e], iki_read_long_reassign_s, &main->setting.reassign)) { + if (iki_read_setting_load_parameter_substitution(main, parameters->array[iki_read_parameter_reassign_e], iki_read_long_reassign_s, &main->setting.reassign)) { main->setting.flag |= iki_read_main_flag_reassign_d; } if (F_status_is_error(main->setting.state.status)) return; - if (iki_read_setting_load_parameter_substitution(main, main->program.parameters.array[iki_read_parameter_substitute_e], iki_read_long_substitute_s, &main->setting.substitute)) { + if (iki_read_setting_load_parameter_substitution(main, parameters->array[iki_read_parameter_substitute_e], iki_read_long_substitute_s, &main->setting.substitute)) { main->setting.flag |= iki_read_main_flag_substitute_d; } if (F_status_is_error(main->setting.state.status)) return; - if (main->program.parameters.array[iki_read_parameter_wrap_e].result & f_console_result_found_e) { - if (!(main->program.parameters.array[iki_read_parameter_wrap_e].result & f_console_result_value_e) || (main->program.parameters.array[iki_read_parameter_wrap_e].values.used % 3)) { + if (parameters->array[iki_read_parameter_wrap_e].result & f_console_result_found_e) { + if (!(parameters->array[iki_read_parameter_wrap_e].result & f_console_result_value_e) || (parameters->array[iki_read_parameter_wrap_e].values.used % 3)) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value_requires_amount(&main->program.error, f_console_symbol_long_normal_s, iki_read_long_wrap_s, iki_read_string_three_s); @@ -284,7 +301,7 @@ extern "C" { main->setting.wrap.used = 0; - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.array[iki_read_parameter_wrap_e].values.used / 3, sizeof(f_string_triple_t), (void **) &main->setting.wrap.array, &main->setting.wrap.used, &main->setting.wrap.size); + main->setting.state.status = f_memory_array_increase_by(parameters->array[iki_read_parameter_wrap_e].values.used / 3, sizeof(f_string_triple_t), (void **) &main->setting.wrap.array, &main->setting.wrap.used, &main->setting.wrap.size); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error(&main->program.error, macro_iki_read_f(f_memory_array_increase_by)); @@ -292,21 +309,16 @@ extern "C" { return; } - f_number_unsigned_t at = 0; - f_number_unsigned_t index = 0; - f_number_unsigned_t i = 0; - f_number_unsigned_t j = 0; + at = 0; + j = 0; - for (; i < main->program.parameters.array[iki_read_parameter_wrap_e].values.used; ++i) { + for (i = 0; i < parameters->array[iki_read_parameter_wrap_e].values.used; ++i) { - index = main->program.parameters.array[iki_read_parameter_wrap_e].values.array[i]; + index = parameters->array[iki_read_parameter_wrap_e].values.array[i]; // Replace any existing values so that each name exists only once. for (j = 0; j < main->setting.wrap.used; ++j) { - - if (f_compare_dynamic(main->program.parameters.arguments.array[index], main->setting.wrap.array[j].a) == F_equal_to) { - break; - } + if (f_compare_dynamic(parameters->arguments.array[index], main->setting.wrap.array[j].a) == F_equal_to) break; } // for at = j; @@ -330,20 +342,20 @@ extern "C" { return; } - main->setting.wrap.array[at].a.string = main->program.parameters.arguments.array[index].string; - main->setting.wrap.array[at].a.used = main->program.parameters.arguments.array[index].used; + main->setting.wrap.array[at].a.string = parameters->arguments.array[index].string; + main->setting.wrap.array[at].a.used = parameters->arguments.array[index].used; main->setting.wrap.array[at].a.size = 0; - index = main->program.parameters.array[iki_read_parameter_wrap_e].values.array[++i]; + index = parameters->array[iki_read_parameter_wrap_e].values.array[++i]; - main->setting.wrap.array[at].b.string = main->program.parameters.arguments.array[index].string; - main->setting.wrap.array[at].b.used = main->program.parameters.arguments.array[index].used; + main->setting.wrap.array[at].b.string = parameters->arguments.array[index].string; + main->setting.wrap.array[at].b.used = parameters->arguments.array[index].used; main->setting.wrap.array[at].b.size = 0; - index = main->program.parameters.array[iki_read_parameter_wrap_e].values.array[++i]; + index = parameters->array[iki_read_parameter_wrap_e].values.array[++i]; - main->setting.wrap.array[at].c.string = main->program.parameters.arguments.array[index].string; - main->setting.wrap.array[at].c.used = main->program.parameters.arguments.array[index].used; + main->setting.wrap.array[at].c.string = parameters->arguments.array[index].string; + main->setting.wrap.array[at].c.used = parameters->arguments.array[index].used; main->setting.wrap.array[at].c.size = 0; if (at == main->setting.wrap.used) { @@ -354,7 +366,7 @@ extern "C" { main->setting.flag |= iki_read_main_flag_wrap_d; } - if (main->program.parameters.array[iki_read_parameter_literal_e].result & f_console_result_found_e) { + if (parameters->array[iki_read_parameter_literal_e].result & f_console_result_found_e) { const uint8_t ids[3] = { iki_read_parameter_object_e, iki_read_parameter_content_e, @@ -367,12 +379,12 @@ extern "C" { iki_read_long_total_s, }; - for (uint8_t i = 0; i < 3; ++i) { + for (uint8_t k = 0; k < 3; ++k) { - if (main->program.parameters.array[ids[i]].result & f_console_result_found_e) { + if (parameters->array[ids[k]].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); - fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_literal_s, names[i]); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_literal_s, names[k]); return; } @@ -380,7 +392,7 @@ extern "C" { main->setting.flag |= iki_read_main_flag_literal_d; } - else if (main->program.parameters.array[iki_read_parameter_object_e].result & f_console_result_found_e) { + else if (parameters->array[iki_read_parameter_object_e].result & f_console_result_found_e) { const uint8_t ids[2] = { iki_read_parameter_content_e, iki_read_parameter_total_e, @@ -391,12 +403,12 @@ extern "C" { iki_read_long_total_s, }; - for (uint8_t i = 0; i < 2; ++i) { + for (uint8_t k = 0; k < 2; ++k) { - if (main->program.parameters.array[ids[i]].result & f_console_result_found_e) { + if (parameters->array[ids[k]].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); - fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_object_s, names[i]); + fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_object_s, names[k]); return; } @@ -404,8 +416,8 @@ extern "C" { main->setting.flag |= iki_read_main_flag_object_d; } - else if (main->program.parameters.array[iki_read_parameter_content_e].result & f_console_result_found_e) { - if (main->program.parameters.array[iki_read_parameter_total_e].result & f_console_result_found_e) { + else if (parameters->array[iki_read_parameter_content_e].result & f_console_result_found_e) { + if (parameters->array[iki_read_parameter_total_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_content_s, iki_read_long_total_s); @@ -415,8 +427,8 @@ extern "C" { main->setting.flag |= iki_read_main_flag_content_d; } - else if (main->program.parameters.array[iki_read_parameter_total_e].result & f_console_result_found_e) { - if (main->program.parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { + else if (parameters->array[iki_read_parameter_total_e].result & f_console_result_found_e) { + if (parameters->array[iki_read_parameter_whole_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_cannot_use_with(&main->program.error, f_console_symbol_long_normal_s, f_console_symbol_long_normal_s, iki_read_long_total_s, iki_read_long_wrap_s); @@ -432,14 +444,14 @@ extern "C" { main->setting.flag |= iki_read_main_flag_content_d; } - if (main->program.parameters.array[iki_read_parameter_whole_e].result & f_console_result_found_e) { + if (parameters->array[iki_read_parameter_whole_e].result & f_console_result_found_e) { main->setting.flag |= iki_read_main_flag_whole_d; } - if (main->program.parameters.remaining.used) { + if (parameters->remaining.used) { main->setting.files.used = 0; - main->setting.state.status = f_memory_arrays_resize(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size, &f_string_dynamics_delete_callback); + main->setting.state.status = f_memory_arrays_resize(parameters->remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size, &f_string_dynamics_delete_callback); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error(&main->program.error, macro_iki_read_f(f_memory_arrays_resize)); @@ -447,9 +459,9 @@ extern "C" { return; } - f_number_unsigned_t index = 0; + index = 0; - for (f_number_unsigned_t i = 0; i < main->program.parameters.remaining.used; ++i, ++main->setting.files.used) { + for (i = 0; i < parameters->remaining.used; ++i, ++main->setting.files.used) { // Static strings are being used, so if a dynamic string exists (size > 0), then de-allocate it. if (main->setting.files.array[main->setting.files.used].size) { @@ -462,10 +474,10 @@ extern "C" { } } - index = main->program.parameters.remaining.array[i]; + index = parameters->remaining.array[i]; - main->setting.files.array[main->setting.files.used].string = main->program.parameters.arguments.array[index].string; - main->setting.files.array[main->setting.files.used].used = main->program.parameters.arguments.array[index].used; + main->setting.files.array[main->setting.files.used].string = parameters->arguments.array[index].string; + main->setting.files.array[main->setting.files.used].used = parameters->arguments.array[index].used; main->setting.files.array[main->setting.files.used].size = 0; main->setting.state.status = f_file_exists(main->setting.files.array[main->setting.files.used], F_true); @@ -508,6 +520,8 @@ extern "C" { f_number_unsigned_t i = 0; f_number_unsigned_t j = 0; + f_console_parameters_t * const parameters = &main->program.parameters; + for (; i < parameter.values.used; ++i) { index = parameter.values.array[i]; @@ -515,8 +529,8 @@ extern "C" { // Replace any existing values so that each name and value pair exists only once. for (j = 0; j < triple->used; ++j) { - if (f_compare_dynamic(main->program.parameters.arguments.array[index], triple->array[j].a) == F_equal_to) { - if (f_compare_dynamic(main->program.parameters.arguments.array[parameter.values.array[i + 1]], triple->array[j].b) == F_equal_to) { + if (f_compare_dynamic(parameters->arguments.array[index], triple->array[j].a) == F_equal_to) { + if (f_compare_dynamic(parameters->arguments.array[parameter.values.array[i + 1]], triple->array[j].b) == F_equal_to) { break; } } @@ -543,20 +557,20 @@ extern "C" { return F_false; } - triple->array[at].a.string = main->program.parameters.arguments.array[index].string; - triple->array[at].a.used = main->program.parameters.arguments.array[index].used; + triple->array[at].a.string = parameters->arguments.array[index].string; + triple->array[at].a.used = parameters->arguments.array[index].used; triple->array[at].a.size = 0; index = parameter.values.array[++i]; - triple->array[at].b.string = main->program.parameters.arguments.array[index].string; - triple->array[at].b.used = main->program.parameters.arguments.array[index].used; + triple->array[at].b.string = parameters->arguments.array[index].string; + triple->array[at].b.used = parameters->arguments.array[index].used; triple->array[at].b.size = 0; index = parameter.values.array[++i]; - triple->array[at].c.string = main->program.parameters.arguments.array[index].string; - triple->array[at].c.used = main->program.parameters.arguments.array[index].used; + triple->array[at].c.string = parameters->arguments.array[index].string; + triple->array[at].c.used = parameters->arguments.array[index].used; triple->array[at].c.size = 0; if (at == triple->used) { diff --git a/level_3/iki_read/c/main/common.h b/level_3/iki_read/c/main/common.h index cbf5cac..9a16a77 100644 --- a/level_3/iki_read/c/main/common.h +++ b/level_3/iki_read/c/main/common.h @@ -37,6 +37,10 @@ extern "C" { * Errors (with error bit) from: f_string_dynamic_append(). * Errors (with error bit) from: fll_program_parameter_process_context(). * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). + * @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_okay. + * Set to NULL to disable. * * @see f_console_parameter_process() * @see f_file_exists() @@ -46,7 +50,7 @@ extern "C" { * @see fll_program_parameter_process_verbosity_standard() */ #ifndef _di_iki_read_setting_load_ - extern void iki_read_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main); + extern void iki_read_setting_load(const f_console_arguments_t arguments, iki_read_main_t * const main, void (*callback)(const f_console_arguments_t arguments, iki_read_main_t * const main)); #endif // _di_iki_read_setting_load_ /** diff --git a/level_3/iki_read/c/main/common/string.c b/level_3/iki_read/c/main/common/string.c index 7df2cfb..16ae664 100644 --- a/level_3/iki_read/c/main/common/string.c +++ b/level_3/iki_read/c/main/common/string.c @@ -8,11 +8,6 @@ extern "C" { const f_string_static_t iki_read_program_version_s = macro_f_string_static_t_initialize_1(IKI_READ_program_version_s, 0, IKI_READ_program_version_s_length); #endif // _di_iki_read_program_version_s_ -#ifndef _di_iki_read_program_name_s_ - const f_string_static_t iki_read_program_name_s = macro_f_string_static_t_initialize_1(IKI_READ_program_name_s, 0, IKI_READ_program_name_s_length); - const f_string_static_t iki_read_program_name_long_s = macro_f_string_static_t_initialize_1(IKI_READ_program_name_long_s, 0, IKI_READ_program_name_long_s_length); -#endif // _di_iki_read_program_name_s_ - #ifndef _di_iki_read_s_ const f_string_static_t iki_read_string_two_s = macro_f_string_static_t_initialize_1(IKI_READ_string_two_s, 0, IKI_READ_string_two_s_length); const f_string_static_t iki_read_string_three_s = macro_f_string_static_t_initialize_1(IKI_READ_string_three_s, 0, IKI_READ_string_three_s_length); diff --git a/level_3/iki_read/c/main/common/string.h b/level_3/iki_read/c/main/common/string.h index 7c90029..b3ccbc9 100644 --- a/level_3/iki_read/c/main/common/string.h +++ b/level_3/iki_read/c/main/common/string.h @@ -46,21 +46,7 @@ extern "C" { #endif // _di_iki_read_program_version_s_ /** - * The program name. - */ -#ifndef _di_iki_read_program_name_s_ - #define IKI_READ_program_name_s "iki_read" - #define IKI_READ_program_name_long_s "IKI Read" - - #define IKI_READ_program_name_s_length 8 - #define IKI_READ_program_name_long_s_length 8 - - extern const f_string_static_t iki_read_program_name_s; - extern const f_string_static_t iki_read_program_name_long_s; -#endif // _di_iki_read_program_name_s_ - -/** - * A collection of static strings associated with IKI Read. + * Special strings used by this program. */ #ifndef _di_iki_read_s_ #define IKI_READ_string_two_s "two" @@ -71,8 +57,15 @@ extern "C" { extern const f_string_static_t iki_read_string_two_s; extern const f_string_static_t iki_read_string_three_s; + + // These are defined by the individual programs. + extern const f_string_static_t iki_read_program_name_s; + extern const f_string_static_t iki_read_program_name_long_s; #endif // _di_iki_read_s_ +/** + * A collection of static strings associated with IKI Read for substitutions. + */ #ifndef _di_iki_read_substitution_s_ #define IKI_READ_substitution_after_s "after" #define IKI_READ_substitution_before_s "before" diff --git a/level_3/iki_read/c/main/common/type.c b/level_3/iki_read/c/main/common/type.c index 6fe79a5..c7f5a8d 100644 --- a/level_3/iki_read/c/main/common/type.c +++ b/level_3/iki_read/c/main/common/type.c @@ -4,11 +4,21 @@ extern "C" { #endif +#ifndef _di_iki_read_setting_delete_ + void iki_read_cache_delete(iki_read_cache_t * const cache) { + + if (!cache) return; + + f_memory_array_resize(0, sizeof(f_char_t), (void **) &cache->buffer.string, &cache->buffer.used, &cache->buffer.size); + } +#endif // _di_iki_read_cache_delete_ + #ifndef _di_iki_read_main_delete_ void iki_read_main_delete(iki_read_main_t * const main) { if (!main) return; + iki_read_cache_delete(&main->cache); fll_program_data_delete(&main->program); iki_read_setting_delete(&main->setting); } @@ -19,8 +29,6 @@ extern "C" { if (!setting) return; - f_memory_array_resize(0, sizeof(f_char_t), (void **) &setting->buffer.string, &setting->buffer.used, &setting->buffer.size); - f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &setting->names.array, &setting->names.used, &setting->names.size, &f_string_dynamics_delete_callback); f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &setting->files.array, &setting->files.used, &setting->files.size, &f_string_dynamics_delete_callback); diff --git a/level_3/iki_read/c/main/common/type.h b/level_3/iki_read/c/main/common/type.h index 870ecfc..0a24591 100644 --- a/level_3/iki_read/c/main/common/type.h +++ b/level_3/iki_read/c/main/common/type.h @@ -17,7 +17,46 @@ extern "C" { #endif /** - * The iki read main program settings. + * The IKI read main program cache. + * + * Properties: + * - buffer: A buffer used for loading the files and other miscellaneous tasks. + */ +#ifndef _di_iki_read_setting_t_ + typedef struct { + f_string_dynamic_t buffer; + } iki_read_cache_t; + + #define iki_read_cache_t_initialize \ + { \ + f_string_dynamic_t_initialize, \ + } +#endif // _di_iki_read_cache_t_ + +/** + * The IKI write callbacks. + * + * Properties: + * - print_help: Print the main help message. + * + * - process_objects_content: Process an Objects and Content set. + */ +#ifndef _di_iki_read_callback_t_ + typedef struct { + void (*print_help)(fl_print_t * const print); + + void (*process_objects_content)(void * const main, const f_string_statics_t objects, const f_string_static_t content); + } iki_read_callback_t; + + #define iki_read_callback_t_initialize \ + { \ + 0, \ + 0, \ + } +#endif // _di_iki_read_callback_t_ + +/** + * The IKI 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). @@ -31,7 +70,6 @@ extern "C" { * - at: The position representing the "at" index. * - line: The position representing the "line" index. * - * - buffer: A buffer used for loading the files and other miscellaneous tasks. * - name: A string representing the IKI vocabulary name being selected. * - files: An array of all files to process (except for the input pipe). * @@ -55,7 +93,6 @@ extern "C" { f_number_unsigned_t at; f_number_unsigned_t line; - f_string_dynamic_t buffer; f_string_dynamics_t names; f_string_dynamics_t files; @@ -77,7 +114,6 @@ extern "C" { macro_f_state_t_initialize_1(iki_read_allocation_large_d, iki_read_allocation_small_d, F_okay, 0, 0, 0, 0, 0, 0, 0), \ 0, \ 0, \ - f_string_dynamic_t_initialize, \ f_string_dynamics_t_initialize, \ f_string_dynamics_t_initialize, \ f_string_maps_t_initialize, \ @@ -99,18 +135,39 @@ extern "C" { */ #ifndef _di_iki_read_main_t_ typedef struct { + iki_read_cache_t cache; + iki_read_callback_t callback; fll_program_data_t program; iki_read_setting_t setting; } iki_read_main_t; #define iki_read_main_t_initialize \ { \ + iki_read_cache_t_initialize, \ + iki_read_callback_t_initialize, \ fll_program_data_t_initialize, \ iki_read_setting_t_initialize, \ } #endif // _di_iki_read_main_t_ /** + * Delete the program cache data. + * + * @param cache + * The program cache data. + * + * Must not be NULL. + * + * This does not alter setting.state.status. + * + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() + */ +#ifndef _di_iki_read_setting_delete_ + extern void iki_read_cache_delete(iki_read_cache_t * const cache); +#endif // _di_iki_read_cache_delete_ + +/** * De-allocate main program data. * * @param main diff --git a/level_3/iki_read/c/main/identify.c b/level_3/iki_read/c/main/identify.c index 304d551..f6130c1 100644 --- a/level_3/iki_read/c/main/identify.c +++ b/level_3/iki_read/c/main/identify.c @@ -22,7 +22,7 @@ extern "C" { j = main->setting.replace.used - 1; do { - if (f_compare_dynamic_partial_string(main->setting.replace.array[j].key.string, main->setting.buffer, main->setting.replace.array[j].key.used, main->setting.data.vocabulary.array[i]) == F_equal_to) { + if (f_compare_dynamic_partial_string(main->setting.replace.array[j].key.string, main->cache.buffer, main->setting.replace.array[j].key.used, main->setting.data.vocabulary.array[i]) == F_equal_to) { main->setting.map_replaces[i] = j; break; @@ -37,7 +37,7 @@ extern "C" { j = main->setting.wrap.used - 1; do { - if (f_compare_dynamic_partial_string(main->setting.wrap.array[j].a.string, main->setting.buffer, main->setting.wrap.array[j].a.used, main->setting.data.vocabulary.array[i]) == F_equal_to) { + if (f_compare_dynamic_partial_string(main->setting.wrap.array[j].a.string, main->cache.buffer, main->setting.wrap.array[j].a.used, main->setting.data.vocabulary.array[i]) == F_equal_to) { main->setting.map_wraps[i] = j; break; @@ -68,8 +68,8 @@ extern "C" { f_number_unsigned_t i = triple->used - 1; do { - if (f_compare_dynamic_partial_string(triple->array[i].a.string, main->setting.buffer, triple->array[i].a.used, name) == F_equal_to) { - if (f_compare_dynamic_partial_string(triple->array[i].b.string, main->setting.buffer, triple->array[i].b.used, value) == F_equal_to) { + if (f_compare_dynamic_partial_string(triple->array[i].a.string, main->cache.buffer, triple->array[i].a.used, name) == F_equal_to) { + if (f_compare_dynamic_partial_string(triple->array[i].b.string, main->cache.buffer, triple->array[i].b.used, value) == F_equal_to) { return i; } } diff --git a/level_3/iki_read/c/main/iki_read.c b/level_3/iki_read/c/main/iki_read.c index 844bd70..c4b21ac 100644 --- a/level_3/iki_read/c/main/iki_read.c +++ b/level_3/iki_read/c/main/iki_read.c @@ -25,14 +25,14 @@ extern "C" { return; } - if (main->setting.flag & iki_read_main_flag_pipe_d) { - f_file_t file = f_file_t_initialize; + f_file_t file = f_file_t_initialize; + if (main->setting.flag & iki_read_main_flag_pipe_d) { file.id = F_type_descriptor_input_d; - main->setting.buffer.used = 0; + main->cache.buffer.used = 0; - main->setting.state.status = f_file_read(file, &main->setting.buffer); + main->setting.state.status = f_file_read(file, &main->cache.buffer); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error_file(&main->program.error, macro_iki_read_f(f_file_read), f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); @@ -43,7 +43,6 @@ extern "C" { } if (F_status_is_error_not(main->setting.state.status) && main->setting.files.used) { - f_file_t file = f_file_t_initialize; off_t size_block = 0; off_t size_file = 0; off_t size_read = 0; @@ -100,7 +99,7 @@ extern "C" { } // Pre-allocate entire file buffer plus space for the terminating NULL. - main->setting.state.status = f_memory_array_increase_by(size_file + 1, sizeof(f_char_t), (void **) &main->setting.buffer.string, &main->setting.buffer.used, &main->setting.buffer.size); + main->setting.state.status = f_memory_array_increase_by(size_file + 1, sizeof(f_char_t), (void **) &main->cache.buffer.string, &main->cache.buffer.used, &main->cache.buffer.size); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error_file(&main->program.error, macro_iki_read_f(f_memory_array_increase_by), main->setting.files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); @@ -119,7 +118,7 @@ extern "C" { break; } - main->setting.state.status = f_file_stream_read_until(file, size_block, &main->setting.buffer); + main->setting.state.status = f_file_stream_read_until(file, size_block, &main->cache.buffer); if (F_status_is_error(main->setting.state.status)) break; } // for @@ -137,7 +136,7 @@ extern "C" { iki_read_process_buffer(main); if (F_status_is_error(main->setting.state.status)) break; - main->setting.buffer.used = 0; + main->cache.buffer.used = 0; } // for if (F_status_is_error(main->setting.state.status)) { diff --git a/level_3/iki_read/c/main/print/data.c b/level_3/iki_read/c/main/print/data.c index 78c4afd..5427640 100644 --- a/level_3/iki_read/c/main/print/data.c +++ b/level_3/iki_read/c/main/print/data.c @@ -24,14 +24,14 @@ extern "C" { else { f_range_t range = macro_f_range_t_initialize_1(main->setting.data.variable.array[index].start, main->setting.data.content.array[index].start - 1); - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); f_print_dynamic(main->setting.reassign.array[at].c, main->program.output.to); range.start = main->setting.data.content.array[index].stop + 1; range.stop = main->setting.data.variable.array[index].stop; - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); } return; @@ -54,7 +54,7 @@ extern "C" { else { f_range_t range = macro_f_range_t_initialize_1(main->setting.data.variable.array[index].start, main->setting.data.content.array[index].start - 1); - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); iki_read_print_data_wrap_prepend(&main->program.output, index); @@ -65,7 +65,7 @@ extern "C" { range.start = main->setting.data.content.array[index].stop + 1; range.stop = main->setting.data.variable.array[index].stop; - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); } } else if (main->setting.replace.used && main->setting.map_replaces[index] < main->setting.replace.used) { @@ -82,7 +82,7 @@ extern "C" { else { f_range_t range = macro_f_range_t_initialize_1(main->setting.data.variable.array[index].start, main->setting.data.content.array[index].start - 1); - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); iki_read_print_data_wrap_prepend(&main->program.output, index); @@ -93,34 +93,34 @@ extern "C" { range.start = main->setting.data.content.array[index].stop + 1; range.stop = main->setting.data.variable.array[index].stop; - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); } } else if (main->setting.flag & iki_read_main_flag_content_d) { iki_read_print_data_wrap_prepend(&main->program.output, index); - f_print_dynamic_partial(main->setting.buffer, main->setting.data.content.array[index], main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, main->setting.data.content.array[index], main->program.output.to); iki_read_print_data_wrap_append(&main->program.output, index); } else if (main->setting.flag & iki_read_main_flag_object_d) { - f_print_dynamic_partial(main->setting.buffer, main->setting.data.vocabulary.array[index], main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, main->setting.data.vocabulary.array[index], main->program.output.to); } else { f_range_t range = macro_f_range_t_initialize_1(main->setting.data.variable.array[index].start, main->setting.data.content.array[index].start - 1); - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); iki_read_print_data_wrap_prepend(&main->program.output, index); - f_print_dynamic_partial(main->setting.buffer, main->setting.data.content.array[index], main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, main->setting.data.content.array[index], main->program.output.to); iki_read_print_data_wrap_append(&main->program.output, index); range.start = main->setting.data.content.array[index].stop + 1; range.stop = main->setting.data.variable.array[index].stop; - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); } } #endif // _di_iki_read_print_data_ diff --git a/level_3/iki_read/c/main/print/message.c b/level_3/iki_read/c/main/print/message.c index 9fcbc5d..8c9243a 100644 --- a/level_3/iki_read/c/main/print/message.c +++ b/level_3/iki_read/c/main/print/message.c @@ -5,13 +5,9 @@ extern "C" { #endif #ifndef _di_iki_read_print_message_help_ - f_status_t iki_read_print_message_help(fl_print_t * const print) { + void iki_read_print_message_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, iki_read_program_name_long_s, iki_read_program_version_s); + if (!print) return; fll_program_print_help_option_standard(print); @@ -39,6 +35,13 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, print->to); fll_program_print_help_usage(print, iki_read_program_name_s, fll_program_parameter_filenames_s); + } +#endif // _di_iki_read_print_message_help_ + +#ifndef _di_iki_read_print_message_help_note_ + void iki_read_print_message_help_note(fl_print_t * const print) { + + if (!print) return; fl_print_format("%r %[Notes:%]%r", print->to, f_string_eol_s, print->set->important, print->set->important, f_string_eol_s); fl_print_format(" This program will find and print Variables, Vocabularies, or Content following the IKI standard, without focusing on any particular Vocabulary specification.%r%r", print->to, f_string_eol_s, f_string_eol_s); @@ -88,13 +91,8 @@ extern "C" { fl_print_format(" option takes priority over the %[%r%r%] option when matching the same Variable.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, iki_read_long_replace_s, print->set->notable, f_string_eol_s, f_string_eol_s); fl_print_format(" The default behavior is to only display Content portion of the IKI Variable.%r", print->to, f_string_eol_s); - - f_file_stream_flush(print->to); - f_file_stream_unlock(print->to); - - return F_okay; } -#endif // _di_iki_read_print_message_help_ +#endif // _di_iki_read_print_message_help_note_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/iki_read/c/main/print/message.h b/level_3/iki_read/c/main/print/message.h index 5739a9d..d31078d 100644 --- a/level_3/iki_read/c/main/print/message.h +++ b/level_3/iki_read/c/main/print/message.h @@ -22,18 +22,30 @@ extern "C" { * @param print * The output structure to print to. * - * This does not alter print.custom.setting.state.status. - * - * @return - * F_okay on success. - * F_output_not on success, but no printing is performed. + * The print.custom is expected to be of type iki_read_main_t. * - * F_output_not (with error bit) if setting is NULL. + * This does not alter print.custom.setting.state.status. */ #ifndef _di_iki_read_print_message_help_ - extern f_status_t iki_read_print_message_help(fl_print_t * const print); + extern void iki_read_print_message_help(fl_print_t * const print); #endif // _di_iki_read_print_message_help_ +/** + * Print standard parts of the help regarding notes. + * + * 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. + * + * The print.custom is expected to be of type iki_read_main_t. + * + * This does not alter print.custom.setting.state.status. + */ +#ifndef _di_iki_read_print_message_help_note_ + extern void iki_read_print_message_help_note(fl_print_t * const print); +#endif // _di_iki_read_print_message_help_note_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/main/process.c b/level_3/iki_read/c/main/process.c index 81a6059..b041bff 100644 --- a/level_3/iki_read/c/main/process.c +++ b/level_3/iki_read/c/main/process.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_iki_read_process_line_ - void iki_read_process_line(iki_read_main_t * const main, f_range_t *range) { + void iki_read_process_line(iki_read_main_t * const main, f_range_t * const range) { if (!(main->setting.flag & iki_read_main_flag_line_d)) { main->setting.state.status = F_false; @@ -17,16 +17,16 @@ extern "C" { range->start = 0; if (main->setting.line) { - for (; line < main->setting.line && range->start < main->setting.buffer.used; ++range->start) { - if (main->setting.buffer.string[range->start] == f_string_eol_s.string[0]) ++line; + for (; line < main->setting.line && range->start < main->cache.buffer.used; ++range->start) { + if (main->cache.buffer.string[range->start] == f_string_eol_s.string[0]) ++line; } // for } if (line == main->setting.line) { // Find where the found line ends and set that as the range stop. - for (range->stop = range->start; range->stop < main->setting.buffer.used; ++range->stop) { - if (main->setting.buffer.string[range->stop] == f_string_eol_s.string[0]) break; + for (range->stop = range->start; range->stop < main->cache.buffer.used; ++range->stop) { + if (main->cache.buffer.string[range->stop] == f_string_eol_s.string[0]) break; } // for main->setting.state.status = F_true; @@ -50,12 +50,12 @@ extern "C" { return; } - f_range_t buffer_range = macro_f_range_t_initialize_2(main->setting.buffer.used); + f_range_t buffer_range = macro_f_range_t_initialize_2(main->cache.buffer.used); iki_read_process_line(main, &buffer_range); if (main->setting.state.status == F_true) { - if (buffer_range.start > main->setting.buffer.used) { + if (buffer_range.start > main->cache.buffer.used) { main->setting.state.status = F_data_not; return; @@ -81,9 +81,9 @@ extern "C" { #endif // _di_iki_read_process_buffer_ #ifndef _di_iki_read_process_buffer_ranges_ - void iki_read_process_buffer_ranges(iki_read_main_t * const main, f_range_t *buffer_range) { + void iki_read_process_buffer_ranges(iki_read_main_t * const main, f_range_t * const buffer_range) { - fl_iki_read(&main->setting.buffer, buffer_range, &main->setting.data, &main->setting.state); + fl_iki_read(&main->cache.buffer, buffer_range, &main->setting.data, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error(&main->program.error, macro_iki_read_f(fl_iki_read)); @@ -102,7 +102,7 @@ extern "C" { main->setting.map_wraps = wraps; for (; i < main->setting.data.delimits.used; ++i) { - main->setting.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + main->cache.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for iki_read_identify_alteration(main); @@ -110,7 +110,7 @@ extern "C" { if (main->setting.flag & iki_read_main_flag_name_d) { f_number_unsigned_t j = 0; f_number_unsigned_t matches = 0; - bool unmatched = F_true; + uint8_t unmatched = F_true; f_file_stream_lock(main->program.output.to); @@ -118,7 +118,7 @@ extern "C" { for (j = 0; j < main->setting.names.used; ++j) { - if (f_compare_dynamic_partial_string(main->setting.names.array[j].string, main->setting.buffer, main->setting.names.array[j].used, main->setting.data.vocabulary.array[i]) == F_equal_to) { + if (f_compare_dynamic_partial_string(main->setting.names.array[j].string, main->cache.buffer, main->setting.names.array[j].used, main->setting.data.vocabulary.array[i]) == F_equal_to) { unmatched = F_false; if (main->setting.flag & iki_read_main_flag_at_d) { @@ -192,7 +192,7 @@ extern "C" { f_range_t range = buffer_range; - fl_iki_read(&main->setting.buffer, &range, &main->setting.data, &main->setting.state); + fl_iki_read(&main->cache.buffer, &range, &main->setting.data, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error(&main->program.error, macro_iki_read_f(fl_iki_read)); @@ -203,11 +203,11 @@ extern "C" { f_number_unsigned_t i = 0; for (; i < main->setting.data.delimits.used; ++i) { - main->setting.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + main->cache.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for if (!main->setting.data.variable.used) { - fll_print_dynamic_partial(main->setting.buffer, buffer_range, main->program.output.to); + fll_print_dynamic_partial(main->cache.buffer, buffer_range, main->program.output.to); main->setting.state.status = F_okay; @@ -241,7 +241,7 @@ extern "C" { range.start = i; range.stop = main->setting.data.variable.array[j].start - 1; - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); range.start = main->setting.data.variable.array[j].stop + 1; range.stop = buffer_range.stop; @@ -251,7 +251,7 @@ extern "C" { if (main->setting.names.used) { for (k = 0; k < main->setting.names.used; ++k) { - if (f_compare_dynamic_partial_string(main->setting.names.array[k].string, main->setting.buffer, main->setting.names.array[k].used, main->setting.data.vocabulary.array[j]) == F_equal_to) break; + if (f_compare_dynamic_partial_string(main->setting.names.array[k].string, main->cache.buffer, main->setting.names.array[k].used, main->setting.data.vocabulary.array[j]) == F_equal_to) break; } // for if (k < main->setting.names.used) { @@ -268,7 +268,7 @@ extern "C" { if (i <= buffer_range.stop) { range.start = i; - f_print_dynamic_partial(main->setting.buffer, range, main->program.output.to); + f_print_dynamic_partial(main->cache.buffer, range, main->program.output.to); } f_file_stream_unlock(main->program.output.to); @@ -281,12 +281,12 @@ extern "C" { #ifndef _di_iki_read_process_buffer_total_ void iki_read_process_buffer_total(iki_read_main_t * const main) { - f_range_t range = macro_f_range_t_initialize_2(main->setting.buffer.used); + f_range_t range = macro_f_range_t_initialize_2(main->cache.buffer.used); iki_read_process_line(main, &range); if (main->setting.state.status == F_true) { - if (range.start > main->setting.buffer.used) { + if (range.start > main->cache.buffer.used) { fll_print_format("%r%r", main->program.output.to, f_string_ascii_0_s, f_string_eol_s); main->setting.state.status = F_okay; @@ -302,7 +302,7 @@ extern "C" { return; } - fl_iki_read(&main->setting.buffer, &range, &main->setting.data, &main->setting.state); + fl_iki_read(&main->cache.buffer, &range, &main->setting.data, &main->setting.state); if (F_status_is_error(main->setting.state.status)) { iki_read_print_error(&main->program.error, macro_iki_read_f(fl_iki_read)); @@ -314,7 +314,7 @@ extern "C" { f_number_unsigned_t total = 0; for (; i < main->setting.data.delimits.used; ++i) { - main->setting.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + main->cache.buffer.string[main->setting.data.delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for if (main->program.parameters.array[iki_read_parameter_name_e].result & f_console_result_value_e) { @@ -346,7 +346,7 @@ extern "C" { for (j = 0; j < main->setting.data.vocabulary.used; ++j) { - main->setting.state.status = f_compare_dynamic_partial(name, main->setting.buffer, range, main->setting.data.vocabulary.array[j]); + main->setting.state.status = f_compare_dynamic_partial(name, main->cache.buffer, range, main->setting.data.vocabulary.array[j]); if (main->setting.state.status == F_equal_to) ++total; } // for diff --git a/level_3/iki_read/c/main/process.h b/level_3/iki_read/c/main/process.h index 8017d59..17895a7 100644 --- a/level_3/iki_read/c/main/process.h +++ b/level_3/iki_read/c/main/process.h @@ -24,8 +24,8 @@ extern "C" { * * @param main * The main program data. - * @param setting - * The main program settings. + * + * Must not be NULL. * * This alters setting.state.status: * F_true is returned if the range is processed. @@ -35,7 +35,7 @@ extern "C" { * The range value to represent the --line values. */ #ifndef _di_iki_read_process_line_ - extern void iki_read_process_line(iki_read_main_t * const main, f_range_t *range); + extern void iki_read_process_line(iki_read_main_t * const main, f_range_t * const range); #endif // _di_iki_read_process_line_ /** @@ -45,8 +45,8 @@ extern "C" { * * @param main * The main program data. - * @param setting - * The main program settings. + * + * Must not be NULL. * * This alters setting.state.status: * F_okay on success. @@ -71,11 +71,13 @@ extern "C" { * * @param main * The main program data. - * @param setting - * The main program settings. + * + * Must not be NULL. * @param buffer_range * The range within the buffer to process. * + * Must not be NULL. + * * @return * F_okay on success. * F_data_not on success, but nothing to print. @@ -83,7 +85,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ranges_ - extern void iki_read_process_buffer_ranges(iki_read_main_t * const main, f_range_t *buffer_range); + extern void iki_read_process_buffer_ranges(iki_read_main_t * const main, f_range_t * const buffer_range); #endif // _di_iki_read_process_buffer_ranges_ /** @@ -93,10 +95,8 @@ extern "C" { * * @param main * The main program data. - * @param setting - * The main program settings. - * @param buffer_range - * The range within the buffer to process. + * + * Must not be NULL. * * @return * F_okay on success. @@ -113,8 +113,8 @@ extern "C" { * * @param main * The main program data. - * @param setting - * The main program settings. + * + * Must not be NULL. * * @return * F_okay on success. diff --git a/level_3/iki_read/data/build/fakefile b/level_3/iki_read/data/build/fakefile index 38c1ae6..959843a 100644 --- a/level_3/iki_read/data/build/fakefile +++ b/level_3/iki_read/data/build/fakefile @@ -8,14 +8,18 @@ settings: environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH main: - build + build settings + build settings.eki_read + build settings.iki_read install: shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.eki_read + shell ./install.sh parameter:'work' parameter:'verbosity' parameter:'color' -s data/build/settings.iki_read help: print - print context:'title'Fakefile Options for IKI Read Program.context:'reset' + print context:'title'Fakefile Options for IKI Read Programs.context:'reset' print print The following operations are available\: diff --git a/level_3/iki_read/data/build/settings b/level_3/iki_read/data/build/settings index 579213e..c1fbee8 100644 --- a/level_3/iki_read/data/build/settings +++ b/level_3/iki_read/data/build/settings @@ -1,5 +1,7 @@ # fss-0001 # +# Builds the main library of the project with all parts except "main" program related. +# # Modes: # - android: Compile on an android system (using Termux; may need modification depending on the android system). # - clang: Use CLang rather than the default, which is generally GCC. @@ -41,8 +43,6 @@ build_libraries-monolithic -lfll build_sources_library main/iki_read.c main/common.c main/identify.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c main/print/data.c main/print/error.c main/print/message.c main/process.c main/signal.c main/thread.c -build_sources_program main/main.c - build_sources_headers main/iki_read.h main/common.h main/identify.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h main/print/data.h main/print/error.h main/print/message.h main/process.h main/signal.h main/thread.h build_sources_documentation man @@ -52,15 +52,6 @@ build_shared yes build_static no path_headers program/iki_read -path_library_script script -path_library_shared shared -path_library_static static -path_object_script script -path_object_shared shared -path_object_static static -path_program_script script -path_program_shared shared -path_program_static static has_path_standard yes preserve_path_headers yes diff --git a/level_3/iki_read/data/build/settings.eki_read b/level_3/iki_read/data/build/settings.eki_read new file mode 100644 index 0000000..8cd4249 --- /dev/null +++ b/level_3/iki_read/data/build/settings.eki_read @@ -0,0 +1,73 @@ +# fss-0001 +# +# Builds the "eki_read" program. +# This must be called after the "setting". +# + +build_name eki_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes android clang coverage fanalyzer gcc gcc_13 individual individual_thread level monolithic test thread threadless +modes_default monolithic thread gcc + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -lc -liki_read +build_libraries-individual -lfll_error -lfll_print -lfll_program -lfl_conversion -lfl_iki -lfl_print -lf_color -lf_compare -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_pipe -lf_print -lf_rip -lf_signal -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 eki/main.c +build_sources_program eki/common.c eki/eki_read.c eki/print.c eki/process.c + +build_sources_headers eki/common.h eki/eki_read.h eki/print.h eki/process.h + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/iki_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-android -D_di_f_thread_attribute_affinity_get_ -D_di_f_thread_attribute_affinity_set_ -D_di_f_thread_attribute_concurrency_get_ -D_di_f_thread_attribute_concurrency_set_ -D_di_f_thread_attribute_default_get_ -D_di_f_thread_attribute_default_set_ -D_di_f_thread_cancel_ -D_di_f_thread_cancel_state_set_ -D_di_f_thread_cancel_test_ -D_di_f_thread_join_try_ -D_di_f_thread_join_timed_ -D_pthread_mutex_prioceiling_unsupported_ -D_di_f_thread_semaphore_file_close_ -D_di_f_thread_semaphore_file_open_ -D_di_f_thread_semaphore_file_delete_ -D_di_f_thread_cancel_type_set_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines-threadless -D_di_thread_support_ + +flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces +flags -fstack-clash-protection -fno-delete-null-pointer-checks +flags -Wl,-z,nodlopen -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now +flags-android -Wno-implicit-function-declaration -Wl,-z,norelro +flags-clang -Wno-logical-op-parentheses +flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ +flags-fanalyzer -fanalyzer +flags-gcc_13 -fstrict-flex-arrays=3 +flags-test -O0 -fstack-protector-strong -Wall +flags-thread -pthread + +flags_library -fPIC +flags_object -fPIC +flags_program -fPIE +flags_program-android -fPIE -Wl,-z,relro diff --git a/level_3/iki_read/data/build/settings.iki_read b/level_3/iki_read/data/build/settings.iki_read new file mode 100644 index 0000000..db1681e --- /dev/null +++ b/level_3/iki_read/data/build/settings.iki_read @@ -0,0 +1,73 @@ +# fss-0001 +# +# Builds the "iki_read" program. +# This must be called after the "setting". +# + +build_name iki_read + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes android clang coverage fanalyzer gcc gcc_13 individual individual_thread level monolithic test thread threadless +modes_default monolithic thread gcc + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -lc -liki_read +build_libraries-individual -lfll_error -lfll_print -lfll_program -lfl_conversion -lfl_iki -lfl_print -lf_color -lf_compare -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_pipe -lf_print -lf_rip -lf_signal -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 iki/main.c +build_sources_program iki/common.c iki/iki_read.c iki/print.c iki/process.c + +build_sources_headers iki/common.h iki/iki_read.h iki/print.h iki/process.h + +build_sources_documentation man + +build_script yes +build_shared yes +build_static no + +path_headers program/iki_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-android -D_di_f_thread_attribute_affinity_get_ -D_di_f_thread_attribute_affinity_set_ -D_di_f_thread_attribute_concurrency_get_ -D_di_f_thread_attribute_concurrency_set_ -D_di_f_thread_attribute_default_get_ -D_di_f_thread_attribute_default_set_ -D_di_f_thread_cancel_ -D_di_f_thread_cancel_state_set_ -D_di_f_thread_cancel_test_ -D_di_f_thread_join_try_ -D_di_f_thread_join_timed_ -D_pthread_mutex_prioceiling_unsupported_ -D_di_f_thread_semaphore_file_close_ -D_di_f_thread_semaphore_file_open_ -D_di_f_thread_semaphore_file_delete_ -D_di_f_thread_cancel_type_set_ +defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines-threadless -D_di_thread_support_ + +flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces +flags -fstack-clash-protection -fno-delete-null-pointer-checks +flags -Wl,-z,nodlopen -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now +flags-android -Wno-implicit-function-declaration -Wl,-z,norelro +flags-clang -Wno-logical-op-parentheses +flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ +flags-fanalyzer -fanalyzer +flags-gcc_13 -fstrict-flex-arrays=3 +flags-test -O0 -fstack-protector-strong -Wall +flags-thread -pthread + +flags_library -fPIC +flags_object -fPIC +flags_program -fPIE +flags_program-android -fPIE -Wl,-z,relro