From 70ddbe2583466195ce15f2953f6f1bb48c38c7a7 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 12 Mar 2012 22:03:13 -0500 Subject: [PATCH] Update: rename *error_code projects to *return_code This should make the applications make a little more sense. That is, when testing for not-error codes, it makes more sense to say not-error return codes than to say not-error error codes. --- level_3/error_code/c/error_code.h | 122 -------------------- level_3/fss_error_code/c/fss_error_code.h | 123 --------------------- level_3/fss_error_code/c/main.c | 13 --- .../c/fss_return_code.c} | 84 +++++++------- level_3/fss_return_code/c/fss_return_code.h | 123 +++++++++++++++++++++ level_3/fss_return_code/c/main.c | 13 +++ .../data/build/settings | 8 +- level_3/{error_code => return_code}/c/main.c | 6 +- .../c/error_code.c => return_code/c/return_code.c} | 84 +++++++------- level_3/return_code/c/return_code.h | 122 ++++++++++++++++++++ .../data/build/settings | 8 +- 11 files changed, 353 insertions(+), 353 deletions(-) delete mode 100644 level_3/error_code/c/error_code.h delete mode 100644 level_3/fss_error_code/c/fss_error_code.h delete mode 100644 level_3/fss_error_code/c/main.c rename level_3/{fss_error_code/c/fss_error_code.c => fss_return_code/c/fss_return_code.c} (75%) create mode 100644 level_3/fss_return_code/c/fss_return_code.h create mode 100644 level_3/fss_return_code/c/main.c rename level_3/{fss_error_code => fss_return_code}/data/build/settings (70%) rename level_3/{error_code => return_code}/c/main.c (50%) rename level_3/{error_code/c/error_code.c => return_code/c/return_code.c} (77%) create mode 100644 level_3/return_code/c/return_code.h rename level_3/{error_code => return_code}/data/build/settings (71%) diff --git a/level_3/error_code/c/error_code.h b/level_3/error_code/c/error_code.h deleted file mode 100644 index 09f979f..0000000 --- a/level_3/error_code/c/error_code.h +++ /dev/null @@ -1,122 +0,0 @@ -/* FLL - Level 3 - * Project: FSS - * Version: 0.3.x - * Licenses: lgplv2.1 - * Programmers: Kevin Day - * Documentation: - * - * This program provides error code to string translation. - */ -#ifndef _error_code_h - -// libc includes -#include -#include -#include - -// fll-0 includes -#include -#include -#include -#include -#include - -// fll-1 includes -#include -#include -#include -#include - -// fll-2 includes -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -#ifndef _di_error_code_version_ - #define error_code_major_version "0" - #define error_code_minor_version "3" - #define error_code_micro_version "0" - #define error_code_version error_code_major_version "." error_code_minor_version "." error_code_micro_version -#endif // _di_error_code_version_ - -#ifndef _di_error_code_name_ - #define error_code_name "error_code" - #define error_code_name_long "Error Code" -#endif // _di_error_code_name_ - -#ifndef _di_error_code_defines_ - #define error_code_short_is_okay "o" - #define error_code_short_is_warning "w" - #define error_code_short_is_error "e" - - #define error_code_long_is_okay "is_okay" - #define error_code_long_is_warning "is_warning" - #define error_code_long_is_error "is_error" - - enum { - error_code_parameter_help, - error_code_parameter_light, - error_code_parameter_no_color, - error_code_parameter_version, - - error_code_parameter_is_okay, - error_code_parameter_is_warning, - error_code_parameter_is_error, - }; - - #define f_console_parameter_initialize_error_code \ - { \ - f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_false, f_console_type_normal, 0), \ - f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \ - f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \ - f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \ - f_console_parameter_initialize(error_code_short_is_okay, error_code_long_is_okay, 0, 0, f_false, f_console_type_normal, 0), \ - f_console_parameter_initialize(error_code_short_is_warning, error_code_long_is_warning, 0, 0, f_false, f_console_type_normal, 0), \ - f_console_parameter_initialize(error_code_short_is_error, error_code_long_is_error, 0, 0, f_false, f_console_type_normal, 0), \ - } - - #define error_code_total_parameters 7 -#endif // _di_error_code_defines_ - -#ifndef _di_error_code_data_ - typedef struct { - f_console_parameter parameters[error_code_total_parameters]; - - f_string_lengths remaining; - f_bool process_pipe; - - fll_color_context context; - } error_code_data; - - #define error_code_data_initialize \ - { \ - f_console_parameter_initialize_error_code, \ - f_string_lengths_initialize, \ - f_false, \ - fll_color_context_initialize, \ - } -#endif // _di_error_code_data_ - -#ifndef _di_error_code_print_version_ - extern f_return_status error_code_print_version(const error_code_data data); -#endif // _di_error_code_print_version_ - -#ifndef _di_error_code_print_help_ - extern f_return_status error_code_print_help(const error_code_data data); -#endif // _di_error_code_print_help_ - -#ifndef _di_error_code_main_ - extern f_return_status error_code_main(const f_array_length argc, const f_string argv[], error_code_data *data); -#endif // _di_error_code_main_ - -#ifndef _di_error_code_delete_data_ - extern f_return_status error_code_delete_data(error_code_data *data); -#endif // _di_error_code_delete_data_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _error_code_h diff --git a/level_3/fss_error_code/c/fss_error_code.h b/level_3/fss_error_code/c/fss_error_code.h deleted file mode 100644 index 8d73dff..0000000 --- a/level_3/fss_error_code/c/fss_error_code.h +++ /dev/null @@ -1,123 +0,0 @@ -/* FLL - Level 3 - * Project: FSS - * Version: 0.3.x - * Licenses: lgplv2.1 - * Programmers: Kevin Day - * Documentation: - * - * This program provides error code to string translation. - */ -#ifndef _fss_error_code_h - -// libc includes -#include -#include -#include - -// fll-0 includes -#include -#include -#include -#include -#include - -// fll-1 includes -#include -#include -#include -#include - -// fll-2 includes -#include -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -#ifndef _di_fss_error_code_version_ - #define fss_error_code_major_version "0" - #define fss_error_code_minor_version "3" - #define fss_error_code_micro_version "0" - #define fss_error_code_version fss_error_code_major_version "." fss_error_code_minor_version "." fss_error_code_micro_version -#endif // _di_fss_error_code_version_ - -#ifndef _di_fss_error_code_name_ - #define fss_error_code_name "fss_error_code" - #define fss_error_code_name_long "FSS Error Code" -#endif // _di_fss_error_code_name_ - -#ifndef _di_fss_error_code_defines_ - #define fss_error_code_short_is_okay "o" - #define fss_error_code_short_is_warning "w" - #define fss_error_code_short_is_error "e" - - #define fss_error_code_long_is_okay "is_okay" - #define fss_error_code_long_is_warning "is_warning" - #define fss_error_code_long_is_error "is_error" - - enum { - fss_error_code_parameter_help, - fss_error_code_parameter_light, - fss_error_code_parameter_no_color, - fss_error_code_parameter_version, - - fss_error_code_parameter_is_okay, - fss_error_code_parameter_is_warning, - fss_error_code_parameter_is_error, - }; - - #define f_console_parameter_initialize_fss_error_code \ - { \ - f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_false, f_console_type_normal, 0), \ - f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \ - f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \ - f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \ - f_console_parameter_initialize(fss_error_code_short_is_okay, fss_error_code_long_is_okay, 0, 0, f_false, f_console_type_normal, 0), \ - f_console_parameter_initialize(fss_error_code_short_is_warning, fss_error_code_long_is_warning, 0, 0, f_false, f_console_type_normal, 0), \ - f_console_parameter_initialize(fss_error_code_short_is_error, fss_error_code_long_is_error, 0, 0, f_false, f_console_type_normal, 0), \ - } - - #define fss_error_code_total_parameters 7 -#endif // _di_fss_error_code_defines_ - -#ifndef _di_fss_error_code_data_ - typedef struct { - f_console_parameter parameters[fss_error_code_total_parameters]; - - f_string_lengths remaining; - f_bool process_pipe; - - fll_color_context context; - } fss_error_code_data; - - #define fss_error_code_data_initialize \ - { \ - f_console_parameter_initialize_fss_error_code, \ - f_string_lengths_initialize, \ - f_false, \ - fll_color_context_initialize, \ - } -#endif // _di_fss_error_code_data_ - -#ifndef _di_fss_error_code_print_version_ - extern f_return_status fss_error_code_print_version(const fss_error_code_data data); -#endif // _di_fss_error_code_print_version_ - -#ifndef _di_fss_error_code_print_help_ - extern f_return_status fss_error_code_print_help(const fss_error_code_data data); -#endif // _di_fss_error_code_print_help_ - -#ifndef _di_fss_error_code_main_ - extern f_return_status fss_error_code_main(const f_array_length argc, const f_string argv[], fss_error_code_data *data); -#endif // _di_fss_error_code_main_ - -#ifndef _di_fss_error_code_delete_data_ - extern f_return_status fss_error_code_delete_data(fss_error_code_data *data); -#endif // _di_fss_error_code_delete_data_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _fss_error_code_h diff --git a/level_3/fss_error_code/c/main.c b/level_3/fss_error_code/c/main.c deleted file mode 100644 index fdd3ada..0000000 --- a/level_3/fss_error_code/c/main.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -int main(const f_array_length argc, const f_string argv[]){ - fss_error_code_data data = fss_error_code_data_initialize; - - /* - if (f_pipe_exists()){ - data.process_pipe = f_true; - } - */ - - return fss_error_code_main(argc, argv, &data); -} diff --git a/level_3/fss_error_code/c/fss_error_code.c b/level_3/fss_return_code/c/fss_return_code.c similarity index 75% rename from level_3/fss_error_code/c/fss_error_code.c rename to level_3/fss_return_code/c/fss_return_code.c index 4c3bb9a..0195707 100644 --- a/level_3/fss_error_code/c/fss_error_code.c +++ b/level_3/fss_return_code/c/fss_return_code.c @@ -4,28 +4,28 @@ * Licenses: lgplv2.1 * Programmers: Kevin Day */ -#include +#include #ifdef __cplusplus extern "C"{ #endif // version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors -#ifndef _di_fss_error_code_print_version_ - f_return_status fss_error_code_print_version(const fss_error_code_data data){ - printf("%s\n", fss_error_code_version); +#ifndef _di_fss_return_code_print_version_ + f_return_status fss_return_code_print_version(const fss_return_code_data data){ + printf("%s\n", fss_return_code_version); return f_none; } -#endif // _fss_error_code_print_version_ +#endif // _fss_return_code_print_version_ -#ifndef _di_fss_error_code_print_help_ - f_return_status fss_error_code_print_help(const fss_error_code_data data){ +#ifndef _di_fss_return_code_print_help_ + f_return_status fss_return_code_print_help(const fss_return_code_data data){ printf("\n"); - fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_error_code_name_long); + fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_return_code_name_long); printf("\n"); - fl_print_color(f_standard_output, data.context.notable, data.context.reset, " Version %s", fss_error_code_version); + fl_print_color(f_standard_output, data.context.notable, data.context.reset, " Version %s", fss_return_code_version); printf("\n\n"); @@ -62,24 +62,24 @@ extern "C"{ printf("\n"); printf("\n %s", f_console_symbol_short_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_error_code_short_is_okay); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_short_is_okay); printf(", %s", f_console_symbol_long_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_error_code_long_is_okay); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_long_is_okay); printf(" Returns true if the error code is not an error."); printf("\n %s", f_console_symbol_short_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_error_code_short_is_warning); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_short_is_warning); printf(", %s", f_console_symbol_long_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_error_code_long_is_warning); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_long_is_warning); printf(" Returns true if the error code is a warning."); printf("\n %s", f_console_symbol_short_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_error_code_short_is_error); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_short_is_error); printf(", %s", f_console_symbol_long_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_error_code_long_is_error); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_long_is_error); printf(" Returns true if the error code is an error."); @@ -87,7 +87,7 @@ extern "C"{ fl_print_color(f_standard_output, data.context.important, data.context.reset, " Usage: "); printf("\n "); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_error_code_name); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_name); printf(" "); fl_print_color(f_standard_output, data.context.notable, data.context.reset, "["); @@ -106,24 +106,24 @@ extern "C"{ return f_none; } -#endif // _di_fss_error_code_print_help_ +#endif // _di_fss_return_code_print_help_ -#ifndef _di_fss_error_code_main_ - f_return_status fss_error_code_main(const f_array_length argc, const f_string argv[], fss_error_code_data *data){ +#ifndef _di_fss_return_code_main_ + f_return_status fss_return_code_main(const f_array_length argc, const f_string argv[], fss_return_code_data *data){ f_status status = f_status_initialize; f_status allocation_status = f_status_initialize; - status = fl_process_parameters(argc, argv, data->parameters, fss_error_code_total_parameters, &data->remaining); + status = fl_process_parameters(argc, argv, data->parameters, fss_return_code_total_parameters, &data->remaining); // load colors when not told to show no colors - if (data->parameters[fss_error_code_parameter_no_color].result == f_console_result_none){ + if (data->parameters[fss_return_code_parameter_no_color].result == f_console_result_none){ fll_new_color_context(allocation_status, data->context); if (allocation_status == f_none){ - fll_colors_load_context(&data->context, data->parameters[fss_error_code_parameter_light].result == f_console_result_found); + fll_colors_load_context(&data->context, data->parameters[fss_return_code_parameter_light].result == f_console_result_found); } else { fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - fss_error_code_delete_data(data); + fss_return_code_delete_data(data); return allocation_status; } } @@ -142,16 +142,16 @@ extern "C"{ fl_print_color_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_error_code_delete_data(data); + fss_return_code_delete_data(data); return status; } // execute parameter results - if (data->parameters[fss_error_code_parameter_help].result == f_console_result_found){ - fss_error_code_print_help(*data); - } else if (data->parameters[fss_error_code_parameter_version].result == f_console_result_found){ - fss_error_code_print_version(*data); - } else if (data->parameters[fss_error_code_parameter_is_error].result == f_console_result_found && data->remaining.used > 0){ + if (data->parameters[fss_return_code_parameter_help].result == f_console_result_found){ + fss_return_code_print_help(*data); + } else if (data->parameters[fss_return_code_parameter_version].result == f_console_result_found){ + fss_return_code_print_version(*data); + } else if (data->parameters[fss_return_code_parameter_is_error].result == f_console_result_found && data->remaining.used > 0){ f_array_length counter = f_array_length_initialize; f_status code = f_status_initialize; @@ -162,14 +162,14 @@ extern "C"{ code = (f_status) atoll(argv[data->remaining.array[counter]]); if (fll_fss_errors_is_error(code)){ - fss_error_code_delete_data(data); + fss_return_code_delete_data(data); return f_true; } } - fss_error_code_delete_data(data); + fss_return_code_delete_data(data); return f_false; - } else if (data->parameters[fss_error_code_parameter_is_warning].result == f_console_result_found && data->remaining.used > 0){ + } else if (data->parameters[fss_return_code_parameter_is_warning].result == f_console_result_found && data->remaining.used > 0){ f_array_length counter = f_array_length_initialize; f_status code = f_status_initialize; @@ -180,14 +180,14 @@ extern "C"{ code = (f_status) atoll(argv[data->remaining.array[counter]]); if (fll_fss_errors_is_warning(code)){ - fss_error_code_delete_data(data); + fss_return_code_delete_data(data); return f_true; } } - fss_error_code_delete_data(data); + fss_return_code_delete_data(data); return f_false; - } else if (data->parameters[fss_error_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0){ + } else if (data->parameters[fss_return_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0){ f_array_length counter = f_array_length_initialize; f_status code = f_status_initialize; @@ -198,12 +198,12 @@ extern "C"{ code = (f_status) atoll(argv[data->remaining.array[counter]]); if (fll_fss_errors_is_okay(code)){ - fss_error_code_delete_data(data); + fss_return_code_delete_data(data); return f_true; } } - fss_error_code_delete_data(data); + fss_return_code_delete_data(data); return f_false; } else if (data->remaining.used > 0 || data->process_pipe){ f_array_length counter = f_array_length_initialize; @@ -227,13 +227,13 @@ extern "C"{ status = f_invalid_parameter; } - fss_error_code_delete_data(data); + fss_return_code_delete_data(data); return status; } -#endif // _di_fss_error_code_main_ +#endif // _di_fss_return_code_main_ -#ifndef _di_fss_error_code_delete_data_ - f_return_status fss_error_code_delete_data(fss_error_code_data *data){ +#ifndef _di_fss_return_code_delete_data_ + f_return_status fss_return_code_delete_data(fss_return_code_data *data){ f_status status = f_status_initialize; f_delete_string_lengths(status, data->remaining); @@ -241,7 +241,7 @@ extern "C"{ return f_none; } -#endif // _di_fss_error_code_delete_data_ +#endif // _di_fss_return_code_delete_data_ #ifdef __cplusplus diff --git a/level_3/fss_return_code/c/fss_return_code.h b/level_3/fss_return_code/c/fss_return_code.h new file mode 100644 index 0000000..4a3341d --- /dev/null +++ b/level_3/fss_return_code/c/fss_return_code.h @@ -0,0 +1,123 @@ +/* FLL - Level 3 + * Project: FSS + * Version: 0.3.x + * Licenses: lgplv2.1 + * Programmers: Kevin Day + * Documentation: + * + * This program provides error code to string translation. + */ +#ifndef _fss_return_code_h + +// libc includes +#include +#include +#include + +// fll-0 includes +#include +#include +#include +#include +#include + +// fll-1 includes +#include +#include +#include +#include + +// fll-2 includes +#include +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +#ifndef _di_fss_return_code_version_ + #define fss_return_code_major_version "0" + #define fss_return_code_minor_version "3" + #define fss_return_code_micro_version "0" + #define fss_return_code_version fss_return_code_major_version "." fss_return_code_minor_version "." fss_return_code_micro_version +#endif // _di_fss_return_code_version_ + +#ifndef _di_fss_return_code_name_ + #define fss_return_code_name "fss_return_code" + #define fss_return_code_name_long "FSS Error Code" +#endif // _di_fss_return_code_name_ + +#ifndef _di_fss_return_code_defines_ + #define fss_return_code_short_is_okay "o" + #define fss_return_code_short_is_warning "w" + #define fss_return_code_short_is_error "e" + + #define fss_return_code_long_is_okay "is_okay" + #define fss_return_code_long_is_warning "is_warning" + #define fss_return_code_long_is_error "is_error" + + enum { + fss_return_code_parameter_help, + fss_return_code_parameter_light, + fss_return_code_parameter_no_color, + fss_return_code_parameter_version, + + fss_return_code_parameter_is_okay, + fss_return_code_parameter_is_warning, + fss_return_code_parameter_is_error, + }; + + #define f_console_parameter_initialize_fss_return_code \ + { \ + f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_false, f_console_type_normal, 0), \ + f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \ + f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \ + f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \ + f_console_parameter_initialize(fss_return_code_short_is_okay, fss_return_code_long_is_okay, 0, 0, f_false, f_console_type_normal, 0), \ + f_console_parameter_initialize(fss_return_code_short_is_warning, fss_return_code_long_is_warning, 0, 0, f_false, f_console_type_normal, 0), \ + f_console_parameter_initialize(fss_return_code_short_is_error, fss_return_code_long_is_error, 0, 0, f_false, f_console_type_normal, 0), \ + } + + #define fss_return_code_total_parameters 7 +#endif // _di_fss_return_code_defines_ + +#ifndef _di_fss_return_code_data_ + typedef struct { + f_console_parameter parameters[fss_return_code_total_parameters]; + + f_string_lengths remaining; + f_bool process_pipe; + + fll_color_context context; + } fss_return_code_data; + + #define fss_return_code_data_initialize \ + { \ + f_console_parameter_initialize_fss_return_code, \ + f_string_lengths_initialize, \ + f_false, \ + fll_color_context_initialize, \ + } +#endif // _di_fss_return_code_data_ + +#ifndef _di_fss_return_code_print_version_ + extern f_return_status fss_return_code_print_version(const fss_return_code_data data); +#endif // _di_fss_return_code_print_version_ + +#ifndef _di_fss_return_code_print_help_ + extern f_return_status fss_return_code_print_help(const fss_return_code_data data); +#endif // _di_fss_return_code_print_help_ + +#ifndef _di_fss_return_code_main_ + extern f_return_status fss_return_code_main(const f_array_length argc, const f_string argv[], fss_return_code_data *data); +#endif // _di_fss_return_code_main_ + +#ifndef _di_fss_return_code_delete_data_ + extern f_return_status fss_return_code_delete_data(fss_return_code_data *data); +#endif // _di_fss_return_code_delete_data_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _fss_return_code_h diff --git a/level_3/fss_return_code/c/main.c b/level_3/fss_return_code/c/main.c new file mode 100644 index 0000000..72fc878 --- /dev/null +++ b/level_3/fss_return_code/c/main.c @@ -0,0 +1,13 @@ +#include + +int main(const f_array_length argc, const f_string argv[]){ + fss_return_code_data data = fss_return_code_data_initialize; + + /* + if (f_pipe_exists()){ + data.process_pipe = f_true; + } + */ + + return fss_return_code_main(argc, argv, &data); +} diff --git a/level_3/fss_error_code/data/build/settings b/level_3/fss_return_code/data/build/settings similarity index 70% rename from level_3/fss_error_code/data/build/settings rename to level_3/fss_return_code/data/build/settings index 6e88903..443f053 100644 --- a/level_3/fss_error_code/data/build/settings +++ b/level_3/fss_return_code/data/build/settings @@ -1,6 +1,6 @@ # fss-0000 -project_name fss_error_code +project_name fss_return_code project_level 3 version_major 0 @@ -9,13 +9,13 @@ version_micro 0 build_compiler gcc build_libraries -lc -lf_memory -lf_console -lfl_console -lf_conversion -lf_pipe -lf_output -lfl_colors -lfll_colors -lfl_errors -lfl_fss -lfll_fss -build_sources_library fss_error_code.c +build_sources_library fss_return_code.c build_sources_program main.c -build_sources_headers fss_error_code.h +build_sources_headers fss_return_code.h build_shared yes flags_all -z now flags_shared flags_static flags_library -fPIC -flags_program -fPIE -lfss_error_code +flags_program -fPIE -lfss_return_code diff --git a/level_3/error_code/c/main.c b/level_3/return_code/c/main.c similarity index 50% rename from level_3/error_code/c/main.c rename to level_3/return_code/c/main.c index 7050959..4c61c76 100644 --- a/level_3/error_code/c/main.c +++ b/level_3/return_code/c/main.c @@ -1,7 +1,7 @@ -#include +#include int main(const f_array_length argc, const f_string argv[]){ - error_code_data data = error_code_data_initialize; + return_code_data data = return_code_data_initialize; /* if (f_pipe_exists()){ @@ -9,5 +9,5 @@ int main(const f_array_length argc, const f_string argv[]){ } */ - return error_code_main(argc, argv, &data); + return return_code_main(argc, argv, &data); } diff --git a/level_3/error_code/c/error_code.c b/level_3/return_code/c/return_code.c similarity index 77% rename from level_3/error_code/c/error_code.c rename to level_3/return_code/c/return_code.c index 2ad6ad7..e18b58b 100644 --- a/level_3/error_code/c/error_code.c +++ b/level_3/return_code/c/return_code.c @@ -4,28 +4,28 @@ * Licenses: lgplv2.1 * Programmers: Kevin Day */ -#include +#include #ifdef __cplusplus extern "C"{ #endif // version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors -#ifndef _di_error_code_print_version_ - f_return_status error_code_print_version(const error_code_data data){ - printf("%s\n", error_code_version); +#ifndef _di_return_code_print_version_ + f_return_status return_code_print_version(const return_code_data data){ + printf("%s\n", return_code_version); return f_none; } -#endif // _error_code_print_version_ +#endif // _return_code_print_version_ -#ifndef _di_error_code_print_help_ - f_return_status error_code_print_help(const error_code_data data){ +#ifndef _di_return_code_print_help_ + f_return_status return_code_print_help(const return_code_data data){ printf("\n"); - fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", error_code_name_long); + fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", return_code_name_long); printf("\n"); - fl_print_color(f_standard_output, data.context.notable, data.context.reset, " Version %s", error_code_version); + fl_print_color(f_standard_output, data.context.notable, data.context.reset, " Version %s", return_code_version); printf("\n\n"); @@ -60,26 +60,26 @@ extern "C"{ printf(" Print only the version number"); printf("\n %s", f_console_symbol_short_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_code_short_is_okay); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_short_is_okay); printf(", %s", f_console_symbol_long_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_code_long_is_okay); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_long_is_okay); printf(" Returns true if the error code is not an error."); printf("\n"); printf("\n %s", f_console_symbol_short_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_code_short_is_warning); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_short_is_warning); printf(", %s", f_console_symbol_long_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_code_long_is_warning); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_long_is_warning); printf(" Returns true if the error code is a warning."); printf("\n %s", f_console_symbol_short_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_code_short_is_error); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_short_is_error); printf(", %s", f_console_symbol_long_enable); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_code_long_is_error); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_long_is_error); printf(" Returns true if the error code is an error."); @@ -87,7 +87,7 @@ extern "C"{ fl_print_color(f_standard_output, data.context.important, data.context.reset, " Usage: "); printf("\n "); - fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_code_name); + fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_name); printf(" "); fl_print_color(f_standard_output, data.context.notable, data.context.reset, "["); @@ -106,24 +106,24 @@ extern "C"{ return f_none; } -#endif // _di_error_code_print_help_ +#endif // _di_return_code_print_help_ -#ifndef _di_error_code_main_ - f_return_status error_code_main(const f_array_length argc, const f_string argv[], error_code_data *data){ +#ifndef _di_return_code_main_ + f_return_status return_code_main(const f_array_length argc, const f_string argv[], return_code_data *data){ f_status status = f_status_initialize; f_status allocation_status = f_status_initialize; - status = fl_process_parameters(argc, argv, data->parameters, error_code_total_parameters, &data->remaining); + status = fl_process_parameters(argc, argv, data->parameters, return_code_total_parameters, &data->remaining); // load colors when not told to show no colors - if (data->parameters[error_code_parameter_no_color].result == f_console_result_none){ + if (data->parameters[return_code_parameter_no_color].result == f_console_result_none){ fll_new_color_context(allocation_status, data->context); if (allocation_status == f_none){ - fll_colors_load_context(&data->context, data->parameters[error_code_parameter_light].result == f_console_result_found); + fll_colors_load_context(&data->context, data->parameters[return_code_parameter_light].result == f_console_result_found); } else { fprintf(f_standard_error, "Critical Error: unable to allocate memory\n"); - error_code_delete_data(data); + return_code_delete_data(data); return allocation_status; } } @@ -142,16 +142,16 @@ extern "C"{ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status); } - error_code_delete_data(data); + return_code_delete_data(data); return status; } // execute parameter results - if (data->parameters[error_code_parameter_help].result == f_console_result_found){ - error_code_print_help(*data); - } else if (data->parameters[error_code_parameter_version].result == f_console_result_found){ - error_code_print_version(*data); - } else if (data->parameters[error_code_parameter_is_error].result == f_console_result_found && data->remaining.used > 0){ + if (data->parameters[return_code_parameter_help].result == f_console_result_found){ + return_code_print_help(*data); + } else if (data->parameters[return_code_parameter_version].result == f_console_result_found){ + return_code_print_version(*data); + } else if (data->parameters[return_code_parameter_is_error].result == f_console_result_found && data->remaining.used > 0){ f_array_length counter = f_array_length_initialize; f_status code = f_status_initialize; @@ -162,14 +162,14 @@ extern "C"{ code = (f_status) atoll(argv[data->remaining.array[counter]]); if (fl_errors_is_error(code)){ - error_code_delete_data(data); + return_code_delete_data(data); return f_true; } } - error_code_delete_data(data); + return_code_delete_data(data); return f_false; - } else if (data->parameters[error_code_parameter_is_warning].result == f_console_result_found && data->remaining.used > 0){ + } else if (data->parameters[return_code_parameter_is_warning].result == f_console_result_found && data->remaining.used > 0){ f_array_length counter = f_array_length_initialize; f_status code = f_status_initialize; @@ -180,14 +180,14 @@ extern "C"{ code = (f_status) atoll(argv[data->remaining.array[counter]]); if (fl_errors_is_warning(code)){ - error_code_delete_data(data); + return_code_delete_data(data); return f_true; } } - error_code_delete_data(data); + return_code_delete_data(data); return f_false; - } else if (data->parameters[error_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0){ + } else if (data->parameters[return_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0){ f_array_length counter = f_array_length_initialize; f_status code = f_status_initialize; @@ -198,12 +198,12 @@ extern "C"{ code = (f_status) atoll(argv[data->remaining.array[counter]]); if (fl_errors_is_okay(code)){ - error_code_delete_data(data); + return_code_delete_data(data); return f_true; } } - error_code_delete_data(data); + return_code_delete_data(data); return f_false; } else if (data->remaining.used > 0 || data->process_pipe){ f_array_length counter = f_array_length_initialize; @@ -227,13 +227,13 @@ extern "C"{ status = f_invalid_parameter; } - error_code_delete_data(data); + return_code_delete_data(data); return status; } -#endif // _di_error_code_main_ +#endif // _di_return_code_main_ -#ifndef _di_error_code_delete_data_ - f_return_status error_code_delete_data(error_code_data *data){ +#ifndef _di_return_code_delete_data_ + f_return_status return_code_delete_data(return_code_data *data){ f_status status = f_status_initialize; f_delete_string_lengths(status, data->remaining); @@ -241,7 +241,7 @@ extern "C"{ return f_none; } -#endif // _di_error_code_delete_data_ +#endif // _di_return_code_delete_data_ #ifdef __cplusplus diff --git a/level_3/return_code/c/return_code.h b/level_3/return_code/c/return_code.h new file mode 100644 index 0000000..5f60899 --- /dev/null +++ b/level_3/return_code/c/return_code.h @@ -0,0 +1,122 @@ +/* FLL - Level 3 + * Project: FSS + * Version: 0.3.x + * Licenses: lgplv2.1 + * Programmers: Kevin Day + * Documentation: + * + * This program provides error code to string translation. + */ +#ifndef _return_code_h + +// libc includes +#include +#include +#include + +// fll-0 includes +#include +#include +#include +#include +#include + +// fll-1 includes +#include +#include +#include +#include + +// fll-2 includes +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +#ifndef _di_return_code_version_ + #define return_code_major_version "0" + #define return_code_minor_version "3" + #define return_code_micro_version "0" + #define return_code_version return_code_major_version "." return_code_minor_version "." return_code_micro_version +#endif // _di_return_code_version_ + +#ifndef _di_return_code_name_ + #define return_code_name "return_code" + #define return_code_name_long "Error Code" +#endif // _di_return_code_name_ + +#ifndef _di_return_code_defines_ + #define return_code_short_is_okay "o" + #define return_code_short_is_warning "w" + #define return_code_short_is_error "e" + + #define return_code_long_is_okay "is_okay" + #define return_code_long_is_warning "is_warning" + #define return_code_long_is_error "is_error" + + enum { + return_code_parameter_help, + return_code_parameter_light, + return_code_parameter_no_color, + return_code_parameter_version, + + return_code_parameter_is_okay, + return_code_parameter_is_warning, + return_code_parameter_is_error, + }; + + #define f_console_parameter_initialize_return_code \ + { \ + f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, 0, f_false, f_console_type_normal, 0), \ + f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \ + f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \ + f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \ + f_console_parameter_initialize(return_code_short_is_okay, return_code_long_is_okay, 0, 0, f_false, f_console_type_normal, 0), \ + f_console_parameter_initialize(return_code_short_is_warning, return_code_long_is_warning, 0, 0, f_false, f_console_type_normal, 0), \ + f_console_parameter_initialize(return_code_short_is_error, return_code_long_is_error, 0, 0, f_false, f_console_type_normal, 0), \ + } + + #define return_code_total_parameters 7 +#endif // _di_return_code_defines_ + +#ifndef _di_return_code_data_ + typedef struct { + f_console_parameter parameters[return_code_total_parameters]; + + f_string_lengths remaining; + f_bool process_pipe; + + fll_color_context context; + } return_code_data; + + #define return_code_data_initialize \ + { \ + f_console_parameter_initialize_return_code, \ + f_string_lengths_initialize, \ + f_false, \ + fll_color_context_initialize, \ + } +#endif // _di_return_code_data_ + +#ifndef _di_return_code_print_version_ + extern f_return_status return_code_print_version(const return_code_data data); +#endif // _di_return_code_print_version_ + +#ifndef _di_return_code_print_help_ + extern f_return_status return_code_print_help(const return_code_data data); +#endif // _di_return_code_print_help_ + +#ifndef _di_return_code_main_ + extern f_return_status return_code_main(const f_array_length argc, const f_string argv[], return_code_data *data); +#endif // _di_return_code_main_ + +#ifndef _di_return_code_delete_data_ + extern f_return_status return_code_delete_data(return_code_data *data); +#endif // _di_return_code_delete_data_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _return_code_h diff --git a/level_3/error_code/data/build/settings b/level_3/return_code/data/build/settings similarity index 71% rename from level_3/error_code/data/build/settings rename to level_3/return_code/data/build/settings index 7ca25d0..a4a4071 100644 --- a/level_3/error_code/data/build/settings +++ b/level_3/return_code/data/build/settings @@ -1,6 +1,6 @@ # fss-0000 -project_name error_code +project_name return_code project_level 3 version_major 0 @@ -9,13 +9,13 @@ version_micro 0 build_compiler gcc build_libraries -lc -lf_memory -lf_console -lfl_console -lf_conversion -lf_pipe -lf_output -lfl_colors -lfll_colors -lfl_errors -build_sources_library error_code.c +build_sources_library return_code.c build_sources_program main.c -build_sources_headers error_code.h +build_sources_headers return_code.h build_shared yes flags_all -z now flags_shared flags_static flags_library -fPIC -flags_program -fPIE -lerror_code +flags_program -fPIE -lreturn_code -- 1.8.3.1