From c12bfc720b9e2c883bb074e58b0db226eb5a6570 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 5 Apr 2023 23:09:52 -0500 Subject: [PATCH] Progress: Continue program related work, addressing f_state_t, recursion, and Featureless Make. Add missing f_directory_statuss_resize() implemetnation. Add code property to f_state_t to provide custom flags for the caller to control. Create fake_local_t to pass custom information to the recursion functions. Begin setting up and populating the failures structure. Take care more cases where the interrupt needs to be handled. This now sets the interrupt function globally and so the interrupt should be checked more often (such as in FSS Basic List read functions). Make sure the interrupt is not checked twice once a signal is received. This can happen after a program returns due to an interrupt. --- level_0/f_directory/c/directory/type.c | 10 ++++++ level_0/f_directory/c/directory/type.h | 44 +++++++++++++++++-------- level_0/f_type/c/type.h | 9 +++-- level_3/control/c/private-control.c | 4 +-- level_3/controller/c/entry/private-entry.c | 6 ++-- level_3/controller/c/rule/private-rule.c | 8 ++--- level_3/fake/c/main/build.c | 18 ++++++---- level_3/fake/c/main/build/load.c | 2 +- level_3/fake/c/main/common/enumeration.h | 14 ++++++++ level_3/fake/c/main/common/type.h | 31 ++++++++++++++++- level_3/fake/c/main/fake.c | 2 +- level_3/fake/c/main/main.c | 4 ++- level_3/fake/c/main/make/load_fakefile.c | 21 ++---------- level_3/fake/c/main/print/verbose.c | 12 +++++-- level_3/fake/c/main/signal.c | 21 ++++++++++++ level_3/fake/c/main/signal.h | 20 +++++++++++ level_3/fss_basic_list_read/c/private-read.c | 2 +- level_3/fss_basic_read/c/private-read.c | 2 +- level_3/fss_embedded_list_read/c/private-read.c | 2 +- level_3/fss_extended_list_read/c/private-read.c | 2 +- level_3/fss_extended_read/c/private-read.c | 2 +- level_3/fss_payload_read/c/private-read.c | 2 +- 22 files changed, 174 insertions(+), 64 deletions(-) diff --git a/level_0/f_directory/c/directory/type.c b/level_0/f_directory/c/directory/type.c index 85e6f71..bd7c6b6 100644 --- a/level_0/f_directory/c/directory/type.c +++ b/level_0/f_directory/c/directory/type.c @@ -173,6 +173,16 @@ extern "C" { } #endif // _di_f_directory_statuss_increase_by_ +#ifndef _di_f_directory_statuss_resize_ + f_status_t f_directory_statuss_resize(const f_array_length_t length, f_directory_statuss_t * const statuss) { + #ifndef _di_level_0_parameter_checking_ + if (!statuss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_directory_statuss_resize(length, statuss); + } +#endif // _di_f_directory_statuss_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_directory/c/directory/type.h b/level_0/f_directory/c/directory/type.h index c4b259e..1a18786 100644 --- a/level_0/f_directory/c/directory/type.h +++ b/level_0/f_directory/c/directory/type.h @@ -425,8 +425,11 @@ extern "C" { * @return * F_none on success. * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_directory_statuss_adjust_ extern f_status_t f_directory_statuss_adjust(const f_array_length_t length, f_directory_statuss_t * const statuss); @@ -448,8 +451,11 @@ extern "C" { * F_none on success. * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_directory_statuss_decimate_by_ extern f_status_t f_directory_statuss_decimate_by(const f_array_length_t amount, f_directory_statuss_t * const statuss); @@ -471,8 +477,11 @@ extern "C" { * F_none on success. * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_directory_statuss_decrease_by_ extern f_status_t f_directory_statuss_decrease_by(const f_array_length_t amount, f_directory_statuss_t * const statuss); @@ -494,9 +503,11 @@ extern "C" { * F_none on success. * F_data_not on success, but there is no reason to increase size (used + 1 <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_directory_statuss_increase_ extern f_status_t f_directory_statuss_increase(const f_array_length_t step, f_directory_statuss_t * const statuss); @@ -518,9 +529,11 @@ extern "C" { * F_none on success. * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_array_too_large (with error bit) if the new array length is too large. + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_directory_statuss_increase_by_ extern f_status_t f_directory_statuss_increase_by(const f_array_length_t amount, f_directory_statuss_t * const statuss); @@ -537,8 +550,11 @@ extern "C" { * @return * F_none on success. * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_string_dynamic_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamic_resize() */ #ifndef _di_f_directory_statuss_resize_ extern f_status_t f_directory_statuss_resize(const f_array_length_t length, f_directory_statuss_t * const statuss); diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index 5c61c5a..75fdb04 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -95,7 +95,8 @@ extern "C" { * * step_large: The allocation step to use for large buffers. * step_small: The allocation step to use for small buffers. - * flag: A 32-bit digit intended for provided flags that are defined by the function. + * flag: A 64-bit digit intended for provided flags that are defined by the function. + * code: A 64-bit digit intended for provided flags that are defined by the caller. * status: The status used while processing (This should hold the error passed to the handle callback and should be updated as necessary). * handle: A function to call on a specific error (allowing for the error to be handled before function returns). May be NULL. * interrupt: A function to call for checking to see if an interrupt is to be called. May be NULL. @@ -109,6 +110,7 @@ extern "C" { uint16_t step_small; f_status_t status; uint64_t flag; + uint64_t code; void (*handle)(void * const state, void * const internal); void (*interrupt)(void * const state, void * const internal); @@ -128,13 +130,15 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ } - #define macro_f_state_t_initialize_1(step_large, step_small, status, flag, handle, interrupt, callbacks, custom, data) { \ + #define macro_f_state_t_initialize_1(step_large, step_small, status, flag, code, handle, interrupt, callbacks, custom, data) { \ step_large, \ step_small, \ status, \ flag, \ + code, \ handle, \ interrupt, \ callbacks, \ @@ -147,6 +151,7 @@ extern "C" { state.step_small = 0; \ state.status = F_none; \ state.flag = 0; \ + state.code = 0; \ state.handle = 0; \ state.interrupt = 0; \ state.callbacks = 0; \ diff --git a/level_3/control/c/private-control.c b/level_3/control/c/private-control.c index ee72d49..1b3f1c0 100644 --- a/level_3/control/c/private-control.c +++ b/level_3/control/c/private-control.c @@ -167,7 +167,7 @@ extern "C" { if (F_status_is_error(status)) return status; } - const f_state_t state = macro_f_state_t_initialize_1(control_allocation_large_d, control_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); + const f_state_t state = macro_f_state_t_initialize_1(control_allocation_large_d, control_allocation_small_d, F_none, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); f_string_static_t contents_array[main->parameters.remaining.used]; f_string_statics_t contents = macro_f_string_statics_t_initialize(contents_array, 0, main->parameters.remaining.used); @@ -318,7 +318,7 @@ extern "C" { } { - f_state_t state = macro_f_state_t_initialize_1(control_allocation_large_d, control_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); + f_state_t state = macro_f_state_t_initialize_1(control_allocation_large_d, control_allocation_small_d, F_none, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); f_string_range_t range_packet = macro_f_string_range_t_initialize2(data->cache.large.used); status = fll_fss_basic_list_read(data->cache.large, state, &range_packet, &data->cache.packet_objects, &data->cache.packet_contents, &data->cache.delimits, 0, 0); diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index d0d4707..c314961 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -95,7 +95,7 @@ extern "C" { { controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_entry, global.thread); - f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_string_range_t range = content_range; status = fll_fss_extended_read(cache->buffer_file, state, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); @@ -1577,7 +1577,7 @@ extern "C" { if (F_status_is_error_not(status)) { if (cache->buffer_file.used) { controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_entry, global.thread); - f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_string_range_t range = macro_f_string_range_t_initialize2(cache->buffer_file.used); status = fll_fss_basic_list_read(cache->buffer_file, state, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments); @@ -1876,7 +1876,7 @@ extern "C" { { controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_entry, global.thread); - f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_string_range_t range = content_range; status = fll_fss_extended_read(cache->buffer_file, state, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index cc2e2e9..3e4ad23 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -222,7 +222,7 @@ extern "C" { f_status_t status = F_none; controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); - f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_array_length_t i = 0; @@ -2360,7 +2360,7 @@ extern "C" { f_status_t status = F_none; controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); - f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_string_range_t range = macro_f_string_range_t_initialize2(cache->buffer_item.used); f_array_length_t last = 0; @@ -3785,7 +3785,7 @@ extern "C" { if (cache->buffer_file.used) { controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); - f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_string_range_t range = macro_f_string_range_t_initialize2(cache->buffer_file.used); status = fll_fss_basic_list_read(cache->buffer_file, state, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments); @@ -3951,7 +3951,7 @@ extern "C" { f_string_range_t range2 = f_string_range_t_initialize; controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); - f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + f_state_t state = macro_f_state_t_initialize_1(controller_common_allocation_large_d, controller_common_allocation_small_d, F_none, 0, 0, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); status = fll_fss_extended_read(cache->buffer_item, state, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); diff --git a/level_3/fake/c/main/build.c b/level_3/fake/c/main/build.c index f09e682..8c3fee6 100644 --- a/level_3/fake/c/main/build.c +++ b/level_3/fake/c/main/build.c @@ -172,6 +172,7 @@ extern "C" { f_string_dynamic_t destination_file = f_string_dynamic_t_initialize; f_string_dynamic_t destination_directory = f_string_dynamic_t_initialize; f_string_static_t buffer = f_string_static_t_initialize; + fake_local_t local = macro_fake_local_t_initialize_1(main, &failures, 0); if (main->program.message.verbosity != f_console_verbosity_quiet_e && main->program.message.verbosity != f_console_verbosity_error_e) { fll_print_format("%r%[Copying %Q.%]%r", main->program.message.to, f_string_eol_s, main->program.context.set.important, label, main->program.context.set.important, f_string_eol_s); @@ -191,11 +192,12 @@ extern "C" { f_directory_recurse_copy_t recurse = f_directory_recurse_copy_t_initialize; recurse.verbose = &fake_print_verbose_recursive_copy; - recurse.state.custom = (void *) data; - - //recurse.failures = &failures; // @fixme this now needs to be handled by a callback in recurse (recurse.state.handle)., maybe make this a callback on f_directory_recurse_copy_t? + recurse.state.custom = (void *) &local; + recurse.state.code = fake_state_code_local_e; recurse.mode = mode; + f_array_length_t j = 0; + for (f_array_length_t i = 0; i < files.used; ++i) { if (fake_signal_check(main)) break; @@ -232,16 +234,16 @@ extern "C" { break; } + // @todo replace fl_directory_copy() with fl_directory_do() because it has better error handling. + // @todo once this is done, then consider removing fl_directory_copy() entirely. + // @todo consider providing a copy/clone/move callback in FLL in place of fl_directory_copy() that can be passed to fl_directory_do(). fl_directory_copy(path_source, destination_directory, &recurse); if (F_status_is_error(main->setting.state.status)) { if (main->program.error.verbosity >= f_console_verbosity_verbose_e) { - /* // @fixme - for (f_array_length_t j = 0; j < failures.used; ++j) { - + for (j = 0; j < failures.used; ++j) { fake_print_error_build_operation_file(&main->program.error, macro_fake_f(fl_directory_copy), fake_common_file_directory_copy_s, f_file_operation_to_s, path_source, destination_directory, F_true); } // for - */ if (F_status_set_fine(main->setting.state.status) != F_failure) { fake_print_error(&main->program.error, macro_fake_f(fl_directory_copy)); @@ -337,6 +339,8 @@ extern "C" { f_string_dynamic_resize(0, &destination_file); f_string_dynamic_resize(0, &destination_directory); + f_directory_statuss_resize(0, &failures); + fake_build_touch(data, file_stage); } #endif // _di_fake_build_copy_ diff --git a/level_3/fake/c/main/build/load.c b/level_3/fake/c/main/build/load.c index 38eb956..4d17e0f 100644 --- a/level_3/fake/c/main/build/load.c +++ b/level_3/fake/c/main/build/load.c @@ -136,7 +136,7 @@ extern "C" { f_fss_delimits_t delimits = f_fss_delimits_t_initialize; // @todo make sure main->setting.state.custom = (void *) main->program; - //f_state_t state = macro_f_state_t_initialize_1(fake_allocation_large_d, fake_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main->program, 0); + //f_state_t state = macro_f_state_t_initialize_1(fake_allocation_large_d, fake_allocation_small_d, F_none, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main->program, 0); fll_fss_extended_read(buffer, &range, &objects, &contents, 0, 0, &delimits, 0, &main->setting.state); diff --git a/level_3/fake/c/main/common/enumeration.h b/level_3/fake/c/main/common/enumeration.h index e59794a..d76cbc2 100644 --- a/level_3/fake/c/main/common/enumeration.h +++ b/level_3/fake/c/main/common/enumeration.h @@ -381,6 +381,20 @@ extern "C" { }; // enum #endif // _di_fake_print_flag_e_ +/** + * Flags for the code property in the f_state_t structure. + * + * fake_state_code_*_e: + * - none: No flags set. + * - local: A flag designating that the state.custom is in fake_local_t rather than fake_main_t. + */ +#ifndef _di_fake_state_code_e_ + enum { + fake_state_code_none_e = 0x0, + fake_state_code_local_e = 0x1, + }; // enum +#endif // _di_fake_state_code_e_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/main/common/type.h b/level_3/fake/c/main/common/type.h index e155574..ce65a34 100644 --- a/level_3/fake/c/main/common/type.h +++ b/level_3/fake/c/main/common/type.h @@ -308,7 +308,36 @@ extern "C" { f_string_dynamic_t_initialize, \ 0, \ } -#endif // _di_fake_main_t_ +#endif // _di_fake_data_t_ + +/** + * The program data for local operations so that custom data can be passed to functions. + * + * main: The program and settings data. + * custom_1: Custom data that both the caller and the called function know to expect. + * custom_2: Custom data that both the caller and the called function know to expect. + */ +#ifndef _di_fake_local_t_ + typedef struct { + fake_main_t *main; + void *custom_1; + void *custom_2; + } fake_local_t; + + #define fake_local_t_initialize \ + { \ + 0, \ + 0, \ + 0, \ + } + + #define macro_fake_local_t_initialize_1(main, custom_1, custom_2) \ + { \ + main, \ + custom_1, \ + custom_2, \ + } +#endif // _di_fake_local_t_ /** * Build settings data. diff --git a/level_3/fake/c/main/fake.c b/level_3/fake/c/main/fake.c index 631bf0e..917fad5 100644 --- a/level_3/fake/c/main/fake.c +++ b/level_3/fake/c/main/fake.c @@ -195,7 +195,7 @@ extern "C" { } if (main->setting.state.status == F_child) break; - if (fake_signal_check(main)) break; + if (F_status_set_fine(main->setting.state.status) == F_interrupt || fake_signal_check(main)) break; if (F_status_is_error(main->setting.state.status)) break; } // for } diff --git a/level_3/fake/c/main/main.c b/level_3/fake/c/main/main.c index f1eefe1..f9eba33 100644 --- a/level_3/fake/c/main/main.c +++ b/level_3/fake/c/main/main.c @@ -20,7 +20,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.setting.flag |= fake_main_flag_enable_static_e; data.setting.state.step_large = fake_allocation_large_d; data.setting.state.step_small = fake_allocation_small_d; - data.setting.state.custom = (void *) &data.program; + data.setting.state.custom = (void *) &data; + data.setting.state.code = fake_state_code_none_e; + data.setting.state.interrupt = &fake_signal_handler_callback; f_console_parameter_t parameters[] = fake_console_parameter_t_initialize; data.program.parameters.array = parameters; diff --git a/level_3/fake/c/main/make/load_fakefile.c b/level_3/fake/c/main/make/load_fakefile.c index c8c8f6f..479edb7 100644 --- a/level_3/fake/c/main/make/load_fakefile.c +++ b/level_3/fake/c/main/make/load_fakefile.c @@ -9,14 +9,7 @@ extern "C" { if (!data_make || !data_make->data || !data_make->main) return; if (F_status_is_error(data_make->main->setting.state.status)) return; - - if (fll_program_standard_signal_received(&data_make->main->program)) { - fll_program_print_signal_received(&data_make->main->program.warning, data_make->main->program.signal_received); - - data_make->main->setting.state.status = F_status_set_error(F_interrupt); - - return; - } + if (fake_signal_check(data_make->main)) return; data_make->fakefile.used = 0; @@ -103,17 +96,7 @@ extern "C" { for (f_array_length_t i = 0; i < list_objects.used; ++i) { - if (!(i % fake_signal_check_short_d)) { - if (fll_program_standard_signal_received(&data_make->main->program)) { - fll_program_print_signal_received(&data_make->main->program.warning, data_make->main->program.signal_received); - - data_make->main->setting.state.status = F_status_set_error(F_interrupt); - - break; - } - - data_make->main->program.signal_check = 0; - } + if (fake_signal_check(data_make->main)) break; if (f_compare_dynamic_partial_string(fake_make_item_settings_s.string, data_make->main->buffer, fake_make_item_settings_s.used, list_objects.array[i]) == F_equal_to) { if (!missing_settings) { diff --git a/level_3/fake/c/main/print/verbose.c b/level_3/fake/c/main/print/verbose.c index be49445..363ac20 100644 --- a/level_3/fake/c/main/print/verbose.c +++ b/level_3/fake/c/main/print/verbose.c @@ -91,7 +91,9 @@ extern "C" { return; } - fake_main_t * const main = (fake_main_t *) recurse->state.custom; + fake_main_t * const main = (recurse->state.code & fake_state_code_local_e) + ? ((fake_local_t *) recurse->state.custom)->main + : (fake_main_t *) recurse->state.custom; if (main->program.message.verbosity < f_console_verbosity_verbose_e) { recurse->state.status = F_output_not; @@ -116,7 +118,9 @@ extern "C" { return; } - fake_main_t * const main = (fake_main_t *) recurse->state.custom; + fake_main_t * const main = (recurse->state.code & fake_state_code_local_e) + ? ((fake_local_t *) recurse->state.custom)->main + : (fake_main_t *) recurse->state.custom; if (main->program.message.verbosity < f_console_verbosity_verbose_e) { recurse->state.status = F_output_not; @@ -141,7 +145,9 @@ extern "C" { return; } - fake_main_t * const main = (fake_main_t *) recurse->state.custom; + fake_main_t * const main = (recurse->state.code & fake_state_code_local_e) + ? ((fake_local_t *) recurse->state.custom)->main + : (fake_main_t *) recurse->state.custom; if (main->program.message.verbosity < f_console_verbosity_verbose_e) { recurse->state.status = F_output_not; diff --git a/level_3/fake/c/main/signal.c b/level_3/fake/c/main/signal.c index a401144..57b4ddc 100644 --- a/level_3/fake/c/main/signal.c +++ b/level_3/fake/c/main/signal.c @@ -108,6 +108,27 @@ extern "C" { } #endif // !defined(_di_fake_signal_handler_) && !defined(_di_thread_support_) +#ifndef _di_fake_signal_handler_callback_ + void fake_signal_handler_callback(void * const void_state, void * const void_internal) { + + if (!void_state) return; + + f_state_t * const state = (f_state_t *) void_state; + + if (!state->custom) { + state->status = F_interrupt_not; + + return; + } + + fake_main_t * const main = (state->code & fake_state_code_local_e) + ? ((fake_local_t *) state->custom)->main + : (fake_main_t *) state->custom; + + state->status = (fake_signal_check(main) == F_true) ? F_status_set_error(F_interrupt) : F_interrupt_not; + } +#endif // _di_fake_signal_handler_callback_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/main/signal.h b/level_3/fake/c/main/signal.h index a40c0da..21d9bea 100644 --- a/level_3/fake/c/main/signal.h +++ b/level_3/fake/c/main/signal.h @@ -79,6 +79,26 @@ extern "C" { extern void fake_signal_handler(fake_main_t * const main); #endif // !defined(_di_fake_signal_handler_) && !defined(_di_thread_support_) +/** + * A callback intended to be assigned to the state.interrupt. + * + * @param state + * The f_state_t data. + * + * The state.custom must be fake_main_t, except for when the code has the bit fake_state_code_local_e. + * When the fake_state_code_local_e bit is set, then the state.custum must be fake_local_t. + * + * This alters state.status: + * F_interrupt_not if not interrupted. + * + * F_interrupt (with error bit) if interrupted. + * @param internal + * Not used. + */ +#ifndef _di_fake_signal_handler_callback_ + extern void fake_signal_handler_callback(void * const state, void * const internal); +#endif // _di_fake_signal_handler_callback_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index 204237f..a3dce34 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -246,7 +246,7 @@ extern "C" { #ifndef _di_fss_basic_list_read_load_ f_status_t fss_basic_list_read_load(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize_1(fss_basic_list_read_common_allocation_large_d, fss_basic_list_read_common_allocation_small_d, F_none, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); + f_state_t state = macro_f_state_t_initialize_1(fss_basic_list_read_common_allocation_large_d, fss_basic_list_read_common_allocation_small_d, F_none, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index 2818718..475cd73 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -223,7 +223,7 @@ extern "C" { #ifndef _di_fss_basic_read_load_ f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize_1(fss_basic_read_common_allocation_large_d, fss_basic_read_common_allocation_small_d, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); + f_state_t state = macro_f_state_t_initialize_1(fss_basic_read_common_allocation_large_d, fss_basic_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits.used = 0; diff --git a/level_3/fss_embedded_list_read/c/private-read.c b/level_3/fss_embedded_list_read/c/private-read.c index 1929502..b09a6ab 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -245,7 +245,7 @@ extern "C" { f_status_t status = F_none; { - f_state_t state = macro_f_state_t_initialize_1(fss_embedded_list_read_common_allocation_large_d, fss_embedded_list_read_common_allocation_small_d, 0, 0, &fll_program_standard_signal_handle, 0, (void *) data->main, 0); + f_state_t state = macro_f_state_t_initialize_1(fss_embedded_list_read_common_allocation_large_d, fss_embedded_list_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) data->main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); objects_delimits->used = 0; diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index b186670..bc458a9 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -245,7 +245,7 @@ extern "C" { #ifndef _di_fss_extended_list_read_load_ f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize_1(fss_extended_list_read_common_allocation_large_d, fss_extended_list_read_common_allocation_small_d, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); + f_state_t state = macro_f_state_t_initialize_1(fss_extended_list_read_common_allocation_large_d, fss_extended_list_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index 30a18a3..1e2a2da 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -249,7 +249,7 @@ extern "C" { #ifndef _di_fss_extended_read_load_ f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize_1(fss_extended_read_common_allocation_large_d, fss_extended_read_common_allocation_small_d, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); + f_state_t state = macro_f_state_t_initialize_1(fss_extended_read_common_allocation_large_d, fss_extended_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index b7e6b63..381a49b 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -237,7 +237,7 @@ extern "C" { #ifndef _di_fss_payload_read_load_ f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize_1(fss_payload_read_common_allocation_large_d, fss_payload_read_common_allocation_small_d, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); + f_state_t state = macro_f_state_t_initialize_1(fss_payload_read_common_allocation_large_d, fss_payload_read_common_allocation_small_d, 0, 0, 0, &fll_program_standard_signal_handle, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; -- 1.8.3.1