Add three new parameters: is_okay, is_warning, and is_error.
These should test to see if the error code is in fact an error, a warning, or not an error.
#endif
#ifndef _di_fl_errors_to_string_
- // Convert error codes to their string equivalents.
- f_return_status fl_errors_to_string(const f_status error, f_string *string){
+ f_return_status fl_errors_to_string(const f_status error, f_string *string) {
#ifndef _di_level_1_parameter_checking_
if (string == f_null) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
}
#endif // _di_fl_errors_to_string_
+#ifndef _di_fl_errors_is_error_
+ f_return_status fl_errors_is_error(const f_status error) {
+ if (fl_errors_is_okay(error) == f_true) {
+ return f_false;
+ } else if (fl_errors_is_warning(error) == f_true) {
+ return f_false;
+ }
+
+ return f_true;
+ }
+#endif // _di_fl_errors_is_error_
+
+#ifndef _di_fl_errors_is_warning_
+ f_return_status fl_errors_is_warning(const f_status error) {
+ switch(error){
+ #ifndef _di_fl_errors_basic_
+ case f_no_data:
+ return f_true;
+ #endif // _di_fl_errors_basic_
+
+ #ifndef _di_f_errors_buffers_
+ case f_no_data_on_eof:
+ return f_true;
+ case f_no_data_on_eos:
+ return f_true;
+ case f_no_data_on_stop:
+ return f_true;
+ case f_none_on_eof:
+ return f_true;
+ case f_none_on_eos:
+ return f_true;
+ case f_none_on_stop:
+ return f_true;
+ #endif // _di_f_errors_buffers_
+
+ default:
+ return f_false;
+ }
+
+ return f_unknown;
+ }
+#endif // _di_fl_errors_is_warning_
+
+#ifndef _di_fl_errors_is_okay_
+ // Returns true or false depending on whether the standard context of the error code represents an normal return status and not an error.
+ // Keep in mind that many of the error codes are context-specific and may be reported as an "okay" here when it is in fact not okay.
+ f_return_status fl_errors_is_okay(const f_status error) {
+ switch(error){
+ #ifndef _di_fl_errors_booleans_
+ case f_false:
+ return f_true;
+ case f_true:
+ return f_true;
+ #endif // _di_fl_errors_booleans_
+
+ #ifndef _di_fl_errors_basic_
+ case f_none:
+ return f_true;
+ case f_dummy:
+ return f_true;
+ #endif // _di_fl_errors_basic_
+
+ #ifndef _di_fll_error_non_
+ case f_less_than:
+ return f_true;
+ case f_equal_to:
+ return f_true;
+ case f_not_equal_to:
+ return f_true;
+ case f_greater_than:
+ return f_true;
+ #endif // _di_fl_errors_non_
+
+ default:
+ return f_false;
+ }
+
+ return f_unknown;
+ }
+#endif // _di_fl_errors_is_okay_
+
#ifdef __cplusplus
} // extern "C"
#endif
extern f_return_status fl_errors_to_string(const f_status error, f_string *string);
#endif // _di_fl_errors_to_string_
+#ifndef _di_fl_errors_is_error_
+ // Returns true or false depending on whether the standard context of the error code represents an error.
+ // Keep in mind that many of the error codes are context-specific and may be reported as an error here when it is in fact not an error.
+ extern f_return_status fl_errors_is_error(const f_status error);
+#endif // _di_fl_errors_is_error_
+
+#ifndef _di_fl_errors_is_warning_
+ // Returns true or false depending on whether the standard context of the error code represents a warning.
+ // Keep in mind that many of the error codes are context-specific and may be reported as a warning here when it is in fact not a warning.
+ extern f_return_status fl_errors_is_warning(const f_status error);
+#endif // _di_fl_errors_is_warning_
+
+
+#ifndef _di_fl_errors_is_okay_
+ // Returns true or false depending on whether the standard context of the error code represents an normal return status and not an error.
+ // Keep in mind that many of the error codes are context-specific and may be reported as an "okay" here when it is in fact not okay.
+ extern f_return_status fl_errors_is_okay(const f_status error);
+#endif // _di_fl_errors_is_okay_
+
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _di_fl_fss_errors_success_
}; // enum
-
#ifdef __cplusplus
} // extern "C"
#endif
#endif
#ifndef _di_fll_fss_errors_to_string_
- // Convert error codes to their string equivalents.
f_return_status fll_fss_errors_to_string(const f_status error, f_string *string) {
#ifndef _di_level_2_parameter_checking_
if (string == f_null) return f_invalid_parameter;
}
#endif // _di_fll_errors_to_string_
+#ifndef _di_fll_fss_errors_is_error_
+ f_return_status fll_fss_errors_is_error(const f_status error) {
+ if (fll_fss_errors_is_okay(error) == f_true) {
+ return f_false;
+ } else if (fll_fss_errors_is_warning(error) == f_true) {
+ return f_false;
+ }
+
+ return f_true;
+ }
+#endif // _di_fll_fss_errors_is_error_
+
+#ifndef _di_fll_fss_errors_is_warning_
+ f_return_status fll_fss_errors_is_warning(const f_status error) {
+ switch(error){
+ #ifndef _di_fll_fss_errors_basic_
+ case f_no_data:
+ return f_true;
+ #endif // _di_fll_fss_errors_basic_
+
+ #ifndef _di_f_errors_buffers_
+ case f_no_data_on_eof:
+ return f_true;
+ case f_no_data_on_eos:
+ return f_true;
+ case f_no_data_on_stop:
+ return f_true;
+ case f_none_on_eof:
+ return f_true;
+ case f_none_on_eos:
+ return f_true;
+ case f_none_on_stop:
+ return f_true;
+ #endif // _di_f_errors_buffers_
+
+ default:
+ return f_false;
+ }
+
+ return f_unknown;
+ }
+#endif // _di_fll_fss_errors_is_warning_
+
+#ifndef _di_fll_fss_errors_is_okay_
+ f_return_status fll_fss_errors_is_okay(const f_status error) {
+ switch(error){
+ #ifndef _di_fll_fss_errors_booleans_
+ case f_false:
+ return f_true;
+ case f_true:
+ return f_true;
+ #endif // _di_fll_fss_errors_booleans_
+
+ #ifndef _di_fll_fss_errors_basic_
+ case f_none:
+ return f_true;
+ case f_dummy:
+ return f_true;
+ #endif // _di_fll_fss_errors_basic_
+
+ #ifndef _di_fll_error_non_
+ case f_less_than:
+ return f_true;
+ case f_equal_to:
+ return f_true;
+ case f_not_equal_to:
+ return f_true;
+ case f_greater_than:
+ return f_true;
+ #endif // _di_fll_fss_errors_non_
+
+ default:
+ return f_false;
+ }
+
+ return f_unknown;
+ }
+#endif // _di_fll_fss_errors_is_okay_
+
#ifdef __cplusplus
} // extern "C"
#endif
extern f_return_status fll_fss_errors_to_string(const f_status error, f_string *string);
#endif // _di_fll_errors_to_string_
+#ifndef _di_fll_fss_errors_is_error_
+ // Returns true or false depending on whether the standard context of the error code represents an error.
+ // Keep in mind that many of the error codes are context-specific and may be reported as an error here when it is in fact not an error.
+ extern f_return_status fll_fss_errors_is_error(const f_status error);
+#endif // _di_fll_fss_errors_is_error_
+
+#ifndef _di_fll_fss_errors_is_warning_
+ // Returns true or false depending on whether the standard context of the error code represents a warning.
+ // Keep in mind that many of the error codes are context-specific and may be reported as a warning here when it is in fact not a warning.
+ extern f_return_status fll_fss_errors_is_warning(const f_status error);
+#endif // _di_fll_fss_errors_is_warning_
+
+
+#ifndef _di_fll_fss_errors_is_okay_
+ // Returns true or false depending on whether the standard context of the error code represents an normal return status and not an error.
+ // Keep in mind that many of the error codes are context-specific and may be reported as "okay" here when it is in fact not okay.
+ extern f_return_status fll_fss_errors_is_okay(const f_status error);
+#endif // _di_fll_fss_errors_is_okay_
+
#ifdef __cplusplus
} // extern "C"
#endif
fl_print_color(f_standard_output, data.context.standout, data.context.reset, f_console_standard_long_version);
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);
+
+ printf(", %s", f_console_symbol_long_enable);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_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);
+
+ printf(", %s", f_console_symbol_long_enable);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_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);
+
+ printf(", %s", f_console_symbol_long_enable);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, error_code_long_is_error);
+ printf(" Returns true if the error code is an error.");
+
printf("\n\n");
fl_print_color(f_standard_output, data.context.important, data.context.reset, " Usage: ");
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){
+ f_array_length counter = f_array_length_initialize;
+
+ f_status code = f_status_initialize;
+
+ status = f_false;
+
+ for (; counter < data->remaining.used; counter++){
+ code = (f_status) atoll(argv[data->remaining.array[counter]]);
+
+ if (fl_errors_is_error(code)){
+ error_code_delete_data(data);
+ return f_true;
+ }
+ }
+
+ error_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){
+ f_array_length counter = f_array_length_initialize;
+
+ f_status code = f_status_initialize;
+
+ status = f_false;
+
+ for (; counter < data->remaining.used; counter++){
+ code = (f_status) atoll(argv[data->remaining.array[counter]]);
+
+ if (fl_errors_is_warning(code)){
+ error_code_delete_data(data);
+ return f_true;
+ }
+ }
+
+ error_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){
+ f_array_length counter = f_array_length_initialize;
+
+ f_status code = f_status_initialize;
+
+ status = f_false;
+
+ for (; counter < data->remaining.used; counter++){
+ code = (f_status) atoll(argv[data->remaining.array[counter]]);
+
+ if (fl_errors_is_okay(code)){
+ error_code_delete_data(data);
+ return f_true;
+ }
+ }
+
+ error_code_delete_data(data);
+ return f_false;
} else if (data->remaining.used > 0 || data->process_pipe){
f_array_length counter = f_array_length_initialize;
#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_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 4
+ #define error_code_total_parameters 7
#endif // _di_error_code_defines_
#ifndef _di_error_code_data_
printf(" Print only the version number");
+ 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);
+
+ 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);
+ 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);
+
+ 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);
+ 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);
+
+ 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);
+ printf(" Returns true if the error code is an error.");
+
+
printf("\n\n");
fl_print_color(f_standard_output, data.context.important, data.context.reset, " Usage: ");
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){
+ f_array_length counter = f_array_length_initialize;
+
+ f_status code = f_status_initialize;
+
+ status = f_false;
+
+ for (; counter < data->remaining.used; counter++){
+ code = (f_status) atoll(argv[data->remaining.array[counter]]);
+
+ if (fll_fss_errors_is_error(code)){
+ fss_error_code_delete_data(data);
+ return f_true;
+ }
+ }
+
+ fss_error_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){
+ f_array_length counter = f_array_length_initialize;
+
+ f_status code = f_status_initialize;
+
+ status = f_false;
+
+ for (; counter < data->remaining.used; counter++){
+ code = (f_status) atoll(argv[data->remaining.array[counter]]);
+
+ if (fll_fss_errors_is_warning(code)){
+ fss_error_code_delete_data(data);
+ return f_true;
+ }
+ }
+
+ fss_error_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){
+ f_array_length counter = f_array_length_initialize;
+
+ f_status code = f_status_initialize;
+
+ status = f_false;
+
+ for (; counter < data->remaining.used; counter++){
+ code = (f_status) atoll(argv[data->remaining.array[counter]]);
+
+ if (fll_fss_errors_is_okay(code)){
+ fss_error_code_delete_data(data);
+ return f_true;
+ }
+ }
+
+ fss_error_code_delete_data(data);
+ return f_false;
} else if (data->remaining.used > 0 || data->process_pipe){
f_array_length counter = f_array_length_initialize;
#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_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 4
+ #define fss_error_code_total_parameters 7
#endif // _di_fss_error_code_defines_
#ifndef _di_fss_error_code_data_