]> Kevux Git Server - control/commitdiff
Update: Use the pre-defined typedef structure style for the main program type.
authorKevin Day <Kevin@kevux.org>
Mon, 20 Jan 2025 23:53:50 +0000 (17:53 -0600)
committerKevin Day <Kevin@kevux.org>
Mon, 20 Jan 2025 23:53:50 +0000 (17:53 -0600)
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.

18 files changed:
sources/c/program/control/control/main.c
sources/c/program/control/main/action.c
sources/c/program/control/main/action.h
sources/c/program/control/main/common.c
sources/c/program/control/main/common.h
sources/c/program/control/main/common/type.c
sources/c/program/control/main/common/type.h
sources/c/program/control/main/packet.c
sources/c/program/control/main/packet.h
sources/c/program/control/main/print/debug.c
sources/c/program/control/main/print/error.c
sources/c/program/control/main/print/message.c
sources/c/program/control/main/process.c
sources/c/program/control/main/process.h
sources/c/program/control/main/signal.c
sources/c/program/control/main/signal.h
sources/c/program/control/main/thread.c
sources/c/program/control/main/thread.h

index 20509b4e7ae82111763b61934db0f3cccf37c39f..dd5a18250ec9f05bda0bafbfacd8d1067b58aad8 100644 (file)
@@ -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;
index c29a5dba811057b7212c49926199d910ee37a19c..f9d818d86962ebfa80d64e082ca7120b516bdde6 100644 (file)
@@ -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;
 
index 3917f0b60ad9b8aac0e27e988c5fa98949246981..b0d401aee71aaf543432281c422dea5ce511c24f 100644 (file)
@@ -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
index fe65a9ddfd3f5819ece06a3a5d753bc8231669c7..7513bd885d2e0d038794ec14057054077e5e1cdb 100644 (file)
@@ -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;
 
index e846daff426cc836c6b8b1629485c7d52fe81ca8..c6e8f21b26f6a312b1cdb2689243cfb70892fa04 100644 (file)
@@ -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
index 46e06f9d8ca47d7e8859f106fc525f1266f8275f..1626d0e6d7a650a0bb4479eaadd167e9a43333a0 100644 (file)
@@ -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;
 
index 973b971d38fc4db4b55721e92ddb8b9ea1a3d0ab..e2910fe81368b6ed3375edf151089d0a13e44dd1 100644 (file)
@@ -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_
 
 /**
index 69f7cef58507b3beef9e25f8bfda353ce81d7c1e..72d86a5763f97b301d84c6fa1196ccf8093c0922 100644 (file)
@@ -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;
 
index 2ef8185d9dfc052ac98d0dfcb52da9bcd07290f7..f5fdefb23e94dae63bb8ac88fe64591b51180f7f 100644 (file)
@@ -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
index 7e8b2f1b9100de4f12165e5e887de1d6ca2ebf1b..58bc6c8bc1d6ce9d2012991fe10c00ad65a26707 100644 (file)
@@ -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);
 
index 8f862fc17dc317468a14e2bd39547f1876ed1546..a014454037eb39798e31bb18dd153faded8e633d 100644 (file)
@@ -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);
 
index 2146fd2bc7cc8faf20b936bf8c95aab52e451349..c540defb93b2cad2fc18c73751cdc6315414ea55 100644 (file)
@@ -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);
 
index e6ce0b02bb4b1dbc1dd733ce9af39ac67b5904a1..784777b726bee31970e85a184bc04d626905d764 100644 (file)
@@ -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;
 
index 4a90ef75e3a3ee83023595659f79b683eaeae939..9a7e69b14092ee179d856ad211911c1740eea833 100644 (file)
@@ -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
index 442df757c90b4e48f25f1cd239d980dbbf11c547..7daac73839488e36f7d81ae1d23a3e9233e30784 100644 (file)
@@ -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;
 
index a499a49098d756ffbd2238ff456593aee3a795e3..26914d991d1262ec908cf71d56cc05710114f325 100644 (file)
@@ -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
index 1ce8490404af71d78a0ff3795f08c6456adae3cb..c9a44e2cdcfb2af8d0e6145470b764e86cdb8aa3 100644 (file)
@@ -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;
index 8c542d36b6ef90ff83ba663f6d710863add0e569..f59145c2664adeb29acb7f154fcc611aa86b6cdb 100644 (file)
@@ -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.