From 255cfabad7ccb633a8a2c77b1aef142af509363a Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 29 Mar 2022 22:17:30 -0500 Subject: [PATCH] Update: Restructure iki_read to use fll_program_data_t. Create iki_read_data_t for private data and passing the fll_program_data_t pointer. Move parameter initialization and deallocation for FLL program data into main.c. --- level_3/iki_read/c/common.c | 13 -- level_3/iki_read/c/common.h | 75 ------------ level_3/iki_read/c/iki_read.c | 66 +++++----- level_3/iki_read/c/iki_read.h | 2 +- level_3/iki_read/c/main.c | 8 +- level_3/iki_read/c/private-common.c | 33 +++-- level_3/iki_read/c/private-common.h | 59 ++++++++- level_3/iki_read/c/private-print.c | 14 +-- level_3/iki_read/c/private-print.h | 6 +- level_3/iki_read/c/private-read.c | 236 ++++++++++++++++++------------------ level_3/iki_read/c/private-read.h | 36 +++--- 11 files changed, 258 insertions(+), 290 deletions(-) diff --git a/level_3/iki_read/c/common.c b/level_3/iki_read/c/common.c index 44a8021..e2283a6 100644 --- a/level_3/iki_read/c/common.c +++ b/level_3/iki_read/c/common.c @@ -49,19 +49,6 @@ extern "C" { const f_string_static_t iki_read_substitution_with_s = macro_f_string_static_t_initialize(IKI_READ_substitution_with_s, 0, IKI_READ_substitution_with_s_length); #endif // _di_iki_read_substitution_t_ -#ifndef _di_iki_read_main_delete_ - f_status_t iki_read_main_delete(iki_read_main_t * const main) { - - f_console_parameters_delete(&main->parameters); - - f_string_dynamic_resize(0, &main->buffer); - - macro_f_color_context_t_delete_simple(main->context); - - return F_none; - } -#endif // _di_iki_read_main_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/common.h b/level_3/iki_read/c/common.h index 78ca2d5..8e3edb9 100644 --- a/level_3/iki_read/c/common.h +++ b/level_3/iki_read/c/common.h @@ -234,81 +234,6 @@ extern "C" { #define macro_iki_read_substitutions_t_adjust(status, replacements, length) macro_f_memory_structure_adjust(status, replacements, iki_read_substitution_t, length) #endif // _di_iki_read_substitutions_t_ -/** - * The main program data. - * - * parameters: The state of pre-defined parameters passed to the program. - * process_pipe: Designate whether or not to process the input pipe. - * output: The output file for general printing. - * error: The output file for error printing. - * warning: The output file for warning printing. - * signal: The process signal management structure. - * context: The color context. - * - * @todo - */ -#ifndef _di_iki_read_main_t_ - typedef struct { - f_console_parameters_t parameters; - - uint16_t signal_check; - bool process_pipe; - - fl_print_t output; - fl_print_t error; - fl_print_t warning; - - f_signal_t signal; - - uint8_t mode; - - f_number_unsigned_t at; - f_number_unsigned_t line; - - f_string_dynamic_t buffer; - - iki_read_substitutions_t replacements; - - f_color_context_t context; - } iki_read_main_t; - - #define iki_read_main_t_initialize \ - { \ - f_console_parameters_t_initialize, \ - 0, \ - F_false, \ - fl_print_t_initialize, \ - macro_fl_print_t_initialize_error(), \ - macro_fl_print_t_initialize_warning(), \ - f_signal_t_initialize, \ - 0, \ - 0, \ - 0, \ - f_string_dynamic_t_initialize, \ - iki_read_substitutions_t_initialize, \ - f_color_context_t_initialize, \ - } -#endif // _di_iki_read_main_t_ - -/** - * Deallocate main. - * - * Be sure to call this after executing iki_read_main(). - * - * @param main - * The main program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - * - * @see iki_read_main() - */ -#ifndef _di_iki_read_main_delete_ - extern f_status_t iki_read_main_delete(iki_read_main_t * const main); -#endif // _di_iki_read_main_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index c3eafbe..1d28165 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -66,14 +66,10 @@ extern "C" { #endif // _di_iki_read_print_help_ #ifndef _di_iki_read_main_ - f_status_t iki_read_main(iki_read_main_t * const main, const f_console_arguments_t *arguments) { + f_status_t iki_read_main(fll_program_data_t * const main, const f_console_arguments_t *arguments) { f_status_t status = F_none; - f_console_parameter_t parameters[] = iki_read_console_parameter_t_initialize; - main->parameters.array = parameters; - main->parameters.used = iki_read_total_parameters_d; - { f_console_parameter_id_t ids[3] = { iki_read_parameter_no_color_e, iki_read_parameter_light_e, iki_read_parameter_dark_e }; const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3); @@ -107,8 +103,6 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } - iki_read_main_delete(main); - return F_status_set_error(status); } } @@ -124,8 +118,6 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); - iki_read_main_delete(main); - return status; } @@ -151,14 +143,16 @@ extern "C" { } } - f_string_static_t * const argv = main->parameters.arguments.array; + iki_read_data_t data = iki_read_data_t_initialize; + data.main = main; + data.argv = main->parameters.arguments.array; status = F_none; if (main->parameters.array[iki_read_parameter_help_e].result == f_console_result_found_e) { iki_read_print_help(main->output.to, main->context); - iki_read_main_delete(main); + iki_read_data_delete(&data); return F_none; } @@ -166,7 +160,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_version_e].result == f_console_result_found_e) { fll_program_print_version(main->output.to, iki_read_program_version_s); - iki_read_main_delete(main); + iki_read_data_delete(&data); return F_none; } @@ -190,15 +184,15 @@ extern "C" { f_number_unsigned_t number = 0; - status = fl_conversion_dynamic_to_number_unsigned(argv[index], &number); + status = fl_conversion_dynamic_to_number_unsigned(data.argv[index], &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, iki_read_long_at_s, argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, iki_read_long_at_s, data.argv[index]); status = F_status_set_error(F_parameter); } - main->at = number; + data.at = number; if (main->parameters.array[iki_read_parameter_whole_e].result == f_console_result_found_e) { if (main->error.verbosity != f_console_verbosity_quiet_e) { @@ -235,15 +229,15 @@ extern "C" { f_number_unsigned_t number = 0; - status = fl_conversion_dynamic_to_number_unsigned(argv[index], &number); + status = fl_conversion_dynamic_to_number_unsigned(data.argv[index], &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, iki_read_long_line_s, argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_dynamic_to_number_unsigned", F_true, iki_read_long_line_s, data.argv[index]); status = F_status_set_error(F_parameter); } - main->line = number; + data.line = number; } if (main->parameters.array[iki_read_parameter_name_e].result == f_console_result_found_e) { @@ -341,7 +335,7 @@ extern "C" { status = F_status_set_error(F_parameter); } - main->mode = iki_read_mode_literal_e; + data.mode = iki_read_mode_literal_e; } else if (main->parameters.array[iki_read_parameter_object_e].result == f_console_result_found_e) { if (main->parameters.array[iki_read_parameter_content_e].result == f_console_result_found_e) { @@ -376,15 +370,15 @@ extern "C" { status = F_status_set_error(F_parameter); } - main->mode = iki_read_mode_object_e; + data.mode = iki_read_mode_object_e; } else if (main->parameters.array[iki_read_parameter_total_e].result == f_console_result_found_e) { - main->mode = iki_read_mode_total_e; + data.mode = iki_read_mode_total_e; } else { // This is the default behavior, so there is no reason to check for the -c/--content parameter. - main->mode = iki_read_mode_content_e; + data.mode = iki_read_mode_content_e; } if (main->parameters.array[iki_read_parameter_whole_e].result == f_console_result_found_e) { @@ -410,7 +404,7 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream); } - iki_read_main_delete(main); + iki_read_data_delete(&data); return F_status_set_error(F_parameter); } @@ -420,17 +414,17 @@ extern "C" { file.id = F_type_descriptor_input_d; - status = f_file_read(file, &main->buffer); + status = f_file_read(file, &data.buffer); if (F_status_is_error(status)) { fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read", F_true, f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); } else { - status = iki_read_process_buffer(main); + status = iki_read_process_buffer(&data); } // Clear buffers before continuing. - f_string_dynamic_resize(0, &main->buffer); + f_string_dynamic_resize(0, &data.buffer); } if (F_status_is_fine(status) && main->parameters.remaining.used > 0) { @@ -439,7 +433,7 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % iki_read_signal_check_d)) { - if (iki_read_signal_received(main)) { + if (iki_read_signal_received(&data)) { status = F_status_set_error(F_interrupt); break; @@ -451,10 +445,10 @@ extern "C" { macro_f_file_t_reset(file); file.size_read = 0; - status = f_file_open(argv[main->parameters.remaining.array[i]], 0, &file); + status = f_file_open(data.argv[main->parameters.remaining.array[i]], 0, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); break; } @@ -462,7 +456,7 @@ extern "C" { status = f_file_size_by_id(file.id, &file.size_read); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); f_file_stream_close(F_true, &file); @@ -478,21 +472,21 @@ extern "C" { ++file.size_read; - status = f_file_read(file, &main->buffer); + status = f_file_read(file, &data.buffer); f_file_stream_close(F_true, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read", F_true, data.argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); break; } - status = iki_read_process_buffer(main); + status = iki_read_process_buffer(&data); if (F_status_is_error(status)) break; // Clear buffers before repeating the loop. - f_string_dynamic_resize(0, &main->buffer); + f_string_dynamic_resize(0, &data.buffer); } // for } } @@ -506,7 +500,7 @@ extern "C" { // ensure a newline is always put at the end of the program execution, unless in quiet mode. if (main->error.verbosity != f_console_verbosity_quiet_e) { - if (F_status_is_error(status) || !main->mode) { + if (F_status_is_error(status) || !data.mode) { if (F_status_set_fine(status) == F_interrupt) { fflush(main->output.to.stream); } @@ -515,7 +509,7 @@ extern "C" { } } - iki_read_main_delete(main); + iki_read_data_delete(&data); return status; } diff --git a/level_3/iki_read/c/iki_read.h b/level_3/iki_read/c/iki_read.h index 7175928..81fc311 100644 --- a/level_3/iki_read/c/iki_read.h +++ b/level_3/iki_read/c/iki_read.h @@ -98,7 +98,7 @@ extern "C" { * @see iki_read_main_delete() */ #ifndef _di_iki_read_main_ - extern f_status_t iki_read_main(iki_read_main_t * const main, const f_console_arguments_t *arguments); + extern f_status_t iki_read_main(fll_program_data_t * const main, const f_console_arguments_t *arguments); #endif // _di_iki_read_main_ #ifdef __cplusplus diff --git a/level_3/iki_read/c/main.c b/level_3/iki_read/c/main.c index 63caa67..5d3af57 100644 --- a/level_3/iki_read/c/main.c +++ b/level_3/iki_read/c/main.c @@ -3,7 +3,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); - iki_read_main_t data = iki_read_main_t_initialize; + fll_program_data_t data = fll_program_data_t_initialize; + + f_console_parameter_t parameters[] = iki_read_console_parameter_t_initialize; + data.parameters.array = parameters; + data.parameters.used = iki_read_total_parameters_d; if (f_pipe_input_exists()) { data.process_pipe = F_true; @@ -15,6 +19,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_standard_setdown(&data.signal); + fll_program_data_delete(&data); + if (F_status_is_error(status)) return 1; return 0; diff --git a/level_3/iki_read/c/private-common.c b/level_3/iki_read/c/private-common.c index efc1243..d131d1c 100644 --- a/level_3/iki_read/c/private-common.c +++ b/level_3/iki_read/c/private-common.c @@ -5,28 +5,37 @@ extern "C" { #endif +#ifndef _di_iki_read_data_delete_ + f_status_t iki_read_data_delete(iki_read_data_t * const data) { + + f_string_dynamic_resize(0, &data->buffer); + + return F_none; + } +#endif // _di_iki_read_data_delete_ + #ifndef _di_iki_read_print_signal_received_ - void iki_read_print_signal_received(iki_read_main_t * const main, const f_status_t signal) { + void iki_read_print_signal_received(iki_read_data_t * const data, const f_status_t signal) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. - fflush(main->warning.to.stream); + fflush(data->main->warning.to.stream); - flockfile(main->warning.to.stream); + flockfile(data->main->warning.to.stream); - fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); - fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); + fl_print_format("%]%r%r%[Received signal code %]", data->main->warning.to.stream, data->main->context.set.reset, f_string_eol_s, f_string_eol_s, data->main->context.set.warning, data->main->context.set.warning); + fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, signal, data->main->context.set.notable); + fl_print_format("%[.%]%r", data->main->warning.to.stream, data->main->context.set.warning, data->main->context.set.warning, f_string_eol_s); - funlockfile(main->warning.to.stream); + funlockfile(data->main->warning.to.stream); } #endif // _di_iki_read_print_signal_received_ #ifndef _di_iki_read_signal_received_ - f_status_t iki_read_signal_received(iki_read_main_t * const main) { + f_status_t iki_read_signal_received(iki_read_data_t * const data) { - if (main->signal.id == -1) { + if (data->main->signal.id == -1) { return F_false; } @@ -34,7 +43,7 @@ extern "C" { memset(&information, 0, sizeof(struct signalfd_siginfo)); - if (f_signal_read(main->signal, 0, &information) == F_signal) { + if (f_signal_read(data->main->signal, 0, &information) == F_signal) { switch (information.ssi_signo) { case F_signal_abort: case F_signal_broken_pipe: @@ -42,7 +51,7 @@ extern "C" { case F_signal_interrupt: case F_signal_quit: case F_signal_termination: - iki_read_print_signal_received(main, information.ssi_signo); + iki_read_print_signal_received(data, information.ssi_signo); return information.ssi_signo; } diff --git a/level_3/iki_read/c/private-common.h b/level_3/iki_read/c/private-common.h index 97a8d17..008a885 100644 --- a/level_3/iki_read/c/private-common.h +++ b/level_3/iki_read/c/private-common.h @@ -25,15 +25,62 @@ extern "C" { #endif // _di_iki_read_common_ /** + * The program data. + * + * argv: The argument structure in the progam data parameters for simplifying syntax. + * at: The processed at parameter value. + * buffer: The buffer containing the file. + * line: The processed line parameter value. + * main: The main program data. + * mode: The read mode to operate in. + */ +#ifndef _di_iki_read_data_t_ + typedef struct { + fll_program_data_t *main; + f_string_static_t *argv; + + uint8_t mode; + + f_number_unsigned_t at; + f_number_unsigned_t line; + + f_string_dynamic_t buffer; + } iki_read_data_t; + + #define iki_read_data_t_initialize \ + { \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + f_string_dynamic_t_initialize, \ + } +#endif // _di_iki_read_data_t_ + +/** + * Deallocate program data. + * + * @param data + * The program data. + * + * @return + * F_none on success. + */ +#ifndef _di_iki_read_data_delete_ + extern f_status_t iki_read_data_delete(iki_read_data_t * const data); +#endif // _di_iki_read_data_delete_ + +/** * Print a message about a process signal being recieved, such as an interrupt signal. * - * @param main - * The main program data. + * @param data + * The program data. * @param signal * The signal received. */ #ifndef _di_iki_read_print_signal_received_ - extern void iki_read_print_signal_received(iki_read_main_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void iki_read_print_signal_received(iki_read_data_t * const data, const f_status_t signal) F_attribute_visibility_internal_d; #endif // _di_iki_read_print_signal_received_ /** @@ -41,8 +88,8 @@ extern "C" { * * Only signals that are blocked via main.signal will be received. * - * @param main - * The main program data. + * @param data + * The program data. * * @return * A positive number representing a valid signal on signal received. @@ -51,7 +98,7 @@ extern "C" { * @see f_signal_read() */ #ifndef _di_iki_read_signal_received_ - extern f_status_t iki_read_signal_received(iki_read_main_t * const main) F_attribute_visibility_internal_d; + extern f_status_t iki_read_signal_received(iki_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_iki_read_signal_received_ #ifdef __cplusplus diff --git a/level_3/iki_read/c/private-print.c b/level_3/iki_read/c/private-print.c index a0071ea..1dfafea 100644 --- a/level_3/iki_read/c/private-print.c +++ b/level_3/iki_read/c/private-print.c @@ -7,36 +7,36 @@ extern "C" { #endif #ifndef _di_iki_read_substitutions_print_ - void iki_read_substitutions_print(iki_read_main_t * const main, const f_iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitutions_t substitutions, const f_array_length_t index, const bool content_only) { + void iki_read_substitutions_print(iki_read_data_t * const data, const f_iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitutions_t substitutions, const f_array_length_t index, const bool content_only) { f_status_t status = F_none; f_array_length_t i = 0; for (; i < substitutions.used; ++i) { - status = fl_string_dynamic_partial_compare_string(substitutions.array[i].replace.string, main->buffer, substitutions.array[i].replace.used, iki_data.content.array[index]); + status = fl_string_dynamic_partial_compare_string(substitutions.array[i].replace.string, data->buffer, substitutions.array[i].replace.used, iki_data.content.array[index]); if (status == F_equal_to) break; } // for if (status == F_equal_to) { if (content_only) { - f_print_dynamic(substitutions.array[i].with, main->output.to.stream); + f_print_dynamic(substitutions.array[i].with, data->main->output.to.stream); } else { f_string_range_t range = macro_f_string_range_t_initialize(iki_data.variable.array[index].start, iki_data.content.array[index].start - 1); - f_print_dynamic_partial(main->buffer, range, main->output.to.stream); + f_print_dynamic_partial(data->buffer, range, data->main->output.to.stream); - f_print_dynamic(substitutions.array[i].with, main->output.to.stream); + f_print_dynamic(substitutions.array[i].with, data->main->output.to.stream); range.start = iki_data.content.array[index].stop + 1; range.stop = iki_data.variable.array[index].stop; - f_print_dynamic_partial(main->buffer, range, main->output.to.stream); + f_print_dynamic_partial(data->buffer, range, data->main->output.to.stream); } } else { - f_print_dynamic_partial(main->buffer, ranges.array[index], main->output.to.stream); + f_print_dynamic_partial(data->buffer, ranges.array[index], data->main->output.to.stream); } } #endif // _di_iki_read_substitutions_print_ diff --git a/level_3/iki_read/c/private-print.h b/level_3/iki_read/c/private-print.h index 205ffe8..8687a22 100644 --- a/level_3/iki_read/c/private-print.h +++ b/level_3/iki_read/c/private-print.h @@ -15,8 +15,8 @@ extern "C" { /** * Print any applicable substition and if there is non then print the given range at the given index. * - * @param main - * The main program data. + * @param data + * The program data. * @param iki_data * The IKI data. * @param ranges @@ -30,7 +30,7 @@ extern "C" { * Set to FALSE to print the entire variable when printing substituted text. */ #ifndef _di_iki_read_substitutions_print_ - extern void iki_read_substitutions_print(iki_read_main_t * const main, const f_iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitutions_t substitutions, const f_array_length_t index, const bool content_only) F_attribute_visibility_internal_d; + extern void iki_read_substitutions_print(iki_read_data_t * const data, const f_iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitutions_t substitutions, const f_array_length_t index, const bool content_only) F_attribute_visibility_internal_d; #endif // _di_iki_read_substitutions_print_ #ifdef __cplusplus diff --git a/level_3/iki_read/c/private-read.c b/level_3/iki_read/c/private-read.c index ff470a5..4bc080c 100644 --- a/level_3/iki_read/c/private-read.c +++ b/level_3/iki_read/c/private-read.c @@ -8,24 +8,24 @@ extern "C" { #endif #ifndef _di_iki_read_process_at_ - f_status_t iki_read_process_at(iki_read_main_t * const main, f_string_range_t *range) { + f_status_t iki_read_process_at(iki_read_data_t * const data, f_string_range_t *range) { - if (main->parameters.array[iki_read_parameter_line_e].result != f_console_result_additional_e) { + if (data->main->parameters.array[iki_read_parameter_line_e].result != f_console_result_additional_e) { return F_false; } f_array_length_t line = 0; range->start = 0; - if (main->line > 0) { - for (; line < main->line && range->start < main->buffer.used; ++range->start) { - if (main->buffer.string[range->start] == f_string_eol_s.string[0]) ++line; + if (data->line > 0) { + for (; line < data->line && range->start < data->buffer.used; ++range->start) { + if (data->buffer.string[range->start] == f_string_eol_s.string[0]) ++line; } // for } - if (line == main->line) { - for (range->stop = range->start; range->stop < main->buffer.used; ++range->stop) { - if (main->buffer.string[range->stop] == f_string_eol_s.string[0]) break; + if (line == data->line) { + for (range->stop = range->start; range->stop < data->buffer.used; ++range->stop) { + if (data->buffer.string[range->stop] == f_string_eol_s.string[0]) break; } // for return F_true; @@ -36,18 +36,18 @@ extern "C" { #endif // _di_iki_read_process_at_ #ifndef _di_iki_read_process_buffer_ - f_status_t iki_read_process_buffer(iki_read_main_t * const main) { + f_status_t iki_read_process_buffer(iki_read_data_t * const data) { f_status_t status = F_none; f_iki_data_t iki_data = f_iki_data_t_initialize; - if (main->parameters.array[iki_read_parameter_whole_e].result == f_console_result_found_e) { - f_string_range_t buffer_range = macro_f_string_range_t_initialize2(main->buffer.used); + if (data->main->parameters.array[iki_read_parameter_whole_e].result == f_console_result_found_e) { + f_string_range_t buffer_range = macro_f_string_range_t_initialize2(data->buffer.used); - status = iki_read_process_at(main, &buffer_range); + status = iki_read_process_at(data, &buffer_range); if (status == F_true) { - if (buffer_range.start > main->buffer.used) { + if (buffer_range.start > data->buffer.used) { return F_data_not; } } @@ -55,38 +55,38 @@ extern "C" { return F_data_not; } - if (main->mode == iki_read_mode_content_e) { - status = iki_read_process_buffer_ranges_whole(main, buffer_range, &iki_data, &iki_data.content); + if (data->mode == iki_read_mode_content_e) { + status = iki_read_process_buffer_ranges_whole(data, buffer_range, &iki_data, &iki_data.content); } - else if (main->mode == iki_read_mode_literal_e) { - status = iki_read_process_buffer_ranges_whole(main, buffer_range, &iki_data, &iki_data.variable); + else if (data->mode == iki_read_mode_literal_e) { + status = iki_read_process_buffer_ranges_whole(data, buffer_range, &iki_data, &iki_data.variable); } - else if (main->mode == iki_read_mode_object_e) { - status = iki_read_process_buffer_ranges_whole(main, buffer_range, &iki_data, &iki_data.vocabulary); + else if (data->mode == iki_read_mode_object_e) { + status = iki_read_process_buffer_ranges_whole(data, buffer_range, &iki_data, &iki_data.vocabulary); } } - else if (main->mode == iki_read_mode_total_e) { - status = iki_read_process_buffer_total(main, &iki_data); + else if (data->mode == iki_read_mode_total_e) { + status = iki_read_process_buffer_total(data, &iki_data); } else { - f_string_range_t buffer_range = macro_f_string_range_t_initialize2(main->buffer.used); + f_string_range_t buffer_range = macro_f_string_range_t_initialize2(data->buffer.used); - status = iki_read_process_at(main, &buffer_range); + status = iki_read_process_at(data, &buffer_range); - if (status == F_true && buffer_range.start > main->buffer.used || status == F_data_not) { + if (status == F_true && buffer_range.start > data->buffer.used || status == F_data_not) { f_iki_data_delete(&iki_data); return F_data_not; } - if (main->mode == iki_read_mode_content_e) { - status = iki_read_process_buffer_ranges(main, &buffer_range, &iki_data, &iki_data.content); + if (data->mode == iki_read_mode_content_e) { + status = iki_read_process_buffer_ranges(data, &buffer_range, &iki_data, &iki_data.content); } - else if (main->mode == iki_read_mode_literal_e) { - status = iki_read_process_buffer_ranges(main, &buffer_range, &iki_data, &iki_data.variable); + else if (data->mode == iki_read_mode_literal_e) { + status = iki_read_process_buffer_ranges(data, &buffer_range, &iki_data, &iki_data.variable); } - else if (main->mode == iki_read_mode_object_e) { - status = iki_read_process_buffer_ranges(main, &buffer_range, &iki_data, &iki_data.vocabulary); + else if (data->mode == iki_read_mode_object_e) { + status = iki_read_process_buffer_ranges(data, &buffer_range, &iki_data, &iki_data.vocabulary); } } @@ -97,7 +97,7 @@ extern "C" { #endif // _di_iki_read_process_buffer_ #ifndef _di_iki_read_process_buffer_ranges_ - f_status_t iki_read_process_buffer_ranges(iki_read_main_t * const main, f_string_range_t *buffer_range, f_iki_data_t *iki_data, f_string_ranges_t *ranges) { + f_status_t iki_read_process_buffer_ranges(iki_read_data_t * const data, f_string_range_t *buffer_range, f_iki_data_t *iki_data, f_string_ranges_t *ranges) { f_status_t status = F_none; @@ -106,30 +106,30 @@ extern "C" { { f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, 0, 0, 0); - status = fl_iki_read(state, &main->buffer, buffer_range, iki_data); + status = fl_iki_read(state, &data->buffer, buffer_range, iki_data); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fl_iki_read", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "fl_iki_read", F_true); return status; } for (f_array_length_t i = 0; i < iki_data->delimits.used; ++i) { - main->buffer.string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + data->buffer.string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for - const bool content_only = main->mode == iki_read_mode_content_e; + const bool content_only = data->mode == iki_read_mode_content_e; iki_read_substitutions_t substitutionss[iki_data->variable.used]; memset(substitutionss, 0, sizeof(iki_read_substitutions_t) * iki_data->variable.used); - if (main->mode == iki_read_mode_literal_e || main->mode == iki_read_mode_content_e) { - status = iki_read_substitutions_identify(main, &iki_data->vocabulary, substitutionss); + if (data->mode == iki_read_mode_literal_e || data->mode == iki_read_mode_content_e) { + status = iki_read_substitutions_identify(data, &iki_data->vocabulary, substitutionss); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) { macro_iki_read_substitutions_t_delete_simple(substitutionss[i]); @@ -139,7 +139,7 @@ extern "C" { } } - if (main->parameters.array[iki_read_parameter_name_e].result == f_console_result_additional_e) { + if (data->main->parameters.array[iki_read_parameter_name_e].result == f_console_result_additional_e) { f_string_dynamic_t name = f_string_dynamic_t_initialize; f_array_length_t index = 0; @@ -148,15 +148,15 @@ extern "C" { f_array_length_t matches = 0; buffer_range->start = 0; - for (; i < main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { + for (; i < data->main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { - index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; + index = data->main->parameters.array[iki_read_parameter_name_e].values.array[i]; name.used = 0; - status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); + status = f_string_dynamic_append_nulless(data->argv[index], &name); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) { macro_iki_read_substitutions_t_delete_simple(substitutionss[i]); @@ -168,31 +168,31 @@ extern "C" { buffer_range->stop = name.used - 1; - flockfile(main->output.to.stream); + flockfile(data->main->output.to.stream); for (j = 0; j < iki_data->vocabulary.used; ++j) { - status = fl_string_dynamic_partial_compare(name, main->buffer, *buffer_range, iki_data->vocabulary.array[j]); + status = fl_string_dynamic_partial_compare(name, data->buffer, *buffer_range, iki_data->vocabulary.array[j]); if (status == F_equal_to) { unmatched = F_false; - if (main->parameters.array[iki_read_parameter_at_e].result == f_console_result_additional_e) { - if (matches++ != main->at) continue; + if (data->main->parameters.array[iki_read_parameter_at_e].result == f_console_result_additional_e) { + if (matches++ != data->at) continue; } if (substitutionss[j].used) { - iki_read_substitutions_print(main, *iki_data, *ranges, substitutionss[j], j, content_only); + iki_read_substitutions_print(data, *iki_data, *ranges, substitutionss[j], j, content_only); } else { - f_print_dynamic_partial(main->buffer, ranges->array[j], main->output.to.stream); + f_print_dynamic_partial(data->buffer, ranges->array[j], data->main->output.to.stream); } - f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + f_print_dynamic_raw(f_string_eol_s, data->main->output.to.stream); } } // for - funlockfile(main->output.to.stream); + funlockfile(data->main->output.to.stream); } // for f_string_dynamic_resize(0, &name); @@ -205,20 +205,20 @@ extern "C" { } } else if (ranges->used) { - if (main->parameters.array[iki_read_parameter_at_e].result == f_console_result_additional_e) { - if (main->at < ranges->used) { - flockfile(main->output.to.stream); + if (data->main->parameters.array[iki_read_parameter_at_e].result == f_console_result_additional_e) { + if (data->at < ranges->used) { + flockfile(data->main->output.to.stream); - if (substitutionss[main->at].used) { - iki_read_substitutions_print(main, *iki_data, *ranges, substitutionss[main->at], main->at, content_only); + if (substitutionss[data->at].used) { + iki_read_substitutions_print(data, *iki_data, *ranges, substitutionss[data->at], data->at, content_only); } else { - f_print_dynamic_partial(main->buffer, ranges->array[main->at], main->output.to.stream); + f_print_dynamic_partial(data->buffer, ranges->array[data->at], data->main->output.to.stream); } - f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + f_print_dynamic_raw(f_string_eol_s, data->main->output.to.stream); - funlockfile(main->output.to.stream); + funlockfile(data->main->output.to.stream); status = F_none; } @@ -227,21 +227,21 @@ extern "C" { } } else { - flockfile(main->output.to.stream); + flockfile(data->main->output.to.stream); for (f_array_length_t i = 0; i < ranges->used; ++i) { if (substitutionss[i].used) { - iki_read_substitutions_print(main, *iki_data, *ranges, substitutionss[i], i, content_only); + iki_read_substitutions_print(data, *iki_data, *ranges, substitutionss[i], i, content_only); } else { - f_print_dynamic_partial(main->buffer, ranges->array[i], main->output.to.stream); + f_print_dynamic_partial(data->buffer, ranges->array[i], data->main->output.to.stream); } - f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + f_print_dynamic_raw(f_string_eol_s, data->main->output.to.stream); } // for - funlockfile(main->output.to.stream); + funlockfile(data->main->output.to.stream); status = F_none; } @@ -259,7 +259,7 @@ extern "C" { #endif // _di_iki_read_process_buffer_ranges_ #ifndef _di_iki_read_process_buffer_ranges_whole_ - f_status_t iki_read_process_buffer_ranges_whole(iki_read_main_t * const main, const f_string_range_t buffer_range, f_iki_data_t *iki_data, f_string_ranges_t *ranges) { + f_status_t iki_read_process_buffer_ranges_whole(iki_read_data_t * const data, const f_string_range_t buffer_range, f_iki_data_t *iki_data, f_string_ranges_t *ranges) { f_status_t status = F_none; f_string_range_t range = buffer_range; @@ -267,36 +267,36 @@ extern "C" { { f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, 0, 0, 0); - status = fl_iki_read(state, &main->buffer, &range, iki_data); + status = fl_iki_read(state, &data->buffer, &range, iki_data); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fl_iki_read", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "fl_iki_read", F_true); return status; } for (f_array_length_t i = 0; i < iki_data->delimits.used; ++i) { - main->buffer.string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + data->buffer.string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for if (!iki_data->variable.used) { - fll_print_dynamic_partial(main->buffer, buffer_range, main->output.to.stream); + fll_print_dynamic_partial(data->buffer, buffer_range, data->main->output.to.stream); return F_none; } - const bool content_only = main->mode == iki_read_mode_content_e; + const bool content_only = data->mode == iki_read_mode_content_e; iki_read_substitutions_t substitutionss[iki_data->variable.used]; memset(substitutionss, 0, sizeof(iki_read_substitutions_t) * iki_data->variable.used); - if (main->mode == iki_read_mode_literal_e || main->mode == iki_read_mode_content_e) { - status = iki_read_substitutions_identify(main, &iki_data->vocabulary, substitutionss); + if (data->mode == iki_read_mode_literal_e || data->mode == iki_read_mode_content_e) { + status = iki_read_substitutions_identify(data, &iki_data->vocabulary, substitutionss); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) { macro_iki_read_substitutions_t_delete_simple(substitutionss[i]); @@ -314,17 +314,17 @@ extern "C" { substitution_range.start = 0; - if (main->parameters.array[iki_read_parameter_name_e].result == f_console_result_additional_e) { + if (data->main->parameters.array[iki_read_parameter_name_e].result == f_console_result_additional_e) { f_array_length_t i = 0; f_array_length_t j = 0; - for (f_array_length_t index = 0; i < main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { + for (f_array_length_t index = 0; i < data->main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { - index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; + index = data->main->parameters.array[iki_read_parameter_name_e].values.array[i]; for (j = 0, name_missed = F_true; j < names.used; ++j) { - if (fl_string_dynamic_compare(main->parameters.arguments.array[index], names.array[j]) == F_equal_to) { + if (fl_string_dynamic_compare(data->argv[index], names.array[j]) == F_equal_to) { name_missed = F_false; break; @@ -335,15 +335,15 @@ extern "C" { macro_f_memory_structure_increment(status, names, 1, F_iki_default_allocation_small_d, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "macro_f_memory_structure_increment", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "macro_f_memory_structure_increment", F_true); break; } - status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &names.array[names.used]); + status = f_string_dynamic_append_nulless(data->argv[index], &names.array[names.used]); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); break; } @@ -372,7 +372,7 @@ extern "C" { range = buffer_range; name_range.start = 0; - flockfile(main->output.to.stream); + flockfile(data->main->output.to.stream); while (i <= range.stop && j < stop) { @@ -380,7 +380,7 @@ extern "C" { range.start = i; range.stop = iki_data->variable.array[j].start - 1; - f_print_dynamic_partial(main->buffer, range, main->output.to.stream); + f_print_dynamic_partial(data->buffer, range, data->main->output.to.stream); range.start = iki_data->variable.array[j].stop + 1; range.stop = buffer_range.stop; @@ -394,7 +394,7 @@ extern "C" { for (k = 0; k < names.used; ++k) { name_range.stop = names.array[k].used - 1; - status = fl_string_dynamic_partial_compare(main->buffer, names.array[k], iki_data->vocabulary.array[j], name_range); + status = fl_string_dynamic_partial_compare(data->buffer, names.array[k], iki_data->vocabulary.array[j], name_range); if (status == F_equal_to) { name_missed = F_false; @@ -404,27 +404,27 @@ extern "C" { if (name_missed) { if (substitutionss[j].used) { - iki_read_substitutions_print(main, *iki_data, iki_data->variable, substitutionss[j], j, F_false); + iki_read_substitutions_print(data, *iki_data, iki_data->variable, substitutionss[j], j, F_false); } else { - f_print_dynamic_partial(main->buffer, iki_data->variable.array[j], main->output.to.stream); + f_print_dynamic_partial(data->buffer, iki_data->variable.array[j], data->main->output.to.stream); } } else { if (substitutionss[j].used) { - iki_read_substitutions_print(main, *iki_data, *ranges, substitutionss[j], j, content_only); + iki_read_substitutions_print(data, *iki_data, *ranges, substitutionss[j], j, content_only); } else { - f_print_dynamic_partial(main->buffer, ranges->array[j], main->output.to.stream); + f_print_dynamic_partial(data->buffer, ranges->array[j], data->main->output.to.stream); } } } else { if (substitutionss[j].used) { - iki_read_substitutions_print(main, *iki_data, *ranges, substitutionss[j], j, content_only); + iki_read_substitutions_print(data, *iki_data, *ranges, substitutionss[j], j, content_only); } else { - f_print_dynamic_partial(main->buffer, ranges->array[j], main->output.to.stream); + f_print_dynamic_partial(data->buffer, ranges->array[j], data->main->output.to.stream); } } @@ -434,10 +434,10 @@ extern "C" { if (i <= buffer_range.stop) { range.start = i; - f_print_dynamic_partial(main->buffer, range, main->output.to.stream); + f_print_dynamic_partial(data->buffer, range, data->main->output.to.stream); } - funlockfile(main->output.to.stream); + funlockfile(data->main->output.to.stream); } for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) { @@ -451,22 +451,22 @@ extern "C" { #endif // _di_iki_read_process_buffer_ranges_whole_ #ifndef _di_iki_read_process_buffer_total_ - f_status_t iki_read_process_buffer_total(iki_read_main_t * const main, f_iki_data_t *iki_data) { + f_status_t iki_read_process_buffer_total(iki_read_data_t * const data, f_iki_data_t *iki_data) { f_status_t status = F_none; - f_string_range_t range = macro_f_string_range_t_initialize2(main->buffer.used); + f_string_range_t range = macro_f_string_range_t_initialize2(data->buffer.used); - status = iki_read_process_at(main, &range); + status = iki_read_process_at(data, &range); if (status == F_true) { - if (range.start > main->buffer.used) { - fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); + if (range.start > data->buffer.used) { + fll_print_format("%r%r", data->main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); return F_none; } } else if (status == F_data_not) { - fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); + fll_print_format("%r%r", data->main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); return F_none; } @@ -474,22 +474,22 @@ extern "C" { { f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, 0, 0, 0); - status = fl_iki_read(state, &main->buffer, &range, iki_data); + status = fl_iki_read(state, &data->buffer, &range, iki_data); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "fl_iki_read", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "fl_iki_read", F_true); return status; } for (f_array_length_t i = 0; i < iki_data->delimits.used; ++i) { - main->buffer.string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; + data->buffer.string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0]; } // for f_array_length_t total = 0; - if (main->parameters.array[iki_read_parameter_name_e].result == f_console_result_additional_e) { + if (data->main->parameters.array[iki_read_parameter_name_e].result == f_console_result_additional_e) { f_string_dynamic_t name = f_string_dynamic_t_initialize; f_array_length_t index = 0; @@ -498,25 +498,25 @@ extern "C" { range.start = 0; - for (; i < main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { + for (; i < data->main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { - if (!((++main->signal_check) % iki_read_signal_check_d)) { - if (iki_read_signal_received(main)) { + if (!((++data->main->signal_check) % iki_read_signal_check_d)) { + if (iki_read_signal_received(data)) { f_string_dynamic_resize(0, &name); return F_status_set_error(F_interrupt); } - main->signal_check = 0; + data->main->signal_check = 0; } - index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; + index = data->main->parameters.array[iki_read_parameter_name_e].values.array[i]; name.used = 0; - status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); + status = f_string_dynamic_append_nulless(data->argv[index], &name); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); + fll_error_print(data->main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); f_string_dynamic_resize(0, &name); @@ -527,7 +527,7 @@ extern "C" { for (j = 0; j < iki_data->vocabulary.used; ++j) { - status = fl_string_dynamic_partial_compare(name, main->buffer, range, iki_data->vocabulary.array[j]); + status = fl_string_dynamic_partial_compare(name, data->buffer, range, iki_data->vocabulary.array[j]); if (status == F_equal_to) ++total; } // for @@ -540,8 +540,8 @@ extern "C" { } // if that at position is within the actual total, then the total at the given position is 1, otherwise is 0. - if (main->parameters.array[iki_read_parameter_at_e].result == f_console_result_additional_e) { - if (main->at < total) { + if (data->main->parameters.array[iki_read_parameter_at_e].result == f_console_result_additional_e) { + if (data->at < total) { total = 1; } else { @@ -549,16 +549,16 @@ extern "C" { } } - fll_print_format("%ul%r", main->output.to.stream, total, f_string_eol_s); + fll_print_format("%ul%r", data->main->output.to.stream, total, f_string_eol_s); return F_none; } #endif // _di_iki_read_process_buffer_total_ #ifndef _di_iki_read_substitutions_identify_ - f_status_t iki_read_substitutions_identify(iki_read_main_t * const main, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) { + f_status_t iki_read_substitutions_identify(iki_read_data_t * const data, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) { - if (main->parameters.array[iki_read_parameter_substitute_e].result != f_console_result_additional_e) { + if (data->main->parameters.array[iki_read_parameter_substitute_e].result != f_console_result_additional_e) { return F_none; } @@ -570,7 +570,7 @@ extern "C" { f_array_length_t index = 0; f_array_length_t index_2 = 0; - f_console_parameter_t *parameter = &main->parameters.array[iki_read_parameter_substitute_e]; + f_console_parameter_t *parameter = &data->main->parameters.array[iki_read_parameter_substitute_e]; for (; i < parameter->values.used; i += 3) { @@ -578,16 +578,16 @@ extern "C" { for (j = 0; j < vocabulary->used; ++j) { - if (fl_string_dynamic_partial_compare_string(main->parameters.arguments.array[index].string, main->buffer, main->parameters.arguments.array[index].used, vocabulary->array[j]) == F_equal_to) { + if (fl_string_dynamic_partial_compare_string(data->argv[index].string, data->buffer, data->argv[index].used, vocabulary->array[j]) == F_equal_to) { macro_f_memory_structure_increment(status, substitutionss[j], 1, F_iki_default_allocation_small_d, macro_iki_read_substitutions_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; index = parameter->values.array[i + 1]; index_2 = substitutionss[j].used; - substitutionss[j].array[index_2].replace = main->parameters.arguments.array[index]; + substitutionss[j].array[index_2].replace = data->argv[index]; index = parameter->values.array[i + 2]; - substitutionss[j].array[index_2].with = main->parameters.arguments.array[index]; + substitutionss[j].array[index_2].with = data->argv[index]; ++substitutionss[j].used; } diff --git a/level_3/iki_read/c/private-read.h b/level_3/iki_read/c/private-read.h index 1c87a43..3899367 100644 --- a/level_3/iki_read/c/private-read.h +++ b/level_3/iki_read/c/private-read.h @@ -18,8 +18,8 @@ extern "C" { * If the --at parameter is not specified in the console arguments, then range is untouched. * The range.start will be greater than main->buffer.used if the --at range is not found before buffer end is reached. * - * @param main - * The main program data. + * @param data + * The program data. * @param range * The range value to represent the --at values. * @@ -31,14 +31,14 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_at_ - extern f_status_t iki_read_process_at(iki_read_main_t * const main, f_string_range_t *range) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_at(iki_read_data_t * const data, f_string_range_t *range) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_at_ /** * Process a given buffer. * - * @param main - * The main program data. + * @param data + * The program data. * * @return * F_none on success. @@ -47,14 +47,14 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ - extern f_status_t iki_read_process_buffer(iki_read_main_t * const main) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_buffer(iki_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_buffer_ /** * Process a given buffer, printing the given range. * - * @param main - * The main program data. + * @param data + * The program data. * @param buffer_range * The range within the buffer to process. * @param iki_data @@ -70,7 +70,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ranges_ - extern f_status_t iki_read_process_buffer_ranges(iki_read_main_t * const main, f_string_range_t *buffer_range, f_iki_data_t *iki_data, f_string_ranges_t *ranges) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_buffer_ranges(iki_read_data_t * const data, f_string_range_t *buffer_range, f_iki_data_t *iki_data, f_string_ranges_t *ranges) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_buffer_ranges_ /** @@ -78,8 +78,8 @@ extern "C" { * * The entire variable is replaced with the range from the associated ranges. * - * @param main - * The main program data. + * @param data + * The program data. * @param buffer_range * The range within the buffer to process. * @param iki_data @@ -95,14 +95,14 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ranges_whole_ - extern f_status_t iki_read_process_buffer_ranges_whole(iki_read_main_t * const main, const f_string_range_t buffer_range, f_iki_data_t *iki_data, f_string_ranges_t *ranges) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_buffer_ranges_whole(iki_read_data_t * const data, const f_string_range_t buffer_range, f_iki_data_t *iki_data, f_string_ranges_t *ranges) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_buffer_ranges_whole_ /** * Process a given buffer, printing the total. * - * @param main - * The main program data. + * @param data + * The program data. * @param iki_data * The IKI data. * @@ -112,14 +112,14 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_total_ - extern f_status_t iki_read_process_buffer_total(iki_read_main_t * const main, f_iki_data_t *iki_data) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_buffer_total(iki_read_data_t * const data, f_iki_data_t *iki_data) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_buffer_total_ /** * Process the arguments, associating substitions with a given vocabulary. * - * @param main - * The main program data. + * @param data + * The program data. * @param vocabulary * The ranges representing a vocabulary. * @param substitutionss @@ -131,7 +131,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_substitutions_identify_ - extern f_status_t iki_read_substitutions_identify(iki_read_main_t * const main, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) F_attribute_visibility_internal_d; + extern f_status_t iki_read_substitutions_identify(iki_read_data_t * const data, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) F_attribute_visibility_internal_d; #endif // _di_iki_read_substitutions_identify_ #ifdef __cplusplus -- 1.8.3.1