From fa6dfe82cd1b2c2992e074fe8505edeba9b88b5e Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 2 Sep 2019 23:21:08 -0500 Subject: [PATCH] Update: console code and some macros Add explicit dark mode console option. Add support for order of operations priority on parameters ("+n +l +d" would result in colors for dark background because +d overrides both +n and +l due to being the right-most parameter). Rewrite level_3 programs to utilize the new fll_program_process_parameters() helper function. Fix some screwed up macro definitions and uses. --- level_0/f_console/c/console.h | 12 ++-- level_0/f_fss/c/fss.h | 2 +- level_0/f_string/c/string.h | 37 ++++------- level_0/f_type/c/type_array.h | 17 ++--- level_0/f_utf/c/utf.h | 53 ++++++---------- level_1/fl_console/c/console.c | 8 +++ level_2/fll_program/c/program.c | 73 ++++++++++++++++++++-- level_2/fll_program/c/program.h | 4 +- level_3/firewall/c/firewall.c | 43 +++---------- level_3/firewall/c/firewall.h | 7 ++- .../fss_basic_list_read/c/fss_basic_list_read.c | 41 ++---------- .../fss_basic_list_read/c/fss_basic_list_read.h | 4 +- .../fss_basic_list_write/c/fss_basic_list_write.c | 42 ++----------- .../fss_basic_list_write/c/fss_basic_list_write.h | 4 +- level_3/fss_basic_read/c/fss_basic_read.c | 41 ++---------- level_3/fss_basic_read/c/fss_basic_read.h | 4 +- level_3/fss_basic_write/c/fss_basic_write.c | 42 ++----------- level_3/fss_basic_write/c/fss_basic_write.h | 4 +- level_3/fss_extended_read/c/fss_extended_read.c | 41 ++---------- level_3/fss_extended_read/c/fss_extended_read.h | 4 +- level_3/fss_extended_write/c/fss_extended_write.c | 25 +++----- level_3/fss_extended_write/c/fss_extended_write.h | 4 +- level_3/fss_status_code/c/fss_status_code.c | 39 ++---------- level_3/fss_status_code/c/fss_status_code.h | 4 +- level_3/init/c/init.c | 36 ++--------- level_3/init/c/init.h | 13 +++- level_3/init/c/private-init.c | 2 +- level_3/status_code/c/status_code.c | 39 ++---------- level_3/status_code/c/status_code.h | 4 +- 29 files changed, 221 insertions(+), 428 deletions(-) diff --git a/level_0/f_console/c/console.h b/level_0/f_console/c/console.h index 76fdcc9..ed25f8b 100644 --- a/level_0/f_console/c/console.h +++ b/level_0/f_console/c/console.h @@ -61,12 +61,14 @@ extern "C" { * Create some standard command line parameter options required by the kevux/fss/fll specifications. */ #ifndef _di_f_standard_console_parameters_ - #define f_console_standard_short_debug "d" + #define f_console_standard_short_dark "d" + #define f_console_standard_short_debug "D" #define f_console_standard_short_help "h" #define f_console_standard_short_light "l" #define f_console_standard_short_no_color "n" #define f_console_standard_short_version "v" + #define f_console_standard_long_dark "dark" #define f_console_standard_long_debug "debug" #define f_console_standard_long_help "help" #define f_console_standard_long_light "light" @@ -90,7 +92,6 @@ extern "C" { #define f_console_default_allocation_step 4 #endif // _di_f_console_default_allocation_step_ - /** * Provide console type enumerations: * @@ -133,6 +134,8 @@ extern "C" { * - type: One of the f_console_type_* codes, defining how this parameter is to be processed. * - result: A code representing that the parameter was found and how it was found ('-h' vs '--help'). * - total: A number representing the total number of times this parameter was found ('-h -h' would result in a total of 2). + * - location: The last location in argv[] where this parameter was found. + * - location_sub: The last sub-location at location in argv (only used by short parameters, such as -h or +l). * - additional: An array of locations representing where in the argv[] the additional arguments are found. */ #ifndef _di_f_console_parameter_ @@ -147,11 +150,12 @@ extern "C" { uint8_t result; uint8_t total; + f_string_length location; + f_string_length location_sub; f_string_lengths additional; } f_console_parameter; - #define f_console_parameter_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value) \ - { symbol_short, symbol_long, symbol_other, has_additional, type_value, f_console_result_none, 0, f_string_lengths_initialize } + #define f_console_parameter_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value) { symbol_short, symbol_long, symbol_other, has_additional, type_value, f_console_result_none, 0, 0, 0, f_string_lengths_initialize } #endif // _di_f_console_parameter_ /** diff --git a/level_0/f_fss/c/fss.h b/level_0/f_fss/c/fss.h index 448d205..17bee35 100644 --- a/level_0/f_fss/c/fss.h +++ b/level_0/f_fss/c/fss.h @@ -133,7 +133,7 @@ enum { #define f_fss_headers_initialize { 0, 0, 0 } - #define f_clear_fss_headers(headers) f_macro_memory_structure_clear(headers) + #define f_macro_fss_headers_clear(headers) f_macro_memory_structure_clear(headers) #define f_macro_fss_headers_new(status, headers, length) f_macro_memory_structure_new(status, headers, f_fss_header, length) diff --git a/level_0/f_string/c/string.h b/level_0/f_string/c/string.h index 8cf3b2d..6748ef2 100644 --- a/level_0/f_string/c/string.h +++ b/level_0/f_string/c/string.h @@ -122,20 +122,15 @@ extern "C" { #define f_string_lengths_initialize { 0, 0, 0 } - #define f_macro_string_lengths_new(status, lengths) \ - f_macro_memory_structure_new(status, lengths, f_string_length) + #define f_macro_string_lengths_clear(lengths) f_macro_memory_structure_clear(lengths) - #define f_macro_string_lengths_delete(status, lengths) \ - f_macro_memory_structure_delete(status, lengths, f_string_length) + #define f_macro_string_lengths_new(status, lengths, length) f_macro_memory_structure_new(status, lengths, f_string_length, length) - #define f_macro_string_lengths_destroy(status, lengths) \ - f_macro_memory_structure_destroy(status, lengths, f_string_length) + #define f_macro_string_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_string_length) + #define f_macro_string_lengths_destroy(status, lengths) f_macro_memory_structure_destroy(status, lengths, f_string_length) - #define f_macro_string_lengths_resize(status, lengths, new_length) \ - f_macro_memory_structure_resize(status, lengths, f_string_length, new_length) - - #define f_macro_string_lengths_adjust(status, lengths, new_length) \ - f_macro_memory_structure_adjust(status, lengths, f_string_length, new_length) + #define f_macro_string_lengths_resize(status, lengths, new_length) f_macro_memory_structure_resize(status, lengths, f_string_length, new_length) + #define f_macro_string_lengths_adjust(status, lengths, new_length) f_macro_memory_structure_adjust(status, lengths, f_string_length, new_length) #endif // _di_f_string_lengths_ /** @@ -176,23 +171,15 @@ extern "C" { #define f_string_locations_initialize {0, 0, 0} - #define f_clear_string_locations(locations) \ - f_macro_memory_structure_clear(locations) - - #define f_macro_string_locations_new(status, locations, length) \ - f_macro_memory_structure_new(status, locations, f_string_location, length) - - #define f_macro_string_locations_delete(status, locations) \ - f_macro_memory_structure_delete(status, locations, f_string_location) + #define f_clear_string_locations(locations) f_macro_memory_structure_clear(locations) - #define f_macro_string_locations_destroy(status, locations) \ - f_macro_memory_structure_destroy(status, locations, f_string_location) + #define f_macro_string_locations_new(status, locations, length) f_macro_memory_structure_new(status, locations, f_string_location, length) - #define f_macro_string_locations_resize(status, locations, new_length) \ - f_macro_memory_structure_resize(status, locations, f_string_location, new_length) + #define f_macro_string_locations_delete(status, locations) f_macro_memory_structure_delete(status, locations, f_string_location) + #define f_macro_string_locations_destroy(status, locations) f_macro_memory_structure_destroy(status, locations, f_string_location) - #define f_macro_string_locations_adjust(status, locations, new_length) \ - f_macro_memory_structure_adjust(status, locations, f_string_location, new_length) + #define f_macro_string_locations_resize(status, locations, new_length) f_macro_memory_structure_resize(status, locations, f_string_location, new_length) + #define f_macro_string_locations_adjust(status, locations, new_length) f_macro_memory_structure_adjust(status, locations, f_string_location, new_length) #endif // _di_f_string_locations_ /** diff --git a/level_0/f_type/c/type_array.h b/level_0/f_type/c/type_array.h index a1f2f3a..a7eaef2 100644 --- a/level_0/f_type/c/type_array.h +++ b/level_0/f_type/c/type_array.h @@ -31,20 +31,15 @@ extern "C" { #define f_array_lengths_initialize { 0, 0, 0 } - #define f_macro_array_lengths_new(status, lengths, length) \ - f_macro_memory_structure_new(status, lengths, f_array_length, length) + #define f_macro_array_lengths_clear(lengths) f_macro_memory_structure_clear(lengths) - #define f_macro_array_lengths_delete(status, lengths) \ - f_macro_memory_structure_delete(status, lengths, f_array_length) + #define f_macro_array_lengths_new(status, lengths, length) f_macro_memory_structure_new(status, lengths, f_array_length, length) - #define f_macro_array_lengths_destroy(status, lengths) \ - f_macro_memory_structure_destroy(status, lengths, f_array_length) + #define f_macro_array_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_array_length) + #define f_macro_array_lengths_destroy(status, lengths) f_macro_memory_structure_destroy(status, lengths, f_array_length) - #define f_macro_array_lengths_resize(status, lengths, new_length) \ - f_macro_memory_structure_resize(status, lengths, f_array_length, new_length) - - #define f_macro_array_lengths_adjust(status, lengths, new_length) \ - f_macro_memory_structure_adjust(status, lengths, f_array_length, new_length) + #define f_macro_array_lengths_resize(status, lengths, new_length) f_macro_memory_structure_resize(status, lengths, f_array_length, new_length) + #define f_macro_array_lengths_adjust(status, lengths, new_length) f_macro_memory_structure_adjust(status, lengths, f_array_length, new_length) #endif // _di_f_array_lengths_ #ifdef __cplusplus diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index be71f1b..897d550 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -174,14 +174,12 @@ extern "C" { #define f_utf_string_initialize f_utf_character_eos #define f_macro_utf_string_new(status, string, length) status = f_memory_new((void **) & string, sizeof(f_utf_string), length) + #define f_macro_utf_string_delete(status, string, size) status = f_memory_delete((void **) & string, sizeof(f_utf_string), size) #define f_macro_utf_string_destroy(status, string, size) status = f_memory_destroy((void **) & string, sizeof(f_utf_string), size) - #define f_macro_utf_string_resize(status, string, old_length, new_length) \ - status = f_memory_resize((void **) & string, sizeof(f_utf_string), old_length, new_length) - - #define f_macro_utf_string_adjust(status, string, old_length, new_length) \ - status = f_memory_adjust((void **) & string, sizeof(f_utf_string), old_length, new_length) + #define f_macro_utf_string_resize(status, string, old_length, new_length) status = f_memory_resize((void **) & string, sizeof(f_utf_string), old_length, new_length) + #define f_macro_utf_string_adjust(status, string, old_length, new_length) status = f_memory_adjust((void **) & string, sizeof(f_utf_string), old_length, new_length) #endif // _di_f_utf_string_ /** @@ -191,14 +189,12 @@ extern "C" { typedef f_s_long f_utf_string_length; #define f_macro_utf_string_length_new(status, string, length) status = f_memory_new((void **) & string, sizeof(f_utf_string_length), length) + #define f_macro_utf_string_length_delete(status, string, length) status = f_memory_delete((void **) & string, sizeof(f_utf_string_length), length) #define f_macro_utf_string_length_destroy(status, string, size) status = f_memory_destroy((f_void_P *) & string, sizeof(f_utf_string_length), size) - #define f_macro_utf_string_length_resize(status, length, old_length, new_length) \ - status = f_memory_resize((void **) & length, sizeof(f_utf_string_length), old_length, new_length) - - #define f_macro_utf_string_length_adjust(status, length, old_length, new_length) \ - status = f_memory_adjust((void **) & length, sizeof(f_utf_string_length), old_length, new_length) + #define f_macro_utf_string_length_resize(status, length, old_length, new_length) status = f_memory_resize((void **) & length, sizeof(f_utf_string_length), old_length, new_length) + #define f_macro_utf_string_length_adjust(status, length, old_length, new_length) status = f_memory_adjust((void **) & length, sizeof(f_utf_string_length), old_length, new_length) #endif // _di_f_utf_string_length_ /** @@ -214,20 +210,15 @@ extern "C" { #define f_utf_string_lengths_initialize { 0, 0, 0 } - #define f_macro_utf_string_length_news(status, lengths) \ - f_macro_memory_structure_new(status, lengths, f_utf_string_length) + #define f_macro_utf_string_lengths_clear(lengths) f_macro_memory_structure_clear(lengths) - #define f_macro_utf_string_length_deletes(status, lengths) \ - f_macro_memory_structure_delete(status, lengths, f_utf_string_length) + #define f_macro_utf_string_lengths_new(status, lengths, length) f_macro_memory_structure_new(status, lengths, f_utf_string_length, length) - #define f_macro_utf_string_length_destroys(status, lengths) \ - f_macro_memory_structure_destroy(status, lengths, f_utf_string_length) + #define f_macro_utf_string_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_utf_string_length) + #define f_macro_utf_string_lengths_destroy(status, lengths) f_macro_memory_structure_destroy(status, lengths, f_utf_string_length) - #define f_macro_utf_string_length_resizes(status, lengths, new_length) \ - f_macro_memory_structure_resize(status, lengths, f_utf_string_length, new_length) - - #define f_macro_utf_string_length_adjusts(status, lengths, new_length) \ - f_macro_memory_structure_adjust(status, lengths, f_utf_string_length, new_length) + #define f_macro_utf_string_lengths_resize(status, lengths, new_length) f_macro_memory_structure_resize(status, lengths, f_utf_string_length, new_length) + #define f_macro_utf_string_lengths_adjust(status, lengths, new_length) f_macro_memory_structure_adjust(status, lengths, f_utf_string_length, new_length) #endif // _di_f_utf_string_lengths_ /** @@ -268,23 +259,15 @@ extern "C" { #define f_utf_string_locations_initialize {0, 0, 0} - #define f_clear_utf_string_locations(locations) \ - f_macro_memory_structure_clear(locations) - - #define f_macro_utf_string_location_news(status, locations, length) \ - f_macro_memory_structure_new(status, locations, f_utf_string_location, length) - - #define f_macro_utf_string_location_deletes(status, locations) \ - f_macro_memory_structure_delete(status, locations, f_utf_string_location) + #define f_clear_utf_string_locations(locations) f_macro_memory_structure_clear(locations) - #define f_macro_utf_string_location_destroys(status, locations) \ - f_macro_memory_structure_destroy(status, locations, f_utf_string_location) + #define f_macro_utf_string_location_news(status, locations, length) f_macro_memory_structure_new(status, locations, f_utf_string_location, length) - #define f_macro_utf_string_location_resizes(status, locations, new_length) \ - f_macro_memory_structure_resize(status, locations, f_utf_string_location, new_length) + #define f_macro_utf_string_location_deletes(status, locations) f_macro_memory_structure_delete(status, locations, f_utf_string_location) + #define f_macro_utf_string_location_destroys(status, locations) f_macro_memory_structure_destroy(status, locations, f_utf_string_location) - #define f_macro_utf_string_location_adjusts(status, locations, new_length) \ - f_macro_memory_structure_adjust(status, locations, f_utf_string_location, new_length) + #define f_macro_utf_string_location_resizes(status, locations, new_length) f_macro_memory_structure_resize(status, locations, f_utf_string_location, new_length) + #define f_macro_utf_string_location_adjusts(status, locations, new_length) f_macro_memory_structure_adjust(status, locations, f_utf_string_location, new_length) #endif // _di_f_utf_string_locations_ /** diff --git a/level_1/fl_console/c/console.c b/level_1/fl_console/c/console.c index 348054b..5db19bd 100644 --- a/level_1/fl_console/c/console.c +++ b/level_1/fl_console/c/console.c @@ -118,8 +118,14 @@ extern "C" { } parameters[parameter_counter].result = f_console_result_found; + parameters[parameter_counter].location = location; + parameters[parameter_counter].location_sub = 0; parameters[parameter_counter].total++; + if (result == console_short) { + parameters[parameter_counter].location_sub = sub_location; + } + if (parameters[parameter_counter].has_additional) { if (needs_additional.used + parameters[parameter_counter].has_additional > needs_additional.size) { f_status allocation_status = f_none; @@ -161,6 +167,8 @@ extern "C" { } parameters[parameter_counter].result = f_console_result_found; + parameters[parameter_counter].location = location; + parameters[parameter_counter].location_sub = 0; parameters[parameter_counter].total++; if (parameters[parameter_counter].has_additional) { diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 6209a15..2a10531 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -79,14 +79,79 @@ extern "C" { #endif // _di_fll_program_print_version_ #ifndef _di_fll_program_process_parameters_ - f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, f_string_lengths *remaining, fl_color_context *context) { + f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, const f_array_length parameter_dark, f_string_lengths *remaining, fl_color_context *context) { f_status status = f_none; f_status allocation_status = f_none; status = fl_process_parameters(argc, argv, parameters, total_parameters, remaining); - // load colors when not told to show no colors - if (parameters[parameter_no_color].result == f_console_result_none) { + f_string_length color_mode = parameter_dark; + + if (parameters[parameter_no_color].result == f_console_result_found) { + if (parameters[parameter_light].result == f_console_result_none) { + if (parameters[parameter_dark].result == f_console_result_none || parameters[parameter_no_color].location > parameters[parameter_dark].location) { + color_mode = parameter_no_color; + } + else if (parameters[parameter_no_color].location == parameters[parameter_dark].location && parameters[parameter_no_color].location_sub > parameters[parameter_dark].location_sub) { + color_mode = parameter_no_color; + } + } + else { + if (parameters[parameter_dark].result == f_console_result_none) { + if (parameters[parameter_no_color].location > parameters[parameter_light].location) { + color_mode = parameter_no_color; + } + else if (parameters[parameter_no_color].location == parameters[parameter_light].location && parameters[parameter_no_color].location_sub > parameters[parameter_light].location_sub) { + color_mode = parameter_no_color; + } + else { + color_mode = parameter_light; + } + } + else if (parameters[parameter_no_color].location > parameters[parameter_dark].location) { + if (parameters[parameter_no_color].location > parameters[parameter_light].location) { + color_mode = parameter_no_color; + } + else if (parameters[parameter_no_color].location == parameters[parameter_light].location && parameters[parameter_no_color].location_sub > parameters[parameter_light].location_sub) { + color_mode = parameter_no_color; + } + else { + color_mode = parameter_light; + } + } + else if (parameters[parameter_no_color].location == parameters[parameter_dark].location && parameters[parameter_no_color].location_sub > parameters[parameter_dark].location_sub) { + if (parameters[parameter_no_color].location > parameters[parameter_light].location) { + color_mode = parameter_no_color; + } + else if (parameters[parameter_no_color].location == parameters[parameter_light].location && parameters[parameter_no_color].location_sub > parameters[parameter_light].location_sub) { + color_mode = parameter_no_color; + } + else { + color_mode = parameter_light; + } + } + else if (parameters[parameter_light].location > parameters[parameter_dark].location) { + color_mode = parameter_light; + } + else if (parameters[parameter_light].location == parameters[parameter_dark].location && parameters[parameter_light].location_sub > parameters[parameter_dark].location_sub) { + color_mode = parameter_light; + } + } + } + else if (parameters[parameter_light].result == f_console_result_found) { + if (parameters[parameter_dark].result == f_console_result_none) { + color_mode = parameter_light; + } + else if (parameters[parameter_light].location > parameters[parameter_dark].location) { + color_mode = parameter_light; + } + else if (parameters[parameter_light].location == parameters[parameter_dark].location && parameters[parameter_light].location_sub > parameters[parameter_dark].location_sub) { + color_mode = parameter_light; + } + } + + // load colors unless told not to. + if (color_mode != parameter_no_color) { fl_macro_color_context_new(allocation_status, (*context)); if (f_status_is_error(allocation_status)) { @@ -94,7 +159,7 @@ extern "C" { return allocation_status; } - fl_color_load_context(context, parameters[parameter_light].result == f_console_result_found); + fl_color_load_context(context, color_mode == parameter_light); } if (f_status_is_error(status)) { diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index 129c56d..f67c8de 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -126,6 +126,8 @@ extern "C" { * The parameter in the parameters array representing the no-color option. * @param parameter_light * The parameter in the parameters array representing the light-color option. + * @param parameter_dark + * The parameter in the parameters array representing the dark-color option. * @param remaining * A list of remaining parameters not associated with anything. * @param context @@ -138,7 +140,7 @@ extern "C" { * f_reallocation_error (with error bit) on memory reallocation error. */ #ifndef _di_fll_program_process_parameters_ - extern f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, f_string_lengths *remaining, fl_color_context *context); + extern f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, const f_array_length parameter_dark, f_string_lengths *remaining, fl_color_context *context); #endif // _di_fll_program_process_parameters_ #ifdef __cplusplus diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index b126d00..a330fa4 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -17,6 +17,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -55,48 +56,15 @@ extern "C" { #ifndef _di_firewall_main_ f_return_status firewall_main(const f_s_int argc, const f_string argv[], firewall_data *data) { - f_status status = f_none; - f_status status2 = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, firewall_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[firewall_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(status2, data->context); - - if (status2 == f_none) { - fl_color_load_context(&data->context, data->parameters[firewall_parameter_light].result == f_console_result_found); - } - else { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - firewall_delete_data(data); - return status2; - } - } + f_status status = fll_program_process_parameters(argc, argv, data->parameters, firewall_total_parameters, firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } - else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory"); - } - else if (f_status_set_fine(status) == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()"); - } - else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status)); - } - firewall_delete_data(data); return f_status_set_error(status); } + status = f_none; + // execute parameter results if (data->parameters[firewall_parameter_help].result == f_console_result_found) { firewall_print_help(*data); @@ -567,6 +535,7 @@ extern "C" { status = firewall_buffer_rules(file_path.string, f_true, &local, data); + f_status status2 = f_none; f_macro_string_dynamic_delete(status2, file_path); } @@ -628,6 +597,8 @@ extern "C" { status = firewall_create_custom_chains(&reserved, &local, data); if (f_status_is_error(status)) { + f_status status2 = f_none; + firewall_macro_delete_fss_buffers(status2, local.buffer, local.chain_objects, local.chain_contents) firewall_delete_data(data); return status; diff --git a/level_3/firewall/c/firewall.h b/level_3/firewall/c/firewall.h index e9d6cba..dff2708 100644 --- a/level_3/firewall/c/firewall.h +++ b/level_3/firewall/c/firewall.h @@ -204,6 +204,7 @@ extern "C" { enum { firewall_parameter_help, firewall_parameter_light, + firewall_parameter_dark, firewall_parameter_no_color, firewall_parameter_version, @@ -240,6 +241,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, f_false, f_console_type_inverse), \ @@ -250,12 +252,13 @@ extern "C" { f_console_parameter_initialize(0, 0, firewall_command_show, f_false, f_console_type_other), \ } - #define firewall_total_parameters 10 + #define firewall_total_parameters 11 #else #define f_console_parameter_initialize_firewall \ { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(0, 0, firewall_command_start, f_false, f_console_type_other), \ @@ -265,7 +268,7 @@ extern "C" { f_console_parameter_initialize(0, 0, firewall_command_show, f_false, f_console_type_other), \ } - #define firewall_total_parameters 9 + #define firewall_total_parameters 10 #endif // _en_firewall_debug_ #endif // _di_firewall_defines_ diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index a5061bc..143f0ec 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -10,6 +10,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -32,48 +33,16 @@ extern "C" { f_return_status fss_basic_list_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility ("internal"))); f_return_status fss_basic_list_read_main(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data) { - f_status status = f_none; - f_status status2 = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, fss_basic_list_read_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[fss_basic_list_read_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(status2, data->context); - - if (f_status_is_error(status2)) { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - fss_basic_list_read_delete_data(data); - return status2; - } - else { - fl_color_load_context(&data->context, data->parameters[fss_basic_list_read_parameter_light].result == f_console_result_found); - } - } + f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_list_read_total_parameters, fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } - else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory"); - } - else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()"); - } - else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status)); - } - fss_basic_list_read_delete_data(data); return f_status_set_error(status); } + f_status status2 = f_none; + status = f_none; + // execute parameter results if (data->parameters[fss_basic_list_read_parameter_help].result == f_console_result_found) { fss_basic_list_read_print_help(*data); diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.h b/level_3/fss_basic_list_read/c/fss_basic_list_read.h index 85a58db..695bab1 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.h @@ -71,6 +71,7 @@ extern "C" { enum { fss_basic_list_read_parameter_help, fss_basic_list_read_parameter_light, + fss_basic_list_read_parameter_dark, fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_version, @@ -86,6 +87,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(fss_basic_list_read_short_name, fss_basic_list_read_long_name, 0, f_true, f_console_type_normal), \ @@ -96,7 +98,7 @@ extern "C" { f_console_parameter_initialize(fss_basic_list_read_short_line, fss_basic_list_read_long_line, 0, f_true, f_console_type_normal), \ } - #define fss_basic_list_read_total_parameters 10 + #define fss_basic_list_read_total_parameters 11 #endif // _di_fss_basic_list_read_defines_ #ifndef _di_fss_basic_list_read_data_ diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index 187d67c..dd841b7 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -10,6 +10,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -27,48 +28,15 @@ extern "C" { #ifndef _di_fss_basic_list_write_main_ f_return_status fss_basic_list_write_main(const f_array_length argc, const f_string argv[], fss_basic_list_write_data *data) { - f_status status = f_none; - f_status status2 = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, fss_basic_list_write_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[fss_basic_list_write_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(status2, data->context); - - if (f_status_is_error(status2)) { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - fss_basic_list_write_delete_data(data); - return status2; - } - else { - fl_color_load_context(&data->context, data->parameters[fss_basic_list_write_parameter_light].result == f_console_result_found); - } - } + f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_list_write_total_parameters, fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } - else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory."); - } - else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()."); - } - else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", f_status_set_error(status)); - } - fss_basic_list_write_delete_data(data); return f_status_set_error(status); } + status = f_none; + // execute parameter results if (data->parameters[fss_basic_list_write_parameter_help].result == f_console_result_found) { fss_basic_list_write_print_help(*data); @@ -110,6 +78,8 @@ extern "C" { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status)); } + f_status status2 = f_none; + f_macro_string_dynamic_delete(status2, input); fss_basic_list_write_delete_data(data); return f_status_set_error(status); diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.h b/level_3/fss_basic_list_write/c/fss_basic_list_write.h index ea44cd1..472791b 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.h +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.h @@ -61,6 +61,7 @@ extern "C" { enum { fss_basic_list_write_parameter_help, fss_basic_list_write_parameter_light, + fss_basic_list_write_parameter_dark, fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_version, @@ -73,6 +74,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(fss_basic_list_write_short_object, fss_basic_list_write_long_object, 0, f_false, f_console_type_normal), \ @@ -80,7 +82,7 @@ extern "C" { f_console_parameter_initialize(fss_basic_list_write_short_string, fss_basic_list_write_long_string, 0, f_true, f_console_type_normal), \ } - #define fss_basic_list_write_total_parameters 7 + #define fss_basic_list_write_total_parameters 8 #endif // _di_fss_basic_list_write_defines_ #ifndef _di_fss_basic_list_write_data_ diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 5c23903..0723658 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -10,6 +10,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -30,48 +31,16 @@ extern "C" { f_return_status fss_basic_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_read_data *data, const f_string filename, const f_string_length target) f_gcc_attribute_visibility_internal; f_return_status fss_basic_read_main(const f_array_length argc, const f_string argv[], fss_basic_read_data *data) { - f_status status = f_none; - f_status status2 = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, fss_basic_read_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[fss_basic_read_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(status2, data->context); - - if (f_status_is_error(status2)) { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - fss_basic_read_delete_data(data); - return status2; - } - else { - fl_color_load_context(&data->context, data->parameters[fss_basic_read_parameter_light].result == f_console_result_found); - } - } + f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_read_total_parameters, fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } - else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory"); - } - else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()"); - } - else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status)); - } - fss_basic_read_delete_data(data); return f_status_set_error(status); } + f_status status2 = f_none; + status = f_none; + // execute parameter results if (data->parameters[fss_basic_read_parameter_help].result == f_console_result_found) { fss_basic_read_print_help(*data); diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h index 6ff2da9..e176f1e 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -67,6 +67,7 @@ extern "C" { enum { fss_basic_read_parameter_help, fss_basic_read_parameter_light, + fss_basic_read_parameter_dark, fss_basic_read_parameter_no_color, fss_basic_read_parameter_version, @@ -80,6 +81,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(fss_basic_read_short_name, fss_basic_read_long_name, 0, f_true, f_console_type_normal), \ @@ -88,7 +90,7 @@ extern "C" { f_console_parameter_initialize(fss_basic_read_short_object, fss_basic_read_long_object, 0, f_false, f_console_type_normal), \ } - #define fss_basic_read_total_parameters 8 + #define fss_basic_read_total_parameters 9 #endif // _di_fss_basic_read_defines_ #ifndef _di_fss_basic_read_data_ diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index 03ede7f..ec45108 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -10,6 +10,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -27,48 +28,15 @@ extern "C" { #ifndef _di_fss_basic_write_main_ f_return_status fss_basic_write_main(const f_array_length argc, const f_string argv[], fss_basic_write_data *data) { - f_status status = f_none; - f_status status2 = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, fss_basic_write_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[fss_basic_write_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(status2, data->context); - - if (f_status_is_error(status2)) { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - fss_basic_write_delete_data(data); - return status2; - } - else { - fl_color_load_context(&data->context, data->parameters[fss_basic_write_parameter_light].result == f_console_result_found); - } - } + f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_write_total_parameters, fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } - else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory."); - } - else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()."); - } - else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", f_status_set_error(status)); - } - fss_basic_write_delete_data(data); return f_status_set_error(status); } + status = f_none; + // execute parameter results if (data->parameters[fss_basic_write_parameter_help].result == f_console_result_found) { fss_basic_write_print_help(*data); @@ -110,6 +78,8 @@ extern "C" { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status)); } + f_status status2 = f_none; + f_macro_string_dynamic_delete(status2, input); fss_basic_write_delete_data(data); return f_status_set_error(status); diff --git a/level_3/fss_basic_write/c/fss_basic_write.h b/level_3/fss_basic_write/c/fss_basic_write.h index 2980d51..9a46e68 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.h +++ b/level_3/fss_basic_write/c/fss_basic_write.h @@ -60,6 +60,7 @@ extern "C" { enum { fss_basic_write_parameter_help, fss_basic_write_parameter_light, + fss_basic_write_parameter_dark, fss_basic_write_parameter_no_color, fss_basic_write_parameter_version, @@ -72,6 +73,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(fss_basic_write_short_object, fss_basic_write_long_object, 0, f_false, f_console_type_normal), \ @@ -79,7 +81,7 @@ extern "C" { f_console_parameter_initialize(fss_basic_write_short_string, fss_basic_write_long_string, 0, f_true, f_console_type_normal), \ } - #define fss_basic_write_total_parameters 7 + #define fss_basic_write_total_parameters 8 #endif // _di_fss_basic_write_defines_ #ifndef _di_fss_basic_write_data_ diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 9bf5b16..17ca402 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -10,6 +10,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -31,48 +32,16 @@ extern "C" { f_return_status fss_extended_read_main_process_file(const f_array_length argc, const f_string argv[], fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) f_gcc_attribute_visibility_internal; f_return_status fss_extended_read_main(const f_array_length argc, const f_string argv[], fss_extended_read_data *data) { - f_status status = f_none; - f_status status2 = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, fss_extended_read_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[fss_extended_read_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(status2, data->context); - - if (f_status_is_error(status2)) { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - fss_extended_read_delete_data(data); - return status2; - } - else { - fl_color_load_context(&data->context, data->parameters[fss_extended_read_parameter_light].result == f_console_result_found); - } - } + f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_extended_read_total_parameters, fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } - else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory"); - } - else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()"); - } - else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status)); - } - fss_extended_read_delete_data(data); return f_status_set_error(status); } + f_status status2 = f_none; + status = f_none; + // execute parameter results if (data->parameters[fss_extended_read_parameter_help].result == f_console_result_found) { fss_extended_read_print_help(*data); diff --git a/level_3/fss_extended_read/c/fss_extended_read.h b/level_3/fss_extended_read/c/fss_extended_read.h index 4ac7910..7138277 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.h +++ b/level_3/fss_extended_read/c/fss_extended_read.h @@ -69,6 +69,7 @@ extern "C" { enum { fss_extended_read_parameter_help, fss_extended_read_parameter_light, + fss_extended_read_parameter_dark, fss_extended_read_parameter_no_color, fss_extended_read_parameter_version, @@ -83,6 +84,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(fss_extended_read_short_name, fss_extended_read_long_name, 0, f_true, f_console_type_normal), \ @@ -92,7 +94,7 @@ extern "C" { f_console_parameter_initialize(fss_extended_read_short_select, fss_extended_read_long_select, 0, f_true, f_console_type_normal), \ } - #define fss_extended_read_total_parameters 9 + #define fss_extended_read_total_parameters 10 #endif // _di_fss_extended_read_defines_ #ifndef _di_fss_extended_read_data_ diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index 2b67fb6..db587bc 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -10,6 +10,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -28,25 +29,15 @@ extern "C" { #ifndef _di_fss_extended_write_main_ f_return_status fss_extended_write_main(const f_array_length argc, const f_string argv[], fss_extended_write_data *data) { - f_status status = f_none; - f_status status2 = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, fss_extended_write_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[fss_extended_write_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(status2, data->context); + f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_extended_write_total_parameters, fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark, &data->remaining, &data->context); - if (f_status_is_error(status2)) { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - fss_extended_write_delete_data(data); - return status2; - } - else { - fl_color_load_context(&data->context, data->parameters[fss_extended_write_parameter_light].result == f_console_result_found); - } + if (f_status_is_error(status)) { + fss_extended_write_delete_data(data); + return f_status_set_error(status); } + status = f_none; + if (f_status_is_error(status)) { status = f_status_set_fine(status); @@ -111,6 +102,8 @@ extern "C" { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status)); } + f_status status2 = f_none; + f_macro_string_dynamic_delete(status2, input); fss_extended_write_delete_data(data); return f_status_set_error(status); diff --git a/level_3/fss_extended_write/c/fss_extended_write.h b/level_3/fss_extended_write/c/fss_extended_write.h index a4867e8..2988f7d 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.h +++ b/level_3/fss_extended_write/c/fss_extended_write.h @@ -63,6 +63,7 @@ extern "C" { enum { fss_extended_write_parameter_help, fss_extended_write_parameter_light, + fss_extended_write_parameter_dark, fss_extended_write_parameter_no_color, fss_extended_write_parameter_version, @@ -76,6 +77,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(fss_extended_write_short_object, fss_extended_write_long_object, 0, f_false, f_console_type_normal), \ @@ -84,7 +86,7 @@ extern "C" { f_console_parameter_initialize(fss_extended_write_short_partial, fss_extended_write_long_partial, 0, f_false, f_console_type_normal), \ } - #define fss_extended_write_total_parameters 8 + #define fss_extended_write_total_parameters 9 #endif // _di_fss_extended_write_defines_ #ifndef _di_fss_extended_write_data_ diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index 273fd1e..2fc410c 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -10,6 +10,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -28,47 +29,15 @@ extern "C" { #ifndef _di_fss_status_code_main_ f_return_status fss_status_code_main(const f_array_length argc, const f_string argv[], fss_status_code_data *data) { - f_status status = f_none; - f_status allocation_status = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, fss_status_code_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[fss_status_code_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(allocation_status, data->context); - - if (f_status_is_error(allocation_status)) { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - fss_status_code_delete_data(data); - return allocation_status; - } - - fl_color_load_context(&data->context, data->parameters[fss_status_code_parameter_light].result == f_console_result_found); - } + f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_status_code_total_parameters, fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } - else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory."); - } - else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()."); - } - else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status); - } - fss_status_code_delete_data(data); return f_status_set_error(status); } + status = f_none; + // execute parameter results if (data->parameters[fss_status_code_parameter_help].result == f_console_result_found) { fss_status_code_print_help(*data); diff --git a/level_3/fss_status_code/c/fss_status_code.h b/level_3/fss_status_code/c/fss_status_code.h index 4f940f2..3388f08 100644 --- a/level_3/fss_status_code/c/fss_status_code.h +++ b/level_3/fss_status_code/c/fss_status_code.h @@ -63,6 +63,7 @@ extern "C" { enum { fss_status_code_parameter_help, fss_status_code_parameter_light, + fss_status_code_parameter_dark, fss_status_code_parameter_no_color, fss_status_code_parameter_version, @@ -76,6 +77,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(fss_status_code_short_is_fine, fss_status_code_long_is_fine, 0, f_false, f_console_type_normal), \ @@ -84,7 +86,7 @@ extern "C" { f_console_parameter_initialize(fss_status_code_short_number, fss_status_code_long_number, 0, f_false, f_console_type_normal), \ } - #define fss_status_code_total_parameters 8 + #define fss_status_code_total_parameters 9 #endif // _di_fss_status_code_defines_ #ifndef _di_fss_status_code_data_ diff --git a/level_3/init/c/init.c b/level_3/init/c/init.c index 1779e14..c9f4002 100644 --- a/level_3/init/c/init.c +++ b/level_3/init/c/init.c @@ -26,6 +26,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); fll_program_print_help_option(data.context, f_console_standard_short_debug, f_console_standard_long_debug, " Enable debugging."); @@ -44,7 +45,6 @@ extern "C" { #ifndef _di_init_main_ f_return_status init_main(const f_s_int argc, const f_string argv[], init_argument *argument) { f_status status = f_none; - f_status status2 = f_none; f_autochar run_level[init_kernel_runlevel_buffer]; memset(run_level, 0, sizeof(f_autochar) * init_kernel_runlevel_buffer); @@ -52,41 +52,15 @@ extern "C" { f_u_short do_socket_file = f_true; f_u_short do_socket_port = f_false; - status = fl_process_parameters(argc, argv, argument->parameters, init_total_parameters, &argument->remaining); - - // load colors when not told to show no colors - if (argument->parameters[init_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(status2, argument->context); - - if (status2 == f_none) { - fl_color_load_context(&argument->context, argument->parameters[init_parameter_light].result == f_console_result_found); - } else { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - init_delete_argument((*argument)); - return status2; - } - } + status = fll_program_process_parameters(argc, argv, data->parameters, init_total_parameters, init_parameter_no_color, init_parameter_light, init_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "CRITICAL ERROR: unable to allocate memory"); - } else if (f_status_set_fine(status) == f_invalid_parameter) { - fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()"); - } else { - fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status)); - } - - init_delete_argument((*argument)); + init_delete_data(data); return f_status_set_error(status); } + status = f_none; + if (argument->parameters[init_parameter_runlevel].result == f_console_result_found) { const f_u_int parameter_length = strlen(argv[argument->parameters[init_parameter_runlevel].additional.array[0]]); diff --git a/level_3/init/c/init.h b/level_3/init/c/init.h index 0c2d4fc..a1365d7 100644 --- a/level_3/init/c/init.h +++ b/level_3/init/c/init.h @@ -151,9 +151,14 @@ extern "C" { enum { init_parameter_help, init_parameter_light, + init_parameter_dark, init_parameter_no_color, init_parameter_version, - init_parameter_debug, + + #ifdef _en_init_debug_ + init_parameter_debug, + #endif // _en_init_debug_ + init_parameter_runlevel, init_parameter_no_prepare, }; @@ -163,6 +168,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, f_false, f_console_type_inverse), \ @@ -170,19 +176,20 @@ extern "C" { f_console_parameter_initialize(init_parameter_no_prepare_short_name, init_parameter_no_prepare_long_name, 0, f_true, f_console_type_normal), \ } - #define init_total_parameters 7 + #define init_total_parameters 8 #else #define f_console_parameter_initialize_init \ { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(init_parameter_runlevel_short_name, init_parameter_runlevel_long_name, 0, f_true, f_console_type_normal), \ f_console_parameter_initialize(init_parameter_no_prepare_short_name, init_parameter_no_prepare_long_name, 0, f_true, f_console_type_normal), \ } - #define init_total_parameters 6 + #define init_total_parameters 7 #endif // _en_init_debug_ #endif // _di_init_defines_ diff --git a/level_3/init/c/private-init.c b/level_3/init/c/private-init.c index 2d49edc..2a4946a 100644 --- a/level_3/init/c/private-init.c +++ b/level_3/init/c/private-init.c @@ -487,7 +487,7 @@ f_string_location location = f_string_location_initialize; f_fss_objects objects = f_fss_objects_initialize; f_fss_contents contents = f_fss_contents_initialize; - f_string_length position = f_string_length_initialize; + f_string_length position = 0; // load the main file into memory. status = init_rule_buffer(init_rule_core_file, &buffer, &objects, &contents); diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index 9a64cb5..5e8e5bb 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -10,6 +10,7 @@ extern "C" { fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message."); fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds."); + fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color."); fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number."); @@ -28,47 +29,15 @@ extern "C" { #ifndef _di_status_code_main_ f_return_status status_code_main(const f_array_length argc, const f_string argv[], status_code_data *data) { - f_status status = f_none; - f_status allocation_status = f_none; - - status = fl_process_parameters(argc, argv, data->parameters, status_code_total_parameters, &data->remaining); - - // load colors when not told to show no colors - if (data->parameters[status_code_parameter_no_color].result == f_console_result_none) { - fl_macro_color_context_new(allocation_status, data->context); - - if (f_status_is_error(allocation_status)) { - fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - status_code_delete_data(data); - return allocation_status; - } - - fl_color_load_context(&data->context, data->parameters[status_code_parameter_light].result == f_console_result_found); - } + f_status status = fll_program_process_parameters(argc, argv, data->parameters, status_code_total_parameters, status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark, &data->remaining, &data->context); if (f_status_is_error(status)) { - status = f_status_set_fine(status); - - if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); - // TODO: there is a way to identify which parameter is incorrect - // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 - // nothing can be 0 as that represents the program name, unless argv[] is improperly created - } - else if (status == f_allocation_error || status == f_reallocation_error) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory."); - } - else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()."); - } - else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status); - } - status_code_delete_data(data); return f_status_set_error(status); } + status = f_none; + // execute parameter results if (data->parameters[status_code_parameter_help].result == f_console_result_found) { status_code_print_help(*data); diff --git a/level_3/status_code/c/status_code.h b/level_3/status_code/c/status_code.h index 5524544..2e4145a 100644 --- a/level_3/status_code/c/status_code.h +++ b/level_3/status_code/c/status_code.h @@ -60,6 +60,7 @@ extern "C" { enum { status_code_parameter_help, status_code_parameter_light, + status_code_parameter_dark, status_code_parameter_no_color, status_code_parameter_version, @@ -73,6 +74,7 @@ extern "C" { { \ f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(status_code_short_is_fine, status_code_long_is_fine, 0, f_false, f_console_type_normal), \ @@ -81,7 +83,7 @@ extern "C" { f_console_parameter_initialize(status_code_short_number, status_code_long_number, 0, f_false, f_console_type_normal), \ } - #define status_code_total_parameters 8 + #define status_code_total_parameters 9 #endif // _di_status_code_defines_ #ifndef _di_status_code_data_ -- 1.8.3.1