From: Kevin Day Date: Sat, 9 May 2020 19:22:04 +0000 (-0500) Subject: Update: explode parameter priotization into left & right, add quiet and verbose optio... X-Git-Tag: 0.5.0~275 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=cba5b8ca466ea606a3c4cc16203c859c4a0a6257;p=fll Update: explode parameter priotization into left & right, add quiet and verbose options, and minor code cleanup The (right) parameter prioritization function should be expanded into a left-prioritization and a right-prioritaztion. Make +q/++quiet and +V/++verbose standard options for verbose. Add length defines for console standard defines. Make sure the status return is handled. There were a few cases where it was not being handled. Minor code structure cleanups for structural issues I happened to observe. --- diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index e9764b1..a535802 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -315,15 +315,57 @@ extern "C" { } #endif // _di_f_console_parameter_process_ -#ifndef _di_f_console_parameter_prioritize_ - f_return_status f_console_parameter_prioritize(const f_console_parameters parameters, const f_console_parameter_ids choices, f_console_parameter_id *decision) { +#ifndef _di_f_console_parameter_prioritize_left_ + f_return_status f_console_parameter_prioritize_left(const f_console_parameters parameters, const f_console_parameter_ids choices, f_console_parameter_id *decision) { #ifndef _di_level_0_parameter_checking_ if (decision == 0) return f_status_set_error(f_invalid_parameter); - if (parameters.used == 0) return f_status_set_error(f_invalid_parameter); if (choices.id == 0) return f_status_set_error(f_invalid_parameter); - if (choices.used == 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ + if (choices.used == 0) return f_no_data; + if (parameters.used == 0) return f_no_data; + + f_array_length location = 0; + f_array_length location_sub = 0; + f_console_parameter_id priority = 0; + + for (f_array_length i = 0; i < choices.used; i++) { + if (choices.id[i] > parameters.used) return f_status_set_error(f_invalid_parameter); + + if (parameters.parameter[choices.id[i]].result == f_console_result_found) { + if (parameters.parameter[choices.id[i]].location < location) { + location = parameters.parameter[choices.id[i]].location; + location_sub = parameters.parameter[choices.id[i]].location_sub; + priority = choices.id[i]; + } + else if (parameters.parameter[choices.id[i]].location == location && parameters.parameter[choices.id[i]].location_sub < location_sub) { + location_sub = parameters.parameter[choices.id[i]].location_sub; + priority = choices.id[i]; + } + } + } // for + + // The first parameter location (argc = 0) is the program name, therefore if the location is 0, then no matches were found. + if (location == 0) { + return f_no_data; + } + + *decision = priority; + + return f_none; + } +#endif // _di_f_console_parameter_prioritize_left_ + +#ifndef _di_f_console_parameter_prioritize_right_ + f_return_status f_console_parameter_prioritize_right(const f_console_parameters parameters, const f_console_parameter_ids choices, f_console_parameter_id *decision) { + #ifndef _di_level_0_parameter_checking_ + if (decision == 0) return f_status_set_error(f_invalid_parameter); + if (choices.id == 0) return f_status_set_error(f_invalid_parameter); + #endif // _di_level_0_parameter_checking_ + + if (choices.used == 0) return f_no_data; + if (parameters.used == 0) return f_no_data; + f_array_length location = 0; f_array_length location_sub = 0; f_console_parameter_id priority = 0; @@ -353,7 +395,7 @@ extern "C" { return f_none; } -#endif // _di_f_console_parameter_prioritize_ +#endif // _di_f_console_parameter_prioritize_right_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_console/c/console.h b/level_0/f_console/c/console.h index 7f60c71..0b6316e 100644 --- a/level_0/f_console/c/console.h +++ b/level_0/f_console/c/console.h @@ -67,7 +67,25 @@ extern "C" { #endif // _di_f_console_symbols_ /** - * Create some standard command line parameter options required by the kevux/fss/fll specifications. + * Create some standard command line parameter options required/expected by the kevux/fss/fll specifications. + * + * It is expected that all of the "+" and "++" console options described below are reserved for these purposes. + * This is not a strict requirement as such a thing is non-sense in open-source, but this should be considered a strong recommendation. + * + * It is acceptable for any of these options, when specified multiple times, for that number of times to represent the "level". + * For example, a "+D +D" means more debug output than simply "+D". + * + * The following options are subjective in interpretation but are expected to follow the general interpretation: + * - debug: Enable debugging, which will likely increase output verbosity. + * - quiet: Decrease verbosity, print less, in some use cases this could mean printing nothing. + * - verbose: Increase verbosity, print more, in some use cases this could mean printing just about everything. + * + * The following are less subjective in interpretation but do allow some flexibility. + * - dark: Do display color intended for dark backgrounds (often the default behavior) when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) + * - help: Display the help text. This does not define how the text is displayed only that the text is displayed. + * - light: Do display color intended for light backgrounds when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) + * - no_color: Do not display color when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.) + * - version: Should always print only the version number, no colors, but what represents the version number is undefined by this project. */ #ifndef _di_f_standard_console_parameters_ #define f_console_standard_short_dark "d" @@ -75,14 +93,36 @@ extern "C" { #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_quiet "q" + #define f_console_standard_short_verbose "V" #define f_console_standard_short_version "v" + #define f_console_standard_short_dark_length 1 + #define f_console_standard_short_debug_length 1 + #define f_console_standard_short_help_length 1 + #define f_console_standard_short_light_length 1 + #define f_console_standard_short_no_color_length 1 + #define f_console_standard_short_quiet_length 1 + #define f_console_standard_short_verbose_length 1 + #define f_console_standard_short_version_length 1 + #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" #define f_console_standard_long_no_color "no_color" + #define f_console_standard_long_quiet "quiet" + #define f_console_standard_long_verbose "verbose" #define f_console_standard_long_version "version" + + #define f_console_standard_long_dark_length 4 + #define f_console_standard_long_debug_length 5 + #define f_console_standard_long_help_length 4 + #define f_console_standard_long_light_length 5 + #define f_console_standard_long_no_color_length 8 + #define f_console_standard_long_quiet_length 5 + #define f_console_standard_long_verbose_length 7 + #define f_console_standard_long_version_length 7 #endif // _di_f_standard_console_parameters_ /** @@ -290,6 +330,36 @@ extern "C" { * Given a set of parameter choices, determine which one has the highest priority. * * The priority is determined by viewing the parameters from left to right. + * The left-most parameter defined in the set has the priority over others. + * + * For example, the color context modes override each other, so only one gets priority. + * If given, say "+l ++no_color +d", the "+d" would be the left-most parameter "+l" and "++no_color". + * The decision would be "+d". + * + * This also applies to short parameters combined into one, such as "+lnd", the "d" would again be the decision. + * + * @param parameters + * The parameters to process. + * @param choices + * An array of numeric ids, each representing a parameter within the parameters variable. + * The order does not matter. + * @param decision + * The resulting decision. + * If none of the parameters are found, then this will not be updated (therefore it is safe to have it pre-initialized to the default). + * + * @return + * f_none on success. + * f_no_data if no parameters were found. + * f_invalid_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_console_parameter_prioritize_left_ + extern f_return_status f_console_parameter_prioritize_left(const f_console_parameters parameters, const f_console_parameter_ids choices, f_console_parameter_id *decision); +#endif // _di_f_console_parameter_prioritize_left_ + +/** + * Given a set of parameter choices, determine which one has the highest priority. + * + * The priority is determined by viewing the parameters from left to right. * The right-most parameter defined in the set has the priority over others. * * For example, the color context modes override each other, so only one gets priority. @@ -312,9 +382,9 @@ extern "C" { * f_no_data if no parameters were found. * f_invalid_parameter (with error bit) if a parameter is invalid. */ -#ifndef _di_f_console_parameter_prioritize_ - extern f_return_status f_console_parameter_prioritize(const f_console_parameters parameters, const f_console_parameter_ids choices, f_console_parameter_id *decision); -#endif // _di_f_console_parameter_prioritize_ +#ifndef _di_f_console_parameter_prioritize_right_ + extern f_return_status f_console_parameter_prioritize_right(const f_console_parameters parameters, const f_console_parameter_ids choices, f_console_parameter_id *decision); +#endif // _di_f_console_parameter_prioritize_right_ #ifdef __cplusplus } // extern "C" diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index d3b9410..34a5e49 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -90,40 +90,24 @@ extern "C" { #endif // _di_fll_program_print_version_ #ifndef _di_fll_program_parameter_process_ - f_return_status fll_program_parameter_process(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, f_string_lengths *remaining, fl_color_context *context) { + f_return_status fll_program_parameter_process(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, const bool right, f_string_lengths *remaining, fl_color_context *context) { f_status status = f_none; status = f_console_parameter_process(arguments, parameters, remaining); - f_console_parameter_id decision = choices.id[2]; - - f_console_parameter_prioritize(parameters, choices, &decision); - - // load colors unless told not to. - if (decision != choices.id[0]) { - f_status allocation_status = f_none; - - fl_macro_color_context_new(allocation_status, (*context)); - - if (f_status_is_error(allocation_status)) { - fprintf(f_standard_error, "CRITICAL ERROR: Unable to allocate memory.\n"); - return allocation_status; - } - - fl_color_load_context(context, decision == choices.id[1]); - } - if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_no_data) { fl_color_print_line(f_standard_error, context->error, 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 + // @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_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print(f_standard_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); + fl_color_print(f_standard_error, context->notable, context->reset, "f_console_parameter_process"); + fl_color_print_line(f_standard_error, context->error, context->reset, ")."); } else if (status == f_invalid_utf) { fl_color_print(f_standard_error, context->error, context->reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling "); @@ -146,10 +130,98 @@ extern "C" { return f_status_set_error(status); } + f_console_parameter_id decision = choices.id[2]; + + f_string function; + + if (right) { + function = "f_console_parameter_prioritize_right"; + status = f_console_parameter_prioritize_right(parameters, choices, &decision); + } + else { + function = "f_console_parameter_prioritize_left"; + status = f_console_parameter_prioritize_left(parameters, choices, &decision); + } + + if (f_status_is_error(status)) { + status = f_status_set_fine(status); + + if (status == f_error_allocation || status == f_error_reallocation) { + fl_color_print(f_standard_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); + fl_color_print(f_standard_error, context->notable, context->reset, "%s", function); + fl_color_print_line(f_standard_error, context->error, context->reset, ")."); + } + else if (status == f_invalid_parameter) { + fl_color_print(f_standard_error, context->error, context->reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_standard_error, context->notable, context->reset, "%s", function); + fl_color_print_line(f_standard_error, context->error, context->reset, "()."); + } + else { + fl_color_print(f_standard_error, context->error, context->reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_standard_error, context->notable, context->reset, "%u", status); + fl_color_print(f_standard_error, context->error, context->reset, ") has occurred while calling "); + fl_color_print(f_standard_error, context->notable, context->reset, "%s", function); + fl_color_print_line(f_standard_error, context->error, context->reset, "()."); + } + + return f_status_set_error(status); + } + + // load colors unless told not to. + if (decision != choices.id[0]) { + f_status allocation_status = f_none; + + fl_macro_color_context_new(allocation_status, (*context)); + + if (f_status_is_error(allocation_status)) { + fl_color_print(f_standard_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); + fl_color_print(f_standard_error, context->notable, context->reset, "fl_macro_color_context_new"); + fl_color_print_line(f_standard_error, context->error, context->reset, "()."); + + return allocation_status; + } + + status = fl_color_load_context(context, decision == choices.id[1]); + } + return status; } #endif // _di_fll_program_parameter_process_ +#ifndef _di_fll_program_parameter_process_quietly_ + f_return_status fll_program_parameter_process_quietly(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, const bool right, f_string_lengths *remaining, fl_color_context *context) { + f_status status = f_none; + + status = f_console_parameter_process(arguments, parameters, remaining); + + if (f_status_is_error(status)) return status; + + f_console_parameter_id decision = choices.id[2]; + + if (right) { + status = f_console_parameter_prioritize_right(parameters, choices, &decision); + } + else { + status = f_console_parameter_prioritize_left(parameters, choices, &decision); + } + + if (f_status_is_error(status)) return status; + + // load colors unless told not to. + if (decision != choices.id[0]) { + f_status allocation_status = f_none; + + fl_macro_color_context_new(allocation_status, (*context)); + + if (f_status_is_error(allocation_status)) return allocation_status; + + status = fl_color_load_context(context, decision == choices.id[1]); + } + + return status; + } +#endif // _di_fll_program_parameter_process_quietly_ + #ifndef _di_fll_program_parameter_additional_append_ f_return_status fll_program_parameter_additional_append(const f_string *argv, const f_string_lengths additional, f_string_dynamics *destination) { #ifndef _di_level_2_parameter_checking_ diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index 26dd647..5494f44 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -144,6 +144,8 @@ extern "C" { * @param choices * A set of the color options: no-color option, light-color option, dark-color option. * This must have its used size set to 3 and the ids are expected to be in this order: no_color, light, and dark. + * @param right + * Set to TRUE for right priortization and FALSE for left prioritization. * @param remaining * A list of remaining parameters not associated with anything. * @param context @@ -156,8 +158,34 @@ extern "C" { * f_error_reallocation (with error bit) on memory reallocation error. */ #ifndef _di_fll_program_parameter_process_ - extern f_return_status fll_program_parameter_process(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, f_string_lengths *remaining, fl_color_context *context); + extern f_return_status fll_program_parameter_process(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, const bool right, f_string_lengths *remaining, fl_color_context *context); #endif // _di_fll_program_parameter_process_ +/** + * Perform basic parameter loading, including initialization of color context but does not print errors. + * + * @param arguments + * The parameters passed to the process. + * @param parameters + * The console parameters to look for. + * @param choices + * A set of the color options: no-color option, light-color option, dark-color option. + * This must have its used size set to 3 and the ids are expected to be in this order: no_color, light, and dark. + * @param right + * Set to TRUE for right priortization and FALSE for left prioritization. + * @param remaining + * A list of remaining parameters not associated with anything. + * @param context + * The color context. + * + * @return + * f_none on success. + * f_no_data if "additional" parameters were expected but not found. + * f_invalid_parameter (with error bit) if a parameter is invalid. + * f_error_reallocation (with error bit) on memory reallocation error. + */ +#ifndef _di_fll_program_parameter_process_quietly_ + extern f_return_status fll_program_parameter_process_quietly(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, const bool right, f_string_lengths *remaining, fl_color_context *context); +#endif // _di_fll_program_parameter_process_quietly_ /** * Allocate new strings from all of the provided locations. diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index c6aa474..c008f3d 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -82,12 +82,14 @@ extern "C" { choices.id = ids; choices.used = 3; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); if (f_status_is_error(status)) { byte_dump_delete_data(data); return f_status_set_error(status); } + + status = f_none; } // Identify priority of mode parameters. @@ -97,7 +99,7 @@ extern "C" { choices.id = ids; choices.used = 5; - status = f_console_parameter_prioritize(parameters, choices, &choice); + status = f_console_parameter_prioritize_right(parameters, choices, &choice); if (f_status_is_error(status)) { byte_dump_delete_data(data); @@ -128,7 +130,7 @@ extern "C" { choices.id = ids; choices.used = 3; - status = f_console_parameter_prioritize(parameters, choices, &choice); + status = f_console_parameter_prioritize_right(parameters, choices, &choice); if (f_status_is_error(status)) { byte_dump_delete_data(data); diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 981f78e..d5fd1af 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -17,6 +17,8 @@ extern "C" { fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds."); fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds."); fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color."); + fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output."); + fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output."); fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number."); printf("%c", f_string_eol); @@ -93,12 +95,14 @@ extern "C" { choices.id = ids; choices.used = 3; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); if (f_status_is_error(status)) { fake_delete_data(data); return f_status_set_error(status); } + + status = f_none; } // Determine order of operations. diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index cd69025..0732e7d 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -337,7 +337,10 @@ extern "C" { fake_parameter_help, fake_parameter_light, fake_parameter_dark, + fake_parameter_debug, fake_parameter_no_color, + fake_parameter_quiet, + fake_parameter_verbose, fake_parameter_version, fake_parameter_defines, @@ -374,7 +377,10 @@ extern "C" { f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_console_type_normal), \ f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, 0, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \ + f_console_parameter_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_initialize(fake_short_defines, fake_long_defines, 0, 1, f_console_type_normal), \ f_console_parameter_initialize(fake_short_mode, fake_long_mode, 0, 1, f_console_type_normal), \ @@ -401,7 +407,7 @@ extern "C" { f_console_parameter_initialize(0, 0, fake_other_operation_skeleton, 0, f_console_type_other), \ } - #define fake_total_parameters 28 + #define fake_total_parameters 31 #endif // _di_fake_defines_ #ifndef _di_fake_data_ diff --git a/level_3/fake/data/build/settings b/level_3/fake/data/build/settings index 83922a0..55bef6b 100644 --- a/level_3/fake/data/build/settings +++ b/level_3/fake/data/build/settings @@ -1,4 +1,4 @@ -# fss-0000 +# fss-0001 project_name fake project_level 3 diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index ccd9858..d5e3285 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -63,15 +63,15 @@ extern "C" { f_console_parameter_id ids[3] = { firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); - } + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); - if (f_status_is_error(status)) { - firewall_delete_data(data); - return f_status_set_error(status); - } + if (f_status_is_error(status)) { + firewall_delete_data(data); + return f_status_set_error(status); + } - status = f_none; + status = f_none; + } if (data->parameters[firewall_parameter_help].result == f_console_result_found) { firewall_print_help(data->context); 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 c1c7ebe..8da900b 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 @@ -130,7 +130,7 @@ extern "C" { f_console_parameter_id ids[3] = { fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); if (f_status_is_error(status)) { fss_basic_list_read_delete_data(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 57e5dd3..d4470e9 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 @@ -35,15 +35,15 @@ extern "C" { f_console_parameter_id ids[3] = { fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); - } + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); - if (f_status_is_error(status)) { - fss_basic_list_write_delete_data(data); - return f_status_set_error(status); - } + if (f_status_is_error(status)) { + fss_basic_list_write_delete_data(data); + return f_status_set_error(status); + } - status = f_none; + status = f_none; + } if (data->parameters[fss_basic_list_write_parameter_help].result == f_console_result_found) { fss_basic_list_write_print_help(data->context); 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 dfff8b6..55f527f 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -130,7 +130,7 @@ extern "C" { f_console_parameter_id ids[3] = { fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); if (f_status_is_error(status)) { fss_basic_read_delete_data(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 9d93e92..e3e85d1 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -35,15 +35,15 @@ extern "C" { f_console_parameter_id ids[3] = { fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); - } + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); - if (f_status_is_error(status)) { - fss_basic_write_delete_data(data); - return f_status_set_error(status); - } + if (f_status_is_error(status)) { + fss_basic_write_delete_data(data); + return f_status_set_error(status); + } - status = f_none; + status = f_none; + } if (data->parameters[fss_basic_write_parameter_help].result == f_console_result_found) { fss_basic_write_print_help(data->context); diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index c54a1ab..547e203 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -130,7 +130,7 @@ extern "C" { f_console_parameter_id ids[3] = { fss_extended_list_read_parameter_no_color, fss_extended_list_read_parameter_light, fss_extended_list_read_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); if (f_status_is_error(status)) { fss_extended_list_read_delete_data(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 18abb1e..8153fb9 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -130,7 +130,7 @@ extern "C" { f_console_parameter_id ids[3] = { fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); if (f_status_is_error(status)) { fss_extended_read_delete_data(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 2552c29..2dadede 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -36,15 +36,15 @@ extern "C" { f_console_parameter_id ids[3] = { fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); - } + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); - if (f_status_is_error(status)) { - fss_extended_write_delete_data(data); - return f_status_set_error(status); - } + if (f_status_is_error(status)) { + fss_extended_write_delete_data(data); + return f_status_set_error(status); + } - status = f_none; + status = f_none; + } if (f_status_is_error(status)) { status = f_status_set_fine(status); 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 02131b2..66b34c1 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -37,16 +37,15 @@ extern "C" { f_console_parameter_id ids[3] = { fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); - } + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); - if (f_status_is_error(status)) { - fss_status_code_delete_data(data); - return f_status_set_error(status); - } + if (f_status_is_error(status)) { + fss_status_code_delete_data(data); + return f_status_set_error(status); + } - f_status status2 = f_none; - status = f_none; + status = f_none; + } if (data->parameters[fss_status_code_parameter_help].result == f_console_result_found) { fss_status_code_print_help(data->context); @@ -99,6 +98,8 @@ extern "C" { return f_status_set_error(f_invalid_parameter); } + f_status status2 = f_none; + if (data->parameters[fss_status_code_parameter_is_error].result == f_console_result_found || data->parameters[fss_status_code_parameter_is_warning].result == f_console_result_found || data->parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { if (data->process_pipe) { // @todo: call fss_status_code_process_check() here for all data from pipe that is space separated. diff --git a/level_3/init/c/init.c b/level_3/init/c/init.c index 04d87c1..e4fa957 100644 --- a/level_3/init/c/init.c +++ b/level_3/init/c/init.c @@ -57,16 +57,15 @@ extern "C" { f_console_parameter_id ids[3] = { init_parameter_no_color, init_parameter_light, init_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); - } - - if (f_status_is_error(status)) { - // @todo: init_delete_data(data); - return f_status_set_error(status); - } + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); - status = f_none; + if (f_status_is_error(status)) { + // @todo: init_delete_data(data); + return f_status_set_error(status); + } + status = f_none; + } if (data->parameters[init_parameter_runlevel].result == f_console_result_found) { const unsigned int parameter_length = strlen(arguments.argv[data->parameters[init_parameter_runlevel].additional.array[0]]); diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index b6a2910..d7a92d5 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -37,16 +37,15 @@ extern "C" { f_console_parameter_id ids[3] = { status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark }; f_console_parameter_ids choices = { ids, 3 }; - status = fll_program_parameter_process(arguments, parameters, choices, &data->remaining, &data->context); - } + status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); - if (f_status_is_error(status)) { - status_code_delete_data(data); - return f_status_set_error(status); - } + if (f_status_is_error(status)) { + status_code_delete_data(data); + return f_status_set_error(status); + } - f_status status2 = f_none; - status = f_none; + status = f_none; + } if (data->parameters[status_code_parameter_help].result == f_console_result_found) { status_code_print_help(data->context); @@ -99,6 +98,8 @@ extern "C" { return f_status_set_error(f_invalid_parameter); } + f_status status2 = f_none; + if (data->parameters[status_code_parameter_is_error].result == f_console_result_found || data->parameters[status_code_parameter_is_warning].result == f_console_result_found || data->parameters[status_code_parameter_is_fine].result == f_console_result_found) { if (data->process_pipe) { // @todo: call status_code_process_check() here for all data from pipe that is space separated.