From: Kevin Day Date: Thu, 8 Jan 2015 03:14:41 +0000 (-0600) Subject: Update: f_error changes and more signals X-Git-Tag: 0.4.2~13 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=88f0746a7acc2d4ca8607c405d2fa80cbc56f9ca;p=fll Update: f_error changes and more signals - Added more signal commands. - Added more signal codes for up to 64 signals. - Replaced f_error_unmask with f_error_set_fine to be more consistent with the other f_error_set_* names. - The signal bit is intended to be both the error and warning bit set so it is mathematically the same as the mask bit. - Change f_none starting point to 197 to handle all possible 64 signals. --- diff --git a/level_0/f_errors/c/errors.h b/level_0/f_errors/c/errors.h index d472804..c66b5cf 100644 --- a/level_0/f_errors/c/errors.h +++ b/level_0/f_errors/c/errors.h @@ -142,18 +142,25 @@ extern "C"{ #define f_error_bit_warning 16384 #define f_error_bit_mask 49152 #define f_error_bit_fine 16383 + #define f_error_bit_signal 49152 - #define f_error_is_error(status) status & f_error_bit_error - #define f_error_is_warning(status) status & f_error_bit_warning - #define f_error_is_problem(status) status & f_error_bit_mask // this is either a warning or an error - #define f_error_is_fine(status) (status & f_error_bit_mask) == 0 - #define f_error_is_not_error(status) (status & f_error_bit_error) == 0 + #define f_error_is_error(status) status & f_error_bit_error + #define f_error_is_warning(status) status & f_error_bit_warning + #define f_error_is_problem(status) status & f_error_bit_mask + #define f_error_is_fine(status) (status & f_error_bit_mask) == 0 + #define f_error_is_not_error(status) (status & f_error_bit_error) == 0 + #define f_error_is_not_warning(status) (status & f_error_bit_warning) == 0 + #define f_error_is_not_signal(status) (status & f_error_bit_signal) == 0 + + // use both error and warning bits to designate that the response is a signal. + #define f_error_is_signal(status) (status & f_error_bit_signal) == f_error_bit_signal #define f_error_set_error(status) status | f_error_bit_error #define f_error_set_warning(status) status | f_error_bit_warning + #define f_error_set_signal(status) status | f_error_bit_signal - // use f_error_unmask to remove the error and warning bits - #define f_error_unmask(status) status & f_error_bit_fine + // use f_error_set_fine to remove the error, warning, and signal bits + #define f_error_set_fine(status) status & f_error_bit_fine #endif // _di_f_error_masks_ // use of an enumerator makes more sense here than explicitly defining every error code @@ -195,10 +202,45 @@ enum { f_signal_pollable_event, f_signal_power_failure, f_signal_bad_system_call, + + // these will be renamed if new names are given for the remaining system calls (up to 64). + f_signal_reserved_32, + f_signal_reserved_33, + f_signal_reserved_34, + f_signal_reserved_35, + f_signal_reserved_36, + f_signal_reserved_37, + f_signal_reserved_38, + f_signal_reserved_39, + f_signal_reserved_40, + f_signal_reserved_41, + f_signal_reserved_42, + f_signal_reserved_43, + f_signal_reserved_44, + f_signal_reserved_45, + f_signal_reserved_46, + f_signal_reserved_47, + f_signal_reserved_48, + f_signal_reserved_49, + f_signal_reserved_50, + f_signal_reserved_51, + f_signal_reserved_52, + f_signal_reserved_53, + f_signal_reserved_54, + f_signal_reserved_55, + f_signal_reserved_56, + f_signal_reserved_57, + f_signal_reserved_58, + f_signal_reserved_59, + f_signal_reserved_60, + f_signal_reserved_61, + f_signal_reserved_62, + f_signal_reserved_63, + f_signal_reserved_64, #endif // _di_f_errors_signals_ #ifndef _di_f_errors_basic_ - f_none = 166, // start at 166 to allow compatibility with the reserved bash return codes (keep in mind fss return codes can be larger than 255). + f_none = 197, // start at 197 to allow compatibility with the reserved bash return codes (keep in mind fss return codes can be larger than 255). f_dummy, // to only be used as a placeholder f_warn, // warning f_critical, diff --git a/level_1/fl_errors/c/errors.c b/level_1/fl_errors/c/errors.c index ad70d08..85ca5af 100644 --- a/level_1/fl_errors/c/errors.c +++ b/level_1/fl_errors/c/errors.c @@ -19,7 +19,7 @@ extern "C"{ if (string == f_null) return f_error_set_error(f_invalid_parameter); #endif // _di_level_1_parameter_checking_ - f_status umasked_error = f_error_unmask(error); + f_status umasked_error = f_error_set_fine(error); switch (umasked_error) { #ifndef _di_fl_errors_booleans_ diff --git a/level_2/fll_fss/c/fss_errors.c b/level_2/fll_fss/c/fss_errors.c index dca6b25..e20dfcc 100644 --- a/level_2/fll_fss/c/fss_errors.c +++ b/level_2/fll_fss/c/fss_errors.c @@ -16,7 +16,7 @@ extern "C"{ if (string == f_null) return f_error_set_error(f_invalid_parameter); #endif // _di_level_2_parameter_checking_ - f_status unmasked_error = f_error_unmask(error); + f_status unmasked_error = f_error_set_fine(error); switch (unmasked_error) { #ifndef _di_fll_fss_errors_error_ diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index 0f1adb3..eaca551 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -127,7 +127,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); @@ -136,7 +136,7 @@ extern "C"{ // nothing can be 0 as that represents the program name, unless argv[] is improperly created } else if (f_macro_test_for_allocation_errors(status)) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory"); - } else if (f_error_unmask(status) == f_invalid_parameter) { + } else if (f_error_set_fine(status) == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()"); } else { 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()", f_error_set_error(status)); @@ -339,7 +339,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (f_macro_test_for_allocation_errors(status)) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory"); @@ -387,7 +387,7 @@ extern "C"{ status = fl_directory_list((f_string) network_devices, &data->devices); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (f_macro_test_for_allocation_errors(status)) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory"); @@ -571,7 +571,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); firewall_delete_local_data(&local); diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 7bf1898..a4e03c6 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -605,7 +605,7 @@ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -640,7 +640,7 @@ f_file_close(&file); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()"); @@ -669,7 +669,7 @@ } if (f_error_set_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_read() for the file '%s'", file_path.string); @@ -1019,7 +1019,7 @@ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_failure) { if (tool == firewall_program_iptables) { @@ -1068,7 +1068,7 @@ status = f_file_open(&file, filename); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (optional) { if (status == f_invalid_parameter) { @@ -1101,7 +1101,7 @@ f_file_close(&file); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()."); @@ -1129,7 +1129,7 @@ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", filename); @@ -1159,7 +1159,7 @@ status = firewall_perform_commands(*local, *data); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (f_macro_test_for_allocation_errors(status)) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory."); 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 1f43116..7130a5e 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 @@ -151,7 +151,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); @@ -192,7 +192,7 @@ extern "C"{ status = fl_file_read_fifo(file, &data->buffer); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -230,7 +230,7 @@ extern "C"{ data->file_position.total_elements = original_size; if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -267,7 +267,7 @@ extern "C"{ f_file_close(&file); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()"); @@ -326,7 +326,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename); 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 27138f6..070ed29 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 @@ -123,7 +123,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); @@ -163,7 +163,7 @@ extern "C"{ status = fl_file_read_fifo(file, &input); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -233,7 +233,7 @@ extern "C"{ status = f_file_open(&output, argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); f_file_close(&output); @@ -257,7 +257,7 @@ extern "C"{ f_file_close(&output); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); 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 cf37068..15e0298 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -137,7 +137,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); @@ -178,7 +178,7 @@ extern "C"{ status = fl_file_read_fifo(file, &data->buffer); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()"); @@ -221,7 +221,7 @@ extern "C"{ data->file_position.total_elements = original_size; if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -258,7 +258,7 @@ extern "C"{ f_file_close(&file); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()"); @@ -318,7 +318,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename); 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 6dd9bc1..1d3c49d 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -123,7 +123,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); @@ -163,7 +163,7 @@ extern "C"{ status = fl_file_read_fifo(file, &input); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -233,7 +233,7 @@ extern "C"{ status = f_file_open(&output, argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); f_file_close(&output); @@ -257,7 +257,7 @@ extern "C"{ f_file_close(&output); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); 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 c5e8662..3da2493 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -144,7 +144,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); @@ -190,7 +190,7 @@ extern "C"{ status = fl_file_read_fifo(file, &data->buffer); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -229,7 +229,7 @@ extern "C"{ data->file_position.total_elements = original_size; if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -273,7 +273,7 @@ extern "C"{ f_file_close(&file); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()"); @@ -332,7 +332,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_extended_read() for the file '%s'", filename); 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 8e0dd38..85cf2e5 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -130,7 +130,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); @@ -170,7 +170,7 @@ extern "C"{ status = fl_file_read_fifo(file, &input); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); @@ -278,7 +278,7 @@ extern "C"{ status = f_file_open(&output, argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); f_file_close(&output); @@ -302,7 +302,7 @@ extern "C"{ f_file_close(&output); if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_invalid_parameter) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); diff --git a/level_3/fss_return_code/c/fss_return_code.c b/level_3/fss_return_code/c/fss_return_code.c index 2f4a7e2..2fa198b 100644 --- a/level_3/fss_return_code/c/fss_return_code.c +++ b/level_3/fss_return_code/c/fss_return_code.c @@ -136,7 +136,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); diff --git a/level_3/return_code/c/return_code.c b/level_3/return_code/c/return_code.c index f95d060..2f266ba 100644 --- a/level_3/return_code/c/return_code.c +++ b/level_3/return_code/c/return_code.c @@ -136,7 +136,7 @@ extern "C"{ } if (f_error_is_error(status)) { - status = f_error_unmask(status); + status = f_error_set_fine(status); if (status == f_no_data) { fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");