From b14ccf0e82a9945857cb4b9e9133b02cddf8d132 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 13 Feb 2025 20:29:43 -0600 Subject: [PATCH] Update: Use *_settings_load_call_t for callbacks. Switch these callbacks to use the typedef design. --- level_3/fss_read/c/main/common.c | 6 +++--- level_3/fss_read/c/main/common.h | 5 +++-- level_3/fss_read/c/main/common/type.h | 2 ++ level_3/iki_read/c/main/common.c | 6 +++--- level_3/iki_read/c/main/common.h | 5 +++-- level_3/iki_read/c/main/common/type.h | 1 + level_3/iki_write/c/main/common.c | 6 +++--- level_3/iki_write/c/main/common.h | 5 +++-- level_3/iki_write/c/main/common/type.h | 1 + 9 files changed, 22 insertions(+), 15 deletions(-) diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index 14aed69..169c2ea 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -41,7 +41,7 @@ extern "C" { #endif // _di_fss_read_ensure_quotes_length_ #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)) { + void fss_read_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main, const fss_read_settings_load_call_t do_settings_load) { if (!main) return; @@ -91,8 +91,8 @@ extern "C" { main->setting.flag |= fss_read_main_flag_copyright_d; } - if (callback) { - callback(arguments, main); + if (do_settings_load) { + do_settings_load(arguments, main); if (F_status_is_error(main->setting.state.status)) return; if (main->setting.state.status == F_done) { diff --git a/level_3/fss_read/c/main/common.h b/level_3/fss_read/c/main/common.h index b32fea9..4e30712 100644 --- a/level_3/fss_read/c/main/common.h +++ b/level_3/fss_read/c/main/common.h @@ -65,9 +65,10 @@ extern "C" { * * Errors (with error bit) from: fss_read_setting_load_depth(). * Errors (with error bit) from: fss_read_signal_check() - * @param callback + * @param do_settings_load * (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() @@ -79,7 +80,7 @@ extern "C" { * @see fss_read_signal_check() */ #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)); + extern void fss_read_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main, const fss_read_settings_load_call_t do_settings_load); #endif // _di_fss_read_setting_load_ /** diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index 24cdad5..6a1a144 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -334,6 +334,8 @@ extern "C" { * - setting: The settings data. */ #ifndef _di_fss_read_main_t_ + typedef void (*fss_read_settings_load_call_t)(const f_console_arguments_t arguments, fss_read_main_t * const main); + struct fss_read_main_t_ { fss_read_cache_t cache; fss_read_call_t call; diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index 033f074..eca54c2 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -5,7 +5,7 @@ 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 (*callback)(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, const iki_read_settings_load_call_t do_settings_load) { if (!main) return; @@ -43,8 +43,8 @@ extern "C" { return; } - if (callback) { - callback(arguments, main); + if (do_settings_load) { + do_settings_load(arguments, main); if (F_status_is_error(main->setting.state.status)) return; if (main->setting.state.status == F_done) { diff --git a/level_3/iki_read/c/main/common.h b/level_3/iki_read/c/main/common.h index 029697b..2545bf8 100644 --- a/level_3/iki_read/c/main/common.h +++ b/level_3/iki_read/c/main/common.h @@ -37,9 +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 + * @param do_settings_load * (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() @@ -50,7 +51,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, void (*callback)(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, const iki_read_settings_load_call_t do_settings_load); #endif // _di_iki_read_setting_load_ /** diff --git a/level_3/iki_read/c/main/common/type.h b/level_3/iki_read/c/main/common/type.h index d9e54aa..1576c76 100644 --- a/level_3/iki_read/c/main/common/type.h +++ b/level_3/iki_read/c/main/common/type.h @@ -59,6 +59,7 @@ extern "C" { * - delete_data: Delete the IKI/EKI data. */ #ifndef _di_iki_read_callback_t_ + typedef void (*iki_read_settings_load_call_t)(const f_console_arguments_t arguments, iki_read_main_t * const main); typedef void (*iki_read_main_call_t) (iki_read_main_t * const main); typedef void (*iki_read_print_data_call_t) (fl_print_t * const print, const f_number_unsigned_t index); typedef void (*iki_read_process_buffer_ranges_call_t) (iki_read_main_t * const main, f_range_t * const range_buffer); diff --git a/level_3/iki_write/c/main/common.c b/level_3/iki_write/c/main/common.c index 3fe1028..e3b1610 100644 --- a/level_3/iki_write/c/main/common.c +++ b/level_3/iki_write/c/main/common.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_iki_write_setting_load_ - void iki_write_setting_load(const f_console_arguments_t arguments, iki_write_main_t * const main, void (*callback)(const f_console_arguments_t arguments, iki_write_main_t * const main)) { + void iki_write_setting_load(const f_console_arguments_t arguments, iki_write_main_t * const main, const iki_write_settings_load_call_t do_settings_load) { if (!main) return; @@ -43,8 +43,8 @@ extern "C" { return; } - if (callback) { - callback(arguments, main); + if (do_settings_load) { + do_settings_load(arguments, main); if (F_status_is_error(main->setting.state.status)) return; if (main->setting.state.status == F_done) { diff --git a/level_3/iki_write/c/main/common.h b/level_3/iki_write/c/main/common.h index aff245c..1862496 100644 --- a/level_3/iki_write/c/main/common.h +++ b/level_3/iki_write/c/main/common.h @@ -35,9 +35,10 @@ extern "C" { * 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(). - * @param callback + * @param do_settings_load * (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() @@ -46,7 +47,7 @@ extern "C" { * @see fll_program_parameter_process_verbosity_standard() */ #ifndef _di_iki_write_setting_load_ - extern void iki_write_setting_load(const f_console_arguments_t arguments, iki_write_main_t * const main, void (*callback)(const f_console_arguments_t arguments, iki_write_main_t * const main)); + extern void iki_write_setting_load(const f_console_arguments_t arguments, iki_write_main_t * const main, const iki_write_settings_load_call_t do_settings_load); #endif // _di_iki_write_setting_load_ #ifdef __cplusplus diff --git a/level_3/iki_write/c/main/common/type.h b/level_3/iki_write/c/main/common/type.h index 3454f7c..3f2f123 100644 --- a/level_3/iki_write/c/main/common/type.h +++ b/level_3/iki_write/c/main/common/type.h @@ -60,6 +60,7 @@ extern "C" { * - process_objects_content: Process an Objects and Content set. */ #ifndef _di_iki_write_call_t_ + typedef void (*iki_write_settings_load_call_t)(const f_console_arguments_t arguments, iki_write_main_t * const main); typedef void (*iki_write_load_objects_content_pipe_call_t)(void * const main, const f_range_t range, uint8_t * const pipe_state); typedef void (*iki_write_process_objects_content_call_t)(void * const main, const f_string_statics_t objects, const f_string_static_t content); -- 1.8.3.1