From: Kevin Day Date: Sat, 10 Dec 2022 22:36:27 +0000 (-0600) Subject: Update: Centralize the error print function names. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=7b7f26d8867b43d49dfe4e14bdb919344c3f895a;p=fll Update: Centralize the error print function names. This reduces repeated strings in the code. A helper macro is used so that the individual code never needs to be changed if there are any changes to the array and the enumeration. This reduces the binary file size. --- diff --git a/level_3/fss_write/c/basic/fss_write.c b/level_3/fss_write/c/basic/fss_write.c index 57c01c3..9926279 100644 --- a/level_3/fss_write/c/basic/fss_write.c +++ b/level_3/fss_write/c/basic/fss_write.c @@ -31,7 +31,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_basic_content_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_content_write)); return; } @@ -78,7 +78,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_basic_object_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_object_write)); } } #endif // _di_fss_write_basic_process_object_ diff --git a/level_3/fss_write/c/basic/fss_write.h b/level_3/fss_write/c/basic/fss_write.h index 6a05ea8..ed6d4f4 100644 --- a/level_3/fss_write/c/basic/fss_write.h +++ b/level_3/fss_write/c/basic/fss_write.h @@ -44,6 +44,7 @@ // FSS Write includes. #include +#include #include #include #include diff --git a/level_3/fss_write/c/basic_list/fss_write.c b/level_3/fss_write/c/basic_list/fss_write.c index df63592..544f55f 100644 --- a/level_3/fss_write/c/basic_list/fss_write.c +++ b/level_3/fss_write/c/basic_list/fss_write.c @@ -34,7 +34,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_basic_list_content_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_content_write)); return; } @@ -78,7 +78,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_basic_list_object_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); } } #endif // _di_fss_write_basic_list_process_object_ diff --git a/level_3/fss_write/c/basic_list/fss_write.h b/level_3/fss_write/c/basic_list/fss_write.h index d27f6e0..c67135b 100644 --- a/level_3/fss_write/c/basic_list/fss_write.h +++ b/level_3/fss_write/c/basic_list/fss_write.h @@ -45,6 +45,7 @@ // FSS Write includes. #include +#include #include #include #include diff --git a/level_3/fss_write/c/embedded_list/fss_write.c b/level_3/fss_write/c/embedded_list/fss_write.c index c3a4756..6d6ee73 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.c +++ b/level_3/fss_write/c/embedded_list/fss_write.c @@ -35,7 +35,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_embedded_list_content_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_content_write)); return; } @@ -79,7 +79,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_embedded_list_object_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_embedded_list_object_write)); } } #endif // _di_fss_write_embedded_list_process_object_ diff --git a/level_3/fss_write/c/embedded_list/fss_write.h b/level_3/fss_write/c/embedded_list/fss_write.h index a6f7275..5a3841c 100644 --- a/level_3/fss_write/c/embedded_list/fss_write.h +++ b/level_3/fss_write/c/embedded_list/fss_write.h @@ -44,6 +44,7 @@ // FSS Write includes. #include +#include #include #include #include diff --git a/level_3/fss_write/c/extended/fss_write.c b/level_3/fss_write/c/extended/fss_write.c index 6093ece..44e6508 100644 --- a/level_3/fss_write/c/extended/fss_write.c +++ b/level_3/fss_write/c/extended/fss_write.c @@ -36,7 +36,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_extended_content_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_content_write)); return; } @@ -83,7 +83,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_extended_object_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_object_write)); } } #endif // _di_fss_write_extended_process_object_ diff --git a/level_3/fss_write/c/extended/fss_write.h b/level_3/fss_write/c/extended/fss_write.h index d6dffa0..058254e 100644 --- a/level_3/fss_write/c/extended/fss_write.h +++ b/level_3/fss_write/c/extended/fss_write.h @@ -44,6 +44,7 @@ // FSS Write includes. #include +#include #include #include #include diff --git a/level_3/fss_write/c/extended_list/fss_write.c b/level_3/fss_write/c/extended_list/fss_write.c index 0bce5f4..33423f2 100644 --- a/level_3/fss_write/c/extended_list/fss_write.c +++ b/level_3/fss_write/c/extended_list/fss_write.c @@ -35,7 +35,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_extended_list_content_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_extended_list_content_write)); return; } @@ -79,7 +79,7 @@ extern "C" { } if (F_status_is_error(macro_fss_write_setting(setting)->status)) { - fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_extended_list_object_write"); + fss_write_print_error(macro_fss_write_setting(setting), main->error, macro_fss_write_f(fl_fss_extended_list_object_write)); } } #endif // _di_fss_write_extended_list_process_object_ diff --git a/level_3/fss_write/c/extended_list/fss_write.h b/level_3/fss_write/c/extended_list/fss_write.h index d7a9d41..44e4649 100644 --- a/level_3/fss_write/c/extended_list/fss_write.h +++ b/level_3/fss_write/c/extended_list/fss_write.h @@ -44,6 +44,7 @@ // FSS Write includes. #include +#include #include #include #include diff --git a/level_3/fss_write/c/main/common-print.c b/level_3/fss_write/c/main/common-print.c new file mode 100644 index 0000000..89157ba --- /dev/null +++ b/level_3/fss_write/c/main/common-print.c @@ -0,0 +1,45 @@ +#include "fss_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_fss_write_f_a_ + const f_string_t fss_write_f_a[] = { + "f_console_parameter_process", + "f_file_read_block", + "f_file_stream_open", + "f_fss_is_space", + "f_string_dynamic_append", + "f_string_dynamic_append_nulless", + "f_string_dynamic_increase_by", + "f_string_dynamics_increase", + "f_string_dynamics_increase_by", + "f_string_dynamics_resize", + "f_string_dynamicss_increase", + "f_string_dynamicss_increase_by", + "f_string_ranges_increase", + "f_string_ranges_increase_by", + "f_string_rangess_increase", + "f_string_rangess_increase_by", + "f_string_read_block_increase", + "fl_fss_basic_content_write", + "fl_fss_basic_list_content_write", + "fl_fss_basic_list_object_write", + "fl_fss_basic_object_write", + "fl_fss_embedded_list_content_write", + "fl_fss_embedded_list_object_write", + "fl_fss_extended_content_write", + "fl_fss_extended_list_content_write", + "fl_fss_extended_list_object_write", + "fl_fss_extended_object_write", + "fl_fss_payload_content_write", + "fll_program_parameter_process_context", + "fll_program_parameter_process_verbosity", + "fll_fss_payload_write", + }; +#endif // _di_fss_write_f_a_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/fss_write/c/main/common-print.h b/level_3/fss_write/c/main/common-print.h new file mode 100644 index 0000000..bf38044 --- /dev/null +++ b/level_3/fss_write/c/main/common-print.h @@ -0,0 +1,80 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common data structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _fss_write_common_print_h +#define _fss_write_common_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A special array of strings intended for representing funciton names. + * + * These are primarily used for printing errors with the function names. + * + * The macro macro_fss_write_f() is used to reference the array index by the enum name. + * + * macro_fss_write_f(): + * - name: The name of the function. + */ +#ifndef _di_fss_write_f_a_ + extern const f_string_t fss_write_f_a[]; + + #define macro_fss_write_f(name) fss_write_f_a[fss_write_f_##name##_e] +#endif // _di_fss_write_f_a_ + +/** + * An enum representing specific indexes within the above array. + * + * This is a convenience enum used to make code slightly more readable. + */ +#ifndef _di_fss_write_f_e_ + enum { + fss_write_f_f_console_parameter_process_e, + fss_write_f_f_file_read_block_e, + fss_write_f_f_file_stream_open_e, + fss_write_f_f_fss_is_space_e, + fss_write_f_f_string_dynamic_append_e, + fss_write_f_f_string_dynamic_append_nulless_e, + fss_write_f_f_string_dynamic_increase_by_e, + fss_write_f_f_string_dynamics_increase_e, + fss_write_f_f_string_dynamics_increase_by_e, + fss_write_f_f_string_dynamics_resize_e, + fss_write_f_f_string_dynamicss_increase_e, + fss_write_f_f_string_dynamicss_increase_by_e, + fss_write_f_f_string_ranges_increase_e, + fss_write_f_f_string_ranges_increase_by_e, + fss_write_f_f_string_rangess_increase_e, + fss_write_f_f_string_rangess_increase_by_e, + fss_write_f_f_string_read_block_increase_e, + fss_write_f_fl_fss_basic_content_write_e, + fss_write_f_fl_fss_basic_list_content_write_e, + fss_write_f_fl_fss_basic_list_object_write_e, + fss_write_f_fl_fss_basic_object_write_e, + fss_write_f_fl_fss_embedded_list_content_write_e, + fss_write_f_fl_fss_embedded_list_object_write_e, + fss_write_f_fl_fss_extended_content_write_e, + fss_write_f_fl_fss_extended_list_content_write_e, + fss_write_f_fl_fss_extended_list_object_write_e, + fss_write_f_fl_fss_extended_object_write_e, + fss_write_f_fl_fss_payload_content_write_e, + fss_write_f_fll_program_parameter_process_context_e, + fss_write_f_fll_program_parameter_process_verbosity_e, + fss_write_f_fll_fss_payload_write_e, + }; // enum +#endif // _di_fss_write_f_e_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_write_common_print_h diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index 3811190..b7941fa 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -76,7 +76,7 @@ extern "C" { setting->status = f_console_parameter_process(arguments, &main->parameters); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_console_parameter_process"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_console_parameter_process)); return; } @@ -96,7 +96,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fll_program_parameter_process_context"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fll_program_parameter_process_context)); return; } @@ -127,7 +127,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fll_program_parameter_process_verbosity)); return; } @@ -179,7 +179,7 @@ extern "C" { setting->status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &main->output.to); if (F_status_is_error(setting->status)) { - fss_write_print_error_file(setting, main->error, "f_file_stream_open", main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); + fss_write_print_error_file(setting, main->error, macro_fss_write_f(f_file_stream_open), main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); return; } @@ -204,7 +204,7 @@ extern "C" { setting->status = f_string_dynamics_resize(values->used, &setting->objects); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamics_resize"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_resize)); return; } @@ -258,7 +258,7 @@ extern "C" { setting->status = f_string_dynamicss_increase_by(values_object->used, &setting->contentss); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamicss_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase_by)); return; } @@ -289,7 +289,7 @@ extern "C" { setting->status = f_string_dynamics_increase_by(total, &setting->contentss.array[j]); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamics_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase_by)); return; } @@ -328,7 +328,7 @@ extern "C" { setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->prepend); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamic_append_nulless"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append_nulless)); return; } @@ -342,7 +342,7 @@ extern "C" { setting->status = f_fss_is_space(state, main->parameters.arguments.array[index], range); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_fss_is_space"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_fss_is_space)); return; } @@ -397,7 +397,7 @@ extern "C" { setting->status = f_string_rangess_increase_by(values_data->used, &setting->ignoress); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_rangess_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase_by)); return; } @@ -429,7 +429,7 @@ extern "C" { setting->status = f_string_ranges_increase_by(total, &setting->ignoress.array[j]); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_ranges_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_ranges_increase_by)); return; } diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index a1e0cc0..89a82c2 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -125,7 +125,7 @@ extern "C" { setting->status = f_string_dynamics_increase(setting->state.step_small, &setting->objects); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamics_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); return; } @@ -134,7 +134,7 @@ extern "C" { setting->status = f_string_dynamicss_increase(setting->state.step_small, &setting->contentss); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamicss_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase)); return; } @@ -142,7 +142,7 @@ extern "C" { setting->status = f_string_dynamics_increase(setting->state.step_small, setting->contents); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamics_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); return; } @@ -151,7 +151,7 @@ extern "C" { setting->status = f_string_rangess_increase(setting->state.step_small, &setting->ignoress); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_rangess_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase)); return; } @@ -183,7 +183,7 @@ extern "C" { status_pipe = f_file_read_block(input, &setting->block); if (F_status_is_error(status_pipe)) { - fss_write_print_error(setting, main->error, "f_file_read_block"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_file_read_block)); status_pipe = F_status_set_error(F_pipe); @@ -211,7 +211,7 @@ extern "C" { setting->status = f_string_dynamic_increase_by(setting->block.used, setting->object); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } @@ -277,7 +277,7 @@ extern "C" { setting->status = f_string_dynamics_increase(setting->state.step_small, setting->contents); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamics_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); break; } @@ -294,7 +294,7 @@ extern "C" { setting->status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } @@ -328,7 +328,7 @@ extern "C" { setting->status = f_string_ranges_increase(setting->state.step_small, setting->ignores); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_ranges_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_ranges_increase)); break; } diff --git a/level_3/fss_write/c/main/fss_write.h b/level_3/fss_write/c/main/fss_write.h index 95f3434..aa88b90 100644 --- a/level_3/fss_write/c/main/fss_write.h +++ b/level_3/fss_write/c/main/fss_write.h @@ -43,6 +43,7 @@ // FSS Write includes. #include +#include #include #ifdef __cplusplus diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index 08bf899..ad4a2e1 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -44,7 +44,7 @@ extern "C" { setting->status = f_string_dynamics_increase(setting->state.step_small, &setting->objects); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamics_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); return; } @@ -53,7 +53,7 @@ extern "C" { setting->status = f_string_dynamicss_increase(setting->state.step_small, &setting->contentss); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamicss_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamicss_increase)); return; } @@ -61,7 +61,7 @@ extern "C" { setting->status = f_string_dynamics_increase(setting->state.step_small, setting->contents); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamics_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); return; } @@ -70,7 +70,7 @@ extern "C" { setting->status = f_string_rangess_increase(setting->state.step_small, &setting->ignoress); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_rangess_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_rangess_increase)); return; } @@ -102,7 +102,7 @@ extern "C" { status_pipe = f_file_read_block(input, &setting->block); if (F_status_is_error(status_pipe)) { - fss_write_print_error(setting, main->error, "f_file_read_block"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_file_read_block)); status_pipe = F_status_set_error(F_pipe); @@ -130,7 +130,7 @@ extern "C" { setting->status = f_string_dynamic_increase_by(setting->block.used, setting->object); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } @@ -196,7 +196,7 @@ extern "C" { setting->status = f_string_dynamics_increase(setting->state.step_small, setting->contents); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamics_increase"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamics_increase)); break; } @@ -215,7 +215,7 @@ extern "C" { setting->status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } @@ -239,7 +239,7 @@ extern "C" { setting->status = f_string_dynamic_increase_by(total, &setting->contents->array[setting->contents->used]); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } @@ -315,7 +315,7 @@ extern "C" { setting->status = f_string_dynamic_increase_by(length + 1, &setting->contents->array[setting->contents->used]); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_increase_by)); break; } @@ -411,7 +411,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fll_fss_payload_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fll_fss_payload_write)); return; } @@ -451,7 +451,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_basic_list_object_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_basic_list_object_write)); return; } @@ -481,7 +481,7 @@ extern "C" { ); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "fl_fss_payload_content_write"); + fss_write_print_error(setting, main->error, macro_fss_write_f(fl_fss_payload_content_write)); return; } @@ -491,7 +491,7 @@ extern "C" { setting->status = f_string_dynamic_append(f_string_eol_s, &setting->buffer); if (F_status_is_error(setting->status)) { - fss_write_print_error(setting, main->error, "f_string_dynamic_append"); + fss_write_print_error(setting, main->error, macro_fss_write_f(f_string_dynamic_append)); return; } diff --git a/level_3/fss_write/c/payload/fss_write.h b/level_3/fss_write/c/payload/fss_write.h index 7c3170e..7a87455 100644 --- a/level_3/fss_write/c/payload/fss_write.h +++ b/level_3/fss_write/c/payload/fss_write.h @@ -45,6 +45,7 @@ // FSS Write includes. #include +#include #include #include #include diff --git a/level_3/fss_write/data/build/settings b/level_3/fss_write/data/build/settings index d283c3d..302010f 100644 --- a/level_3/fss_write/data/build/settings +++ b/level_3/fss_write/data/build/settings @@ -25,7 +25,7 @@ build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_print -lfll_pr build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library main/fss_write.c main/common.c main/print.c +build_sources_library main/fss_write.c main/common.c main/common-print.c main/print.c build_sources_library basic/fss_write.c basic/common.c basic/print.c build_sources_library basic_list/fss_write.c basic_list/common.c basic_list/print.c build_sources_library embedded_list/fss_write.c embedded_list/common.c embedded_list/print.c @@ -33,7 +33,7 @@ build_sources_library extended/fss_write.c extended/common.c extended/print.c build_sources_library extended_list/fss_write.c extended_list/common.c extended_list/print.c build_sources_library payload/fss_write.c payload/common.c payload/print.c -build_sources_headers main/fss_write.h main/common.h main/print.h main/private-common.h +build_sources_headers main/fss_write.h main/common.h main/common-print.h main/print.h main/private-common.h build_sources_headers basic/fss_write.h basic/common.h basic/print.h basic/private-common.h build_sources_headers basic_list/fss_write.h basic_list/common.h basic_list/print.h build_sources_headers embedded_list/fss_write.h embedded_list/common.h embedded_list/print.h diff --git a/level_3/iki_read/c/common-print.c b/level_3/iki_read/c/common-print.c new file mode 100644 index 0000000..b94b513 --- /dev/null +++ b/level_3/iki_read/c/common-print.c @@ -0,0 +1,31 @@ +#include "iki_read.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_iki_read_f_a_ + const f_string_t iki_read_f_a[] = { + "f_console_parameter_process", + "f_file_descriptor", + "f_file_read", + "f_file_size_by_id", + "f_file_stream_open", + "f_file_stream_read_until", + "f_string_dynamic_append_nulless", + "f_string_dynamic_increase_by", + "f_string_dynamic_resize", + "f_string_dynamics_append", + "f_string_dynamics_increase_by", + "f_string_dynamics_resize", + "f_string_maps_increase_by", + "f_string_triples_increase_by", + "fl_iki_read", + "fll_program_parameter_process_context", + "fll_program_parameter_process_verbosity", + }; +#endif // _di_iki_read_f_a_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_read/c/common-print.h b/level_3/iki_read/c/common-print.h new file mode 100644 index 0000000..a62097e --- /dev/null +++ b/level_3/iki_read/c/common-print.h @@ -0,0 +1,66 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common data structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_read_common_print_h +#define _iki_read_common_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A special array of strings intended for representing funciton names. + * + * These are primarily used for printing errors with the function names. + * + * The macro macro_iki_read_f() is used to reference the array index by the enum name. + * + * macro_iki_read_f(): + * - name: The name of the function. + */ +#ifndef _di_iki_read_f_a_ + extern const f_string_t iki_read_f_a[]; + + #define macro_iki_read_f(name) iki_read_f_a[iki_read_f_##name##_e] +#endif // _di_iki_read_f_a_ + +/** + * An enum representing specific indexes within the above array. + * + * This is a convenience enum used to make code slightly more readable. + */ +#ifndef _di_iki_read_f_e_ + enum { + iki_read_f_f_console_parameter_process_e, + iki_read_f_f_file_descriptor_e, + iki_read_f_f_file_read_e, + iki_read_f_f_file_size_by_id_e, + iki_read_f_f_file_stream_open_e, + iki_read_f_f_file_stream_read_until_e, + iki_read_f_f_string_dynamic_append_nulless_e, + iki_read_f_f_string_dynamic_increase_by_e, + iki_read_f_f_string_dynamic_resize_e, + iki_read_f_f_string_dynamics_append_e, + iki_read_f_f_string_dynamics_increase_by_e, + iki_read_f_f_string_dynamics_resize_e, + iki_read_f_f_string_maps_increase_by_e, + iki_read_f_f_string_triples_increase_by_e, + iki_read_f_fl_iki_read_e, + iki_read_f_fll_program_parameter_process_context_e, + iki_read_f_fll_program_parameter_process_verbosity_e, + }; // enum +#endif // _di_iki_read_f_e_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_read_common_print_h diff --git a/level_3/iki_read/c/common.c b/level_3/iki_read/c/common.c index dc52d8f..2903f9e 100644 --- a/level_3/iki_read/c/common.c +++ b/level_3/iki_read/c/common.c @@ -85,7 +85,7 @@ extern "C" { setting->status = f_console_parameter_process(arguments, &main->parameters); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_console_parameter_process"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_console_parameter_process)); return; } @@ -105,7 +105,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "fll_program_parameter_process_context"); + iki_read_print_error(setting, main->error, macro_iki_read_f(fll_program_parameter_process_context)); return; } @@ -136,7 +136,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); + iki_read_print_error(setting, main->error, macro_iki_read_f(fll_program_parameter_process_verbosity)); return; } @@ -239,7 +239,7 @@ extern "C" { setting->status = f_string_dynamics_increase_by(main->parameters.array[iki_read_parameter_name_e].values.used, &setting->names); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_dynamics_increase_by"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_increase_by)); return; } @@ -270,7 +270,7 @@ extern "C" { } // for if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_dynamics_append"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_append)); return; } @@ -303,7 +303,7 @@ extern "C" { setting->status = f_string_maps_increase_by(main->parameters.array[iki_read_parameter_replace_e].values.used / 2, &setting->replace); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_maps_increase_by"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_maps_increase_by)); return; } @@ -337,7 +337,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_dynamic_resize"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); return; } @@ -388,7 +388,7 @@ extern "C" { setting->status = f_string_triples_increase_by(main->parameters.array[iki_read_parameter_wrap_e].values.used / 3, &setting->wrap); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_triples_increase_by"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_triples_increase_by)); return; } @@ -426,7 +426,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_dynamic_resize"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); return; } @@ -551,7 +551,7 @@ extern "C" { setting->status = f_string_dynamics_resize(main->parameters.remaining.used, &setting->files); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_dynamics_resize"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamics_resize)); return; } @@ -565,7 +565,7 @@ extern "C" { setting->status = f_string_dynamic_resize(0, &setting->files.array[setting->files.used]); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_dynamic_resize"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); return; } @@ -611,7 +611,7 @@ extern "C" { setting->status = f_string_triples_increase_by(parameter.values.used / 3, triple); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_triples_increase_by"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_triples_increase_by)); return F_false; } @@ -651,7 +651,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_dynamic_resize"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_resize)); return F_false; } diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index e3f67e4..19bfc29 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -35,7 +35,7 @@ extern "C" { setting->status = f_file_read(file, &setting->buffer); if (F_status_is_error(setting->status)) { - iki_read_print_error_file(setting, main->error, "f_file_read", f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); + iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_read), f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); } else { iki_read_process_buffer(main, setting); @@ -69,7 +69,7 @@ extern "C" { setting->status = f_file_stream_open(setting->files.array[i], f_string_empty_s, &file); if (F_status_is_error(setting->status)) { - iki_read_print_error_file(setting, main->error, "f_file_stream_open", setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_stream_open), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); return; } @@ -77,7 +77,7 @@ extern "C" { setting->status = f_file_descriptor(&file); if (F_status_is_error(setting->status)) { - iki_read_print_error_file(setting, main->error, "f_file_descriptor", setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_descriptor), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); return; } @@ -87,7 +87,7 @@ extern "C" { setting->status = f_file_size_by_id(file, &size_file); if (F_status_is_error(setting->status)) { - iki_read_print_error_file(setting, main->error, "f_file_size_by_id", setting->files.array[i], f_file_operation_analyze_s, fll_error_file_type_file_e); + iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_size_by_id), setting->files.array[i], f_file_operation_analyze_s, fll_error_file_type_file_e); break; } @@ -114,7 +114,7 @@ extern "C" { setting->status = f_string_dynamic_increase_by(size_file + 1, &setting->buffer); if (F_status_is_error(setting->status)) { - iki_read_print_error_file(setting, main->error, "f_string_dynamic_increase_by", setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_string_dynamic_increase_by), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); break; } @@ -136,7 +136,7 @@ extern "C" { if (F_status_is_error(setting->status)) { if (F_status_set_fine(setting->status) != F_interrupt) { - iki_read_print_error_file(setting, main->error, "f_file_stream_read_until", setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); + iki_read_print_error_file(setting, main->error, macro_iki_read_f(f_file_stream_read_until), setting->files.array[i], f_file_operation_process_s, fll_error_file_type_file_e); } break; diff --git a/level_3/iki_read/c/iki_read.h b/level_3/iki_read/c/iki_read.h index e26f217..45f6006 100644 --- a/level_3/iki_read/c/iki_read.h +++ b/level_3/iki_read/c/iki_read.h @@ -52,6 +52,7 @@ // IKI Read includes. #include +#include #include #ifdef __cplusplus diff --git a/level_3/iki_read/c/private-read.c b/level_3/iki_read/c/private-read.c index 89eea4a..48d20de 100644 --- a/level_3/iki_read/c/private-read.c +++ b/level_3/iki_read/c/private-read.c @@ -169,7 +169,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "fl_iki_read"); + iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); return; } @@ -282,7 +282,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "fl_iki_read"); + iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); return; } @@ -396,7 +396,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "fl_iki_read"); + iki_read_print_error(setting, main->error, macro_iki_read_f(fl_iki_read)); return; } @@ -438,7 +438,7 @@ extern "C" { setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); if (F_status_is_error(setting->status)) { - iki_read_print_error(setting, main->error, "f_string_dynamic_append_nulless"); + iki_read_print_error(setting, main->error, macro_iki_read_f(f_string_dynamic_append_nulless)); f_string_dynamic_resize(0, &name); diff --git a/level_3/iki_read/data/build/settings b/level_3/iki_read/data/build/settings index b734186..4babf3b 100644 --- a/level_3/iki_read/data/build/settings +++ b/level_3/iki_read/data/build/settings @@ -22,11 +22,11 @@ build_libraries-individual -lfll_error -lfll_print -lfll_program -lfl_conversion build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library iki_read.c common.c print.c private-common.c private-print.c private-read.c +build_sources_library iki_read.c common.c common-print.c print.c private-common.c private-print.c private-read.c build_sources_program main.c -build_sources_headers iki_read.h common.h print.h +build_sources_headers iki_read.h common.h common-print.h print.h build_script yes build_shared yes diff --git a/level_3/iki_write/c/common-print.c b/level_3/iki_write/c/common-print.c new file mode 100644 index 0000000..1c97f36 --- /dev/null +++ b/level_3/iki_write/c/common-print.c @@ -0,0 +1,23 @@ +#include "iki_write.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_iki_write_f_a_ + const f_string_t iki_write_f_a[] = { + "f_console_parameter_process", + "f_file_read", + "f_iki_object_is", + "f_string_dynamic_partial_append_nulless", + "f_string_dynamic_seek_to", + "f_string_dynamics_resize", + "fll_iki_content_escape", + "fll_program_parameter_process_context", + "fll_program_parameter_process_verbosity", + }; +#endif // _di_iki_write_f_a_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/iki_write/c/common-print.h b/level_3/iki_write/c/common-print.h new file mode 100644 index 0000000..f4b329c --- /dev/null +++ b/level_3/iki_write/c/common-print.h @@ -0,0 +1,58 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common data structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _iki_write_common_print_h +#define _iki_write_common_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A special array of strings intended for representing funciton names. + * + * These are primarily used for printing errors with the function names. + * + * The macro macro_iki_write_f() is used to reference the array index by the enum name. + * + * macro_iki_write_f(): + * - name: The name of the function. + */ +#ifndef _di_iki_write_f_a_ + extern const f_string_t iki_write_f_a[]; + + #define macro_iki_write_f(name) iki_write_f_a[iki_write_f_##name##_e] +#endif // _di_iki_write_f_a_ + +/** + * An enum representing specific indexes within the above array. + * + * This is a convenience enum used to make code slightly more readable. + */ +#ifndef _di_iki_write_f_e_ + enum { + iki_write_f_f_console_parameter_process_e, + iki_write_f_f_file_read_e, + iki_write_f_f_iki_object_is_e, + iki_write_f_f_string_dynamic_partial_append_nulless_e, + iki_write_f_f_string_dynamic_seek_to_e, + iki_write_f_f_string_dynamics_resize_e, + iki_write_f_fll_iki_content_escape_e, + iki_write_f_fll_program_parameter_process_context_e, + iki_write_f_fll_program_parameter_process_verbosity_e, + }; // enum +#endif // _di_iki_write_f_e_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _iki_write_common_print_h diff --git a/level_3/iki_write/c/common.c b/level_3/iki_write/c/common.c index 6166cc4..8a9d1f6 100644 --- a/level_3/iki_write/c/common.c +++ b/level_3/iki_write/c/common.c @@ -61,7 +61,7 @@ extern "C" { setting->status = f_console_parameter_process(arguments, &main->parameters); if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "f_console_parameter_process"); + iki_write_print_error(setting, main->error, macro_iki_write_f(f_console_parameter_process)); return; } @@ -81,7 +81,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "fll_program_parameter_process_context"); + iki_write_print_error(setting, main->error, macro_iki_write_f(fll_program_parameter_process_context)); return; } @@ -112,7 +112,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); + iki_write_print_error(setting, main->error, macro_iki_write_f(fll_program_parameter_process_verbosity)); return; } @@ -181,7 +181,7 @@ extern "C" { setting->status = f_string_dynamics_resize(values->used, &setting->objects); if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "f_string_dynamics_resize"); + iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamics_resize)); return; } @@ -216,7 +216,7 @@ extern "C" { setting->status = f_string_dynamics_resize(values->used, &setting->contents); if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "f_string_dynamics_resize"); + iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamics_resize)); return; } diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 8f09554..1f7123b 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -61,7 +61,7 @@ extern "C" { if (F_status_is_error(status)) { setting->status = F_status_set_error(F_pipe); - iki_write_print_error_file(setting, main->error, "f_file_read", f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + iki_write_print_error_file(setting, main->error, macro_iki_write_f(f_file_read), f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); return; } @@ -87,7 +87,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "f_string_dynamic_seek_to"); + iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_seek_to)); return; } @@ -112,7 +112,7 @@ extern "C" { setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->content); if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "f_string_dynamic_partial_append_nulless"); + iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_partial_append_nulless)); return; } @@ -131,7 +131,7 @@ extern "C" { setting->status = f_string_dynamic_partial_append_nulless(setting->buffer, range, &setting->object); if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "f_string_dynamic_partial_append_nulless"); + iki_write_print_error(setting, main->error, macro_iki_write_f(f_string_dynamic_partial_append_nulless)); return; } diff --git a/level_3/iki_write/c/iki_write.h b/level_3/iki_write/c/iki_write.h index 67027cd..35d96f2 100644 --- a/level_3/iki_write/c/iki_write.h +++ b/level_3/iki_write/c/iki_write.h @@ -52,6 +52,7 @@ // IKI Write includes. #include +#include #include #ifdef __cplusplus diff --git a/level_3/iki_write/c/private-write.c b/level_3/iki_write/c/private-write.c index 7531131..cdaf9e7 100644 --- a/level_3/iki_write/c/private-write.c +++ b/level_3/iki_write/c/private-write.c @@ -32,7 +32,7 @@ extern "C" { } if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "f_iki_object_is"); + iki_write_print_error(setting, main->error, macro_iki_write_f(f_iki_object_is)); return; } @@ -42,7 +42,7 @@ extern "C" { setting->status = fll_iki_content_escape(content, setting->quote, &setting->escaped); if (F_status_is_error(setting->status)) { - iki_write_print_error(setting, main->error, "fll_iki_content_escape"); + iki_write_print_error(setting, main->error, macro_iki_write_f(fll_iki_content_escape)); return; } diff --git a/level_3/iki_write/data/build/settings b/level_3/iki_write/data/build/settings index 801023a..9d29ba5 100644 --- a/level_3/iki_write/data/build/settings +++ b/level_3/iki_write/data/build/settings @@ -21,11 +21,11 @@ build_libraries-individual -lfll_error -lfll_iki -lfll_print -lfll_program -lfl_ build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library iki_write.c common.c print.c private-common.c private-write.c +build_sources_library iki_write.c common.c common-print.c print.c private-common.c private-write.c build_sources_program main.c -build_sources_headers iki_write.h common.h print.h +build_sources_headers iki_write.h common.h common-print.h print.h build_script yes build_shared yes diff --git a/level_3/status_code/c/common-print.c b/level_3/status_code/c/common-print.c new file mode 100644 index 0000000..25ec837 --- /dev/null +++ b/level_3/status_code/c/common-print.c @@ -0,0 +1,19 @@ +#include "status_code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_status_code_f_a_ + const f_string_t status_code_f_a[] = { + "f_console_parameter_process", + "status_string_from", + "status_string_to", + "fll_program_parameter_process_context", + "fll_program_parameter_process_verbosity", + }; +#endif // _di_status_code_f_a_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/status_code/c/common-print.h b/level_3/status_code/c/common-print.h new file mode 100644 index 0000000..f9f7c2f --- /dev/null +++ b/level_3/status_code/c/common-print.h @@ -0,0 +1,54 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common data structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _status_code_common_print_h +#define _status_code_common_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A special array of strings intended for representing funciton names. + * + * These are primarily used for printing errors with the function names. + * + * The macro macro_status_code_f() is used to reference the array index by the enum name. + * + * macro_status_code_f(): + * - name: The name of the function. + */ +#ifndef _di_status_code_f_a_ + extern const f_string_t status_code_f_a[]; + + #define macro_status_code_f(name) status_code_f_a[status_code_f_##name##_e] +#endif // _di_status_code_f_a_ + +/** + * An enum representing specific indexes within the above array. + * + * This is a convenience enum used to make code slightly more readable. + */ +#ifndef _di_status_code_f_e_ + enum { + status_code_f_f_console_parameter_process_e, + status_code_f_status_string_from_e, + status_code_f_status_string_to_e, + status_code_f_fll_program_parameter_process_context_e, + status_code_f_fll_program_parameter_process_verbosity_e, + }; // enum +#endif // _di_status_code_f_e_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _status_code_common_print_h diff --git a/level_3/status_code/c/common.c b/level_3/status_code/c/common.c index 74e27d7..1ba6c32 100644 --- a/level_3/status_code/c/common.c +++ b/level_3/status_code/c/common.c @@ -59,7 +59,7 @@ extern "C" { setting->status = f_console_parameter_process(arguments, &main->parameters); if (F_status_is_error(setting->status)) { - status_code_print_error(setting, main->error, "f_console_parameter_process"); + status_code_print_error(setting, main->error, macro_status_code_f(f_console_parameter_process)); return; } @@ -79,7 +79,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - status_code_print_error(setting, main->error, "fll_program_parameter_process_context"); + status_code_print_error(setting, main->error, macro_status_code_f(fll_program_parameter_process_context)); return; } @@ -110,7 +110,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - status_code_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); + status_code_print_error(setting, main->error, macro_status_code_f(fll_program_parameter_process_verbosity)); return; } diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index 26881be..bedbeb1 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -14,11 +14,11 @@ extern "C" { if (!setting->status_string_from || !setting->status_string_to) { if (!setting->status_string_from) { - status_code_print_error_invalid_callback(setting, main->error, "status_string_from"); + status_code_print_error_invalid_callback(setting, main->error, macro_status_code_f(status_string_from)); } if (!setting->status_string_to) { - status_code_print_error_invalid_callback(setting, main->error, "status_string_to"); + status_code_print_error_invalid_callback(setting, main->error, macro_status_code_f(status_string_to)); } setting->status = F_status_set_error(F_parameter); diff --git a/level_3/status_code/c/status_code.h b/level_3/status_code/c/status_code.h index d4fd0f2..7baab5f 100644 --- a/level_3/status_code/c/status_code.h +++ b/level_3/status_code/c/status_code.h @@ -43,6 +43,7 @@ // Status Code includes. #include +#include #include #ifdef __cplusplus diff --git a/level_3/status_code/data/build/settings b/level_3/status_code/data/build/settings index 366d881..3889dfb 100644 --- a/level_3/status_code/data/build/settings +++ b/level_3/status_code/data/build/settings @@ -25,11 +25,11 @@ build_libraries-individual -lfll_error -lfll_print -lfll_program -lfll_status_st build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library status_code.c common.c print.c private-common.c private-status_code.c +build_sources_library status_code.c common.c common-print.c print.c private-common.c private-status_code.c build_sources_program main-status_code.c -build_sources_headers status_code.h common.h print.h +build_sources_headers status_code.h common.h common-print.h print.h build_script yes build_shared yes diff --git a/level_3/utf8/c/common-print.c b/level_3/utf8/c/common-print.c new file mode 100644 index 0000000..5d26921 --- /dev/null +++ b/level_3/utf8/c/common-print.c @@ -0,0 +1,22 @@ +#include "utf8.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_utf8_f_a_ + const f_string_t utf8_f_a[] = { + "f_console_parameter_prioritize_right", + "f_console_parameter_process", + "f_file_stream_open", + "f_string_dynamic_append_nulless", + "f_string_dynamics_increase_by", + "fll_program_parameter_process_context", + "fll_program_parameter_process_verbosity", + "utf8_detect_codepoint", + }; +#endif // _di_utf8_f_a_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_3/utf8/c/common-print.h b/level_3/utf8/c/common-print.h new file mode 100644 index 0000000..e8bfa4c --- /dev/null +++ b/level_3/utf8/c/common-print.h @@ -0,0 +1,57 @@ +/** + * FLL - Level 3 + * + * Project: FSS Write + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the common data structures. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _utf8_common_print_h +#define _utf8_common_print_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A special array of strings intended for representing funciton names. + * + * These are primarily used for printing errors with the function names. + * + * The macro macro_utf8_f() is used to reference the array index by the enum name. + * + * macro_utf8_f(): + * - name: The name of the function. + */ +#ifndef _di_utf8_f_a_ + extern const f_string_t utf8_f_a[]; + + #define macro_utf8_f(name) utf8_f_a[utf8_f_##name##_e] +#endif // _di_utf8_f_a_ + +/** + * An enum representing specific indexes within the above array. + * + * This is a convenience enum used to make code slightly more readable. + */ +#ifndef _di_utf8_f_e_ + enum { + utf8_f_f_console_parameter_prioritize_right_e, + utf8_f_f_console_parameter_process_e, + utf8_f_f_file_stream_open_e, + utf8_f_f_string_dynamic_append_nulless_e, + utf8_f_f_string_dynamics_increase_by_e, + utf8_f_fll_program_parameter_process_context_e, + utf8_f_fll_program_parameter_process_verbosity_e, + utf8_f_utf8_detect_codepoint_e, + }; // enum +#endif // _di_utf8_f_e_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _utf8_common_print_h diff --git a/level_3/utf8/c/common.c b/level_3/utf8/c/common.c index d473d96..b763aa0 100644 --- a/level_3/utf8/c/common.c +++ b/level_3/utf8/c/common.c @@ -98,7 +98,7 @@ extern "C" { setting->status = f_console_parameter_process(arguments, &main->parameters); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "f_console_parameter_process"); + utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_process)); return; } @@ -118,7 +118,7 @@ extern "C" { setting->status = fll_program_parameter_process_context(choices, modes, F_true, main); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "fll_program_parameter_process_context"); + utf8_print_error(setting, main->error, macro_utf8_f(fll_program_parameter_process_context)); return; } @@ -149,7 +149,7 @@ extern "C" { setting->status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "fll_program_parameter_process_verbosity"); + utf8_print_error(setting, main->error, macro_utf8_f(fll_program_parameter_process_verbosity)); return; } @@ -164,7 +164,7 @@ extern "C" { setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "f_console_parameter_prioritize_right"); + utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_prioritize_right)); return; } @@ -195,7 +195,7 @@ extern "C" { setting->status = f_console_parameter_prioritize_right(main->parameters, choices, &choice); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "f_console_parameter_prioritize_right"); + utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_prioritize_right)); return; } @@ -293,7 +293,7 @@ extern "C" { setting->status = f_string_dynamics_increase_by(1, &setting->path_files_to); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "f_string_dynamics_increase_by"); + utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamics_increase_by)); return; } @@ -303,7 +303,7 @@ extern "C" { setting->status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "f_string_dynamic_append_nulless"); + utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamic_append_nulless)); return; } @@ -313,7 +313,7 @@ extern "C" { setting->status = f_file_stream_open(main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_open_mode_append_s, &main->output.to); if (F_status_is_error(setting->status)) { - utf8_print_error_file(setting, main->error, "f_file_stream_open", main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); + utf8_print_error_file(setting, main->error, macro_utf8_f(f_file_stream_open), main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], f_file_operation_open_s, fll_error_file_type_file_e); return; } @@ -353,7 +353,7 @@ extern "C" { setting->status = f_string_dynamics_increase_by(main->parameters.array[utf8_parameter_from_file_e].values.used, &setting->path_files_from); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "f_string_dynamics_increase_by"); + utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamics_increase_by)); return; } @@ -372,7 +372,7 @@ extern "C" { if (F_status_is_error(setting->status)) { utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(setting->status), "f_string_dynamic_append_nulless", F_true); + fll_error_print(main->error, F_status_set_fine(setting->status), macro_utf8_f(f_string_dynamic_append_nulless), F_true); break; } @@ -424,7 +424,7 @@ extern "C" { setting->status = f_string_dynamics_resize(main->parameters.remaining.used, &setting->remaining); if (F_status_is_error(setting->status)) { - utf8_print_error(setting, main->error, "f_string_dynamic_append_nulless"); + utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamic_append_nulless)); return; } diff --git a/level_3/utf8/c/private-utf8.c b/level_3/utf8/c/private-utf8.c index 5b0d6ab..fa24f2c 100644 --- a/level_3/utf8/c/private-utf8.c +++ b/level_3/utf8/c/private-utf8.c @@ -45,7 +45,7 @@ extern "C" { if (F_status_is_error(status)) { utf8_print_line_first_locked(setting, main->error); - fll_error_print(main->error, F_status_set_fine(status), "utf8_detect_codepoint", F_true); + fll_error_print(main->error, F_status_set_fine(status), macro_utf8_f(utf8_detect_codepoint), F_true); break; } diff --git a/level_3/utf8/c/utf8.c b/level_3/utf8/c/utf8.c index 28ce190..034525d 100644 --- a/level_3/utf8/c/utf8.c +++ b/level_3/utf8/c/utf8.c @@ -78,7 +78,7 @@ extern "C" { setting->status = f_file_stream_open(setting->path_files_from.array[i], f_string_empty_s, &file); if (F_status_is_error(setting->status)) { - utf8_print_error_file(setting, main->error, "f_file_stream_open", setting->path_files_from.array[i], f_file_operation_open_s, fll_error_file_type_file_e); + utf8_print_error_file(setting, main->error, macro_utf8_f(f_file_stream_open), setting->path_files_from.array[i], f_file_operation_open_s, fll_error_file_type_file_e); break; } diff --git a/level_3/utf8/c/utf8.h b/level_3/utf8/c/utf8.h index efbcbaa..668cbcd 100644 --- a/level_3/utf8/c/utf8.h +++ b/level_3/utf8/c/utf8.h @@ -56,6 +56,7 @@ // UTF-8 includes. #include +#include #include #ifdef __cplusplus diff --git a/level_3/utf8/data/build/settings b/level_3/utf8/data/build/settings index 501819c..210338f 100644 --- a/level_3/utf8/data/build/settings +++ b/level_3/utf8/data/build/settings @@ -22,12 +22,12 @@ build_libraries-individual -lfll_error -lfll_print -lfll_program -lfl_conversion build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll -build_sources_library common.c print.c utf8.c +build_sources_library common.c common-print.c print.c utf8.c build_sources_library private-common.c private-utf8.c private-utf8_bytesequence.c private-utf8_codepoint.c build_sources_program main.c -build_sources_headers common.h print.h utf8.h +build_sources_headers common.h common-print.h print.h utf8.h build_script yes build_shared yes