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.
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;
#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;
* 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
#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;
* @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
#endif
#ifndef _di_control_delete_
- void control_delete(control_t * const control) {
+ void control_delete(control_main_t * const control) {
if (!control) return;
#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.
* - 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.
* @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_
/**
#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;
#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;
#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;
#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;
* @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_
/**
* @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_
/**
* 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_
/**
* @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
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);
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;
}
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;
}
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);
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);
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);
#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;
* 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
#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;
#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;
#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;
* @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_
/**
* @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
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;
* @param main
* The program and settings data.
*
- * Must be of type control_t.
+ * Must be of type control_main_t.
*
* @return
* 0, always.