From: Kevin Day Date: Mon, 20 Jan 2025 23:53:50 +0000 (-0600) Subject: Update: Use the pre-defined typedef structure style for the main program type. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=67e0361c014c76da4b33c77499203665bae6d396;p=control Update: Use the pre-defined typedef structure style for the main program type. Make sure that the typedef is defined early for a later defined type. This allows for circular use of the main, such as with callbacks. This is being done across all of my programs. --- diff --git a/sources/c/program/control/control/main.c b/sources/c/program/control/control/main.c index 20509b4..dd5a182 100644 --- a/sources/c/program/control/control/main.c +++ b/sources/c/program/control/control/main.c @@ -2,7 +2,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { - control_t data = control_t_initialize; + control_main_t data = control_main_t_initialize; data.program.debug.flag |= control_print_flag_debug_d | control_print_flag_out_d; data.program.error.flag |= control_print_flag_error_d | control_print_flag_out_d; diff --git a/sources/c/program/control/main/action.c b/sources/c/program/control/main/action.c index c29a5db..f9d818d 100644 --- a/sources/c/program/control/main/action.c +++ b/sources/c/program/control/main/action.c @@ -74,7 +74,7 @@ extern "C" { #endif // _di_control_action_type_name_ #ifndef _di_control_action_verify_ - void control_action_verify(control_t * const main) { + void control_action_verify(control_main_t * const main) { if (!main) return; diff --git a/sources/c/program/control/main/action.h b/sources/c/program/control/main/action.h index 3917f0b..b0d401a 100644 --- a/sources/c/program/control/main/action.h +++ b/sources/c/program/control/main/action.h @@ -56,7 +56,7 @@ extern "C" { * F_parameter (with error bit) on parameter validation/verification failure. */ #ifndef _di_control_action_verify_ - extern void control_action_verify(control_t * const main); + extern void control_action_verify(control_main_t * const main); #endif // _di_control_action_verify_ #ifdef __cplusplus diff --git a/sources/c/program/control/main/common.c b/sources/c/program/control/main/common.c index fe65a9d..7513bd8 100644 --- a/sources/c/program/control/main/common.c +++ b/sources/c/program/control/main/common.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_control_setting_load_ - void control_setting_load(const f_console_arguments_t arguments, control_t * const main) { + void control_setting_load(const f_console_arguments_t arguments, control_main_t * const main) { if (!main) return; diff --git a/sources/c/program/control/main/common.h b/sources/c/program/control/main/common.h index e846daf..c6e8f21 100644 --- a/sources/c/program/control/main/common.h +++ b/sources/c/program/control/main/common.h @@ -38,7 +38,7 @@ extern "C" { * @see fll_program_parameter_process_context() */ #ifndef _di_control_setting_load_ - extern void control_setting_load(const f_console_arguments_t arguments, control_t * const main); + extern void control_setting_load(const f_console_arguments_t arguments, control_main_t * const main); #endif // _di_control_setting_load_ #ifdef __cplusplus diff --git a/sources/c/program/control/main/common/type.c b/sources/c/program/control/main/common/type.c index 46e06f9..1626d0e 100644 --- a/sources/c/program/control/main/common/type.c +++ b/sources/c/program/control/main/common/type.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_control_delete_ - void control_delete(control_t * const control) { + void control_delete(control_main_t * const control) { if (!control) return; diff --git a/sources/c/program/control/main/common/type.h b/sources/c/program/control/main/common/type.h index 973b971..e2910fe 100644 --- a/sources/c/program/control/main/common/type.h +++ b/sources/c/program/control/main/common/type.h @@ -17,6 +17,13 @@ extern "C" { #endif /** + * Pre-define the main type so it can be used in child classes. + */ +#ifndef _di_control_t_typedef_ + typedef struct control_main_t_ control_main_t; +#endif // _di_control_t_typedef_ + +/** * The control cache. * * large: A buffer for storing large sets of data. @@ -158,21 +165,21 @@ extern "C" { * - setting: The settings data. * - cache: The cache data. */ -#ifndef _di_control_t_ - typedef struct { +#ifndef _di_control_main_t_ + struct control_main_t_ { fll_program_data_t program; control_setting_t setting; control_cache_t cache; - } control_t; + }; - #define control_t_initialize \ + #define control_main_t_initialize \ { \ fll_program_data_t_initialize, \ control_setting_t_initialize, \ control_cache_t_initialize, \ } -#endif // _di_control_t_ +#endif // _di_control_main_t_ /** * Deallocate control data. @@ -190,7 +197,7 @@ extern "C" { * @see control_setting_delete() */ #ifndef _di_control_delete_ - extern void control_delete(control_t * const control); + extern void control_delete(control_main_t * const control); #endif // _di_control_delete_ /** diff --git a/sources/c/program/control/main/packet.c b/sources/c/program/control/main/packet.c index 69f7cef..72d86a5 100644 --- a/sources/c/program/control/main/packet.c +++ b/sources/c/program/control/main/packet.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_control_packet_build_ - void control_packet_build(control_t * const main) { + void control_packet_build(control_main_t * const main) { if (!main) return; @@ -148,7 +148,7 @@ extern "C" { #endif // _di_control_packet_header_length_ #ifndef _di_control_packet_receive_ - void control_packet_receive(control_t * const main, control_payload_header_t * const header) { + void control_packet_receive(control_main_t * const main, control_payload_header_t * const header) { if (!main || !header) return; @@ -489,7 +489,7 @@ extern "C" { #endif // _di_control_packet_receive_ #ifndef _di_control_packet_process_ - void control_packet_process(control_t * const main, control_payload_header_t * const header) { + void control_packet_process(control_main_t * const main, control_payload_header_t * const header) { if (!main || !header) return; @@ -540,7 +540,7 @@ extern "C" { #endif // _di_control_packet_process_ #ifndef _di_control_packet_send_ - void control_packet_send(control_t * const main) { + void control_packet_send(control_main_t * const main) { if (!main) return; diff --git a/sources/c/program/control/main/packet.h b/sources/c/program/control/main/packet.h index 2ef8185..f5fdefb 100644 --- a/sources/c/program/control/main/packet.h +++ b/sources/c/program/control/main/packet.h @@ -38,7 +38,7 @@ extern "C" { * @see f_string_dynamic_append() */ #ifndef _di_control_packet_build_ - extern void control_packet_build(control_t * const main); + extern void control_packet_build(control_main_t * const main); #endif // _di_control_packet_build_ /** @@ -107,7 +107,7 @@ extern "C" { * @see fll_fss_basic_list_read() */ #ifndef _di_control_packet_receive_ - extern void control_packet_receive(control_t * const main, control_payload_header_t * const header); + extern void control_packet_receive(control_main_t * const main, control_payload_header_t * const header); #endif // _di_control_packet_receive_ /** @@ -128,7 +128,7 @@ extern "C" { * The control payload packet header data. */ #ifndef _di_control_packet_process_ - extern void control_packet_process(control_t * const main, control_payload_header_t * const header); + extern void control_packet_process(control_main_t * const main, control_payload_header_t * const header); #endif // _di_control_packet_process_ /** @@ -145,7 +145,7 @@ extern "C" { * @see f_socket_write() */ #ifndef _di_control_packet_send_ - extern void control_packet_send(control_t * const main); + extern void control_packet_send(control_main_t * const main); #endif // _di_control_packet_send_ #ifdef __cplusplus diff --git a/sources/c/program/control/main/print/debug.c b/sources/c/program/control/main/print/debug.c index 7e8b2f1..58bc6c8 100644 --- a/sources/c/program/control/main/print/debug.c +++ b/sources/c/program/control/main/print/debug.c @@ -27,7 +27,7 @@ extern "C" { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_debug_e) return F_output_not; - control_t * const main = (control_t *) print->custom; + control_main_t * const main = (control_main_t *) print->custom; f_file_stream_lock(print->to); diff --git a/sources/c/program/control/main/print/error.c b/sources/c/program/control/main/print/error.c index 8f862fc..a014454 100644 --- a/sources/c/program/control/main/print/error.c +++ b/sources/c/program/control/main/print/error.c @@ -10,7 +10,7 @@ extern "C" { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - fll_error_print(print, F_status_set_fine(((control_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e); + fll_error_print(print, F_status_set_fine(((control_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e); return F_okay; } @@ -22,7 +22,7 @@ extern "C" { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - fll_error_file_print(print, F_status_set_fine(((control_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type); + fll_error_file_print(print, F_status_set_fine(((control_main_t *) print->custom)->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type); return F_okay; } @@ -34,7 +34,7 @@ extern "C" { if (!print || !print->custom || !header) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - control_t * const main = (control_t *) print->custom; + control_main_t * const main = (control_main_t *) print->custom; f_file_stream_lock(print->to); @@ -64,7 +64,7 @@ extern "C" { if (!print || !print->custom || !header) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - control_t * const main = (control_t *) print->custom; + control_main_t * const main = (control_main_t *) print->custom; f_file_stream_lock(print->to); diff --git a/sources/c/program/control/main/print/message.c b/sources/c/program/control/main/print/message.c index 2146fd2..c540def 100644 --- a/sources/c/program/control/main/print/message.c +++ b/sources/c/program/control/main/print/message.c @@ -50,7 +50,7 @@ extern "C" { if (!print || !print->custom || !header) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_normal_e) return F_output_not; - control_t * const main = (control_t *) print->custom; + control_main_t * const main = (control_main_t *) print->custom; f_file_stream_lock(print->to); diff --git a/sources/c/program/control/main/process.c b/sources/c/program/control/main/process.c index e6ce0b0..784777b 100644 --- a/sources/c/program/control/main/process.c +++ b/sources/c/program/control/main/process.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_control_process_ - void control_process(control_t * const main) { + void control_process(control_main_t * const main) { if (!main || F_status_is_error(main->setting.state.status)) return; diff --git a/sources/c/program/control/main/process.h b/sources/c/program/control/main/process.h index 4a90ef7..9a7e69b 100644 --- a/sources/c/program/control/main/process.h +++ b/sources/c/program/control/main/process.h @@ -39,7 +39,7 @@ extern "C" { * F_parameter (with error bit) if main is NULL or setting is NULL. */ #ifndef _di_control_process_ - extern void control_process(control_t * const main); + extern void control_process(control_main_t * const main); #endif // _di_control_process_ #ifdef __cplusplus diff --git a/sources/c/program/control/main/signal.c b/sources/c/program/control/main/signal.c index 442df75..7daac73 100644 --- a/sources/c/program/control/main/signal.c +++ b/sources/c/program/control/main/signal.c @@ -5,7 +5,7 @@ extern "C" { #endif #if !defined(_di_control_signal_check_) && defined(_di_thread_support_) - f_status_t control_signal_check(control_t * const main) { + f_status_t control_signal_check(control_main_t * const main) { if (!main || main->program.signal.id == -1) return F_false; @@ -26,7 +26,7 @@ extern "C" { #endif // !defined(_di_control_signal_check_) && defined(_di_thread_support_) #if !defined(_di_control_signal_check_) && !defined(_di_thread_support_) - f_status_t control_signal_check(control_t * const main) { + f_status_t control_signal_check(control_main_t * const main) { if (!main || main->program.signal.id == -1) return F_false; @@ -43,7 +43,7 @@ extern "C" { #endif // !defined(_di_control_signal_check_) && !defined(_di_thread_support_) #if !defined(_di_control_signal_handler_) && !defined(_di_thread_support_) - void control_signal_handler(control_t * const main) { + void control_signal_handler(control_main_t * const main) { if (!main) return; diff --git a/sources/c/program/control/main/signal.h b/sources/c/program/control/main/signal.h index a499a49..26914d9 100644 --- a/sources/c/program/control/main/signal.h +++ b/sources/c/program/control/main/signal.h @@ -45,7 +45,7 @@ extern "C" { * @see fll_program_standard_signal_received() */ #ifndef _di_control_signal_check_ - extern f_status_t control_signal_check(control_t * const main); + extern f_status_t control_signal_check(control_main_t * const main); #endif // _di_control_signal_check_ /** @@ -76,7 +76,7 @@ extern "C" { * @see f_signal_wait() */ #if !defined(_di_control_signal_handler_) && !defined(_di_thread_support_) - extern void control_signal_handler(control_t * const main); + extern void control_signal_handler(control_main_t * const main); #endif // !defined(_di_control_signal_handler_) && !defined(_di_thread_support_) #ifdef __cplusplus diff --git a/sources/c/program/control/main/thread.c b/sources/c/program/control/main/thread.c index 1ce8490..c9a44e2 100644 --- a/sources/c/program/control/main/thread.c +++ b/sources/c/program/control/main/thread.c @@ -10,7 +10,7 @@ extern "C" { f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0); if (main) { - control_signal_handler((control_t *) main); + control_signal_handler((control_main_t *) main); } return 0; diff --git a/sources/c/program/control/main/thread.h b/sources/c/program/control/main/thread.h index 8c542d3..f59145c 100644 --- a/sources/c/program/control/main/thread.h +++ b/sources/c/program/control/main/thread.h @@ -26,7 +26,7 @@ * @param main * The program and settings data. * - * Must be of type control_t. + * Must be of type control_main_t. * * @return * 0, always.