From: Kevin Day Date: Wed, 19 May 2021 03:48:26 +0000 (-0500) Subject: Progress: Interrupt and memory allocation related changes. X-Git-Tag: 0.5.4~31 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=a7f343335a6429555a269d291bd90446f8e42be1;p=fll Progress: Interrupt and memory allocation related changes. I've noticed that when processing large files, the FSS programs cannot be interrupted using controlled interrupts rather than the standard interrupt signals. The POSIX standard structure of interrupts, particularly in threads, is very poorly defined. When a threaded program wishes to be triggered for an exit, the pthread_cancel() function works by immediately exiting the program rather than aborting. This prevents proper deallocated and shutting down of programs, particularly those that handle interrupts. This introduces a new f_state_t structure that allows passing a generalized state around that accepts (void *) arguments so that it is not tied to any particular implementation beyond the basic structure. The FLL/FSS and IKI processing functions then take advantage of this and utilize the state. There are performance concerns with this, but the need to have controlled interrupts is deemed far more important. Furthermore, the generic function is open ended so that the caller can potentially implement some sort of optimization. Now that an f_state_t structure exists I am finally compelled to move the allocation step functionality into this structure. This will allow for more performance improvements (such as determining allocation step according to file size). For large files (megabytes, gigabytes, etc..) the allocation step can be set to something large, such as 16384. Doing so should reduce the amount of memory I/O needed for resize operations. I have opted to use uint16_t, so there is a max step of 64k at this time. This entire process needs additional reviewing before releasing. I designed this with the intent to move the function parameters into the (void *) data property on the f_state_t structure. This will allow for reducing the parameters passed. This design will also allow for me to later on add additional state information that can be passed to the caller. This also allows for better or more granular error handling and reporting. More work is needed in this regard because many of the functions currently written need to utilize this (such as the recursive directory functions). This focuses on the most basic utilization in the programs but I would like to perform file size tests so that I can at least have a very basic heuristic for determining the default allocation size for large (or small) files. A new project fl_signal is provided with a basic interrupt callback for f_state_t as I believe a dirt simple callback will be commonly used. The default allocation step is now broken up into large and small allocation steps. --- diff --git a/build/level_0/settings b/build/level_0/settings index c114ae5..fedcc2b 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -24,7 +24,7 @@ build_libraries-level_threadless build_sources_library account.c private-account.c capability.c color.c color-common.c console.c console-common.c control_group.c control_group-common.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c file-common.c private-file.c fss.c private-fss.c fss_named.c fss_nest.c fss_set.c iki.c iki-common.c private-iki.c limit.c memory.c memory_structure.c private-memory.c path.c path-common.c private-path.c pipe.c print.c private-print.c serialize.c serialize-common.c private-serialize.c signal.c socket.c string.c string-common.c private-string.c string_dynamic.c string_map.c string_quantity.c string_range.c string_triple.c type_array.c private-type_array.c utf.c utf-common.c private-utf.c utf_dynamic.c utf_map.c utf_quantity.c utf_range.c utf_triple.c build_sources_library-level thread.c private-thread.c build_sources_program -build_sources_headers account.h account-common.h capability.h capability-common.h color.h color-common.h console.h console-common.h control_group.h control_group-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h execute.h execute-common.h file.h file-common.h fss.h private-fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h limit.h limit-common.h memory.h memory_structure.h memory-common.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h status_array.h string.h string-common.h private-string.h string_dynamic.h string_map.h string_quantity.h string_range.h string_triple.h type.h type_array.h private-type_array.h type_array-common.h utf.h utf-common.h utf_dynamic.h utf_map.h utf_quantity.h utf_range.h utf_triple.h +build_sources_headers account.h account-common.h capability.h capability-common.h color.h color-common.h console.h console-common.h control_group.h control_group-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h execute.h execute-common.h file.h file-common.h fss.h private-fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h limit.h limit-common.h memory.h memory_structure.h memory-common.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h string.h string-common.h private-string.h string_dynamic.h string_map.h string_quantity.h string_range.h string_triple.h type.h type_array.h private-type_array.h type_array-common.h utf.h utf-common.h utf_dynamic.h utf_map.h utf_quantity.h utf_range.h utf_triple.h build_sources_headers-level thread.h thread-common.h build_sources_script build_sources_setting diff --git a/build/level_1/settings b/build/level_1/settings index 405b211..60da028 100644 --- a/build/level_1/settings +++ b/build/level_1/settings @@ -21,10 +21,10 @@ build_language c build_libraries -lc -lcap build_libraries-level -lfll_0 build_libraries-level_threadless -lfll_0 -build_sources_library console.c control_group.c conversion.c directory.c private-directory.c environment.c private-fss.c fss_basic.c fss_basic_list.c fss_embedded_list.c fss_extended.c fss_extended_list.c iki.c print.c private-print.c status.c string.c private-string.c utf.c private-utf.c utf_file.c private-utf_file.c +build_sources_library console.c control_group.c conversion.c directory.c private-directory.c environment.c private-fss.c fss_basic.c fss_basic_list.c fss_embedded_list.c fss_extended.c fss_extended_list.c iki.c print.c private-print.c signal.c status.c string.c private-string.c utf.c private-utf.c utf_file.c private-utf_file.c build_sources_library-level build_sources_program -build_sources_headers console.h control_group.h conversion.h directory.h environment.h execute.h execute-common.h fss.h fss_basic.h fss_basic_list.h fss_embedded_list.h fss_extended.h fss_extended_list.h fss_status.h iki.h print.h status.h string.h utf.h utf_file.h +build_sources_headers console.h control_group.h conversion.h directory.h environment.h execute.h execute-common.h fss.h fss_basic.h fss_basic_list.h fss_embedded_list.h fss_extended.h fss_extended_list.h fss_status.h iki.h print.h signal.h signal-common.h status.h string.h utf.h utf_file.h build_sources_headers-level build_sources_script build_sources_setting diff --git a/build/monolithic/settings b/build/monolithic/settings index 92a4b9e..dc08117 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -21,10 +21,10 @@ build_language c build_libraries -lc -lcap build_libraries-monolithic build_libraries-monolithic_threadless -build_sources_library level_0/account.c level_0/private-account.c level_0/capability.c level_0/color.c level_0/color-common.c level_0/console.c level_0/console-common.c level_0/control_group.c level_0/control_group-common.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/file-common.c level_0/private-file.c level_0/fss.c level_0/private-fss.c level_0/fss_named.c level_0/fss_nest.c level_0/fss_set.c level_0/iki.c level_0/iki-common.c level_0/private-iki.c level_0/limit.c level_0/memory.c level_0/memory_structure.c level_0/private-memory.c level_0/path.c level_0/path-common.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/serialize-common.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/string.c level_0/string-common.c level_0/private-string.c level_0/string_dynamic.c level_0/string_map.c level_0/string_quantity.c level_0/string_range.c level_0/string_triple.c level_0/type_array.c level_0/private-type_array.c level_0/utf.c level_0/utf-common.c level_0/private-utf.c level_0/utf_dynamic.c level_0/utf_map.c level_0/utf_quantity.c level_0/utf_range.c level_0/utf_triple.c level_1/console.c level_1/control_group.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_embedded_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/private-print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/control_group.c level_2/error.c level_2/error-common.c level_2/private-error.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_embedded_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c +build_sources_library level_0/account.c level_0/private-account.c level_0/capability.c level_0/color.c level_0/color-common.c level_0/console.c level_0/console-common.c level_0/control_group.c level_0/control_group-common.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/file-common.c level_0/private-file.c level_0/fss.c level_0/private-fss.c level_0/fss_named.c level_0/fss_nest.c level_0/fss_set.c level_0/iki.c level_0/iki-common.c level_0/private-iki.c level_0/limit.c level_0/memory.c level_0/memory_structure.c level_0/private-memory.c level_0/path.c level_0/path-common.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/serialize-common.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/string.c level_0/string-common.c level_0/private-string.c level_0/string_dynamic.c level_0/string_map.c level_0/string_quantity.c level_0/string_range.c level_0/string_triple.c level_0/type_array.c level_0/private-type_array.c level_0/utf.c level_0/utf-common.c level_0/private-utf.c level_0/utf_dynamic.c level_0/utf_map.c level_0/utf_quantity.c level_0/utf_range.c level_0/utf_triple.c level_1/console.c level_1/control_group.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_embedded_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/private-print.c level_1/signal.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/control_group.c level_2/error.c level_2/error-common.c level_2/private-error.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_embedded_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c build_sources_library-monolithic level_0/thread.c level_0/private-thread.c build_sources_program -build_sources_headers level_0/account.h level_0/account-common.h level_0/capability.h level_0/capability-common.h level_0/color.h level_0/color-common.h level_0/console.h level_0/console-common.h level_0/control_group.h level_0/control_group-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/execute.h level_0/execute-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/private-fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/limit.h level_0/limit-common.h level_0/memory.h level_0/memory_structure.h level_0/memory-common.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/private-string.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/string_triple.h level_0/type.h level_0/type_array.h level_0/private-type_array.h level_0/type_array-common.h level_0/utf.h level_0/utf-common.h level_0/utf_dynamic.h level_0/utf_map.h level_0/utf_quantity.h level_0/utf_range.h level_0/utf_triple.h level_1/console.h level_1/control_group.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/execute.h level_1/execute-common.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_embedded_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/control_group.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_embedded_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h +build_sources_headers level_0/account.h level_0/account-common.h level_0/capability.h level_0/capability-common.h level_0/color.h level_0/color-common.h level_0/console.h level_0/console-common.h level_0/control_group.h level_0/control_group-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/execute.h level_0/execute-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/private-fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/limit.h level_0/limit-common.h level_0/memory.h level_0/memory_structure.h level_0/memory-common.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/string.h level_0/string-common.h level_0/private-string.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/string_triple.h level_0/type.h level_0/type_array.h level_0/private-type_array.h level_0/type_array-common.h level_0/utf.h level_0/utf-common.h level_0/utf_dynamic.h level_0/utf_map.h level_0/utf_quantity.h level_0/utf_range.h level_0/utf_triple.h level_1/console.h level_1/control_group.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/execute.h level_1/execute-common.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_embedded_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/signal.h level_1/signal-common.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/control_group.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_embedded_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h build_sources_headers-monolithic level_0/thread.h level_0/thread-common.h build_sources_script build_sources_setting diff --git a/build/scripts/bootstrap-example.sh b/build/scripts/bootstrap-example.sh index 0009be6..968b41b 100644 --- a/build/scripts/bootstrap-example.sh +++ b/build/scripts/bootstrap-example.sh @@ -56,7 +56,7 @@ if [[ $1 == "individual" ]] ; then bash build/scripts/package.sh $verbose $color build -i if [[ $? -eq 0 ]] ; then - for i in f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_thread fl_console fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_status fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_iki fll_path fll_program fll_status ; do + for i in f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_thread fl_console fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_signal fl_status fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_iki fll_path fll_program fll_status ; do echo && echo "Processing $i." && cd package/individual/$i-$2/ && diff --git a/level_0/f_account/c/account-common.h b/level_0/f_account/c/account-common.h index b1d073e..b7c9998 100644 --- a/level_0/f_account/c/account-common.h +++ b/level_0/f_account/c/account-common.h @@ -101,7 +101,7 @@ extern "C" { #define macro_f_string_accounts_t_delete_simple(accounts) macro_f_memory_structure_delete_simple(values, sizeof(f_account_t), 0) #define macro_f_string_accounts_t_destroy_simple(accounts) macro_f_memory_structure_destroy_simple(values, sizeof(f_account_t), 0) - #define macro_f_string_accounts_t_increase(status, values) macro_f_memory_structure_increase(status, values, f_account_t) + #define macro_f_string_accounts_t_increase(status, step, values) macro_f_memory_structure_increase(status, step, values, f_account_t) #define macro_f_string_accounts_t_increase_by(status, values, amount) macro_f_memory_structure_increase_by(status, values, f_account_t, amount) #define macro_f_string_accounts_t_decrease_by(status, values, amount) macro_f_memory_structure_decrease_by(status, values, f_account_t, amount) #define macro_f_string_accounts_t_decimate_by(status, values, amount) macro_f_memory_structure_decimate_by(status, values, f_account_t, amount) diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index 0541f0d..92e2aba 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -82,7 +82,7 @@ extern "C" { if (needs_value.used > 0) { i = needs_value.array[0]; - macro_f_array_lengths_t_increase(status, parameters.parameter[i].values) + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, parameters.parameter[i].values) if (F_status_is_error(status)) { macro_f_array_lengths_t_delete_simple(needs_value); @@ -200,7 +200,7 @@ extern "C" { continue; } - macro_f_array_lengths_t_increase(status, parameters.parameter[i].locations) + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, parameters.parameter[i].locations) if (F_status_is_error(status)) { macro_f_array_lengths_t_delete_simple(needs_value); @@ -208,7 +208,7 @@ extern "C" { return status; } - macro_f_array_lengths_t_increase(status, parameters.parameter[i].locations_sub) + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, parameters.parameter[i].locations_sub) if (F_status_is_error(status)) { macro_f_array_lengths_t_delete_simple(needs_value); @@ -263,7 +263,7 @@ extern "C" { if (strncmp(arguments.argv[location], parameters.parameter[i].symbol_other, argument_length + 1) != 0) continue; - macro_f_array_lengths_t_increase(status, parameters.parameter[i].locations) + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, parameters.parameter[i].locations) if (F_status_is_error(status)) { macro_f_array_lengths_t_delete_simple(needs_value); @@ -271,7 +271,7 @@ extern "C" { return status; } - macro_f_array_lengths_t_increase(status, parameters.parameter[i].locations_sub) + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, parameters.parameter[i].locations_sub) if (F_status_is_error(status)) { macro_f_array_lengths_t_delete_simple(needs_value); @@ -310,7 +310,7 @@ extern "C" { // populate list of remaining parameters.parameter not associated with anything. if (remaining->used == remaining->size) { - macro_f_memory_structure_increment(status, (*remaining), 1, f_memory_default_allocation_step, macro_f_array_lengths_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*remaining), 1, f_memory_default_allocation_small, macro_f_array_lengths_t_resize, F_array_too_large); if (F_status_is_error(status)) { macro_f_array_lengths_t_delete_simple(needs_value); return status; diff --git a/level_0/f_directory/c/directory-common.h b/level_0/f_directory/c/directory-common.h index d6ef5f7..2434643 100644 --- a/level_0/f_directory/c/directory-common.h +++ b/level_0/f_directory/c/directory-common.h @@ -67,7 +67,7 @@ extern "C" { * This is generally used for nftw() recursive operations to reduce the number of open file descriptors during recursion. */ #ifndef _di_f_directory_limitations_ - #define f_directory_default_allocation_step f_memory_default_allocation_step + #define f_directory_default_allocation_step f_memory_default_allocation_small #define f_directory_descriptors_max 255 #define f_directory_name_max NAME_MAX diff --git a/level_0/f_directory/c/directory_type.h b/level_0/f_directory/c/directory_type.h index 91ef33f..d58ab1d 100644 --- a/level_0/f_directory/c/directory_type.h +++ b/level_0/f_directory/c/directory_type.h @@ -74,6 +74,7 @@ extern "C" { * * The allocation macros apply to the path. * + * step: The allocation step. * status: The status code. * path: The dynamically allocated path associated with the status code. */ @@ -95,7 +96,7 @@ extern "C" { #define macro_f_directory_status_t_delete_simple(statuses) macro_f_string_dynamic_t_delete_simple(statuses.path) #define macro_f_directory_status_t_destroy_simple(statuses) macro_f_string_dynamic_t_destroy_simple(statuses.path) - #define macro_f_directory_status_t_increase(status, values) macro_f_string_dynamic_t_increase(status, values) + #define macro_f_directory_status_t_increase(status, step, values) macro_f_string_dynamic_t_increase(status, step, values) #define macro_f_directory_status_t_increase_by(status, values, amount) macro_f_string_dynamic_t_increase_by(status, values, amount) #define macro_f_directory_status_t_decrease_by(status, values, amount) macro_f_string_dynamic_t_decrease_by(status, values, amount) #define macro_f_directory_status_t_decimate_by(status, values, amount) macro_f_string_dynamic_t_decimate_by(status, values, amount) diff --git a/level_0/f_fss/c/fss-common.h b/level_0/f_fss/c/fss-common.h index 1c96e6f..6c2d021 100644 --- a/level_0/f_fss/c/fss-common.h +++ b/level_0/f_fss/c/fss-common.h @@ -144,7 +144,7 @@ extern "C" { * Recommended to be set to at least 4 to be UTF-8 friendlier. */ #ifndef _di_f_fss_default_allocation_step_ - #define f_fss_default_allocation_step f_memory_default_allocation_step + #define f_fss_default_allocation_step f_memory_default_allocation_small #endif // _di_f_fss_default_allocation_step_ /** @@ -190,7 +190,7 @@ extern "C" { #define macro_f_fss_headers_t_delete_simple(headers) macro_f_memory_structure_delete_simple(headers, f_fss_header_t) #define macro_f_fss_headers_t_destroy_simple(headers) macro_f_memory_structure_destroy_simple(headers, f_fss_header_t) - #define macro_f_fss_headers_t_increase(status, headers) macro_f_memory_structure_increase(status, headers, f_fss_header_t) + #define macro_f_fss_headers_t_increase(status, step, headers) macro_f_memory_structure_increase(status, step, headers, f_fss_header_t) #define macro_f_fss_headers_t_increase_by(status, headers, amount) macro_f_memory_structure_increase_by(status, headers, f_fss_header_t, amount) #define macro_f_fss_headers_t_decrease_by(status, headers, amount) macro_f_memory_structure_decrease_by(status, headers, f_fss_header_t, amount) #define macro_f_fss_headers_t_decimate_by(status, headers, amount) macro_f_memory_structure_decimate_by(status, headers, f_fss_header_t, amount) @@ -227,7 +227,7 @@ extern "C" { #define macro_f_fss_objects_t_delete_simple(objects) macro_f_string_ranges_t_delete_simple(objects) #define macro_f_fss_objects_t_destroy_simple(objects) macro_f_string_ranges_t_destroy_simple(objects) - #define macro_f_fss_objects_t_increase(status, objects) macro_f_string_ranges_t_increase(status, objects) + #define macro_f_fss_objects_t_increase(status, step, objects) macro_f_string_ranges_t_increase(status, step, objects) #define macro_f_fss_objects_t_increase_by(status, objects, amount) macro_f_string_ranges_t_increase_by(status, objects, amount) #define macro_f_fss_objects_t_decrease_by(status, objects, amount) macro_f_string_ranges_t_decrease_by(status, objects, amount) #define macro_f_fss_objects_t_decimate_by(status, objects, amount) macro_f_string_ranges_t_decimate_by(status, objects, amount) @@ -255,7 +255,7 @@ extern "C" { #define macro_f_fss_content_t_delete_simple(content) macro_f_string_ranges_t_delete_simple(content) #define macro_f_fss_content_t_destroy_simple(content) macro_f_string_ranges_t_destroy_simple(content) - #define macro_f_fss_content_t_increase(status, content) macro_f_string_ranges_t_increase(status, content) + #define macro_f_fss_content_t_increase(status, step, content) macro_f_string_ranges_t_increase(status, step, content) #define macro_f_fss_content_t_increase_by(status, content, amount) macro_f_string_ranges_t_increase_by(status, content, amount) #define macro_f_fss_content_t_decrease_by(status, content, amount) macro_f_string_ranges_t_decrease_by(status, content, amount) #define macro_f_fss_content_t_decimate_by(status, content, amount) macro_f_string_ranges_t_decimate_by(status, content, amount) @@ -281,7 +281,7 @@ extern "C" { #define macro_f_fss_contents_t_delete_simple(contents) macro_f_string_rangess_t_delete_simple(contents) #define macro_f_fss_contents_t_destroy_simple(contents) macro_f_string_rangess_t_destroy_simple(contents) - #define macro_f_fss_contents_t_increase(status, contents) macro_f_string_rangess_t_increase(status, contents) + #define macro_f_fss_contents_t_increase(status, step, contents) macro_f_string_rangess_t_increase(status, step, contents) #define macro_f_fss_contents_t_increase_by(status, contents, amount) macro_f_string_rangess_t_increase_by(status, contents, amount) #define macro_f_fss_contents_t_decrease_by(status, contents, amount) macro_f_string_rangess_t_decrease_by(status, contents, amount) #define macro_f_fss_contents_t_decimate_by(status, contents, amount) macro_f_string_rangess_t_decimate_by(status, contents, amount) diff --git a/level_0/f_fss/c/fss_comment.h b/level_0/f_fss/c/fss_comment.h index 12205f1..1a9cd39 100644 --- a/level_0/f_fss/c/fss_comment.h +++ b/level_0/f_fss/c/fss_comment.h @@ -43,7 +43,7 @@ extern "C" { #define macro_f_fss_comments_t_delete_simple(comments) macro_f_string_ranges_t_delete_simple(comments) #define macro_f_fss_comments_t_destroy_simple(comments) macro_f_string_ranges_t_destroy_simple(comments) - #define macro_f_fss_comments_t_increase(status, comments) macro_f_string_ranges_t_increase(status, comments) + #define macro_f_fss_comments_t_increase(status, step, comments) macro_f_string_ranges_t_increase(status, step, comments) #define macro_f_fss_comments_t_increase_by(status, comments, amount) macro_f_string_ranges_t_increase_by(status, comments, amount) #define macro_f_fss_comments_t_decrease_by(status, comments, amount) macro_f_string_ranges_t_decrease_by(status, comments, amount) #define macro_f_fss_comments_t_decimate_by(status, comments, amount) macro_f_string_ranges_t_decimate_by(status, comments, amount) @@ -69,7 +69,7 @@ extern "C" { #define macro_f_fss_commentss_t_delete_simple(commentss) macro_f_string_rangess_t_delete_simple(commentss) #define macro_f_fss_commentss_t_destroy_simple(commentss) macro_f_string_rangess_t_destroy_simple(commentss) - #define macro_f_fss_commentss_t_increase(status, commentss) macro_f_string_rangess_t_increase(status, commentss) + #define macro_f_fss_commentss_t_increase(status, step, commentss) macro_f_string_rangess_t_increase(status, step, commentss) #define macro_f_fss_commentss_t_increase_by(status, commentss, amount) macro_f_string_rangess_t_increase_by(status, commentss, amount) #define macro_f_fss_commentss_t_decrease_by(status, commentss, amount) macro_f_string_rangess_t_decrease_by(status, commentss, amount) #define macro_f_fss_commentss_t_decimate_by(status, commentss, amount) macro_f_string_rangess_t_decimate_by(status, commentss, amount) diff --git a/level_0/f_fss/c/fss_delimit.h b/level_0/f_fss/c/fss_delimit.h index 276ee02..f988c44 100644 --- a/level_0/f_fss/c/fss_delimit.h +++ b/level_0/f_fss/c/fss_delimit.h @@ -43,7 +43,7 @@ extern "C" { #define macro_f_fss_delimits_t_delete_simple(delimits) macro_f_array_lengths_t_delete_simple(delimits) #define macro_f_fss_delimits_t_destroy_simple(delimits) macro_f_array_lengths_t_destroy_simple(delimits) - #define macro_f_fss_delimits_t_increase(status, delimits) macro_f_array_lengths_t_increase(status, delimits) + #define macro_f_fss_delimits_t_increase(status, step, delimits) macro_f_array_lengths_t_increase(status, step, delimits) #define macro_f_fss_delimits_t_increase_by(status, delimits, amount) macro_f_array_lengths_t_increase_by(status, delimits, amount) #define macro_f_fss_delimits_t_decrease_by(status, delimits, amount) macro_f_array_lengths_t_decrease_by(status, delimits, amount) #define macro_f_fss_delimits_t_decimate_by(status, delimits, amount) macro_f_array_lengths_t_decimate_by(status, delimits, amount) @@ -69,7 +69,7 @@ extern "C" { #define macro_f_fss_delimitss_t_delete_simple(delimitss) macro_f_array_lengthss_t_delete_simple(delimitss) #define macro_f_fss_delimitss_t_destroy_simple(delimitss) macro_f_array_lengthss_t_destroy_simple(delimitss) - #define macro_f_fss_delimitss_t_increase(status, delimitss) macro_f_array_lengthss_t_increase(status, delimitss) + #define macro_f_fss_delimitss_t_increase(status, step, delimitss) macro_f_array_lengthss_t_increase(status, step, delimitss) #define macro_f_fss_delimitss_t_increase_by(status, delimitss, amount) macro_f_array_lengthss_t_increase_by(status, delimitss, amount) #define macro_f_fss_delimitss_t_decrease_by(status, delimitss, amount) macro_f_array_lengthss_t_decrease_by(status, delimitss, amount) #define macro_f_fss_delimitss_t_decimate_by(status, delimitss, amount) macro_f_array_lengthss_t_decimate_by(status, delimitss, amount) diff --git a/level_0/f_fss/c/fss_named.c b/level_0/f_fss/c/fss_named.c index 4c6134d..85cbf54 100644 --- a/level_0/f_fss/c/fss_named.c +++ b/level_0/f_fss/c/fss_named.c @@ -46,13 +46,14 @@ extern "C" { #endif // _di_f_fss_named_decrease_by_ #ifndef _di_f_fss_named_increase_ - f_status_t f_fss_named_increase(f_fss_named_t *named) { + f_status_t f_fss_named_increase(const uint16_t step, f_fss_named_t *named) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!named) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (named->objects.used + 1 > named->objects.size) { - f_array_length_t size = named->objects.used + f_memory_default_allocation_step; + f_array_length_t size = named->objects.used + step; if (size > f_array_length_t_size) { if (named->objects.used + 1 > f_array_length_t_size) { @@ -139,13 +140,14 @@ extern "C" { #endif // _di_f_fss_nameds_decrease_by_ #ifndef _di_f_fss_nameds_increase_ - f_status_t f_fss_nameds_increase(f_fss_nameds_t *nameds) { + f_status_t f_fss_nameds_increase(const uint16_t step, f_fss_nameds_t *nameds) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!nameds) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (nameds->used + 1 > nameds->size) { - f_array_length_t size = nameds->used + f_memory_default_allocation_step; + f_array_length_t size = nameds->used + step; if (size > f_array_length_t_size) { if (nameds->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_fss/c/fss_named.h b/level_0/f_fss/c/fss_named.h index 41690b6..d098f3c 100644 --- a/level_0/f_fss/c/fss_named.h +++ b/level_0/f_fss/c/fss_named.h @@ -50,7 +50,7 @@ extern "C" { #define macro_f_fss_named_t_delete_simple(named) f_fss_named_resize(0, &named); #define macro_f_fss_named_t_destroy_simple(named) f_fss_named_adjust(0, &named); - #define macro_f_fss_named_t_increase(status, named) status = f_fss_named_increase(&named); + #define macro_f_fss_named_t_increase(status, step, named) status = f_fss_named_increase(step, &named); #define macro_f_fss_named_t_increase_by(status, named, amount) status = f_fss_named_increase_by(amount, &named); #define macro_f_fss_named_t_decrease_by(status, named, amount) status = f_fss_named_decrease_by(amount, &named); #define macro_f_fss_named_t_decimate_by(status, named, amount) status = f_fss_named_decimate_by(amount, &named); @@ -81,7 +81,7 @@ extern "C" { #define macro_f_fss_nameds_t_delete_simple(nameds) f_fss_nameds_resize(0, &nameds); #define macro_f_fss_nameds_t_destroy_simple(nameds) f_fss_nameds_adjust(0, &nameds); - #define macro_f_fss_nameds_t_increase(status, nameds) status = f_fss_nameds_increase(&nameds); + #define macro_f_fss_nameds_t_increase(status, step, nameds) status = f_fss_nameds_increase(step, &nameds); #define macro_f_fss_nameds_t_increase_by(status, nameds, amount) status = f_fss_nameds_increase_by(amount, &nameds); #define macro_f_fss_nameds_t_decrease_by(status, nameds, amount) status = f_fss_nameds_decrease_by(amount, &nameds); #define macro_f_fss_nameds_t_decimate_by(status, nameds, amount) status = f_fss_nameds_decimate_by(amount, &nameds); @@ -155,6 +155,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param named * The named array to resize. * @@ -167,7 +170,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_named_increase_ - extern f_status_t f_fss_named_increase(f_fss_named_t *named); + extern f_status_t f_fss_named_increase(const uint16_t step, f_fss_named_t *named); #endif // _di_f_fss_named_increase_ /** @@ -280,6 +283,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param nameds * The nameds array to resize. * @@ -292,7 +298,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_nameds_increase_ - extern f_status_t f_fss_nameds_increase(f_fss_nameds_t *nameds); + extern f_status_t f_fss_nameds_increase(const uint16_t step, f_fss_nameds_t *nameds); #endif // _di_f_fss_nameds_increase_ /** diff --git a/level_0/f_fss/c/fss_nest.c b/level_0/f_fss/c/fss_nest.c index b0fd227..d6e7c43 100644 --- a/level_0/f_fss/c/fss_nest.c +++ b/level_0/f_fss/c/fss_nest.c @@ -46,13 +46,14 @@ extern "C" { #endif // _di_f_fss_items_decrease_by_ #ifndef _di_f_fss_items_increase_ - f_status_t f_fss_items_increase(f_fss_items_t *items) { + f_status_t f_fss_items_increase(const uint16_t step, f_fss_items_t *items) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!items) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (items->used + 1 > items->size) { - f_array_length_t size = items->used + f_memory_default_allocation_step; + f_array_length_t size = items->used + step; if (size > f_array_length_t_size) { if (items->used + 1 > f_array_length_t_size) { @@ -139,13 +140,14 @@ extern "C" { #endif // _di_f_fss_nest_decrease_by_ #ifndef _di_f_fss_nest_increase_ - f_status_t f_fss_nest_increase(f_fss_nest_t *nest) { + f_status_t f_fss_nest_increase(const uint16_t step, f_fss_nest_t *nest) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!nest) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (nest->used + 1 > nest->size) { - f_array_length_t size = nest->used + f_memory_default_allocation_step; + f_array_length_t size = nest->used + step; if (size > f_array_length_t_size) { if (nest->used + 1 > f_array_length_t_size) { @@ -232,13 +234,14 @@ extern "C" { #endif // _di_f_fss_nests_decrease_by_ #ifndef _di_f_fss_nests_increase_ - f_status_t f_fss_nests_increase(f_fss_nests_t *nests) { + f_status_t f_fss_nests_increase(const uint16_t step, f_fss_nests_t *nests) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!nests) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (nests->used + 1 > nests->size) { - f_array_length_t size = nests->used + f_memory_default_allocation_step; + f_array_length_t size = nests->used + step; if (size > f_array_length_t_size) { if (nests->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_fss/c/fss_nest.h b/level_0/f_fss/c/fss_nest.h index dfde4f4..2bf9969 100644 --- a/level_0/f_fss/c/fss_nest.h +++ b/level_0/f_fss/c/fss_nest.h @@ -52,7 +52,7 @@ extern "C" { #define macro_f_fss_item_t_delete_simple(item) macro_f_fss_content_t_delete_simple(item.content) #define macro_f_fss_item_t_destroy_simple(item) macro_f_fss_content_t_destroy_simple(item.content) - #define macro_f_fss_item_t_increase(status, item) macro_f_fss_content_t_increase(status, item.content) + #define macro_f_fss_item_t_increase(status, step, item) macro_f_fss_content_t_increase(status, step, item.content) #define macro_f_fss_item_t_increase_by(status, item, amount) macro_f_fss_content_t_increase_by(status, item.content, amount) #define macro_f_fss_item_t_decrease_by(status, item, amount) macro_f_fss_content_t_decrease_by(status, item.content, amount) #define macro_f_fss_item_t_decimate_by(status, item, amount) macro_f_fss_content_t_decimate_by(status, item.content, amount) @@ -104,7 +104,7 @@ extern "C" { #define macro_f_fss_items_t_delete_simple(items) f_fss_items_resize(0, &items); #define macro_f_fss_items_t_destroy_simple(items) f_fss_items_adjust(0, &items); - #define macro_f_fss_items_t_increase(status, items) status = f_fss_items_increase(&items); + #define macro_f_fss_items_t_increase(status, step, items) status = f_fss_items_increase(step, &items); #define macro_f_fss_items_t_increase_by(status, items, amount) status = f_fss_items_increase_by(amount, &items); #define macro_f_fss_items_t_decrease_by(status, items, amount) status = f_fss_items_decrease_by(amount, &items); #define macro_f_fss_items_t_decimate_by(status, items, amount) status = f_fss_items_decimate_by(amount, &items); @@ -140,7 +140,7 @@ extern "C" { #define macro_f_fss_nest_t_delete_simple(nest) f_fss_nest_resize(0, &nest); #define macro_f_fss_nest_t_destroy_simple(nest) f_fss_nest_adjust(0, &nest); - #define macro_f_fss_nest_t_increase(status, nest) status = f_fss_nest_increase(&nest); + #define macro_f_fss_nest_t_increase(status, step, nest) status = f_fss_nest_increase(step, &nest); #define macro_f_fss_nest_t_increase_by(status, nest, amount) status = f_fss_nest_increase_by(amount, &nest); #define macro_f_fss_nest_t_decrease_by(status, nest, amount) status = f_fss_nest_decrease_by(amount, &nest); #define macro_f_fss_nest_t_decimate_by(status, nest, amount) status = f_fss_nest_decimate_by(amount, &nest); @@ -171,7 +171,7 @@ extern "C" { #define macro_f_fss_nests_t_delete_simple(nests) f_fss_nests_resize(0, &nests); #define macro_f_fss_nests_t_destroy_simple(nests) f_fss_nests_adjust(0, &nests); - #define macro_f_fss_nests_t_increase(status, nests) status = f_fss_nests_increase(&nests); + #define macro_f_fss_nests_t_increase(status, step, nests) status = f_fss_nests_increase(step, &nests); #define macro_f_fss_nests_t_increase_by(status, nests, amount) status = f_fss_nests_increase_by(amount, &nests); #define macro_f_fss_nests_t_decrease_by(status, nests, amount) status = f_fss_nests_decrease_by(amount, &nests); #define macro_f_fss_nests_t_decimate_by(status, nests, amount) status = f_fss_nests_decimate_by(amount, &nests); @@ -245,6 +245,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param items * The items array to resize. * @@ -257,7 +260,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_items_increase_ - extern f_status_t f_fss_items_increase(f_fss_items_t *items); + extern f_status_t f_fss_items_increase(const uint16_t step, f_fss_items_t *items); #endif // _di_f_fss_items_increase_ /** @@ -370,6 +373,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param nest * The nest array to resize. * @@ -382,7 +388,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_nest_increase_ - extern f_status_t f_fss_nest_increase(f_fss_nest_t *nest); + extern f_status_t f_fss_nest_increase(const uint16_t step, f_fss_nest_t *nest); #endif // _di_f_fss_nest_increase_ /** @@ -495,6 +501,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param nests * The nests array to resize. * @@ -507,7 +516,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_nests_increase_ - extern f_status_t f_fss_nests_increase(f_fss_nests_t *nests); + extern f_status_t f_fss_nests_increase(const uint16_t step, f_fss_nests_t *nests); #endif // _di_f_fss_nests_increase_ /** diff --git a/level_0/f_fss/c/fss_quote.h b/level_0/f_fss/c/fss_quote.h index 229eb9e..17499e7 100644 --- a/level_0/f_fss/c/fss_quote.h +++ b/level_0/f_fss/c/fss_quote.h @@ -53,7 +53,7 @@ extern "C" { #define macro_f_fss_quotes_t_delete_simple(quotes) macro_f_uint8s_t_delete_simple(quotes) #define macro_f_fss_quotes_t_destroy_simple(quotes) macro_f_uint8s_t_destroy_simple(quotes) - #define macro_f_fss_quotes_t_increase(status, quotes) macro_f_uint8s_t_increase(status, quotes) + #define macro_f_fss_quotes_t_increase(status, step, quotes) macro_f_uint8s_t_increase(status, step, quotes) #define macro_f_fss_quotes_t_increase_by(status, quotes, amount) macro_f_uint8s_t_increase_by(status, quotes, amount) #define macro_f_fss_quotes_t_decrease_by(status, quotes, amount) macro_f_uint8s_t_decrease_by(status, quotes, amount) #define macro_f_fss_quotes_t_decimate_by(status, quotes, amount) macro_f_uint8s_t_decimate_by(status, quotes, amount) @@ -79,7 +79,7 @@ extern "C" { #define macro_f_fss_quotess_t_delete_simple(quotess) macro_f_uint8ss_t_delete_simple(quotess) #define macro_f_fss_quotess_t_destroy_simple(quotess) macro_f_uint8ss_t_destroy_simple(quotess) - #define macro_f_fss_quotess_t_increase(status, quotess) macro_f_uint8ss_t_increase(status, quotess) + #define macro_f_fss_quotess_t_increase(status, step, quotess) macro_f_uint8ss_t_increase(status, step, quotess) #define macro_f_fss_quotess_t_increase_by(status, quotess, amount) macro_f_uint8ss_t_increase_by(status, quotess, amount) #define macro_f_fss_quotess_t_decrease_by(status, quotess, amount) macro_f_uint8ss_t_decrease_by(status, quotess, amount) #define macro_f_fss_quotess_t_decimate_by(status, quotess, amount) macro_f_uint8ss_t_decimate_by(status, quotess, amount) diff --git a/level_0/f_fss/c/fss_set.c b/level_0/f_fss/c/fss_set.c index 249fa3a..e4e47a6 100644 --- a/level_0/f_fss/c/fss_set.c +++ b/level_0/f_fss/c/fss_set.c @@ -46,13 +46,14 @@ extern "C" { #endif // _di_f_fss_set_decrease_by_ #ifndef _di_f_fss_set_increase_ - f_status_t f_fss_set_increase(f_fss_set_t *set) { + f_status_t f_fss_set_increase(const uint16_t step, f_fss_set_t *set) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!set) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (set->objects.used + 1 > set->objects.size) { - f_array_length_t size = set->objects.used + f_memory_default_allocation_step; + f_array_length_t size = set->objects.used + step; if (size > f_array_length_t_size) { if (set->objects.used + 1 > f_array_length_t_size) { @@ -139,13 +140,14 @@ extern "C" { #endif // _di_f_fss_set_quote_decrease_by_ #ifndef _di_f_fss_set_quote_increase_ - f_status_t f_fss_set_quote_increase(f_fss_set_quote_t *set_quote) { + f_status_t f_fss_set_quote_increase(const uint16_t step, f_fss_set_quote_t *set_quote) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!set_quote) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (set_quote->objects.used + 1 > set_quote->objects.size) { - f_array_length_t size = set_quote->objects.used + f_memory_default_allocation_step; + f_array_length_t size = set_quote->objects.used + step; if (size > f_array_length_t_size) { if (set_quote->objects.used + 1 > f_array_length_t_size) { @@ -232,13 +234,14 @@ extern "C" { #endif // _di_f_fss_set_quotes_decrease_by_ #ifndef _di_f_fss_set_quotes_increase_ - f_status_t f_fss_set_quotes_increase(f_fss_set_quotes_t *set_quotes) { + f_status_t f_fss_set_quotes_increase(const uint16_t step, f_fss_set_quotes_t *set_quotes) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!set_quotes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (set_quotes->used + 1 > set_quotes->size) { - f_array_length_t size = set_quotes->used + f_memory_default_allocation_step; + f_array_length_t size = set_quotes->used + step; if (size > f_array_length_t_size) { if (set_quotes->used + 1 > f_array_length_t_size) { @@ -325,13 +328,14 @@ extern "C" { #endif // _di_f_fss_sets_decrease_by_ #ifndef _di_f_fss_sets_increase_ - f_status_t f_fss_sets_increase(f_fss_sets_t *sets) { + f_status_t f_fss_sets_increase(const uint16_t step, f_fss_sets_t *sets) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (sets->used + 1 > sets->size) { - f_array_length_t size = sets->used + f_memory_default_allocation_step; + f_array_length_t size = sets->used + step; if (size > f_array_length_t_size) { if (sets->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_fss/c/fss_set.h b/level_0/f_fss/c/fss_set.h index 58c806a..be4782b 100644 --- a/level_0/f_fss/c/fss_set.h +++ b/level_0/f_fss/c/fss_set.h @@ -43,7 +43,7 @@ extern "C" { #define macro_f_fss_set_t_delete_simple(set) f_fss_set_resize(0, &set); #define macro_f_fss_set_t_destroy_simple(set) f_fss_set_adjust(0, &set); - #define macro_f_fss_set_t_increase(status, set) status = f_fss_set_increase(&set); + #define macro_f_fss_set_t_increase(status, step, set) status = f_fss_set_increase(step, &set); #define macro_f_fss_set_t_increase_by(status, set, amount) status = f_fss_set_increase_by(amount, &set); #define macro_f_fss_set_t_decrease_by(status, set, amount) status = f_fss_set_decrease_by(amount, &set); #define macro_f_fss_set_t_decimate_by(status, set, amount) status = f_fss_set_decimate_by(amount, &set); @@ -74,7 +74,7 @@ extern "C" { #define macro_f_fss_sets_t_delete_simple(sets) f_fss_sets_resize(0, &sets); #define macro_f_fss_sets_t_destroy_simple(sets) f_fss_sets_adjust(0, &sets); - #define macro_f_fss_sets_t_increase(status, sets) status = f_fss_sets_increase(&sets); + #define macro_f_fss_sets_t_increase(status, step, sets) status = f_fss_sets_increase(step, &sets); #define macro_f_fss_sets_t_increase_by(status, sets, amount) status = f_fss_sets_increase_by(amount, &sets); #define macro_f_fss_sets_t_decrease_by(status, sets, amount) status = f_fss_sets_decrease_by(amount, &sets); #define macro_f_fss_sets_t_decimate_by(status, sets, amount) status = f_fss_sets_decimate_by(amount, &sets); @@ -114,7 +114,7 @@ extern "C" { #define macro_f_fss_set_quote_t_delete_simple(set_quote) f_fss_set_quote_resize(0, &set_quote); #define macro_f_fss_set_quote_t_destroy_simple(set_quote) f_fss_set_quote_adjust(0, &set_quote); - #define macro_f_fss_set_quote_t_increase(status, set_quote) status = f_fss_set_quote_increase(&set_quote); + #define macro_f_fss_set_quote_t_increase(status, step, set_quote) status = f_fss_set_quote_increase(step, &set_quote); #define macro_f_fss_set_quote_t_increase_by(status, set_quote, amount) status = f_fss_set_quote_increase_by(amount, &set_quote); #define macro_f_fss_set_quote_t_decrease_by(status, set_quote, amount) status = f_fss_set_quote_decrease_by(amount, &set_quote); #define macro_f_fss_set_quote_t_decimate_by(status, set_quote, amount) status = f_fss_set_quote_decimate_by(amount, &set_quote); @@ -145,7 +145,7 @@ extern "C" { #define macro_f_fss_set_quotes_t_delete_simple(set_quotes) f_fss_set_quotes_resize(0, &set_quotes); #define macro_f_fss_set_quotes_t_destroy_simple(set_quotes) f_fss_set_quotes_adjust(0, &set_quotes); - #define macro_f_fss_set_quotes_t_increase(status, set_quotes) status = f_fss_set_quotes_increase(&set_quotes); + #define macro_f_fss_set_quotes_t_increase(status, step, set_quotes) status = f_fss_set_quotes_increase(step, &set_quotes); #define macro_f_fss_set_quotes_t_increase_by(status, set_quotes, amount) status = f_fss_set_quotes_increase_by(amount, &set_quotes); #define macro_f_fss_set_quotes_t_decrease_by(status, set_quotes, amount) status = f_fss_set_quotes_decrease_by(amount, &set_quotes); #define macro_f_fss_set_quotes_t_decimate_by(status, set_quotes, amount) status = f_fss_set_quotes_decimate_by(amount, &set_quotes); @@ -219,6 +219,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param set * The set array to resize. * @@ -231,7 +234,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_set_increase_ - extern f_status_t f_fss_set_increase(f_fss_set_t *set); + extern f_status_t f_fss_set_increase(const uint16_t step, f_fss_set_t *set); #endif // _di_f_fss_set_increase_ /** @@ -344,6 +347,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set_quote max buffer size (f_array_length_t_size). * If already set_quote to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param set_quote * The set_quote array to resize. * @@ -356,7 +362,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_set_quote_increase_ - extern f_status_t f_fss_set_quote_increase(f_fss_set_quote_t *set_quote); + extern f_status_t f_fss_set_quote_increase(const uint16_t step, f_fss_set_quote_t *set_quote); #endif // _di_f_fss_set_quote_increase_ /** @@ -469,6 +475,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param set_quotes * The set_quotes array to resize. * @@ -481,7 +490,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_set_quotes_increase_ - extern f_status_t f_fss_set_quotes_increase(f_fss_set_quotes_t *set_quotes); + extern f_status_t f_fss_set_quotes_increase(const uint16_t step, f_fss_set_quotes_t *set_quotes); #endif // _di_f_fss_set_quotes_increase_ /** @@ -594,6 +603,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param sets * The sets array to resize. * @@ -606,7 +618,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_fss_sets_increase_ - extern f_status_t f_fss_sets_increase(f_fss_sets_t *sets); + extern f_status_t f_fss_sets_increase(const uint16_t step, f_fss_sets_t *sets); #endif // _di_f_fss_sets_increase_ /** diff --git a/level_0/f_iki/c/iki-common.h b/level_0/f_iki/c/iki-common.h index f2e2104..7967740 100644 --- a/level_0/f_iki/c/iki-common.h +++ b/level_0/f_iki/c/iki-common.h @@ -194,14 +194,15 @@ extern "C" { /** * Reallocate delimits array if necessary for appending a new delimit. * + * state: The state. * status: The return status to use. * delimits: The delimit array to conditionally reallocate. */ #ifndef _di_macro_f_iki_allocate_delimits_if_necessary_ - #define macro_f_iki_allocate_delimits_if_necessary(status, delimits) \ + #define macro_f_iki_allocate_delimits_if_necessary(state, status, delimits) \ status = F_none; \ if (delimits.used == delimits.size) { \ - if (delimits.used + f_iki_default_allocation_step > f_array_length_t_size) { \ + if (delimits.used + state.step_small > f_array_length_t_size) { \ if (delimits.used == f_array_length_t_size) { \ status = F_status_set_error(F_string_too_large); \ } \ @@ -210,7 +211,7 @@ extern "C" { } \ } \ else { \ - macro_f_array_lengths_t_resize(status, delimits, delimits.size + f_iki_default_allocation_step); \ + macro_f_array_lengths_t_resize(status, delimits, delimits.size + state.step_small); \ } \ } #endif // _di_macro_f_iki_allocate_delimits_if_necessary_ @@ -218,14 +219,15 @@ extern "C" { /** * Reallocate delimits array if necessary for appending a new ranges. * + * state: The state. * status: The return status to use. * ranges: The delimit array to conditionally reallocate. */ #ifndef _di_macro_f_iki_allocate_ranges_if_necessary_ - #define macro_f_iki_allocate_ranges_if_necessary(status, ranges) \ + #define macro_f_iki_allocate_ranges_if_necessary(state, status, ranges) \ status = F_none; \ if (ranges.used == ranges.size) { \ - if (ranges.used + f_iki_default_allocation_step > f_array_length_t_size) { \ + if (ranges.used + state.step_small > f_array_length_t_size) { \ if (ranges.used == f_array_length_t_size) { \ status = F_status_set_error(F_string_too_large); \ } \ @@ -234,7 +236,7 @@ extern "C" { } \ } \ else { \ - macro_f_string_ranges_t_resize(status, ranges, ranges.size + f_iki_default_allocation_step); \ + macro_f_string_ranges_t_resize(status, ranges, ranges.size + state.step_small); \ } \ } #endif // _di_macro_f_iki_allocate_ranges_if_necessary_ diff --git a/level_0/f_iki/c/iki.c b/level_0/f_iki/c/iki.c index 139d57b..fdae925 100644 --- a/level_0/f_iki/c/iki.c +++ b/level_0/f_iki/c/iki.c @@ -56,7 +56,7 @@ extern "C" { #endif // _di_f_iki_object_partial_is_ #ifndef _di_f_iki_read_ - f_status_t f_iki_read(f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content) { + f_status_t f_iki_read(f_state_t state, f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content) { #ifndef _di_level_0_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); if (!range) return F_status_set_error(F_parameter); @@ -118,6 +118,15 @@ extern "C" { // find the start and end of the vocabulary name. while (range->start <= range->stop && range->start < buffer->used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer->string[range->start] == f_iki_syntax_placeholder) { ++range->start; continue; @@ -127,11 +136,6 @@ extern "C" { if (range->start == found_vocabulary.start) { status = f_utf_buffer_increment(*buffer, range, 1); - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - return status; - } - break; } @@ -142,25 +146,19 @@ extern "C" { status = f_utf_buffer_increment(*buffer, range, 1); } while (F_status_is_fine(status) && buffer->string[range->start] == f_iki_syntax_placeholder); - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - return status; - } + if (F_status_is_error(status)) break; // found a valid vocabulary name. if (buffer->string[range->start] == f_iki_syntax_quote_single || buffer->string[range->start] == f_iki_syntax_quote_double) { quote = buffer->string[range->start]; ++range->start; + break; } // this is not a valid vocabulary name so seek until a non-word, non-dash, or non-plus character. macro_f_iki_seek_word_dash_plus(status, buffer, range, width_max, F_false); - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - - return status; - } + if (F_status_is_error(status)) break; break; } @@ -199,12 +197,7 @@ extern "C" { } status = f_utf_buffer_increment(*buffer, range, 1); - - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - - return status; - } + if (F_status_is_error(status)) break; } // while break; @@ -213,21 +206,14 @@ extern "C" { macro_f_iki_determine_width_max(buffer, range, width_max); status = f_utf_is_word_dash_plus(buffer->string + range->start, width_max, F_false); - - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - - return status; - } + if (F_status_is_error(status)) break; // current word-dash-plus block is not a valid variable name, try again. if (status == F_false) { macro_f_iki_seek_word_dash_plus(status, buffer, range, width_max, F_true); if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - - return status; + break; } else if (range->start > range->stop) { macro_f_array_lengths_t_delete_simple(delimits); @@ -245,13 +231,14 @@ extern "C" { } status = f_utf_buffer_increment(*buffer, range, 1); + if (F_status_is_error(status)) break; + } // while - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); + if (F_status_is_error(status)) { + macro_f_array_lengths_t_delete_simple(delimits); - return status; - } - } // while + return status; + } // process potentially valid content. if (quote) { @@ -259,6 +246,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer->used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer->string[range->start] == f_iki_syntax_placeholder) { ++range->start; @@ -269,13 +265,8 @@ extern "C" { // this is a valid vocabulary name and content, but if it is delimited, save the delimit and ignore. if (vocabulary_delimited) { - macro_f_iki_allocate_delimits_if_necessary(status, delimits); - - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - - return status; - } + macro_f_iki_allocate_delimits_if_necessary(state, status, delimits); + if (F_status_is_error(status)) break; delimits.array[delimits.used] = vocabulary_slash_first; ++delimits.used; @@ -288,20 +279,17 @@ extern "C" { break; } else { - macro_f_iki_allocate_ranges_if_necessary(status, (*variable)); + macro_f_iki_allocate_ranges_if_necessary(state, status, (*variable)); if (F_status_is_fine(status)) { - macro_f_iki_allocate_ranges_if_necessary(status, (*vocabulary)); + macro_f_iki_allocate_ranges_if_necessary(state, status, (*vocabulary)); } if (F_status_is_fine(status)) { - macro_f_iki_allocate_ranges_if_necessary(status, (*content)); + macro_f_iki_allocate_ranges_if_necessary(state, status, (*content)); } - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - return status; - } + if (F_status_is_error(status)) break; variable->array[variable->used].start = found_vocabulary.start; variable->array[variable->used].stop = range->start; @@ -364,11 +352,7 @@ extern "C" { macro_f_array_lengths_t_resize(status, delimits, delimits.used + content_slash_delimits); } - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - - return status; - } + if (F_status_is_error(status)) break; } content_range.start = content_slash_first; @@ -384,25 +368,18 @@ extern "C" { } status = f_utf_buffer_increment(*buffer, (&content_range), 1); - - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - return status; - } + if (F_status_is_error(status)) break; } // while + if (F_status_is_error(status)) break; + // valid content's ending quote is not delimited, save and return. if (content_slash_total % 2 == 0) { // this is a valid vocabulary name and content, but if it is delimited, save the delimit and ignore. if (vocabulary_delimited) { - macro_f_iki_allocate_delimits_if_necessary(status, delimits); - - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - - return status; - } + macro_f_iki_allocate_delimits_if_necessary(state, status, delimits); + if (F_status_is_error(status)) break; delimits.array[delimits.used] = vocabulary_slash_first; ++delimits.used; @@ -418,21 +395,17 @@ extern "C" { found_vocabulary.start = range->start; } else { - macro_f_iki_allocate_ranges_if_necessary(status, (*variable)); + macro_f_iki_allocate_ranges_if_necessary(state, status, (*variable)); if (F_status_is_fine(status)) { - macro_f_iki_allocate_ranges_if_necessary(status, (*vocabulary)); + macro_f_iki_allocate_ranges_if_necessary(state, status, (*vocabulary)); } if (F_status_is_fine(status)) { - macro_f_iki_allocate_ranges_if_necessary(status, (*content)); + macro_f_iki_allocate_ranges_if_necessary(state, status, (*content)); } - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - - return status; - } + if (F_status_is_error(status)) break; variable->array[variable->used].start = found_vocabulary.start; variable->array[variable->used].stop = range->start; @@ -476,20 +449,14 @@ extern "C" { ++content_slash_total; status = f_utf_buffer_increment(*buffer, range, 1); - - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - return status; - } + if (F_status_is_error(status)) break; } // while + + if (F_status_is_error(status)) break; } status = f_utf_buffer_increment(*buffer, range, 1); - - if (F_status_is_error(status)) { - macro_f_array_lengths_t_delete_simple(delimits); - return status; - } + if (F_status_is_error(status)) break; } // while } else { @@ -497,12 +464,19 @@ extern "C" { find_next = F_true; } + if (F_status_is_error(status)) { + macro_f_array_lengths_t_delete_simple(delimits); + + return status; + } + if (find_next) { macro_f_iki_seek_word_dash_plus(status, buffer, range, width_max, F_true); found_vocabulary.start = range->start; find_next = F_false; } + } while (range->start <= range->stop && range->start < buffer->used); for (f_array_length_t i = 0; i < delimits.used; ++i) { diff --git a/level_0/f_iki/c/iki.h b/level_0/f_iki/c/iki.h index 272181a..9aa5301 100644 --- a/level_0/f_iki/c/iki.h +++ b/level_0/f_iki/c/iki.h @@ -120,6 +120,15 @@ extern "C" { * This will update the buffer at the given range with any placeholders to escaped data. * Calling this more than once on the same buffer range could result in multiple escaping. * + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param buffer * The string to process. * @param range @@ -142,12 +151,13 @@ extern "C" { * F_data_not_eos on success and EOS was reached, but there were no IKI vocabulary names found. * F_data_not_stop on success and stop point was reached, but there were no IKI vocabulary names found. * + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if a string length is too large to store in the buffer. */ #ifndef _di_f_iki_read_ - extern f_status_t f_iki_read(f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content); + extern f_status_t f_iki_read(f_state_t state, f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content); #endif // _di_f_iki_read_ #ifdef __cplusplus diff --git a/level_0/f_limit/c/limit-common.h b/level_0/f_limit/c/limit-common.h index 11bc435..62fe41c 100644 --- a/level_0/f_limit/c/limit-common.h +++ b/level_0/f_limit/c/limit-common.h @@ -57,7 +57,7 @@ extern "C" { #define macro_f_limit_values_t_delete_simple(values) macro_f_memory_structure_delete_simple(values, f_limit_value_t) #define macro_f_limit_values_t_destroy_simple(values) macro_f_memory_structure_destroy_simple(values, f_limit_value_t) - #define macro_f_limit_values_t_increase(status, values) macro_f_memory_structure_increase(status, values, f_limit_value_t) + #define macro_f_limit_values_t_increase(status, step, values) macro_f_memory_structure_increase(status, step, values, f_limit_value_t) #define macro_f_limit_values_t_increase_by(status, values, amount) macro_f_memory_structure_increase_by(status, values, f_limit_value_t, amount) #define macro_f_limit_values_t_decrease_by(status, values, amount) macro_f_memory_structure_decrease_by(status, values, f_limit_value_t, amount) #define macro_f_limit_values_t_decimate_by(status, values, amount) macro_f_memory_structure_decimate_by(status, values, f_limit_value_t, amount) @@ -107,7 +107,7 @@ extern "C" { #define macro_f_limit_sets_t_delete_simple(sets) macro_f_memory_structure_delete_simple(sets, f_limit_set_t) #define macro_f_limit_sets_t_destroy_simple(sets) macro_f_memory_structure_destroy_simple(sets, f_limit_set_t) - #define macro_f_limit_sets_t_increase(status, sets) macro_f_memory_structure_increase(status, sets, f_limit_set_t) + #define macro_f_limit_sets_t_increase(status, step, sets) macro_f_memory_structure_increase(status, step, sets, f_limit_set_t) #define macro_f_limit_sets_t_increase_by(status, sets, amount) macro_f_memory_structure_increase_by(status, sets, f_limit_set_t, amount) #define macro_f_limit_sets_t_decrease_by(status, sets, amount) macro_f_memory_structure_decrease_by(status, sets, f_limit_set_t, amount) #define macro_f_limit_sets_t_decimate_by(status, sets, amount) macro_f_memory_structure_decimate_by(status, sets, f_limit_set_t, amount) diff --git a/level_0/f_memory/c/memory-common.h b/level_0/f_memory/c/memory-common.h index 760efc8..52641dd 100644 --- a/level_0/f_memory/c/memory-common.h +++ b/level_0/f_memory/c/memory-common.h @@ -38,7 +38,8 @@ extern "C" { * Other projects may provide their own values. */ #ifndef _di_f_memory_default_allocation_step_ - #define f_memory_default_allocation_step 4 + #define f_memory_default_allocation_large 64 + #define f_memory_default_allocation_small 4 #endif // _di_f_memory_default_allocation_step_ /** @@ -130,22 +131,23 @@ extern "C" { /** * Increase a generic memory structure. * - * status: the status to return. - * structure: the structure to operate on. - * type: the structure type. + * status: The status to return. + * step: The allocation step. + * structure: The structure to operate on. + * type: The structure type. */ #ifndef _di_macro_f_memory_structure_increase_ - #define macro_f_memory_structure_increase(status, structure, type) \ - status = f_memory_structure_increase(sizeof(type), (void **) &structure.array, &structure.used, &structure.size); + #define macro_f_memory_structure_increase(status, step, structure, type) \ + status = f_memory_structure_increase(step, sizeof(type), (void **) &structure.array, &structure.used, &structure.size); #endif // _di_macro_f_memory_structure_increase_ /** * Increase a generic memory structure by some amount. * - * status: the status to return. - * structure: the structure to operate on. - * type: the structure type. - * amount: the amount to increase the size of the array by. + * status: The status to return. + * structure: The structure to operate on. + * type: The structure type. + * amount: The amount to increase the size of the array by. */ #ifndef _di_macro_f_memory_structure_increase_by_ #define macro_f_memory_structure_increase_by(status, structure, type, amount) \ @@ -155,10 +157,10 @@ extern "C" { /** * Decrease a generic memory structure by some amount. * - * status: the status to return. - * structure: the structure to operate on. - * type: the structure type. - * amount: the amount to decrease the size of the array by. + * status: The status to return. + * structure: The structure to operate on. + * type: The structure type. + * amount: The amount to decrease the size of the array by. */ #ifndef _di_macro_f_memory_structure_decrease_by_ #define macro_f_memory_structure_decrease_by(status, structure, type, amount) \ @@ -168,10 +170,10 @@ extern "C" { /** * Decimate a generic memory structure by some amount. * - * status: the status to return. - * structure: the structure to operate on. - * type: the structure type. - * amount: the amount to decimate the size of the array by. + * status: The status to return. + * structure: The structure to operate on. + * type: The structure type. + * amount: The amount to decimate the size of the array by. */ #ifndef _di_macro_f_memory_structure_decimate_by_ #define macro_f_memory_structure_decimate_by(status, structure, type, amount) \ @@ -195,12 +197,12 @@ extern "C" { /** * Resize a generic memory structures. * - * status: the status to return. - * structures: the structures to operate on. - * type_stucture: the structure type. - * type_stuctures: the structures type. - * length: the new size of the array. - * type_length: the data type of the length variable type. + * status: The status to return. + * structures: The structures to operate on. + * type_stucture: The structure type. + * type_stuctures: The structures type. + * length: The new size of the array. + * type_length: The data type of the length variable type. */ #ifndef _di_macro_f_memory_structures_resize_ #define macro_f_memory_structures_resize(status, structures, type_structure, type_structures, length, type_length) \ @@ -215,12 +217,12 @@ extern "C" { /** * Adjust a generic memory structures. * - * status: the status to return. - * structures: the structures to operate on. - * type_stucture: the structure type. - * type_stuctures: the structures type. - * length: the new size of the array. - * type_length: the data type of the length variable type. + * status: The status to return. + * structures: The structures to operate on. + * type_stucture: The structure type. + * type_stuctures: The structures type. + * length: The new size of the array. + * type_length: The data type of the length variable type. */ #ifndef _di_macro_f_memory_structures_adjust_ #define macro_f_memory_structures_adjust(status, structures, type_structure, type_structures, length, type_length) \ @@ -235,10 +237,10 @@ extern "C" { /** * Delete a generic memory structures. * - * status: the status to return. - * structures: the structures to operate on. - * type_stucture: the structure type. - * type_stuctures: the structures type. + * status: The status to return. + * structures: The structures to operate on. + * type_stucture: The structure type. + * type_stuctures: The structures type. */ #ifndef _di_macro_f_memory_structures_delete_ #define macro_f_memory_structures_delete(status, structures, type_structure, type_structures) \ @@ -254,10 +256,10 @@ extern "C" { /** * Destroy a generic memory structures. * - * status: the status to return. - * structures: the structures to operate on. - * type_stucture: the structure type. - * type_stuctures: the structures type. + * status: The status to return. + * structures: The structures to operate on. + * type_stucture: The structure type. + * type_stuctures: The structures type. */ #ifndef _di_macro_f_memory_structures_destroy_ #define macro_f_memory_structures_destroy(status, structures, type_structure, type_structures) \ @@ -273,9 +275,9 @@ extern "C" { /** * Delete a generic memory structures. * - * structures: the structures to operate on. - * type_stucture: the structure type. - * type_stuctures: the structures type. + * structures: The structures to operate on. + * type_stucture: The structure type. + * type_stuctures: The structures type. */ #ifndef _di_macro_f_memory_structures_delete_simple_ #define macro_f_memory_structures_delete_simple(structures, type_structure, type_structures) \ @@ -290,9 +292,9 @@ extern "C" { /** * Destroy a generic memory structures. * - * structures: the structures to operate on. - * type_stucture: the structure type. - * type_stuctures: the structures type. + * structures: The structures to operate on. + * type_stucture: The structure type. + * type_stuctures: The structures type. */ #ifndef _di_macro_f_memory_structures_destroy_simple_ #define macro_f_memory_structures_destroy_simple(structures, type_structure, type_structures) \ @@ -309,10 +311,10 @@ extern "C" { * * This only increases if the structure.used + 1 is greater than structure.size. * - * status: the status to return. - * structures: the structures to operate on. - * type_stuctures: the structures type. - * type_length: the data type of the length variable type. + * status: The status to return. + * structures: The structures to operate on. + * type_stuctures: The structures type. + * type_length: The data type of the length variable type. */ #ifndef _di_macro_f_memory_structures_increase_ #define macro_f_memory_structures_increase(status, structures, type_structures, type_length) \ @@ -324,11 +326,11 @@ extern "C" { * * This only increases if the structure.used + amount is greater than structure.size. * - * status: the status to return. - * structures: the structures to operate on. - * type_stuctures: the structures type. - * type_length: the data type of the length variable type. - * amount: the amount to increase by. + * status: The status to return. + * structures: The structures to operate on. + * type_stuctures: The structures type. + * type_length: The data type of the length variable type. + * amount: The amount to increase by. */ #ifndef _di_macro_f_memory_structures_increase_by_ #define macro_f_memory_structures_increase_by(status, structures, type_structures, type_length, amount) \ @@ -338,12 +340,12 @@ extern "C" { /** * Decrease a generic memory structures by the given amount. * - * status: the status to return. - * structures: the structures to operate on. - * type_stucture: the structure type. - * type_stuctures: the structures type. - * type_length: the data type of the length variable type. - * amount: the amount to decrease by. + * status: The status to return. + * structures: The structures to operate on. + * type_stucture: The structure type. + * type_stuctures: The structures type. + * type_length: The data type of the length variable type. + * amount: The amount to decrease by. */ #ifndef _di_macro_f_memory_structures_decrease_by_ #define macro_f_memory_structures_decrease_by(status, structures, type_structure, type_structures, type_length, amount) \ @@ -356,12 +358,12 @@ extern "C" { /** * Decimate a generic memory structures by the given amount. * - * status: the status to return. - * structures: the structures to operate on. - * type_stucture: the structure type. - * type_stuctures: the structures type. - * type_length: the data type of the length variable type. - * amount: the amount to decimate by. + * status: The status to return. + * structures: The structures to operate on. + * type_stucture: The structure type. + * type_stuctures: The structures type. + * type_length: The data type of the length variable type. + * amount: The amount to decimate by. */ #ifndef _di_macro_f_memory_structures_decimate_by_ #define macro_f_memory_structures_decimate_by(status, structures, type_structure, type_structures, type_length, amount) \ @@ -380,12 +382,12 @@ extern "C" { * * Be sure to check size for error after calling this. * - * status: the status to return. - * structures: the structures to operate on. - * step: the step to increase by, must be less than or equal to step_default. - * step_default: the default step to increase by if memory allows. - * macro_resize: the resize structure macro to call that excepts the exact arguments: (status, structure, length). - * error_too_large: the error status to return when f_array_length_t_size would be exceeded. + * status: The status to return. + * structures: The structures to operate on. + * step: The step to increase by, must be less than or equal to step_default. + * step_default: The default step to increase by if memory allows. + * macro_resize: The resize structure macro to call that excepts the exact arguments: (status, structure, length). + * error_too_large: The error status to return when f_array_length_t_size would be exceeded. */ #ifndef _di_macro_f_memory_structure_increment_ #define macro_f_memory_structure_increment(status, structure, step, step_default, macro_resize, error_too_large) \ diff --git a/level_0/f_memory/c/memory_structure.c b/level_0/f_memory/c/memory_structure.c index 6b65968..7b8d938 100644 --- a/level_0/f_memory/c/memory_structure.c +++ b/level_0/f_memory/c/memory_structure.c @@ -53,8 +53,9 @@ extern "C" { #endif // _di_f_memory_structure_decrease_by_ #ifndef _di_f_memory_structure_increase_ - f_status_t f_memory_structure_increase(const size_t type_size, void **structure, f_array_length_t *used, f_array_length_t *size) { + f_status_t f_memory_structure_increase(const uint16_t step, const size_t type_size, void **structure, f_array_length_t *used, f_array_length_t *size) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!type_size) return F_status_set_error(F_parameter); if (!structure) return F_status_set_error(F_parameter); if (!used) return F_status_set_error(F_parameter); @@ -62,7 +63,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (*used + 1 > *size) { - f_array_length_t length_new = *used + f_memory_default_allocation_step; + f_array_length_t length_new = *used + step; if (length_new > f_array_length_t_size) { if (*used + 1 > f_array_length_t_size) { diff --git a/level_0/f_memory/c/memory_structure.h b/level_0/f_memory/c/memory_structure.h index 518c772..5051c0e 100644 --- a/level_0/f_memory/c/memory_structure.h +++ b/level_0/f_memory/c/memory_structure.h @@ -117,6 +117,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param type_size * The size of the structure type (such as: sizeof(structure_size)). * Must be greater than 0. @@ -139,7 +142,7 @@ extern "C" { * @see memset() */ #ifndef _di_f_memory_structure_increase_ - extern f_status_t f_memory_structure_increase(const size_t type_size, void **structure, f_array_length_t *used, f_array_length_t *size); + extern f_status_t f_memory_structure_increase(const uint16_t step, const size_t type_size, void **structure, f_array_length_t *used, f_array_length_t *size); #endif // _di_f_memory_structure_increase_ /** diff --git a/level_0/f_serialize/c/serialize.c b/level_0/f_serialize/c/serialize.c index e19a543..ece3e06 100644 --- a/level_0/f_serialize/c/serialize.c +++ b/level_0/f_serialize/c/serialize.c @@ -51,7 +51,7 @@ extern "C" { width = macro_f_utf_byte_width(serialize.string[i]); if (serialize.string[i] == f_serialize_simple_splitter_s[0] || i + 1 >= serialize.used) { - macro_f_memory_structure_increment(status, (*strings), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*strings), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (start == i) { @@ -120,7 +120,7 @@ extern "C" { width = macro_f_utf_byte_width(serialize.string[i]); if (serialize.string[i] == f_serialize_simple_splitter_s[0] || i + 1 >= serialize.used) { - macro_f_memory_structure_increment(status, (*locations), 1, f_memory_default_allocation_step, macro_f_string_ranges_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*locations), 1, f_memory_default_allocation_small, macro_f_string_ranges_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (start == i) { diff --git a/level_0/f_signal/c/signal-common.h b/level_0/f_signal/c/signal-common.h index 8b914b3..37b6ed1 100644 --- a/level_0/f_signal/c/signal-common.h +++ b/level_0/f_signal/c/signal-common.h @@ -33,6 +33,11 @@ extern "C" { #define f_signal_t_initialize {0, 0, { 0 } } #define macro_f_signal_t_initialize(flags, id, set) { flags, id, set } + + #define macro_f_signal_t_clear(signal) \ + signal.flags = 0; \ + signal.id = 0; \ + signal.set[0] = 0; #endif // _di_f_signal_t_ /** diff --git a/level_0/f_status/c/status.h b/level_0/f_status/c/status.h index f5b33a3..5829c8f 100644 --- a/level_0/f_status/c/status.h +++ b/level_0/f_status/c/status.h @@ -177,12 +177,16 @@ extern "C" { F_descriptor_not, F_device, F_device_not, + F_disable, + F_disable_not, F_done, F_done_not, F_dummy, F_dummy_not, F_empty, F_empty_not, + F_enable, + F_enable_not, F_encoding, F_encoding_not, F_eoa, diff --git a/level_0/f_status/c/status_array.h b/level_0/f_status/c/status_array.h deleted file mode 100644 index 8a69a74..0000000 --- a/level_0/f_status/c/status_array.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Status - * API Version: 0.5 - * Licenses: lgplv2.1 - * - * Provides status arrays that require memory operations. - * - * Because memory requires status.h, this is moved to a separate file to reduce potential circular dependency issues. - */ -#ifndef _F_status_array_h -#define _F_status_array_h - -// fll-0 includes -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * An array of status codes. - * - * array: An array of status codes. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_statuss_t_ - typedef struct { - f_status_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_statuss_t; - - #define f_statuss_t_initialize { 0, 0, 0 } - - #define macro_f_statuss_t_clear(statuss) macro_f_memory_structure_clear(statuss) - - #define macro_f_statuss_t_resize(status, statuss, length) macro_f_memory_structure_resize(status, statuss, f_status_t, length) - #define macro_f_statuss_t_adjust(status, statuss, length) macro_f_memory_structure_adjust(status, statuss, f_status_t, length) - - #define macro_f_statuss_t_delete_simple(statuss) macro_f_memory_structure_delete_simple(statuss, f_status_t) - #define macro_f_statuss_t_destroy_simple(statuss) macro_f_memory_structure_destroy_simple(statuss, f_status_t) - - #define macro_f_statuss_t_increase(status, statuss) macro_f_memory_structure_increase(status, statuss, f_status_t) - #define macro_f_statuss_t_increase_by(status, statuss, amount) macro_f_memory_structure_increase_by(status, statuss, f_status_t, amount) - #define macro_f_statuss_t_decrease_by(status, statuss, amount) macro_f_memory_structure_decrease_by(status, statuss, f_status_t, amount) - #define macro_f_statuss_t_decimate_by(status, statuss, amount) macro_f_memory_structure_decimate_by(status, statuss, f_status_t, amount) -#endif // _di_f_statuss_t_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _F_status_array_h diff --git a/level_0/f_status/data/build/settings b/level_0/f_status/data/build/settings index b6e1008..ab42477 100644 --- a/level_0/f_status/data/build/settings +++ b/level_0/f_status/data/build/settings @@ -22,7 +22,7 @@ build_libraries -lc build_libraries-individual build_sources_library build_sources_program -build_sources_headers status.h status_array.h +build_sources_headers status.h build_sources_script build_sources_setting build_script yes diff --git a/level_0/f_string/c/string_dynamic.c b/level_0/f_string/c/string_dynamic.c index c1116e3..21f26f9 100644 --- a/level_0/f_string/c/string_dynamic.c +++ b/level_0/f_string/c/string_dynamic.c @@ -164,13 +164,14 @@ extern "C" { #endif // _di_f_string_dynamic_decrease_by_ #ifndef _di_f_string_dynamic_increase_ - f_status_t f_string_dynamic_increase(f_string_dynamic_t *dynamic) { + f_status_t f_string_dynamic_increase(const uint16_t step, f_string_dynamic_t *dynamic) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (dynamic->used + 1 > dynamic->size) { - f_array_length_t size = dynamic->used + f_memory_default_allocation_step; + f_array_length_t size = dynamic->used + step; if (size > f_array_length_t_size) { if (dynamic->used + 1 > f_array_length_t_size) { @@ -948,13 +949,14 @@ extern "C" { #endif // _di_f_string_dynamics_decrease_by_ #ifndef _di_f_string_dynamics_increase_ - f_status_t f_string_dynamics_increase(f_string_dynamics_t *dynamics) { + f_status_t f_string_dynamics_increase(const uint16_t step, f_string_dynamics_t *dynamics) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (dynamics->used + 1 > dynamics->size) { - f_array_length_t size = dynamics->used + f_memory_default_allocation_step; + f_array_length_t size = dynamics->used + step; if (size > f_array_length_t_size) { if (dynamics->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_string/c/string_dynamic.h b/level_0/f_string/c/string_dynamic.h index 1133965..5f4a6f7 100644 --- a/level_0/f_string/c/string_dynamic.h +++ b/level_0/f_string/c/string_dynamic.h @@ -73,7 +73,7 @@ extern "C" { #define macro_f_string_dynamic_t_delete_simple(dynamic) f_string_dynamic_resize(0, &dynamic); #define macro_f_string_dynamic_t_destroy_simple(dynamic) f_string_dynamic_adjust(0, &dynamic); - #define macro_f_string_dynamic_t_increase(status, dynamic) status = f_string_dynamic_increase(&dynamic); + #define macro_f_string_dynamic_t_increase(status, step, dynamic) status = f_string_dynamic_increase(step, &dynamic); #define macro_f_string_dynamic_t_increase_by(status, dynamic, amount) status = f_string_dynamic_increase_by(amount, &dynamic); #define macro_f_string_dynamic_t_decrease_by(status, dynamic, amount) status = f_string_dynamic_decrease_by(amount, &dynamic); #define macro_f_string_dynamic_t_decimate_by(status, dynamic, amount) status = f_string_dynamic_decimate_by(amount, &dynamic); @@ -122,7 +122,7 @@ extern "C" { #define macro_f_string_dynamics_t_delete_simple(dynamics) f_string_dynamics_resize(0, &dynamics); #define macro_f_string_dynamics_t_destroy_simple(dynamics) f_string_dynamics_adjust(0, &dynamics); - #define macro_f_string_dynamics_t_increase(status, dynamics) status = f_string_dynamics_increase(&dynamics); + #define macro_f_string_dynamics_t_increase(status, step, dynamics) status = f_string_dynamics_increase(step, &dynamics); #define macro_f_string_dynamics_t_increase_by(status, dynamics, amount) status = f_string_dynamics_increase_by(amount, &dynamics); #define macro_f_string_dynamics_t_decrease_by(status, dynamics, amount) status = f_string_dynamics_decrease_by(amount, &dynamics); #define macro_f_string_dynamics_t_decimate_by(status, dynamics, amount) status = f_string_dynamics_decimate_by(amount, &dynamics); @@ -269,8 +269,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * - * @param amount - * A positive number representing how much to increase the size by. + * @param step + * The allocation step to use. + * Must be greater than 0. * @param dynamic * The string to resize. * @@ -284,7 +285,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_dynamic_increase_ - extern f_status_t f_string_dynamic_increase(f_string_dynamic_t *dynamic); + extern f_status_t f_string_dynamic_increase(const uint16_t step, f_string_dynamic_t *dynamic); #endif // _di_f_string_dynamic_increase_ /** @@ -1097,6 +1098,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param dynamics * The array to resize. * @@ -1110,7 +1114,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_dynamics_increase_ - extern f_status_t f_string_dynamics_increase(f_string_dynamics_t *dynamics); + extern f_status_t f_string_dynamics_increase(const uint16_t step, f_string_dynamics_t *dynamics); #endif // _di_f_string_dynamics_increase_ /** diff --git a/level_0/f_string/c/string_map.c b/level_0/f_string/c/string_map.c index 341e5b3..8559044 100644 --- a/level_0/f_string/c/string_map.c +++ b/level_0/f_string/c/string_map.c @@ -79,13 +79,14 @@ extern "C" { #endif // _di_f_string_map_multis_decrease_by_ #ifndef _di_f_string_map_multis_increase_ - f_status_t f_string_map_multis_increase(f_string_map_multis_t *map_multis) { + f_status_t f_string_map_multis_increase(const uint16_t step, f_string_map_multis_t *map_multis) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!map_multis) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (map_multis->used + 1 > map_multis->size) { - f_array_length_t size = map_multis->used + f_memory_default_allocation_step; + f_array_length_t size = map_multis->used + step; if (size > f_array_length_t_size) { if (map_multis->used + 1 > f_array_length_t_size) { @@ -207,13 +208,14 @@ extern "C" { #endif // _di_f_string_maps_decrease_by_ #ifndef _di_f_string_maps_increase_ - f_status_t f_string_maps_increase(f_string_maps_t *maps) { + f_status_t f_string_maps_increase(const uint16_t step, f_string_maps_t *maps) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (maps->used + 1 > maps->size) { - f_array_length_t size = maps->used + f_memory_default_allocation_step; + f_array_length_t size = maps->used + step; if (size > f_array_length_t_size) { if (maps->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_string/c/string_map.h b/level_0/f_string/c/string_map.h index 3846b1f..457ccd7 100644 --- a/level_0/f_string/c/string_map.h +++ b/level_0/f_string/c/string_map.h @@ -68,7 +68,7 @@ extern "C" { #define macro_f_string_maps_t_delete_simple(maps) f_string_maps_resize(0, &maps); #define macro_f_string_maps_t_destroy_simple(maps) f_string_maps_adjust(0, &maps); - #define macro_f_string_maps_t_increase(status, maps) status = f_string_maps_increase(maps); + #define macro_f_string_maps_t_increase(status, step, maps) status = f_string_maps_increase(step, maps); #define macro_f_string_maps_t_increase_by(status, maps, amount) status = f_string_maps_increase_by(amount, maps); #define macro_f_string_maps_t_decrease_by(status, maps, amount) status = f_string_maps_decrease_by(amount, maps); #define macro_f_string_maps_t_decimate_by(status, maps, amount) status = f_string_maps_decimate_by(amount, maps); @@ -126,7 +126,7 @@ extern "C" { #define macro_f_string_map_multis_t_delete_simple(map_multis) f_string_map_multis_resize(0, &map_multis); #define macro_f_string_map_multis_t_destroy_simple(map_multis) f_string_map_multis_adjust(0, &map_multis); - #define macro_f_string_map_multis_t_increase(status, map_multis) status = f_string_map_multis_increase(&map_multis); + #define macro_f_string_map_multis_t_increase(status, step, map_multis) status = f_string_map_multis_increase(step, &map_multis); #define macro_f_string_map_multis_t_increase_by(status, map_multis, amount) status = f_string_map_multis_increase_by(amount, &map_multis); #define macro_f_string_map_multis_t_decrease_by(status, map_multis, amount) status = f_string_map_multis_decrease_by(amount, &map_multis); #define macro_f_string_map_multis_t_decimate_by(status, map_multis, amount) status = f_string_map_multis_decimate_by(amount, &map_multis); @@ -224,6 +224,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param map_multis * The map_multis array to resize. * @@ -237,7 +240,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_map_multis_increase_ - extern f_status_t f_string_map_multis_increase(f_string_map_multis_t *map_multis); + extern f_status_t f_string_map_multis_increase(const uint16_t step, f_string_map_multis_t *map_multis); #endif // _di_f_string_map_multis_increase_ /** @@ -376,6 +379,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param maps * The string maps array to resize. * @@ -389,7 +395,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_maps_increase_ - extern f_status_t f_string_maps_increase(f_string_maps_t *maps); + extern f_status_t f_string_maps_increase(const uint16_t step, f_string_maps_t *maps); #endif // _di_f_string_maps_increase_ /** diff --git a/level_0/f_string/c/string_quantity.c b/level_0/f_string/c/string_quantity.c index 75cb24f..c656b56 100644 --- a/level_0/f_string/c/string_quantity.c +++ b/level_0/f_string/c/string_quantity.c @@ -73,13 +73,14 @@ extern "C" { #endif // _di_f_string_quantitys_decrease_by_ #ifndef _di_f_string_quantitys_increase_ - f_status_t f_string_quantitys_increase(f_string_quantitys_t *quantitys) { + f_status_t f_string_quantitys_increase(const uint16_t step, f_string_quantitys_t *quantitys) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (quantitys->used + 1 > quantitys->size) { - f_array_length_t size = quantitys->used + f_memory_default_allocation_step; + f_array_length_t size = quantitys->used + step; if (size > f_array_length_t_size) { if (quantitys->used + 1 > f_array_length_t_size) { @@ -166,13 +167,14 @@ extern "C" { #endif // _di_f_string_quantityss_decrease_by_ #ifndef _di_f_string_quantityss_increase_ - f_status_t f_string_quantityss_increase(f_string_quantityss_t *quantityss) { + f_status_t f_string_quantityss_increase(const uint16_t step, f_string_quantityss_t *quantityss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (quantityss->used + 1 > quantityss->size) { - f_array_length_t size = quantityss->used + f_memory_default_allocation_step; + f_array_length_t size = quantityss->used + step; if (size > f_array_length_t_size) { if (quantityss->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_string/c/string_quantity.h b/level_0/f_string/c/string_quantity.h index b875ba7..fe59c8c 100644 --- a/level_0/f_string/c/string_quantity.h +++ b/level_0/f_string/c/string_quantity.h @@ -62,7 +62,7 @@ extern "C" { #define macro_f_string_quantitys_t_delete_simple(quantitys) f_string_quantitys_resize(0, &quantitys); #define macro_f_string_quantitys_t_destroy_simple(quantitys) f_string_quantitys_adjust(0, &quantitys); - #define macro_f_string_quantitys_t_increase(status, quantitys) status = f_string_quantitys_increase(&quantitys); + #define macro_f_string_quantitys_t_increase(status, step, quantitys) status = f_string_quantitys_increase(step, &quantitys); #define macro_f_string_quantitys_t_increase_by(status, quantitys, amount) status = f_string_quantitys_increase_by(amount, &quantitys); #define macro_f_string_quantitys_t_decrease_by(status, quantitys, amount) status = f_string_quantitys_decrease_by(amount, &quantitys); #define macro_f_string_quantitys_t_decimate_by(status, quantitys, amount) status = f_string_quantitys_decimate_by(amount, &quantitys); @@ -93,7 +93,7 @@ extern "C" { #define macro_f_string_quantityss_t_delete_simple(quantityss) f_string_quantityss_resize(0, &quantityss); #define macro_f_string_quantityss_t_destroy_simple(quantityss) f_string_quantityss_adjust(0, &quantityss); - #define macro_f_string_quantityss_t_increase(status, quantityss) status = f_string_quantityss_increase(&quantityss); + #define macro_f_string_quantityss_t_increase(status, step, quantityss) status = f_string_quantityss_increase(step, &quantityss); #define macro_f_string_quantityss_t_increase_by(status, quantityss, amount) status = f_string_quantityss_increase_by(amount, &quantityss); #define macro_f_string_quantityss_t_decrease_by(status, quantityss, amount) status = f_string_quantityss_decrease_by(amount, &quantityss); #define macro_f_string_quantityss_t_decimate_by(status, quantityss, amount) status = f_string_quantityss_decimate_by(amount, &quantityss); @@ -190,6 +190,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param quantitys * The string quantitys array to resize. * @@ -202,7 +205,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_quantitys_increase_ - extern f_status_t f_string_quantitys_increase(f_string_quantitys_t *quantitys); + extern f_status_t f_string_quantitys_increase(const uint16_t step, f_string_quantitys_t *quantitys); #endif // _di_f_string_quantitys_increase_ /** @@ -319,6 +322,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param quantityss * The string quantityss array to resize. * @@ -332,7 +338,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_quantityss_increase_ - extern f_status_t f_string_quantityss_increase(f_string_quantityss_t *quantityss); + extern f_status_t f_string_quantityss_increase(const uint16_t step, f_string_quantityss_t *quantityss); #endif // _di_f_string_quantityss_increase_ /** diff --git a/level_0/f_string/c/string_range.c b/level_0/f_string/c/string_range.c index ebca973..da17fe2 100644 --- a/level_0/f_string/c/string_range.c +++ b/level_0/f_string/c/string_range.c @@ -73,13 +73,14 @@ extern "C" { #endif // _di_f_string_ranges_decrease_by_ #ifndef _di_f_string_ranges_increase_ - f_status_t f_string_ranges_increase(f_string_ranges_t *ranges) { + f_status_t f_string_ranges_increase(const uint16_t step, f_string_ranges_t *ranges) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (ranges->used + 1 > ranges->size) { - f_array_length_t size = ranges->used + f_memory_default_allocation_step; + f_array_length_t size = ranges->used + step; if (size > f_array_length_t_size) { if (ranges->used + 1 > f_array_length_t_size) { @@ -166,13 +167,14 @@ extern "C" { #endif // _di_f_string_rangess_decrease_by_ #ifndef _di_f_string_rangess_increase_ - f_status_t f_string_rangess_increase(f_string_rangess_t *rangess) { + f_status_t f_string_rangess_increase(const uint16_t step, f_string_rangess_t *rangess) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (rangess->used + 1 > rangess->size) { - f_array_length_t size = rangess->used + f_memory_default_allocation_step; + f_array_length_t size = rangess->used + step; if (size > f_array_length_t_size) { if (rangess->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_string/c/string_range.h b/level_0/f_string/c/string_range.h index 2fd5379..643c6e9 100644 --- a/level_0/f_string/c/string_range.h +++ b/level_0/f_string/c/string_range.h @@ -68,7 +68,7 @@ extern "C" { #define macro_f_string_ranges_t_delete_simple(ranges) f_string_ranges_resize(0, &ranges); #define macro_f_string_ranges_t_destroy_simple(ranges) f_string_ranges_adjust(0, &ranges); - #define macro_f_string_ranges_t_increase(status, ranges) status = f_string_ranges_increase(&ranges); + #define macro_f_string_ranges_t_increase(status, step, ranges) status = f_string_ranges_increase(step, &ranges); #define macro_f_string_ranges_t_increase_by(status, ranges, amount) status = f_string_ranges_increase_by(amount, &ranges); #define macro_f_string_ranges_t_decrease_by(status, ranges, amount) status = f_string_ranges_decrease_by(amount, &ranges); #define macro_f_string_ranges_t_decimate_by(status, ranges, amount) status = f_string_ranges_decimate_by(amount, &ranges); @@ -99,7 +99,7 @@ extern "C" { #define macro_f_string_rangess_t_delete_simple(rangess) f_string_rangess_resize(0, &rangess); #define macro_f_string_rangess_t_destroy_simple(rangess) f_string_rangess_adjust(0, &rangess); - #define macro_f_string_rangess_t_increase(status, rangess) status = f_string_rangess_increase(&rangess); + #define macro_f_string_rangess_t_increase(status, step, rangess) status = f_string_rangess_increase(step, &rangess); #define macro_f_string_rangess_t_increase_by(status, rangess, amount) status = f_string_rangess_increase_by(amount, &rangess); #define macro_f_string_rangess_t_decrease_by(status, rangess, amount) status = f_string_rangess_decrease_by(amount, &rangess); #define macro_f_string_rangess_t_decimate_by(status, rangess, amount) status = f_string_rangess_decimate_by(amount, &rangess); @@ -195,6 +195,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param ranges * The string ranges array to resize. * F_data_not on success, but there is no reason to increase size (used + 1 <= size). @@ -208,7 +211,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_ranges_increase_ - extern f_status_t f_string_ranges_increase(f_string_ranges_t *ranges); + extern f_status_t f_string_ranges_increase(const uint16_t step, f_string_ranges_t *ranges); #endif // _di_f_string_ranges_increase_ /** @@ -326,6 +329,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param rangess * The string rangess array to resize. * @@ -339,7 +345,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_rangess_increase_ - extern f_status_t f_string_rangess_increase(f_string_rangess_t *rangess); + extern f_status_t f_string_rangess_increase(const uint16_t step, f_string_rangess_t *rangess); #endif // _di_f_string_rangess_increase_ /** diff --git a/level_0/f_string/c/string_triple.c b/level_0/f_string/c/string_triple.c index 1780d17..e107227 100644 --- a/level_0/f_string/c/string_triple.c +++ b/level_0/f_string/c/string_triple.c @@ -89,13 +89,14 @@ extern "C" { #endif // _di_f_string_triples_decrease_by_ #ifndef _di_f_string_triples_increase_ - f_status_t f_string_triples_increase(f_string_triples_t *triples) { + f_status_t f_string_triples_increase(const uint16_t step, f_string_triples_t *triples) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (triples->used + 1 > triples->size) { - f_array_length_t size = triples->used + f_memory_default_allocation_step; + f_array_length_t size = triples->used + f_memory_default_allocation_small; if (size > f_array_length_t_size) { if (triples->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_string/c/string_triple.h b/level_0/f_string/c/string_triple.h index b0a9ff5..b644872 100644 --- a/level_0/f_string/c/string_triple.h +++ b/level_0/f_string/c/string_triple.h @@ -79,7 +79,7 @@ extern "C" { #define macro_f_string_triples_t_delete_simple(triples) f_string_triples_resize(0, &triples); #define macro_f_string_triples_t_destroy_simple(triples) f_string_triples_adjust(0, &triples); - #define macro_f_string_triples_t_increase(status, triples) status = f_string_triples_increase(triples); + #define macro_f_string_triples_t_increase(status, step, triples) status = f_string_triples_increase(step, triples); #define macro_f_string_triples_t_increase_by(status, triples, amount) status = f_string_triples_increase_by(amount, triples); #define macro_f_string_triples_t_decrease_by(status, triples, amount) status = f_string_triples_decrease_by(amount, triples); #define macro_f_string_triples_t_decimate_by(status, triples, amount) status = f_string_triples_decimate_by(amount, triples); @@ -176,6 +176,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param triples * The string triples array to resize. * @@ -189,7 +192,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_triples_increase_ - extern f_status_t f_string_triples_increase(f_string_triples_t *triples); + extern f_status_t f_string_triples_increase(const uint16_t step, f_string_triples_t *triples); #endif // _di_f_string_triples_increase_ /** diff --git a/level_0/f_thread/c/thread-common.h b/level_0/f_thread/c/thread-common.h index b632455..445e7d3 100644 --- a/level_0/f_thread/c/thread-common.h +++ b/level_0/f_thread/c/thread-common.h @@ -55,7 +55,7 @@ extern "C" { #define macro_f_thread_attributes_t_delete_simple(attributes) f_thread_attributes_resize(0, &attributes); #define macro_f_thread_attributes_t_destroy_simple(attributes) f_thread_attributes_adjust(0, &attributes); - #define macro_f_thread_attributes_t_increase(status, attributes) status = f_thread_attributes_increase(attributes); + #define macro_f_thread_attributes_t_increase(status, step, attributes) status = f_thread_attributes_increase(step, attributes); #define macro_f_thread_attributes_t_increase_by(status, attributes, amount) status = f_thread_attributes_increase_by(amount, attributes); #define macro_f_thread_attributes_t_decrease_by(status, attributes, amount) status = f_thread_attributes_decrease_by(amount, attributes); #define macro_f_thread_attributes_t_decimate_by(status, attributes, amount) status = f_thread_attributes_decimate_by(amount, attributes); @@ -99,7 +99,7 @@ extern "C" { #define macro_f_thread_barriers_t_delete_simple(barriers) f_thread_barriers_resize(0, &barriers); #define macro_f_thread_barriers_t_destroy_simple(barriers) f_thread_barriers_adjust(0, &barriers); - #define macro_f_thread_barriers_t_increase(status, barriers) status = f_thread_barriers_increase(barriers); + #define macro_f_thread_barriers_t_increase(status, step, barriers) status = f_thread_barriers_increase(step, barriers); #define macro_f_thread_barriers_t_increase_by(status, barriers, amount) status = f_thread_barriers_increase_by(amount, barriers); #define macro_f_thread_barriers_t_decrease_by(status, barriers, amount) status = f_thread_barriers_decrease_by(amount, barriers); #define macro_f_thread_barriers_t_decimate_by(status, barriers, amount) status = f_thread_barriers_decimate_by(amount, barriers); @@ -144,7 +144,7 @@ extern "C" { #define macro_f_thread_barrier_attributes_t_delete_simple(barrier_attributes) f_thread_barrier_attributes_resize(0, &barrier_attributes); #define macro_f_thread_barrier_attributes_t_destroy_simple(barrier_attributes) f_thread_barrier_attributes_adjust(0, &barrier_attributes); - #define macro_f_thread_barrier_attributes_t_increase(status, barrier_attributes) status = f_thread_barrier_attributes_increase(barrier_attributes); + #define macro_f_thread_barrier_attributes_t_increase(status, step, barrier_attributes) status = f_thread_barrier_attributes_increase(step, barrier_attributes); #define macro_f_thread_barrier_attributes_t_increase_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_increase_by(amount, barrier_attributes); #define macro_f_thread_barrier_attributes_t_decrease_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_decrease_by(amount, barrier_attributes); #define macro_f_thread_barrier_attributes_t_decimate_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_decimate_by(amount, barrier_attributes); @@ -189,7 +189,7 @@ extern "C" { #define macro_f_thread_conditions_t_delete_simple(conditions) f_thread_conditions_resize(0, &conditions); #define macro_f_thread_conditions_t_destroy_simple(conditions) f_thread_conditions_adjust(0, &conditions); - #define macro_f_thread_conditions_t_increase(status, conditions) status = f_thread_conditions_increase(conditions); + #define macro_f_thread_conditions_t_increase(status, step, conditions) status = f_thread_conditions_increase(step, conditions); #define macro_f_thread_conditions_t_increase_by(status, conditions, amount) status = f_thread_conditions_increase_by(amount, conditions); #define macro_f_thread_conditions_t_decrease_by(status, conditions, amount) status = f_thread_conditions_decrease_by(amount, conditions); #define macro_f_thread_conditions_t_decimate_by(status, conditions, amount) status = f_thread_conditions_decimate_by(amount, conditions); @@ -234,7 +234,7 @@ extern "C" { #define macro_f_thread_condition_attributes_t_delete_simple(attributes) f_thread_condition_attributes_resize(0, &condition_attributes); #define macro_f_thread_condition_attributes_t_destroy_simple(attributes) f_thread_condition_attributes_adjust(0, &condition_attributes); - #define macro_f_thread_condition_attributes_t_increase(status, attributes) status = f_thread_condition_attributes_increase(attributes); + #define macro_f_thread_condition_attributes_t_increase(status, step, attributes) status = f_thread_condition_attributes_increase(step, attributes); #define macro_f_thread_condition_attributes_t_increase_by(status, attributes, amount) status = f_thread_condition_attributes_increase_by(amount, attributes); #define macro_f_thread_condition_attributes_t_decrease_by(status, attributes, amount) status = f_thread_condition_attributes_decrease_by(amount, attributes); #define macro_f_thread_condition_attributes_t_decimate_by(status, attributes, amount) status = f_thread_condition_attributes_decimate_by(amount, attributes); @@ -274,7 +274,7 @@ extern "C" { #define macro_f_thread_ids_t_delete_simple(ids) macro_f_memory_structure_delete_simple(ids, f_thread_id_t) #define macro_f_thread_ids_t_destroy_simple(ids) macro_f_memory_structure_destroy_simple(ids, f_thread_id_t) - #define macro_f_thread_ids_t_increase(status, ids) macro_f_memory_structure_increase(status, ids, f_thread_id_t) + #define macro_f_thread_ids_t_increase(status, step, ids) macro_f_memory_structure_increase(status, step, ids, f_thread_id_t) #define macro_f_thread_ids_t_increase_by(status, ids, amount) macro_f_memory_structure_increase_by(status, ids, f_thread_id_t, amount) #define macro_f_thread_ids_t_decrease_by(status, ids, amount) macro_f_memory_structure_decrease_by(status, ids, f_thread_id_t, amount) #define macro_f_thread_ids_t_decimate_by(status, ids, amount) macro_f_memory_structure_decimate_by(status, ids, f_thread_id_t, amount) @@ -318,7 +318,7 @@ extern "C" { #define macro_f_thread_keys_t_delete_simple(keys) f_thread_keys_resize(0, &keys); #define macro_f_thread_keys_t_destroy_simple(keys) f_thread_keys_adjust(0, &keys); - #define macro_f_thread_keys_t_increase(status, keys) status = f_thread_keys_increase(keys); + #define macro_f_thread_keys_t_increase(status, step, keys) status = f_thread_keys_increase(step, keys); #define macro_f_thread_keys_t_increase_by(status, keys, amount) status = f_thread_keys_increase_by(amount, keys); #define macro_f_thread_keys_t_decrease_by(status, keys, amount) status = f_thread_keys_decrease_by(amount, keys); #define macro_f_thread_keys_t_decimate_by(status, keys, amount) status = f_thread_keys_decimate_by(amount, keys); @@ -361,7 +361,7 @@ extern "C" { #define macro_f_thread_locks_t_delete_simple(locks) macro_f_memory_structure_delete_simple(locks, f_thread_lock_t) #define macro_f_thread_locks_t_destroy_simple(locks) macro_f_memory_structure_destroy_simple(locks, f_thread_lock_t) - #define macro_f_thread_locks_t_increase(status, locks) macro_f_memory_structure_increase(status, locks, f_thread_lock_t) + #define macro_f_thread_locks_t_increase(status, step, locks) macro_f_memory_structure_increase(status, step, locks, f_thread_lock_t) #define macro_f_thread_locks_t_increase_by(status, locks, amount) macro_f_memory_structure_increase_by(status, locks, f_thread_lock_t, amount) #define macro_f_thread_locks_t_decrease_by(status, locks, amount) macro_f_memory_structure_decrease_by(status, locks, f_thread_lock_t, amount) #define macro_f_thread_locks_t_decimate_by(status, locks, amount) macro_f_memory_structure_decimate_by(status, locks, f_thread_lock_t, amount) @@ -406,7 +406,7 @@ extern "C" { #define macro_f_thread_lock_attributes_t_delete_simple(attributes) f_thread_lock_attributes_resize(0, &attributes); #define macro_f_thread_lock_attributes_t_destroy_simple(attributes) f_thread_lock_attributes_adjust(0, &attributes); - #define macro_f_thread_lock_attributes_t_increase(status, attributes) status = f_thread_lock_attributes_increase(attributes); + #define macro_f_thread_lock_attributes_t_increase(status, step, attributes) status = f_thread_lock_attributes_increase(step, attributes); #define macro_f_thread_lock_attributes_t_increase_by(status, attributes, amount) status = f_thread_lock_attributes_increase_by(amount, attributes); #define macro_f_thread_lock_attributes_t_decrease_by(status, attributes, amount) status = f_thread_lock_attributes_decrease_by(amount, attributes); #define macro_f_thread_lock_attributes_t_decimate_by(status, attributes, amount) status = f_thread_lock_attributes_decimate_by(amount, attributes); @@ -453,7 +453,7 @@ extern "C" { #define macro_f_thread_mutexs_t_delete_simple(mutexs) f_thread_mutexs_resize(0, &mutexs); #define macro_f_thread_mutexs_t_destroy_simple(mutexs) f_thread_mutexs_adjust(0, &mutexs); - #define macro_f_thread_mutexs_t_increase(status, mutexs) status = f_thread_mutexs_increase(mutexs); + #define macro_f_thread_mutexs_t_increase(status, step, mutexs) status = f_thread_mutexs_increase(step, mutexs); #define macro_f_thread_mutexs_t_increase_by(status, mutexs, amount) status = f_thread_mutexs_increase_by(amount, mutexs); #define macro_f_thread_mutexs_t_decrease_by(status, mutexs, amount) status = f_thread_mutexs_decrease_by(amount, mutexs); #define macro_f_thread_mutexs_t_decimate_by(status, mutexs, amount) status = f_thread_mutexs_decimate_by(amount, mutexs); @@ -498,7 +498,7 @@ extern "C" { #define macro_f_thread_mutex_attributes_t_delete_simple(attributes) f_thread_mutex_attributes_resize(0, &attributes); #define macro_f_thread_mutex_attributes_t_destroy_simple(attributes) f_thread_mutex_attributes_adjust(0, &attributes); - #define macro_f_thread_mutex_attributes_t_increase(status, attributes) status = f_thread_mutex_attributes_increase(attributes); + #define macro_f_thread_mutex_attributes_t_increase(status, step, attributes) status = f_thread_mutex_attributes_increase(step, attributes); #define macro_f_thread_mutex_attributes_t_increase_by(status, attributes, amount) status = f_thread_mutex_attributes_increase_by(amount, attributes); #define macro_f_thread_mutex_attributes_t_decrease_by(status, attributes, amount) status = f_thread_mutex_attributes_decrease_by(amount, attributes); #define macro_f_thread_mutex_attributes_t_decimate_by(status, attributes, amount) status = f_thread_mutex_attributes_decimate_by(amount, attributes); @@ -538,7 +538,7 @@ extern "C" { #define macro_f_thread_onces_t_delete_simple(onces) macro_f_memory_structure_delete_simple(onces, f_thread_once_t) #define macro_f_thread_onces_t_destroy_simple(onces) macro_f_memory_structure_destroy_simple(onces, f_thread_once_t) - #define macro_f_thread_onces_t_increase(status, onces) macro_f_memory_structure_increase(status, onces, f_thread_once_t) + #define macro_f_thread_onces_t_increase(status, step, onces) macro_f_memory_structure_increase(status, step, onces, f_thread_once_t) #define macro_f_thread_onces_t_increase_by(status, onces, amount) macro_f_memory_structure_increase_by(status, onces, f_thread_once_t, amount) #define macro_f_thread_onces_t_decrease_by(status, onces, amount) macro_f_memory_structure_decrease_by(status, onces, f_thread_once_t, amount) #define macro_f_thread_onces_t_decimate_by(status, onces, amount) macro_f_memory_structure_decimate_by(status, onces, f_thread_once_t, amount) @@ -584,7 +584,7 @@ extern "C" { #define macro_f_thread_semaphores_t_delete_simple(semaphores) f_thread_semaphores_resize(0, &semaphores); #define macro_f_thread_semaphores_t_destroy_simple(semaphores) f_thread_semaphores_adjust(0, &semaphores); - #define macro_f_thread_semaphores_t_increase(status, semaphores) status = f_thread_semaphores_increase(semaphores); + #define macro_f_thread_semaphores_t_increase(status, step, semaphores) status = f_thread_semaphores_increase(step, semaphores); #define macro_f_thread_semaphores_t_increase_by(status, semaphores, amount) status = f_thread_semaphores_increase_by(amount, semaphores); #define macro_f_thread_semaphores_t_decrease_by(status, semaphores, amount) status = f_thread_semaphores_decrease_by(amount, semaphores); #define macro_f_thread_semaphores_t_decimate_by(status, semaphores, amount) status = f_thread_semaphores_decimate_by(amount, semaphores); @@ -638,7 +638,7 @@ extern "C" { #define macro_f_thread_sets_t_delete_simple(sets) f_thread_sets_resize(0, &sets); #define macro_f_thread_sets_t_destroy_simple(sets) f_thread_sets_adjust(0, &sets); - #define macro_f_thread_sets_t_increase(status, sets) status = f_thread_sets_increase(sets); + #define macro_f_thread_sets_t_increase(status, step, sets) status = f_thread_sets_increase(step, sets); #define macro_f_thread_sets_t_increase_by(status, sets, amount) status = f_thread_sets_increase_by(amount, sets); #define macro_f_thread_sets_t_decrease_by(status, sets, amount) status = f_thread_sets_decrease_by(amount, sets); #define macro_f_thread_sets_t_decimate_by(status, sets, amount) status = f_thread_sets_decimate_by(amount, sets); @@ -682,7 +682,7 @@ extern "C" { #define macro_f_thread_spins_t_delete_simple(spins) f_thread_spins_resize(0, &spins); #define macro_f_thread_spins_t_destroy_simple(spins) f_thread_spins_adjust(0, &spins); - #define macro_f_thread_spins_t_increase(status, spins) status = f_thread_spins_increase(spins); + #define macro_f_thread_spins_t_increase(status, step, spins) status = f_thread_spins_increase(step, spins); #define macro_f_thread_spins_t_increase_by(status, spins, amount) status = f_thread_spins_increase_by(amount, spins); #define macro_f_thread_spins_t_decrease_by(status, spins, amount) status = f_thread_spins_decrease_by(amount, spins); #define macro_f_thread_spins_t_decimate_by(status, spins, amount) status = f_thread_spins_decimate_by(amount, spins); diff --git a/level_0/f_thread/c/thread.c b/level_0/f_thread/c/thread.c index c12e634..02d415c 100644 --- a/level_0/f_thread/c/thread.c +++ b/level_0/f_thread/c/thread.c @@ -536,13 +536,14 @@ extern "C" { #endif // _di_f_thread_attributes_decrease_by_ #ifndef _di_f_thread_attributes_increase_ - f_status_t f_thread_attributes_increase(f_thread_attributes_t *attributes) { + f_status_t f_thread_attributes_increase(const uint16_t step, f_thread_attributes_t *attributes) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (attributes->used + 1 > attributes->size) { - f_array_length_t size = attributes->used + f_memory_default_allocation_step; + f_array_length_t size = attributes->used + step; if (size > f_array_length_t_size) { if (attributes->used + 1 > f_array_length_t_size) { @@ -687,13 +688,14 @@ extern "C" { #endif // _di_f_thread_barrier_attributes_decrease_by_ #ifndef _di_f_thread_barrier_attributes_increase_ - f_status_t f_thread_barrier_attributes_increase(f_thread_barrier_attributes_t *attributes) { + f_status_t f_thread_barrier_attributes_increase(const uint16_t step, f_thread_barrier_attributes_t *attributes) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (attributes->used + 1 > attributes->size) { - f_array_length_t size = attributes->used + f_memory_default_allocation_step; + f_array_length_t size = attributes->used + step; if (size > f_array_length_t_size) { if (attributes->used + 1 > f_array_length_t_size) { @@ -822,13 +824,14 @@ extern "C" { #endif // _di_f_thread_barriers_decrease_by_ #ifndef _di_f_thread_barriers_increase_ - f_status_t f_thread_barriers_increase(f_thread_barriers_t *barriers) { + f_status_t f_thread_barriers_increase(const uint16_t step, f_thread_barriers_t *barriers) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!barriers) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (barriers->used + 1 > barriers->size) { - f_array_length_t size = barriers->used + f_memory_default_allocation_step; + f_array_length_t size = barriers->used + step; if (size > f_array_length_t_size) { if (barriers->used + 1 > f_array_length_t_size) { @@ -1069,13 +1072,14 @@ extern "C" { #endif // _di_f_thread_condition_attributes_decrease_by_ #ifndef _di_f_thread_condition_attributes_increase_ - f_status_t f_thread_condition_attributes_increase(f_thread_condition_attributes_t *attributes) { + f_status_t f_thread_condition_attributes_increase(const uint16_t step, f_thread_condition_attributes_t *attributes) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (attributes->used + 1 > attributes->size) { - f_array_length_t size = attributes->used + f_memory_default_allocation_step; + f_array_length_t size = attributes->used + step; if (size > f_array_length_t_size) { if (attributes->used + 1 > f_array_length_t_size) { @@ -1274,13 +1278,14 @@ extern "C" { #endif // _di_f_thread_conditions_decrease_by_ #ifndef _di_f_thread_conditions_increase_ - f_status_t f_thread_conditions_increase(f_thread_conditions_t *conditions) { + f_status_t f_thread_conditions_increase(const uint16_t step, f_thread_conditions_t *conditions) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!conditions) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (conditions->used + 1 > conditions->size) { - f_array_length_t size = conditions->used + f_memory_default_allocation_step; + f_array_length_t size = conditions->used + step; if (size > f_array_length_t_size) { if (conditions->used + 1 > f_array_length_t_size) { @@ -1533,13 +1538,14 @@ extern "C" { #endif // _di_f_thread_keys_decrease_by_ #ifndef _di_f_thread_keys_increase_ - f_status_t f_thread_keys_increase(f_thread_keys_t *keys) { + f_status_t f_thread_keys_increase(const uint16_t step, f_thread_keys_t *keys) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!keys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (keys->used + 1 > keys->size) { - f_array_length_t size = keys->used + f_memory_default_allocation_step; + f_array_length_t size = keys->used + step; if (size > f_array_length_t_size) { if (keys->used + 1 > f_array_length_t_size) { @@ -1692,13 +1698,14 @@ extern "C" { #endif // _di_f_thread_lock_attributes_decrease_by_ #ifndef _di_f_thread_lock_attributes_increase_ - f_status_t f_thread_lock_attributes_increase(f_thread_lock_attributes_t *attributes) { + f_status_t f_thread_lock_attributes_increase(const uint16_t step, f_thread_lock_attributes_t *attributes) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (attributes->used + 1 > attributes->size) { - f_array_length_t size = attributes->used + f_memory_default_allocation_step; + f_array_length_t size = attributes->used + step; if (size > f_array_length_t_size) { if (attributes->used + 1 > f_array_length_t_size) { @@ -1938,13 +1945,14 @@ extern "C" { #endif // _di_f_thread_locks_decrease_by_ #ifndef _di_f_thread_locks_increase_ - f_status_t f_thread_locks_increase(f_thread_locks_t *locks) { + f_status_t f_thread_locks_increase(const uint16_t step, f_thread_locks_t *locks) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!locks) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (locks->used + 1 > locks->size) { - f_array_length_t size = locks->used + f_memory_default_allocation_step; + f_array_length_t size = locks->used + step; if (size > f_array_length_t_size) { if (locks->used + 1 > f_array_length_t_size) { @@ -2209,13 +2217,14 @@ extern "C" { #endif // _di_f_thread_mutex_attributes_decrease_by_ #ifndef _di_f_thread_mutex_attributes_increase_ - f_status_t f_thread_mutex_attributes_increase(f_thread_mutex_attributes_t *attributes) { + f_status_t f_thread_mutex_attributes_increase(const uint16_t step, f_thread_mutex_attributes_t *attributes) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!attributes) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (attributes->used + 1 > attributes->size) { - f_array_length_t size = attributes->used + f_memory_default_allocation_step; + f_array_length_t size = attributes->used + step; if (size > f_array_length_t_size) { if (attributes->used + 1 > f_array_length_t_size) { @@ -2639,13 +2648,14 @@ extern "C" { #endif // _di_f_thread_mutexs_decrease_by_ #ifndef _di_f_thread_mutexs_increase_ - f_status_t f_thread_mutexs_increase(f_thread_mutexs_t *mutexs) { + f_status_t f_thread_mutexs_increase(const uint16_t step, f_thread_mutexs_t *mutexs) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!mutexs) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (mutexs->used + 1 > mutexs->size) { - f_array_length_t size = mutexs->used + f_memory_default_allocation_step; + f_array_length_t size = mutexs->used + step; if (size > f_array_length_t_size) { if (mutexs->used + 1 > f_array_length_t_size) { @@ -2807,13 +2817,14 @@ extern "C" { #endif // _di_f_thread_semaphores_decrease_by_ #ifndef _di_f_thread_semaphores_increase_ - f_status_t f_thread_semaphores_increase(f_thread_semaphores_t *semaphores) { + f_status_t f_thread_semaphores_increase(const uint16_t step, f_thread_semaphores_t *semaphores) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!semaphores) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (semaphores->used + 1 > semaphores->size) { - f_array_length_t size = semaphores->used + f_memory_default_allocation_step; + f_array_length_t size = semaphores->used + step; if (size > f_array_length_t_size) { if (semaphores->used + 1 > f_array_length_t_size) { @@ -2900,13 +2911,14 @@ extern "C" { #endif // _di_f_thread_sets_decrease_by_ #ifndef _di_f_thread_sets_increase_ - f_status_t f_thread_sets_increase(f_thread_sets_t *sets) { + f_status_t f_thread_sets_increase(const uint16_t step, f_thread_sets_t *sets) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!sets) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (sets->used + 1 > sets->size) { - f_array_length_t size = sets->used + f_memory_default_allocation_step; + f_array_length_t size = sets->used + step; if (size > f_array_length_t_size) { if (sets->used + 1 > f_array_length_t_size) { @@ -3148,13 +3160,14 @@ extern "C" { #endif // _di_f_thread_spins_decrease_by_ #ifndef _di_f_thread_spins_increase_ - f_status_t f_thread_spins_increase(f_thread_spins_t *spins) { + f_status_t f_thread_spins_increase(const uint16_t step, f_thread_spins_t *spins) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!spins) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (spins->used + 1 > spins->size) { - f_array_length_t size = spins->used + f_memory_default_allocation_step; + f_array_length_t size = spins->used + step; if (size > f_array_length_t_size) { if (spins->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_thread/c/thread.h b/level_0/f_thread/c/thread.h index 303cb68..c6750ac 100644 --- a/level_0/f_thread/c/thread.h +++ b/level_0/f_thread/c/thread.h @@ -685,6 +685,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param attributes * The string attributes array to resize. * @@ -697,7 +700,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_attributes_increase_ - extern f_status_t f_thread_attributes_increase(f_thread_attributes_t *attributes); + extern f_status_t f_thread_attributes_increase(const uint16_t step, f_thread_attributes_t *attributes); #endif // _di_f_thread_attributes_increase_ /** @@ -897,6 +900,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param attributes * The thread attributes array to resize. * @@ -909,7 +915,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barrier_attributes_increase_ - extern f_status_t f_thread_barrier_attributes_increase(f_thread_barrier_attributes_t *attributes); + extern f_status_t f_thread_barrier_attributes_increase(const uint16_t step, f_thread_barrier_attributes_t *attributes); #endif // _di_f_thread_barrier_attributes_increase_ /** @@ -1087,6 +1093,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param barriers * The thread barriers array to resize. * @@ -1099,7 +1108,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_barriers_increase_ - extern f_status_t f_thread_barriers_increase(f_thread_barriers_t *barriers); + extern f_status_t f_thread_barriers_increase(const uint16_t step, f_thread_barriers_t *barriers); #endif // _di_f_thread_barriers_increase_ /** @@ -1429,6 +1438,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param attributes * The string attributes array to resize. * @@ -1441,7 +1453,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_condition_attributes_increase_ - extern f_status_t f_thread_condition_attributes_increase(f_thread_condition_attributes_t *attributes); + extern f_status_t f_thread_condition_attributes_increase(const uint16_t step, f_thread_condition_attributes_t *attributes); #endif // _di_f_thread_condition_attributes_increase_ /** @@ -1695,6 +1707,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param conditions * The string conditions array to resize. * @@ -1707,7 +1722,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_conditions_increase_ - extern f_status_t f_thread_conditions_increase(f_thread_conditions_t *conditions); + extern f_status_t f_thread_conditions_increase(const uint16_t step, f_thread_conditions_t *conditions); #endif // _di_f_thread_conditions_increase_ /** @@ -2069,6 +2084,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param keys * The string keys array to resize. * @@ -2081,7 +2099,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_keys_increase_ - extern f_status_t f_thread_keys_increase(f_thread_keys_t *keys); + extern f_status_t f_thread_keys_increase(const uint16_t step, f_thread_keys_t *keys); #endif // _di_f_thread_keys_increase_ /** @@ -2282,6 +2300,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param attributes * The string attributes array to resize. * @@ -2294,7 +2315,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_lock_attributes_increase_ - extern f_status_t f_thread_lock_attributes_increase(f_thread_lock_attributes_t *attributes); + extern f_status_t f_thread_lock_attributes_increase(const uint16_t step, f_thread_lock_attributes_t *attributes); #endif // _di_f_thread_lock_attributes_increase_ /** @@ -2604,6 +2625,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param locks * The string locks array to resize. * @@ -2616,7 +2640,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_locks_increase_ - extern f_status_t f_thread_locks_increase(f_thread_locks_t *locks); + extern f_status_t f_thread_locks_increase(const uint16_t step, f_thread_locks_t *locks); #endif // _di_f_thread_locks_increase_ /** @@ -2942,6 +2966,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param attributes * The string attributes array to resize. * @@ -2954,7 +2981,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutex_attributes_increase_ - extern f_status_t f_thread_mutex_attributes_increase(f_thread_mutex_attributes_t *attributes); + extern f_status_t f_thread_mutex_attributes_increase(const uint16_t step, f_thread_mutex_attributes_t *attributes); #endif // _di_f_thread_mutex_attributes_increase_ /** @@ -3267,6 +3294,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param mutexs * The string mutexs array to resize. * @@ -3279,7 +3309,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_mutexs_increase_ - extern f_status_t f_thread_mutexs_increase(f_thread_mutexs_t *mutexs); + extern f_status_t f_thread_mutexs_increase(const uint16_t step, f_thread_mutexs_t *mutexs); #endif // _di_f_thread_mutexs_increase_ /** @@ -3740,6 +3770,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param semaphores * The string semaphores array to resize. * @@ -3752,7 +3785,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_semaphores_increase_ - extern f_status_t f_thread_semaphores_increase(f_thread_semaphores_t *semaphores); + extern f_status_t f_thread_semaphores_increase(const uint16_t step, f_thread_semaphores_t *semaphores); #endif // _di_f_thread_semaphores_increase_ /** @@ -3865,6 +3898,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param sets * The string sets array to resize. * @@ -3877,7 +3913,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_sets_increase_ - extern f_status_t f_thread_sets_increase(f_thread_sets_t *sets); + extern f_status_t f_thread_sets_increase(const uint16_t step, f_thread_sets_t *sets); #endif // _di_f_thread_sets_increase_ /** @@ -4182,6 +4218,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param spins * The string spins array to resize. * @@ -4194,7 +4233,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_thread_spins_increase_ - extern f_status_t f_thread_spins_increase(f_thread_spins_t *spins); + extern f_status_t f_thread_spins_increase(const uint16_t step, f_thread_spins_t *spins); #endif // _di_f_thread_spins_increase_ /** diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index b714498..2b514c4 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -26,13 +26,107 @@ extern "C" { #endif /** - * Status type. + * Compiler-specific attribute visibility features. + * + * Use these macros for visibility-specific tweaks so that if these are not supported by any given compiler, then they can be easily disabled. + * + * f_attribute_visibility_internal provides a way to make some functions effectively private. + */ +#ifndef _di_f_attribute_visibility_ + #define f_attribute_visibility_hidden __attribute__((visibility("hidden"))) + #define f_attribute_visibility_internal __attribute__((visibility("internal"))) + #define f_attribute_visibility_protected __attribute__((visibility("protected"))) + #define f_attribute_visibility_public __attribute__((visibility("default"))) +#endif // _di_f_attribute_visibility_ + +/** + * A status intended to be used as the return value status of some function or operation. */ #ifndef _di_f_type_status_t_ typedef uint16_t f_status_t; #endif // _di_f_type_status_t_ /** + * A representation of a state to be shared between different levels for some function. + * + * This is used to provide advanced controls on different levels of the project to something outside. + * + * The allocate provides an allocation step so that the caller can determine a better performing allocation step for their purpose. + * For example, if the caller knows that they need to allocate a hundred megabytes of data of which is separated into blocks of 8k, then allocate could be set to 8192. + * + * There are two standard callbacks that are expected to be commonly available: interrupt() and handle(). + * Additional callbacks are stored in the structure "callbacks" as defined by the class requiring the use of this structure (f_state_t). + * + * All state values may be NULL, in which case they are to be ignored. + * + * The general interpretation of the return results of interrupt() or any of the functions should have an error bit to designate an error and not an error bit to designate no error. + * In the case of interrupt(), the F_interrupt and F_interrupt_not must be returned as appropriate and if not an error (the F_interrupt and F_interrupt_not may have an error bit). + * To keep the logic simple, it is recommended that F_interrupt always be returned with the error bit set. + * + * The general interpretation of handle() is to either print an error message or to perform additional tasks when an error occurs (such as saving state data for use at a higher level). + * This allows for the error to be processed with all relevant data before the function returns. + * + * These two callbacks (handle() and interrupt()) accept the following parameters: + * - error: The current status code (with error bit as appropriate) (only passed to handle()). + * - state: The state data. Must be of type f_state_t. Must not be NULL. + * - internal: Additional data passed by the function being called, often containing internal data to the called function. May be NULL. + * + * The "custom" property on f_state_t is intended to be used so that the callback, such as the interrupt(), can make changes to something within the scope of the parent. + * + * For example: + * There exists some project "bob" with some functions "bob_does()" and "bob_interrupts()". + * The function "bob_does()" maintains a state (f_state_t) called "bob_state". + * The function "bob_does()" will call "f_talk()" that accepts a state (f_state_t) and defines the data structure type "f_interject_t" to be called interject. + * While "f_talk()" executes, "bob_interrupts()" is periodically with the state (f_state_t) "bob_state" as the first parameter and the data structure (f_interject_t) "interject" as the second parameter. + * If Bob interjects the talk, then bob_interrupts() would return F_interrupt. + * If Bob does not interject the talk, then bob_interrupts() would return F_interrupt_not. + * This response is handled within f_talk(). + * The f_talk() function will then return status when done and might immediately return with F_interrupt (with error bit) if bob_interrupts() returns F_interrupt (with/without error bit). + * + * step_large: The allocation step to use for large buffers. + * step_small: The allocation step to use for small buffers. + * 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 (return result is passed to and handled by caller). May be NULL. + * callbacks: A structure (defined by function/project using this) of additional functions to call. May be NULL. + * custom: A structure (defined by caller/parent) for holding custom data to be passed along to the interrupt() or one of the functions. May be NULL. + * data: A structure (defined by function) for holding data relevant to the function. May be NULL. May be required. + */ +#ifndef _di_f_type_state_t_ + typedef struct { + uint16_t step_large; + uint16_t step_small; + + f_status_t (*handle)(const f_status_t error, void *state, void *internal); + f_status_t (*interrupt)(void *state, void *internal); + + void *callbacks; + void *custom; + void *data; + } f_state_t; + + #define f_state_t_initialize { f_memory_default_allocation_large, f_memory_default_allocation_small, 0, 0, 0, 0, 0 } + + #define macro_f_state_t_initialize(step_large, step_small, handle, interrupt, callbacks, custom, data) { \ + step_large, \ + step_small, \ + handle, \ + interrupt, \ + callbacks, \ + custom, \ + data \ + } + + #define macro_f_state_t_clear(state) \ + state.step_large = 0; \ + state.step_small = 0; \ + state.handle = 0; \ + state.interrupt = 0; \ + state.callbacks = 0; \ + state.custom = 0; \ + state.data = 0; +#endif // _di_f_type_state_t_ + +/** * Conditional 128-bit support. * * This should work in GCC, but other compilers this may not be available. @@ -219,18 +313,44 @@ extern "C" { #endif // _di_f_cell_t_ /** - * Compiler-specific attribute visibility features. + * An array of f_cell_t. * - * Use these macros for visibility-specific tweaks so that if these are not supported by any given compiler, then they can be easily disabled. + * The macros are defined in type_array.h or type_array-common.h. * - * f_attribute_visibility_internal provides a way to make some functions effectively private. + * array: The array of f_cell_t. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. */ -#ifndef _di_f_attribute_visibility_ - #define f_attribute_visibility_hidden __attribute__((visibility("hidden"))) - #define f_attribute_visibility_internal __attribute__((visibility("internal"))) - #define f_attribute_visibility_protected __attribute__((visibility("protected"))) - #define f_attribute_visibility_public __attribute__((visibility("default"))) -#endif // _di_f_attribute_visibility_ +#ifndef _di_f_cells_t_ + typedef struct { + f_cell_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_cells_t; + + #define f_cells_t_initialize { 0, 0, 0 } +#endif // _di_f_cells_t_ + +/** + * This holds an array of f_cells_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * array: The array of f_cell_t arrays. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_cellss_t_ + typedef struct { + f_cells_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_cellss_t; + + #define f_cellss_t_initialize { 0, 0, 0 } +#endif // _di_f_cellss_t_ /** * A structure representing a set of modes intended to be used by file or directory operations. @@ -413,46 +533,6 @@ extern "C" { #endif // _di_f_array_lengthss_t_ /** - * An array of f_cell_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * array: The array of f_cell_t. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_cells_t_ - typedef struct { - f_cell_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_cells_t; - - #define f_cells_t_initialize { 0, 0, 0 } -#endif // _di_f_cells_t_ - -/** - * This holds an array of f_cells_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * array: The array of f_cell_t arrays. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_cellss_t_ - typedef struct { - f_cells_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_cellss_t; - - #define f_cellss_t_initialize { 0, 0, 0 } -#endif // _di_f_cellss_t_ - -/** * An array of array int8_t. * * The macros are defined in type_array.h or type_array-common.h. @@ -630,6 +710,8 @@ extern "C" { } f_int32s_t; #define f_int32s_t_initialize { 0, 0, 0 } + + #define macro_f_int32s_t_initialize(structure) #endif // _di_int32s_t_ /** @@ -879,6 +961,86 @@ extern "C" { #define f_uint128ss_t_initialize { 0, 0, 0 } #endif // _di_uint128ss_t_ +/** + * This holds an array of f_status_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * array: The array of f_status_t arrays. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_type_statuss_t_ + typedef struct { + f_status_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_statuss_t; + + #define f_statuss_t_initialize { 0, 0, 0 } +#endif // _di_f_type_statuss_t_ + +/** + * This holds an array of f_statuss_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * array: The array of f_status_t arrays. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_type_statusss_t_ + typedef struct { + f_statuss_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_statusss_t; + + #define f_statusss_t_initialize { 0, 0, 0 } +#endif // _di_f_type_statusss_t_ + +/** + * This holds an array of f_state_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * array: The array of f_state_t arrays. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_type_states_t_ + typedef struct { + f_state_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_states_t; + + #define f_states_t_initialize { 0, 0, 0 } +#endif // _di_f_type_states_t_ + +/** + * This holds an array of f_states_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * array: The array of f_state_t arrays. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_type_statess_t_ + typedef struct { + f_states_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_statess_t; + + #define f_statess_t_initialize { 0, 0, 0 } +#endif // _di_f_type_statess_t_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array-common.h b/level_0/f_type_array/c/type_array-common.h index 6551bdb..0ac3b11 100644 --- a/level_0/f_type_array/c/type_array-common.h +++ b/level_0/f_type_array/c/type_array-common.h @@ -17,6 +17,78 @@ extern "C" { #endif /** + * Macros for f_statuss_t, see type.h for typedefs. + */ +#ifndef _di_f_statuss_t_ + #define macro_f_statuss_t_clear(statuss) macro_f_memory_structure_clear(statuss) + + #define macro_f_statuss_t_resize(status, statuss, length) macro_f_memory_structure_resize(status, statuss, f_status_t, length) + #define macro_f_statuss_t_adjust(status, statuss, length) macro_f_memory_structure_adjust(status, statuss, f_status_t, length) + + #define macro_f_statuss_t_delete_simple(statuss) macro_f_memory_structure_delete_simple(statuss, f_status_t) + #define macro_f_statuss_t_destroy_simple(statuss) macro_f_memory_structure_destroy_simple(statuss, f_status_t) + + #define macro_f_statuss_t_increase(status, step, statuss) macro_f_memory_structure_increase(status, step, statuss, f_status_t) + #define macro_f_statuss_t_increase_by(status, statuss, amount) macro_f_memory_structure_increase_by(status, statuss, f_status_t, amount) + #define macro_f_statuss_t_decrease_by(status, statuss, amount) macro_f_memory_structure_decrease_by(status, statuss, f_status_t, amount) + #define macro_f_statuss_t_decimate_by(status, statuss, amount) macro_f_memory_structure_decimate_by(status, statuss, f_status_t, amount) +#endif // _di_f_statuss_t_ + +/** + * Macros for f_statusss_t, see type.h for typedefs. + */ +#ifndef _di_f_statusss_t_ + #define macro_f_statusss_t_clear(rangess) macro_f_memory_structures_clear(rangess) + + #define macro_f_statusss_t_resize(status, statusss, length) status = f_type_statusss_resize(length, &statusss); + #define macro_f_statusss_t_adjust(status, statusss, length) status = f_type_statusss_adjust(length, &statusss); + + #define macro_f_statusss_t_delete_simple(statusss) f_type_statusss_resize(0, &statusss); + #define macro_f_statusss_t_destroy_simple(statusss) f_type_statusss_adjust(0, &statusss); + + #define macro_f_statusss_t_increase(status, step, statusss) status = f_type_statusss_increase(step, &statusss); + #define macro_f_statusss_t_increase_by(status, statusss, amount) status = f_type_statusss_increase_by(amount, &statusss); + #define macro_f_statusss_t_decrease_by(status, statusss, amount) status = f_type_statusss_decrease_by(amount, &statusss); + #define macro_f_statusss_t_decimate_by(status, statusss, amount) status = f_type_statusss_decimate_by(amount, &statusss); +#endif // _di_f_statusss_t_ + +/** + * Macros for f_states_t, see type.h for typedefs. + */ +#ifndef _di_f_states_t_ + #define macro_f_states_t_clear(states) macro_f_memory_structure_clear(states) + + #define macro_f_states_t_resize(status, states, length) macro_f_memory_structure_resize(status, states, f_state_t, length) + #define macro_f_states_t_adjust(status, states, length) macro_f_memory_structure_adjust(status, states, f_state_t, length) + + #define macro_f_states_t_delete_simple(states) macro_f_memory_structure_delete_simple(states, f_state_t) + #define macro_f_states_t_destroy_simple(states) macro_f_memory_structure_destroy_simple(states, f_state_t) + + #define macro_f_states_t_increase(status,step, states) macro_f_memory_structure_increase(status, step, states, f_state_t) + #define macro_f_states_t_increase_by(status, states, amount) macro_f_memory_structure_increase_by(status, states, f_state_t, amount) + #define macro_f_states_t_decrease_by(status, states, amount) macro_f_memory_structure_decrease_by(status, states, f_state_t, amount) + #define macro_f_states_t_decimate_by(status, states, amount) macro_f_memory_structure_decimate_by(status, states, f_state_t, amount) +#endif // _di_f_states_t_ + +/** + * Macros for f_statess_t, see type.h for typedefs. + */ +#ifndef _di_f_statess_t_ + #define macro_f_statess_t_clear(rangess) macro_f_memory_structures_clear(rangess) + + #define macro_f_statess_t_resize(status, statess, length) status = f_type_statess_resize(length, &statess); + #define macro_f_statess_t_adjust(status, statess, length) status = f_type_statess_adjust(length, &statess); + + #define macro_f_statess_t_delete_simple(statess) f_type_statess_resize(0, &statess); + #define macro_f_statess_t_destroy_simple(statess) f_type_statess_adjust(0, &statess); + + #define macro_f_statess_t_increase(status, step, statess) status = f_type_statess_increase(step, &statess); + #define macro_f_statess_t_increase_by(status, statess, amount) status = f_type_statess_increase_by(amount, &statess); + #define macro_f_statess_t_decrease_by(status, statess, amount) status = f_type_statess_decrease_by(amount, &statess); + #define macro_f_statess_t_decimate_by(status, statess, amount) status = f_type_statess_decimate_by(amount, &statess); +#endif // _di_f_statess_t_ + +/** * Macros for f_array_lengths_t, see type.h for typedefs. */ #ifndef _di_f_array_lengths_t_ @@ -28,7 +100,7 @@ extern "C" { #define macro_f_array_lengths_t_delete_simple(lengths) macro_f_memory_structure_delete_simple(lengths, f_array_length_t) #define macro_f_array_lengths_t_destroy_simple(lengths) macro_f_memory_structure_destroy_simple(lengths, f_array_length_t) - #define macro_f_array_lengths_t_increase(status, lengths) macro_f_memory_structure_increase(status, lengths, f_array_length_t) + #define macro_f_array_lengths_t_increase(status, step, lengths) macro_f_memory_structure_increase(status, step, lengths, f_array_length_t) #define macro_f_array_lengths_t_increase_by(status, lengths, amount) macro_f_memory_structure_increase_by(status, lengths, f_array_length_t, amount) #define macro_f_array_lengths_t_decrease_by(status, lengths, amount) macro_f_memory_structure_decrease_by(status, lengths, f_array_length_t, amount) #define macro_f_array_lengths_t_decimate_by(status, lengths, amount) macro_f_memory_structure_decimate_by(status, lengths, f_array_length_t, amount) @@ -46,14 +118,14 @@ extern "C" { #define macro_f_array_lengthss_t_delete_simple(lengths) f_type_array_lengthss_resize(0, &lengths); #define macro_f_array_lengthss_t_destroy_simple(lengths) f_type_array_lengthss_adjust(0, &lengths); - #define macro_f_array_lengthss_t_increase(status, lengths) status = f_type_array_lengthss_increase(&lengths); - #define macro_f_array_lengthss_t_increase_by(status, lengths, amount) status = f_type_array_lengthss_increase(amount, &lengths); + #define macro_f_array_lengthss_t_increase(status, step, lengths) status = f_type_array_lengthss_increase(step, &lengths); + #define macro_f_array_lengthss_t_increase_by(status, lengths, amount) status = f_type_array_lengthss_increase_by(amount, &lengths); #define macro_f_array_lengthss_t_decrease_by(status, lengths, amount) status = f_type_array_lengthss_decrease_by(amount, &lengths); #define macro_f_array_lengthss_t_decimate_by(status, lengths, amount) status = f_type_array_lengthss_decimate_by(amount, &lengths); #endif // _di_f_array_lengthss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_cells_t, see type.h for typedefs. */ #ifndef _di_f_cells_t_ #define macro_f_cells_t_clear(cells) macro_f_memory_structure_clear(cells) @@ -64,14 +136,14 @@ extern "C" { #define macro_f_cells_t_delete_simple(cells) macro_f_memory_structure_delete_simple(cells, f_cell_t) #define macro_f_cells_t_destroy_simple(cells) macro_f_memory_structure_destroy_simple(cells, f_cell_t) - #define macro_f_cells_t_increase(status, cells) macro_f_memory_structure_increase(status, cells, f_cell_t) + #define macro_f_cells_t_increase(status, step, cells) macro_f_memory_structure_increase(status, step, cells, f_cell_t) #define macro_f_cells_t_increase_by(status, cells, amount) macro_f_memory_structure_increase_by(status, cells, f_cell_t, amount) #define macro_f_cells_t_decrease_by(status, cells, amount) macro_f_memory_structure_decrease_by(status, cells, f_cell_t, amount) #define macro_f_cells_t_decimate_by(status, cells, amount) macro_f_memory_structure_decimate_by(status, cells, f_cell_t, amount) #endif // _di_f_cells_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_cellss_t, see type.h for typedefs. */ #ifndef _di_f_cellss_t_ #define macro_f_cellss_t_clear(rangess) macro_f_memory_structures_clear(rangess) @@ -82,8 +154,8 @@ extern "C" { #define macro_f_cellss_t_delete_simple(cellss) f_type_cellss_resize(0, &cellss); #define macro_f_cellss_t_destroy_simple(cellss) f_type_cellss_adjust(0, &cellss); - #define macro_f_cellss_t_increase(status, cellss) status = f_type_cellss_increase(&cellss); - #define macro_f_cellss_t_increase_by(status, cellss, amount) status = f_type_cellss_increase(amount, &cellss); + #define macro_f_cellss_t_increase(status, step, cellss) status = f_type_cellss_increase(step, &cellss); + #define macro_f_cellss_t_increase_by(status, cellss, amount) status = f_type_cellss_increase_by(amount, &cellss); #define macro_f_cellss_t_decrease_by(status, cellss, amount) status = f_type_cellss_decrease_by(amount, &cellss); #define macro_f_cellss_t_decimate_by(status, cellss, amount) status = f_type_cellss_decimate_by(amount, &cellss); #endif // _di_f_cellss_t_ @@ -100,7 +172,7 @@ extern "C" { #define macro_f_int8s_t_delete_simple(int8s) macro_f_memory_structure_delete_simple(int8s, int8_t) #define macro_f_int8s_t_destroy_simple(int8s) macro_f_memory_structure_destroy_simple(int8s, int8_t) - #define macro_f_int8s_t_increase(status, int8s) macro_f_memory_structure_increase(status, int8s, int8_t) + #define macro_f_int8s_t_increase(status, step, int8s) macro_f_memory_structure_increase(status, step, int8s, int8_t) #define macro_f_int8s_t_increase_by(status, int8s, amount) macro_f_memory_structure_increase_by(status, int8s, int8_t, amount) #define macro_f_int8s_t_decrease_by(status, int8s, amount) macro_f_memory_structure_decrease_by(status, int8s, int8_t, amount) #define macro_f_int8s_t_decimate_by(status, int8s, amount) macro_f_memory_structure_decimate_by(status, int8s, int8_t, amount) @@ -115,8 +187,8 @@ extern "C" { #define macro_f_int8ss_t_resize(status, int8ss, length) status = f_type_int8ss_resize(length, &int8ss); #define macro_f_int8ss_t_adjust(status, int8ss, length) status = f_type_int8ss_adjust(length, &int8ss); - #define macro_f_int8ss_t_increase(status, int8ss) status = f_type_int8ss_increase(&int8ss); - #define macro_f_int8ss_t_increase_by(status, int8ss, amount) status = f_type_int8ss_increase(amount, &int8ss); + #define macro_f_int8ss_t_increase(status, step, int8ss) status = f_type_int8ss_increase(step, &int8ss); + #define macro_f_int8ss_t_increase_by(status, int8ss, amount) status = f_type_int8ss_increase_by(amount, &int8ss); #define macro_f_int8ss_t_decrease_by(status, int8ss, amount) status = f_type_int8ss_decrease_by(amount, &int8ss); #define macro_f_int8ss_t_decimate_by(status, int8ss, amount) status = f_type_int8ss_decimate_by(amount, &int8ss); @@ -133,7 +205,7 @@ extern "C" { #define macro_f_uint8s_t_resize(status, uint8s, length) macro_f_memory_structure_resize(status, uint8s, uint8_t, length) #define macro_f_uint8s_t_adjust(status, uint8s, length) macro_f_memory_structure_adjust(status, uint8s, uint8_t, length) - #define macro_f_uint8s_t_increase(status, uint8s) macro_f_memory_structure_increase(status, uint8s, uint8_t) + #define macro_f_uint8s_t_increase(status, step, uint8s) macro_f_memory_structure_increase(status, step, uint8s, uint8_t) #define macro_f_uint8s_t_increase_by(status, uint8s, amount) macro_f_memory_structure_increase_by(status, uint8s, uint8_t, amount) #define macro_f_uint8s_t_decrease_by(status, uint8s, amount) macro_f_memory_structure_decrease_by(status, uint8s, uint8_t, amount) #define macro_f_uint8s_t_decimate_by(status, uint8s, amount) macro_f_memory_structure_decimate_by(status, uint8s, uint8_t, amount) @@ -154,7 +226,7 @@ extern "C" { #define macro_f_uint8ss_t_delete_simple(uint8ss) f_type_uint8ss_resize(0, &uint8ss); #define macro_f_uint8ss_t_destroy_simple(uint8ss) f_type_uint8ss_adjust(0, &uint8ss); - #define macro_f_uint8ss_t_increase(status, uint8ss) status = f_type_uint8ss_increase(&uint8ss); + #define macro_f_uint8ss_t_increase(status, step, uint8ss) status = f_type_uint8ss_increase(step, &uint8ss); #define macro_f_uint8ss_t_increase_by(status, uint8ss, amount) status = f_type_uint8ss_increase(amount, &uint8ss); #define macro_f_uint8ss_t_decrease_by(status, uint8ss, amount) status = f_type_uint8ss_decrease_by(amount, &uint8ss); #define macro_f_uint8ss_t_decimate_by(status, uint8ss, amount) status = f_type_uint8ss_decimate_by(amount, &uint8ss); @@ -172,7 +244,7 @@ extern "C" { #define macro_f_int16s_t_delete_simple(int16s) macro_f_memory_structure_delete_simple(int16s, int16_t) #define macro_f_int16s_t_destroy_simple(int16s) macro_f_memory_structure_destroy_simple(int16s, int16_t) - #define macro_f_int16s_t_increase(status, int16s) macro_f_memory_structure_increase(status, int16s, int16_t) + #define macro_f_int16s_t_increase(status, step, int16s) macro_f_memory_structure_increase(status, step, int16s, int16_t) #define macro_f_int16s_t_increase_by(status, int16s, amount) macro_f_memory_structure_increase_by(status, int16s, int16_t, amount) #define macro_f_int16s_t_decrease_by(status, int16s, amount) macro_f_memory_structure_decrease_by(status, int16s, int16_t, amount) #define macro_f_int16s_t_decimate_by(status, int16s, amount) macro_f_memory_structure_decimate_by(status, int16s, int16_t, amount) @@ -187,7 +259,7 @@ extern "C" { #define macro_f_int16ss_t_resize(status, int16ss, length) status = f_type_int16ss_resize(length, &int16ss); #define macro_f_int16ss_t_adjust(status, int16ss, length) status = f_type_int16ss_adjust(length, &int16ss); - #define macro_f_int16ss_t_increase(status, int16ss) status = f_type_int16ss_increase(&int16ss); + #define macro_f_int16ss_t_increase(status, step, int16ss) status = f_type_int16ss_increase(step, &int16ss); #define macro_f_int16ss_t_increase_by(status, int16ss, amount) status = f_type_int16ss_increase(amount, &int16ss); #define macro_f_int16ss_t_decrease_by(status, int16ss, amount) status = f_type_int16ss_decrease_by(amount, &int16ss); #define macro_f_int16ss_t_decimate_by(status, int16ss, amount) status = f_type_int16ss_decimate_by(amount, &int16ss); @@ -208,7 +280,7 @@ extern "C" { #define macro_f_uint16s_t_delete_simple(uint16s) macro_f_memory_structure_delete_simple(uint16s, uint16_t) #define macro_f_uint16s_t_destroy_simple(uint16s) macro_f_memory_structure_destroy_simple(uint16s, uint16_t) - #define macro_f_uint16s_t_increase(status, uint16s) macro_f_memory_structure_increase(status, uint16s, uint16_t) + #define macro_f_uint16s_t_increase(status, step, uint16s) macro_f_memory_structure_increase(status, step, uint16s, uint16_t) #define macro_f_uint16s_t_increase_by(status, uint16s, amount) macro_f_memory_structure_increase_by(status, uint16s, uint16_t, amount) #define macro_f_uint16s_t_decrease_by(status, uint16s, amount) macro_f_memory_structure_decrease_by(status, uint16s, uint16_t, amount) #define macro_f_uint16s_t_decimate_by(status, uint16s, amount) macro_f_memory_structure_decimate_by(status, uint16s, uint16_t, amount) @@ -226,7 +298,7 @@ extern "C" { #define macro_f_uint16ss_t_delete_simple(uint16ss) f_type_uint16ss_resize(0, &uint16ss); #define macro_f_uint16ss_t_destroy_simple(uint16ss) f_type_uint16ss_adjust(0, &uint16ss); - #define macro_f_uint16ss_t_increase(status, uint16ss) status = f_type_uint16ss_increase(&uint16ss); + #define macro_f_uint16ss_t_increase(status, step, uint16ss) status = f_type_uint16ss_increase(step, &uint16ss); #define macro_f_uint16ss_t_increase_by(status, uint16ss, amount) status = f_type_uint16ss_increase(amount, &uint16ss); #define macro_f_uint16ss_t_decrease_by(status, uint16ss, amount) status = f_type_uint16ss_decrease_by(amount, &uint16ss); #define macro_f_uint16ss_t_decimate_by(status, uint16ss, amount) status = f_type_uint16ss_decimate_by(amount, &uint16ss); @@ -244,7 +316,7 @@ extern "C" { #define macro_f_int32s_t_delete_simple(int32s) macro_f_memory_structure_delete_simple(int32s, int32_t) #define macro_f_int32s_t_destroy_simple(int32s) macro_f_memory_structure_destroy_simple(int32s, int32_t) - #define macro_f_int32s_t_increase(status, int32s) macro_f_memory_structure_increase(status, int32s, int32_t) + #define macro_f_int32s_t_increase(status, step, int32s) macro_f_memory_structure_increase(status, step, int32s, int32_t) #define macro_f_int32s_t_increase_by(status, int32s, amount) macro_f_memory_structure_increase_by(status, int32s, int32_t, amount) #define macro_f_int32s_t_decrease_by(status, int32s, amount) macro_f_memory_structure_decrease_by(status, int32s, int32_t, amount) #define macro_f_int32s_t_decimate_by(status, int32s, amount) macro_f_memory_structure_decimate_by(status, int32s, int32_t, amount) @@ -262,7 +334,7 @@ extern "C" { #define macro_f_int32ss_t_delete_simple(int32ss) f_type_int32ss_resize(0, &int32ss); #define macro_f_int32ss_t_destroy_simple(int32ss) f_type_int32ss_adjust(0, &int32ss); - #define macro_f_int32ss_t_increase(status, int32ss) status = f_type_int32ss_increase(&int32ss); + #define macro_f_int32ss_t_increase(status, step, int32ss) status = f_type_int32ss_increase(step, &int32ss); #define macro_f_int32ss_t_increase_by(status, int32ss, amount) status = f_type_int32ss_increase(amount, &int32ss); #define macro_f_int32ss_t_decrease_by(status, int32ss, amount) status = f_type_int32ss_decrease_by(amount, &int32ss); #define macro_f_int32ss_t_decimate_by(status, int32ss, amount) status = f_type_int32ss_decimate_by(amount, &int32ss); @@ -280,7 +352,7 @@ extern "C" { #define macro_f_uint32s_t_delete_simple(uint32s) macro_f_memory_structure_delete_simple(uint32s, uint32_t) #define macro_f_uint32s_t_destroy_simple(uint32s) macro_f_memory_structure_destroy_simple(uint32s, uint32_t) - #define macro_f_uint32s_t_increase(status, uint32s) macro_f_memory_structure_increase(status, uint32s, uint32_t) + #define macro_f_uint32s_t_increase(status, step, uint32s) macro_f_memory_structure_increase(status, step, uint32s, uint32_t) #define macro_f_uint32s_t_increase_by(status, uint32s, amount) macro_f_memory_structure_increase_by(status, uint32s, uint32_t, amount) #define macro_f_uint32s_t_decrease_by(status, uint32s, amount) macro_f_memory_structure_decrease_by(status, uint32s, uint32_t, amount) #define macro_f_uint32s_t_decimate_by(status, uint32s, amount) macro_f_memory_structure_decimate_by(status, uint32s, uint32_t, amount) @@ -298,7 +370,7 @@ extern "C" { #define macro_f_uint32ss_t_delete_simple(uint32ss) f_type_uint32ss_resize(0, &uint32ss); #define macro_f_uint32ss_t_destroy_simple(uint32ss) f_type_uint32ss_adjust(0, &uint32ss); - #define macro_f_uint32ss_t_increase(status, uint32ss) status = f_type_uint32ss_increase(&uint32ss); + #define macro_f_uint32ss_t_increase(status, step, uint32ss) status = f_type_uint32ss_increase(step, &uint32ss); #define macro_f_uint32ss_t_increase_by(status, uint32ss, amount) status = f_type_uint32ss_increase(amount, &uint32ss); #define macro_f_uint32ss_t_decrease_by(status, uint32ss, amount) status = f_type_uint32ss_decrease_by(amount, &uint32ss); #define macro_f_uint32ss_t_decimate_by(status, uint32ss, amount) status = f_type_uint32ss_decimate_by(amount, &uint32ss); @@ -316,7 +388,7 @@ extern "C" { #define macro_f_int64s_t_delete_simple(int64s) macro_f_memory_structure_delete_simple(int64s, int64_t) #define macro_f_int64s_t_destroy_simple(int64s) macro_f_memory_structure_destroy_simple(int64s, int64_t) - #define macro_f_int64s_t_increase(status, int64s) macro_f_memory_structure_increase(status, int64s, int64_t) + #define macro_f_int64s_t_increase(status, step, int64s) macro_f_memory_structure_increase(status, step, int64s, int64_t) #define macro_f_int64s_t_increase_by(status, int64s, amount) macro_f_memory_structure_increase_by(status, int64s, int64_t, amount) #define macro_f_int64s_t_decrease_by(status, int64s, amount) macro_f_memory_structure_decrease_by(status, int64s, int64_t, amount) #define macro_f_int64s_t_decimate_by(status, int64s, amount) macro_f_memory_structure_decimate_by(status, int64s, int64_t, amount) @@ -331,7 +403,7 @@ extern "C" { #define macro_f_int64ss_t_resize(status, int64ss, length) status = f_type_int64ss_resize(length, &int64ss); #define macro_f_int64ss_t_adjust(status, int64ss, length) status = f_type_int64ss_adjust(length, &int64ss); - #define macro_f_int64ss_t_increase(status, int64ss) status = f_type_int64ss_increase(&int64ss); + #define macro_f_int64ss_t_increase(status, step, int64ss) status = f_type_int64ss_increase(step, &int64ss); #define macro_f_int64ss_t_increase_by(status, int64ss, amount) status = f_type_int64ss_increase(amount, &int64ss); #define macro_f_int64ss_t_decrease_by(status, int64ss, amount) status = f_type_int64ss_decrease_by(amount, &int64ss); #define macro_f_int64ss_t_decimate_by(status, int64ss, amount) status = f_type_int64ss_decimate_by(amount, &int64ss); @@ -352,7 +424,7 @@ extern "C" { #define macro_f_uint64s_t_delete_simple(uint64s) macro_f_memory_structure_delete_simple(uint64s, uint64_t) #define macro_f_uint64s_t_destroy_simple(uint64s) macro_f_memory_structure_destroy_simple(uint64s, uint64_t) - #define macro_f_uint64s_t_increase(status, uint64s) macro_f_memory_structure_increase(status, uint64s, uint64_t) + #define macro_f_uint64s_t_increase(status, step, uint64s) macro_f_memory_structure_increase(status, step, uint64s, uint64_t) #define macro_f_uint64s_t_increase_by(status, uint64s, amount) macro_f_memory_structure_increase_by(status, uint64s, uint64_t, amount) #define macro_f_uint64s_t_decrease_by(status, uint64s, amount) macro_f_memory_structure_decrease_by(status, uint64s, uint64_t, amount) #define macro_f_uint64s_t_decimate_by(status, uint64s, amount) macro_f_memory_structure_decimate_by(status, uint64s, uint64_t, amount) @@ -367,7 +439,7 @@ extern "C" { #define macro_f_uint64ss_t_resize(status, uint64ss, length) status = f_type_uint64ss_resize(length, &uint64ss); #define macro_f_uint64ss_t_adjust(status, uint64ss, length) status = f_type_uint64ss_adjust(length, &uint64ss); - #define macro_f_uint64ss_t_increase(status, uint64ss) status = f_type_uint64ss_increase(&uint64ss); + #define macro_f_uint64ss_t_increase(status, step, uint64ss) status = f_type_uint64ss_increase(step, &uint64ss); #define macro_f_uint64ss_t_increase_by(status, uint64ss, amount) status = f_type_uint64ss_increase(amount, &uint64ss); #define macro_f_uint64ss_t_decrease_by(status, uint64ss, amount) status = f_type_uint64ss_decrease_by(amount, &uint64ss); #define macro_f_uint64ss_t_decimate_by(status, uint64ss, amount) status = f_type_uint64ss_decimate_by(amount, &uint64ss); @@ -388,7 +460,7 @@ extern "C" { #define macro_f_int128s_t_delete_simple(int128s) macro_f_memory_structure_delete_simple(int128s, f_int128_t) #define macro_f_int128s_t_destroy_simple(int128s) macro_f_memory_structure_destroy_simple(int128s, f_int128_t) - #define macro_f_int128s_t_increase(status, int128s) macro_f_memory_structure_increase(status, int128s, f_int128_t) + #define macro_f_int128s_t_increase(status, step, int128s) macro_f_memory_structure_increase(status, step, int128s, f_int128_t) #define macro_f_int128s_t_increase_by(status, int128s, amount) macro_f_memory_structure_increase_by(status, int128s, f_int128_t, amount) #define macro_f_int128s_t_decrease_by(status, int128s, amount) macro_f_memory_structure_decrease_by(status, int128s, f_int128_t, amount) #define macro_f_int128s_t_decimate_by(status, int128s, amount) macro_f_memory_structure_decimate_by(status, int128s, f_int128_t, amount) @@ -406,7 +478,7 @@ extern "C" { #define macro_f_int128ss_t_delete_simple(int128ss) f_type_int128ss_resize(0, &int128ss); #define macro_f_int128ss_t_destroy_simple(int128ss) f_type_int128ss_adjust(0, &int128ss); - #define macro_f_int128ss_t_increase(status, int128ss) status = f_type_int128ss_increase(&int128ss); + #define macro_f_int128ss_t_increase(status, step, int128ss) status = f_type_int128ss_increase(step, &int128ss); #define macro_f_int128ss_t_increase_by(status, int128ss, amount) status = f_type_int128ss_increase(amount, &int128ss); #define macro_f_int128ss_t_decrease_by(status, int128ss, amount) status = f_type_int128ss_decrease_by(amount, &int128ss); #define macro_f_int128ss_t_decimate_by(status, int128ss, amount) status = f_type_int128ss_decimate_by(amount, &int128ss); @@ -424,7 +496,7 @@ extern "C" { #define macro_f_uint128s_t_delete_simple(uint128s) macro_f_memory_structure_delete_simple(uint128s, f_uint128_t) #define macro_f_uint128s_t_destroy_simple(uint128s) macro_f_memory_structure_destroy_simple(uint128s, f_uint128_t) - #define macro_f_uint128s_t_increase(status, uint128s) macro_f_memory_structure_increase(status, uint128s, f_uint128_t) + #define macro_f_uint128s_t_increase(status, step, uint128s) macro_f_memory_structure_increase(status, step, uint128s, f_uint128_t) #define macro_f_uint128s_t_increase_by(status, uint128s, amount) macro_f_memory_structure_increase_by(status, uint128s, f_uint128_t, amount) #define macro_f_uint128s_t_decrease_by(status, uint128s, amount) macro_f_memory_structure_decrease_by(status, uint128s, f_uint128_t, amount) #define macro_f_uint128s_t_decimate_by(status, uint128s, amount) macro_f_memory_structure_decimate_by(status, uint128s, f_uint128_t, amount) @@ -442,7 +514,7 @@ extern "C" { #define macro_f_uint128ss_t_delete_simple(uint128ss) f_type_uint128ss_resize(0, &uint128ss); #define macro_f_uint128ss_t_destroy_simple(uint128ss) f_type_uint128ss_adjust(0, &uint128ss); - #define macro_f_uint128ss_t_increase(status, uint128ss) status = f_type_uint128ss_increase(&uint128ss); + #define macro_f_uint128ss_t_increase(status, step, uint128ss) status = f_type_uint128ss_increase(step, &uint128ss); #define macro_f_uint128ss_t_increase_by(status, uint128ss, amount) status = f_type_uint128ss_increase(amount, &uint128ss); #define macro_f_uint128ss_t_decrease_by(status, uint128ss, amount) status = f_type_uint128ss_decrease_by(amount, &uint128ss); #define macro_f_uint128ss_t_decimate_by(status, uint128ss, amount) status = f_type_uint128ss_decimate_by(amount, &uint128ss); diff --git a/level_0/f_type_array/c/type_array.c b/level_0/f_type_array/c/type_array.c index d957675..e8f14cc 100644 --- a/level_0/f_type_array/c/type_array.c +++ b/level_0/f_type_array/c/type_array.c @@ -57,13 +57,14 @@ extern "C" { #endif // _di_f_type_cells_decrease_by_ #ifndef _di_f_type_cells_increase_ - f_status_t f_type_cells_increase(f_cells_t *cells) { + f_status_t f_type_cells_increase(const uint16_t step, f_cells_t *cells) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!cells) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (cells->used + 1 > cells->size) { - f_array_length_t size = cells->used + f_memory_default_allocation_step; + f_array_length_t size = cells->used + step; if (size > f_array_length_t_size) { if (cells->used + 1 > f_array_length_t_size) { @@ -174,13 +175,14 @@ extern "C" { #endif // _di_f_type_cellss_decrease_by_ #ifndef _di_f_type_cellss_increase_ - f_status_t f_type_cellss_increase(f_cellss_t *cellss) { + f_status_t f_type_cellss_increase(const uint16_t step, f_cellss_t *cellss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!cellss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (cellss->used + 1 > cellss->size) { - f_array_length_t size = cellss->used + f_memory_default_allocation_step; + f_array_length_t size = cellss->used + step; if (size > f_array_length_t_size) { if (cellss->used + 1 > f_array_length_t_size) { @@ -279,13 +281,14 @@ extern "C" { #endif // _di_f_type_array_lengths_decrease_by_ #ifndef _di_f_type_array_lengths_increase_ - f_status_t f_type_array_lengths_increase(f_array_lengths_t *lengths) { + f_status_t f_type_array_lengths_increase(const uint16_t step, f_array_lengths_t *lengths) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!lengths) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (lengths->used + 1 > lengths->size) { - f_array_length_t size = lengths->used + f_memory_default_allocation_step; + f_array_length_t size = lengths->used + step; if (size > f_array_length_t_size) { if (lengths->used + 1 > f_array_length_t_size) { @@ -396,13 +399,14 @@ extern "C" { #endif // _di_f_type_array_lengthss_decrease_by_ #ifndef _di_f_type_array_lengthss_increase_ - f_status_t f_type_array_lengthss_increase(f_array_lengthss_t *lengthss) { + f_status_t f_type_array_lengthss_increase(const uint16_t step, f_array_lengthss_t *lengthss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!lengthss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (lengthss->used + 1 > lengthss->size) { - f_array_length_t size = lengthss->used + f_memory_default_allocation_step; + f_array_length_t size = lengthss->used + step; if (size > f_array_length_t_size) { if (lengthss->used + 1 > f_array_length_t_size) { @@ -501,13 +505,14 @@ extern "C" { #endif // _di_f_type_int8s_decrease_by_ #ifndef _di_f_type_int8s_increase_ - f_status_t f_type_int8s_increase(f_int8s_t *int8s) { + f_status_t f_type_int8s_increase(const uint16_t step, f_int8s_t *int8s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int8s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int8s->used + 1 > int8s->size) { - f_array_length_t size = int8s->used + f_memory_default_allocation_step; + f_array_length_t size = int8s->used + step; if (size > f_array_length_t_size) { if (int8s->used + 1 > f_array_length_t_size) { @@ -618,13 +623,14 @@ extern "C" { #endif // _di_f_type_int8ss_decrease_by_ #ifndef _di_f_type_int8ss_increase_ - f_status_t f_type_int8ss_increase(f_int8ss_t *int8ss) { + f_status_t f_type_int8ss_increase(const uint16_t step, f_int8ss_t *int8ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int8ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int8ss->used + 1 > int8ss->size) { - f_array_length_t size = int8ss->used + f_memory_default_allocation_step; + f_array_length_t size = int8ss->used + step; if (size > f_array_length_t_size) { if (int8ss->used + 1 > f_array_length_t_size) { @@ -723,13 +729,14 @@ extern "C" { #endif // _di_f_type_uint8s_decrease_by_ #ifndef _di_f_type_uint8s_increase_ - f_status_t f_type_uint8s_increase(f_uint8s_t *uint8s) { + f_status_t f_type_uint8s_increase(const uint16_t step, f_uint8s_t *uint8s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint8s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint8s->used + 1 > uint8s->size) { - f_array_length_t size = uint8s->used + f_memory_default_allocation_step; + f_array_length_t size = uint8s->used + step; if (size > f_array_length_t_size) { if (uint8s->used + 1 > f_array_length_t_size) { @@ -840,13 +847,14 @@ extern "C" { #endif // _di_f_type_uint8ss_decrease_by_ #ifndef _di_f_type_uint8ss_increase_ - f_status_t f_type_uint8ss_increase(f_uint8ss_t *uint8ss) { + f_status_t f_type_uint8ss_increase(const uint16_t step, f_uint8ss_t *uint8ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint8ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint8ss->used + 1 > uint8ss->size) { - f_array_length_t size = uint8ss->used + f_memory_default_allocation_step; + f_array_length_t size = uint8ss->used + step; if (size > f_array_length_t_size) { if (uint8ss->used + 1 > f_array_length_t_size) { @@ -945,13 +953,14 @@ extern "C" { #endif // _di_f_type_int16s_decrease_by_ #ifndef _di_f_type_int16s_increase_ - f_status_t f_type_int16s_increase(f_int16s_t *int16s) { + f_status_t f_type_int16s_increase(const uint16_t step, f_int16s_t *int16s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int16s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int16s->used + 1 > int16s->size) { - f_array_length_t size = int16s->used + f_memory_default_allocation_step; + f_array_length_t size = int16s->used + step; if (size > f_array_length_t_size) { if (int16s->used + 1 > f_array_length_t_size) { @@ -1062,13 +1071,14 @@ extern "C" { #endif // _di_f_type_int16ss_decrease_by_ #ifndef _di_f_type_int16ss_increase_ - f_status_t f_type_int16ss_increase(f_int16ss_t *int16ss) { + f_status_t f_type_int16ss_increase(const uint16_t step, f_int16ss_t *int16ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int16ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int16ss->used + 1 > int16ss->size) { - f_array_length_t size = int16ss->used + f_memory_default_allocation_step; + f_array_length_t size = int16ss->used + step; if (size > f_array_length_t_size) { if (int16ss->used + 1 > f_array_length_t_size) { @@ -1167,13 +1177,14 @@ extern "C" { #endif // _di_f_type_uint16s_decrease_by_ #ifndef _di_f_type_uint16s_increase_ - f_status_t f_type_uint16s_increase(f_uint16s_t *uint16s) { + f_status_t f_type_uint16s_increase(const uint16_t step, f_uint16s_t *uint16s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint16s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint16s->used + 1 > uint16s->size) { - f_array_length_t size = uint16s->used + f_memory_default_allocation_step; + f_array_length_t size = uint16s->used + step; if (size > f_array_length_t_size) { if (uint16s->used + 1 > f_array_length_t_size) { @@ -1284,13 +1295,14 @@ extern "C" { #endif // _di_f_type_uint16ss_decrease_by_ #ifndef _di_f_type_uint16ss_increase_ - f_status_t f_type_uint16ss_increase(f_uint16ss_t *uint16ss) { + f_status_t f_type_uint16ss_increase(const uint16_t step, f_uint16ss_t *uint16ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint16ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint16ss->used + 1 > uint16ss->size) { - f_array_length_t size = uint16ss->used + f_memory_default_allocation_step; + f_array_length_t size = uint16ss->used + step; if (size > f_array_length_t_size) { if (uint16ss->used + 1 > f_array_length_t_size) { @@ -1389,13 +1401,14 @@ extern "C" { #endif // _di_f_type_int32s_decrease_by_ #ifndef _di_f_type_int32s_increase_ - f_status_t f_type_int32s_increase(f_int32s_t *int32s) { + f_status_t f_type_int32s_increase(const uint16_t step, f_int32s_t *int32s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int32s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int32s->used + 1 > int32s->size) { - f_array_length_t size = int32s->used + f_memory_default_allocation_step; + f_array_length_t size = int32s->used + step; if (size > f_array_length_t_size) { if (int32s->used + 1 > f_array_length_t_size) { @@ -1506,13 +1519,14 @@ extern "C" { #endif // _di_f_type_int32ss_decrease_by_ #ifndef _di_f_type_int32ss_increase_ - f_status_t f_type_int32ss_increase(f_int32ss_t *int32ss) { + f_status_t f_type_int32ss_increase(const uint16_t step, f_int32ss_t *int32ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int32ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int32ss->used + 1 > int32ss->size) { - f_array_length_t size = int32ss->used + f_memory_default_allocation_step; + f_array_length_t size = int32ss->used + step; if (size > f_array_length_t_size) { if (int32ss->used + 1 > f_array_length_t_size) { @@ -1611,13 +1625,14 @@ extern "C" { #endif // _di_f_type_uint32s_decrease_by_ #ifndef _di_f_type_uint32s_increase_ - f_status_t f_type_uint32s_increase(f_uint32s_t *uint32s) { + f_status_t f_type_uint32s_increase(const uint16_t step, f_uint32s_t *uint32s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint32s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint32s->used + 1 > uint32s->size) { - f_array_length_t size = uint32s->used + f_memory_default_allocation_step; + f_array_length_t size = uint32s->used + step; if (size > f_array_length_t_size) { if (uint32s->used + 1 > f_array_length_t_size) { @@ -1728,13 +1743,14 @@ extern "C" { #endif // _di_f_type_uint32ss_decrease_by_ #ifndef _di_f_type_uint32ss_increase_ - f_status_t f_type_uint32ss_increase(f_uint32ss_t *uint32ss) { + f_status_t f_type_uint32ss_increase(const uint16_t step, f_uint32ss_t *uint32ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint32ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint32ss->used + 1 > uint32ss->size) { - f_array_length_t size = uint32ss->used + f_memory_default_allocation_step; + f_array_length_t size = uint32ss->used + step; if (size > f_array_length_t_size) { if (uint32ss->used + 1 > f_array_length_t_size) { @@ -1833,13 +1849,14 @@ extern "C" { #endif // _di_f_type_int64s_decrease_by_ #ifndef _di_f_type_int64s_increase_ - f_status_t f_type_int64s_increase(f_int64s_t *int64s) { + f_status_t f_type_int64s_increase(const uint16_t step, f_int64s_t *int64s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int64s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int64s->used + 1 > int64s->size) { - f_array_length_t size = int64s->used + f_memory_default_allocation_step; + f_array_length_t size = int64s->used + step; if (size > f_array_length_t_size) { if (int64s->used + 1 > f_array_length_t_size) { @@ -1950,13 +1967,14 @@ extern "C" { #endif // _di_f_type_int64ss_decrease_by_ #ifndef _di_f_type_int64ss_increase_ - f_status_t f_type_int64ss_increase(f_int64ss_t *int64ss) { + f_status_t f_type_int64ss_increase(const uint16_t step, f_int64ss_t *int64ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int64ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int64ss->used + 1 > int64ss->size) { - f_array_length_t size = int64ss->used + f_memory_default_allocation_step; + f_array_length_t size = int64ss->used + step; if (size > f_array_length_t_size) { if (int64ss->used + 1 > f_array_length_t_size) { @@ -2055,13 +2073,14 @@ extern "C" { #endif // _di_f_type_uint64s_decrease_by_ #ifndef _di_f_type_uint64s_increase_ - f_status_t f_type_uint64s_increase(f_uint64s_t *uint64s) { + f_status_t f_type_uint64s_increase(const uint16_t step, f_uint64s_t *uint64s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint64s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint64s->used + 1 > uint64s->size) { - f_array_length_t size = uint64s->used + f_memory_default_allocation_step; + f_array_length_t size = uint64s->used + step; if (size > f_array_length_t_size) { if (uint64s->used + 1 > f_array_length_t_size) { @@ -2172,13 +2191,14 @@ extern "C" { #endif // _di_f_type_uint64ss_decrease_by_ #ifndef _di_f_type_uint64ss_increase_ - f_status_t f_type_uint64ss_increase(f_uint64ss_t *uint64ss) { + f_status_t f_type_uint64ss_increase(const uint16_t step, f_uint64ss_t *uint64ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint64ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint64ss->used + 1 > uint64ss->size) { - f_array_length_t size = uint64ss->used + f_memory_default_allocation_step; + f_array_length_t size = uint64ss->used + step; if (size > f_array_length_t_size) { if (uint64ss->used + 1 > f_array_length_t_size) { @@ -2277,13 +2297,14 @@ extern "C" { #endif // _di_f_type_int128s_decrease_by_ #ifndef _di_f_type_int128s_increase_ - f_status_t f_type_int128s_increase(f_int128s_t *int128s) { + f_status_t f_type_int128s_increase(const uint16_t step, f_int128s_t *int128s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int128s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int128s->used + 1 > int128s->size) { - f_array_length_t size = int128s->used + f_memory_default_allocation_step; + f_array_length_t size = int128s->used + step; if (size > f_array_length_t_size) { if (int128s->used + 1 > f_array_length_t_size) { @@ -2394,13 +2415,14 @@ extern "C" { #endif // _di_f_type_int128ss_decrease_by_ #ifndef _di_f_type_int128ss_increase_ - f_status_t f_type_int128ss_increase(f_int128ss_t *int128ss) { + f_status_t f_type_int128ss_increase(const uint16_t step, f_int128ss_t *int128ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!int128ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (int128ss->used + 1 > int128ss->size) { - f_array_length_t size = int128ss->used + f_memory_default_allocation_step; + f_array_length_t size = int128ss->used + step; if (size > f_array_length_t_size) { if (int128ss->used + 1 > f_array_length_t_size) { @@ -2499,13 +2521,14 @@ extern "C" { #endif // _di_f_type_uint128s_decrease_by_ #ifndef _di_f_type_uint128s_increase_ - f_status_t f_type_uint128s_increase(f_uint128s_t *uint128s) { + f_status_t f_type_uint128s_increase(const uint16_t step, f_uint128s_t *uint128s) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint128s) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint128s->used + 1 > uint128s->size) { - f_array_length_t size = uint128s->used + f_memory_default_allocation_step; + f_array_length_t size = uint128s->used + step; if (size > f_array_length_t_size) { if (uint128s->used + 1 > f_array_length_t_size) { @@ -2616,13 +2639,14 @@ extern "C" { #endif // _di_f_type_uint128ss_decrease_by_ #ifndef _di_f_type_uint128ss_increase_ - f_status_t f_type_uint128ss_increase(f_uint128ss_t *uint128ss) { + f_status_t f_type_uint128ss_increase(const uint16_t step, f_uint128ss_t *uint128ss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!uint128ss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (uint128ss->used + 1 > uint128ss->size) { - f_array_length_t size = uint128ss->used + f_memory_default_allocation_step; + f_array_length_t size = uint128ss->used + step; if (size > f_array_length_t_size) { if (uint128ss->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_type_array/c/type_array.h b/level_0/f_type_array/c/type_array.h index cd3b104..ecd41b5 100644 --- a/level_0/f_type_array/c/type_array.h +++ b/level_0/f_type_array/c/type_array.h @@ -115,6 +115,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param cells * The string cells array to resize. * @@ -128,7 +131,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_cells_increase_ - extern f_status_t f_type_cells_increase(f_cells_t *cells); + extern f_status_t f_type_cells_increase(const uint16_t step, f_cells_t *cells); #endif // _di_f_type_cells_increase_ /** @@ -289,6 +292,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param cellss * The string cellss array to resize. * @@ -302,7 +308,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_cellss_increase_ - extern f_status_t f_type_cellss_increase(f_cellss_t *cellss); + extern f_status_t f_type_cellss_increase(const uint16_t step, f_cellss_t *cellss); #endif // _di_f_type_cellss_increase_ /** @@ -441,6 +447,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param lengths * The string lengths array to resize. * @@ -454,7 +463,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_array_lengths_increase_ - extern f_status_t f_type_array_lengths_increase(f_array_lengths_t *lengths); + extern f_status_t f_type_array_lengths_increase(const uint16_t step, f_array_lengths_t *lengths); #endif // _di_f_type_array_lengths_increase_ /** @@ -615,6 +624,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param lengthss * The string lengthss array to resize. * @@ -628,7 +640,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_array_lengthss_increase_ - extern f_status_t f_type_array_lengthss_increase(f_array_lengthss_t *lengthss); + extern f_status_t f_type_array_lengthss_increase(const uint16_t step, f_array_lengthss_t *lengthss); #endif // _di_f_type_array_lengthss_increase_ /** @@ -767,6 +779,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int8s * The string int8s array to resize. * @@ -780,7 +795,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int8s_increase_ - extern f_status_t f_type_int8s_increase(f_int8s_t *int8s); + extern f_status_t f_type_int8s_increase(const uint16_t step, f_int8s_t *int8s); #endif // _di_f_type_int8s_increase_ /** @@ -941,6 +956,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int8ss * The string int8ss array to resize. * @@ -954,7 +972,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int8ss_increase_ - extern f_status_t f_type_int8ss_increase(f_int8ss_t *int8ss); + extern f_status_t f_type_int8ss_increase(const uint16_t step, f_int8ss_t *int8ss); #endif // _di_f_type_int8ss_increase_ /** @@ -1093,6 +1111,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint8s * The string uint8s array to resize. * @@ -1106,7 +1127,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint8s_increase_ - extern f_status_t f_type_uint8s_increase(f_uint8s_t *uint8s); + extern f_status_t f_type_uint8s_increase(const uint16_t step, f_uint8s_t *uint8s); #endif // _di_f_type_uint8s_increase_ /** @@ -1267,6 +1288,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint8ss * The string uint8ss array to resize. * @@ -1280,7 +1304,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint8ss_increase_ - extern f_status_t f_type_uint8ss_increase(f_uint8ss_t *uint8ss); + extern f_status_t f_type_uint8ss_increase(const uint16_t step, f_uint8ss_t *uint8ss); #endif // _di_f_type_uint8ss_increase_ /** @@ -1419,6 +1443,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int16s * The string int16s array to resize. * @@ -1432,7 +1459,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int16s_increase_ - extern f_status_t f_type_int16s_increase(f_int16s_t *int16s); + extern f_status_t f_type_int16s_increase(const uint16_t step, f_int16s_t *int16s); #endif // _di_f_type_int16s_increase_ /** @@ -1593,6 +1620,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int16ss * The string int16ss array to resize. * @@ -1606,7 +1636,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int16ss_increase_ - extern f_status_t f_type_int16ss_increase(f_int16ss_t *int16ss); + extern f_status_t f_type_int16ss_increase(const uint16_t step, f_int16ss_t *int16ss); #endif // _di_f_type_int16ss_increase_ /** @@ -1745,6 +1775,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint16s * The string uint16s array to resize. * @@ -1758,7 +1791,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint16s_increase_ - extern f_status_t f_type_uint16s_increase(f_uint16s_t *uint16s); + extern f_status_t f_type_uint16s_increase(const uint16_t step, f_uint16s_t *uint16s); #endif // _di_f_type_uint16s_increase_ /** @@ -1919,6 +1952,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint16ss * The string uint16ss array to resize. * @@ -1932,7 +1968,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint16ss_increase_ - extern f_status_t f_type_uint16ss_increase(f_uint16ss_t *uint16ss); + extern f_status_t f_type_uint16ss_increase(const uint16_t step, f_uint16ss_t *uint16ss); #endif // _di_f_type_uint16ss_increase_ /** @@ -2071,6 +2107,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int32s * The string int32s array to resize. * @@ -2084,7 +2123,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int32s_increase_ - extern f_status_t f_type_int32s_increase(f_int32s_t *int32s); + extern f_status_t f_type_int32s_increase(const uint16_t step, f_int32s_t *int32s); #endif // _di_f_type_int32s_increase_ /** @@ -2245,6 +2284,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int32ss * The string int32ss array to resize. * @@ -2258,7 +2300,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int32ss_increase_ - extern f_status_t f_type_int32ss_increase(f_int32ss_t *int32ss); + extern f_status_t f_type_int32ss_increase(const uint16_t step, f_int32ss_t *int32ss); #endif // _di_f_type_int32ss_increase_ /** @@ -2397,6 +2439,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint32s * The string uint32s array to resize. * @@ -2410,7 +2455,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint32s_increase_ - extern f_status_t f_type_uint32s_increase(f_uint32s_t *uint32s); + extern f_status_t f_type_uint32s_increase(const uint16_t step, f_uint32s_t *uint32s); #endif // _di_f_type_uint32s_increase_ /** @@ -2571,6 +2616,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint32ss * The string uint32ss array to resize. * @@ -2584,7 +2632,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint32ss_increase_ - extern f_status_t f_type_uint32ss_increase(f_uint32ss_t *uint32ss); + extern f_status_t f_type_uint32ss_increase(const uint16_t step, f_uint32ss_t *uint32ss); #endif // _di_f_type_uint32ss_increase_ /** @@ -2723,6 +2771,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int64s * The string int64s array to resize. * @@ -2736,7 +2787,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int64s_increase_ - extern f_status_t f_type_int64s_increase(f_int64s_t *int64s); + extern f_status_t f_type_int64s_increase(const uint16_t step, f_int64s_t *int64s); #endif // _di_f_type_int64s_increase_ /** @@ -2897,6 +2948,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int64ss * The string int64ss array to resize. * @@ -2910,7 +2964,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int64ss_increase_ - extern f_status_t f_type_int64ss_increase(f_int64ss_t *int64ss); + extern f_status_t f_type_int64ss_increase(const uint16_t step, f_int64ss_t *int64ss); #endif // _di_f_type_int64ss_increase_ /** @@ -3049,6 +3103,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint64s * The string uint64s array to resize. * @@ -3062,7 +3119,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint64s_increase_ - extern f_status_t f_type_uint64s_increase(f_uint64s_t *uint64s); + extern f_status_t f_type_uint64s_increase(const uint16_t step, f_uint64s_t *uint64s); #endif // _di_f_type_uint64s_increase_ /** @@ -3223,6 +3280,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint64ss * The string uint64ss array to resize. * @@ -3236,7 +3296,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint64ss_increase_ - extern f_status_t f_type_uint64ss_increase(f_uint64ss_t *uint64ss); + extern f_status_t f_type_uint64ss_increase(const uint16_t step, f_uint64ss_t *uint64ss); #endif // _di_f_type_uint64ss_increase_ /** @@ -3375,6 +3435,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int128s * The string int128s array to resize. * @@ -3388,7 +3451,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int128s_increase_ - extern f_status_t f_type_int128s_increase(f_int128s_t *int128s); + extern f_status_t f_type_int128s_increase(const uint16_t step, f_int128s_t *int128s); #endif // _di_f_type_int128s_increase_ /** @@ -3549,6 +3612,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param int128ss * The string int128ss array to resize. * @@ -3562,7 +3628,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_int128ss_increase_ - extern f_status_t f_type_int128ss_increase(f_int128ss_t *int128ss); + extern f_status_t f_type_int128ss_increase(const uint16_t step, f_int128ss_t *int128ss); #endif // _di_f_type_int128ss_increase_ /** @@ -3701,6 +3767,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint128s * The string uint128s array to resize. * @@ -3714,7 +3783,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint128s_increase_ - extern f_status_t f_type_uint128s_increase(f_uint128s_t *uint128s); + extern f_status_t f_type_uint128s_increase(const uint16_t step, f_uint128s_t *uint128s); #endif // _di_f_type_uint128s_increase_ /** @@ -3875,6 +3944,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param uint128ss * The string uint128ss array to resize. * @@ -3888,7 +3960,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_type_uint128ss_increase_ - extern f_status_t f_type_uint128ss_increase(f_uint128ss_t *uint128ss); + extern f_status_t f_type_uint128ss_increase(const uint16_t step, f_uint128ss_t *uint128ss); #endif // _di_f_type_uint128ss_increase_ /** diff --git a/level_0/f_utf/c/utf_dynamic.c b/level_0/f_utf/c/utf_dynamic.c index ed18677..66fa497 100644 --- a/level_0/f_utf/c/utf_dynamic.c +++ b/level_0/f_utf/c/utf_dynamic.c @@ -157,13 +157,14 @@ extern "C" { #endif // _di_f_utf_string_dynamic_decrease_by_ #ifndef _di_f_utf_string_dynamic_increase_ - f_status_t f_utf_string_dynamic_increase(f_utf_string_dynamic_t *dynamic) { + f_status_t f_utf_string_dynamic_increase(const uint16_t step, f_utf_string_dynamic_t *dynamic) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (dynamic->used + 1 > dynamic->size) { - f_array_length_t size = dynamic->used + f_memory_default_allocation_step; + f_array_length_t size = dynamic->used + step; if (size > f_array_length_t_size) { if (dynamic->used + 1 > f_array_length_t_size) { @@ -938,13 +939,14 @@ extern "C" { #endif // _di_f_utf_string_dynamics_decrease_by_ #ifndef _di_f_utf_string_dynamics_increase_ - f_status_t f_utf_string_dynamics_increase(f_utf_string_dynamics_t *dynamics) { + f_status_t f_utf_string_dynamics_increase(const uint16_t step, f_utf_string_dynamics_t *dynamics) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (dynamics->used + 1 > dynamics->size) { - f_array_length_t size = dynamics->used + f_memory_default_allocation_step; + f_array_length_t size = dynamics->used + step; if (size > f_array_length_t_size) { if (dynamics->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_utf/c/utf_dynamic.h b/level_0/f_utf/c/utf_dynamic.h index 8a7eda4..6402d44 100644 --- a/level_0/f_utf/c/utf_dynamic.h +++ b/level_0/f_utf/c/utf_dynamic.h @@ -73,7 +73,7 @@ extern "C" { #define macro_f_utf_string_dynamic_t_delete_simple(dynamic) f_utf_string_dynamic_resize(0, &dynamic); #define macro_f_utf_string_dynamic_t_destroy_simple(dynamic) f_utf_string_dynamic_adjust(0, &dynamic); - #define macro_f_utf_string_dynamic_t_increase(status, dynamic) status = f_utf_string_dynamic_increase(&dynamic); + #define macro_f_utf_string_dynamic_t_increase(status, step, dynamic) status = f_utf_string_dynamic_increase(step, &dynamic); #define macro_f_utf_string_dynamic_t_increase_by(status, dynamic, amount) status = f_utf_string_dynamic_increase_by(amount, &dynamic); #define macro_f_utf_string_dynamic_t_decrease_by(status, dynamic, amount) status = f_utf_string_dynamic_decrease_by(amount, &dynamic); #define macro_f_utf_string_dynamic_t_decimate_by(status, dynamic, amount) status = f_utf_string_dynamic_decimate_by(amount, &dynamic); @@ -287,8 +287,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * - * @param amount - * A positive number representing how much to increase the size by. + * @param step + * The allocation step to use. + * Must be greater than 0. * @param dynamic * The string to resize. * @@ -302,7 +303,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_increase_ - extern f_status_t f_utf_string_dynamic_increase(f_utf_string_dynamic_t *dynamic); + extern f_status_t f_utf_string_dynamic_increase(const uint16_t step, f_utf_string_dynamic_t *dynamic); #endif // _di_f_utf_string_dynamic_increase_ /** @@ -1118,6 +1119,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param dynamics * The array to resize. * @@ -1131,7 +1135,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamics_increase_ - extern f_status_t f_utf_string_dynamics_increase(f_utf_string_dynamics_t *dynamics); + extern f_status_t f_utf_string_dynamics_increase(const uint16_t step, f_utf_string_dynamics_t *dynamics); #endif // _di_f_utf_string_dynamics_increase_ /** diff --git a/level_0/f_utf/c/utf_map.c b/level_0/f_utf/c/utf_map.c index 68e12ff..04eb898 100644 --- a/level_0/f_utf/c/utf_map.c +++ b/level_0/f_utf/c/utf_map.c @@ -79,13 +79,14 @@ extern "C" { #endif // _di_f_utf_string_map_multis_decrease_by_ #ifndef _di_f_utf_string_map_multis_increase_ - f_status_t f_utf_string_map_multis_increase(f_utf_string_map_multis_t *map_multis) { + f_status_t f_utf_string_map_multis_increase(const uint16_t step, f_utf_string_map_multis_t *map_multis) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!map_multis) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (map_multis->used + 1 > map_multis->size) { - f_array_length_t size = map_multis->used + f_memory_default_allocation_step; + f_array_length_t size = map_multis->used + step; if (size > f_array_length_t_size) { if (map_multis->used + 1 > f_array_length_t_size) { @@ -207,13 +208,14 @@ extern "C" { #endif // _di_f_utf_string_maps_decrease_by_ #ifndef _di_f_utf_string_maps_increase_ - f_status_t f_utf_string_maps_increase(f_utf_string_maps_t *maps) { + f_status_t f_utf_string_maps_increase(const uint16_t step, f_utf_string_maps_t *maps) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (maps->used + 1 > maps->size) { - f_array_length_t size = maps->used + f_memory_default_allocation_step; + f_array_length_t size = maps->used + step; if (size > f_array_length_t_size) { if (maps->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_utf/c/utf_map.h b/level_0/f_utf/c/utf_map.h index f2fca21..694b041 100644 --- a/level_0/f_utf/c/utf_map.h +++ b/level_0/f_utf/c/utf_map.h @@ -224,6 +224,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param map_multis * The map_multis array to resize. * @@ -237,7 +240,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_map_multis_increase_ - extern f_status_t f_utf_string_map_multis_increase(f_utf_string_map_multis_t *map_multis); + extern f_status_t f_utf_string_map_multis_increase(const uint16_t step, f_utf_string_map_multis_t *map_multis); #endif // _di_f_utf_string_map_multis_increase_ /** @@ -376,6 +379,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param maps * The string maps array to resize. * @@ -389,7 +395,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_maps_increase_ - extern f_status_t f_utf_string_maps_increase(f_utf_string_maps_t *maps); + extern f_status_t f_utf_string_maps_increase(const uint16_t step, f_utf_string_maps_t *maps); #endif // _di_f_utf_string_maps_increase_ /** diff --git a/level_0/f_utf/c/utf_quantity.c b/level_0/f_utf/c/utf_quantity.c index 5663c14..2edd524 100644 --- a/level_0/f_utf/c/utf_quantity.c +++ b/level_0/f_utf/c/utf_quantity.c @@ -71,13 +71,14 @@ extern "C" { #endif // _di_f_utf_string_quantitys_decrease_by_ #ifndef _di_f_utf_string_quantitys_increase_ - f_status_t f_utf_string_quantitys_increase(f_utf_string_quantitys_t *quantitys) { + f_status_t f_utf_string_quantitys_increase(const uint16_t step, f_utf_string_quantitys_t *quantitys) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (quantitys->used + 1 > quantitys->size) { - f_array_length_t size = quantitys->used + f_memory_default_allocation_step; + f_array_length_t size = quantitys->used + step; if (size > f_array_length_t_size) { if (quantitys->used + 1 > f_array_length_t_size) { @@ -164,13 +165,14 @@ extern "C" { #endif // _di_f_utf_string_quantityss_decrease_by_ #ifndef _di_f_utf_string_quantityss_increase_ - f_status_t f_utf_string_quantityss_increase(f_utf_string_quantityss_t *quantityss) { + f_status_t f_utf_string_quantityss_increase(const uint16_t step, f_utf_string_quantityss_t *quantityss) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (quantityss->used + 1 > quantityss->size) { - f_array_length_t size = quantityss->used + f_memory_default_allocation_step; + f_array_length_t size = quantityss->used + step; if (size > f_array_length_t_size) { if (quantityss->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_utf/c/utf_quantity.h b/level_0/f_utf/c/utf_quantity.h index da97780..bc1445f 100644 --- a/level_0/f_utf/c/utf_quantity.h +++ b/level_0/f_utf/c/utf_quantity.h @@ -190,6 +190,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param quantitys * The string quantitys array to resize. * @@ -202,7 +205,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_quantitys_increase_ - extern f_status_t f_utf_string_quantitys_increase(f_utf_string_quantitys_t *quantitys); + extern f_status_t f_utf_string_quantitys_increase(const uint16_t step, f_utf_string_quantitys_t *quantitys); #endif // _di_f_utf_string_quantitys_increase_ /** @@ -319,6 +322,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param quantityss * The string quantityss array to resize. * @@ -332,7 +338,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_quantityss_increase_ - extern f_status_t f_utf_string_quantityss_increase(f_utf_string_quantityss_t *quantityss); + extern f_status_t f_utf_string_quantityss_increase(const uint16_t step, f_utf_string_quantityss_t *quantityss); #endif // _di_f_utf_string_quantityss_increase_ /** diff --git a/level_0/f_utf/c/utf_range.c b/level_0/f_utf/c/utf_range.c index d37e917..ee43d86 100644 --- a/level_0/f_utf/c/utf_range.c +++ b/level_0/f_utf/c/utf_range.c @@ -71,13 +71,14 @@ extern "C" { #endif // _di_f_utf_string_ranges_decrease_by_ #ifndef _di_f_utf_string_ranges_increase_ - f_status_t f_utf_string_ranges_increase(f_utf_string_ranges_t *ranges) { + f_status_t f_utf_string_ranges_increase(const uint16_t step, f_utf_string_ranges_t *ranges) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (ranges->used + 1 > ranges->size) { - f_array_length_t size = ranges->used + f_memory_default_allocation_step; + f_array_length_t size = ranges->used + step; if (size > f_array_length_t_size) { if (ranges->used + 1 > f_array_length_t_size) { @@ -164,13 +165,14 @@ extern "C" { #endif // _di_f_utf_string_rangess_decrease_by_ #ifndef _di_f_utf_string_rangess_increase_ - f_status_t f_utf_string_rangess_increase(f_utf_string_rangess_t *rangess) { + f_status_t f_utf_string_rangess_increase(const uint16_t step, f_utf_string_rangess_t *rangess) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (rangess->used + 1 > rangess->size) { - f_array_length_t size = rangess->used + f_memory_default_allocation_step; + f_array_length_t size = rangess->used + step; if (size > f_array_length_t_size) { if (rangess->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_utf/c/utf_range.h b/level_0/f_utf/c/utf_range.h index 94e78dd..2281b62 100644 --- a/level_0/f_utf/c/utf_range.h +++ b/level_0/f_utf/c/utf_range.h @@ -208,7 +208,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_ranges_increase_ - extern f_status_t f_utf_string_ranges_increase(f_utf_string_ranges_t *ranges); + extern f_status_t f_utf_string_ranges_increase(const uint16_t step, f_utf_string_ranges_t *ranges); #endif // _di_f_utf_string_ranges_increase_ /** @@ -339,7 +339,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_rangess_increase_ - extern f_status_t f_utf_string_rangess_increase(f_utf_string_rangess_t *rangess); + extern f_status_t f_utf_string_rangess_increase(const uint16_t step, f_utf_string_rangess_t *rangess); #endif // _di_f_utf_string_rangess_increase_ /** diff --git a/level_0/f_utf/c/utf_triple.c b/level_0/f_utf/c/utf_triple.c index 95a09ac..7929799 100644 --- a/level_0/f_utf/c/utf_triple.c +++ b/level_0/f_utf/c/utf_triple.c @@ -89,13 +89,14 @@ extern "C" { #endif // _di_f_utf_string_triples_decrease_by_ #ifndef _di_f_utf_string_triples_increase_ - f_status_t f_utf_string_triples_increase(f_utf_string_triples_t *triples) { + f_status_t f_utf_string_triples_increase(const uint16_t step, f_utf_string_triples_t *triples) { #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (triples->used + 1 > triples->size) { - f_array_length_t size = triples->used + f_memory_default_allocation_step; + f_array_length_t size = triples->used + step; if (size > f_array_length_t_size) { if (triples->used + 1 > f_array_length_t_size) { diff --git a/level_0/f_utf/c/utf_triple.h b/level_0/f_utf/c/utf_triple.h index ae068ed..9315f83 100644 --- a/level_0/f_utf/c/utf_triple.h +++ b/level_0/f_utf/c/utf_triple.h @@ -176,6 +176,9 @@ extern "C" { * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). * If already set to the maximum buffer size, then the resize will fail. * + * @param step + * The allocation step to use. + * Must be greater than 0. * @param triples * The string triples array to resize. * @@ -189,7 +192,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_triples_increase_ - extern f_status_t f_utf_string_triples_increase(f_utf_string_triples_t *triples); + extern f_status_t f_utf_string_triples_increase(const uint16_t step, f_utf_string_triples_t *triples); #endif // _di_f_utf_string_triples_increase_ /** diff --git a/level_1/fl_directory/c/directory.h b/level_1/fl_directory/c/directory.h index faf4547..32bdd52 100644 --- a/level_1/fl_directory/c/directory.h +++ b/level_1/fl_directory/c/directory.h @@ -32,8 +32,8 @@ // fll-0 includes #include #include -#include #include +#include #include #include #include diff --git a/level_1/fl_directory/c/private-directory.c b/level_1/fl_directory/c/private-directory.c index b8d25b4..91868d6 100644 --- a/level_1/fl_directory/c/private-directory.c +++ b/level_1/fl_directory/c/private-directory.c @@ -164,7 +164,7 @@ extern "C" { const f_status_t status_failure = status; - macro_f_memory_structure_increment(status, (*recurse.failures), 1, f_memory_default_allocation_step, macro_f_directory_statuss_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*recurse.failures), 1, f_memory_default_allocation_small, macro_f_directory_statuss_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; f_directory_status_t failure = f_directory_status_t_initialize; @@ -369,7 +369,7 @@ extern "C" { const f_status_t status_failure = status; - macro_f_memory_structure_increment(status, (*recurse.failures), 1, f_memory_default_allocation_step, macro_f_directory_statuss_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*recurse.failures), 1, f_memory_default_allocation_small, macro_f_directory_statuss_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; f_directory_status_t failure = f_directory_status_t_initialize; diff --git a/level_1/fl_environment/c/environment.c b/level_1/fl_environment/c/environment.c index 1c45df9..8da70b0 100644 --- a/level_1/fl_environment/c/environment.c +++ b/level_1/fl_environment/c/environment.c @@ -15,7 +15,7 @@ extern "C" { return F_data_not; } - f_status_t status = f_string_maps_increase(environment); + f_status_t status = f_string_maps_increase(f_memory_default_allocation_small, environment); if (F_status_is_error(status)) return status; environment->array[environment->used].name.used = 0; @@ -102,7 +102,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Append an equivalent representation of PWD (string used length is 0). - macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; macro_f_string_dynamic_t_clear(paths->array[paths->used]); @@ -118,7 +118,7 @@ extern "C" { for (i = 0; i <= length; ++i) { if (i == length || path[i] == f_path_separator_variable_s[0]) { - macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (!i) { @@ -178,7 +178,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; macro_f_string_dynamic_t_clear(paths->array[paths->used]); @@ -197,7 +197,7 @@ extern "C" { for (i = 0; i <= path.used; ++i) { if (i == path.used || path.string[i] == f_path_separator_variable_s[0]) { - macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (!i) { @@ -258,7 +258,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; paths->array[paths->used].string = 0; @@ -279,7 +279,7 @@ extern "C" { for (; i > 0; --i, --j) { if (!j || path[j] == f_path_separator_variable_s[0]) { - macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (path[j] == f_path_separator_variable_s[0]) { @@ -355,7 +355,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; macro_f_string_dynamic_t_clear(paths->array[paths->used]); @@ -376,7 +376,7 @@ extern "C" { for (; i > 0; --i, --j) { if (!j || path.string[j] == f_path_separator_variable_s[0]) { - macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*paths), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (path.string[j] == f_path_separator_variable_s[0]) { diff --git a/level_1/fl_fss/c/fss_basic.c b/level_1/fl_fss/c/fss_basic.c index 592cde4..676bf94 100644 --- a/level_1/fl_fss/c/fss_basic.c +++ b/level_1/fl_fss/c/fss_basic.c @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef _di_fl_fss_basic_object_read_ - f_status_t fl_fss_basic_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote, f_fss_delimits_t *delimits) { + f_status_t fl_fss_basic_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote, f_fss_delimits_t *delimits) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -16,7 +16,7 @@ extern "C" { const f_array_length_t delimits_used = delimits->used; - f_status_t status = private_fl_fss_basic_read(buffer, F_true, range, found, quote, delimits); + f_status_t status = private_fl_fss_basic_read(buffer, F_true, state, range, found, quote, delimits); if (F_status_is_error(status)) { delimits->used = delimits_used; @@ -29,7 +29,7 @@ extern "C" { #endif // _di_fl_fss_basic_object_read_ #ifndef _di_fl_fss_basic_content_read_ - f_status_t fl_fss_basic_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits) { + f_status_t fl_fss_basic_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -53,15 +53,24 @@ extern "C" { return F_data_not_stop; } - macro_f_fss_content_t_increase(status, (*found)) + macro_f_fss_content_t_increase(status, state.step_small, (*found)) if (F_status_is_error(status)) return status; found->array[found->used].start = range->start; for (;; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + status = f_fss_skip_past_delimit(buffer, range); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; if (status == F_none_eos || status == F_none_stop) { return status; @@ -70,6 +79,10 @@ extern "C" { if (buffer.string[range->start] == f_fss_basic_close) break; } // for + if (F_status_is_error(status)) { + return status; + } + found->array[found->used++].stop = range->start - 1; status = f_utf_buffer_increment(buffer, range, 1); @@ -80,7 +93,7 @@ extern "C" { #endif // _di_fl_fss_basic_content_read_ #ifndef _di_fl_fss_basic_object_write_string_ - f_status_t fl_fss_basic_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_basic_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -88,7 +101,7 @@ extern "C" { const f_array_length_t destination_used = destination->used; - f_status_t status = private_fl_fss_basic_write(F_true, object, quote ? quote : f_fss_delimit_quote_double, range, destination); + f_status_t status = private_fl_fss_basic_write(F_true, object, quote ? quote : f_fss_delimit_quote_double, state, range, destination); if (status == F_data_not_stop || status == F_data_not_eos) { @@ -110,7 +123,7 @@ extern "C" { f_status_t status2 = F_none; if (complete == f_fss_complete_full_trim) { - status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_delimit_quote_double, destination_used, destination); + status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_delimit_quote_double, destination_used, state, destination); if (F_status_is_error(status2)) { destination->used = destination_used; @@ -119,7 +132,7 @@ extern "C" { } } - status2 = f_string_dynamic_increase(destination); + status2 = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status2)) { destination->used = destination_used; @@ -139,7 +152,7 @@ extern "C" { #endif // _di_fl_fss_basic_object_write_string_ #ifndef _di_fl_fss_basic_content_write_string_ - f_status_t fl_fss_basic_content_write_string(const f_string_static_t content, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_basic_content_write_string(const f_string_static_t content, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -154,7 +167,7 @@ extern "C" { // content should be terminated, even if empty. if (complete == f_fss_complete_full || complete == f_fss_complete_full_trim || complete == f_fss_complete_end) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) return status; destination->string[destination->used++] = f_fss_basic_close; @@ -175,6 +188,14 @@ extern "C" { for (; range->start <= range->stop && range->start < content.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + if (content.string[range->start] == f_fss_eol) { destination->used = destination_used; diff --git a/level_1/fl_fss/c/fss_basic.h b/level_1/fl_fss/c/fss_basic.h index 7901177..9f7b007 100644 --- a/level_1/fl_fss/c/fss_basic.h +++ b/level_1/fl_fss/c/fss_basic.h @@ -37,6 +37,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -61,6 +70,7 @@ extern "C" { * F_terminated_not_group_eos if EOS was reached before the a group termination was reached. * F_terminated_not_group_stop if stop point was reached before the a group termination was reached. * + * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_utf_buffer_increment(). @@ -72,7 +82,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_basic_object_read_ - extern f_status_t fl_fss_basic_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote, f_fss_delimits_t *delimits); + extern f_status_t fl_fss_basic_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote, f_fss_delimits_t *delimits); #endif // _di_fl_fss_basic_object_read_ /** @@ -82,6 +92,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -102,6 +121,7 @@ extern "C" { * F_terminated_not_group_eos if EOS was reached before the a group termination was reached. * F_terminated_not_group_stop if stop point was reached before the a group termination was reached. * + * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_utf_buffer_increment(). @@ -109,7 +129,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_basic_content_read_ - extern f_status_t fl_fss_basic_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits); + extern f_status_t fl_fss_basic_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits); #endif // _di_fl_fss_basic_content_read_ /** @@ -132,6 +152,15 @@ extern "C" { * If f_fss_complete_full_trim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object (inside the quotes). * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object. * If f_fss_complete_partial_tim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object (inside the quotes). + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the object string to write as an object. * @param destination @@ -145,6 +174,7 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. @@ -155,7 +185,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_basic_object_write_string_ - extern f_status_t fl_fss_basic_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_basic_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_basic_object_write_string_ /** @@ -174,6 +204,15 @@ extern "C" { * If f_fss_complete_end, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. * If f_fss_complete_partial, this will write any appropriate open and close aspects of this content, except for the final newline. * If f_fss_complete_full, this will write any appropriate open and close aspects of this content, including the final newline. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the content string to write as an content. * @param destination @@ -185,13 +224,14 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if appended string length is too large to store in the destination. */ #ifndef _di_fl_fss_basic_content_write_string_ - extern f_status_t fl_fss_basic_content_write_string(const f_string_static_t content, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_basic_content_write_string(const f_string_static_t content, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_basic_content_write_string_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/fss_basic_list.c b/level_1/fl_fss/c/fss_basic_list.c index 301d1c2..d47af1e 100644 --- a/level_1/fl_fss/c/fss_basic_list.c +++ b/level_1/fl_fss/c/fss_basic_list.c @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef _di_fl_fss_basic_list_object_read_ - f_status_t fl_fss_basic_list_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits) { + f_status_t fl_fss_basic_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -68,12 +68,30 @@ extern "C" { // identify where the object ends. while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_delimit_slash) { slash_first = range->start; slash_count = 1; for (range->start++; range->start <= range->stop && range->start < buffer.used; range->start++) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_delimit_placeholder) { continue; } else if (buffer.string[range->start] != f_fss_delimit_slash) { @@ -94,6 +112,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_space(buffer, *range); @@ -151,7 +178,7 @@ extern "C" { graph_first = F_false; // comments may only have whitespace before the '#', therefore only the first slash needs to be delimited. - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = slash_first; @@ -172,6 +199,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_space(buffer, *range); @@ -234,7 +270,7 @@ extern "C" { #endif // _di_fl_fss_basic_list_object_read_ #ifndef _di_fl_fss_basic_list_content_read_ - f_status_t fl_fss_basic_list_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments) { + f_status_t fl_fss_basic_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -250,7 +286,7 @@ extern "C" { private_macro_fl_fss_content_with_comments_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, F_none_eos, F_none_stop); - macro_f_fss_content_t_increase(status, (*found)) + macro_f_fss_content_t_increase(status, state.step_small, (*found)) if (F_status_is_error(status)) return status; found->array[found->used].start = range->start; @@ -266,9 +302,18 @@ extern "C" { // identify where the content ends. while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) { if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -287,6 +332,15 @@ extern "C" { for (++range->start; range->start <= range->stop && range->start < buffer.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_delimit_placeholder) { continue; } else if (buffer.string[range->start] != f_fss_delimit_slash) { @@ -304,6 +358,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_space(buffer, *range); @@ -348,7 +411,7 @@ extern "C" { if (F_status_is_error(status)) break; if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -373,6 +436,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_space(buffer, *range); @@ -405,7 +477,7 @@ extern "C" { if (buffer.string[range->start] == f_fss_eol) { if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -424,7 +496,7 @@ extern "C" { status = f_fss_seek_to_eol(buffer, range); if (F_status_is_error(status)) break; - macro_f_fss_comments_t_increase(status, (*comments)) + macro_f_fss_comments_t_increase(status, state.step_small, (*comments)) if (F_status_is_error(status)) break; if (range->start > range->stop || range->start >= buffer.used) { @@ -468,7 +540,7 @@ extern "C" { #endif // _di_fl_fss_basic_list_content_read_ #ifndef _di_fl_fss_basic_list_object_write_string_ - f_status_t fl_fss_basic_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_basic_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -509,10 +581,19 @@ extern "C" { // find the first graph character. while (range->start <= range->stop && range->start < object.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_comment) { // when a comment is found, escape it. - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = f_fss_delimit_slash; @@ -558,10 +639,28 @@ extern "C" { while (range->start <= range->stop && range->start < object.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_delimit_slash) { slash_count = 1; - for (range->start++; range->start <= range->stop && range->start < object.used; range->start++) { + for (++range->start; range->start <= range->stop && range->start < object.used; ++range->start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } if (object.string[range->start] == f_fss_delimit_placeholder) { continue; @@ -620,7 +719,7 @@ extern "C" { if (complete == f_fss_complete_partial || complete == f_fss_complete_partial_trim || complete == f_fss_complete_full || complete == f_fss_complete_full_trim) { if (complete == f_fss_complete_full_trim) { - status = private_fl_fss_basic_list_write_object_trim(used_start, destination); + status = private_fl_fss_basic_list_write_object_trim(used_start, state, destination); if (F_status_is_error(status)) { destination->used = used_start; @@ -657,7 +756,7 @@ extern "C" { #endif // _di_fl_fss_basic_list_object_write_string_ #ifndef _di_fl_fss_basic_list_content_write_string_ - f_status_t fl_fss_basic_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_basic_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -668,7 +767,7 @@ extern "C" { if (status == F_none_stop || status == F_none_eos) { if (complete == f_fss_complete_full || complete == f_fss_complete_full_trim || complete == f_fss_complete_end) { - const f_status_t status_allocation = f_string_dynamic_increase(destination); + const f_status_t status_allocation = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status_allocation)) return status_allocation; destination->string[destination->used++] = f_fss_basic_list_close; @@ -699,6 +798,15 @@ extern "C" { while (range->start <= range->stop && range->start < content.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (content.string[range->start] == f_fss_delimit_slash && !is_comment) { slash_count = 1; @@ -714,6 +822,15 @@ extern "C" { for (range->start++; range->start <= range->stop && range->start < content.used; range->start++) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (content.string[range->start] == f_fss_delimit_placeholder) continue; if (content.string[range->start] != f_fss_delimit_slash) break; @@ -742,13 +859,13 @@ extern "C" { range->start = start + 1; - status = private_fl_fss_basic_list_write_add_until_end(content, range, destination); + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; continue; } - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = f_fss_basic_list_open; @@ -782,13 +899,13 @@ extern "C" { range->start = start + 1; - status = private_fl_fss_basic_list_write_add_until_end(content, range, destination); + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; continue; } - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = f_fss_basic_list_open; @@ -846,7 +963,7 @@ extern "C" { } if (complete == f_fss_complete_full || complete == f_fss_complete_full_trim || complete == f_fss_complete_end) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) return status; // check to see if a newline exists, at the end. diff --git a/level_1/fl_fss/c/fss_basic_list.h b/level_1/fl_fss/c/fss_basic_list.h index 1fb1864..f877a35 100644 --- a/level_1/fl_fss/c/fss_basic_list.h +++ b/level_1/fl_fss/c/fss_basic_list.h @@ -38,6 +38,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -62,6 +71,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -73,7 +83,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_basic_list_object_read_ - extern f_status_t fl_fss_basic_list_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits); + extern f_status_t fl_fss_basic_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits); #endif // _di_fl_fss_basic_list_object_read_ /** @@ -83,6 +93,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -111,6 +130,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -122,7 +142,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_basic_list_content_read_ - extern f_status_t fl_fss_basic_list_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments); + extern f_status_t fl_fss_basic_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments); #endif // _di_fl_fss_basic_list_content_read_ /** @@ -142,6 +162,15 @@ extern "C" { * If f_fss_complete_full_trim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object. * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object. * If f_fss_complete_partial_tim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the object string to write as an object. * @param destination @@ -155,6 +184,7 @@ extern "C" { * F_none_stop on success after reaching stopping point. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. @@ -163,7 +193,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_basic_list_object_write_string_ - extern f_status_t fl_fss_basic_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_basic_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_basic_list_object_write_string_ /** @@ -186,6 +216,15 @@ extern "C" { * A string of whitespace to prepend at the start of each line. * This should only be whitespace, anything else could product invalid content. * Set the pointer address to 0 to disable. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the content string to write as an content. * @param destination @@ -200,6 +239,7 @@ extern "C" { * F_none_stop on success after reaching stopping point . * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -207,7 +247,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_basic_list_content_write_string_ - extern f_status_t fl_fss_basic_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_basic_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_basic_list_content_write_string_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/fss_embedded_list.c b/level_1/fl_fss/c/fss_embedded_list.c index a6b7b14..3fdcc34 100644 --- a/level_1/fl_fss/c/fss_embedded_list.c +++ b/level_1/fl_fss/c/fss_embedded_list.c @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef _di_fl_fss_embedded_list_object_read_ - f_status_t fl_fss_embedded_list_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits) { + f_status_t fl_fss_embedded_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -53,6 +53,7 @@ extern "C" { if (F_status_is_error(status)) { delimits->used = delimits_used; + return status; } @@ -80,6 +81,15 @@ extern "C" { // identify where the object ends. while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_delimit_slash) { slash_first = range->start; slash_count = 1; @@ -89,6 +99,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder || buffer.string[range->start] == f_fss_delimit_slash)) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_delimit_slash) slash_count++; status = f_utf_buffer_increment(buffer, range, 1); @@ -106,6 +125,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_graph(buffer, *range); @@ -159,7 +187,7 @@ extern "C" { graph_first = F_false; // comments may only have whitespace before the '#', therefore only the first slash needs to be delimited. - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = slash_first; @@ -180,6 +208,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_space(buffer, *range); @@ -227,6 +264,15 @@ extern "C" { // seek to the end of the line when no valid object is found. while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) { @@ -251,7 +297,7 @@ extern "C" { #endif // _di_fl_fss_embedded_list_object_read_ #ifndef _di_fl_fss_embedded_list_content_read_ - f_status_t fl_fss_embedded_list_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_nest_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments) { + f_status_t fl_fss_embedded_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_nest_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -266,19 +312,19 @@ extern "C" { return status; } - macro_f_fss_nest_t_increase(status, (*found)); + macro_f_fss_nest_t_increase(status, state.step_small, (*found)); if (F_status_is_error(status)) return status; f_array_lengths_t positions_start = f_array_lengths_t_initialize; macro_f_array_lengths_t_clear(positions_start) - macro_f_array_lengths_t_resize(status, positions_start, f_fss_default_allocation_step) + macro_f_array_lengths_t_resize(status, positions_start, state.step_small) if (F_status_is_error(status)) return status; f_fss_objects_t objects = f_fss_objects_t_initialize; macro_f_fss_objects_t_clear(objects) - macro_f_fss_objects_t_resize(status, objects, f_fss_default_allocation_step) + macro_f_fss_objects_t_resize(status, objects, state.step_small) if (F_status_is_error(status)) { macro_f_array_lengths_t_delete_simple(positions_start); @@ -314,9 +360,18 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) { if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -349,6 +404,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder || buffer.string[range->start] == f_fss_delimit_slash)) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + position_previous = range->start; if (buffer.string[range->start] == f_fss_delimit_slash) { @@ -375,7 +439,7 @@ extern "C" { // When slash is odd and a (delimited) valid open/close is found, then save delimited positions and continue. if (buffer.string[range->start] == f_fss_eol) { if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -399,9 +463,18 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) { if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -475,7 +548,7 @@ extern "C" { ++depth; if (depth > positions_start.size) { - macro_f_array_lengths_t_resize(status, positions_start, positions_start.size + f_fss_default_allocation_step); + macro_f_array_lengths_t_resize(status, positions_start, positions_start.size + state.step_small); if (F_status_is_error(status)) break; } @@ -490,7 +563,7 @@ extern "C" { } } else { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = slash_last; @@ -517,6 +590,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; if (buffer.string[range->start] != f_fss_delimit_placeholder) { @@ -545,10 +627,10 @@ extern "C" { depth++; if (depth >= positions_start.size) { - macro_f_array_lengths_t_resize(status, positions_start, positions_start.size + f_fss_default_allocation_step); + macro_f_array_lengths_t_resize(status, positions_start, positions_start.size + state.step_small); if (F_status_is_error(status)) break; - macro_f_fss_objects_t_resize(status, objects, objects.size + f_fss_default_allocation_step); + macro_f_fss_objects_t_resize(status, objects, objects.size + state.step_small); if (F_status_is_error(status)) break; } @@ -562,7 +644,7 @@ extern "C" { objects.array[depth].stop = before_list_open; if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -579,7 +661,7 @@ extern "C" { if (F_status_is_error(status)) break; if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -591,6 +673,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) { newline_last = range->start; line_start = range->start + 1; @@ -618,6 +709,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + position_previous = range->start; status = f_utf_buffer_increment(buffer, range, 1); @@ -647,11 +747,11 @@ extern "C" { } if (buffer.string[range->start] == f_fss_eol) { - macro_f_fss_nest_t_increase(status, (*found)); + macro_f_fss_nest_t_increase(status, state.step_small, (*found)); if (F_status_is_error(status)) break; if (found->depth[depth].used == found->depth[depth].size) { - macro_f_fss_items_t_resize(status, found->depth[depth], found->depth[depth].size + f_fss_default_allocation_step); + macro_f_fss_items_t_resize(status, found->depth[depth], found->depth[depth].size + state.step_small); if (F_status_is_error(status)) break; } @@ -683,7 +783,7 @@ extern "C" { } if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -712,9 +812,18 @@ extern "C" { // No valid object close found, seek until EOL. while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) { if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -748,7 +857,7 @@ extern "C" { status = f_fss_seek_to_eol(buffer, range); if (F_status_is_error(status)) break; - macro_f_fss_comments_t_increase(status, (*comments)) + macro_f_fss_comments_t_increase(status, state.step_small, (*comments)) if (F_status_is_error(status)) break; if (range->start > range->stop || range->start >= buffer.used) { @@ -756,7 +865,7 @@ extern "C" { } else { if (graph_first == 0x2) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = comment_delimit; @@ -825,7 +934,7 @@ extern "C" { #endif // _di_fl_fss_embedded_list_content_read_ #ifndef _di_fl_fss_embedded_list_object_write_string_ - f_status_t fl_fss_embedded_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_embedded_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -871,10 +980,19 @@ extern "C" { // find the first graph character. while (range->start <= range->stop && range->start < object.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_comment) { // when a comment is found, escape it. - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = f_fss_delimit_slash; @@ -920,11 +1038,29 @@ extern "C" { while (range->start <= range->stop && range->start < object.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_delimit_slash) { slash_count = 1; for (++range->start; range->start <= range->stop && range->start < object.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_delimit_placeholder) { continue; } else if (object.string[range->start] != f_fss_delimit_slash) { @@ -988,7 +1124,7 @@ extern "C" { if (complete == f_fss_complete_partial || complete == f_fss_complete_partial_trim || complete == f_fss_complete_full || complete == f_fss_complete_full_trim) { if (complete == f_fss_complete_full_trim) { - status = private_fl_fss_basic_list_write_object_trim(used_start, destination); + status = private_fl_fss_basic_list_write_object_trim(used_start, state, destination); if (F_status_is_error(status)) { destination->used = used_start; @@ -1032,7 +1168,7 @@ extern "C" { #endif // _di_fl_fss_embedded_list_object_write_string_ #ifndef _di_fl_fss_embedded_list_content_write_string_ - f_status_t fl_fss_embedded_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_embedded_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -1081,6 +1217,15 @@ extern "C" { while (range->start <= range->stop && range->start < content.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (content.string[range->start] == f_fss_delimit_slash && !is_comment) { slash_count = 1; @@ -1095,6 +1240,15 @@ extern "C" { for (++range->start; range->start <= range->stop && range->start < content.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (content.string[range->start] == f_fss_delimit_placeholder) continue; if (content.string[range->start] != f_fss_delimit_slash) break; @@ -1125,7 +1279,7 @@ extern "C" { range->start = start + 1; - status = private_fl_fss_basic_list_write_add_until_end(content, range, destination); + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; if (content.string[range->start] != f_fss_eol) { @@ -1180,12 +1334,12 @@ extern "C" { if (ignore && ignore->used) { - for (r = 0; r < ignore->used; r++) { + for (r = 0; r < ignore->used; ++r) { if (start >= ignore->array[r].start && start <= ignore->array[r].stop) break; } // for if (r < ignore->used) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = content.string[start]; @@ -1203,13 +1357,13 @@ extern "C" { range->start = start + 1; - status = private_fl_fss_basic_list_write_add_until_end(content, range, destination); + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; continue; } - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = content.string[start]; @@ -1251,7 +1405,7 @@ extern "C" { status = f_string_dynamic_increase_by(width, destination); if (F_status_is_error(status)) break; - for (i = 0; i < width; i++) { + for (i = 0; i < width; ++i) { destination->string[destination->used++] = content.string[range->start + i]; } // for } diff --git a/level_1/fl_fss/c/fss_embedded_list.h b/level_1/fl_fss/c/fss_embedded_list.h index b63a828..4ed6d37 100644 --- a/level_1/fl_fss/c/fss_embedded_list.h +++ b/level_1/fl_fss/c/fss_embedded_list.h @@ -38,6 +38,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -62,6 +71,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -73,7 +83,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_embedded_list_object_read_ - extern f_status_t fl_fss_embedded_list_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits); + extern f_status_t fl_fss_embedded_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits); #endif // _di_fl_fss_embedded_list_object_read_ /** @@ -87,6 +97,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -115,6 +134,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -125,7 +145,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_embedded_list_content_read_ - extern f_status_t fl_fss_embedded_list_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_nest_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments); + extern f_status_t fl_fss_embedded_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_nest_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments); #endif // _di_fl_fss_embedded_list_content_read_ /** @@ -145,6 +165,15 @@ extern "C" { * If f_fss_complete_full_trim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object. * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object. * If f_fss_complete_partial_tim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the object string to write as an object. * @param destination @@ -158,6 +187,7 @@ extern "C" { * F_none_stop on success after reaching stopping point . * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. @@ -166,7 +196,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_embedded_list_object_write_string_ - extern f_status_t fl_fss_embedded_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_embedded_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_embedded_list_object_write_string_ /** @@ -194,6 +224,15 @@ extern "C" { * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close. * Any valid nested object open or valid nested object close inside an ingore range will not be escaped. * Set the pointer address to 0 to disable. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the content string to write as an content. * @param destination @@ -207,6 +246,7 @@ extern "C" { * F_none_stop on success after reaching stopping point. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -214,7 +254,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_embedded_list_content_write_string_ - extern f_status_t fl_fss_embedded_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_embedded_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_embedded_list_content_write_string_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/fss_extended.c b/level_1/fl_fss/c/fss_extended.c index 5b7c327..e0ebe47 100644 --- a/level_1/fl_fss/c/fss_extended.c +++ b/level_1/fl_fss/c/fss_extended.c @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef _di_fl_fss_extended_object_read_ - f_status_t fl_fss_extended_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_fss_delimits_t *delimits) { + f_status_t fl_fss_extended_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_fss_delimits_t *delimits) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -16,7 +16,7 @@ extern "C" { const f_array_length_t delimits_used = delimits->used; - f_status_t status = private_fl_fss_basic_read(buffer, F_true, range, found, quoted, delimits); + f_status_t status = private_fl_fss_basic_read(buffer, F_true, state, range, found, quoted, delimits); if (F_status_is_error(status)) { delimits->used = delimits_used; @@ -35,7 +35,7 @@ extern "C" { #endif // _di_fl_fss_extended_object_read_ #ifndef _di_fl_fss_extended_content_read_ - f_status_t fl_fss_extended_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_quotes_t *quotes, f_fss_delimits_t *delimits) { + f_status_t fl_fss_extended_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_content_t *found, f_fss_quotes_t *quotes, f_fss_delimits_t *delimits) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -49,7 +49,8 @@ extern "C" { if (F_status_is_error(status)) return status; if (status == F_none_eol) { - range->start++; + ++range->start; + return FL_fss_found_content_not; } @@ -66,15 +67,16 @@ extern "C" { uint8_t content_found = 0; while (range->start <= range->stop && range->start < buffer.used) { + f_string_range_t content_partial = f_string_range_t_initialize; f_fss_quote_t quoted = 0; - status = private_fl_fss_basic_read(buffer, F_false, range, &content_partial, "ed, delimits); + status = private_fl_fss_basic_read(buffer, F_false, state, range, &content_partial, "ed, delimits); if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) { if (found->used + 1 > found->size) { - macro_f_string_ranges_t_increase(status_allocate, (*found)); + macro_f_string_ranges_t_increase(status_allocate, state.step_small, (*found)); if (F_status_is_fine(status_allocate) && quotes) { macro_f_fss_quotes_t_resize(status_allocate, (*quotes), found->size); @@ -144,7 +146,7 @@ extern "C" { #endif // _di_fl_fss_extended_content_read_ #ifndef _di_fl_fss_extended_object_write_string_ -f_status_t fl_fss_extended_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { +f_status_t fl_fss_extended_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -152,7 +154,7 @@ f_status_t fl_fss_extended_object_write_string(const f_string_static_t object, c const f_array_length_t used_start = destination->used; - f_status_t status = private_fl_fss_basic_write(F_true, object, quote ? quote : f_fss_delimit_quote_double, range, destination); + f_status_t status = private_fl_fss_basic_write(F_true, object, quote ? quote : f_fss_delimit_quote_double, state, range, destination); if (status == F_data_not_stop || status == F_data_not_eos) { @@ -169,11 +171,11 @@ f_status_t fl_fss_extended_object_write_string(const f_string_static_t object, c f_status_t status2 = F_none; if (complete == f_fss_complete_full_trim) { - status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_delimit_quote_double, used_start, destination); + status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_delimit_quote_double, used_start, state, destination); if (F_status_is_error(status2)) return status2; } - status2 = f_string_dynamic_increase(destination); + status2 = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status2)) return status2; destination->string[destination->used++] = f_fss_extended_open; @@ -185,14 +187,14 @@ f_status_t fl_fss_extended_object_write_string(const f_string_static_t object, c #endif // _di_fl_fss_extended_object_write_string_ #ifndef _di_fl_fss_extended_content_write_string_ - f_status_t fl_fss_extended_content_write_string(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_extended_content_write_string(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ // this operates exactly like an object, syntax-wise. - const f_status_t status = private_fl_fss_basic_write(F_false, content, quote ? quote : f_fss_delimit_quote_double, range, destination); + const f_status_t status = private_fl_fss_basic_write(F_false, content, quote ? quote : f_fss_delimit_quote_double, state, range, destination); if (status == F_data_not_stop || status == F_data_not_eos) { diff --git a/level_1/fl_fss/c/fss_extended.h b/level_1/fl_fss/c/fss_extended.h index 3ecac9b..59f1765 100644 --- a/level_1/fl_fss/c/fss_extended.h +++ b/level_1/fl_fss/c/fss_extended.h @@ -37,6 +37,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -61,6 +70,7 @@ extern "C" { * F_terminated_not_group_eos if EOS was reached before the a group termination was reached. * F_terminated_not_group_stop if stop point was reached before the a group termination was reached. * + * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_utf_buffer_increment(). @@ -72,7 +82,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_extended_object_read_ - extern f_status_t fl_fss_extended_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_fss_delimits_t *delimits); + extern f_status_t fl_fss_extended_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_fss_delimits_t *delimits); #endif // _di_fl_fss_extended_object_read_ /** @@ -82,6 +92,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -105,6 +124,7 @@ extern "C" { * F_terminated_not_group_eos if EOS was reached before the a group termination was reached. * F_terminated_not_group_stop if stop point was reached before the a group termination was reached. * + * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_utf_buffer_increment(). @@ -115,7 +135,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_extended_content_read_ - extern f_status_t fl_fss_extended_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_quotes_t *quotes, f_fss_delimits_t *delimits); + extern f_status_t fl_fss_extended_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_content_t *found, f_fss_quotes_t *quotes, f_fss_delimits_t *delimits); #endif // _di_fl_fss_extended_content_read_ /** @@ -136,6 +156,15 @@ extern "C" { * If f_fss_complete_none, then only the object name is written. * If f_fss_complete_full, this will write any appropriate open and close aspects of this object. * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the object string to write as an object. * @param destination @@ -149,6 +178,7 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. @@ -159,7 +189,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_extended_object_write_string_ - extern f_status_t fl_fss_extended_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_extended_object_write_string(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_extended_object_write_string_ /** @@ -181,6 +211,15 @@ extern "C" { * If f_fss_complete_end, then the content followed by any appropriate "end" character designating the last content for some object, printing final newline, if applicable. * If f_fss_complete_partial, this will write any appropriate open and close aspects of this content, except for the final newline. * If f_fss_complete_full, this will write any appropriate open and close aspects of this content, including the final newline. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the content string to write as an content. * @param destination @@ -194,6 +233,7 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. @@ -204,7 +244,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_extended_content_write_string_ - extern f_status_t fl_fss_extended_content_write_string(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_extended_content_write_string(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_extended_content_write_string_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/fss_extended_list.c b/level_1/fl_fss/c/fss_extended_list.c index cc7461f..df37cb9 100644 --- a/level_1/fl_fss/c/fss_extended_list.c +++ b/level_1/fl_fss/c/fss_extended_list.c @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef _di_fl_fss_extended_list_object_read_ - f_status_t fl_fss_extended_list_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits) { + f_status_t fl_fss_extended_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -53,6 +53,7 @@ extern "C" { if (F_status_is_error(status)) { delimits->used = delimits_used; + return status; } @@ -80,6 +81,15 @@ extern "C" { // identify where the object ends. while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_delimit_slash) { slash_first = range->start; slash_count = 1; @@ -89,6 +99,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_delimit_placeholder || buffer.string[range->start] == f_fss_delimit_slash)) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_delimit_slash) slash_count++; status = f_utf_buffer_increment(buffer, range, 1); @@ -106,6 +125,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_graph(buffer, *range); @@ -159,7 +187,7 @@ extern "C" { graph_first = F_false; // comments may only have whitespace before the '#', therefore only the first slash needs to be delimited. - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = slash_first; @@ -180,6 +208,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_space(buffer, *range); @@ -228,6 +265,15 @@ extern "C" { // seek to the end of the line when no valid object is found. while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) { @@ -252,7 +298,7 @@ extern "C" { #endif // _di_fl_fss_extended_list_object_read_ #ifndef _di_fl_fss_extended_list_content_read_ - f_status_t fl_fss_extended_list_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments) { + f_status_t fl_fss_extended_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!found) return F_status_set_error(F_parameter); @@ -268,7 +314,7 @@ extern "C" { private_macro_fl_fss_content_with_comments_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, F_none_eos, F_none_stop); - macro_f_fss_content_t_increase(status, (*found)) + macro_f_fss_content_t_increase(status, state.step_small, (*found)) if (F_status_is_error(status)) return status; found->array[found->used].start = range->start; @@ -281,8 +327,17 @@ extern "C" { // identify where the content ends. while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + status = f_fss_skip_past_space(buffer, range); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; if (status == F_none_eol) { newline_last = range->start; @@ -299,6 +354,15 @@ extern "C" { for (++range->start; range->start <= range->stop && range->start < buffer.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_delimit_placeholder) { continue; } else if (buffer.string[range->start] != f_fss_delimit_slash) { @@ -318,6 +382,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_space(buffer, *range); @@ -332,7 +405,7 @@ extern "C" { if (range->start > range->stop || range->start >= buffer.used) break; if (buffer.string[range->start] == f_fss_eol) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = slash_first; @@ -340,7 +413,7 @@ extern "C" { } } else if (buffer.string[range->start] == f_fss_comment) { - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) break; delimits->array[delimits->used++] = slash_first; @@ -357,6 +430,15 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (buffer.string[range->start] == f_fss_eol) break; status = f_fss_is_space(buffer, *range); @@ -398,7 +480,7 @@ extern "C" { status = f_fss_seek_to_eol(buffer, range); if (F_status_is_error(status)) break; - macro_f_fss_comments_t_increase(status, (*comments)) + macro_f_fss_comments_t_increase(status, state.step_small, (*comments)) if (F_status_is_error(status)) break; if (range->start > range->stop || range->start >= buffer.used) { @@ -430,7 +512,7 @@ extern "C" { #endif // _di_fl_fss_extended_list_content_read_ #ifndef _di_fl_fss_extended_list_object_write_string_ - f_status_t fl_fss_extended_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_extended_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -476,10 +558,19 @@ extern "C" { // find the first graph character. while (range->start <= range->stop && range->start < object.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_comment) { // when a comment is found, escape it. - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = f_fss_delimit_slash; @@ -525,18 +616,36 @@ extern "C" { while (range->start <= range->stop && range->start < object.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_delimit_slash) { slash_count = 1; for (++range->start; range->start <= range->stop && range->start < object.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_delimit_placeholder) { continue; } else if (object.string[range->start] != f_fss_delimit_slash) { break; } - slash_count++; + ++slash_count; } // for if (F_status_is_error(status)) break; @@ -592,7 +701,7 @@ extern "C" { if (complete == f_fss_complete_partial || complete == f_fss_complete_partial_trim || complete == f_fss_complete_full || complete == f_fss_complete_full_trim) { if (complete == f_fss_complete_full_trim) { - status = private_fl_fss_basic_list_write_object_trim(used_start, destination); + status = private_fl_fss_basic_list_write_object_trim(used_start, state, destination); if (F_status_is_error(status)) { destination->used = used_start; @@ -636,7 +745,7 @@ extern "C" { #endif // _di_fl_fss_extended_list_object_write_string_ #ifndef _di_fl_fss_extended_list_content_write_string_ - f_status_t fl_fss_extended_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_extended_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -685,6 +794,15 @@ extern "C" { while (range->start <= range->stop && range->start < content.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (content.string[range->start] == f_fss_delimit_slash && !is_comment) { slash_count = 1; @@ -699,6 +817,15 @@ extern "C" { for (++range->start; range->start <= range->stop && range->start < content.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (content.string[range->start] == f_fss_delimit_placeholder) continue; if (content.string[range->start] != f_fss_delimit_slash) break; @@ -726,7 +853,7 @@ extern "C" { range->start = start + 1; - status = private_fl_fss_basic_list_write_add_until_end(content, range, destination); + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; if (content.string[range->start] != f_fss_eol) { @@ -786,7 +913,7 @@ extern "C" { } // for if (r < ignore->used) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = content.string[start]; @@ -805,13 +932,13 @@ extern "C" { range->start = start + 1; - status = private_fl_fss_basic_list_write_add_until_end(content, range, destination); + status = private_fl_fss_basic_list_write_add_until_end(content, state, range, destination); if (F_status_is_error(status)) break; continue; } - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = content.string[start]; diff --git a/level_1/fl_fss/c/fss_extended_list.h b/level_1/fl_fss/c/fss_extended_list.h index f463e37..3192a70 100644 --- a/level_1/fl_fss/c/fss_extended_list.h +++ b/level_1/fl_fss/c/fss_extended_list.h @@ -38,6 +38,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -62,6 +71,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -73,7 +83,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_extended_list_object_read_ - extern f_status_t fl_fss_extended_list_object_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits); + extern f_status_t fl_fss_extended_list_object_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_delimits_t *delimits); #endif // _di_fl_fss_extended_list_object_read_ /** @@ -85,6 +95,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -113,6 +132,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -123,7 +143,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_extended_list_content_read_ - extern f_status_t fl_fss_extended_list_content_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments); + extern f_status_t fl_fss_extended_list_content_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments); #endif // _di_fl_fss_extended_list_content_read_ /** @@ -143,6 +163,15 @@ extern "C" { * If f_fss_complete_full_trim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object. * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object. * If f_fss_complete_partial_tim, this will write any appropriate open and close aspects of this object, but will omit whitespace before and after the object. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the object string to write as an object. * @param destination @@ -156,6 +185,7 @@ extern "C" { * F_none_stop on success after reaching stopping point . * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. @@ -164,7 +194,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_extended_list_object_write_string_ - extern f_status_t fl_fss_extended_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_extended_list_object_write_string(const f_string_static_t object, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_extended_list_object_write_string_ /** @@ -192,6 +222,15 @@ extern "C" { * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close. * Any valid nested object open or valid nested object close inside an ingore range will not be escaped. * Set the pointer address to 0 to disable. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the content string to write as an content. * @param destination @@ -205,6 +244,7 @@ extern "C" { * F_none_stop on success after reaching stopping point . * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -212,7 +252,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_extended_list_content_write_string_ - extern f_status_t fl_fss_extended_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_extended_list_content_write_string(const f_string_static_t content, const uint8_t complete, const f_string_static_t *prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_extended_list_content_write_string_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index ce89a8b..397ee3f 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -7,7 +7,7 @@ extern "C" { #endif #if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) - f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quote, const f_array_length_t used_start, f_string_dynamic_t *destination) { + f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quote, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t *destination) { f_status_t status = F_none; f_string_range_t destination_range = macro_f_string_range_t_initialize(destination->used); @@ -17,6 +17,17 @@ extern "C" { // if there are any spaces, then this will be quoted so find the first non-placeholder character. for (; destination_range.start < destination->used; ++destination_range.start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + if (destination->string[destination_range.start] != f_fss_delimit_placeholder) break; } // for @@ -25,6 +36,16 @@ extern "C" { for (++destination_range.start; destination_range.start < destination->used; ++destination_range.start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + if (destination->string[destination_range.start] == f_fss_delimit_placeholder) { continue; } @@ -47,10 +68,20 @@ extern "C" { } // for // find the last quote. - for (destination_range.start = destination->used - 1; destination_range.start > front; destination_range.start--) { + for (destination_range.start = destination->used - 1; destination_range.start > front; --destination_range.start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } if (destination->string[destination_range.start] == quote) { - destination_range.start--; + --destination_range.start; break; } } // for @@ -59,6 +90,16 @@ extern "C" { for (; destination_range.start > front; destination_range.start--) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + if (destination->string[destination_range.start] == f_fss_delimit_placeholder) { continue; } @@ -70,6 +111,7 @@ extern "C" { if (F_status_is_error(status)) { destination->used = used_start; + return status; } @@ -85,10 +127,21 @@ extern "C" { // if there is no whitespace between the quotes, post-trimming, then remove the quotes. for (destination_range.start = front; destination_range.start < rear; ++destination_range.start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + destination->used = used_start; + + return F_status_set_error(F_interrupt); + } + } + status = f_fss_is_space(*destination, destination_range); if (F_status_is_error(status)) { destination->used = used_start; + return status; } @@ -106,16 +159,24 @@ extern "C" { #endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) #if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_) || !defined(_di_fl_fss_embedded_list_content_write_string_) - f_status_t private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { f_status_t status = F_none; for (; range->start <= range->stop && range->start < buffer.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + if (buffer.string[range->start] == f_fss_delimit_placeholder) continue; if (buffer.string[range->start] == f_fss_eol) break; - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = buffer.string[range->start]; @@ -126,7 +187,7 @@ extern "C" { #endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_) || !defined(_di_fl_fss_embedded_list_content_write_string_) #if !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) - f_status_t private_fl_fss_basic_list_write_object_trim(const f_array_length_t used_start, f_string_dynamic_t *destination) { + f_status_t private_fl_fss_basic_list_write_object_trim(const f_array_length_t used_start, f_state_t state, f_string_dynamic_t *destination) { f_status_t status = F_none; f_string_range_t destination_range = macro_f_string_range_t_initialize(destination->used); @@ -136,6 +197,14 @@ extern "C" { for (; destination_range.start < destination->used; ++destination_range.start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + if (destination->string[destination_range.start] == f_fss_delimit_placeholder) { continue; } @@ -157,7 +226,15 @@ extern "C" { } // for } // for - for (destination_range.start = destination->used - 1; destination_range.start > 0; destination_range.start--) { + for (destination_range.start = destination->used - 1; destination_range.start > 0; --destination_range.start) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } if (destination->string[destination_range.start] == f_fss_delimit_placeholder) { --destination->used; @@ -200,7 +277,7 @@ extern "C" { #endif // !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) #if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_) - f_status_t private_fl_fss_basic_read(const f_string_static_t buffer, const bool object_as, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote, f_fss_delimits_t *delimits) { + f_status_t private_fl_fss_basic_read(const f_string_static_t buffer, const bool object_as, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote, f_fss_delimits_t *delimits) { f_status_t status = f_fss_skip_past_space(buffer, range); if (F_status_is_error(status)) return status; @@ -229,6 +306,14 @@ extern "C" { while (buffer.string[range->start] != f_fss_eol) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + ++range->start; if (range->start >= buffer.used) { @@ -264,26 +349,35 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + status = f_fss_is_zero_width(buffer, *range); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; if (status == F_true) { status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; continue; } if (buffer.string[range->start] != f_fss_delimit_slash) { status = f_fss_is_space(buffer, *range); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; // found the end of the object while processing the slash for potential delimits. if (status == F_true) { found->stop = range->start - 1; status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; if (buffer.string[range->start] == f_fss_eol) { return FL_fss_found_object_content_not; @@ -296,9 +390,11 @@ extern "C" { } status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; } // while + if (F_status_is_error(status)) return status; + if (range->start >= buffer.used) { found->stop = buffer.used - 1; @@ -315,7 +411,7 @@ extern "C" { // only the first slash before a quoted needs to be escaped (or not) as once there is a slash before a quoted, this cannot ever be a quote object. // this simplifies the number of slashes needed. - macro_f_fss_delimits_t_increase(status, (*delimits)); + macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits)); if (F_status_is_error(status)) return status; delimits->array[delimits->used] = first_slash; @@ -340,15 +436,26 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + status = f_fss_is_space(buffer, *range); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; if (status == F_true) break; status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(status)) return status; + if (F_status_is_error(status)) break; } // while + if (F_status_is_error(status)) return status; + found->stop = range->start - 1; if (buffer.string[range->start] == f_fss_eol) { @@ -371,6 +478,14 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + if (buffer.string[range->start] == f_fss_delimit_slash) { first_slash = range->start; slash_count = 1; @@ -380,6 +495,14 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + if (buffer.string[range->start] == f_fss_delimit_placeholder) { status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) return status; @@ -460,7 +583,7 @@ extern "C" { ++delimits->used; } - slash_count--; + --slash_count; } status = f_utf_buffer_increment(buffer, range, 1); @@ -470,6 +593,15 @@ extern "C" { range->start = location + 1; while (buffer.string[range->start] == f_fss_delimit_placeholder) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + ++range->start; if (range->start >= buffer.used) return F_none_eos; @@ -483,6 +615,14 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) return status; } // while @@ -531,7 +671,7 @@ extern "C" { ++delimits->used; } - slash_count--; + --slash_count; } status = f_utf_buffer_increment(buffer, range, 1); @@ -592,6 +732,14 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + if (buffer.string[range->start] == f_fss_eol) { // move the start position to after the EOL. @@ -614,6 +762,14 @@ extern "C" { while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(status)) return status; } // while @@ -690,7 +846,7 @@ extern "C" { #endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) #if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) || !defined(_di_fl_fss_extended_content_write_string_) - f_status_t private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quote, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quote, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { f_status_t status = f_fss_skip_past_space(object, range); if (F_status_is_error(status)) return status; @@ -733,12 +889,30 @@ extern "C" { for (; range->start <= range->stop && range->start < object.used; ) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_delimit_slash) { item_first = range->start++; item_total = 1; for (; range->start <= range->stop && range->start < object.used; ++range->start) { + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + status = F_status_set_error(F_interrupt); + break; + } + } + if (object.string[range->start] == f_fss_delimit_slash) { ++item_total; } @@ -754,7 +928,7 @@ extern "C" { // if this is the first quote, then only a single delimit slash is needed. if (item_first == input_start) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = f_fss_delimit_slash; @@ -816,7 +990,7 @@ extern "C" { // add the slashes that delimit the slashes. if (item_first == input_start) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = f_fss_delimit_slash; @@ -898,7 +1072,7 @@ extern "C" { // the very first quote, must be escaped, when quoting is disabled. if (item_first == input_start) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[used_start + 1] = f_fss_delimit_slash; @@ -909,7 +1083,7 @@ extern "C" { if (range->start > range->stop || range->start >= object.used) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = quote; @@ -917,7 +1091,7 @@ extern "C" { } if (object.string[range->start] == quote) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = quote; @@ -932,7 +1106,7 @@ extern "C" { if (status == F_true) { if (item_first != input_start) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; destination->string[destination->used++] = f_fss_delimit_slash; @@ -987,7 +1161,7 @@ extern "C" { } if (quoted) { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) { destination->used = used_start; @@ -1002,6 +1176,15 @@ extern "C" { if (destination->string[input_start] == quote) { for (i = input_start + 1; i <= range->stop && i < object.used; ++i) { + + if (state.interrupt) { + status = state.interrupt((void *) &state, 0); + + if (F_status_set_fine(status) == F_interrupt) { + return F_status_set_error(F_interrupt); + } + } + if (object.string[i] != f_fss_delimit_placeholder) break; } // for diff --git a/level_1/fl_fss/c/private-fss.h b/level_1/fl_fss/c/private-fss.h index 2b25a0f..3258bc9 100644 --- a/level_1/fl_fss/c/private-fss.h +++ b/level_1/fl_fss/c/private-fss.h @@ -23,19 +23,30 @@ extern "C" { * Otherwise, this is the type of quote to wrap the object in when writing. * @param used_start * The destination.used value before any operations were perfomed. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param destination * The buffer where the object is written to. * * @return * F_none on success. * + * F_interrupt (with error bit) if stopping due to an interrupt. + * * Errors (with error bit) from: f_fss_is_space(). * * @see fl_fss_basic_object_write_string() * @see fl_fss_extended_object_write_string() */ #if !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) - extern f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quote, const f_array_length_t used_start, f_string_dynamic_t *destination) f_attribute_visibility_internal; + extern f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quote, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t *destination) f_attribute_visibility_internal; #endif // !defined(_di_fl_fss_basic_object_write_string_) || !defined(_di_fl_fss_extended_object_write_string_) /** @@ -43,6 +54,15 @@ extern "C" { * * @param buffer * The buffer to seek through. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer string to process. * @param destination @@ -51,6 +71,8 @@ extern "C" { * @return * F_none on success. * + * F_interrupt (with error bit) if stopping due to an interrupt. + * * Errors (with error bit) from: f_string_dynamic_increase(). * * @see fl_fss_basic_list_content_write_string() @@ -59,27 +81,38 @@ extern "C" { * @see f_string_dynamic_increase() */ #if !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_) || !defined(_di_fl_fss_embedded_list_content_write_string_) - extern f_status_t private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_string_range_t *range, f_string_dynamic_t *destination) f_attribute_visibility_internal; + extern f_status_t private_fl_fss_basic_list_write_add_until_end(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) f_attribute_visibility_internal; #endif // !defined(_di_fl_fss_basic_list_content_write_string_) || !defined(_di_fl_fss_extended_list_content_write_string_) || !defined(_di_fl_fss_embedded_list_content_write_string_) /** * Trim a given object used by the basic list and extended list object write functions. * * @param used_start - * The destination.used value before any operations were perfomed. + * The destination.used value before any operations were performed. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param destination * The buffer where the object is written to. * * @return * F_none on success. * + * F_interrupt (with error bit) if stopping due to an interrupt. + * * Errors (with error bit) from: f_fss_is_space(). * * @see fl_fss_basic_list_object_write_string() * @see fl_fss_extended_list_object_write_string() */ #if !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) - extern f_status_t private_fl_fss_basic_list_write_object_trim(const f_array_length_t used_start, f_string_dynamic_t *destination) f_attribute_visibility_internal; + extern f_status_t private_fl_fss_basic_list_write_object_trim(const f_array_length_t used_start, f_state_t state, f_string_dynamic_t *destination) f_attribute_visibility_internal; #endif // !defined(_di_fl_fss_basic_list_object_write_string_) || !defined(_di_fl_fss_extended_list_object_write_string_) /** @@ -95,6 +128,15 @@ extern "C" { * * As Object, this checks if the first graph character is a comment character '#', or an escaped comment character '#'. * As Content, this does nothing special in regards to a leading '#'. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the buffer to be processed. * The start location will be updated as the buffer is being processed. @@ -123,6 +165,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -139,7 +182,7 @@ extern "C" { * @see fl_fss_extended_content_read() */ #if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_) - extern f_status_t private_fl_fss_basic_read(const f_string_static_t buffer, const bool object_as, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_fss_delimits_t *delimits) f_attribute_visibility_internal; + extern f_status_t private_fl_fss_basic_read(const f_string_static_t buffer, const bool object_as, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_fss_delimits_t *delimits) f_attribute_visibility_internal; #endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_) /** @@ -160,6 +203,15 @@ extern "C" { * @param quoted * If 0, then double quotes are auto-inserted, if needed. * Otherwise, this is the type of quote to wrap the object in when writing. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions. + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The start/stop location within the object string to write as an object. * @param destination @@ -173,6 +225,7 @@ extern "C" { * F_data_not_eos no data to write due start location being greater than or equal to buffer size. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * F_parameter (with error bit) if a parameter is invalid. @@ -186,7 +239,7 @@ extern "C" { * @see fl_fss_extended_content_write_string() */ #if !defined(fl_fss_basic_object_write_string) || !defined(fl_fss_extended_object_write_string) || !defined(_di_fl_fss_extended_content_write_string_) - extern f_status_t private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) f_attribute_visibility_internal; + extern f_status_t private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quoted, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) f_attribute_visibility_internal; #endif // !defined(fl_fss_basic_object_write_string) || !defined(fl_fss_extended_object_write_string) || !defined(_di_fl_fss_extended_content_write_string_) #ifdef __cplusplus diff --git a/level_1/fl_iki/c/iki.c b/level_1/fl_iki/c/iki.c index dcf3e0a..a002dc2 100644 --- a/level_1/fl_iki/c/iki.c +++ b/level_1/fl_iki/c/iki.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fl_iki_read_ - f_status_t fl_iki_read(f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content) { + f_status_t fl_iki_read(f_state_t state, f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content) { #ifndef _di_level_1_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); if (!range) return F_status_set_error(F_parameter); @@ -14,7 +14,7 @@ extern "C" { f_status_t status = F_none; do { - status = f_iki_read(buffer, range, variable, vocabulary, content); + status = f_iki_read(state, buffer, range, variable, vocabulary, content); if (F_status_is_error(status)) return status; if (status == F_data_not_eos || status == F_data_not_stop) { diff --git a/level_1/fl_iki/c/iki.h b/level_1/fl_iki/c/iki.h index 656dcbc..f66d2eb 100644 --- a/level_1/fl_iki/c/iki.h +++ b/level_1/fl_iki/c/iki.h @@ -35,6 +35,15 @@ extern "C" { * This does not verify if any vocabulary name is known. * This only finds complete vocabulary names and their respective content. * + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param buffer * The string to process. * @param range @@ -56,6 +65,7 @@ extern "C" { * F_data_not_eos on success and EOS was reached, but there were no IKI vocabularie names found. * F_data_not_stop on success and stop point was reached, but there were no IKI vocabularie names found. * + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if a string length is too large to store in the buffer. @@ -63,7 +73,7 @@ extern "C" { * Errors (with error bit) from: f_iki_read(). */ #ifndef _di_fl_iki_read_ - extern f_status_t fl_iki_read(f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content); + extern f_status_t fl_iki_read(f_state_t state, f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content); #endif // _di_fl_iki_read_ #ifdef __cplusplus diff --git a/level_1/fl_signal/c/signal-common.h b/level_1/fl_signal/c/signal-common.h new file mode 100644 index 0000000..613c736 --- /dev/null +++ b/level_1/fl_signal/c/signal-common.h @@ -0,0 +1,47 @@ +/** + * FLL - Level 1 + * + * Project: Signal + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Defines common data to be used for/by project execute. + * + * This is auto-included by execute.h and should not need to be explicitly included. + */ +#ifndef _FL_signal_common_h +#define _FL_signal_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A structure intended to be used as the "data" structure for f_state_t for interrupt related functionality. + * + * interrupts: An array of signal codes to treat as interrupts. + * signal: The signal structure to use. + * trigger: The signal that triggered the interrupt, if applicable. + */ +#ifndef _di_fl_signal_interrupt_t_ + typedef struct { + f_int32s_t interrupts; + f_signal_t signal; + int32_t trigger; + } fl_signal_interrupt_t; + + #define fl_signal_interrupt_t_initialize { f_int32s_t_initialize, f_signal_t_initialize, 0 } + + #define macro_fl_signal_interrupt_t_initialize(interrupts, signal) { interrupts, signal, 0 } + + #define macro_fl_signal_interrupt_t_clear(structure) \ + macro_f_int32s_t_clear(structure.interrupts) \ + macro_f_signal_t_clear(structure.signal) \ + structure.trigger = 0; +#endif // _di_fl_signal_interrupt_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _FL_signal_common_h diff --git a/level_1/fl_signal/c/signal.c b/level_1/fl_signal/c/signal.c new file mode 100644 index 0000000..e831647 --- /dev/null +++ b/level_1/fl_signal/c/signal.c @@ -0,0 +1,52 @@ +#include "signal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fl_signal_state_interrupt_ + f_status_t fl_signal_state_interrupt(void *state, void *internal) { + #ifndef _di_level_1_parameter_checking_ + if (!state) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + f_state_t *state_ptr = (f_state_t *) state; + + if (!state_ptr->custom) { + return F_status_set_error(F_parameter); + } + + fl_signal_interrupt_t *signal_interrupt = (fl_signal_interrupt_t *) state_ptr->custom; + + if (!signal_interrupt || !signal_interrupt->signal.id) { + return F_enable_not; + } + + if (!signal_interrupt->interrupts.used) { + return F_interrupt_not; + } + + struct signalfd_siginfo information; + + memset(&information, 0, sizeof(struct signalfd_siginfo)); + + const f_status_t status = f_signal_read(signal_interrupt->signal, &information); + + if (status == F_signal) { + for (f_array_length_t i = 0; i < signal_interrupt->interrupts.used; ++i) { + + if (information.ssi_signo == signal_interrupt->interrupts.array[i]) { + signal_interrupt->trigger = information.ssi_signo; + + return F_status_set_error(F_interrupt); + } + } // for + } + + return F_interrupt_not; + } +#endif // _di_fl_signal_state_interrupt_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_signal/c/signal.h b/level_1/fl_signal/c/signal.h new file mode 100644 index 0000000..8b0e795 --- /dev/null +++ b/level_1/fl_signal/c/signal.h @@ -0,0 +1,68 @@ +/** + * FLL - Level 1 + * + * Project: Signal + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Provides common signal functions. + */ +#ifndef _FL_signal_h +#define _FL_signal_h + +// libc includes +#include +#include +#include + +// fll-0 includes +#include +#include +#include + +// fll-1 signal includes +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Check to see if a given signal is received. + * + * Provides a simple interrupt checker for general use. + * + * This is intended to be explicitly use for the interrupt() callback defined in f_state_t. + * + * This check all interrupts provided in state->data.interrupts and if a signal is found, store that signal in state->data.trigger and returns F_interrupt (with error bit set). + * If state->data.signal.id is NULL, then F_enable_not is returned. + * + * @param state + * The state such that: + * - state->handle: Ignored. + * - state->interrupt: A pointer to this function. + * - state->callbacks: Ignored. + * - state->custom: The interrupt data, of the type fl_signal_interrupt_t (Must not be NULL). + * - state->data: Ignored. + * @param internal + * This is ignored. + * + * @return + * F_none on success. + * F_enable_not on success but signals are not requested to be processed. + * F_interrupt_not on success and no requested signal was found. + * + * F_interrupt (with error bit) if a requested signal is confirmed to be found. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see f_signal_read() + */ +#ifndef _di_fl_signal_state_interrupt_ + extern f_status_t fl_signal_state_interrupt(void *state, void *internal); +#endif // _di_fl_signal_state_interrupt_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _FL_signal_h diff --git a/level_1/fl_signal/data/build/defines b/level_1/fl_signal/data/build/defines new file mode 100644 index 0000000..c665317 --- /dev/null +++ b/level_1/fl_signal/data/build/defines @@ -0,0 +1,2 @@ +# fss-0000 + diff --git a/level_1/fl_signal/data/build/dependencies b/level_1/fl_signal/data/build/dependencies new file mode 100644 index 0000000..01e8165 --- /dev/null +++ b/level_1/fl_signal/data/build/dependencies @@ -0,0 +1,5 @@ +# fss-0000 + +f_type +f_status +f_signal diff --git a/level_1/fl_signal/data/build/settings b/level_1/fl_signal/data/build/settings new file mode 100644 index 0000000..76590c6 --- /dev/null +++ b/level_1/fl_signal/data/build/settings @@ -0,0 +1,55 @@ +# fss-0001 + +project_name fl_iki + +version_major 0 +version_minor 5 +version_micro 4 +version_target major + +environment + +process_pre +process_post + +modes individual +modes_default individual + +build_compiler gcc +build_indexer ar +build_language c +build_libraries -lc +build_libraries-individual -lf_signal +build_sources_library signal.c +build_sources_program +build_sources_headers signal.h signal-common.h +build_sources_script +build_sources_setting +build_script yes +build_shared yes +build_static no + +path_headers fll/level_1 +path_headers_preserve no +path_library_script script +path_library_shared shared +path_library_static static +path_program_script script +path_program_shared shared +path_program_static static +path_sources +path_standard yes + +search_exclusive yes +search_shared yes +search_static yes + +defines_all +defines_static +defines_shared + +flags_all -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_shared +flags_static +flags_library -fPIC +flags_program -fPIE diff --git a/level_1/fl_status/c/status.c b/level_1/fl_status/c/status.c index e35feff..3d20608 100644 --- a/level_1/fl_status/c/status.c +++ b/level_1/fl_status/c/status.c @@ -315,6 +315,12 @@ extern "C" { case F_device_not: *string = FL_status_string_device_not; break; + case F_disable: + *string = FL_status_string_disable; + break; + case F_disable_not: + *string = FL_status_string_disable_not; + break; case F_done: *string = FL_status_string_done; break; @@ -333,6 +339,12 @@ extern "C" { case F_empty_not: *string = FL_status_string_empty_not; break; + case F_enable: + *string = FL_status_string_enable; + break; + case F_enable_not: + *string = FL_status_string_enable_not; + break; case F_encoding: *string = FL_status_string_encoding; break; diff --git a/level_1/fl_status/c/status.h b/level_1/fl_status/c/status.h index 69839ff..3297181 100644 --- a/level_1/fl_status/c/status.h +++ b/level_1/fl_status/c/status.h @@ -197,12 +197,16 @@ extern "C" { #define FL_status_string_descriptor_not "F_descriptor_not" #define FL_status_string_device "F_device" #define FL_status_string_device_not "F_device_not" + #define FL_status_string_disable "F_disable" + #define FL_status_string_disable_not "F_disable_not" #define FL_status_string_done "F_done" #define FL_status_string_done_not "F_done_not" #define FL_status_string_dummy "F_dummy" #define FL_status_string_dummy_not "F_dummy_not" #define FL_status_string_empty "F_empty" #define FL_status_string_empty_not "F_empty_not" + #define FL_status_string_enable "F_enable" + #define FL_status_string_enable_not "F_enable_not" #define FL_status_string_encoding "F_encoding" #define FL_status_string_encoding_not "F_encoding_not" #define FL_status_string_eoa "F_eoa" @@ -370,12 +374,16 @@ extern "C" { #define FL_status_string_descriptor_not_length 16 #define FL_status_string_device_length 8 #define FL_status_string_device_not_length 12 + #define FL_status_string_disable_length 9 + #define FL_status_string_disable_not_length 13 #define FL_status_string_done_length 6 #define FL_status_string_done_not_length 10 #define FL_status_string_dummy_length 7 #define FL_status_string_dummy_not_length 11 #define FL_status_string_empty_length 7 #define FL_status_string_empty_not_length 11 + #define FL_status_string_enable_length 8 + #define FL_status_string_enable_not_length 12 #define FL_status_string_encoding_length 10 #define FL_status_string_encoding_not_length 14 #define FL_status_string_eoa_length 5 diff --git a/level_2/fll_execute/c/private-execute.c b/level_2/fll_execute/c/private-execute.c index c93b220..734b01c 100644 --- a/level_2/fll_execute/c/private-execute.c +++ b/level_2/fll_execute/c/private-execute.c @@ -8,7 +8,7 @@ extern "C" { #if !defined(_di_fll_execute_arguments_add_) || !defined(_di_fll_execute_arguments_add_set_) || !defined(_di_fll_execute_arguments_dynamic_add_) || !defined(_di_fll_execute_arguments_dynamic_add_set_) f_status_t private_fll_execute_arguments_add(const f_string_t source, const f_array_length_t length, f_string_dynamics_t *arguments) { - f_status_t status = f_string_dynamics_increase(arguments); + f_status_t status = f_string_dynamics_increase(f_memory_default_allocation_small, arguments); if (F_status_is_error(status)) return status; f_string_dynamic_t argument = f_string_dynamic_t_initialize; @@ -43,7 +43,7 @@ extern "C" { #if !defined(_di_fll_execute_arguments_add_parameter_) || !defined(_di_fll_execute_arguments_add_parameter_set_) || !defined(_di_fll_execute_arguments_dynamic_add_parameter_) || !defined(_di_fll_execute_arguments_dynamic_add_parameter_set_) f_status_t private_fll_execute_arguments_add_parameter(const f_string_t prefix, const f_array_length_t prefix_length, const f_string_t name, const f_array_length_t name_length, const f_string_t value, const f_array_length_t value_length, f_string_dynamics_t *arguments) { - f_status_t status = f_string_dynamics_increase(arguments); + f_status_t status = f_string_dynamics_increase(f_memory_default_allocation_small, arguments); if (F_status_is_error(status)) return status; f_string_dynamic_t argument = f_string_dynamic_t_initialize; @@ -100,7 +100,7 @@ extern "C" { return status; } - status = f_string_dynamics_increase(arguments); + status = f_string_dynamics_increase(f_memory_default_allocation_small, arguments); if (F_status_is_error(status)) { f_string_dynamic_resize(0, &argument); diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index 6186ff1..78e961b 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -331,11 +331,11 @@ extern "C" { if (F_status_is_error(status)) return status; if (status == F_equal_to_not) continue; - status = f_string_map_multis_increase(values[j]); + status = f_string_map_multis_increase(f_memory_default_allocation_small, values[j]); if (F_status_is_error(status)) return status; if (indexs) { - macro_f_array_lengths_t_increase(status, (*indexs[j])); + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, (*indexs[j])); if (F_status_is_error(status)) return status; } @@ -403,11 +403,11 @@ extern "C" { if (F_status_is_error(status)) return status; if (status == F_equal_to_not) continue; - status = f_string_maps_increase(values[j]); + status = f_string_maps_increase(f_memory_default_allocation_small, values[j]); if (F_status_is_error(status)) return status; if (indexs) { - macro_f_array_lengths_t_increase(status, (*indexs[j])); + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, (*indexs[j])); if (F_status_is_error(status)) return status; } @@ -505,11 +505,11 @@ extern "C" { map_multi = &values[j]->array[k]; } else { - status = f_string_map_multis_increase(values[j]); + status = f_string_map_multis_increase(f_memory_default_allocation_small, values[j]); if (F_status_is_error(status)) return status; if (indexs) { - macro_f_array_lengths_t_increase(status, (*indexs[j])); + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, (*indexs[j])); if (F_status_is_error(status)) return status; } @@ -530,7 +530,7 @@ extern "C" { if (contents.array[i].used == 1) continue; } - status = f_string_dynamics_increase(&map_multi->value); + status = f_string_dynamics_increase(f_memory_default_allocation_small, &map_multi->value); if (F_status_is_error(status)) return status; for (k = 1; k < contents.array[i].used; k++) { @@ -617,11 +617,11 @@ extern "C" { map = &values[j]->array[k]; } else { - status = f_string_maps_increase(values[j]); + status = f_string_maps_increase(f_memory_default_allocation_small, values[j]); if (F_status_is_error(status)) return status; if (indexs) { - macro_f_array_lengths_t_increase(status, (*indexs[j])); + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, (*indexs[j])); if (F_status_is_error(status)) return status; } @@ -740,11 +740,11 @@ extern "C" { if (F_status_is_error(status)) return status; if (status == F_equal_to_not) continue; - status = f_string_dynamics_increase(values[j]); + status = f_string_dynamics_increase(f_memory_default_allocation_small, values[j]); if (F_status_is_error(status)) return status; if (indexs) { - macro_f_array_lengths_t_increase(status, (*indexs[j])); + macro_f_array_lengths_t_increase(status, f_memory_default_allocation_small, (*indexs[j])); if (F_status_is_error(status)) return status; } diff --git a/level_2/fll_fss/c/fss_basic.c b/level_2/fll_fss/c/fss_basic.c index eee76e2..ef4dfde 100644 --- a/level_2/fll_fss/c/fss_basic.c +++ b/level_2/fll_fss/c/fss_basic.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fll_fss_basic_read_ - f_status_t fll_fss_basic_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) { + f_status_t fll_fss_basic_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) { #ifndef _di_level_2_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!objects) return F_status_set_error(F_parameter); @@ -23,14 +23,14 @@ extern "C" { do { if (objects->used == objects->size) { - macro_f_fss_objects_t_increase(status2, (*objects)) + macro_f_fss_objects_t_increase(status2, f_memory_default_allocation_small, (*objects)) if (F_status_is_error(status2)) return status2; - macro_f_fss_contents_t_increase(status2, (*contents)) + macro_f_fss_contents_t_increase(status2, f_memory_default_allocation_small, (*contents)) if (F_status_is_error(status2)) return status2; if (objects_quoted) { - macro_f_fss_quotes_t_increase(status2, (*objects_quoted)) + macro_f_fss_quotes_t_increase(status2, f_memory_default_allocation_small, (*objects_quoted)) if (F_status_is_error(status2)) return status2; } } @@ -40,7 +40,7 @@ extern "C" { quoted_object = &objects_quoted->array[objects_quoted->used]; } - status = fl_fss_basic_object_read(buffer, range, &objects->array[objects->used], quoted_object, objects_delimits); + status = fl_fss_basic_object_read(buffer, state, range, &objects->array[objects->used], quoted_object, objects_delimits); if (F_status_is_error(status)) return status; if (range->start >= range->stop || range->start >= buffer.used) { @@ -51,7 +51,7 @@ extern "C" { objects_quoted->used++; } - macro_f_fss_content_t_increase(status2, contents->array[contents->used]) + macro_f_fss_content_t_increase(status2, f_memory_default_allocation_small, contents->array[contents->used]) if (F_status_is_error(status2)) return status2; contents->used++; @@ -78,7 +78,7 @@ extern "C" { if (status == FL_fss_found_object) { found_data = F_true; - status = fl_fss_basic_content_read(buffer, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits); + status = fl_fss_basic_content_read(buffer, state, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits); if (F_status_is_error(status)) return status; break; @@ -86,7 +86,7 @@ extern "C" { else if (status == FL_fss_found_object_content_not) { found_data = F_true; - macro_f_fss_content_t_increase(status2, contents->array[contents->used]) + macro_f_fss_content_t_increase(status2, f_memory_default_allocation_small, contents->array[contents->used]) if (F_status_is_error(status2)) return status2; break; @@ -154,7 +154,7 @@ extern "C" { #endif // _di_fll_fss_basic_read_ #ifndef _di_fll_fss_basic_write_string_ - f_status_t fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *destination) { + f_status_t fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -162,7 +162,7 @@ extern "C" { f_status_t status = 0; f_string_range_t range = macro_f_string_range_t_initialize(object.used); - status = fl_fss_basic_object_write_string(object, quote, f_fss_complete_full, &range, destination); + status = fl_fss_basic_object_write_string(object, quote, f_fss_complete_full, state, &range, destination); if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { return status; @@ -173,11 +173,11 @@ extern "C" { range.start = 0; range.stop = content.used - 1; - status = fl_fss_basic_content_write_string(content, f_fss_complete_full, &range, destination); + status = fl_fss_basic_content_write_string(content, f_fss_complete_full, state, &range, destination); if (F_status_is_error(status)) return status; } else { - status = f_string_dynamic_increase(destination); + status = f_string_dynamic_increase(f_memory_default_allocation_small, destination); if (F_status_is_error(status)) return status; destination->string[destination->used++] = f_string_eol_s[0]; diff --git a/level_2/fll_fss/c/fss_basic.h b/level_2/fll_fss/c/fss_basic.h index a76c189..00e728f 100644 --- a/level_2/fll_fss/c/fss_basic.h +++ b/level_2/fll_fss/c/fss_basic.h @@ -33,6 +33,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The range within the buffer that is currently being read. * @param objects @@ -59,6 +68,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_number_overflow (with error bit) if the maximimum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. @@ -68,7 +78,7 @@ extern "C" { * Errors (with error bit) from: fl_fss_basic_object_read(). */ #ifndef _di_fll_fss_basic_read_ - extern f_status_t fll_fss_basic_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits); + extern f_status_t fll_fss_basic_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits); #endif // _di_fll_fss_basic_read_ /** @@ -81,6 +91,15 @@ extern "C" { * @param quote * If 0, then double quotes are auto-inserted, when required. * Otherwise, this is the type of quote to wrap the object in when writing. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param destination * The buffer where the content is written to. * @@ -92,6 +111,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -101,7 +121,7 @@ extern "C" { * Errors (with error bit) from: f_string_dynamic_increase_by(). */ #ifndef _di_fll_fss_basic_write_string_ - extern f_status_t fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *destination); + extern f_status_t fll_fss_basic_write_string(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t *destination); #endif // _di_fll_fss_basic_write_string_ #ifdef __cplusplus diff --git a/level_2/fll_fss/c/fss_basic_list.c b/level_2/fll_fss/c/fss_basic_list.c index 6a5fbf8..aeb4595 100644 --- a/level_2/fll_fss/c/fss_basic_list.c +++ b/level_2/fll_fss/c/fss_basic_list.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fll_fss_basic_list_read_ - f_status_t fll_fss_basic_list_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { + f_status_t fll_fss_basic_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { #ifndef _di_level_2_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!objects) return F_status_set_error(F_parameter); @@ -29,14 +29,14 @@ extern "C" { } do { - status = fl_fss_basic_list_object_read(buffer, range, &objects->array[objects->used], objects_delimits); + status = fl_fss_basic_list_object_read(buffer, state, range, &objects->array[objects->used], objects_delimits); if (F_status_is_error(status)) return status; if (range->start >= range->stop || range->start >= buffer.used) { if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) { objects->used++; - macro_f_fss_delimits_t_increase(status2, contents->array[contents->used]) + macro_f_fss_delimits_t_increase(status2, f_memory_default_allocation_small, contents->array[contents->used]) if (F_status_is_error(status2)) return status2; contents->used++; @@ -63,7 +63,7 @@ extern "C" { if (status == FL_fss_found_object) { found_data = F_true; - status = fl_fss_basic_list_content_read(buffer, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits, comments); + status = fl_fss_basic_list_content_read(buffer, state, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits, comments); if (F_status_is_error(status)) return status; break; @@ -71,7 +71,7 @@ extern "C" { else if (status == FL_fss_found_object_content_not) { found_data = F_true; - macro_f_fss_content_t_increase(status2, contents->array[contents->used]) + macro_f_fss_content_t_increase(status2, f_memory_default_allocation_small, contents->array[contents->used]) if (F_status_is_error(status2)) return status2; break; @@ -128,7 +128,7 @@ extern "C" { #endif // _di_fll_fss_basic_list_read_ #ifndef _di_fll_fss_basic_list_write_string_ - f_status_t fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_string_dynamic_t *destination) { + f_status_t fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -136,7 +136,7 @@ extern "C" { f_status_t status = 0; f_string_range_t range = macro_f_string_range_t_initialize(object.used); - status = fl_fss_basic_list_object_write_string(object, f_fss_complete_full, &range, destination); + status = fl_fss_basic_list_object_write_string(object, f_fss_complete_full, state, &range, destination); if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { return status; @@ -152,7 +152,7 @@ extern "C" { range.stop = 0; } - status = fl_fss_basic_list_content_write_string(content, f_fss_complete_full, content_prepend, &range, destination); + status = fl_fss_basic_list_content_write_string(content, f_fss_complete_full, content_prepend, state, &range, destination); } return status; diff --git a/level_2/fll_fss/c/fss_basic_list.h b/level_2/fll_fss/c/fss_basic_list.h index 2767a80..9f32715 100644 --- a/level_2/fll_fss/c/fss_basic_list.h +++ b/level_2/fll_fss/c/fss_basic_list.h @@ -32,6 +32,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The range within the buffer that is currently being read. * @param objects @@ -58,6 +67,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_number_overflow (with error bit) if the maximimum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. @@ -67,7 +77,7 @@ extern "C" { * Errors (with error bit) from: fl_fss_basic_list_object_read(). */ #ifndef _di_fll_fss_basic_list_read_ - extern f_status_t fll_fss_basic_list_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments); + extern f_status_t fll_fss_basic_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments); #endif // _di_fll_fss_basic_list_read_ /** @@ -80,6 +90,15 @@ extern "C" { * @param content_prepend * A string to prepend at the start of each line in content, such as spaces. * Set the pointer address to 0 to disable. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param destination * The buffer to write to. * @@ -91,6 +110,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -100,7 +120,7 @@ extern "C" { * Errors (with error bit) from: f_string_dynamic_increase_by(). */ #ifndef _di_fll_fss_basic_list_write_string_ - extern f_status_t fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_string_dynamic_t *destination); + extern f_status_t fll_fss_basic_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, f_state_t state, f_string_dynamic_t *destination); #endif // _di_fll_fss_basic_list_write_string_ #ifdef __cplusplus diff --git a/level_2/fll_fss/c/fss_embedded_list.c b/level_2/fll_fss/c/fss_embedded_list.c index 93054ca..bed51a3 100644 --- a/level_2/fll_fss/c/fss_embedded_list.c +++ b/level_2/fll_fss/c/fss_embedded_list.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fll_fss_embedded_list_read_ - f_status_t fll_fss_embedded_list_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_nest_t *nest, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { + f_status_t fll_fss_embedded_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_nest_t *nest, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { #ifndef _di_level_2_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!nest) return F_status_set_error(F_parameter); @@ -34,7 +34,7 @@ extern "C" { if (F_status_is_error(status)) return status; } - status = fl_fss_embedded_list_object_read(buffer, range, &nest->depth[0].array[nest->depth[0].used].object, objects_delimits); + status = fl_fss_embedded_list_object_read(buffer, state, range, &nest->depth[0].array[nest->depth[0].used].object, objects_delimits); if (F_status_is_error(status)) return status; if (range->start >= range->stop || range->start >= buffer.used) { @@ -63,7 +63,7 @@ extern "C" { if (status == FL_fss_found_object) { found_data = F_true; - status = fl_fss_embedded_list_content_read(buffer, range, nest, contents_delimits ? contents_delimits : objects_delimits, comments); + status = fl_fss_embedded_list_content_read(buffer, state, range, nest, contents_delimits ? contents_delimits : objects_delimits, comments); break; } else if (status == FL_fss_found_object_content_not) { @@ -126,7 +126,7 @@ extern "C" { #endif // _di_fll_fss_embedded_list_read_ #ifndef _di_fll_fss_embedded_list_write_string_ - f_status_t fll_fss_embedded_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_string_dynamic_t *destination) { + f_status_t fll_fss_embedded_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -134,7 +134,7 @@ extern "C" { f_status_t status = 0; f_string_range_t range = macro_f_string_range_t_initialize(object.used); - status = fl_fss_embedded_list_object_write_string(object, f_fss_complete_full, &range, destination); + status = fl_fss_embedded_list_object_write_string(object, f_fss_complete_full, state, &range, destination); if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { return status; @@ -150,7 +150,7 @@ extern "C" { range.stop = 0; } - status = fl_fss_embedded_list_content_write_string(content, f_fss_complete_full, content_prepend, ignore, &range, destination); + status = fl_fss_embedded_list_content_write_string(content, f_fss_complete_full, content_prepend, ignore, state, &range, destination); } return status; diff --git a/level_2/fll_fss/c/fss_embedded_list.h b/level_2/fll_fss/c/fss_embedded_list.h index cd01980..22b66a2 100644 --- a/level_2/fll_fss/c/fss_embedded_list.h +++ b/level_2/fll_fss/c/fss_embedded_list.h @@ -31,6 +31,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The range within the buffer that is currently being read. * @param nest @@ -58,6 +67,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_number_overflow (with error bit) if the maximimum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. @@ -71,7 +81,7 @@ extern "C" { * Errors (with error bit) from: fl_fss_embedded_list_object_read(). */ #ifndef _di_fll_fss_embedded_list_read_ - extern f_status_t fll_fss_embedded_list_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_nest_t *nest, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments); + extern f_status_t fll_fss_embedded_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_nest_t *nest, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments); #endif // _di_fll_fss_embedded_list_read_ /** @@ -89,6 +99,15 @@ extern "C" { * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close. * Any valid nested object open or valid nested object close inside an ingore range will not be escaped. * Set the pointer address to 0 to disable. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param destination * The buffer where the content is written to. * @@ -100,6 +119,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -109,7 +129,7 @@ extern "C" { * Errors (with error bit) from: f_string_dynamic_increase_by(). */ #ifndef _di_fll_fss_embedded_list_write_string_ - extern f_status_t fll_fss_embedded_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_string_dynamic_t *destination); + extern f_status_t fll_fss_embedded_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t *destination); #endif // _di_fll_fss_embedded_list_write_string_ #ifdef __cplusplus diff --git a/level_2/fll_fss/c/fss_extended.c b/level_2/fll_fss/c/fss_extended.c index 200470d..fd20be5 100644 --- a/level_2/fll_fss/c/fss_extended.c +++ b/level_2/fll_fss/c/fss_extended.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fll_fss_extended_read_ - f_status_t fll_fss_extended_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_quotess_t *contents_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) { + f_status_t fll_fss_extended_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_quotess_t *contents_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) { #ifndef _di_level_2_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!objects) return F_status_set_error(F_parameter); @@ -24,19 +24,19 @@ extern "C" { do { if (objects->used == objects->size) { - macro_f_fss_objects_t_increase(status2, (*objects)); + macro_f_fss_objects_t_increase(status2, f_memory_default_allocation_small, (*objects)); if (F_status_is_error(status2)) return status2; - macro_f_fss_contents_t_increase(status2, (*contents)); + macro_f_fss_contents_t_increase(status2, f_memory_default_allocation_small, (*contents)); if (F_status_is_error(status2)) return status2; if (objects_quoted) { - macro_f_fss_quotes_t_increase(status2, (*objects_quoted)); + macro_f_fss_quotes_t_increase(status2, f_memory_default_allocation_small, (*objects_quoted)); if (F_status_is_error(status2)) return status2; } if (contents_quoted) { - macro_f_fss_quotess_t_increase(status2, (*contents_quoted)); + macro_f_fss_quotess_t_increase(status2, f_memory_default_allocation_small, (*contents_quoted)); if (F_status_is_error(status2)) return status2; } } @@ -46,7 +46,7 @@ extern "C" { quoted_object = &objects_quoted->array[objects_quoted->used]; } - status = fl_fss_extended_object_read(buffer, range, &objects->array[objects->used], quoted_object, objects_delimits); + status = fl_fss_extended_object_read(buffer, state, range, &objects->array[objects->used], quoted_object, objects_delimits); if (F_status_is_error(status)) return status; if (range->start >= range->stop || range->start >= buffer.used) { @@ -57,13 +57,13 @@ extern "C" { objects_quoted->used++; } - macro_f_fss_content_t_increase(status2, contents->array[contents->used]) + macro_f_fss_content_t_increase(status2, f_memory_default_allocation_small, contents->array[contents->used]) if (F_status_is_error(status2)) return status2; contents->used++; if (contents_quoted) { - macro_f_fss_quotes_t_increase(status2, contents_quoted->array[contents_quoted->used]) + macro_f_fss_quotes_t_increase(status2, f_memory_default_allocation_small, contents_quoted->array[contents_quoted->used]) if (F_status_is_error(status2)) return status2; contents_quoted->used++; @@ -91,13 +91,13 @@ extern "C" { found_data = F_true; if (contents_quoted) { - macro_f_fss_quotes_t_increase(status2, contents_quoted->array[contents_quoted->used]) + macro_f_fss_quotes_t_increase(status2, f_memory_default_allocation_small, contents_quoted->array[contents_quoted->used]) if (F_status_is_error(status2)) return status2; quoted_content = &contents_quoted->array[contents_quoted->used]; } - status = fl_fss_extended_content_read(buffer, range, &contents->array[contents->used], quoted_content, contents_delimits ? contents_delimits : objects_delimits); + status = fl_fss_extended_content_read(buffer, state, range, &contents->array[contents->used], quoted_content, contents_delimits ? contents_delimits : objects_delimits); if (F_status_is_error(status)) return status; break; @@ -193,7 +193,7 @@ extern "C" { #endif // _di_fll_fss_extended_read_ #ifndef _di_fll_fss_extended_write_string_ - f_status_t fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *destination) { + f_status_t fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -201,7 +201,7 @@ extern "C" { f_status_t status = 0; f_string_range_t range = macro_f_string_range_t_initialize(object.used); - status = fl_fss_extended_object_write_string(object, quote, f_fss_complete_full, &range, destination); + status = fl_fss_extended_object_write_string(object, quote, f_fss_complete_full, state, &range, destination); if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { return status; @@ -225,7 +225,7 @@ extern "C" { range.stop = 0; } - status = fl_fss_extended_content_write_string(contents.array[i], quote, complete, &range, destination); + status = fl_fss_extended_content_write_string(contents.array[i], quote, complete, state, &range, destination); if (F_status_is_error(status)) return status; } // for } diff --git a/level_2/fll_fss/c/fss_extended.h b/level_2/fll_fss/c/fss_extended.h index 10a1ec7..7c21574 100644 --- a/level_2/fll_fss/c/fss_extended.h +++ b/level_2/fll_fss/c/fss_extended.h @@ -31,6 +31,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The range within the buffer that is currently being read. * @param objects @@ -60,16 +69,17 @@ extern "C" { * F_data_not_eol if there is no data to write and EOL was reached (@todo: review related code and detemine what this is doing). * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. - * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. * F_number_overflow (with error bit) if the maximimum buffer size is reached. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. * * Errors (with error bit) from: fl_fss_extended_content_read(). * Errors (with error bit) from: fl_fss_extended_object_read(). */ #ifndef _di_fll_fss_extended_read_ - extern f_status_t fll_fss_extended_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_quotess_t *contents_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits); + extern f_status_t fll_fss_extended_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *objects_quoted, f_fss_quotess_t *contents_quoted, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits); #endif // _di_fll_fss_extended_read_ /** @@ -82,6 +92,15 @@ extern "C" { * @param quote * If 0, then double quotes are auto-inserted, when required. * Otherwise, this is the type of quote to wrap the object in when writing. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param destination * The buffer where the content is written to. * @@ -93,6 +112,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -102,7 +122,7 @@ extern "C" { * Errors (with error bit) from: f_string_dynamic_increase_by(). */ #ifndef _di_fll_fss_extended_write_string_ - extern f_status_t fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *destination); + extern f_status_t fll_fss_extended_write_string(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_state_t state, f_string_dynamic_t *destination); #endif // _di_fll_fss_extended_write_string_ #ifdef __cplusplus diff --git a/level_2/fll_fss/c/fss_extended_list.c b/level_2/fll_fss/c/fss_extended_list.c index cf2132b..816ae78 100644 --- a/level_2/fll_fss/c/fss_extended_list.c +++ b/level_2/fll_fss/c/fss_extended_list.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fll_fss_extended_list_read_ - f_status_t fll_fss_extended_list_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { + f_status_t fll_fss_extended_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { #ifndef _di_level_2_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!objects) return F_status_set_error(F_parameter); @@ -29,14 +29,14 @@ extern "C" { } do { - status = fl_fss_extended_list_object_read(buffer, range, &objects->array[objects->used], objects_delimits); + status = fl_fss_extended_list_object_read(buffer, state, range, &objects->array[objects->used], objects_delimits); if (F_status_is_error(status)) return status; if (range->start >= range->stop || range->start >= buffer.used) { if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) { objects->used++; - macro_f_fss_content_t_increase(status2, contents->array[contents->used]) + macro_f_fss_content_t_increase(status2, f_memory_default_allocation_small, contents->array[contents->used]) if (F_status_is_error(status2)) return status2; contents->used++; @@ -63,7 +63,7 @@ extern "C" { if (status == FL_fss_found_object) { found_data = F_true; - status = fl_fss_extended_list_content_read(buffer, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits, comments); + status = fl_fss_extended_list_content_read(buffer, state, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits, comments); if (F_status_is_error(status)) return status; break; @@ -71,7 +71,7 @@ extern "C" { else if (status == FL_fss_found_object_content_not) { found_data = F_true; - macro_f_fss_content_t_increase(status2, contents->array[contents->used]) + macro_f_fss_content_t_increase(status2, f_memory_default_allocation_small, contents->array[contents->used]) if (F_status_is_error(status2)) return status2; break; @@ -128,7 +128,7 @@ extern "C" { #endif // _di_fll_fss_extended_list_read_ #ifndef _di_fll_fss_extended_list_write_string_ - f_status_t fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_string_dynamic_t *destination) { + f_status_t fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ @@ -136,7 +136,7 @@ extern "C" { f_status_t status = 0; f_string_range_t range = macro_f_string_range_t_initialize(object.used); - status = fl_fss_extended_list_object_write_string(object, f_fss_complete_full, &range, destination); + status = fl_fss_extended_list_object_write_string(object, f_fss_complete_full, state, &range, destination); if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { return status; @@ -152,7 +152,7 @@ extern "C" { range.stop = 0; } - status = fl_fss_extended_list_content_write_string(content, f_fss_complete_full, content_prepend, ignore, &range, destination); + status = fl_fss_extended_list_content_write_string(content, f_fss_complete_full, content_prepend, ignore, state, &range, destination); } return status; diff --git a/level_2/fll_fss/c/fss_extended_list.h b/level_2/fll_fss/c/fss_extended_list.h index da8690b..bd7f5fe 100644 --- a/level_2/fll_fss/c/fss_extended_list.h +++ b/level_2/fll_fss/c/fss_extended_list.h @@ -33,6 +33,15 @@ extern "C" { * * @param buffer * The buffer to read from. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param range * The range within the buffer that is currently being read. * @param objects @@ -62,6 +71,7 @@ extern "C" { * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_complete_not_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_number_overflow (with error bit) if the maximimum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. @@ -75,7 +85,7 @@ extern "C" { * Errors (with error bit) from: fl_fss_extended_list_object_read(). */ #ifndef _di_fll_fss_extended_list_read_ - extern f_status_t fll_fss_extended_list_read(const f_string_static_t buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments); + extern f_status_t fll_fss_extended_list_read(const f_string_static_t buffer, f_state_t state, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments); #endif // _di_fll_fss_extended_list_read_ /** @@ -93,6 +103,15 @@ extern "C" { * These ranges are only checked/ignored if there is a valid nested object open or a valid nested object close. * Any valid nested object open or valid nested object close inside an ingore range will not be escaped. * Set the pointer address to 0 to disable. + * @param state + * A state for handling interrupts during long running operations. + * There is no print_error() usage at this time (@todo this should be implemented and supported). + * There is no functions structure. + * There is no data structure passed to these functions (@todo the additional parameters could be moved to a custom structure). + * + * When interrupt() returns, only F_interrupt and F_interrupt_not are processed. + * Error bit designates an error but must be passed along with F_interrupt. + * All other statuses are ignored. * @param destination * The buffer where the content is written to. * @@ -104,6 +123,7 @@ extern "C" { * F_data_not_stop no data to write due start location being greater than stop location. * * F_complete_not_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. + * F_interrupt (with error bit) if stopping due to an interrupt. * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) is returned on failure to read/process a UTF-8 character. @@ -113,7 +133,7 @@ extern "C" { * Errors (with error bit) from: f_string_dynamic_increase_by(). */ #ifndef _di_fll_fss_extended_list_write_string_ - extern f_status_t fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_string_dynamic_t *destination); + extern f_status_t fll_fss_extended_list_write_string(const f_string_static_t object, const f_string_static_t content, const f_string_static_t *content_prepend, const f_string_ranges_t *ignore, f_state_t state, f_string_dynamic_t *destination); #endif // _di_fll_fss_extended_list_write_string_ #ifdef __cplusplus diff --git a/level_2/fll_iki/c/private-iki.c b/level_2/fll_iki/c/private-iki.c index acac135..1c94356 100644 --- a/level_2/fll_iki/c/private-iki.c +++ b/level_2/fll_iki/c/private-iki.c @@ -38,7 +38,7 @@ extern "C" { } else if (content.string[i]) { if (escaped->used + 1 > escaped->size) { - status = f_string_dynamic_increase_by(f_memory_default_allocation_step, escaped); + status = f_string_dynamic_increase_by(f_memory_default_allocation_small, escaped); if (F_status_is_error(status)) return status; } @@ -173,7 +173,7 @@ extern "C" { } else if (content.string[i]) { if (unescaped->used + 1 > unescaped->size) { - status = f_string_dynamic_increase_by(f_memory_default_allocation_step, unescaped); + status = f_string_dynamic_increase_by(f_memory_default_allocation_small, unescaped); if (F_status_is_error(status)) return status; } diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 09dfab4..c39faab 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -179,7 +179,7 @@ extern "C" { status = F_none; } else { - macro_f_memory_structure_increment(status, (*destination), 1, f_memory_default_allocation_step, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, (*destination), 1, f_memory_default_allocation_small, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) break; destination->array[destination->used] = ripped; @@ -252,7 +252,7 @@ extern "C" { status = F_none; } else { - macro_f_string_dynamics_t_increase(status, (*destination)); + macro_f_string_dynamics_t_increase(status, f_memory_default_allocation_small, (*destination)); if (F_status_is_error(status)) return status; destination->array[destination->used] = ripped; diff --git a/level_2/fll_status/c/status.c b/level_2/fll_status/c/status.c index ca38ce0..62f8a31 100644 --- a/level_2/fll_status/c/status.c +++ b/level_2/fll_status/c/status.c @@ -625,6 +625,18 @@ extern "C" { return F_none; } + if (fl_string_compare(string, FL_status_string_disable, length, FL_status_string_disable_length) == F_equal_to) { + *code = F_disable; + + return F_none; + } + + if (fl_string_compare(string, FL_status_string_disable_not, length, FL_status_string_disable_not_length) == F_equal_to) { + *code = F_disable_not; + + return F_none; + } + if (fl_string_compare(string, FL_status_string_done, length, FL_status_string_done_length) == F_equal_to) { *code = F_done; @@ -661,6 +673,18 @@ extern "C" { return F_none; } + if (fl_string_compare(string, FL_status_string_enable, length, FL_status_string_enable_length) == F_equal_to) { + *code = F_enable; + + return F_none; + } + + if (fl_string_compare(string, FL_status_string_enable_not, length, FL_status_string_enable_not_length) == F_equal_to) { + *code = F_enable_not; + + return F_none; + } + if (fl_string_compare(string, FL_status_string_encoding, length, FL_status_string_encoding_length) == F_equal_to) { *code = F_encoding; diff --git a/level_3/controller/c/controller.h b/level_3/controller/c/controller.h index 0283366..f859927 100644 --- a/level_3/controller/c/controller.h +++ b/level_3/controller/c/controller.h @@ -96,9 +96,6 @@ extern "C" { #ifndef _di_controller_defines_ - // This specifically must be at least 2 for this project. - #define controller_default_allocation_step 4 - #define controller_default_program_script "bash" #define controller_path_pid "/var/run/controller/controller-" diff --git a/level_3/controller/c/private-common.c b/level_3/controller/c/private-common.c index fc3ea96..48b3f13 100644 --- a/level_3/controller/c/private-common.c +++ b/level_3/controller/c/private-common.c @@ -415,7 +415,7 @@ extern "C" { f_status_t controller_pids_increase(controller_pids_t *pids) { if (pids->used + 1 > pids->size) { - f_array_length_t size = pids->used + controller_default_allocation_step; + f_array_length_t size = pids->used + controller_common_allocation_small; if (size > f_array_length_t_size) { if (pids->used + 1 > f_array_length_t_size) { @@ -581,7 +581,7 @@ extern "C" { f_status_t controller_processs_increase(controller_processs_t *processs) { if (processs->used + 1 > processs->size) { - f_array_length_t size = processs->used + controller_default_allocation_step; + f_array_length_t size = processs->used + controller_common_allocation_small; if (size > f_array_length_t_size) { if (processs->used + 1 > f_array_length_t_size) { @@ -760,7 +760,7 @@ extern "C" { f_status_t controller_rule_ons_increase(controller_rule_ons_t *ons) { if (ons->used + 1 > ons->size) { - f_array_length_t size = ons->used + controller_default_allocation_step; + f_array_length_t size = ons->used + controller_common_allocation_small; if (size > f_array_length_t_size) { if (ons->used + 1 > f_array_length_t_size) { @@ -811,7 +811,7 @@ extern "C" { f_status_t controller_rules_increase(controller_rules_t *rules) { if (rules->used + 1 > rules->size) { - f_array_length_t size = rules->used + controller_default_allocation_step; + f_array_length_t size = rules->used + controller_common_allocation_small; if (size > f_array_length_t_size) { if (rules->used + 1 > f_array_length_t_size) { diff --git a/level_3/controller/c/private-common.h b/level_3/controller/c/private-common.h index 9fd89ea..695943b 100644 --- a/level_3/controller/c/private-common.h +++ b/level_3/controller/c/private-common.h @@ -330,6 +330,20 @@ extern "C" { #endif // _di_controller_resource_limit_t_ /** + * Provide common/generic definitions. + * + * The controller_common_allocation_large or controller_common_allocation_small must be at least 2 for this project. + * + * controller_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_controller_common_ + #define controller_common_allocation_large 256 + #define controller_common_allocation_small 16 +#endif // _di_controller_common_ + +/** * Action related cache. * * line_action: The line in some file representing an Action. @@ -1409,7 +1423,30 @@ extern "C" { controller_processs_t_initialize, \ controller_cache_t_initialize, \ } -#endif // _di_controller_data_common_t_ +#endif // _di_controller_thread_t_ + +/** + * A structure for passing data to the interrupt state function. + * + * is_normal: Boolean designating if this is operating in a normal state. + * thread: The thread data. + */ +#ifndef _di_controller_state_interrupt_t_ + typedef struct { + bool is_normal; + controller_thread_t *thread; + } controller_state_interrupt_t; + + #define controller_state_interrupt_t_initialize { \ + F_true, \ + 0, \ + } + + #define macro_controller_state_interrupt_t_initialize(is_normal, thread) { \ + is_normal, \ + thread, \ + } +#endif // _di_controller_state_interrupt_t_ /** * A wrapper used for passing a common set of all data, particularly for sharing between threads. @@ -1843,7 +1880,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + controller_default_allocation_step <= size). + * F_data_not on success, but there is no reason to increase size (used + controller_common_allocation_small <= 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. @@ -1951,7 +1988,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + controller_default_allocation_step <= size). + * F_data_not on success, but there is no reason to increase size (used + controller_common_allocation_small <= 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. @@ -2096,7 +2133,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + controller_default_allocation_step <= size). + * F_data_not on success, but there is no reason to increase size (used + controller_common_allocation_small <= 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. @@ -2151,7 +2188,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + controller_default_allocation_step <= size). + * F_data_not on success, but there is no reason to increase size (used + controller_common_allocation_small <= 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. diff --git a/level_3/controller/c/private-controller.c b/level_3/controller/c/private-controller.c index 52bb3dd..aafdce7 100644 --- a/level_3/controller/c/private-controller.c +++ b/level_3/controller/c/private-controller.c @@ -479,7 +479,7 @@ extern "C" { cache->action.name_action.used = 0; cache->action.name_item.used = 0; - macro_f_array_lengths_t_increase_by(status, cache->ats, controller_default_allocation_step) + macro_f_array_lengths_t_increase_by(status, cache->ats, controller_common_allocation_small) if (F_status_is_error(status)) { controller_entry_error_print(is_entry, global.main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, global.thread); @@ -583,7 +583,7 @@ extern "C" { if (error_has) break; - macro_f_array_lengths_t_increase_by(status2, cache->ats, controller_default_allocation_step) + macro_f_array_lengths_t_increase_by(status2, cache->ats, controller_common_allocation_small) if (F_status_is_error(status2)) { controller_entry_error_print(is_entry, global.main->error, cache->action, F_status_set_fine(status2), "macro_f_array_lengths_t_increase_by", F_true, global.thread); @@ -723,7 +723,7 @@ extern "C" { if (F_status_is_error(status)) return status; } - macro_f_array_lengths_t_increase_by(status, cache->ats, controller_default_allocation_step) + macro_f_array_lengths_t_increase_by(status, cache->ats, controller_common_allocation_small) if (F_status_is_error(status)) { controller_entry_error_print(is_entry, global->main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, global->thread); @@ -971,7 +971,7 @@ extern "C" { return F_status_is_error(F_critical); } - macro_f_array_lengths_t_increase_by(status, cache->ats, controller_default_allocation_step) + macro_f_array_lengths_t_increase_by(status, cache->ats, controller_common_allocation_small) if (F_status_is_error(status)) { controller_entry_error_print(is_entry, global->main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, global->thread); diff --git a/level_3/controller/c/private-entry.c b/level_3/controller/c/private-entry.c index b308636..b327594 100644 --- a/level_3/controller/c/private-entry.c +++ b/level_3/controller/c/private-entry.c @@ -214,9 +214,11 @@ extern "C" { } // while { + controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(F_true, global.thread); + f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large, controller_common_allocation_small, 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, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); + status = fll_fss_extended_read(cache->buffer_file, state, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); } if (F_status_is_error(status)) { @@ -815,9 +817,11 @@ 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(controller_common_allocation_large, controller_common_allocation_small, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_string_range_t range = macro_f_string_range_t_initialize(cache->buffer_file.used); - status = fll_fss_basic_list_read(cache->buffer_file, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments); + status = fll_fss_basic_list_read(cache->buffer_file, state, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "fll_fss_basic_list_read", F_true, global.thread); @@ -886,7 +890,7 @@ extern "C" { cache->action.name_action.used = 0; cache->action.name_item.used = 0; - status = controller_entry_items_increase_by(controller_default_allocation_step, &entry->items); + status = controller_entry_items_increase_by(controller_common_allocation_small, &entry->items); if (F_status_is_error(status)) { controller_entry_error_print(is_entry, global.main->error, cache->action, F_status_set_fine(status), "controller_entry_items_increase_by", F_true, global.thread); @@ -1104,9 +1108,11 @@ extern "C" { f_status_t status = F_none; { + controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_entry, global.thread); + f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large, controller_common_allocation_small, 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, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); + status = fll_fss_extended_read(cache->buffer_file, state, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); } if (F_status_is_error(status)) { diff --git a/level_3/controller/c/private-rule.c b/level_3/controller/c/private-rule.c index 9927df4..7d19c00 100644 --- a/level_3/controller/c/private-rule.c +++ b/level_3/controller/c/private-rule.c @@ -60,7 +60,7 @@ extern "C" { if (object && object->start <= object->start) { - status = f_string_dynamics_increase(parameters); + status = f_string_dynamics_increase(controller_common_allocation_small, parameters); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread); @@ -95,7 +95,7 @@ extern "C" { if (content->array[i].start > content->array[i].start) continue; - status = f_string_dynamics_increase(parameters); + status = f_string_dynamics_increase(controller_common_allocation_small, parameters); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread); @@ -229,7 +229,7 @@ extern "C" { #endif // _di_controller_rule_actions_increase_by_ #ifndef _di_controller_rule_action_read_ - f_status_t controller_rule_action_read(const controller_global_t global, const uint8_t type, const uint8_t method, controller_cache_t *cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) { + f_status_t controller_rule_action_read(const bool is_normal, const controller_global_t global, const uint8_t type, const uint8_t method, controller_cache_t *cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) { f_status_t status = F_none; @@ -244,7 +244,12 @@ extern "C" { actions->array[actions->used].parameters.used = 0; } - status = fl_fss_extended_list_content_read(cache->buffer_item, range, &cache->content_action, &cache->delimits, &cache->comments); + { + controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); + f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large, controller_common_allocation_small, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + + status = fl_fss_extended_list_content_read(cache->buffer_item, state, range, &cache->content_action, &cache->delimits, &cache->comments); + } if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "fl_fss_extended_list_content_read", F_true, global.thread); @@ -261,7 +266,7 @@ extern "C" { if (item->type == controller_rule_item_type_script || item->type == controller_rule_item_type_utility) { actions->array[actions->used].parameters.used = 0; - status = f_string_dynamics_increase(&actions->array[actions->used].parameters); + status = f_string_dynamics_increase(controller_common_allocation_small, &actions->array[actions->used].parameters); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread); @@ -293,8 +298,13 @@ extern "C" { return status; } - // the object_actions and content_actions caches are being used for the purposes of getting the parameters a given the action. - status = fll_fss_extended_read(cache->buffer_item, &cache->content_action.array[0], &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); + { + controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); + f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large, controller_common_allocation_small, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + + // the object_actions and content_actions caches are being used for the purposes of getting the parameters a given the action. + status = fll_fss_extended_read(cache->buffer_item, state, &cache->content_action.array[0], &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); + } if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "fll_fss_extended_read", F_true, global.thread); @@ -312,7 +322,7 @@ extern "C" { f_array_length_t j = 0; for (; i < cache->object_actions.used; ++i) { - status = controller_rule_actions_increase_by(controller_default_allocation_step, actions); + status = controller_rule_actions_increase_by(controller_common_allocation_small, actions); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "controller_rule_actions_increase_by", F_true, global.thread); @@ -331,7 +341,7 @@ extern "C" { actions->array[actions->used].parameters.used = 0; actions->array[actions->used].status = F_known_not; - status = f_string_dynamics_increase(&actions->array[actions->used].parameters); + status = f_string_dynamics_increase(controller_common_allocation_small, &actions->array[actions->used].parameters); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread); @@ -356,11 +366,15 @@ extern "C" { } } else { - cache->content_action.used = 0; cache->delimits.used = 0; - status = fl_fss_extended_content_read(cache->buffer_item, range, &cache->content_action, 0, &cache->delimits); + { + controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); + f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large, controller_common_allocation_small, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); + + status = fl_fss_extended_content_read(cache->buffer_item, state, range, &cache->content_action, 0, &cache->delimits); + } if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "fll_fss_extended_content_read", F_true, global.thread); @@ -372,7 +386,7 @@ extern "C" { controller_error_print(global.main->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true, global.thread); } else if (item->type == controller_rule_item_type_script || item->type == controller_rule_item_type_utility) { - status = f_string_dynamics_increase(&actions->array[actions->used].parameters); + status = f_string_dynamics_increase(controller_common_allocation_small, &actions->array[actions->used].parameters); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true, global.thread); @@ -1309,7 +1323,7 @@ extern "C" { return status; } - status = f_string_dynamics_increase(&process->path_pids); + status = f_string_dynamics_increase(controller_common_allocation_small, &process->path_pids); if (F_status_is_error(status)) { fll_error_print(global.main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true); @@ -1592,10 +1606,11 @@ extern "C" { #endif // _di_controller_rule_status_is_error_ #ifndef _di_controller_rule_item_read_ - f_status_t controller_rule_item_read(const controller_global_t global, controller_cache_t *cache, controller_rule_item_t *item) { + f_status_t controller_rule_item_read(const bool is_normal, const controller_global_t global, controller_cache_t *cache, controller_rule_item_t *item) { 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(controller_common_allocation_large, controller_common_allocation_small, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_string_range_t range = macro_f_string_range_t_initialize(cache->buffer_item.used); f_array_length_t last = 0; @@ -1607,7 +1622,7 @@ extern "C" { for (; range.start < cache->buffer_item.used && range.start <= range.stop; last = range.start, cache->delimits.used = 0, cache->comments.used = 0) { - status = fl_fss_extended_list_object_read(cache->buffer_item, &range, &cache->range_action, &cache->delimits); + status = fl_fss_extended_list_object_read(cache->buffer_item, state, &range, &cache->range_action, &cache->delimits); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "fl_fss_extended_list_object_read", F_true, global.thread); @@ -1623,7 +1638,7 @@ extern "C" { cache->delimits.used = 0; // The current line is not an Extended List object, so the next possibility is a Basic List (and Extended List, both use the same Object structure). - status = fl_fss_extended_object_read(cache->buffer_item, &range, &cache->range_action, 0, &cache->delimits); + status = fl_fss_extended_object_read(cache->buffer_item, state, &range, &cache->range_action, 0, &cache->delimits); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "fl_fss_extended_object_read", F_true, global.thread); @@ -1737,14 +1752,14 @@ extern "C" { method = controller_rule_action_method_extended; } - status = controller_rule_actions_increase_by(controller_default_allocation_step, &item->actions); + status = controller_rule_actions_increase_by(controller_common_allocation_small, &item->actions); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "controller_rule_actions_increase_by", F_true, global.thread); break; } - status = controller_rule_action_read(global, type, method, cache, item, &item->actions, &range); + status = controller_rule_action_read(is_normal, global, type, method, cache, item, &item->actions, &range); if (F_status_is_error(status)) break; } // for @@ -2822,7 +2837,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = f_type_array_lengths_increase(&process->stack); + status = f_type_array_lengths_increase(controller_common_allocation_small, &process->stack); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "f_type_array_lengths_increase", F_true, global.thread); @@ -3077,9 +3092,11 @@ extern "C" { rule->timestamp = cache->timestamp; 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(controller_common_allocation_large, controller_common_allocation_small, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); f_string_range_t range = macro_f_string_range_t_initialize(cache->buffer_file.used); - status = fll_fss_basic_list_read(cache->buffer_file, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments); + status = fll_fss_basic_list_read(cache->buffer_file, state, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments); if (F_status_is_error(status)) { controller_error_print(global.main->error, F_status_set_fine(status), "fll_fss_basic_list_read", F_true, global.thread); @@ -3197,7 +3214,7 @@ extern "C" { } if (rule->items.array[rule->items.used].type) { - status = controller_rule_item_read(global, cache, &rule->items.array[rule->items.used]); + status = controller_rule_item_read(is_normal, global, cache, &rule->items.array[rule->items.used]); if (F_status_is_error(status)) break; rule->items.used++; @@ -3205,7 +3222,7 @@ extern "C" { else { for_item = F_false; - status = controller_rule_setting_read(global, *global.setting, cache, rule); + status = controller_rule_setting_read(is_normal, global, *global.setting, cache, rule); if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_memory_not) { @@ -3229,7 +3246,7 @@ extern "C" { #endif // _di_controller_rule_read_ #ifndef _di_controller_rule_setting_read_ - f_status_t controller_rule_setting_read(const controller_global_t global, const controller_setting_t setting, controller_cache_t *cache, controller_rule_t *rule) { + f_status_t controller_rule_setting_read(const bool is_normal, const controller_global_t global, const controller_setting_t setting, controller_cache_t *cache, controller_rule_t *rule) { f_status_t status = F_none; f_status_t status_return = F_none; @@ -3237,7 +3254,12 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(cache->buffer_item.used); f_string_range_t range2 = f_string_range_t_initialize; - status = fll_fss_extended_read(cache->buffer_item, &range, &cache->object_actions, &cache->content_actions, 0, 0, &cache->delimits, 0); + { + controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); + f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large, controller_common_allocation_small, 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); + } if (F_status_is_error(status)) { controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "fll_fss_extended_read", F_true, F_false, global.thread); @@ -3472,7 +3494,7 @@ extern "C" { // @todo this needs to be in a function such as f_int32s_increase(). if (rule->affinity.used + 1 > rule->affinity.size) { - f_array_length_t size = rule->affinity.used + f_memory_default_allocation_step; + f_array_length_t size = rule->affinity.used + controller_common_allocation_small; if (size > f_array_length_t_size) { if (rule->affinity.used + 1 > f_array_length_t_size) { @@ -3593,7 +3615,7 @@ extern "C" { setting_maps = &rule->parameter; } - status = f_string_maps_increase(setting_maps); + status = f_string_maps_increase(controller_common_allocation_small, setting_maps); if (F_status_is_error(status)) { controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_string_maps_increase", F_true, F_false, global.thread); @@ -3757,7 +3779,7 @@ extern "C" { for (j = 1; j < cache->content_actions.array[i].used; ++j) { - status = f_string_dynamics_increase(&rule->control_group.groups); + status = f_string_dynamics_increase(controller_common_allocation_small, &rule->control_group.groups); if (F_status_is_error(status)) { controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase", F_true, F_false, global.thread); @@ -3940,7 +3962,7 @@ extern "C" { if (F_status_is_error(status)) continue; - macro_f_limit_sets_t_increase(status, rule->limits); + macro_f_limit_sets_t_increase(status, controller_common_allocation_small, rule->limits); if (F_status_is_error(status)) { controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_limit_sets_increase", F_true, F_false, global.thread); @@ -4640,7 +4662,7 @@ extern "C" { for (j = 0; j < cache->content_actions.array[i].used; ++j) { - macro_f_array_lengths_t_increase_by(status, rule->groups, controller_default_allocation_step) + macro_f_array_lengths_t_increase_by(status, rule->groups, controller_common_allocation_small) if (F_status_is_error(status)) { controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "macro_f_array_lengths_t_increase_by", F_true, F_false, global.thread); @@ -4747,7 +4769,7 @@ extern "C" { for (j = 0; j < cache->content_actions.array[i].used; ++j) { - status = f_string_dynamics_increase(setting_values); + status = f_string_dynamics_increase(controller_common_allocation_small, setting_values); if (F_status_is_error(status)) { controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase", F_true, F_false, global.thread); @@ -5002,7 +5024,7 @@ extern "C" { continue; } - status = f_string_dynamics_increase_by(controller_default_allocation_step, setting_values); + status = f_string_dynamics_increase_by(controller_common_allocation_small, setting_values); if (F_status_is_error(status)) { controller_rule_error_print(global.main->error, cache->action, F_status_set_fine(status), "f_string_dynamics_increase_by", F_true, F_false, global.thread); diff --git a/level_3/controller/c/private-rule.h b/level_3/controller/c/private-rule.h index f55a3d7..268a4b8 100644 --- a/level_3/controller/c/private-rule.h +++ b/level_3/controller/c/private-rule.h @@ -118,6 +118,9 @@ extern "C" { * * This will automatically increase the size of the actions array as needed. * + * @param is_normal + * If TRUE, then process as if this operates during a normal operation (entry and control). + * If FALSE, then process as if this operates during a an exit operation. * @param global * The global data. * @param type @@ -146,7 +149,7 @@ extern "C" { * @see f_fss_count_lines() */ #ifndef _di_controller_rule_action_read_ - extern f_status_t controller_rule_action_read(const controller_global_t global, const uint8_t type, const uint8_t method, controller_cache_t *cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) f_attribute_visibility_internal; + extern f_status_t controller_rule_action_read(const bool is_normal, const controller_global_t global, const uint8_t type, const uint8_t method, controller_cache_t *cache, controller_rule_item_t *item, controller_rule_actions_t *actions, f_string_range_t *range) f_attribute_visibility_internal; #endif // _di_controller_rule_action_read_ /** @@ -540,6 +543,9 @@ extern "C" { * * This will perform additional FSS read functions as appropriate. * + * @param is_normal + * If TRUE, then process as if this operates during a normal operation (entry and control). + * If FALSE, then process as if this operates during a an exit operation. * @param global * The global data. * @param cache @@ -560,7 +566,7 @@ extern "C" { * @see f_string_dynamic_terminate_after() */ #ifndef _di_controller_rule_item_read_ - extern f_status_t controller_rule_item_read(const controller_global_t global, controller_cache_t *cache, controller_rule_item_t *item) f_attribute_visibility_internal; + extern f_status_t controller_rule_item_read(const bool is_normal, const controller_global_t global, controller_cache_t *cache, controller_rule_item_t *item) f_attribute_visibility_internal; #endif // _di_controller_rule_item_read_ /** @@ -770,6 +776,9 @@ extern "C" { * Errors from this are not considered fatal, but the first error code encountered is returned. * Memory failure errors are always immediately returned. * + * @param is_normal + * If TRUE, then process as if this operates during a normal operation (entry and control). + * If FALSE, then process as if this operates during a an exit operation. * @param global * The global data. * @param setting @@ -798,7 +807,7 @@ extern "C" { * @see fll_path_canonical() */ #ifndef _di_controller_rule_setting_read_ - extern f_status_t controller_rule_setting_read(const controller_global_t global, const controller_setting_t setting, controller_cache_t *cache, controller_rule_t *rule) f_attribute_visibility_internal; + extern f_status_t controller_rule_setting_read(const bool is_normal, const controller_global_t global, const controller_setting_t setting, controller_cache_t *cache, controller_rule_t *rule) f_attribute_visibility_internal; #endif // _di_controller_rule_setting_read_ /** diff --git a/level_3/controller/c/private-thread.c b/level_3/controller/c/private-thread.c index 6118547..57a0d6c 100644 --- a/level_3/controller/c/private-thread.c +++ b/level_3/controller/c/private-thread.c @@ -989,6 +989,62 @@ extern "C" { } #endif // _di_controller_thread_signal_ +#ifndef _di_controller_thread_signal_state_fss_ + f_status_t controller_thread_signal_state_fss(void *state, void *internal) { + + if (!state) { + return F_interrupt_not; + } + + f_state_t *state_ptr = (f_state_t *) state; + + if (!state_ptr->custom) { + return F_interrupt_not; + } + + controller_state_interrupt_t *custom = (controller_state_interrupt_t *) state_ptr->custom; + controller_thread_t *thread = custom->thread; + + if (!controller_thread_is_enabled(custom->is_normal, thread)) { + return F_status_set_error(F_interrupt); + } + + if (thread->signal == F_signal_interrupt || thread->signal == F_signal_abort || thread->signal == F_signal_quit || thread->signal == F_signal_termination) { + return F_status_set_error(F_interrupt); + } + + return F_interrupt_not; + } +#endif // _di_controller_thread_signal_state_fss_ + +#ifndef _di_controller_thread_signal_state_iki_ + f_status_t controller_thread_signal_state_iki(void *state, void *internal) { + + if (!state) { + return F_interrupt_not; + } + + f_state_t *state_ptr = (f_state_t *) state; + + if (!state_ptr->custom) { + return F_interrupt_not; + } + + controller_state_interrupt_t *custom = (controller_state_interrupt_t *) state_ptr->custom; + controller_thread_t *thread = custom->thread; + + if (!controller_thread_is_enabled(custom->is_normal, thread)) { + return F_status_set_error(F_interrupt); + } + + if (thread->signal == F_signal_interrupt || thread->signal == F_signal_abort || thread->signal == F_signal_quit || thread->signal == F_signal_termination) { + return F_status_set_error(F_interrupt); + } + + return F_interrupt_not; + } +#endif // _di_controller_thread_signal_state_iki_ + #ifndef _di_controller_thread_signal_normal_ void * controller_thread_signal_normal(void *arguments) { diff --git a/level_3/controller/c/private-thread.h b/level_3/controller/c/private-thread.h index 017c976..5ccc921 100644 --- a/level_3/controller/c/private-thread.h +++ b/level_3/controller/c/private-thread.h @@ -272,8 +272,6 @@ extern "C" { /** * Thread for handling signals/interrupts. * - * Currently this only handles signals to exist, but may be updated to handle interrupt and hangup signals. - * * @param is_normal * If TRUE, then process as if this operates during a normal operation (entry and control). * If FALSE, then process as if this operates during a an exit operation. @@ -285,6 +283,40 @@ extern "C" { #endif // _di_controller_thread_signal_ /** + * Callback passed to FSS functions for checking for interrupts. + * + * @param state + * The f_state_t data. + * @param internal + * Not used. + * + * @return + * F_interrupt_not if not interrupted. + * + * F_interrupt (with error bit) if interrupted. + */ +#ifndef _di_controller_thread_signal_state_fss_ + extern f_status_t controller_thread_signal_state_fss(void *state, void *internal) f_attribute_visibility_internal; +#endif // _di_controller_thread_signal_state_fss_ + +/** + * Callback passed to IKI functions for checking for interrupts. + * + * @param state + * The f_state_t data. + * @param internal + * Not used. + * + * @return + * F_interrupt_not if not interrupted. + * + * F_interrupt (with error bit) if interrupted. + */ +#ifndef _di_controller_thread_signal_state_iki_ + extern f_status_t controller_thread_signal_state_iki(void *state, void *internal) f_attribute_visibility_internal; +#endif // _di_controller_thread_signal_state_iki_ + +/** * Thread for handling signals/interrupts during normal operations. * * Currently this only handles signals to exist, but may be updated to handle interrupt and hangup signals. diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 8968852..ba6255f 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -1328,7 +1328,11 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(buffer.used); f_fss_delimits_t delimits = f_fss_delimits_t_initialize; - *status = fll_fss_extended_read(buffer, &range, &objects, &contents, 0, 0, &delimits, 0); + { + f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large, fake_common_allocation_small, 0, &fake_signal_state_interrupt_fss, 0, (void *) &main, 0); + + *status = fll_fss_extended_read(buffer, state, &range, &objects, &contents, 0, 0, &delimits, 0); + } if (F_status_is_error(*status)) { fake_print_error_fss(main, F_status_set_fine(*status), "fll_fss_extended_read", main.file_data_build_settings.string, range, F_true); diff --git a/level_3/fake/c/private-common.h b/level_3/fake/c/private-common.h index 3dd5aba..baa3b2a 100644 --- a/level_3/fake/c/private-common.h +++ b/level_3/fake/c/private-common.h @@ -385,7 +385,17 @@ extern "C" { #define fake_build_parameter_object_link_arguments_length 3 #endif // _di_fake_build_parameter_ +/** + * Provide common/generic definitions. + * + * fake_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ #ifndef _di_fake_common_ + #define fake_common_allocation_large 256 + #define fake_common_allocation_small 16 + #define fake_common_initial_buffer_max 131072 // 128k max default initial buffer size. #define fake_common_setting_bool_yes "yes" diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index c18d14e..254b994 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -956,6 +956,52 @@ extern "C" { } #endif // _di_fake_signal_read_ +#ifndef _di_fake_signal_state_interrupt_fss_ + f_status_t fake_signal_state_interrupt_fss(void *state, void *internal) { + + if (!state) { + return F_interrupt_not; + } + + f_state_t *state_ptr = (f_state_t *) state; + + if (!state_ptr->custom) { + return F_interrupt_not; + } + + fake_main_t *main = (fake_main_t *) state_ptr->custom; + + if (fake_signal_received(*main)) { + return F_status_set_error(F_interrupt); + } + + return F_interrupt_not; + } +#endif // _di_fake_signal_state_interrupt_fss_ + +#ifndef _di_fake_signal_state_interrupt_iki_ + f_status_t fake_signal_state_interrupt_iki(void *state, void *internal) { + + if (!state) { + return F_interrupt_not; + } + + f_state_t *state_ptr = (f_state_t *) state; + + if (!state_ptr->custom) { + return F_interrupt_not; + } + + fake_main_t *main = (fake_main_t *) state_ptr->custom; + + if (fake_signal_received(*main)) { + return F_status_set_error(F_interrupt); + } + + return F_interrupt_not; + } +#endif // _di_fake_signal_state_interrupt_iki_ + #ifndef _di_fake_validate_directories_ f_status_t fake_validate_parameter_directories(const f_console_arguments_t arguments, const fake_main_t main) { diff --git a/level_3/fake/c/private-fake.h b/level_3/fake/c/private-fake.h index e7f87b9..0d3a3df 100644 --- a/level_3/fake/c/private-fake.h +++ b/level_3/fake/c/private-fake.h @@ -125,6 +125,40 @@ extern "C" { #endif // _di_fake_signal_read_ /** + * Callback passed to FSS functions for checking for interrupts. + * + * @param state + * The f_state_t data. + * @param internal + * Not used. + * + * @return + * F_interrupt_not if not interrupted. + * + * F_interrupt (with error bit) if interrupted. + */ +#ifndef _di_fake_signal_state_interrupt_fss_ + extern f_status_t fake_signal_state_interrupt_fss(void *state, void *internal) f_attribute_visibility_internal; +#endif // _di_fake_signal_state_interrupt_fss_ + +/** + * Callback passed to IKI functions for checking for interrupts. + * + * @param state + * The f_state_t data. + * @param internal + * Not used. + * + * @return + * F_interrupt_not if not interrupted. + * + * F_interrupt (with error bit) if interrupted. + */ +#ifndef _di_fake_signal_state_interrupt_iki_ + extern f_status_t fake_signal_state_interrupt_iki(void *state, void *internal) f_attribute_visibility_internal; +#endif // _di_fake_signal_state_interrupt_iki_ + +/** * Validate directories and print any relating error messages. * * This should not be called for skeleton as in that case the directories probably do not exist. diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index b648dde..89369c5 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -177,6 +177,7 @@ extern "C" { if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return; } @@ -185,6 +186,7 @@ extern "C" { if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return; } @@ -207,7 +209,11 @@ extern "C" { f_fss_delimits_t delimits = f_fss_delimits_t_initialize; f_fss_comments_t comments = f_fss_comments_t_initialize; - *status = fll_fss_basic_list_read(data_make->buffer, &range, &list_objects, &list_contents, &delimits, 0, &comments); + { + f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large, fake_common_allocation_small, 0, &fake_signal_state_interrupt_fss, 0, (void *) &main, 0); + + *status = fll_fss_basic_list_read(data_make->buffer, state, &range, &list_objects, &list_contents, &delimits, 0, &comments); + } if (F_status_is_error(*status)) { fake_print_error_fss(main, F_status_set_fine(*status), "fll_fss_basic_list_read", main.file_data_build_fakefile.string, range, F_true); @@ -235,6 +241,8 @@ extern "C" { f_fss_set_t settings = f_fss_set_t_initialize; + f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large, fake_common_allocation_small, 0, &fake_signal_state_interrupt_fss, 0, (void *) &main, 0); + const f_string_static_t name_settings = macro_f_string_static_t_initialize(fake_make_section_settings, fake_make_section_settings_length); const f_string_static_t name_main = macro_f_string_static_t_initialize(fake_make_section_main, fake_make_section_main_length); @@ -273,7 +281,7 @@ extern "C" { delimits.used = 0; content_range = list_contents.array[i].array[0]; - *status = fll_fss_extended_read(data_make->buffer, &content_range, &settings.objects, &settings.contents, 0, 0, &delimits, 0); + *status = fll_fss_extended_read(data_make->buffer, state, &content_range, &settings.objects, &settings.contents, 0, 0, &delimits, 0); if (F_status_is_error(*status)) { fake_print_error_fss(main, F_status_set_fine(*status), "fll_fss_extended_read", main.file_data_build_fakefile.string, content_range, F_true); @@ -305,7 +313,7 @@ extern "C" { delimits.used = 0; content_range = list_contents.array[i].array[0]; - *status = fll_fss_extended_read(data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents, 0, &data_make->fakefile.array[data_make->fakefile.used].quotess, &delimits, 0); + *status = fll_fss_extended_read(data_make->buffer, state, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents, 0, &data_make->fakefile.array[data_make->fakefile.used].quotess, &delimits, 0); if (F_status_is_error(*status)) { fake_print_error_fss(main, F_status_set_fine(*status), "fll_fss_extended_read", main.file_data_build_fakefile.string, content_range, F_true); @@ -354,7 +362,7 @@ extern "C" { { f_string_t function_name = "macro_f_string_map_multis_t_resize"; - macro_f_string_map_multis_t_resize(*status, data_make->setting_make.parameter, f_memory_default_allocation_step); + macro_f_string_map_multis_t_resize(*status, data_make->setting_make.parameter, f_memory_default_allocation_small); if (F_status_is_error_not(*status)) { data_make->setting_make.parameter.used = 1; @@ -447,7 +455,7 @@ extern "C" { if (k == data_make->setting_build.environment.used) { if (data_make->setting_build.environment.used + 1 > data_make->setting_build.environment.size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, &data_make->setting_build.environment); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, &data_make->setting_build.environment); if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -766,7 +774,7 @@ extern "C" { if (main.context.mode != f_color_mode_none) { if (data_make->parameter.color.used >= data_make->parameter.color.size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, &data_make->parameter.color); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, &data_make->parameter.color); if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -822,7 +830,7 @@ extern "C" { if (main.error.verbosity != f_console_verbosity_normal) { if (data_make->parameter.verbosity.used >= data_make->parameter.verbosity.size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, &data_make->parameter.verbosity); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, &data_make->parameter.verbosity); if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -905,7 +913,7 @@ extern "C" { for (j = 0; j < source[i]->used; j++) { if (destination[i]->used >= destination[i]->size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, destination[i]); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, destination[i]); if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -933,7 +941,7 @@ extern "C" { } if (destination[i]->used >= destination[i]->size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, destination[i]); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, destination[i]); if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -998,7 +1006,7 @@ extern "C" { for (uint8_t i = 0; i < 7; i ++) { if (destination[i]->used >= destination[i]->size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, destination[i]); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, destination[i]); if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -1026,7 +1034,7 @@ extern "C" { } if (destination[i]->used >= destination[i]->size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, destination[i]); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, destination[i]); if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -1066,7 +1074,7 @@ extern "C" { f_array_lengths_t section_stack = f_array_lengths_t_initialize; fake_make_data_t data_make = fake_make_data_t_initialize; - status = f_string_dynamics_increase(&data_make.path.stack); + status = f_string_dynamics_increase(f_memory_default_allocation_small, &data_make.path.stack); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true); @@ -1175,6 +1183,7 @@ extern "C" { #ifndef _di_fake_make_operate_expand_ void fake_make_operate_expand(const fake_main_t main, const f_string_range_t section_name, const f_array_length_t operation, const f_string_static_t operation_name, const f_fss_content_t content, const f_fss_quotes_t quotes, fake_make_data_t *data_make, f_string_dynamics_t *arguments, f_status_t *status) { + if (F_status_is_error(*status)) return; if (!content.used) return; @@ -1198,6 +1207,8 @@ extern "C" { f_iki_vocabulary_t iki_vocabulary = f_iki_vocabulary_t_initialize; f_iki_content_t iki_content = f_iki_content_t_initialize; + f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large, fake_common_allocation_small, 0, &fake_signal_state_interrupt_iki, 0, (void *) &main, 0); + f_string_range_t range = f_string_range_t_initialize; f_string_map_multis_t *parameter = &data_make->setting_make.parameter; @@ -1211,7 +1222,6 @@ extern "C" { f_array_length_t l = 0; f_array_length_t used_arguments = 0; - f_array_length_t previous = 0; const f_string_t reserved_name[] = { @@ -1266,7 +1276,7 @@ extern "C" { used_arguments = arguments->used; - *status = fl_iki_read(&data_make->buffer, &range, &iki_variable, &iki_vocabulary, &iki_content); + *status = fl_iki_read(state, &data_make->buffer, &range, &iki_variable, &iki_vocabulary, &iki_content); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "fl_iki_read", F_true); @@ -1274,7 +1284,7 @@ extern "C" { } if (arguments->used >= arguments->size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, arguments); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, arguments); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -1296,6 +1306,7 @@ extern "C" { } for (j = 0, previous = iki_variable.array[0].start; j < iki_variable.used; j++) { + parameter_is = F_false; define_is = F_false; @@ -1360,7 +1371,7 @@ extern "C" { if (fl_string_dynamic_partial_compare_string(reserved_name[k], data_make->buffer, reserved_length[k], iki_content.array[j]) == F_equal_to) { if (arguments->used >= arguments->size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, arguments); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, arguments); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -1430,7 +1441,7 @@ extern "C" { } else { if (arguments->used >= arguments->size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, arguments); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, arguments); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); @@ -1808,7 +1819,7 @@ extern "C" { status = f_string_dynamic_append_nulless(value, &arguments->array[arguments->used]); } else { - status = f_string_dynamics_increase_by(f_memory_default_allocation_step, arguments); + status = f_string_dynamics_increase_by(f_memory_default_allocation_small, arguments); if (F_status_is_error_not(status)) { status = f_string_dynamic_append_nulless(value, &arguments->array[arguments->used]); @@ -1864,7 +1875,7 @@ extern "C" { status = f_string_dynamic_append_nulless(value, &arguments->array[arguments->used]); } else { - status = f_string_dynamics_increase_by(f_memory_default_allocation_step, arguments); + status = f_string_dynamics_increase_by(f_memory_default_allocation_small, arguments); if (F_status_is_error_not(status)) { status = f_string_dynamic_append_nulless(value, &arguments->array[arguments->used]); @@ -1907,7 +1918,7 @@ extern "C" { // add the operation id to the operation stack. if (section_stack->used + 1 > section_stack->size) { - macro_f_array_lengths_t_increase_by((*status), (*section_stack), f_memory_default_allocation_step); + macro_f_array_lengths_t_increase_by((*status), (*section_stack), f_memory_default_allocation_small); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "macro_f_array_lengths_t_increase_by", F_true); @@ -3653,7 +3664,7 @@ extern "C" { } else { if (data_make->path.stack.used == data_make->path.stack.size) { - *status = f_string_dynamics_increase_by(f_memory_default_allocation_step, &data_make->path.stack); + *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, &data_make->path.stack); if (F_status_set_fine(*status) == F_array_too_large) { fake_print_message_section_operation_path_stack_max(*main, data_make->error, F_array_too_large, "f_string_dynamics_increase_by", "path stack"); diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index 744063f..4bd28cd 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -192,6 +192,7 @@ extern "C" { f_string_range_t input = f_string_range_t_initialize; if (command == firewall_parameter_command_show) { + // Warning: these are hardcoded print commands (I am not certain how I am going to implement external 'show' rules as the default-firewall setting file is the wrong place to put this) bool show_nat = F_true; bool show_mangle = F_true; @@ -232,6 +233,7 @@ extern "C" { if (F_status_is_error(status)) { f_color_print(main->error.to.stream, main->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol_s[0]); + firewall_delete_local_data(&local); firewall_main_delete(main); return status; diff --git a/level_3/firewall/c/firewall.h b/level_3/firewall/c/firewall.h index 3d8c444..b164c5c 100644 --- a/level_3/firewall/c/firewall.h +++ b/level_3/firewall/c/firewall.h @@ -77,7 +77,7 @@ extern "C" { #endif // _di_firewall_paths_ #ifndef _di_firewall_default_allocation_step_ - #define firewall_default_allocation_step f_memory_default_allocation_step + #define firewall_default_allocation_step f_memory_default_allocation_small #endif // _di_firewall_default_allocation_step_ #ifndef _di_firewall_defines_ diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 5831b17..cdca940 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -322,7 +322,7 @@ f_status_t firewall_perform_commands(const firewall_local_data_t local, const fi // first add the program name f_string_dynamics_resize(0, &arguments); - status = f_string_dynamics_increase(&arguments); + status = f_string_dynamics_increase(f_memory_default_allocation_small, &arguments); if (F_status_is_error(status)) break; if (tool == firewall_program_ip46tables) { @@ -650,9 +650,10 @@ f_status_t firewall_perform_commands(const firewall_local_data_t local, const fi f_fss_delimits_t delimits = f_fss_delimits_t_initialize; { + f_state_t state = f_state_t_initialize; f_string_range_t input = macro_f_string_range_t_initialize(local_buffer.used); - status = fll_fss_basic_read(local_buffer, &input, &basic_objects, &basic_contents, 0, &delimits, 0); + status = fll_fss_basic_read(local_buffer, state, &input, &basic_objects, &basic_contents, 0, &delimits, 0); } if (F_status_set_error(status)) { @@ -906,7 +907,7 @@ f_status_t firewall_create_custom_chains(firewall_reserved_chains_t *reserved, f arguments.array[0].used = firewall_chain_create_command_length; - status = f_string_dynamic_increase(&arguments.array[1]); + status = f_string_dynamic_increase(f_memory_default_allocation_small, &arguments.array[1]); if (F_status_is_error(status)) { arguments.used = 1; @@ -1430,9 +1431,10 @@ f_status_t firewall_buffer_rules(const f_string_t filename, const bool optional, f_fss_comments_t comments = f_fss_comments_t_initialize; { + f_state_t state = f_state_t_initialize; f_string_range_t input = macro_f_string_range_t_initialize(local->buffer.used); - status = fll_fss_basic_list_read(local->buffer, &input, &local->chain_objects, &local->chain_contents, &delimits, 0, &comments); + status = fll_fss_basic_list_read(local->buffer, state, &input, &local->chain_objects, &local->chain_contents, &delimits, 0, &comments); } if (F_status_is_error(status)) { @@ -1466,9 +1468,15 @@ f_status_t firewall_buffer_rules(const f_string_t filename, const bool optional, } f_status_t firewall_process_rules(f_string_range_t *range, firewall_local_data_t *local, firewall_main_t *main) { + + f_status_t status = F_none; f_fss_delimits_t delimits = f_fss_delimits_t_initialize; - f_status_t status = fll_fss_extended_read(local->buffer, range, &local->rule_objects, &local->rule_contents, 0, 0, &delimits, 0); + { + f_state_t state = f_state_t_initialize; + + status = fll_fss_extended_read(local->buffer, state, range, &local->rule_objects, &local->rule_contents, 0, 0, &delimits, 0); + } if (F_status_is_error_not(status)) { status = fl_fss_apply_delimit(delimits, &local->buffer); diff --git a/level_3/fss_basic_list_read/c/private-common.h b/level_3/fss_basic_list_read/c/private-common.h index ad90a27..b54f1ad 100644 --- a/level_3/fss_basic_list_read/c/private-common.h +++ b/level_3/fss_basic_list_read/c/private-common.h @@ -13,6 +13,18 @@ extern "C" { #endif /** + * Provide common/generic definitions. + * + * basic_list_read_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_basic_list_read_common_ + #define fss_basic_list_read_common_allocation_large 256 + #define fss_basic_list_read_common_allocation_small 16 +#endif // _di_fss_basic_list_read_common_ + +/** * A structure of parameters applied at some depth. * * depth: The depth number in which this is to be processed at. diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index 54e0908..0855521 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -225,12 +225,13 @@ extern "C" { #ifndef _di_fss_basic_list_read_load_ f_status_t fss_basic_list_read_load(fss_basic_list_read_main_t * const main, fss_basic_list_read_data_t *data) { + f_state_t state = macro_f_state_t_initialize(fss_basic_list_read_common_allocation_large, fss_basic_list_read_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); data->delimits_object.used = 0; data->delimits_content.used = 0; - const f_status_t status = fll_fss_basic_list_read(data->buffer, &input, &data->objects, &data->contents, &data->delimits_object, &data->delimits_content, &data->comments); + const f_status_t status = fll_fss_basic_list_read(data->buffer, state, &input, &data->objects, &data->contents, &data->delimits_object, &data->delimits_content, &data->comments); if (F_status_is_error(status)) { const f_string_t file_name = fss_basic_list_read_file_identify(input.start, data->files); diff --git a/level_3/fss_basic_list_write/c/private-common.h b/level_3/fss_basic_list_write/c/private-common.h index 2c5f723..e568c72 100644 --- a/level_3/fss_basic_list_write/c/private-common.h +++ b/level_3/fss_basic_list_write/c/private-common.h @@ -12,6 +12,18 @@ extern "C" { #endif +/** + * Provide common/generic definitions. + * + * basic_list_write_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_basic_list_write_common_ + #define fss_basic_list_write_common_allocation_large 256 + #define fss_basic_list_write_common_allocation_small 16 +#endif // _di_fss_basic_list_write_common_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c index fdca799..93e5cf8 100644 --- a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c @@ -54,8 +54,9 @@ extern "C" { #ifndef _di_fss_basic_list_write_process_ f_status_t fss_basic_list_write_process(const fss_basic_list_write_main_t main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t *buffer) { - f_status_t status = F_none; + f_status_t status = F_none; + f_state_t state = macro_f_state_t_initialize(fss_basic_list_write_common_allocation_large, fss_basic_list_write_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -79,7 +80,7 @@ extern "C" { } } - status = fl_fss_basic_list_object_write_string(*object, complete, &range, buffer); + status = fl_fss_basic_list_object_write_string(*object, complete, state, &range, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_basic_list_write_error_parameter_unsupported_eol_print(main); @@ -89,6 +90,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_basic_list_object_write_string", F_true); + return status; } } @@ -97,10 +99,11 @@ extern "C" { range.start = 0; range.stop = content->used - 1; - status = fl_fss_basic_list_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &main.prepend, &range, buffer); + status = fl_fss_basic_list_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &main.prepend, state, &range, buffer); if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_basic_list_content_write_string", F_true); + return status; } } @@ -110,6 +113,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "f_string_append", F_true); + return status; } } @@ -123,6 +127,7 @@ extern "C" { #ifndef _di_fss_basic_list_write_process_pipe_ f_status_t fss_basic_list_write_process_pipe(const fss_basic_list_write_main_t main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t *buffer) { + f_status_t status = F_none; f_status_t status_pipe = F_none; @@ -181,17 +186,17 @@ extern "C" { } } - for (; range.start <= range.stop; range.start++) { + for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_basic_list_write_pipe_content_start) { state = 0x2; - range.start++; + ++range.start; break; } if (block.string[range.start] == fss_basic_list_write_pipe_content_end) { state = 0x3; - range.start++; + ++range.start; break; } @@ -230,7 +235,7 @@ extern "C" { } } - for (; range.start <= range.stop; range.start++) { + for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_basic_list_write_pipe_content_start) { if (main.error.verbosity != f_console_verbosity_quiet) { @@ -244,7 +249,7 @@ extern "C" { if (block.string[range.start] == fss_basic_list_write_pipe_content_end) { state = 0x3; - range.start++; + ++range.start; break; } diff --git a/level_3/fss_basic_read/c/private-common.h b/level_3/fss_basic_read/c/private-common.h index 4d3934d..4b403c2 100644 --- a/level_3/fss_basic_read/c/private-common.h +++ b/level_3/fss_basic_read/c/private-common.h @@ -13,6 +13,18 @@ extern "C" { #endif /** + * Provide common/generic definitions. + * + * basic_read_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_basic_read_common_ + #define fss_basic_read_common_allocation_large 256 + #define fss_basic_read_common_allocation_small 16 +#endif // _di_fss_basic_read_common_ + +/** * A structure of parameters applied at some depth. * * depth: The depth number in which this is to be processed at. diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index 7131b3c..f3f3a2e 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -202,11 +202,12 @@ extern "C" { #ifndef _di_fss_basic_read_load_ f_status_t fss_basic_read_load(fss_basic_read_main_t * const main, fss_basic_read_data_t *data) { + f_state_t state = macro_f_state_t_initialize(fss_basic_read_common_allocation_large, fss_basic_read_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); data->delimits.used = 0; - const f_status_t status = fll_fss_basic_read(data->buffer, &input, &data->objects, &data->contents, 0, &data->delimits, 0); + const f_status_t status = fll_fss_basic_read(data->buffer, state, &input, &data->objects, &data->contents, 0, &data->delimits, 0); if (F_status_is_error(status)) { const f_string_t file_name = fss_basic_read_file_identify(input.start, data->files); diff --git a/level_3/fss_basic_write/c/private-common.h b/level_3/fss_basic_write/c/private-common.h index bbd31e0..559cacf 100644 --- a/level_3/fss_basic_write/c/private-common.h +++ b/level_3/fss_basic_write/c/private-common.h @@ -12,6 +12,18 @@ extern "C" { #endif +/** + * Provide common/generic definitions. + * + * basic_write_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_basic_write_common_ + #define fss_basic_write_common_allocation_large 256 + #define fss_basic_write_common_allocation_small 16 +#endif // _di_fss_basic_write_common_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_write/c/private-fss_basic_write.c b/level_3/fss_basic_write/c/private-fss_basic_write.c index 7946323..53ab66e 100644 --- a/level_3/fss_basic_write/c/private-fss_basic_write.c +++ b/level_3/fss_basic_write/c/private-fss_basic_write.c @@ -54,8 +54,9 @@ extern "C" { #ifndef _di_fss_basic_write_process_ f_status_t fss_basic_write_process(const fss_basic_write_main_t main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t *buffer) { - f_status_t status = F_none; + f_status_t status = F_none; + f_state_t state = macro_f_state_t_initialize(fss_basic_write_common_allocation_large, fss_basic_write_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -79,7 +80,7 @@ extern "C" { } } - status = fl_fss_basic_object_write_string(*object, quote, complete, &range, buffer); + status = fl_fss_basic_object_write_string(*object, quote, complete, state, &range, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_basic_write_error_parameter_unsupported_eol_print(main); @@ -89,6 +90,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_basic_object_write_string", F_true); + return status; } } @@ -103,7 +105,7 @@ extern "C" { range.stop = 0; } - status = fl_fss_basic_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &range, buffer); + status = fl_fss_basic_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, state, &range, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_basic_write_error_parameter_unsupported_eol_print(main); @@ -113,6 +115,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_basic_content_write_string", F_true); + return status; } } @@ -122,6 +125,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "f_string_append", F_true); + return status; } } @@ -135,6 +139,7 @@ extern "C" { #ifndef _di_fss_basic_write_process_pipe_ f_status_t fss_basic_write_process_pipe(const fss_basic_write_main_t main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t *buffer) { + f_status_t status = F_none; f_status_t status_pipe = F_none; @@ -197,13 +202,13 @@ extern "C" { if (block.string[range.start] == fss_basic_write_pipe_content_start) { state = 0x2; - range.start++; + ++range.start; break; } if (block.string[range.start] == fss_basic_write_pipe_content_end) { state = 0x3; - range.start++; + ++range.start; break; } @@ -242,7 +247,7 @@ extern "C" { } } - for (; range.start <= range.stop; range.start++) { + for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_basic_write_pipe_content_start) { if (main.error.verbosity != f_console_verbosity_quiet) { @@ -256,7 +261,7 @@ extern "C" { if (block.string[range.start] == fss_basic_write_pipe_content_end) { state = 0x3; - range.start++; + ++range.start; break; } diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index 6c6a611..7211249 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -23,18 +23,19 @@ extern "C" { fprintf(output.stream, "%c", f_string_eol_s[0]); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_at, fss_embedded_list_read_long_at, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select object at this numeric index."); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_content, fss_embedded_list_read_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the content (default)."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_at, fss_embedded_list_read_long_at, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric index."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_content, fss_embedded_list_read_long_content, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Content (default)."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_columns, fss_embedded_list_read_long_columns, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of columns."); fll_program_print_help_option(output, context, fss_embedded_list_read_short_delimit, fss_embedded_list_read_long_delimit, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Designate how to handle applying delimits."); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_depth, fss_embedded_list_read_long_depth, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select object at this numeric depth."); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_empty, fss_embedded_list_read_long_empty, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Include empty content when processing."); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_line, fss_embedded_list_read_long_line, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print only the content at the given line."); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_name, fss_embedded_list_read_long_name, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select object with this name."); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_object, fss_embedded_list_read_long_object, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the object."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_depth, fss_embedded_list_read_long_depth, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object at this numeric depth."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_empty, fss_embedded_list_read_long_empty, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Include empty Content when processing."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_line, fss_embedded_list_read_long_line, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print only the Content at the given line."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_name, fss_embedded_list_read_long_name, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select Object with this name."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_object, fss_embedded_list_read_long_object, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the Object."); fll_program_print_help_option(output, context, fss_embedded_list_read_short_pipe, fss_embedded_list_read_long_pipe, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print using the special pipe format."); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_select, fss_embedded_list_read_long_select, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-content at this index."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_select, fss_embedded_list_read_long_select, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Select sub-Content at this index."); fll_program_print_help_option(output, context, fss_embedded_list_read_short_total, fss_embedded_list_read_long_total, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print the total number of lines."); - fll_program_print_help_option(output, context, fss_embedded_list_read_short_trim, fss_embedded_list_read_long_trim, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim object names on select or print."); + fll_program_print_help_option(output, context, fss_embedded_list_read_short_trim, fss_embedded_list_read_long_trim, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Trim Object names on select or print."); fll_program_print_help_usage(output, context, fss_embedded_list_read_name, "filename(s)"); @@ -42,7 +43,12 @@ extern "C" { fprintf(output.stream, "%c", f_string_eol_s[0]); - fprintf(output.stream, " This program will print the content associated with the given object and content main based on the FSS-0002 Basic List standard.%c", f_string_eol_s[0]); + fprintf(output.stream, " This program will print the Content associated with the given Object and Content main based on the FSS-0002 Basic List standard.%c", f_string_eol_s[0]); + + fprintf(output.stream, "%c", f_string_eol_s[0]); + + fprintf(output.stream, " All numeric positions (indexes) start at 0 instead of 1.%c", f_string_eol_s[0]); + fprintf(output.stream, " For example, a file of 17 lines would range from 0 to 16.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -54,7 +60,7 @@ extern "C" { fprintf(output.stream, " "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_at); - fprintf(output.stream, ": An object index at the specified depth.%c", f_string_eol_s[0]); + fprintf(output.stream, ": An Object index at the specified depth.%c", f_string_eol_s[0]); fprintf(output.stream, " "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_depth); @@ -62,7 +68,7 @@ extern "C" { fprintf(output.stream, " "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_name); - fprintf(output.stream, ": An object name at the specified depth.%c", f_string_eol_s[0]); + fprintf(output.stream, ": An Object name at the specified depth.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -76,8 +82,7 @@ extern "C" { fprintf(output.stream, " The parameter "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_select); - fprintf(output.stream, " selects a content index at a given depth.%c", f_string_eol_s[0]); - fprintf(output.stream, " (This parameter is not synonymous with the depth parameter and does not relate to nested content).%c", f_string_eol_s[0]); + fprintf(output.stream, " selects a Content column.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -112,11 +117,11 @@ extern "C" { fprintf(output.stream, " For parameters like "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_depth); - fprintf(output.stream, ", if the standard doesn't support nested content, then only a depth of 0 would be valid.%c", f_string_eol_s[0]); + fprintf(output.stream, ", if the standard doesn't support nested Content, then only a depth of 0 would be valid.%c", f_string_eol_s[0]); fprintf(output.stream, " For parameters like "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_select); - fprintf(output.stream, ", if the standard doesn't support multiple content groups, then only a select of 0 would be valid.%c", f_string_eol_s[0]); + fprintf(output.stream, ", if the standard doesn't support multiple Content groups, then only a select of 0 would be valid.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -130,9 +135,9 @@ extern "C" { f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_object); fprintf(output.stream, " parameter and the "); f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_content); - fprintf(output.stream, " parameter, the entire object and content are printed, including the formatting.%c", f_string_eol_s[0]); - fprintf(output.stream, " Both the object and content printed are already escaped.%c", f_string_eol_s[0]); - fprintf(output.stream, " Both the object and content are separated by an EOL.%c", f_string_eol_s[0]); + fprintf(output.stream, " parameter, the entire Object and Content are printed, including the formatting.%c", f_string_eol_s[0]); + fprintf(output.stream, " Both the Object and Content printed are already escaped.%c", f_string_eol_s[0]); + fprintf(output.stream, " Both the Object and Content are separated by an EOL.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -144,14 +149,42 @@ extern "C" { fprintf(output.stream, ": Do not apply delimits.%c", f_string_eol_s[0]); fprintf(output.stream, " - "); f_color_print(output.stream, context.set.notable, "%s", fss_embedded_list_read_delimit_mode_name_all); - fprintf(output.stream, ": (default) apply all delimits.%c", f_string_eol_s[0]); - fprintf(output.stream, " - a number, 0 or greater: apply delimits for the specified depth.%c", f_string_eol_s[0]); - fprintf(output.stream, " - a number, 0 or greater, followed by a "); + fprintf(output.stream, ": (default) Apply all delimits.%c", f_string_eol_s[0]); + // @todo + //fprintf(output.stream, " - "); + //f_color_print(output.stream, context.set.notable, "%s", fss_embedded_list_read_delimit_mode_name_object); + //fprintf(output.stream, ": Apply delimits for Objects.%c", f_string_eol_s[0]); + //fprintf(output.stream, " - A number, 0 or greater: apply delimits for Content at the specified depth.%c", f_string_eol_s[0]); + //fprintf(output.stream, " - A number, 0 or greater, followed by a "); f_color_print(output.stream, context.set.notable, "%s", fss_embedded_list_read_delimit_mode_name_greater); - fprintf(output.stream, ": (such as '1+') apply delimits for the specified depth and any greater depth (numerically).%c", f_string_eol_s[0]); - fprintf(output.stream, " - a number, 0 or greater, followed by a "); + fprintf(output.stream, ": (such as '1+') apply delimits for Content at the specified depth and any greater depth (numerically).%c", f_string_eol_s[0]); + fprintf(output.stream, " - A number, 0 or greater, followed by a "); f_color_print(output.stream, context.set.notable, "%s", fss_embedded_list_read_delimit_mode_name_lesser); - fprintf(output.stream, ": (such as '1-') apply delimits for the specified depth and any lesser depth (numerically).%c", f_string_eol_s[0]); + fprintf(output.stream, ": (such as '1-') apply delimits for Content at the specified depth and any lesser depth (numerically).%c", f_string_eol_s[0]); + + fprintf(output.stream, "%c", f_string_eol_s[0]); + + fprintf(output.stream, " The "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_delimit); + fprintf(output.stream, " parameter may be specified multiple times to customize the delimit behavior.%c", f_string_eol_s[0]); + + fprintf(output.stream, " The "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_delimit); + fprintf(output.stream, " values "); + f_color_print(output.stream, context.set.notable, "%s", fss_embedded_list_read_delimit_mode_name_none); + fprintf(output.stream, " and "); + f_color_print(output.stream, context.set.notable, "%s", fss_embedded_list_read_delimit_mode_name_all); + fprintf(output.stream, ", overrule all other delimit values.%c", f_string_eol_s[0]); + + fprintf(output.stream, "%c", f_string_eol_s[0]); + + fprintf(output.stream, " The parameters "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_columns); + fprintf(output.stream, " and "); + f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_select); + fprintf(output.stream, " refer to a Content column.%c", f_string_eol_s[0]); + fprintf(output.stream, " The word \"column\" is being loosely defined to refer to a specific Content.%c", f_string_eol_s[0]); + fprintf(output.stream, " This is not to be confused with a depth.%c", f_string_eol_s[0]); fprintf(output.stream, "%c", f_string_eol_s[0]); @@ -232,6 +265,18 @@ extern "C" { return F_none; } + if (F_status_is_error_not(status) && main->parameters[fss_embedded_list_read_parameter_total].result == f_console_result_found) { + if (main->parameters[fss_embedded_list_read_parameter_columns].result == f_console_result_found) { + f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_total); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '"); + f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_columns); + f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]); + + status = F_status_set_error(F_parameter); + } + } + if (main->remaining.used > 0 || main->process_pipe) { if (main->parameters[fss_embedded_list_read_parameter_at].result == f_console_result_found) { f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); @@ -249,7 +294,7 @@ extern "C" { status = F_status_set_error(F_parameter); } - if (F_status_is_error_not(status) && main->parameters[fss_embedded_list_read_parameter_line].result == f_console_result_found) { + if (F_status_is_error_not(status) && main->parameters[fss_embedded_list_read_parameter_line].result == f_console_result_additional) { f_color_print(main->error.to.stream, main->context.set.error, "%sThe parameter '", fll_error_print_error); f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_embedded_list_read_long_line); f_color_print(main->error.to.stream, main->context.set.error, "' requires a positive number.%c", f_string_eol_s[0]); diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h index b73fc81..1f36b44 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.h @@ -68,6 +68,7 @@ extern "C" { #define fss_embedded_list_read_short_at "a" #define fss_embedded_list_read_short_content "c" + #define fss_embedded_list_read_short_columns "C" #define fss_embedded_list_read_short_delimit "D" #define fss_embedded_list_read_short_depth "d" #define fss_embedded_list_read_short_empty "e" @@ -81,6 +82,7 @@ extern "C" { #define fss_embedded_list_read_long_at "at" #define fss_embedded_list_read_long_content "content" + #define fss_embedded_list_read_long_columns "columns" #define fss_embedded_list_read_long_delimit "delimit" #define fss_embedded_list_read_long_depth "depth" #define fss_embedded_list_read_long_empty "empty" @@ -105,6 +107,7 @@ extern "C" { fss_embedded_list_read_parameter_at, fss_embedded_list_read_parameter_content, + fss_embedded_list_read_parameter_columns, fss_embedded_list_read_parameter_delimit, fss_embedded_list_read_parameter_depth, fss_embedded_list_read_parameter_empty, @@ -130,6 +133,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_at, fss_embedded_list_read_long_at, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_content, fss_embedded_list_read_long_content, 0, 0, f_console_type_normal), \ + f_console_parameter_t_initialize(fss_embedded_list_read_short_columns, fss_embedded_list_read_long_columns, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_delimit, fss_embedded_list_read_long_delimit, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_depth, fss_embedded_list_read_long_depth, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(fss_embedded_list_read_short_empty, fss_embedded_list_read_long_empty, 0, 0, f_console_type_normal), \ @@ -142,7 +146,7 @@ extern "C" { f_console_parameter_t_initialize(fss_embedded_list_read_short_trim, fss_embedded_list_read_long_trim, 0, 0, f_console_type_normal), \ } - #define fss_embedded_list_read_total_parameters 21 + #define fss_embedded_list_read_total_parameters 22 #endif // _di_fss_embedded_list_read_defines_ #ifndef _di_fss_embedded_list_read_delimit_mode_ diff --git a/level_3/fss_embedded_list_read/c/private-common.h b/level_3/fss_embedded_list_read/c/private-common.h index 6402e84..abc0f88 100644 --- a/level_3/fss_embedded_list_read/c/private-common.h +++ b/level_3/fss_embedded_list_read/c/private-common.h @@ -13,6 +13,18 @@ extern "C" { #endif /** + * Provide common/generic definitions. + * + * embedded_list_read_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_embedded_list_read_common_ + #define fss_embedded_list_read_common_allocation_large 256 + #define fss_embedded_list_read_common_allocation_small 16 +#endif // _di_fss_embedded_list_read_common_ + +/** * A structure of parameters applied at some depth. * * depth: the depth number in which this is to be processed at. diff --git a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c index 26a1fa4..9032d78 100644 --- a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.c @@ -218,16 +218,18 @@ extern "C" { #ifndef _di_fss_embedded_list_read_main_process_file_ f_status_t fss_embedded_list_read_main_process_file(const f_console_arguments_t arguments, fss_embedded_list_read_main_t *main, const f_string_t filename, const fss_embedded_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) { + f_status_t status = F_none; { + f_state_t state = macro_f_state_t_initialize(fss_embedded_list_read_common_allocation_large, fss_embedded_list_read_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(main->buffer.used); objects_delimits->used = 0; contents_delimits->used = 0; comments->used = 0; - status = fll_fss_embedded_list_read(main->buffer, &input, &main->nest, objects_delimits, contents_delimits, comments); + status = fll_fss_embedded_list_read(main->buffer, state, &input, &main->nest, objects_delimits, contents_delimits, comments); if (F_status_is_error(status)) { // @todo: detect and replace fll_error_file_type_file with fll_error_file_type_pipe as appropriate. diff --git a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.h b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.h index 31a946a..67b6d5c 100644 --- a/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.h +++ b/level_3/fss_embedded_list_read/c/private-fss_embedded_list_read.h @@ -20,7 +20,7 @@ extern "C" { * @param arguments * The console arguments to pre-process. * @param main - * The program specific main. + * The main data. * @param depths * This stores the pre-processed depth parameters. * @@ -39,7 +39,7 @@ extern "C" { * @param arguments * The console arguments passed to the program. * @param main - * The program specific main. + * The main data. * @param file_name * The name of the file being processed. * @param depths @@ -83,7 +83,7 @@ extern "C" { * The skip status of any parent lists. * Set parents.length to 0 for depth 0. * @param main - * The program specific main. + * The main data. * @param objects_delimits * An array of delimits detected during processing, for top-level objects. * @param contents_delimits @@ -104,7 +104,7 @@ extern "C" { * Print the end of an content. * * @param main - * The program specific main. + * The main data. */ #ifndef _di_fss_embedded_list_read_print_content_end_ extern void fss_embedded_list_read_print_content_end(const fss_embedded_list_read_main_t main) f_attribute_visibility_internal; @@ -116,7 +116,7 @@ extern "C" { * This is only used in pipe output mode. * * @param main - * The program specific main. + * The main data. */ #ifndef _di_fss_embedded_list_read_print_content_ignore_ extern void fss_embedded_list_read_print_content_ignore(const fss_embedded_list_read_main_t main) f_attribute_visibility_internal; @@ -126,7 +126,7 @@ extern "C" { * Print the end of an object (which is essentially the start of a content). * * @param main - * The program specific main. + * The main data. */ #ifndef _di_fss_embedded_list_read_print_object_end_ extern void fss_embedded_list_read_print_object_end(const fss_embedded_list_read_main_t main) f_attribute_visibility_internal; @@ -136,7 +136,7 @@ extern "C" { * Print the end of an object/content set. * * @param main - * The program specific main. + * The main data. */ #ifndef _di_fss_embedded_list_read_print_set_end_ extern void fss_embedded_list_read_print_set_end(const fss_embedded_list_read_main_t main) f_attribute_visibility_internal; @@ -146,7 +146,7 @@ extern "C" { * Rewrite the object and content delimit ranges to be within the given depth range. * * @param main - * The program specific main. + * The main data. * @param objects_delimits * An array of delimits detected during processing, for top-level objects. * @param contents_delimits @@ -162,7 +162,7 @@ extern "C" { * Write the given delimits at the given depth back into the new delimits array, specifically for contents. * * @param main - * The program specific main. + * The main data. * @param depth * The depth in which to process. * @param original_delimits @@ -182,7 +182,7 @@ extern "C" { * Write the given delimits at the given depth back into the new delimits array, specifically for objects. * * @param main - * The program specific main. + * The main data. * @param depth * The depth in which to process. * @param original_delimits @@ -202,7 +202,7 @@ extern "C" { * Determine if the given location is actually within another depth. * * @param main - * The program specific main. + * The main data. * @param depth * The depth in which to process. * @param location diff --git a/level_3/fss_embedded_list_write/c/private-common.h b/level_3/fss_embedded_list_write/c/private-common.h index db0f899..278dca7 100644 --- a/level_3/fss_embedded_list_write/c/private-common.h +++ b/level_3/fss_embedded_list_write/c/private-common.h @@ -12,6 +12,19 @@ extern "C" { #endif + +/** + * Provide common/generic definitions. + * + * embedded_list_write_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_embedded_list_write_common_ + #define fss_embedded_list_write_common_allocation_large 256 + #define fss_embedded_list_write_common_allocation_small 16 +#endif // _di_fss_embedded_list_write_common_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c index 324fb06..88ea763 100644 --- a/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/private-fss_embedded_list_write.c @@ -54,8 +54,9 @@ extern "C" { #ifndef _di_fss_embedded_list_write_process_ f_status_t fss_embedded_list_write_process(const fss_embedded_list_write_main_t main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, const f_string_ranges_t *ignore, f_string_dynamic_t *buffer) { - f_status_t status = F_none; + f_status_t status = F_none; + f_state_t state = macro_f_state_t_initialize(fss_embedded_list_write_common_allocation_large, fss_embedded_list_write_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -79,7 +80,7 @@ extern "C" { } } - status = fl_fss_embedded_list_object_write_string(*object, complete, &range, buffer); + status = fl_fss_embedded_list_object_write_string(*object, complete, state, &range, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_embedded_list_write_error_parameter_unsupported_eol_print(main); @@ -89,6 +90,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_embedded_list_object_write_string", F_true); + return status; } } @@ -97,10 +99,11 @@ extern "C" { range.start = 0; range.stop = content->used - 1; - status = fl_fss_embedded_list_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &main.prepend, ignore, &range, buffer); + status = fl_fss_embedded_list_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &main.prepend, ignore, state, &range, buffer); if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_embedded_list_content_write_string", F_true); + return status; } } @@ -110,6 +113,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "f_string_append", F_true); + return status; } } @@ -123,6 +127,7 @@ extern "C" { #ifndef _di_fss_embedded_list_write_process_pipe_ f_status_t fss_embedded_list_write_process_pipe(const fss_embedded_list_write_main_t main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t *buffer, f_string_ranges_t *ignore) { + f_status_t status = F_none; f_status_t status_pipe = F_none; @@ -186,17 +191,17 @@ extern "C" { } } - for (; range.start <= range.stop; range.start++) { + for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_embedded_list_write_pipe_content_start) { state = 0x2; - range.start++; + ++range.start; break; } if (block.string[range.start] == fss_embedded_list_write_pipe_content_end) { state = 0x3; - range.start++; + ++range.start; break; } @@ -235,7 +240,7 @@ extern "C" { } } - for (; range.start <= range.stop; range.start++) { + for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_embedded_list_write_pipe_content_start) { if (main.error.verbosity != f_console_verbosity_quiet) { @@ -324,6 +329,7 @@ extern "C" { #ifndef _di_fss_embedded_list_write_process_parameter_ignore_ f_status_t fss_embedded_list_write_process_parameter_ignore(const f_console_arguments_t arguments, const fss_embedded_list_write_main_t main, const f_array_lengths_t contents, const f_array_length_t location, f_string_ranges_t *ignore) { + f_status_t status = F_none; f_array_length_t i = 0; @@ -336,7 +342,7 @@ extern "C" { range.start = 0; - for (; i < main.parameters[fss_embedded_list_write_parameter_ignore].locations.used; i++) { + for (; i < main.parameters[fss_embedded_list_write_parameter_ignore].locations.used; ++i) { l = main.parameters[fss_embedded_list_write_parameter_ignore].locations.array[i]; @@ -358,6 +364,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fss_embedded_list_write_process_parameter_ignore", F_true); + return status; } } @@ -376,6 +383,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_parameter_integer_print(main.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_write_long_ignore, arguments.argv[index]); + return status; } @@ -395,6 +403,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_parameter_integer_print(main.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_write_long_ignore, arguments.argv[index]); + return status; } diff --git a/level_3/fss_extended_list_read/c/private-common.h b/level_3/fss_extended_list_read/c/private-common.h index b0bb8de..4c4946a 100644 --- a/level_3/fss_extended_list_read/c/private-common.h +++ b/level_3/fss_extended_list_read/c/private-common.h @@ -12,6 +12,19 @@ extern "C" { #endif + +/** + * Provide common/generic definitions. + * + * extended_list_read_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_extended_list_read_common_ + #define fss_extended_list_read_common_allocation_large 256 + #define fss_extended_list_read_common_allocation_small 16 +#endif // _di_fss_extended_list_read_common_ + /** * A structure of parameters applied at some depth. * diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index e1f4beb..ca9169b 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -225,12 +225,13 @@ extern "C" { #ifndef _di_fss_extended_list_read_load_ f_status_t fss_extended_list_read_load(fss_extended_list_read_main_t * const main, fss_extended_list_read_data_t *data) { + f_state_t state = macro_f_state_t_initialize(fss_extended_list_read_common_allocation_large, fss_extended_list_read_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); data->delimits_object.used = 0; data->delimits_content.used = 0; - const f_status_t status = fll_fss_extended_list_read(data->buffer, &input, &data->objects, &data->contents, &data->delimits_object, &data->delimits_content, &data->comments); + const f_status_t status = fll_fss_extended_list_read(data->buffer, state, &input, &data->objects, &data->contents, &data->delimits_object, &data->delimits_content, &data->comments); if (F_status_is_error(status)) { const f_string_t file_name = fss_extended_list_read_file_identify(input.start, data->files); diff --git a/level_3/fss_extended_list_write/c/private-common.h b/level_3/fss_extended_list_write/c/private-common.h index e72a46d..ea7a11e 100644 --- a/level_3/fss_extended_list_write/c/private-common.h +++ b/level_3/fss_extended_list_write/c/private-common.h @@ -12,6 +12,18 @@ extern "C" { #endif +/** + * Provide common/generic definitions. + * + * extended_list_write_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_extended_list_write_common_ + #define fss_extended_list_write_common_allocation_large 256 + #define fss_extended_list_write_common_allocation_small 16 +#endif // _di_fss_extended_list_write_common_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c b/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c index acdb66c..460bef8 100644 --- a/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/private-fss_extended_list_write.c @@ -54,8 +54,9 @@ extern "C" { #ifndef _di_fss_extended_list_write_process_ f_status_t fss_extended_list_write_process(const fss_extended_list_write_main_t main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, const f_string_ranges_t *ignore, f_string_dynamic_t *buffer) { - f_status_t status = F_none; + f_status_t status = F_none; + f_state_t state = macro_f_state_t_initialize(fss_extended_list_write_common_allocation_large, fss_extended_list_write_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -79,7 +80,7 @@ extern "C" { } } - status = fl_fss_extended_list_object_write_string(*object, complete, &range, buffer); + status = fl_fss_extended_list_object_write_string(*object, complete, state, &range, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_extended_list_write_error_parameter_unsupported_eol_print(main); @@ -89,6 +90,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_extended_list_object_write_string", F_true); + return status; } } @@ -97,10 +99,11 @@ extern "C" { range.start = 0; range.stop = content->used - 1; - status = fl_fss_extended_list_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &main.prepend, ignore, &range, buffer); + status = fl_fss_extended_list_content_write_string(*content, object ? f_fss_complete_full : f_fss_complete_none, &main.prepend, ignore, state, &range, buffer); if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_extended_list_content_write_string", F_true); + return status; } } @@ -110,6 +113,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "f_string_append", F_true); + return status; } } @@ -123,6 +127,7 @@ extern "C" { #ifndef _di_fss_extended_list_write_process_pipe_ f_status_t fss_extended_list_write_process_pipe(const fss_extended_list_write_main_t main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t *buffer, f_string_ranges_t *ignore) { + f_status_t status = F_none; f_status_t status_pipe = F_none; @@ -190,13 +195,13 @@ extern "C" { if (block.string[range.start] == fss_extended_list_write_pipe_content_start) { state = 0x2; - range.start++; + ++range.start; break; } if (block.string[range.start] == fss_extended_list_write_pipe_content_end) { state = 0x3; - range.start++; + ++range.start; break; } @@ -235,7 +240,7 @@ extern "C" { } } - for (; range.start <= range.stop; range.start++) { + for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_extended_list_write_pipe_content_start) { if (main.error.verbosity != f_console_verbosity_quiet) { @@ -324,6 +329,7 @@ extern "C" { #ifndef _di_fss_extended_list_write_process_parameter_ignore_ f_status_t fss_extended_list_write_process_parameter_ignore(const f_console_arguments_t arguments, const fss_extended_list_write_main_t main, const f_array_lengths_t contents, const f_array_length_t location, f_string_ranges_t *ignore) { + f_status_t status = F_none; f_array_length_t i = 0; @@ -336,7 +342,7 @@ extern "C" { range.start = 0; - for (; i < main.parameters[fss_extended_list_write_parameter_ignore].locations.used; i++) { + for (; i < main.parameters[fss_extended_list_write_parameter_ignore].locations.used; ++i) { l = main.parameters[fss_extended_list_write_parameter_ignore].locations.array[i]; @@ -347,6 +353,7 @@ extern "C" { if (ignore->size + f_fss_default_allocation_step > f_array_length_t_size) { if (ignore->size + 1 > f_array_length_t_size) { fll_error_print(main.error, F_string_too_large, "fss_extended_list_write_process_parameter_ignore", F_true); + return F_status_set_error(F_string_too_large); } @@ -358,6 +365,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fss_extended_list_write_process_parameter_ignore", F_true); + return status; } } @@ -395,6 +403,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_parameter_integer_print(main.error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_write_long_ignore, arguments.argv[index]); + return status; } diff --git a/level_3/fss_extended_read/c/private-common.h b/level_3/fss_extended_read/c/private-common.h index f05a58d..ffb165d 100644 --- a/level_3/fss_extended_read/c/private-common.h +++ b/level_3/fss_extended_read/c/private-common.h @@ -13,6 +13,18 @@ extern "C" { #endif /** + * Provide common/generic definitions. + * + * extended_read_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_extended_read_common_ + #define fss_extended_read_common_allocation_large 256 + #define fss_extended_read_common_allocation_small 16 +#endif // _di_fss_extended_read_common_ + +/** * A structure of parameters applied at some depth. * * depth: The depth number in which this is to be processed at. diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index 44abbd8..779a7ea 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -229,12 +229,13 @@ extern "C" { #ifndef _di_fss_extended_read_load_ f_status_t fss_extended_read_load(fss_extended_read_main_t * const main, fss_extended_read_data_t *data) { + f_state_t state = macro_f_state_t_initialize(fss_extended_read_common_allocation_large, fss_extended_read_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); data->delimits_object.used = 0; data->delimits_content.used = 0; - const f_status_t status = fll_fss_extended_read(data->buffer, &input, &data->objects, &data->contents, 0, 0, &data->delimits_object, &data->delimits_content); + const f_status_t status = fll_fss_extended_read(data->buffer, state, &input, &data->objects, &data->contents, 0, 0, &data->delimits_object, &data->delimits_content); if (F_status_is_error(status)) { const f_string_t file_name = fss_extended_read_file_identify(input.start, data->files); diff --git a/level_3/fss_extended_write/c/private-common.h b/level_3/fss_extended_write/c/private-common.h index 3416f30..a6d1889 100644 --- a/level_3/fss_extended_write/c/private-common.h +++ b/level_3/fss_extended_write/c/private-common.h @@ -12,6 +12,18 @@ extern "C" { #endif +/** + * Provide common/generic definitions. + * + * extended_write_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_fss_extended_write_common_ + #define fss_extended_write_common_allocation_large 256 + #define fss_extended_write_common_allocation_small 16 +#endif // _di_fss_extended_write_common_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_write/c/private-fss_extended_write.c b/level_3/fss_extended_write/c/private-fss_extended_write.c index bd98de2..e09251a 100644 --- a/level_3/fss_extended_write/c/private-fss_extended_write.c +++ b/level_3/fss_extended_write/c/private-fss_extended_write.c @@ -54,8 +54,9 @@ extern "C" { #ifndef _di_fss_extended_write_process_ f_status_t fss_extended_write_process(const fss_extended_write_main_t main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_statics_t *contents, f_string_dynamic_t *buffer) { - f_status_t status = F_none; + f_status_t status = F_none; + f_state_t state = macro_f_state_t_initialize(fss_extended_write_common_allocation_large, fss_extended_write_common_allocation_small, 0, 0, 0, 0, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -79,7 +80,7 @@ extern "C" { } } - status = fl_fss_extended_object_write_string(*object, quote, complete, &range, buffer); + status = fl_fss_extended_object_write_string(*object, quote, complete, state, &range, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_extended_write_error_parameter_unsupported_eol_print(main); @@ -89,6 +90,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_extended_object_write_string", F_true); + return F_status_set_error(status); } } @@ -106,7 +108,7 @@ extern "C" { range.stop = 0; } - status = fl_fss_extended_content_write_string(contents->array[i], quote, i + 1 < contents->used ? f_fss_complete_next : f_fss_complete_end, &range, buffer); + status = fl_fss_extended_content_write_string(contents->array[i], quote, i + 1 < contents->used ? f_fss_complete_next : f_fss_complete_end, state, &range, buffer); if (F_status_set_fine(status) == F_none_eol) { fss_extended_write_error_parameter_unsupported_eol_print(main); @@ -116,6 +118,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "fl_fss_extended_content_write_string", F_true); + return F_status_set_error(status); } } // for @@ -126,6 +129,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "f_string_append", F_true); + return status; } } @@ -139,6 +143,7 @@ extern "C" { #ifndef _di_fss_extended_write_process_pipe_ f_status_t fss_extended_write_process_pipe(const fss_extended_write_main_t main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t *buffer) { + f_status_t status = F_none; f_status_t status_pipe = F_none; @@ -185,7 +190,7 @@ extern "C" { if (!state || state == 0x1) { if (!state) { if (contents.used) { - for (i = 0; i < contents.used; i++) { + for (i = 0; i < contents.used; ++i) { contents.array[i].used = 0; } // for } @@ -209,13 +214,13 @@ extern "C" { if (block.string[range.start] == fss_extended_write_pipe_content_start) { state = 0x2; - range.start++; + ++range.start; break; } if (block.string[range.start] == fss_extended_write_pipe_content_end) { state = 0x4; - range.start++; + ++range.start; break; } @@ -247,7 +252,7 @@ extern "C" { } state = 0x3; - contents.used++; + ++contents.used; } if (state == 0x3) { @@ -259,7 +264,7 @@ extern "C" { } if (total) { - for (; range.start <= range.stop; range.start++) { + for (; range.start <= range.stop; ++range.start) { if (block.string[range.start] == fss_extended_write_pipe_content_start) { if (contents.used + 1 > contents.size) { @@ -271,17 +276,18 @@ extern "C" { } } - contents.used++; + ++contents.used; continue; } if (block.string[range.start] == fss_extended_write_pipe_content_end) { state = 0x4; - range.start++; + ++range.start; break; } if (block.string[range.start] == fss_extended_write_pipe_content_ignore) { + // this is not used by this program. continue; } diff --git a/level_3/iki_read/c/iki_read.h b/level_3/iki_read/c/iki_read.h index 955ed36..6d2e92c 100644 --- a/level_3/iki_read/c/iki_read.h +++ b/level_3/iki_read/c/iki_read.h @@ -40,6 +40,7 @@ #include #include #include +#include #include // fll-2 includes diff --git a/level_3/iki_read/c/private-common.h b/level_3/iki_read/c/private-common.h index 0b00619..59dd19c 100644 --- a/level_3/iki_read/c/private-common.h +++ b/level_3/iki_read/c/private-common.h @@ -12,6 +12,18 @@ extern "C" { #endif +/** + * Provide common/generic definitions. + * + * iki_read_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_iki_read_common_ + #define iki_read_common_allocation_large 256 + #define iki_read_common_allocation_small 16 +#endif // _di_iki_read_common_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/private-iki_read.c b/level_3/iki_read/c/private-iki_read.c index b8a9147..81dd11b 100644 --- a/level_3/iki_read/c/private-iki_read.c +++ b/level_3/iki_read/c/private-iki_read.c @@ -8,7 +8,10 @@ extern "C" { #ifndef _di_iki_read_process_at_ f_status_t iki_read_process_at(const f_console_arguments_t arguments, const f_string_t file_name, iki_read_main_t *main, f_string_range_t *range) { - if (main->parameters[iki_read_parameter_line].result != f_console_result_additional) return F_false; + + if (main->parameters[iki_read_parameter_line].result != f_console_result_additional) { + return F_false; + } f_array_length_t line = 0; @@ -33,6 +36,7 @@ extern "C" { #ifndef _di_iki_read_process_buffer_ f_status_t iki_read_process_buffer(const f_console_arguments_t arguments, const f_string_t file_name, iki_read_main_t *main) { + f_status_t status = F_none; f_iki_variable_t variable = f_iki_variable_t_initialize; @@ -101,14 +105,20 @@ extern "C" { #ifndef _di_iki_read_process_buffer_ranges_ f_status_t iki_read_process_buffer_ranges(const f_console_arguments_t arguments, const f_string_t file_name, iki_read_main_t *main, f_string_range_t *buffer_range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content, f_string_ranges_t *ranges) { + f_status_t status = F_none; bool unmatched = F_true; - status = fl_iki_read(&main->buffer, buffer_range, variable, vocabulary, content); + { + f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large, iki_read_common_allocation_small, 0, 0, 0, 0, 0); + + status = fl_iki_read(state, &main->buffer, buffer_range, variable, vocabulary, content); + } if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fl_iki_read", F_true); + return status; } @@ -216,18 +226,25 @@ extern "C" { #ifndef _di_iki_read_process_buffer_ranges_whole_ f_status_t iki_read_process_buffer_ranges_whole(const f_console_arguments_t arguments, const f_string_t file_name, const f_string_range_t buffer_range, iki_read_main_t *main, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content, f_string_ranges_t *ranges) { + f_status_t status = F_none; f_string_range_t range = buffer_range; - status = fl_iki_read(&main->buffer, &range, variable, vocabulary, content); + { + f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large, iki_read_common_allocation_small, 0, 0, 0, 0, 0); + + status = fl_iki_read(state, &main->buffer, &range, variable, vocabulary, content); + } if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fl_iki_read", F_true); + return status; } if (!variable->used) { f_print_dynamic_partial(main->output.stream, main->buffer, buffer_range); + return F_none; } @@ -391,6 +408,7 @@ extern "C" { #ifndef _di_iki_read_process_buffer_total_ f_status_t iki_read_process_buffer_total(const f_console_arguments_t arguments, const f_string_t file_name, iki_read_main_t *main, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content) { + f_status_t status = F_none; f_string_range_t range = macro_f_string_range_t_initialize(main->buffer.used); @@ -399,18 +417,25 @@ extern "C" { if (status == F_true) { if (range.start > main->buffer.used) { printf("0\n"); + return F_none; } } else if (status == F_data_not) { printf("0\n"); + return F_none; } - status = fl_iki_read(&main->buffer, &range, variable, vocabulary, content); + { + f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large, iki_read_common_allocation_small, 0, 0, 0, 0, 0); + + status = fl_iki_read(state, &main->buffer, &range, variable, vocabulary, content); + } if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fl_iki_read", F_true); + return status; } @@ -442,6 +467,7 @@ extern "C" { range.stop = name.used - 1; for (j = 0; j < vocabulary->used; j++) { + status = fl_string_dynamic_partial_compare(name, main->buffer, range, vocabulary->array[j]); if (status == F_equal_to) total++; @@ -522,6 +548,7 @@ extern "C" { range.start = 0; for (; i < substitutions.used; i++) { + range.stop = substitutions.array[i].replace.used - 1; status = fl_string_dynamic_partial_compare(substitutions.array[i].replace, main.buffer, range, content.array[index]); diff --git a/level_3/iki_read/data/build/dependencies b/level_3/iki_read/data/build/dependencies index d2a916a..f8af2dc 100644 --- a/level_3/iki_read/data/build/dependencies +++ b/level_3/iki_read/data/build/dependencies @@ -15,6 +15,7 @@ f_print fl_console fl_conversion fl_iki +fl_signal fl_string fll_error fll_program diff --git a/level_3/iki_read/data/build/settings b/level_3/iki_read/data/build/settings index e21f594..0b3d820 100644 --- a/level_3/iki_read/data/build/settings +++ b/level_3/iki_read/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_program -lfl_console -lfl_conversion -lfl_iki -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_program -lfl_console -lfl_conversion -lfl_iki -lfl_signal -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_path -lf_pipe -lf_print -lf_signal -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library iki_read.c private-common.c private-iki_read.c diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 6017a12..7277608 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -54,6 +54,7 @@ extern "C" { #ifndef _di_iki_write_main_ f_status_t iki_write_main(const f_console_arguments_t arguments, iki_write_main_t *main) { + f_status_t status = F_none; { @@ -96,6 +97,7 @@ extern "C" { if (F_status_is_error(status)) { iki_write_main_delete(main); + return status; } diff --git a/level_3/iki_write/c/private-common.h b/level_3/iki_write/c/private-common.h index 114ebf9..cc31211 100644 --- a/level_3/iki_write/c/private-common.h +++ b/level_3/iki_write/c/private-common.h @@ -12,6 +12,18 @@ extern "C" { #endif +/** + * Provide common/generic definitions. + * + * iki_write_common_allocation_*: + * - large: An allocation step used for buffers that are anticipated to have large buffers. + * - small: An allocation step used for buffers that are anticipated to have small buffers. + */ +#ifndef _di_iki_write_common_ + #define iki_write_common_allocation_large 256 + #define iki_write_common_allocation_small 16 +#endif // _di_iki_write_common_ + #ifdef __cplusplus } // extern "C" #endif