From: Kevin Day Date: Sat, 23 May 2020 20:46:19 +0000 (-0500) Subject: Cleanup: Replace F_file_open_not with F_file_closed, add additional status codes... X-Git-Tag: 0.5.0~240 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=0c98d876d8cf154e4eed524432d7fab051ae8331;p=fll Cleanup: Replace F_file_open_not with F_file_closed, add additional status codes for consistencies Socket was not fully converted into basic status codes (not having connect). I can see future work in sockets whee I may actually add connect codes back, but I won't know until I spend dedicate time on it. Add additional status codes that should probably exist for consistency purposes. With F_file_open_not removed, split behavior into two checks: - F_file for file descriptor errors. - F_file_closed for file not open errors. --- diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index 5a6dd40..488c0ec 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -370,7 +370,8 @@ extern "C" { if (buffer->used > buffer->size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); f_status status = F_none; ssize_t size_read = 0; @@ -420,7 +421,8 @@ extern "C" { if (buffer->used > buffer->size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); f_status status = F_none; ssize_t size_read = 0; @@ -470,7 +472,8 @@ extern "C" { if (buffer->used > buffer->size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); f_status status = F_none; ssize_t size_read = 0; @@ -693,7 +696,8 @@ extern "C" { if (buffer.used >= buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); if (buffer.used == 0) { if (written) *written = 0; @@ -728,7 +732,8 @@ extern "C" { if (buffer.used >= buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); if (buffer.used == 0) { if (written) *written = 0; @@ -773,7 +778,8 @@ extern "C" { if (buffer.used >= buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); if (buffer.used == 0 || total == 0) { if (written) *written = 0; @@ -820,7 +826,8 @@ extern "C" { if (range.start >= buffer.used) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); if (buffer.used == 0) { if (written) *written = 0; diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 3744b69..9d4e556 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -904,7 +904,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see read() @@ -934,7 +935,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see read() @@ -965,7 +967,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see read() @@ -1248,7 +1251,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see write() @@ -1280,7 +1284,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see write() @@ -1313,7 +1318,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see write() @@ -1346,7 +1352,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see write() diff --git a/level_0/f_file/c/private-file.h b/level_0/f_file/c/private-file.h index 54e9bc0..a8c12dd 100644 --- a/level_0/f_file/c/private-file.h +++ b/level_0/f_file/c/private-file.h @@ -610,7 +610,7 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see f_file_write() diff --git a/level_0/f_status/c/status.h b/level_0/f_status/c/status.h index 362e358..4e49f9a 100644 --- a/level_0/f_status/c/status.h +++ b/level_0/f_status/c/status.h @@ -147,6 +147,7 @@ extern "C" { F_address, F_block, F_bound_out, + F_connected, F_connected_not, F_critical, F_descriptor, @@ -155,6 +156,7 @@ extern "C" { F_eof, F_eol, F_eos, + F_exist, F_exist_not, F_failure, F_fork, @@ -176,7 +178,6 @@ extern "C" { F_process_too_many, F_prohibited, F_read_only, - F_socket, F_space_not, F_stop, F_syntax, @@ -184,6 +185,7 @@ extern "C" { F_unsupported, F_utf, F_value, + F_value_not, F_warn, F_write_only, #endif // _di_F_status_basic_ @@ -281,13 +283,12 @@ extern "C" { F_file_descriptor, F_file_descriptor_max, F_file_empty, - F_file_error, F_file_flush, F_file_found, F_file_found_not, F_file_open, + F_file_opened, F_file_open_max, - F_file_open_not, F_file_purge, F_file_read, F_file_reallocation, @@ -327,12 +328,12 @@ extern "C" { F_directory_closed, F_directory_descriptor, F_directory_empty, + F_directory_empty_not, F_directory_found, F_directory_found_not, F_directory_flush, F_directory_link_max, F_directory_open, - F_directory_open_not, F_directory_purge, F_directory_read, F_directory_stream, @@ -344,10 +345,11 @@ extern "C" { #endif // _di_F_status_directory_ #ifndef _di_F_status_socket_ - F_socket_connect_client, - F_socket_connect_target, + F_socket, + F_socket_client, F_socket_receive, F_socket_send, + F_socket_target, #endif // _di_F_status_socket_ #ifndef _di_F_status_compare_ @@ -366,6 +368,14 @@ extern "C" { F_access_denied_user, F_access_denied_world, F_access_denied_write, + F_access_granted, + F_access_granted_execute, + F_access_granted_group, + F_access_granted_read, + F_access_granted_super, // "super" as in super user (root user). + F_access_granted_user, + F_access_granted_world, + F_access_granted_write, #endif // _di_F_status_access_ // Required. diff --git a/level_1/fl_fss/c/fss.c b/level_1/fl_fss/c/fss.c index c6d2926..e3bcfdc 100644 --- a/level_1/fl_fss/c/fss.c +++ b/level_1/fl_fss/c/fss.c @@ -172,8 +172,8 @@ extern "C" { #ifndef _di_level_1_parameter_checking_ if (file == 0) return F_status_set_error(F_parameter); if (header == 0) return F_status_set_error(F_parameter); - if (file->id == 0) return F_status_set_error(F_file_open_not); - if (file->id < 0) return F_status_set_error(F_file_error); + if (file->id == 0) return F_status_set_error(F_file_closed); + if (file->id < 0) return F_status_set_error(F_file); #endif // _di_level_1_parameter_checking_ { diff --git a/level_1/fl_fss/c/fss.h b/level_1/fl_fss/c/fss.h index 08a40b0..0437766 100644 --- a/level_1/fl_fss/c/fss.h +++ b/level_1/fl_fss/c/fss.h @@ -88,7 +88,7 @@ extern "C" { * * Errors from (with error bit): f_file_read_until(). * Errors from (with error bit): fl_fss_identify() - * File errors (with error bit): F_file_seek, F_file_open_not. + * File errors (with error bit): F_file_seek, F_file_closed. * * @see f_file_read_until() * @see fl_fss_identify() diff --git a/level_1/fl_status/c/status.c b/level_1/fl_status/c/status.c index aef203e..f7023a5 100644 --- a/level_1/fl_status/c/status.c +++ b/level_1/fl_status/c/status.c @@ -227,6 +227,9 @@ extern "C" { case F_bound_out: *string = FL_status_string_bound_out; break; + case F_connected: + *string = FL_status_string_connected; + break; case F_connected_not: *string = FL_status_string_connected_not; break; @@ -251,6 +254,9 @@ extern "C" { case F_eos: *string = FL_status_string_eos; break; + case F_exist: + *string = FL_status_string_exist; + break; case F_exist_not: *string = FL_status_string_exist_not; break; @@ -314,9 +320,6 @@ extern "C" { case F_read_only: *string = FL_status_string_read_only; break; - case F_socket: - *string = FL_status_string_socket; - break; case F_space_not: *string = FL_status_string_space_not; break; @@ -338,6 +341,9 @@ extern "C" { case F_value: *string = FL_status_string_value; break; + case F_value_not: + *string = FL_status_string_value_not; + break; case F_warn: *string = FL_status_string_warn; break; @@ -608,8 +614,8 @@ extern "C" { case F_file_open_max: *string = FL_status_string_file_open_max; break; - case F_file_open_not: - *string = FL_status_string_file_open_not; + case F_file_opened: + *string = FL_status_string_file_opened; break; case F_file_purge: *string = FL_status_string_file_purge; @@ -713,6 +719,9 @@ extern "C" { case F_directory_empty: *string = FL_status_string_directory_empty; break; + case F_directory_empty_not: + *string = FL_status_string_directory_empty_not; + break; case F_directory_found: *string = FL_status_string_directory_found; break; @@ -728,9 +737,6 @@ extern "C" { case F_directory_open: *string = FL_status_string_directory_open; break; - case F_directory_open_not: - *string = FL_status_string_directory_open_not; - break; case F_directory_purge: *string = FL_status_string_directory_purge; break; @@ -758,11 +764,11 @@ extern "C" { #endif // _di_F_status_directory_ #ifndef _di_F_status_socket_ - case F_socket_connect_client: - *string = FL_status_string_socket_client; + case F_socket: + *string = FL_status_string_socket; break; - case F_socket_connect_target: - *string = FL_status_string_socket_target; + case F_socket_client: + *string = FL_status_string_socket_client; break; case F_socket_receive: *string = FL_status_string_socket_receive; @@ -770,6 +776,9 @@ extern "C" { case F_socket_send: *string = FL_status_string_socket_send; break; + case F_socket_target: + *string = FL_status_string_socket_target; + break; #endif // _di_F_status_socket_ #ifndef _di_F_error_compare_ @@ -787,7 +796,7 @@ extern "C" { break; #endif // _di_F_status_compare_ - #ifndef _di_F_status_access_denied_ + #ifndef _di_F_status_access_ case F_access_denied: *string = FL_status_string_access_denied; break; @@ -812,7 +821,31 @@ extern "C" { case F_access_denied_super: *string = FL_status_string_access_denied_super; break; - #endif // _di_F_status_access_denied_ + case F_access_granted: + *string = FL_status_string_access_granted; + break; + case F_access_granted_user: + *string = FL_status_string_access_granted_user; + break; + case F_access_granted_group: + *string = FL_status_string_access_granted_group; + break; + case F_access_granted_world: + *string = FL_status_string_access_granted_world; + break; + case F_access_granted_read: + *string = FL_status_string_access_granted_read; + break; + case F_access_granted_write: + *string = FL_status_string_access_granted_write; + break; + case F_access_granted_execute: + *string = FL_status_string_access_granted_execute; + break; + case F_access_granted_super: + *string = FL_status_string_access_granted_super; + break; + #endif // _di_F_status_access_ case F_status_code_last: *string = FL_status_string_status_code_last; diff --git a/level_1/fl_status/c/status.h b/level_1/fl_status/c/status.h index 81871f2..71970e6 100644 --- a/level_1/fl_status/c/status.h +++ b/level_1/fl_status/c/status.h @@ -166,6 +166,7 @@ extern "C" { #define FL_status_string_address "F_address" #define FL_status_string_block "F_block" #define FL_status_string_bound_out "F_bound_out" + #define FL_status_string_connected "F_connected" #define FL_status_string_connected_not "F_connected_not" #define FL_status_string_critical "F_critical" #define FL_status_string_descriptor "F_descriptor" @@ -174,6 +175,7 @@ extern "C" { #define FL_status_string_eof "F_eof" #define FL_status_string_eol "F_eol" #define FL_status_string_eos "F_eos" + #define FL_status_string_exist "F_exist" #define FL_status_string_exist_not "F_exist_not" #define FL_status_string_failure "F_failure" #define FL_status_string_fork "F_fork" @@ -195,7 +197,6 @@ extern "C" { #define FL_status_string_process_too_many "F_process_too_many" #define FL_status_string_prohibited "F_prohibited" #define FL_status_string_read_only "F_read_only" - #define FL_status_string_socket "F_socket" #define FL_status_string_space_not "F_space_not" #define FL_status_string_stop "F_stop" #define FL_status_string_syntax "F_syntax" @@ -203,6 +204,7 @@ extern "C" { #define FL_status_string_unsupported "F_unsupported" #define FL_status_string_utf "F_utf" #define FL_status_string_value "F_value" + #define FL_status_string_value_not "F_value_not" #define FL_status_string_warn "F_warn" #define FL_status_string_write_only "F_write_only" @@ -210,6 +212,7 @@ extern "C" { #define FL_status_string_address_length 9 #define FL_status_string_block_length 7 #define FL_status_string_bound_out_length 11 + #define FL_status_string_connected_length 11 #define FL_status_string_connected_not_length 15 #define FL_status_string_critical_length 10 #define FL_status_string_descriptor_length 12 @@ -218,6 +221,7 @@ extern "C" { #define FL_status_string_eof_length 5 #define FL_status_string_eol_length 5 #define FL_status_string_eos_length 5 + #define FL_status_string_exist_length 7 #define FL_status_string_exist_not_length 11 #define FL_status_string_failure_length 9 #define FL_status_string_fork_length 6 @@ -239,7 +243,6 @@ extern "C" { #define FL_status_string_process_too_many_length 18 #define FL_status_string_prohibited_length 12 #define FL_status_string_read_only_length 11 - #define FL_status_string_socket_length 8 #define FL_status_string_space_not_length 11 #define FL_status_string_stop_length 6 #define FL_status_string_syntax_length 8 @@ -247,6 +250,7 @@ extern "C" { #define FL_status_string_unsupported_length 13 #define FL_status_string_utf_length 5 #define FL_status_string_value_length 7 + #define FL_status_string_value_not_length 11 #define FL_status_string_warn_length 6 #define FL_status_string_write_only_length 12 #endif // _di_F_status_basic_ @@ -424,7 +428,7 @@ extern "C" { #define FL_status_string_file_found_not "F_file_found_not" #define FL_status_string_file_open "F_file_open" #define FL_status_string_file_open_max "F_file_open_max" - #define FL_status_string_file_open_not "F_file_open_not" + #define FL_status_string_file_opened "F_file_opened" #define FL_status_string_file_purge "F_file_purge" #define FL_status_string_file_read "F_file_read" #define FL_status_string_file_reallocation "F_file_reallocation" @@ -464,7 +468,7 @@ extern "C" { #define FL_status_string_file_found_not_length 16 #define FL_status_string_file_open_length 11 #define FL_status_string_file_open_max_length 15 - #define FL_status_string_file_open_not_length 15 + #define FL_status_string_file_opened_length 13 #define FL_status_string_file_purge_length 12 #define FL_status_string_file_read_length 11 #define FL_status_string_file_reallocation_length 19 @@ -508,12 +512,12 @@ extern "C" { #define FL_status_string_directory_closed "F_directory_closed" #define FL_status_string_directory_descriptor "F_directory_descriptor" #define FL_status_string_directory_empty "F_directory_empty" + #define FL_status_string_directory_empty_not "F_directory_empty_not" #define FL_status_string_directory_found "F_directory_found" #define FL_status_string_directory_found_not "F_directory_found_not" #define FL_status_string_directory_flush "F_directory_flush" #define FL_status_string_directory_link_max "F_directory_link_max" #define FL_status_string_directory_open "F_directory_open" - #define FL_status_string_directory_open_not "F_directory_open_not" #define FL_status_string_directory_purge "F_directory_purge" #define FL_status_string_directory_read "F_directory_read" #define FL_status_string_directory_stream "F_directory_stream" @@ -528,12 +532,12 @@ extern "C" { #define FL_status_string_directory_closed_length 18 #define FL_status_string_directory_descriptor_length 22 #define FL_status_string_directory_empty_length 17 + #define FL_status_string_directory_empty_not_length 21 #define FL_status_string_directory_found_length 17 #define FL_status_string_directory_found_not_length 21 #define FL_status_string_directory_flush_length 17 #define FL_status_string_directory_link_max_length 20 #define FL_status_string_directory_open_length 16 - #define FL_status_string_directory_open_not_length 20 #define FL_status_string_directory_purge_length 17 #define FL_status_string_directory_read_length 16 #define FL_status_string_directory_stream_length 18 @@ -545,15 +549,17 @@ extern "C" { #endif // _di_F_status_directory_ #ifndef _di_F_status_socket_ - #define FL_status_string_socket_client "F_socket_connect_client" - #define FL_status_string_socket_target "F_socket_connect_target" + #define FL_status_string_socket "F_socket" + #define FL_status_string_socket_client "F_socket_client" #define FL_status_string_socket_receive "F_socket_receive" #define FL_status_string_socket_send "F_socket_send" + #define FL_status_string_socket_target "F_socket_target" - #define FL_status_string_socket_client_length 23 - #define FL_status_string_socket_target_length 23 + #define FL_status_string_socket_length 8 + #define FL_status_string_socket_client_length 15 #define FL_status_string_socket_receive_length 16 #define FL_status_string_socket_send_length 13 + #define FL_status_string_socket_target_length 15 #endif // _di_F_status_socket_ #ifndef _di_F_status_compare_ @@ -568,7 +574,7 @@ extern "C" { #define FL_status_string_than_less_length 11 #endif // _di_F_status_compare_ - #ifndef _di_F_status_access_denied_ + #ifndef _di_F_status_access_ #define FL_status_string_access_denied "F_access_denied" #define FL_status_string_access_denied_user "F_access_denied_user" #define FL_status_string_access_denied_group "F_access_denied_group" @@ -577,16 +583,32 @@ extern "C" { #define FL_status_string_access_denied_write "F_access_denied_write" #define FL_status_string_access_denied_execute "F_access_denied_execute" #define FL_status_string_access_denied_super "F_access_denied_super" - - #define FL_status_string_access_denied_length 15 - #define FL_status_string_access_denied_user_length 20 - #define FL_status_string_access_denied_group_length 21 - #define FL_status_string_access_denied_world_length 21 - #define FL_status_string_access_denied_read_length 20 - #define FL_status_string_access_denied_write_length 21 - #define FL_status_string_access_denied_execute_length 23 - #define FL_status_string_access_denied_super_length 21 - #endif // _di_F_status_access_denied_ + #define FL_status_string_access_granted "F_access_granted" + #define FL_status_string_access_granted_user "F_access_granted_user" + #define FL_status_string_access_granted_group "F_access_granted_group" + #define FL_status_string_access_granted_world "F_access_granted_world" + #define FL_status_string_access_granted_read "F_access_granted_read" + #define FL_status_string_access_granted_write "F_access_granted_write" + #define FL_status_string_access_granted_execute "F_access_granted_execute" + #define FL_status_string_access_granted_super "F_access_granted_super" + + #define FL_status_string_access_denied_length 15 + #define FL_status_string_access_denied_user_length 20 + #define FL_status_string_access_denied_group_length 21 + #define FL_status_string_access_denied_world_length 21 + #define FL_status_string_access_denied_read_length 20 + #define FL_status_string_access_denied_write_length 21 + #define FL_status_string_access_denied_execute_length 23 + #define FL_status_string_access_denied_super_length 21 + #define FL_status_string_access_granted_length 16 + #define FL_status_string_access_granted_user_length 21 + #define FL_status_string_access_granted_group_length 22 + #define FL_status_string_access_granted_world_length 22 + #define FL_status_string_access_granted_read_length 21 + #define FL_status_string_access_granted_write_length 22 + #define FL_status_string_access_granted_execute_length 24 + #define FL_status_string_access_granted_super_length 22 + #endif // _di_F_status_access_ #define FL_status_string_status_code_last "F_status_code_last" diff --git a/level_1/fl_utf_file/c/private-utf_file.h b/level_1/fl_utf_file/c/private-utf_file.h index dc1f6fc..3515315 100644 --- a/level_1/fl_utf_file/c/private-utf_file.h +++ b/level_1/fl_utf_file/c/private-utf_file.h @@ -40,7 +40,7 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * * @see fl_utf_file_write() diff --git a/level_1/fl_utf_file/c/utf_file.c b/level_1/fl_utf_file/c/utf_file.c index ed131b1..02dc7af 100644 --- a/level_1/fl_utf_file/c/utf_file.c +++ b/level_1/fl_utf_file/c/utf_file.c @@ -12,7 +12,8 @@ extern "C" { if (buffer->used > buffer->size) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); f_status status = F_none; @@ -87,7 +88,8 @@ extern "C" { if (buffer->used > buffer->size) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); f_status status = F_none; @@ -162,7 +164,8 @@ extern "C" { if (buffer->used > buffer->size) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); f_status status = F_none; @@ -245,7 +248,8 @@ extern "C" { if (buffer.used >= buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); if (buffer.used == 0) { *written = 0; @@ -268,7 +272,8 @@ extern "C" { if (buffer.used >= buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); if (buffer.used == 0) { *written = 0; @@ -297,7 +302,8 @@ extern "C" { if (buffer.used >= buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); if (buffer.used == 0 || total == 0) { *written = 0; @@ -328,7 +334,8 @@ extern "C" { if (range.start >= buffer.used) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (file.id <= 0) return F_status_set_error(F_file_open_not); + if (file.id < 0) return F_status_set_error(F_file); + if (file.id == 0) return F_status_set_error(F_file_closed); if (buffer.used == 0) { *written = 0; diff --git a/level_1/fl_utf_file/c/utf_file.h b/level_1/fl_utf_file/c/utf_file.h index b93f4c3..f418e97 100644 --- a/level_1/fl_utf_file/c/utf_file.h +++ b/level_1/fl_utf_file/c/utf_file.h @@ -45,7 +45,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * F_incomplete_utf_eof (with error bit) if UTF-8 character was incomplete at the end of the file. * @@ -76,7 +77,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * F_incomplete_utf_eof (with error bit) if UTF-8 character was incomplete at the end of the file. * @@ -108,7 +110,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * F_incomplete_utf_eof (with error bit) if UTF-8 character was incomplete at the end of the file. * @@ -138,7 +141,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * F_incomplete_utf_stop (with error bit) if UTF-8 character was incomplete at the stop location. * F_incomplete_utf_eos (with error bit) if UTF-8 character was incomplete at the end of the string. @@ -171,7 +175,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * F_incomplete_utf_stop (with error bit) if UTF-8 character was incomplete at the stop location. * F_incomplete_utf_eos (with error bit) if UTF-8 character was incomplete at the end of the string. @@ -205,7 +210,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * F_incomplete_utf_stop (with error bit) if UTF-8 character was incomplete at the stop location. * F_incomplete_utf_eos (with error bit) if UTF-8 character was incomplete at the end of the string. @@ -239,7 +245,8 @@ extern "C" { * F_buffer (with error bit) if the buffer is invalid. * F_interrupted (with error bit) if interrupt was received. * F_input_output (with error bit) on I/O error. - * F_file_open_not (with error bit) if file is not open. + * F_file (with error bit) if file descriptor is in an error state. + * F_file_closed (with error bit) if file is not open. * F_file_type_directory (with error bit) if file descriptor represents a directory. * F_incomplete_utf_stop (with error bit) if UTF-8 character was incomplete at the stop location. * F_incomplete_utf_eos (with error bit) if UTF-8 character was incomplete at the end of the string. diff --git a/level_2/fll_file/c/file.c b/level_2/fll_file/c/file.c index d71a867..c1d4e47 100644 --- a/level_2/fll_file/c/file.c +++ b/level_2/fll_file/c/file.c @@ -10,7 +10,7 @@ extern "C" { if (status == F_memory_allocation || status == F_memory_reallocation) { fl_color_print_line(file, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory."); } - else if (status == F_file_open_not) { + else if (status == F_file_closed) { fl_color_print(file, context.error, context.reset, "INTERNAL ERROR: The file '"); fl_color_print(file, context.notable, context.reset, "%s", file_name); fl_color_print_line(file, context.error, context.reset, "' is no longer open."); diff --git a/level_2/fll_status/c/status.c b/level_2/fll_status/c/status.c index ef48cac..8d27a96 100644 --- a/level_2/fll_status/c/status.c +++ b/level_2/fll_status/c/status.c @@ -381,6 +381,11 @@ extern "C" { return F_none; } + if (fl_string_compare(string, FL_status_string_connected, length, FL_status_string_connected_length) == F_equal_to) { + *code = F_connected; + return F_none; + } + if (fl_string_compare(string, FL_status_string_connected_not, length, FL_status_string_connected_not_length) == F_equal_to) { *code = F_connected_not; return F_none; @@ -421,6 +426,11 @@ extern "C" { return F_none; } + if (fl_string_compare(string, FL_status_string_exist, length, FL_status_string_exist_length) == F_equal_to) { + *code = F_exist; + return F_none; + } + if (fl_string_compare(string, FL_status_string_exist_not, length, FL_status_string_exist_not_length) == F_equal_to) { *code = F_exist_not; return F_none; @@ -526,11 +536,6 @@ extern "C" { return F_none; } - if (fl_string_compare(string, FL_status_string_socket, length, FL_status_string_socket_length) == F_equal_to) { - *code = F_socket; - return F_none; - } - if (fl_string_compare(string, FL_status_string_space_not, length, FL_status_string_space_not_length) == F_equal_to) { *code = F_space_not; return F_none; @@ -566,6 +571,11 @@ extern "C" { return F_none; } + if (fl_string_compare(string, FL_status_string_value_not, length, FL_status_string_value_not_length) == F_equal_to) { + *code = F_value_not; + return F_none; + } + if (fl_string_compare(string, FL_status_string_warn, length, FL_status_string_warn_length) == F_equal_to) { *code = F_warn; return F_none; @@ -998,8 +1008,8 @@ extern "C" { return F_none; } - if (fl_string_compare(string, FL_status_string_file_open_not, length, FL_status_string_file_open_not_length) == F_equal_to) { - *code = F_file_open_not; + if (fl_string_compare(string, FL_status_string_file_opened, length, FL_status_string_file_opened_length) == F_equal_to) { + *code = F_file_opened; return F_none; } @@ -1172,6 +1182,11 @@ extern "C" { return F_none; } + if (fl_string_compare(string, FL_status_string_directory_empty_not, length, FL_status_string_directory_empty_not_length) == F_equal_to) { + *code = F_directory_empty_not; + return F_none; + } + if (fl_string_compare(string, FL_status_string_directory_found, length, FL_status_string_directory_found_length) == F_equal_to) { *code = F_directory_found; return F_none; @@ -1197,11 +1212,6 @@ extern "C" { return F_none; } - if (fl_string_compare(string, FL_status_string_directory_open_not, length, FL_status_string_directory_open_not_length) == F_equal_to) { - *code = F_directory_open_not; - return F_none; - } - if (fl_string_compare(string, FL_status_string_directory_purge, length, FL_status_string_directory_purge_length) == F_equal_to) { *code = F_directory_purge; return F_none; @@ -1244,13 +1254,13 @@ extern "C" { #endif // _di_F_status_directory_ #ifndef _di_F_status_socket_ - if (fl_string_compare(string, FL_status_string_socket_client, length, FL_status_string_socket_client_length) == F_equal_to) { - *code = F_socket_connect_client; + if (fl_string_compare(string, FL_status_string_socket, length, FL_status_string_socket_length) == F_equal_to) { + *code = F_socket; return F_none; } - if (fl_string_compare(string, FL_status_string_socket_target, length, FL_status_string_socket_target_length) == F_equal_to) { - *code = F_socket_connect_target; + if (fl_string_compare(string, FL_status_string_socket_client, length, FL_status_string_socket_client_length) == F_equal_to) { + *code = F_socket_client; return F_none; } @@ -1263,6 +1273,11 @@ extern "C" { *code = F_socket_send; return F_none; } + + if (fl_string_compare(string, FL_status_string_socket_target, length, FL_status_string_socket_target_length) == F_equal_to) { + *code = F_socket_target; + return F_none; + } #endif // _di_F_status_socket_ #ifndef _di_F_status_compare_ @@ -1287,7 +1302,7 @@ extern "C" { } #endif // _di_F_status_compare_ - #ifndef _di_F_status_access_denied_ + #ifndef _di_F_status_access_ if (fl_string_compare(string, FL_status_string_access_denied, length, FL_status_string_access_denied_length) == F_equal_to) { *code = F_access_denied; return F_none; @@ -1327,7 +1342,47 @@ extern "C" { *code = F_access_denied_super; return F_none; } - #endif // _di_F_status_access_denied_ + + if (fl_string_compare(string, FL_status_string_access_granted, length, FL_status_string_access_granted_length) == F_equal_to) { + *code = F_access_granted; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_access_granted_user, length, FL_status_string_access_granted_user_length) == F_equal_to) { + *code = F_access_granted_user; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_access_granted_group, length, FL_status_string_access_granted_group_length) == F_equal_to) { + *code = F_access_granted_group; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_access_granted_world, length, FL_status_string_access_granted_world_length) == F_equal_to) { + *code = F_access_granted_world; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_access_granted_read, length, FL_status_string_access_granted_read_length) == F_equal_to) { + *code = F_access_granted_read; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_access_granted_write, length, FL_status_string_access_granted_write_length) == F_equal_to) { + *code = F_access_granted_write; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_access_granted_execute, length, FL_status_string_access_granted_execute_length) == F_equal_to) { + *code = F_access_granted_execute; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_access_granted_super, length, FL_status_string_access_granted_super_length) == F_equal_to) { + *code = F_access_granted_super; + return F_none; + } + #endif // _di_F_status_access_ if (fl_string_compare(string, FL_status_string_status_code_last, length, FL_status_string_status_code_last_length) == F_equal_to) { *code = F_status_code_last; diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index aab6107..2349c0b 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -625,7 +625,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const else if (status == F_number_overflow) { fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Integer overflow while trying to buffer the file '%.*s'", file_path.used, file_path.string); } - else if (status == F_file_open_not) { + else if (status == F_file_closed) { fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: The file '%.*s' is no longer open", file_path.used, file_path.string); } else if (status == F_file_seek) { @@ -1380,7 +1380,7 @@ f_return_status firewall_buffer_rules(const f_string filename, const bool option else if (status == F_number_overflow) { fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'.", filename); } - else if (status == F_file_open_not) { + else if (status == F_file_closed) { fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open.", filename); } else if (status == F_file_seek) { diff --git a/level_3/init/c/private-init.c b/level_3/init/c/private-init.c index 1d8cae7..a6049c8 100644 --- a/level_3/init/c/private-init.c +++ b/level_3/init/c/private-init.c @@ -52,7 +52,7 @@ fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_read_until()."); } else if (status == F_number_overflow) { fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'.", filename); - } else if (status == F_file_open_not) { + } else if (status == F_file_closed) { fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: The file '%s' is no longer open.", filename); } else if (status == F_file_seek) { fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: A seek error occurred while accessing the file '%s'.", filename);