From 692892731eb89387417808d203c50f9eb0e9a1aa Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 23 May 2020 00:35:03 -0500 Subject: [PATCH] Update: get the level_3 / programs working after major file / directory changes This required making some fixes in the files related code. This puts the UTF-8 file (utf_file) project notably behind an additional work is necessary to get that working correctly as well as having it be consistent with f_file. I've decided that when written pointer is 0, then the caller is requesting to not get back the written size. I am very likely going to do similar behavior with null pointers in other uses, which will help further simplify the design. Other minor changes. Of particular note is moving flags into the f_file structure. This was effectively how the pre-file redesign worked, but it uses flags now instead of the "r", "rw", "a", etc.. string modes used by fopen. Make sure an append flag is available. --- level_0/f_file/c/file.c | 107 +++++-- level_0/f_file/c/file.h | 71 ++--- level_0/f_file/c/private-file.c | 41 +-- level_0/f_file/c/private-file.h | 101 +++++-- level_0/f_pipe/c/pipe.c | 14 +- level_0/f_pipe/c/pipe.h | 34 +-- level_0/f_status/c/status.h | 7 + level_0/f_type/c/type.h | 21 +- level_1/fl_fss/c/fss.h | 4 +- level_1/fl_status/c/status.c | 21 ++ level_1/fl_status/c/status.h | 21 ++ level_1/fl_utf_file/c/utf_file.c | 6 +- level_2/fll_execute/c/execute.c | 4 +- level_2/fll_file/c/file.h | 2 +- level_2/fll_program/c/program.c | 84 +++--- level_2/fll_status/c/status.c | 35 +++ level_3/byte_dump/c/byte_dump.c | 116 ++++---- level_3/byte_dump/c/main.c | 2 +- level_3/byte_dump/c/private-byte_dump.c | 200 +++++++------ level_3/fake/c/fake.c | 36 +-- level_3/fake/c/private-build.c | 114 ++++---- level_3/fake/c/private-clean.c | 6 +- level_3/fake/c/private-fake.c | 234 +++++++-------- level_3/fake/c/private-skeleton.c | 28 +- level_3/firewall/c/firewall.c | 82 +++--- level_3/firewall/c/main.c | 2 +- level_3/firewall/c/private-firewall.c | 314 ++++++++++----------- level_3/firewall/c/private-firewall.h | 2 +- .../fss_basic_list_read/c/fss_basic_list_read.c | 138 ++++----- level_3/fss_basic_list_read/c/main.c | 2 +- .../c/private-fss_basic_list_read.c | 232 +++++++-------- .../fss_basic_list_write/c/fss_basic_list_write.c | 43 +-- level_3/fss_basic_list_write/c/main.c | 2 +- level_3/fss_basic_read/c/fss_basic_read.c | 138 ++++----- level_3/fss_basic_read/c/main.c | 2 +- level_3/fss_basic_read/c/private-fss_basic_read.c | 232 +++++++-------- level_3/fss_basic_write/c/fss_basic_write.c | 43 +-- .../c/fss_extended_list_read.c | 136 ++++----- .../c/fss_extended_list_read.h | 2 +- level_3/fss_extended_list_read/c/main.c | 2 +- .../c/private-fss_extended_list_read.c | 234 +++++++-------- level_3/fss_extended_read/c/fss_extended_read.c | 138 ++++----- level_3/fss_extended_read/c/main.c | 2 +- .../c/private-fss_extended_read.c | 252 ++++++++--------- level_3/fss_extended_write/c/fss_extended_write.c | 53 ++-- level_3/fss_extended_write/c/main.c | 2 +- level_3/fss_status_code/c/fss_status_code.c | 32 +-- level_3/fss_status_code/c/main.c | 2 +- .../fss_status_code/c/private-fss_status_code.c | 20 +- level_3/init/c/init.c | 8 +- level_3/init/c/main.c | 2 +- level_3/init/c/private-init.c | 66 ++--- level_3/status_code/c/main.c | 2 +- level_3/status_code/c/private-status_code.c | 20 +- level_3/status_code/c/status_code.c | 32 +-- 55 files changed, 1876 insertions(+), 1670 deletions(-) diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index 0ef6071..c7a1c56 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -344,22 +344,22 @@ extern "C" { #endif // _di_f_file_is_at_ #ifndef _di_f_file_open_ - f_return_status f_file_open(const f_string path, const int flags, const mode_t mode, f_file *file) { + f_return_status f_file_open(const f_string path, const mode_t mode, f_file *file) { #ifndef _di_level_0_parameter_checking_ if (file == 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_file_open(path, mode, flags, file); + return private_f_file_open(path, mode, file); } #endif // _di_f_file_open_ #ifndef _di_f_file_open_at_ - f_return_status f_file_open_at(const int at_id, const f_string path, const int flags, const mode_t mode, f_file *file) { + f_return_status f_file_open_at(const int at_id, const f_string path, const mode_t mode, f_file *file) { #ifndef _di_level_0_parameter_checking_ if (file == 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_file_open_at(at_id, path, flags, mode, file); + return private_f_file_open_at(at_id, path, mode, file); } #endif // _di_f_file_open_at_ @@ -367,7 +367,7 @@ extern "C" { f_return_status f_file_read(const f_file file, f_string_dynamic *buffer) { #ifndef _di_level_0_parameter_checking_ if (file.size_read == 0) return f_status_set_error(f_invalid_parameter); - if (buffer->used >= buffer->size) return f_status_set_error(f_invalid_parameter); + if (buffer->used > buffer->size) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ if (file.id <= 0) return f_status_set_error(f_file_not_open); @@ -417,7 +417,7 @@ extern "C" { f_return_status f_file_read_block(const f_file file, f_string_dynamic *buffer) { #ifndef _di_level_0_parameter_checking_ if (file.size_read == 0) return f_status_set_error(f_invalid_parameter); - if (buffer->used >= buffer->size) return f_status_set_error(f_invalid_parameter); + if (buffer->used > buffer->size) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ if (file.id <= 0) return f_status_set_error(f_file_not_open); @@ -467,7 +467,7 @@ extern "C" { f_return_status f_file_read_until(const f_file file, f_string_dynamic *buffer, const f_string_length total) { #ifndef _di_level_0_parameter_checking_ if (file.size_read == 0) return f_status_set_error(f_invalid_parameter); - if (buffer->used >= buffer->size) return f_status_set_error(f_invalid_parameter); + if (buffer->used > buffer->size) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ if (file.id <= 0) return f_status_set_error(f_file_not_open); @@ -696,14 +696,26 @@ extern "C" { if (file.id <= 0) return f_status_set_error(f_file_not_open); if (buffer.used == 0) { - *written = 0; + if (written) *written = 0; return f_no_data; } - f_status status = private_f_file_write_until(file, buffer.string, buffer.used, written); - if (f_status_is_error(status)) return f_status_set_error(status); + f_status status = f_none; + + if (written) { + private_f_file_write_until(file, buffer.string, buffer.used, written); + + if (status == f_none && *written == buffer.used) return f_none_on_eos; + } + else { + f_string_length written_local = 0; - if (status == f_none && *written == buffer.used) return f_none_on_eos; + private_f_file_write_until(file, buffer.string, buffer.used, &written_local); + + if (status == f_none && written_local == buffer.used) return f_none_on_eos; + } + + if (f_status_is_error(status)) return f_status_set_error(status); return status; } @@ -719,7 +731,7 @@ extern "C" { if (file.id <= 0) return f_status_set_error(f_file_not_open); if (buffer.used == 0) { - *written = 0; + if (written) *written = 0; return f_no_data; } @@ -729,10 +741,26 @@ extern "C" { write_max = buffer.used; } - f_status status = private_f_file_write_until(file, buffer.string, write_max, written); - if (f_status_is_error(status)) return f_status_set_error(status); + f_status status = f_none; + + if (written) { + private_f_file_write_until(file, buffer.string, write_max, written); - if (status == f_none && *written == buffer.used) return f_none_on_eos; + if (status == f_none) { + if (*written == buffer.used) return f_none_on_eos; + if (*written == write_max) return f_none_on_stop; + } + } + else { + f_string_length written_local = 0; + + private_f_file_write_until(file, buffer.string, write_max, &written_local); + + if (status == f_none) { + if (written_local == buffer.used) return f_none_on_eos; + if (written_local == write_max) return f_none_on_stop; + } + } return status; } @@ -748,7 +776,7 @@ extern "C" { if (file.id <= 0) return f_status_set_error(f_file_not_open); if (buffer.used == 0 || total == 0) { - *written = 0; + if (written) *written = 0; return f_no_data; } @@ -758,10 +786,26 @@ extern "C" { write_max = buffer.used; } - f_status status = private_f_file_write_until(file, buffer.string, write_max, written); - if (f_status_is_error(status)) return f_status_set_error(status); + f_status status = f_none; + + if (written) { + private_f_file_write_until(file, buffer.string, write_max, written); - if (status == f_none && *written == buffer.used) return f_none_on_eos; + if (status == f_none) { + if (*written == buffer.used) return f_none_on_eos; + if (*written == write_max) return f_none_on_stop; + } + } + else { + f_string_length written_local = 0; + + private_f_file_write_until(file, buffer.string, buffer.used, &written_local); + + if (status == f_none) { + if (written_local == buffer.used) return f_none_on_eos; + if (written_local == write_max) return f_none_on_stop; + } + } return status; } @@ -779,7 +823,7 @@ extern "C" { if (file.id <= 0) return f_status_set_error(f_file_not_open); if (buffer.used == 0) { - *written = 0; + if (written) *written = 0; return f_no_data; } @@ -790,12 +834,25 @@ extern "C" { write_max = buffer.used; } - f_status status = private_f_file_write_until(file, buffer.string + range.start, write_max, written); - if (f_status_is_error(status)) return f_status_set_error(status); + f_status status = f_none; + + if (written) { + private_f_file_write_until(file, buffer.string + range.start, write_max, written); + + if (status == f_none) { + if (range.start + *written == buffer.used) return f_none_on_stop; + if (range.start + *written == total) return f_none_on_eos; + } + } + else { + f_string_length written_local = 0; - if (status == f_none) { - if (range.start + *written == total) return f_none_on_stop; - if (range.start + *written == buffer.used) return f_none_on_eos; + private_f_file_write_until(file, buffer.string + range.start, write_max, &written_local); + + if (status == f_none) { + if (range.start + written_local == buffer.used) return f_none_on_eos; + if (range.start + written_local == total) return f_none_on_stop; + } } return status; diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 321a042..efbec56 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -86,16 +86,19 @@ extern "C" { * Commonly used file related properties. * * id: File descriptor. - * size_block: The default number of 1-byte characters to read at a time and is often used for the read/write buffer size. + * flags: Flags used for opening the file. + * size_read: The default number of 1-byte characters to read at a time and is often used for the read buffer size. + * size_write: The default number of 1-byte characters to read at a time and is often used for the write buffer size. */ #ifndef _di_f_file_ typedef struct { int id; + int flags; size_t size_read; size_t size_write; } f_file; - #define f_file_initialize { 0, f_file_default_read_size, f_file_default_write_size } + #define f_file_initialize { 0, O_RDONLY, f_file_default_read_size, f_file_default_write_size } #endif // _di_f_file_ /** @@ -140,6 +143,10 @@ extern "C" { #define f_file_flag_truncate_rw (O_CREAT | O_TRUNC | O_RDRW) #define f_file_flag_truncate_wo (O_CREAT | O_TRUNC | O_WRONLY) + // file open flags pre-combined will truncate any existing files to 0. + #define f_file_flag_append_rw (O_CREAT | O_APPEND | O_RDRW) + #define f_file_flag_append_wo (O_CREAT | O_APPEND | O_WRONLY) + // file open flags pre-combined with synchronous io. #define f_file_flag_sync_ro (O_SYNC | O_RDONLY) #define f_file_flag_sync_wo (O_SYNC | O_WRONLY) @@ -242,6 +249,30 @@ extern "C" { #endif // _di_f_file_modes_ /** + * Check if a file can be accessed. + * + * @param path + * The path file name. + * + * @return + * f_true if file exists. + * f_false if file does not exist. + * f_invalid_parameter (with error bit) if a parameter is invalid. + * f_invalid_name (with error bit) if the filename is too long. + * f_out_of_memory (with error bit) if out of memory. + * f_number_overflow (with error bit) on overflow error. + * f_invalid_directory (with error bit) on invalid directory. + * f_access_denied (with error bit) on access denied. + * f_loop (with error bit) on loop error. + * f_false (with error bit) on unknown/unhandled errors. + * + * @see access() + */ +#ifndef _di_f_file_access_ + extern f_return_status f_file_access(const f_string path); +#endif // _di_f_file_access_ + +/** * Change mode of a given file at the specified path. * * @param path @@ -368,30 +399,6 @@ extern "C" { #endif // _di_f_file_change_owner_at_ /** - * Check if a file can be accessed. - * - * @param path - * The path file name. - * - * @return - * f_true if file exists. - * f_false if file does not exist. - * f_invalid_parameter (with error bit) if a parameter is invalid. - * f_invalid_name (with error bit) if the filename is too long. - * f_out_of_memory (with error bit) if out of memory. - * f_number_overflow (with error bit) on overflow error. - * f_invalid_directory (with error bit) on invalid directory. - * f_access_denied (with error bit) on access denied. - * f_loop (with error bit) on loop error. - * f_false (with error bit) on unknown/unhandled errors. - * - * @see access() - */ -#ifndef _di_f_file_access_ - extern f_return_status f_file_access(const f_string path); -#endif // _di_f_file_access_ - -/** * Copy a file. * * The paths must not contain NULL except for the terminating NULL. @@ -827,8 +834,6 @@ extern "C" { * * @param path * The path file name. - * @param flags - * Any valid flag, such as AT_EMPTY_PATH, AT_NO_AUTOMOUNT, or AT_SYMLINK_NO_FOLLOW. * @param mode * The file mode to open in. * Set to 0 to not use. @@ -846,7 +851,7 @@ extern "C" { * @see open() */ #ifndef _di_f_file_open_ - extern f_return_status f_file_open(const f_string path, const int flags, const mode_t mode, f_file *file); + extern f_return_status f_file_open(const f_string path, const mode_t mode, f_file *file); #endif // _di_f_file_open_ /** @@ -858,8 +863,6 @@ extern "C" { * The parent directory, as an open directory file descriptor, in which path is relative to. * @param path * The path file name. - * @param flags - * Any valid flag, such as AT_EMPTY_PATH, AT_NO_AUTOMOUNT, or AT_SYMLINK_NO_FOLLOW. * @param mode * The file mode to open in. * Set to 0 to not use. @@ -877,7 +880,7 @@ extern "C" { * @see openat() */ #ifndef _di_f_file_open_at_ - extern f_return_status f_file_open_at(const int at_id, const f_string path, const int flags, const mode_t mode, f_file *file); + extern f_return_status f_file_open_at(const int at_id, const f_string path, const mode_t mode, f_file *file); #endif // _di_f_file_open_at_ /** @@ -1234,6 +1237,7 @@ extern "C" { * The buffer to write to the file. * @param written * The total bytes written. + * Set pointer to 0 to not use. * * @return * f_none on success. @@ -1265,6 +1269,7 @@ extern "C" { * The buffer to write to the file. * @param written * The total bytes written. + * Set pointer to 0 to not use. * * @return * f_none on success. @@ -1296,6 +1301,7 @@ extern "C" { * The total bytes to write, unless end of buffer is reached first. * @param written * The total bytes written. + * Set pointer to 0 to not use. * * @return * f_none on success. @@ -1328,6 +1334,7 @@ extern "C" { * An inclusive start an stop range within the buffer to read. * @param written * The total bytes written. + * Set pointer to 0 to not use. * * @return * f_none on success. diff --git a/level_0/f_file/c/private-file.c b/level_0/f_file/c/private-file.c index 5e1728b..fca39e3 100644 --- a/level_0/f_file/c/private-file.c +++ b/level_0/f_file/c/private-file.c @@ -119,10 +119,13 @@ extern "C" { f_file file_source = f_file_initialize; f_file file_destination = f_file_initialize; - f_status status = private_f_file_open(source, f_file_flag_read_only, 0, &file_source); + file_source.flags = f_file_flag_read_only; + file_destination.flags = f_file_flag_write_only | f_file_flag_no_follow; + + f_status status = private_f_file_open(source, 0, &file_source); if (f_status_is_error(status)) return status; - status = private_f_file_open(destination, f_file_flag_write_only | f_file_flag_no_follow, 0, &file_destination); + status = private_f_file_open(destination, 0, &file_destination); if (f_status_is_error(status)) { private_f_file_close(&file_source.id); return status; @@ -156,18 +159,19 @@ extern "C" { #if !defined(_di_f_file_create_) || !defined(_di_f_file_copy_) f_return_status private_f_file_create(const f_string path, const mode_t mode, const bool exclusive, const bool dereference) { - int flags = O_CLOEXEC | O_CREAT | O_WRONLY; + f_file file = f_file_initialize; + + file.flags = O_CLOEXEC | O_CREAT | O_WRONLY; if (exclusive) { - flags |= O_EXCL; + file.flags |= O_EXCL; } if (!dereference) { - flags |= O_NOFOLLOW; + file.flags |= O_NOFOLLOW; } - f_file file = f_file_initialize; - f_status status = private_f_file_open(path, mode, flags, &file); + f_status status = private_f_file_open(path, mode, &file); if (file.id > 0) { return private_f_file_close(&file.id); @@ -179,18 +183,19 @@ extern "C" { #if !defined(_di_f_file_create_at_) || !defined(_di_f_file_copy_at_) f_return_status private_f_file_create_at(const int at_id, const f_string path, const mode_t mode, const bool exclusive, const bool dereference) { - int flags = O_CLOEXEC | O_CREAT | O_WRONLY; + f_file file = f_file_initialize; + + file.flags = O_CLOEXEC | O_CREAT | O_WRONLY; if (exclusive) { - flags |= O_EXCL; + file.flags |= O_EXCL; } if (!dereference) { - flags |= O_NOFOLLOW; + file.flags |= O_NOFOLLOW; } - f_file file = f_file_initialize; - f_status status = private_f_file_open_at(at_id, path, flags, mode, &file); + f_status status = private_f_file_open_at(at_id, path, mode, &file); if (file.id > 0) { return private_f_file_close(&file.id); @@ -275,12 +280,12 @@ extern "C" { #endif // !defined(_di_f_file_link_at_) || !defined(_di_f_file_copy_at_) #if !defined(_di_f_file_open_) || !defined(_di_f_file_copy_) - f_return_status private_f_file_open(const f_string path, const int flags, const mode_t mode, f_file *file) { + f_return_status private_f_file_open(const f_string path, const mode_t mode, f_file *file) { if (mode == 0) { - file->id = open(path, flags); + file->id = open(path, file->flags); } else { - file->id = open(path, flags, mode); + file->id = open(path, file->flags, mode); } if (file->id < 0) { @@ -310,12 +315,12 @@ extern "C" { #endif // !defined(_di_f_file_open_) || !defined(_di_f_file_copy_) #if !defined(_di_f_file_open_at_) || !defined(_di_f_file_copy_at_) - f_return_status private_f_file_open_at(const int at_id, const f_string path, const int flags, const mode_t mode, f_file *file) { + f_return_status private_f_file_open_at(const int at_id, const f_string path, const mode_t mode, f_file *file) { if (mode == 0) { - file->id = openat(at_id, path, flags); + file->id = openat(at_id, path, file->flags); } else { - file->id = openat(at_id, path, flags, mode); + file->id = openat(at_id, path, file->flags, mode); } if (file->id < 0) { diff --git a/level_0/f_file/c/private-file.h b/level_0/f_file/c/private-file.h index b63c22e..83013f6 100644 --- a/level_0/f_file/c/private-file.h +++ b/level_0/f_file/c/private-file.h @@ -43,6 +43,7 @@ extern "C" { * f_failure (with error bit) for any other (mkdir()) error. * * @see f_file_change_mode() + * @see f_file_copy() */ #if !defined(_di_f_file_change_mode_) || !defined(_di_f_file_copy_) extern f_return_status private_f_file_change_mode(const f_string path, const mode_t mode, const bool dereference) f_gcc_attribute_visibility_internal; @@ -77,6 +78,7 @@ extern "C" { * f_failure (with error bit) for any other (mkdir()) error. * * @see f_file_change_mode_at() + * @see f_file_copy_at() */ #if !defined(_di_f_file_change_mode_at_) || !defined(_di_f_file_copy_at_) extern f_return_status private_f_file_change_mode_at(const int at_id, const f_string path, const mode_t mode, const int flags) f_gcc_attribute_visibility_internal; @@ -112,6 +114,7 @@ extern "C" { * f_failure (with error bit) for any other (mkdir()) error. * * @see f_file_change_owner() + * @see f_file_copy() */ #if !defined(_di_f_file_change_owner_) || !defined(_di_f_file_copy_) extern f_return_status private_f_file_change_owner(const f_string path, const uid_t uid, const gid_t gid, const bool dereference) f_gcc_attribute_visibility_internal; @@ -148,6 +151,7 @@ extern "C" { * f_failure (with error bit) for any other (mkdir()) error. * * @see f_file_change_owner_at() + * @see f_file_copy_at() */ #if !defined(_di_f_file_change_owner_at_) || !defined(_di_f_file_copy_at_) extern f_return_status private_f_file_change_owner_at(const int at_id, const f_string path, const uid_t uid, const gid_t gid, const int flags) f_gcc_attribute_visibility_internal; @@ -173,6 +177,7 @@ extern "C" { * f_file_error_close (with error bit) if fclose() failed for any other reason. * * @see f_file_close() + * @see f_file_copy() */ #if !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) extern f_return_status private_f_file_close(int *id) f_gcc_attribute_visibility_internal; @@ -235,11 +240,17 @@ extern "C" { * The path file name. * @param mode * The file mode to open in. - * @param flags - * Any valid flag, such as AT_EMPTY_PATH, AT_NO_AUTOMOUNT, or AT_SYMLINK_NO_FOLLOW. * @param file * The data related to the file being opened. * This will be updated with the file descriptor and file address. + * This will be updated with the create flags (ignoring and overriding existing file.flags). + * @param exclusive + * If TRUE, will fail when file already exists. + * If FALSE, will not fail if file already exists. + * @param dereference + * Set to TRUE to dereferenc symlinks (often is what is desired). + * Set to FALSE to fail if the path is a symbolic link. + * This does not write symbolic links. (@todo add function f_create_link() for creating symbolic links.) * * @return * f_none on success. @@ -261,6 +272,7 @@ extern "C" { * f_file_max_open (with error bit) when system-wide max open files is reached. * f_busy (with error bit) if filesystem is too busy to perforrm write. * + * @see f_file_copy() * @see f_file_create() */ #if !defined(_di_f_file_create_) || !defined(_di_f_file_copy_) @@ -277,12 +289,18 @@ extern "C" { * @param file * The data related to the file being opened. * This will be updated with the file descriptor and file address. + * This will be updated with the create flags (ignoring and overriding existing file.flags). * @param path * The path file name. * @param mode * The file mode to open in. - * @param flags - * Any valid flag, such as AT_EMPTY_PATH, AT_NO_AUTOMOUNT, or AT_SYMLINK_NO_FOLLOW. + * @param exclusive + * If TRUE, will fail when file already exists. + * If FALSE, will not fail if file already exists. + * @param dereference + * Set to TRUE to dereferenc symlinks (often is what is desired). + * Set to FALSE to fail if the path is a symbolic link. + * This does not write symbolic links. (@todo add function f_create_link() for creating symbolic links.) * * @return * f_none on success. @@ -304,6 +322,7 @@ extern "C" { * f_file_max_open (with error bit) when system-wide max open files is reached. * f_busy (with error bit) if filesystem is too busy to perforrm write. * + * @see f_file_copy_at() * @see f_file_create_at() */ #if !defined(_di_f_file_create_at_) || !defined(_di_f_file_copy_at_) @@ -322,6 +341,7 @@ extern "C" { * * @return * + * @see f_file_copy() * @see f_file_link() */ #if !defined(_di_f_file_link_) || !defined(_di_f_file_copy_) @@ -342,6 +362,7 @@ extern "C" { * * @return * + * @see f_file_copy_at() * @see f_file_link_at() */ #if !defined(_di_f_file_link_at_) || !defined(_di_f_file_copy_at_) @@ -366,6 +387,8 @@ extern "C" { * f_unsupported (with error bit) if the file system or file type does not support flushing. * f_failure (with error bit) on any other failure. * + * @see f_file_close() + * @see f_file_copy() * @see f_file_flush() */ #if !defined(_di_f_file_flush_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) @@ -373,14 +396,52 @@ extern "C" { #endif // !defined(_di_f_file_flush_) || !defined(_di_f_file_close_) || !defined(_di_f_file_copy_) /** + * Create a link to a file. + * + * This will not replace existing files/links. + * + * @param target + * A path that the link points to. + * @param point + * A path to the link that does the pointing. + * + * @return + * + * @see f_file_link() + * @see f_file_copy() + */ +#if !defined(_di_f_file_link_) || !defined(_di_f_file_copy_) + extern f_return_status private_f_file_link(const f_string target, const f_string point); +#endif // !defined(_di_f_file_link_) || !defined(_di_f_file_copy_) + +/** + * Create a link to a file. + * + * This will not replace existing files/links. + * + * @param at_id + * The parent directory, as an open directory file descriptor, in which path is relative to. + * @param target + * A path that the link points to. + * @param point + * A path to the link that does the pointing. + * + * @return + * + * @see f_file_link_at() + * @see f_file_copy_at() + */ +#if !defined(_di_f_file_link_at_) || !defined(_di_f_file_copy_at_) + extern f_return_status private_f_file_link_at(const int at_id, const f_string target, const f_string point); +#endif // !defined(_di_f_file_link_at_) || !defined(_di_f_file_copy_at_) + +/** * Private implementation of f_file_open(). * * Intended to be shared to each of the different implementation variations. * * @param path * The path file name. - * @param flags - * Any valid flag, such as AT_EMPTY_PATH, AT_NO_AUTOMOUNT, or AT_SYMLINK_NO_FOLLOW. * @param mode * The file mode to open in. * Set to 0 to not use. @@ -395,10 +456,11 @@ extern "C" { * f_file_error_descriptor (with error bit) if unable to load the file descriptor (the file pointer may still be valid). * f_invalid_parameter (with error bit) if a parameter is invalid. * + * @see f_file_copy() * @see f_file_open() */ #if !defined(_di_f_file_open_) || !defined(_di_f_file_copy_) - extern f_return_status private_f_file_open(const f_string path, const int flags, const mode_t mode, f_file *file) f_gcc_attribute_visibility_internal; + extern f_return_status private_f_file_open(const f_string path, const mode_t mode, f_file *file) f_gcc_attribute_visibility_internal; #endif // !defined(_di_f_file_open_) || !defined(_di_f_file_copy_) /** @@ -410,8 +472,6 @@ extern "C" { * The parent directory, as an open directory file descriptor, in which path is relative to. * @param path * The path file name. - * @param flags - * Any valid flag, such as AT_EMPTY_PATH, AT_NO_AUTOMOUNT, or AT_SYMLINK_NO_FOLLOW. * @param mode * The file mode to open in. * Set to 0 to not use. @@ -426,31 +486,14 @@ extern "C" { * f_file_error_descriptor (with error bit) if unable to load the file descriptor (the file pointer may still be valid). * f_invalid_parameter (with error bit) if a parameter is invalid. * + * @see f_file_copy_at() * @see f_file_open_at() */ #if !defined(_di_f_file_open_at_) || !defined(_di_f_file_copy_at_) - extern f_return_status private_f_file_open_at(const int at_id, const f_string path, const int flags, const mode_t mode, f_file *file) f_gcc_attribute_visibility_internal; + extern f_return_status private_f_file_open_at(const int at_id, const f_string path, const mode_t mode, f_file *file) f_gcc_attribute_visibility_internal; #endif // !defined(_di_f_file_open_at_) || !defined(_di_f_file_copy_at_) /** - * Create a link to a file. - * - * This will not replace existing files/links. - * - * @param target - * A path that the link points to. - * @param point - * A path to the link that does the pointing. - * - * @return - * - * @see f_file_link() - */ -#if !defined(_di_f_file_link_) || !defined(_di_f_file_copy_) - extern f_return_status private_f_file_link(const f_string target, const f_string point); -#endif // !defined(_di_f_file_link_) || !defined(_di_f_file_copy_) - -/** * Private implementation of f_file_close(). * * Intended to be shared to each of the different implementation variations. @@ -474,6 +517,7 @@ extern "C" { * f_loop (with error bit) if a loop occurred. * f_invalid_parameter (with error bit) if a parameter is invalid. * + * @see f_file_copy() * @see f_file_stat() */ #if !defined(_di_f_file_stat_) || !defined(_di_f_file_copy_) @@ -506,6 +550,7 @@ extern "C" { * f_loop (with error bit) if a loop occurred. * f_invalid_parameter (with error bit) if a parameter is invalid. * + * @see f_file_copy_at() * @see f_file_stat_at() */ #if !defined(_di_f_file_stat_at_) || !defined(_di_f_file_copy_at_) diff --git a/level_0/f_pipe/c/pipe.c b/level_0/f_pipe/c/pipe.c index b038b5e..27c59fd 100644 --- a/level_0/f_pipe/c/pipe.c +++ b/level_0/f_pipe/c/pipe.c @@ -4,11 +4,11 @@ extern "C" { #endif -#ifndef _di_f_pipe_exists_ - f_return_status f_pipe_exists() { +#ifndef _di_f_pipe_input_exists_ + f_return_status f_pipe_input_exists() { struct stat st_info; - if (fstat(fileno(f_pipe), &st_info) != 0) { + if (fstat(f_type_descriptor_input, &st_info) != 0) { return f_status_set_error(f_file_error_stat); } @@ -18,13 +18,13 @@ extern "C" { return f_false; } -#endif // _di_f_pipe_exists_ +#endif // _di_f_pipe_input_exists_ #ifndef _di_f_pipe_warning_exists_ f_return_status f_pipe_warning_exists() { struct stat st_info; - if (fstat(fileno(f_pipe_warning), &st_info) != 0) { + if (fstat(f_type_descriptor_warning, &st_info) != 0) { return f_status_set_error(f_file_error_stat); } @@ -40,7 +40,7 @@ extern "C" { f_return_status f_pipe_error_exists() { struct stat st_info; - if (fstat(fileno(f_pipe_error), &st_info) != 0) { + if (fstat(f_type_descriptor_error, &st_info) != 0) { return f_status_set_error(f_file_error_stat); } @@ -56,7 +56,7 @@ extern "C" { f_return_status f_pipe_debug_exists() { struct stat st_info; - if (fstat(fileno(f_pipe_debug), &st_info) != 0) { + if (fstat(f_type_descriptor_debug, &st_info) != 0) { return f_status_set_error(f_file_error_stat); } diff --git a/level_0/f_pipe/c/pipe.h b/level_0/f_pipe/c/pipe.h index bc60ee9..66172ac 100644 --- a/level_0/f_pipe/c/pipe.h +++ b/level_0/f_pipe/c/pipe.h @@ -6,6 +6,8 @@ * Licenses: lgplv2.1 * * Provides pipe functionality. + * + * @todo implement pipe() functionality. */ #ifndef _F_pipe_h #define _F_pipe_h @@ -23,31 +25,21 @@ extern "C" { #endif /** - * Default pipe sources. - */ -#ifndef _di_f_pipe_ - #define f_pipe f_standard_input - #define f_pipe_warning f_standard_warning - #define f_pipe_error f_standard_error - #define f_pipe_debug f_standard_debug -#endif // _di_f_pipe_ - -/** - * Identify whether or not the default f_pipe source (generally standard input) contains piped data. + * Identify whether or not the standard input pipe source contains piped data. * * @return * f_true if there is piped data. * f_false if there is no piped data. * f_file_error_stat (with error bit) on stat() error. * - * @see stat() + * @see fstat() */ -#ifndef _di_f_pipe_exists_ - extern f_return_status f_pipe_exists(); -#endif // _di_f_pipe_exists_ +#ifndef _di_f_pipe_input_exists_ + extern f_return_status f_pipe_input_exists(); +#endif // _di_f_pipe_input_exists_ /** - * Identify whether or not the default f_pipe_warning source (generally standard warning) contains piped data. + * Identify whether or not the standard warning pipe contains piped data. * * For most systems, standard warning does not exist and instead maps to standard output. * @@ -56,28 +48,28 @@ extern "C" { * f_false if there is no piped data. * f_file_error_stat (with error bit) on stat() error. * - * @see stat() + * @see fstat() */ #ifndef _di_f_pipe_warning_exists_ extern f_return_status f_pipe_warning_exists(); #endif // _di_f_pipe_warning_exists_ /** - * Identify whether or not the default f_pipe_error source (generally standard error) contains piped data. + * Identify whether or not the standard error pipe source contains piped data. * * @return * f_true if there is piped data. * f_false if there is no piped data. * f_file_error_stat (with error bit) on stat() error. * - * @see stat() + * @see fstat() */ #ifndef _di_f_pipe_error_exists_ extern f_return_status f_pipe_error_exists(); #endif // _di_f_pipe_error_exists_ /** - * Identify whether or not the default f_pipe_debug source (generally standard warning) contains piped data. + * Identify whether or not the standard debug pipe source contains piped data. * * For most systems, standard debug does not exist and instead maps to standard output. * @@ -86,7 +78,7 @@ extern "C" { * f_false if there is no piped data. * f_file_error_stat (with error bit) on stat() error. * - * @see stat() + * @see fstat() */ #ifndef _di_f_pipe_debug_exists_ extern f_return_status f_pipe_debug_exists(); diff --git a/level_0/f_status/c/status.h b/level_0/f_status/c/status.h index 2c2edff..8581e20 100644 --- a/level_0/f_status/c/status.h +++ b/level_0/f_status/c/status.h @@ -221,19 +221,23 @@ extern "C" { #ifndef _di_f_status_buffers_ f_buffer_too_small, f_buffer_too_large, + f_error_on_block, f_error_on_eof, f_error_on_eol, f_error_on_eos, f_error_on_stop, f_incomplete_utf, + f_incomplete_utf_on_block, f_incomplete_utf_on_eof, f_incomplete_utf_on_eol, f_incomplete_utf_on_eos, f_incomplete_utf_on_stop, + f_none_on_block, f_none_on_eof, f_none_on_eol, f_none_on_eos, f_none_on_stop, + f_no_data_on_block, f_no_data_on_eof, f_no_data_on_eol, f_no_data_on_eos, @@ -241,16 +245,19 @@ extern "C" { f_string_too_small, f_string_too_large, f_unterminated, + f_unterminated_on_block, f_unterminated_on_eof, f_unterminated_on_eol, f_unterminated_on_eos, f_unterminated_on_stop, f_unterminated_group, + f_unterminated_group_on_block, f_unterminated_group_on_eof, f_unterminated_group_on_eol, f_unterminated_group_on_eos, f_unterminated_group_on_stop, f_unterminated_nest, + f_unterminated_nest_on_block, f_unterminated_nest_on_eof, f_unterminated_nest_on_eol, f_unterminated_nest_on_eos, diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index e70e840..e056c9a 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -13,6 +13,7 @@ // libc includes #include #include +#include #ifdef __cplusplus extern "C" { @@ -175,13 +176,19 @@ extern "C" { * For most systems, there is no standard warning nor is there a standard debug. * Therefore, these will map to standard output. */ -#ifndef _di_f_type_standard_input_output_ - #define f_standard_debug stdout - #define f_standard_error stderr - #define f_standard_input stdin - #define f_standard_output stdout - #define f_standard_warning stdout -#endif // _di_f_type_standard_input_output_ +#ifndef _di_f_type_input_output_ + #define f_type_debug stdout + #define f_type_error stderr + #define f_type_input stdin + #define f_type_output stdout + #define f_type_warning stdout + + #define f_type_descriptor_debug STDOUT_FILENO + #define f_type_descriptor_error STDERR_FILENO + #define f_type_descriptor_input STDIN_FILENO + #define f_type_descriptor_output STDOUT_FILENO + #define f_type_descriptor_warning STDOUT_FILENO +#endif // _di_f_type_input_output_ /** * Defines a variable to be used by arrays. diff --git a/level_1/fl_fss/c/fss.h b/level_1/fl_fss/c/fss.h index 1ffe919..f24dd03 100644 --- a/level_1/fl_fss/c/fss.h +++ b/level_1/fl_fss/c/fss.h @@ -86,11 +86,11 @@ extern "C" { * f_none on success. * f_invalid_parameter (with error bit) if a parameter is invalid. * - * Errors from (with error bit): f_file_read_quantity(). + * Errors from (with error bit): f_file_read_until(). * Errors from (with error bit): fl_fss_identify() * File errors (with error bit): f_file_error_seek, f_file_not_open. * - * @see f_file_read_quantity() + * @see f_file_read_until() * @see fl_fss_identify() */ #ifndef _di_fl_fss_identify_file_ diff --git a/level_1/fl_status/c/status.c b/level_1/fl_status/c/status.c index 41d71d9..dba56da 100644 --- a/level_1/fl_status/c/status.c +++ b/level_1/fl_status/c/status.c @@ -456,6 +456,9 @@ extern "C" { case f_no_data_on_stop: *string = fl_status_string_no_data_on_stop; break; + case f_no_data_on_block: + *string = fl_status_string_no_data_on_block; + break; case f_none_on_eof: *string = fl_status_string_none_on_eof; break; @@ -468,6 +471,9 @@ extern "C" { case f_none_on_stop: *string = fl_status_string_none_on_stop; break; + case f_none_on_block: + *string = fl_status_string_none_on_block; + break; case f_error_on_eof: *string = fl_status_string_error_on_eof; break; @@ -480,6 +486,9 @@ extern "C" { case f_error_on_stop: *string = fl_status_string_error_on_stop; break; + case f_error_on_block: + *string = fl_status_string_error_on_block; + break; case f_buffer_too_small: *string = fl_status_string_buffer_too_small; break; @@ -507,6 +516,9 @@ extern "C" { case f_unterminated_on_stop: *string = fl_status_string_unterminated_on_stop; break; + case f_unterminated_on_block: + *string = fl_status_string_unterminated_on_block; + break; case f_unterminated_group: *string = fl_status_string_unterminated_group; break; @@ -522,6 +534,9 @@ extern "C" { case f_unterminated_group_on_stop: *string = fl_status_string_unterminated_group_on_stop; break; + case f_unterminated_group_on_block: + *string = fl_status_string_unterminated_group_on_block; + break; case f_unterminated_nest: *string = fl_status_string_unterminated_nest; break; @@ -537,6 +552,9 @@ extern "C" { case f_unterminated_nest_on_stop: *string = fl_status_string_unterminated_nest_on_stop; break; + case f_unterminated_nest_on_block: + *string = fl_status_string_unterminated_nest_on_block; + break; case f_incomplete_utf: *string = fl_status_string_incomplete_utf; break; @@ -552,6 +570,9 @@ extern "C" { case f_incomplete_utf_on_stop: *string = fl_status_string_incomplete_utf_on_stop; break; + case f_incomplete_utf_on_block: + *string = fl_status_string_incomplete_utf_on_block; + break; #endif // _di_fl_status_buffers_ #ifndef _di_fl_status_allocation_ diff --git a/level_1/fl_status/c/status.h b/level_1/fl_status/c/status.h index 66a705d..9dbbcfe 100644 --- a/level_1/fl_status/c/status.h +++ b/level_1/fl_status/c/status.h @@ -462,6 +462,9 @@ extern "C" { #define fl_status_string_no_data_on_stop "f_no_data_on_stop" #define fl_status_string_no_data_on_stop_length 17 + #define fl_status_string_no_data_on_block "f_no_data_on_block" + #define fl_status_string_no_data_on_block_length 18 + #define fl_status_string_none_on_eol "f_none_on_eol" #define fl_status_string_none_on_eol_length 13 @@ -471,6 +474,9 @@ extern "C" { #define fl_status_string_none_on_stop "f_none_on_stop" #define fl_status_string_none_on_stop_length 14 + #define fl_status_string_none_on_block "f_none_on_block" + #define fl_status_string_none_on_block_length 15 + #define fl_status_string_error_on_eof "f_error_on_eof" #define fl_status_string_error_on_eof_length 14 @@ -483,6 +489,9 @@ extern "C" { #define fl_status_string_error_on_stop "f_error_on_stop" #define fl_status_string_error_on_stop_length 15 + #define fl_status_string_error_on_block "f_error_on_block" + #define fl_status_string_error_on_block_length 16 + #define fl_status_string_buffer_too_small "f_buffer_too_small" #define fl_status_string_buffer_too_small_length 18 @@ -510,6 +519,9 @@ extern "C" { #define fl_status_string_unterminated_on_stop "f_unterminated_on_stop" #define fl_status_string_unterminated_on_stop_length 22 + #define fl_status_string_unterminated_on_block "f_unterminated_on_block" + #define fl_status_string_unterminated_on_block_length 23 + #define fl_status_string_unterminated_group "f_unterminated_group" #define fl_status_string_unterminated_group_length 20 @@ -525,6 +537,9 @@ extern "C" { #define fl_status_string_unterminated_group_on_stop "f_unterminated_group_on_stop" #define fl_status_string_unterminated_group_on_stop_length 28 + #define fl_status_string_unterminated_group_on_block "f_unterminated_group_on_block" + #define fl_status_string_unterminated_group_on_block_length 29 + #define fl_status_string_unterminated_nest "f_unterminated_nest" #define fl_status_string_unterminated_nest_length 19 @@ -540,6 +555,9 @@ extern "C" { #define fl_status_string_unterminated_nest_on_stop "f_unterminated_nest_on_stop" #define fl_status_string_unterminated_nest_on_stop_length 27 + #define fl_status_string_unterminated_nest_on_block "f_unterminated_nest_on_block" + #define fl_status_string_unterminated_nest_on_block_length 28 + #define fl_status_string_incomplete_utf "f_incomplete_utf" #define fl_status_string_incomplete_utf_length 16 @@ -554,6 +572,9 @@ extern "C" { #define fl_status_string_incomplete_utf_on_stop "f_incomplete_utf_on_stop" #define fl_status_string_incomplete_utf_on_stop_length 24 + + #define fl_status_string_incomplete_utf_on_block "f_incomplete_utf_on_block" + #define fl_status_string_incomplete_utf_on_block_length 25 #endif // _di_fl_status_buffers_ #ifndef _di_fl_status_allocation_ diff --git a/level_1/fl_utf_file/c/utf_file.c b/level_1/fl_utf_file/c/utf_file.c index 22297aa..f0ef1ba 100644 --- a/level_1/fl_utf_file/c/utf_file.c +++ b/level_1/fl_utf_file/c/utf_file.c @@ -9,7 +9,7 @@ extern "C" { f_return_status fl_utf_file_read(const f_file file, f_utf_string_dynamic *buffer) { #ifndef _di_level_1_parameter_checking_ if (file.size_read == 0) return f_status_set_error(f_invalid_parameter); - if (buffer->used >= buffer->size) return f_status_set_error(f_invalid_parameter); + if (buffer->used > buffer->size) return f_status_set_error(f_invalid_parameter); #endif // _di_level_1_parameter_checking_ if (file.id <= 0) return f_status_set_error(f_file_not_open); @@ -84,7 +84,7 @@ extern "C" { f_return_status fl_utf_file_read_block(const f_file file, f_utf_string_dynamic *buffer) { #ifndef _di_level_1_parameter_checking_ if (file.size_read == 0) return f_status_set_error(f_invalid_parameter); - if (buffer->used >= buffer->size) return f_status_set_error(f_invalid_parameter); + if (buffer->used > buffer->size) return f_status_set_error(f_invalid_parameter); #endif // _di_level_1_parameter_checking_ if (file.id <= 0) return f_status_set_error(f_file_not_open); @@ -159,7 +159,7 @@ extern "C" { f_return_status fl_utf_file_read_until(const f_file file, f_utf_string_dynamic *buffer, const f_utf_string_length total) { #ifndef _di_level_1_parameter_checking_ if (file.size_read == 0) return f_status_set_error(f_invalid_parameter); - if (buffer->used >= buffer->size) return f_status_set_error(f_invalid_parameter); + if (buffer->used > buffer->size) return f_status_set_error(f_invalid_parameter); #endif // _di_level_1_parameter_checking_ if (file.id <= 0) return f_status_set_error(f_file_not_open); diff --git a/level_2/fll_execute/c/execute.c b/level_2/fll_execute/c/execute.c index 8eb5a24..e27dc4c 100644 --- a/level_2/fll_execute/c/execute.c +++ b/level_2/fll_execute/c/execute.c @@ -388,7 +388,7 @@ extern "C" { clearenv(); for (f_array_length i = 0; i < names.used; i++) { - f_environment_set_dynamic(names.array[i], values.array[i], true); + f_environment_set_dynamic(names.array[i], values.array[i], f_true); } // for execv(program_path, fixed_arguments); @@ -614,7 +614,7 @@ extern "C" { clearenv(); for (f_array_length i = 0; i < names.used; i++) { - f_environment_set_dynamic(names.array[i], values.array[i], true); + f_environment_set_dynamic(names.array[i], values.array[i], f_true); } execvp(program_path, fixed_arguments); diff --git a/level_2/fll_file/c/file.h b/level_2/fll_file/c/file.h index 7a1b76f..2e926ae 100644 --- a/level_2/fll_file/c/file.h +++ b/level_2/fll_file/c/file.h @@ -31,7 +31,7 @@ extern "C" { * Print file error messages. * * @param file - * The file to write to, such as f_standard_output or f_standard_error. + * The file to write to, such as f_type_output or f_type_error. * @param context * The color context information to use when printing. * @param function_name diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 3baaea3..39ce242 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -7,13 +7,13 @@ extern "C" { #ifndef _di_fll_program_print_help_header_ f_return_status fll_program_print_help_header(const fl_color_context context, const f_string name, const f_string version) { printf("%c", f_string_eol); - fl_color_print(f_standard_output, context.title, context.reset, " %s", name); + fl_color_print(f_type_output, context.title, context.reset, " %s", name); printf("%c", f_string_eol); - fl_color_print(f_standard_output, context.notable, context.reset, " Version %s", version); + fl_color_print(f_type_output, context.notable, context.reset, " Version %s", version); printf("%c%c", f_string_eol, f_string_eol); - fl_color_print(f_standard_output, context.important, context.reset, " Available Options: "); + fl_color_print(f_type_output, context.important, context.reset, " Available Options: "); return f_none; } @@ -23,10 +23,10 @@ extern "C" { f_return_status fll_program_print_help_option(const fl_color_context context, const f_string option_short, const f_string option_long, const f_string symbol_short, const f_string symbol_long, const f_string description) { printf("%c", f_string_eol); printf(" %s", symbol_short); - fl_color_print(f_standard_output, context.standout, context.reset, option_short); + fl_color_print(f_type_output, context.standout, context.reset, option_short); printf(", %s", symbol_long); - fl_color_print(f_standard_output, context.standout, context.reset, option_long); + fl_color_print(f_type_output, context.standout, context.reset, option_long); printf(" %s", description); return f_none; @@ -37,7 +37,7 @@ extern "C" { f_return_status fll_program_print_help_option_long(const fl_color_context context, const f_string option_long, const f_string symbol_long, const f_string description) { printf("%c", f_string_eol); printf(" %s", symbol_long); - fl_color_print(f_standard_output, context.standout, context.reset, option_long); + fl_color_print(f_type_output, context.standout, context.reset, option_long); printf(" %s", description); return f_none; @@ -47,7 +47,7 @@ extern "C" { #ifndef _di_fll_program_print_help_option_other_ f_return_status fll_program_print_help_option_other(const fl_color_context context, const f_string option_other, const f_string description) { printf("%c ", f_string_eol); - fl_color_print(f_standard_output, context.standout, context.reset, option_other); + fl_color_print(f_type_output, context.standout, context.reset, option_other); printf(" %s", description); @@ -58,23 +58,23 @@ extern "C" { #ifndef _di_fll_program_print_help_usage_ f_return_status fll_program_print_help_usage(const fl_color_context context, const f_string name, const f_string parameters) { printf("%c%c", f_string_eol, f_string_eol); - fl_color_print(f_standard_output, context.important, context.reset, " Usage:"); + fl_color_print(f_type_output, context.important, context.reset, " Usage:"); printf("%c ", f_string_eol); - fl_color_print(f_standard_output, context.standout, context.reset, name); + fl_color_print(f_type_output, context.standout, context.reset, name); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "["); + fl_color_print(f_type_output, context.notable, context.reset, "["); printf(" options "); - fl_color_print(f_standard_output, context.notable, context.reset, "]"); + fl_color_print(f_type_output, context.notable, context.reset, "]"); if (parameters[0] != '\0') { printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "["); + fl_color_print(f_type_output, context.notable, context.reset, "["); printf(" %s ", parameters); - fl_color_print(f_standard_output, context.notable, context.reset, "]"); + fl_color_print(f_type_output, context.notable, context.reset, "]"); } printf("%c%c", f_string_eol, f_string_eol); @@ -99,32 +99,32 @@ extern "C" { status = f_status_set_fine(status); if (status == f_no_data) { - fl_color_print_line(f_standard_error, context->error, context->reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); + fl_color_print_line(f_type_error, context->error, context->reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); // @todo there is a way to identify which parameter is incorrect // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 // nothing can be 0 as that represents the program name, unless argv[] is improperly created } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print(f_standard_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); - fl_color_print(f_standard_error, context->notable, context->reset, "f_console_parameter_process"); - fl_color_print_line(f_standard_error, context->error, context->reset, ")."); + fl_color_print(f_type_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); + fl_color_print(f_type_error, context->notable, context->reset, "f_console_parameter_process"); + fl_color_print_line(f_type_error, context->error, context->reset, ")."); } else if (status == f_invalid_utf) { - fl_color_print(f_standard_error, context->error, context->reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling "); - fl_color_print(f_standard_error, context->notable, context->reset, "f_console_parameter_process()"); - fl_color_print_line(f_standard_error, context->error, context->reset, "."); + fl_color_print(f_type_error, context->error, context->reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling "); + fl_color_print(f_type_error, context->notable, context->reset, "f_console_parameter_process()"); + fl_color_print_line(f_type_error, context->error, context->reset, "."); } else if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context->error, context->reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, context->notable, context->reset, "f_console_parameter_process()"); - fl_color_print_line(f_standard_error, context->error, context->reset, "."); + fl_color_print(f_type_error, context->error, context->reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, context->notable, context->reset, "f_console_parameter_process()"); + fl_color_print_line(f_type_error, context->error, context->reset, "."); } else { - fl_color_print(f_standard_error, context->error, context->reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context->notable, context->reset, "%u", status); - fl_color_print(f_standard_error, context->error, context->reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context->notable, context->reset, "f_console_parameter_process()"); - fl_color_print_line(f_standard_error, context->error, context->reset, "."); + fl_color_print(f_type_error, context->error, context->reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context->notable, context->reset, "%u", status); + fl_color_print(f_type_error, context->error, context->reset, ") has occurred while calling "); + fl_color_print(f_type_error, context->notable, context->reset, "f_console_parameter_process()"); + fl_color_print_line(f_type_error, context->error, context->reset, "."); } return f_status_set_error(status); @@ -147,21 +147,21 @@ extern "C" { status = f_status_set_fine(status); if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print(f_standard_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); - fl_color_print(f_standard_error, context->notable, context->reset, "%s", function); - fl_color_print_line(f_standard_error, context->error, context->reset, ")."); + fl_color_print(f_type_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); + fl_color_print(f_type_error, context->notable, context->reset, "%s", function); + fl_color_print_line(f_type_error, context->error, context->reset, ")."); } else if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context->error, context->reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, context->notable, context->reset, "%s", function); - fl_color_print_line(f_standard_error, context->error, context->reset, "()."); + fl_color_print(f_type_error, context->error, context->reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, context->notable, context->reset, "%s", function); + fl_color_print_line(f_type_error, context->error, context->reset, "()."); } else { - fl_color_print(f_standard_error, context->error, context->reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context->notable, context->reset, "%u", status); - fl_color_print(f_standard_error, context->error, context->reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context->notable, context->reset, "%s", function); - fl_color_print_line(f_standard_error, context->error, context->reset, "()."); + fl_color_print(f_type_error, context->error, context->reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context->notable, context->reset, "%u", status); + fl_color_print(f_type_error, context->error, context->reset, ") has occurred while calling "); + fl_color_print(f_type_error, context->notable, context->reset, "%s", function); + fl_color_print_line(f_type_error, context->error, context->reset, "()."); } return f_status_set_error(status); @@ -174,9 +174,9 @@ extern "C" { fl_macro_color_context_new(allocation_status, (*context)); if (f_status_is_error(allocation_status)) { - fl_color_print(f_standard_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); - fl_color_print(f_standard_error, context->notable, context->reset, "fl_macro_color_context_new"); - fl_color_print_line(f_standard_error, context->error, context->reset, "()."); + fl_color_print(f_type_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory while calling "); + fl_color_print(f_type_error, context->notable, context->reset, "fl_macro_color_context_new"); + fl_color_print_line(f_type_error, context->error, context->reset, "()."); return allocation_status; } diff --git a/level_2/fll_status/c/status.c b/level_2/fll_status/c/status.c index e75176b..22c9dd9 100644 --- a/level_2/fll_status/c/status.c +++ b/level_2/fll_status/c/status.c @@ -746,6 +746,11 @@ extern "C" { return f_none; } + if (fl_string_compare(string, fl_status_string_no_data_on_block, length, fl_status_string_no_data_on_block_length) == f_equal_to) { + *code = f_no_data_on_block; + return f_none; + } + if (fl_string_compare(string, fl_status_string_none_on_eof, length, fl_status_string_none_on_eof_length) == f_equal_to) { *code = f_none_on_eof; return f_none; @@ -766,6 +771,11 @@ extern "C" { return f_none; } + if (fl_string_compare(string, fl_status_string_none_on_block, length, fl_status_string_none_on_block_length) == f_equal_to) { + *code = f_none_on_block; + return f_none; + } + if (fl_string_compare(string, fl_status_string_error_on_eof, length, fl_status_string_error_on_eof_length) == f_equal_to) { *code = f_error_on_eof; return f_none; @@ -786,6 +796,11 @@ extern "C" { return f_none; } + if (fl_string_compare(string, fl_status_string_error_on_block, length, fl_status_string_error_on_block_length) == f_equal_to) { + *code = f_error_on_block; + return f_none; + } + if (fl_string_compare(string, fl_status_string_buffer_too_small, length, fl_status_string_buffer_too_small_length) == f_equal_to) { *code = f_buffer_too_small; return f_none; @@ -831,6 +846,11 @@ extern "C" { return f_none; } + if (fl_string_compare(string, fl_status_string_unterminated_on_block, length, fl_status_string_unterminated_on_block_length) == f_equal_to) { + *code = f_unterminated_on_block; + return f_none; + } + if (fl_string_compare(string, fl_status_string_unterminated_group, length, fl_status_string_unterminated_group_length) == f_equal_to) { *code = f_unterminated_group; return f_none; @@ -856,6 +876,11 @@ extern "C" { return f_none; } + if (fl_string_compare(string, fl_status_string_unterminated_group_on_block, length, fl_status_string_unterminated_group_on_block_length) == f_equal_to) { + *code = f_unterminated_group_on_block; + return f_none; + } + if (fl_string_compare(string, fl_status_string_unterminated_nest, length, fl_status_string_unterminated_nest_length) == f_equal_to) { *code = f_unterminated_nest; return f_none; @@ -881,6 +906,11 @@ extern "C" { return f_none; } + if (fl_string_compare(string, fl_status_string_unterminated_nest_on_block, length, fl_status_string_unterminated_nest_on_block_length) == f_equal_to) { + *code = f_unterminated_nest_on_block; + return f_none; + } + if (fl_string_compare(string, fl_status_string_incomplete_utf, length, fl_status_string_incomplete_utf_length) == f_equal_to) { *code = f_incomplete_utf; return f_none; @@ -905,6 +935,11 @@ extern "C" { *code = f_incomplete_utf_on_stop; return f_none; } + + if (fl_string_compare(string, fl_status_string_incomplete_utf_on_block, length, fl_status_string_incomplete_utf_on_block_length) == f_equal_to) { + *code = f_incomplete_utf_on_block; + return f_none; + } #endif // _di_fll_status_buffers_ #ifndef _di_fll_status_allocation_ diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index 7baeb03..fd85a28 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -43,13 +43,13 @@ extern "C" { fll_program_print_help_usage(context, byte_dump_name, "filename(s)"); printf(" When using the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_text); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_text); printf(" option, some UTF-8 characters may be replaced by your instance and cause display alignment issues."); printf("%c%c", f_string_eol, f_string_eol); printf(" Special UTF-8 characters and non-spacing UTF-8 characters may be replaced with a space (or a placeholder when the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_placeholder); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_placeholder); printf(" option is used)."); printf("%c%c", f_string_eol, f_string_eol); @@ -59,7 +59,7 @@ extern "C" { printf("%c%c", f_string_eol, f_string_eol); printf(" When "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); printf(" is used, any UTF-8 sequences will still be printed in full should any part is found within the requested range."); printf("%c%c", f_string_eol, f_string_eol); @@ -162,9 +162,9 @@ extern "C" { } else if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[byte_dump_parameter_width].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' was specified, but no value was given."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' was specified, but no value was given."); byte_dump_delete_data(data); return f_status_set_error(status); @@ -174,13 +174,13 @@ extern "C" { status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[byte_dump_parameter_width].additional.array[data->parameters[byte_dump_parameter_width].additional.used - 1]], &number); if (f_status_is_error(status) || number < 1 || number >= 0xfb) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' value can only be a number between "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "0"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " and "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "251"); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_width); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' value can only be a number between "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "0"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " and "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "251"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); byte_dump_delete_data(data); return f_status_set_error(status); @@ -190,9 +190,9 @@ extern "C" { } if (data->parameters[byte_dump_parameter_first].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' was specified, but no value was given."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' was specified, but no value was given."); byte_dump_delete_data(data); return f_status_set_error(status); @@ -202,13 +202,13 @@ extern "C" { status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[byte_dump_parameter_first].additional.array[data->parameters[byte_dump_parameter_first].additional.used - 1]], &number); if (f_status_is_error(status) || number > f_type_number_size_unsigned) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' value can only be a number (inclusively) between "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "0"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " and "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%llu", f_type_number_size_unsigned); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' value can only be a number (inclusively) between "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "0"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " and "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%llu", f_type_number_size_unsigned); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); byte_dump_delete_data(data); return f_status_set_error(status); @@ -218,9 +218,9 @@ extern "C" { } if (data->parameters[byte_dump_parameter_last].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' was specified, but no value was given."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' was specified, but no value was given."); byte_dump_delete_data(data); return f_status_set_error(status); @@ -230,13 +230,13 @@ extern "C" { status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[byte_dump_parameter_last].additional.array[data->parameters[byte_dump_parameter_last].additional.used - 1]], &number); if (f_status_is_error(status) || number < 0 || number > f_type_number_size_unsigned) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' value can only be a number (inclusively) between "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "0"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " and "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%llu", f_type_number_size_unsigned); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' value can only be a number (inclusively) between "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "0"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " and "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%llu", f_type_number_size_unsigned); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); byte_dump_delete_data(data); return f_status_set_error(status); @@ -247,11 +247,11 @@ extern "C" { if (data->parameters[byte_dump_parameter_first].result == f_console_result_additional && data->parameters[byte_dump_parameter_last].result == f_console_result_additional) { if (data->first > data->last) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' value cannot be greater than the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' value."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_first); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' value cannot be greater than the parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' value."); byte_dump_delete_data(data); return f_status_set_error(status); @@ -264,28 +264,28 @@ extern "C" { if (data->process_pipe) { f_file file = f_file_initialize; - file.address = f_pipe; + file.id = f_type_descriptor_input; printf("%c", f_string_eol); - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Piped Byte Dump: (in "); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Piped Byte Dump: (in "); if (data->mode == byte_dump_mode_hexidecimal) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Hexidecimal"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Hexidecimal"); } else if (data->mode == byte_dump_mode_duodecimal) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Duodecimal"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Duodecimal"); } else if (data->mode == byte_dump_mode_octal) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Octal"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Octal"); } else if (data->mode == byte_dump_mode_binary) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Binary"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Binary"); } else if (data->mode == byte_dump_mode_decimal) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Decimal"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Decimal"); } - fl_color_print_line(f_standard_output, data->context.title, data->context.reset, ")"); + fl_color_print_line(f_type_output, data->context.title, data->context.reset, ")"); status = byte_dump_file(*data, "-", file); @@ -322,7 +322,7 @@ extern "C" { for (f_array_length counter = 0; counter < data->remaining.used; counter++) { f_file file = f_file_initialize; - status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); + status = f_file_open(arguments.argv[data->remaining.array[counter]], 0, &file); if (f_status_is_error(status)) { byte_dump_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); byte_dump_delete_data(data); @@ -330,31 +330,31 @@ extern "C" { } printf("%c", f_string_eol); - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Byte Dump of: "); - fl_color_print(f_standard_output, data->context.notable, data->context.reset, "%s", arguments.argv[data->remaining.array[counter]]); - fl_color_print(f_standard_output, data->context.title, data->context.reset, " (in "); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Byte Dump of: "); + fl_color_print(f_type_output, data->context.notable, data->context.reset, "%s", arguments.argv[data->remaining.array[counter]]); + fl_color_print(f_type_output, data->context.title, data->context.reset, " (in "); if (data->mode == byte_dump_mode_hexidecimal) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Hexidecimal"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Hexidecimal"); } else if (data->mode == byte_dump_mode_duodecimal) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Duodecimal"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Duodecimal"); } else if (data->mode == byte_dump_mode_octal) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Octal"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Octal"); } else if (data->mode == byte_dump_mode_binary) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Binary"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Binary"); } else if (data->mode == byte_dump_mode_decimal) { - fl_color_print(f_standard_output, data->context.title, data->context.reset, "Decimal"); + fl_color_print(f_type_output, data->context.title, data->context.reset, "Decimal"); } - fl_color_print_line(f_standard_output, data->context.title, data->context.reset, ")"); + fl_color_print_line(f_type_output, data->context.title, data->context.reset, ")"); status = byte_dump_file(*data, arguments.argv[data->remaining.array[counter]], file); - f_file_close(&file); + f_file_close(&file.id); if (f_status_is_error(status)) { byte_dump_delete_data(data); @@ -367,7 +367,7 @@ extern "C" { } } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more filenames."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more filenames."); status = f_status_set_error(f_invalid_parameter); } diff --git a/level_3/byte_dump/c/main.c b/level_3/byte_dump/c/main.c index 9fc3443..027dacb 100644 --- a/level_3/byte_dump/c/main.c +++ b/level_3/byte_dump/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; byte_dump_data data = byte_dump_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index d706de8..9937147 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -44,8 +44,6 @@ extern "C" { uint8_t invalid[data.width]; memset(&invalid, 0, sizeof(uint8_t) * data.width); - fseek(file.address, data.first, SEEK_SET); - while ((size = read(file.id, &byte, 1)) > 0) { // Storing the next character is designated by width_utf == -1. if (width_utf == -1) { @@ -205,25 +203,25 @@ extern "C" { printf("%c", f_string_eol); // make sure to flush standard out to help prevent standard error from causing poblems. - fflush(f_standard_output); + fflush(f_type_output); if (found_invalid_utf) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "Invalid UTF-8 codes were detected for file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "Invalid UTF-8 codes were detected for file '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", file_name); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); printf("%c", f_string_eol); } if (size < 0) { // @todo: determine what the error from read() is and display it. - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: read() failed for '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: read() failed for '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", file_name); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); printf("%c", f_string_eol); status = f_status_set_error(f_failure); } - fflush(f_standard_error); + fflush(f_type_error); return status; } @@ -251,7 +249,7 @@ extern "C" { } if (cell->column == 0) { - fl_color_print(f_standard_output, data.context.notable, data.context.reset, "%016X ", (uint64_t) cell->row); + fl_color_print(f_type_output, data.context.notable, data.context.reset, "%016X ", (uint64_t) cell->row); if (*offset > 0) { uint8_t offset_to_print = *offset; @@ -301,7 +299,7 @@ extern "C" { if (cell->column < data.width) { if (data.mode == byte_dump_mode_hexidecimal) { if (invalid[character_current]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, " %02x", (uint8_t) byte); + fl_color_print(f_type_output, data.context.error, data.context.reset, " %02x", (uint8_t) byte); } else { printf(" %02x", (uint8_t) byte); @@ -309,7 +307,7 @@ extern "C" { } else if (data.mode == byte_dump_mode_duodecimal) { if (invalid[character_current]) { - f_print_string_dynamic(f_standard_output, data.context.error); + f_print_string_dynamic(f_type_output, data.context.error); } printf(" %01d", byte / 144); @@ -339,12 +337,12 @@ extern "C" { } if (invalid[character_current]) { - f_print_string_dynamic(f_standard_output, data.context.reset); + f_print_string_dynamic(f_type_output, data.context.reset); } } else if (data.mode == byte_dump_mode_octal) { if (invalid[character_current]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, " %03o", (uint8_t) byte); + fl_color_print(f_type_output, data.context.error, data.context.reset, " %03o", (uint8_t) byte); } else { printf(" %03o", (uint8_t) byte); @@ -363,7 +361,7 @@ extern "C" { binary_string[7] = (byte & 0x01) ? '1' : '0'; if (invalid[character_current]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, " %s", binary_string); + fl_color_print(f_type_output, data.context.error, data.context.reset, " %s", binary_string); } else { printf(" %s", binary_string); @@ -371,7 +369,7 @@ extern "C" { } else if (data.mode == byte_dump_mode_decimal) { if (invalid[character_current]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, " %3d", (uint8_t) byte); + fl_color_print(f_type_output, data.context.error, data.context.reset, " %3d", (uint8_t) byte); } else { printf(" %3d", (uint8_t) byte); @@ -436,7 +434,7 @@ extern "C" { uint8_t width_utf = 0; bool printed = f_false; - fl_color_print(f_standard_output, data.context.notable, data.context.reset, " %s ", byte_dump_character_wall); + fl_color_print(f_type_output, data.context.notable, data.context.reset, " %s ", byte_dump_character_wall); if (*offset > 0) { @@ -455,7 +453,7 @@ extern "C" { } while (*offset > 0 && j < data.width) { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", placeholder); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "%s", placeholder); (*offset)--; j++; } // while @@ -474,13 +472,13 @@ extern "C" { if (data.parameters[byte_dump_parameter_placeholder].result == f_console_result_found) { for (; j < previous->bytes && j < data.width; j++) { if (previous->invalid) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); } else if (data.parameters[byte_dump_parameter_classic].result == f_console_result_found) { printf("."); } else { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); } } // for } @@ -505,111 +503,111 @@ extern "C" { width_utf = f_macro_utf_byte_width_is(output); if (invalid[i]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, "%s", byte_dump_character_incomplete); + fl_color_print(f_type_output, data.context.error, data.context.reset, "%s", byte_dump_character_incomplete); } else if (output >= 0 && output <= 32 || output == 127) { if (data.presentation == byte_dump_presentation_normal) { if (output == 0) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_null); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_null); } else if (output == 1) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_start_of_header); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_start_of_header); } else if (output == 2) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_start_of_text); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_start_of_text); } else if (output == 3) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_text); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_text); } else if (output == 4) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_transmission); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_transmission); } else if (output == 5) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_enquiry); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_enquiry); } else if (output == 6) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_acknowledge); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_acknowledge); } else if (output == 7) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_bell); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_bell); } else if (output == 8) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_backspace); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_backspace); } else if (output == 9) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_tab); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_tab); } else if (output == 10) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_new_line); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_new_line); } else if (output == 11) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_tab_vertical); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_tab_vertical); } else if (output == 12) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_form_feed); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_form_feed); } else if (output == 13) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_carriage_return); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_carriage_return); } else if (output == 14) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_shift_out); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_shift_out); } else if (output == 15) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_shift_in); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_shift_in); } else if (output == 16) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_data_link_escape); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_data_link_escape); } else if (output == 17) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_1); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_1); } else if (output == 18) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_2); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_2); } else if (output == 19) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_3); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_3); } else if (output == 20) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_4); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_4); } else if (output == 21) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_negative_acknowledge); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_negative_acknowledge); } else if (output == 22) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_synchronous_idle); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_synchronous_idle); } else if (output == 23) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_transmission_block); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_transmission_block); } else if (output == 24) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_cancel); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_cancel); } else if (output == 25) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_medium); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_medium); } else if (output == 26) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_substitute); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_substitute); } else if (output == 27) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_escape); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_escape); } else if (output == 28) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_file_separator); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_file_separator); } else if (output == 29) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_group_separator); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_group_separator); } else if (output == 30) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_record_separator); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_record_separator); } else if (output == 31) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_unit_separator); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_unit_separator); } else if (output == 32) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_space); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_space); } else if (output == 127) { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_delete); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_delete); } } else if (data.presentation == byte_dump_presentation_simple) { @@ -624,7 +622,7 @@ extern "C" { printf("."); } else { - fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_space); + fl_color_print2(f_type_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_space); } } else if (f_utf_character_is_zero_width(characters.string[i]) == f_true) { @@ -632,7 +630,7 @@ extern "C" { printf("."); } else if (data.parameters[byte_dump_parameter_placeholder].result == f_console_result_found) { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); } else { printf(" "); @@ -641,7 +639,7 @@ extern "C" { else if (f_utf_character_is_control(characters.string[i]) == f_true) { // print a space (or '.') for control characters. if (data.presentation == byte_dump_presentation_classic) { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "."); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "."); } else { printf(" "); @@ -679,10 +677,10 @@ extern "C" { else if (width_utf == 1) { // print invalid placeholder for invalid UTF-8 widths. if (invalid[i]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, "%s", byte_dump_character_incomplete); + fl_color_print(f_type_output, data.context.error, data.context.reset, "%s", byte_dump_character_incomplete); } else { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", byte_dump_character_incomplete); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "%s", byte_dump_character_incomplete); } } else if (width_utf > 0) { @@ -745,13 +743,13 @@ extern "C" { if (width_utf > 1 && j + 1 < data.width) { if (data.parameters[byte_dump_parameter_placeholder].result == f_console_result_found) { if (invalid[i]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); } else if (data.parameters[byte_dump_parameter_classic].result == f_console_result_found) { printf("."); } else { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); } } else { @@ -763,13 +761,13 @@ extern "C" { if (width_utf > 2 && j + 1 < data.width) { if (data.parameters[byte_dump_parameter_placeholder].result == f_console_result_found) { if (invalid[i]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); } else if (data.parameters[byte_dump_parameter_classic].result == f_console_result_found) { printf("."); } else { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); } } else { @@ -781,13 +779,13 @@ extern "C" { if (width_utf > 3 && j + 1 < data.width) { if (data.parameters[byte_dump_parameter_placeholder].result == f_console_result_found) { if (invalid[i]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); } else if (data.parameters[byte_dump_parameter_classic].result == f_console_result_found) { printf("."); } else { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); } } else { @@ -804,13 +802,13 @@ extern "C" { if (data.parameters[byte_dump_parameter_placeholder].result == f_console_result_found) { for (; j < data.width; j++) { if (invalid[j]) { - fl_color_print(f_standard_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.error, data.context.reset, "%s", byte_dump_character_placeholder); } else if (data.parameters[byte_dump_parameter_classic].result == f_console_result_found) { printf("."); } else { - fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); + fl_color_print(f_type_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); } } // for } @@ -820,7 +818,7 @@ extern "C" { } // for } - fl_color_print(f_standard_output, data.context.notable, data.context.reset, " |"); + fl_color_print(f_type_output, data.context.notable, data.context.reset, " |"); printf("%c", f_string_eol); } #endif // _di_byte_dump_file_ @@ -828,68 +826,68 @@ extern "C" { #ifndef _di_byte_dump_print_file_error_ void byte_dump_print_file_error(const fl_color_context context, const f_string function, const f_string file_name, const f_status status) { if (status == f_false) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to find file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: failed to find file '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); return; } if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ", function, file_name); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); - fl_color_print(f_standard_error, context.error, context.reset, "() for the file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ", function, file_name); + fl_color_print(f_type_error, context.notable, context.reset, "%s", function); + fl_color_print(f_type_error, context.error, context.reset, "() for the file '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); return; } if (status == f_invalid_name) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid filename '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Invalid filename '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); return; } if (status == f_out_of_memory) { - fl_color_print(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to access file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to access file '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); return; } if (status == f_number_overflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Overflow while trying to access file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Overflow while trying to access file '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); return; } if (status == f_invalid_directory) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid directory while trying to access file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Invalid directory while trying to access file '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); return; } if (status == f_access_denied) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Access denied while trying to access file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Access denied while trying to access file '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); return; } if (status == f_loop) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Loop while trying to access file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Loop while trying to access file '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); return; } - fl_color_print(f_standard_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%d", status); - fl_color_print(f_standard_error, context.error, context.reset, ") occurred for file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); + fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.error, context.reset, ") occurred for file '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } #endif // _di_byte_dump_print_file_error_ diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 8a77888..6b3e4a5 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -37,7 +37,7 @@ extern "C" { printf("%c%c", f_string_eol, f_string_eol); - fl_color_print(f_standard_output, context.important, context.reset, " Special Options: "); + fl_color_print(f_type_output, context.important, context.reset, " Special Options: "); fll_program_print_help_option_long(context, fake_long_documents_disabled, f_console_symbol_long_enable, " Forcibly do not build documents files."); fll_program_print_help_option_long(context, fake_long_documents_enabled, f_console_symbol_long_enable, " Forcibly do build documents files."); @@ -48,7 +48,7 @@ extern "C" { printf("%c%c", f_string_eol, f_string_eol); - fl_color_print(f_standard_output, context.important, context.reset, " Operations: "); + fl_color_print(f_type_output, context.important, context.reset, " Operations: "); fll_program_print_help_option_other(context, fake_other_operation_build, " Build or compile the code based on build settings file."); fll_program_print_help_option_other(context, fake_other_operation_clean, " Delete all build files."); @@ -58,14 +58,14 @@ extern "C" { fll_program_print_help_usage(context, fake_name, "operation"); printf(" When performing the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s", fake_other_operation_build); + fl_color_print(f_type_output, context.notable, context.reset, "%s", fake_other_operation_build); printf(" operation, the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); printf(" parameter specifies a name (limited to alpha-numeric, underscore, and dash) to be used in addition to the global."); printf("%c", f_string_eol); printf(" For example, when a "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s", fake_long_mode); + fl_color_print(f_type_output, context.notable, context.reset, "%s", fake_long_mode); printf(" of 'fll_monolithic' is specified, build libaries from both 'build_libraries' and 'build_libraries-fll_monolithic' are used (but not 'build_libraries-fll_level')."); printf("%c%c", f_string_eol, f_string_eol); @@ -302,10 +302,10 @@ extern "C" { } if (data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the operation '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", fake_other_operation_make); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is not yet implemented."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the operation '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", fake_other_operation_make); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' is not yet implemented."); } } else if (operations[i] == fake_operation_skeleton) { @@ -314,10 +314,10 @@ extern "C" { if (f_status_is_error(status)) { if (data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the operation '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", operations_name[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' failed."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the operation '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", operations_name[i]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' failed."); } break; @@ -327,18 +327,18 @@ extern "C" { // ensure a newline is always put at the end of the program execution, unless in quite mode. if (data->verbosity != fake_verbosity_quiet) { if (f_status_is_error(status)) { - fprintf(f_standard_error, "%c", f_string_eol); + fprintf(f_type_error, "%c", f_string_eol); } else { - fprintf(f_standard_output, "%cAll operations complete.%c%c", f_string_eol, f_string_eol, f_string_eol); + fprintf(f_type_output, "%cAll operations complete.%c%c", f_string_eol, f_string_eol, f_string_eol); } } } else { if (data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify an operation."); - fprintf(f_standard_error, "%c", f_string_eol); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: you failed to specify an operation."); + fprintf(f_type_error, "%c", f_string_eol); } status = f_status_set_error(f_invalid_parameter); diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 667dfb1..fa99e7d 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -199,12 +199,12 @@ extern "C" { if (names.used + settings.environment.used > names.size) { if (names.used + settings.environment.used > f_array_length_size) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The values for the settings '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", fake_build_settings_name_environment); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' of settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' is too large."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The values for the settings '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", fake_build_settings_name_environment); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' of settings file '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' is too large."); } f_macro_string_dynamic_delete_simple(part); @@ -326,10 +326,10 @@ extern "C" { if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_failure) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to execute script: "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to execute script: "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); } } else { @@ -347,7 +347,7 @@ extern "C" { f_return_status fake_build_operate(const fake_data data) { if (data.verbosity != fake_verbosity_quiet) { printf("%c", f_string_eol); - fl_color_print_line(f_standard_output, data.context.important, data.context.reset, "Building project."); + fl_color_print_line(f_type_output, data.context.important, data.context.reset, "Building project."); } f_status status = f_none; @@ -399,13 +399,13 @@ extern "C" { if (status == f_true) { name_function = "f_file_open"; - status = f_file_open(&file, data.file_data_build_settings.string); + status = f_file_open(data.file_data_build_settings.string, 0, &file); if (status == f_none) { name_function = "f_file_read"; - status = f_file_read(&file, &buffer); + status = f_file_read(file, &buffer); - f_file_close(&file); + f_file_close(&file.id); } } else if (status == f_false) { @@ -438,26 +438,26 @@ extern "C" { if (status == f_status_set_error(f_incomplete_utf_on_stop)) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%d", range.start); - fl_color_print(f_standard_error, data.context.error, data.context.reset, " of settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "')."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%d", range.start); + fl_color_print(f_type_error, data.context.error, data.context.reset, " of settings file '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "')."); } } else if (status == f_status_set_error(f_incomplete_utf_on_stop)) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%d", range.start); - fl_color_print(f_standard_error, data.context.error, data.context.reset, " of settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "')."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%d", range.start); + fl_color_print(f_type_error, data.context.error, data.context.reset, " of settings file '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "')."); } } else { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_fss_extended_read", true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_fss_extended_read", f_true); } f_macro_fss_objects_delete_simple(objects); @@ -627,12 +627,12 @@ extern "C" { if (found == f_false) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: the specified mode '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", modes->array[i].string); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' is not a valid mode, according to '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: the specified mode '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", modes->array[i].string); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' is not a valid mode, according to '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); } error_printed = f_true; @@ -680,10 +680,10 @@ extern "C" { if (status == f_status_set_error(f_string_too_large)) { if (data.verbosity != fake_verbosity_quiet) { // @todo update FSS functions to return which setting index the problem happened on. - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: a setting in the build settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' is too long."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: a setting in the build settings file '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' is too long."); } } else if (!error_printed) { @@ -773,14 +773,14 @@ extern "C" { if (settings_single_source[i]->used > 1) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_standard_warning, "%c", f_string_eol); - fl_color_print(f_standard_warning, data.context.warning, data.context.reset, "WARNING: the setting '"); - fl_color_print(f_standard_warning, data.context.notable, data.context.reset, "%s", settings_single_name[i]); - fl_color_print(f_standard_warning, data.context.warning, data.context.reset, "' in the file '"); - fl_color_print(f_standard_warning, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); - fl_color_print(f_standard_warning, data.context.warning, data.context.reset, "' may only have a single property, only using the first: '"); - fl_color_print(f_standard_warning, data.context.notable, data.context.reset, "%s", settings_single_source[i]->array[0].string); - fl_color_print_line(f_standard_warning, data.context.warning, data.context.reset, "'."); + fprintf(f_type_warning, "%c", f_string_eol); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: the setting '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", settings_single_name[i]); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' in the file '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' may only have a single property, only using the first: '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", settings_single_source[i]->array[0].string); + fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "'."); } } @@ -795,18 +795,18 @@ extern "C" { *settings_single_bool[i] = f_true; if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_standard_warning, "%c", f_string_eol); - fl_color_print(f_standard_warning, data.context.warning, data.context.reset, "WARNING: the setting '"); - fl_color_print(f_standard_warning, data.context.notable, data.context.reset, "%s", settings_single_name[i]); - fl_color_print(f_standard_warning, data.context.warning, data.context.reset, "' in the file '"); - fl_color_print(f_standard_warning, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); - fl_color_print(f_standard_warning, data.context.warning, data.context.reset, "' may be either '"); - fl_color_print(f_standard_warning, data.context.notable, data.context.reset, "%s", fake_build_settings_bool_yes); - fl_color_print(f_standard_warning, data.context.warning, data.context.reset, "' or '"); - fl_color_print(f_standard_warning, data.context.notable, data.context.reset, "%s", fake_build_settings_bool_no); - fl_color_print(f_standard_warning, data.context.warning, data.context.reset, "', defaulting to '"); - fl_color_print(f_standard_warning, data.context.notable, data.context.reset, "%s", fake_build_settings_bool_yes); - fl_color_print_line(f_standard_warning, data.context.warning, data.context.reset, "'."); + fprintf(f_type_warning, "%c", f_string_eol); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: the setting '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", settings_single_name[i]); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' in the file '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' may be either '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", fake_build_settings_bool_yes); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' or '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", fake_build_settings_bool_no); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "', defaulting to '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", fake_build_settings_bool_yes); + fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "'."); } } } diff --git a/level_3/fake/c/private-clean.c b/level_3/fake/c/private-clean.c index 4a9abd8..7090943 100644 --- a/level_3/fake/c/private-clean.c +++ b/level_3/fake/c/private-clean.c @@ -12,9 +12,9 @@ extern "C" { if (data.verbosity != fake_verbosity_quiet) { printf("%c", f_string_eol); - fl_color_print(f_standard_output, data.context.important, data.context.reset, "Deleting all files within build directory '"); - fl_color_print(f_standard_output, data.context.notable, data.context.reset, "%s", data.path_build.string); - fl_color_print_line(f_standard_output, data.context.important, data.context.reset, "'."); + fl_color_print(f_type_output, data.context.important, data.context.reset, "Deleting all files within build directory '"); + fl_color_print(f_type_output, data.context.notable, data.context.reset, "%s", data.path_build.string); + fl_color_print_line(f_type_output, data.context.important, data.context.reset, "'."); } if (data.verbosity == fake_verbosity_verbose) { diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 75040bc..9166395 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -415,10 +415,10 @@ extern "C" { if (status == f_invalid_parameter) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid parameter when calling function "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); - fl_color_print_line(f_standard_error, context.error, context.reset, "()."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Invalid parameter when calling function "); + fl_color_print(f_type_error, context.notable, context.reset, "%s", function); + fl_color_print_line(f_type_error, context.error, context.reset, "()."); } return f_none; @@ -426,22 +426,22 @@ extern "C" { if (status == f_error_allocation || status == f_error_reallocation) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to allocate memory in function "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); - fl_color_print_line(f_standard_error, context.error, context.reset, "()."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Unable to allocate memory in function "); + fl_color_print(f_type_error, context.notable, context.reset, "%s", function); + fl_color_print_line(f_type_error, context.error, context.reset, "()."); } return f_none; } if (fallback && verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%d", status); - fl_color_print(f_standard_error, context.error, context.reset, ") in function "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); - fl_color_print_line(f_standard_error, context.error, context.reset, "()."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); + fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.error, context.reset, ") in function "); + fl_color_print(f_type_error, context.notable, context.reset, "%s", function); + fl_color_print_line(f_type_error, context.error, context.reset, "()."); } return f_unknown; @@ -457,10 +457,10 @@ extern "C" { if (status == f_file_not_found) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to find %s '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: failed to find %s '", file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -468,12 +468,12 @@ extern "C" { if (status == f_invalid_parameter) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); - fl_color_print(f_standard_error, context.error, context.reset, "() for the %s '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s", function); + fl_color_print(f_type_error, context.error, context.reset, "() for the %s '", file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -481,10 +481,10 @@ extern "C" { if (status == f_invalid_name) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid %s name '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Invalid %s name '", file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -492,10 +492,10 @@ extern "C" { if (status == f_out_of_memory) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -503,10 +503,10 @@ extern "C" { if (status == f_number_overflow) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Overflow while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Overflow while trying to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -514,10 +514,10 @@ extern "C" { if (status == f_invalid_directory) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid directory while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Invalid directory while trying to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -525,10 +525,10 @@ extern "C" { if (status == f_access_denied) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Access denied while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Access denied while trying to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -536,10 +536,10 @@ extern "C" { if (status == f_loop) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Loop while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: Loop while trying to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -548,10 +548,10 @@ extern "C" { if (is_file) { if (status == f_directory_not_found) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "' due to an invalid directory in the path."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "' due to an invalid directory in the path."); } return f_none; @@ -560,10 +560,10 @@ extern "C" { else { if (status == f_directory_not_found) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "' due to an invalid directory in the path."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "' due to an invalid directory in the path."); } return f_none; @@ -571,10 +571,10 @@ extern "C" { if (status == f_failure) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_none; @@ -582,12 +582,12 @@ extern "C" { } if (fake_print_error(context, verbosity, status, function, f_false) == f_unknown && fallback && verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%d", status); - fl_color_print(f_standard_error, context.error, context.reset, ") occurred while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); + fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.error, context.reset, ") occurred while trying to %s %s '", operation, file_or_directory); + fl_color_print(f_type_error, context.notable, context.reset, "%s", name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } return f_unknown; @@ -597,10 +597,10 @@ extern "C" { #ifndef _di_fake_print_error_parameter_missing_value_ void fake_print_error_parameter_missing_value(const fl_color_context context, const uint8_t verbosity, const f_string parameter) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_standard_error, context.error, context.reset, "' was specified, but no value was given."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_line(f_type_error, context.error, context.reset, "' was specified, but no value was given."); } } #endif // _di_fake_print_error_parameter_missing_value_ @@ -608,10 +608,10 @@ extern "C" { #ifndef _di_fake_print_error_parameter_too_many_ void fake_print_error_parameter_too_many(const fl_color_context context, const uint8_t verbosity, const f_string parameter) { if (verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_standard_error, context.error, context.reset, "' specified too many times."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_line(f_type_error, context.error, context.reset, "' specified too many times."); } } #endif // _di_fake_print_error_parameter_too_many_ @@ -640,10 +640,10 @@ extern "C" { for (uint8_t i = 0; i < 4; i++) { if (data->parameters[parameters_id[i]].total > 1) { if (data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the operation '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", parameters_name[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' specified too many times."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the operation '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", parameters_name[i]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' specified too many times."); } return f_status_set_error(f_invalid_parameter); @@ -697,10 +697,10 @@ extern "C" { if (f_status_is_error(status)) { if (status == f_status_set_error(f_string_too_large)) { if (data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is too long."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' is too long."); } } else { @@ -716,10 +716,10 @@ extern "C" { if (length == 0 || status == f_no_data) { if (data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' must not be empty and must not contain only whitespace."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' must not be empty and must not contain only whitespace."); } } } @@ -793,10 +793,10 @@ extern "C" { if (f_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to process parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: failed to process parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } return status; @@ -807,10 +807,10 @@ extern "C" { if (f_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "f_macro_string_dynamic_new", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to load default for the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: failed to load default for the parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } return status; @@ -828,10 +828,10 @@ extern "C" { if (f_status_is_error(status)) { if (status == f_status_set_error(f_string_too_large)) { if (data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the (combined) parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_defines); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is too long."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the (combined) parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_defines); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' is too long."); } } else { @@ -851,10 +851,10 @@ extern "C" { if (f_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fll_program_parameter_additional_rip", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to process the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: failed to process the parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } return status; @@ -872,10 +872,10 @@ extern "C" { if (f_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "f_utf_is_word_dash_plus", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to process the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: failed to process the parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } return status; @@ -883,12 +883,12 @@ extern "C" { if (status == f_false) { if (data->verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameters value '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", data->mode.array[i].string); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' contains non-word, non-dash, and non-plus characters."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameters value '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", data->mode.array[i].string); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' contains non-word, non-dash, and non-plus characters."); } return f_status_set_error(f_invalid_parameter); @@ -945,7 +945,7 @@ extern "C" { if (parameters_value[i]->used > 0) { memset(&directory_stat, 0, sizeof(struct stat)); - status = f_file_stat(parameters_value[i]->string, &directory_stat); + status = f_file_stat(parameters_value[i]->string, f_true, &directory_stat); if (status == f_status_set_error(f_file_not_found)) status = f_status_set_error(f_directory_not_found); @@ -957,10 +957,10 @@ extern "C" { } } else if (parameters_required[i]) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: No valid path for the (required) directory parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' was found."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: No valid path for the (required) directory parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' was found."); return f_status_set_error(f_directory_not_found); } diff --git a/level_3/fake/c/private-skeleton.c b/level_3/fake/c/private-skeleton.c index 0848a4c..9bc8b40 100644 --- a/level_3/fake/c/private-skeleton.c +++ b/level_3/fake/c/private-skeleton.c @@ -12,7 +12,7 @@ extern "C" { if (data.verbosity != fake_verbosity_quiet) { printf("%c", f_string_eol); - fl_color_print_line(f_standard_output, data.context.important, data.context.reset, "Generating skeleton structure."); + fl_color_print_line(f_type_output, data.context.important, data.context.reset, "Generating skeleton structure."); } { @@ -102,10 +102,10 @@ extern "C" { if (status == f_false) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The path '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' exists but is not a directory."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The path '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' exists but is not a directory."); } return f_status_set_warning(f_failure); @@ -115,10 +115,10 @@ extern "C" { if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_file_not_found) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The path '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' could not be created, a parent directory does not exist."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The path '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' could not be created, a parent directory does not exist."); } else { fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), "f_directory_create", path.string, "create", f_false, f_true); @@ -182,14 +182,14 @@ extern "C" { mode = f_file_mode_all_rwx; } - status = f_file_create(path.string, mode, true); + status = f_file_create(path.string, mode, f_true, f_true); if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_file_not_found) { - fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The path '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' could not be created, a parent directory does not exist."); + fprintf(f_type_error, "%c", f_string_eol); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The file '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' could not be created, a parent directory does not exist."); } else { fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), "f_file_create", path.string, "create", f_true, f_true); diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index 1c6701d..0fed579 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -26,26 +26,26 @@ extern "C" { #endif // _en_firewall_debug_ printf("%c%c", f_string_eol, f_string_eol); - fl_color_print(f_standard_output, context.important, context.reset, " Available Commands: "); + fl_color_print(f_type_output, context.important, context.reset, " Available Commands: "); printf("%c ", f_string_eol); - fl_color_print(f_standard_output, context.standout, context.reset, firewall_command_start); + fl_color_print(f_type_output, context.standout, context.reset, firewall_command_start); printf(" Turn on the firewall"); printf("%c ", f_string_eol); - fl_color_print(f_standard_output, context.standout, context.reset, firewall_command_stop); + fl_color_print(f_type_output, context.standout, context.reset, firewall_command_stop); printf(" Turn off the firewall"); printf("%c ", f_string_eol); - fl_color_print(f_standard_output, context.standout, context.reset, firewall_command_restart); + fl_color_print(f_type_output, context.standout, context.reset, firewall_command_restart); printf(" Turn off and then turn on the firewall"); printf("%c ", f_string_eol); - fl_color_print(f_standard_output, context.standout, context.reset, firewall_command_lock); + fl_color_print(f_type_output, context.standout, context.reset, firewall_command_lock); printf(" Prevent all communication"); printf("%c ", f_string_eol); - fl_color_print(f_standard_output, context.standout, context.reset, firewall_command_show); + fl_color_print(f_type_output, context.standout, context.reset, firewall_command_show); printf(" Show active firewall settings"); fll_program_print_help_usage(context, firewall_name, "command"); @@ -162,7 +162,7 @@ extern "C" { if (strncmp("nat", arguments.argv[data->remaining.array[counter]], 4) != 0) { if (strncmp("mangle", arguments.argv[data->remaining.array[counter]], 7) != 0) { if (strncmp("ports", arguments.argv[data->remaining.array[counter]], 6) != 0) { - fl_color_print_line(f_standard_warning, data->context.warning, data->context.reset, "WARNING: '%s' is not a valid show option", arguments.argv[data->remaining.array[counter]]); + fl_color_print_line(f_type_warning, data->context.warning, data->context.reset, "WARNING: '%s' is not a valid show option", arguments.argv[data->remaining.array[counter]]); } else { show_ports = f_true; @@ -181,17 +181,17 @@ extern "C" { f_macro_string_dynamics_resize(status, parameters, 7); if (f_status_is_error(status)) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); firewall_delete_local_data(&local); firewall_delete_data(data); return status; } if (show_nat) { - fl_color_print(f_standard_output, data->context.standout, data->context.reset, "=========================== "); - fl_color_print(f_standard_output, data->context.title, data->context.reset, "NAT"); - fl_color_print_line(f_standard_output, data->context.standout, data->context.reset, " ============================"); - fflush(f_standard_output); + fl_color_print(f_type_output, data->context.standout, data->context.reset, "=========================== "); + fl_color_print(f_type_output, data->context.title, data->context.reset, "NAT"); + fl_color_print_line(f_type_output, data->context.standout, data->context.reset, " ============================"); + fflush(f_type_output); parameters.used = 6; @@ -211,15 +211,15 @@ extern "C" { status = fll_execute_program((f_string) firewall_tool_iptables, parameters, &results); - fprintf(f_standard_output, "\n"); - fflush(f_standard_output); + fprintf(f_type_output, "\n"); + fflush(f_type_output); } if (f_status_is_not_error(status) && show_mangle) { - fl_color_print(f_standard_output, data->context.standout, data->context.reset, "========================== "); - fl_color_print(f_standard_output, data->context.title, data->context.reset, "MANGLE"); - fl_color_print_line(f_standard_output, data->context.standout, data->context.reset, " =========================="); - fflush(f_standard_output); + fl_color_print(f_type_output, data->context.standout, data->context.reset, "========================== "); + fl_color_print(f_type_output, data->context.title, data->context.reset, "MANGLE"); + fl_color_print_line(f_type_output, data->context.standout, data->context.reset, " =========================="); + fflush(f_type_output); parameters.used = 6; @@ -239,15 +239,15 @@ extern "C" { status = fll_execute_program((f_string) firewall_tool_iptables, parameters, &results); - fprintf(f_standard_output, "\n"); - fflush(f_standard_output); + fprintf(f_type_output, "\n"); + fflush(f_type_output); } if (f_status_is_not_error(status) && show_ports) { - fl_color_print(f_standard_output, data->context.standout, data->context.reset, "========================== "); - fl_color_print(f_standard_output, data->context.title, data->context.reset, "FILTER"); - fl_color_print_line(f_standard_output, data->context.standout, data->context.reset, " =========================="); - fflush(f_standard_output); + fl_color_print(f_type_output, data->context.standout, data->context.reset, "========================== "); + fl_color_print(f_type_output, data->context.title, data->context.reset, "FILTER"); + fl_color_print_line(f_type_output, data->context.standout, data->context.reset, " =========================="); + fflush(f_type_output); parameters.used = 4; @@ -263,31 +263,31 @@ extern "C" { status = fll_execute_program((f_string) firewall_tool_iptables, parameters, &results); - fprintf(f_standard_output, "\n"); - fflush(f_standard_output); + fprintf(f_type_output, "\n"); + fflush(f_type_output); } if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables); - fprintf(f_standard_error, " "); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables); + fprintf(f_type_error, " "); f_string_length i = 0; - fl_color_print_code(f_standard_error, data->context.error); + fl_color_print_code(f_type_error, data->context.error); - fprintf(f_standard_error, "%s ", firewall_tool_iptables); + fprintf(f_type_error, "%s ", firewall_tool_iptables); for (; i < parameters.used; i++) { - fprintf(f_standard_error, "%s ", parameters.array[i].string); + fprintf(f_type_error, "%s ", parameters.array[i].string); } // for - fl_color_print_code(f_standard_error, data->context.reset); - fprintf(f_standard_error, "\n"); + fl_color_print_code(f_type_error, data->context.reset); + fprintf(f_type_error, "\n"); } status = f_status_set_error(status); @@ -321,13 +321,13 @@ extern "C" { status = f_status_set_fine(status); if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_no_data) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: could not find any network devices"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: could not find any network devices"); } else if (status == f_failure) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to read the device directory '%s'", network_devices); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: failed to read the device directory '%s'", network_devices); } firewall_delete_local_data(&local); @@ -410,7 +410,7 @@ extern "C" { return status; } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform lock request because the lock instructions are missing from: %s.", network_path firewall_file_other); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Failed to perform lock request because the lock instructions are missing from: %s.", network_path firewall_file_other); firewall_delete_local_data(&local); firewall_delete_data(data); @@ -450,7 +450,7 @@ extern "C" { } } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform stop request because the lock instructions are missing from: %s.", network_path firewall_file_other); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Failed to perform stop request because the lock instructions are missing from: %s.", network_path firewall_file_other); firewall_delete_local_data(&local); firewall_delete_data(data); @@ -527,7 +527,7 @@ extern "C" { f_macro_string_dynamic_resize(status, file_path, network_path_length + data->devices.array[i].used + firewall_file_suffix_length + 1); if (f_status_is_error(status)) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); firewall_delete_local_data(&local); firewall_delete_data(data); return status; @@ -639,7 +639,7 @@ extern "C" { firewall_delete_local_data(&local); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: You did not pass a command"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: You did not pass a command"); status = f_status_set_error(f_invalid_parameter); } } diff --git a/level_3/firewall/c/main.c b/level_3/firewall/c/main.c index 7eac475..9b0f4c9 100644 --- a/level_3/firewall/c/main.c +++ b/level_3/firewall/c/main.c @@ -5,7 +5,7 @@ int main(const int argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; firewall_data data = firewall_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index afc27fb..06d5c24 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -72,7 +72,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const if (length >= firewall_chain_length && fl_string_compare(local.buffer.string + local.rule_objects.array[i].start, (f_string) firewall_chain, length, firewall_chain_length) == f_equal_to) { if (chain == firewall_chain_custom_id) { // custom chains can only apply to themselves, so silently ignore chain commands specified within a custom chain. - fprintf(f_standard_warning, "WARNING: At line %i, the chain option is meaningle ss inside of a custom chain.", i); + fprintf(f_type_warning, "WARNING: At line %i, the chain option is meaningle ss inside of a custom chain.", i); continue; } @@ -282,17 +282,17 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const // process rule rule, if the remaining rule does not match as firewall_rule, then it is an invalid rule. else if (length < firewall_rule_length || fl_string_compare(local.buffer.string + local.rule_objects.array[i].start, (f_string) firewall_rule, length, firewall_rule_length) == f_not_equal_to) { if (length > 0) { - fl_color_print_code(f_standard_warning, data.context.warning); - fprintf(f_standard_warning, "WARNING: At line %i, the object '", i); - f_print_string(f_standard_warning, local.buffer.string + local.rule_objects.array[i].start, length); - fprintf(f_standard_warning, "' is invalid"); - fl_color_print_code(f_standard_warning, data.context.reset); + fl_color_print_code(f_type_warning, data.context.warning); + fprintf(f_type_warning, "WARNING: At line %i, the object '", i); + f_print_string(f_type_warning, local.buffer.string + local.rule_objects.array[i].start, length); + fprintf(f_type_warning, "' is invalid"); + fl_color_print_code(f_type_warning, data.context.reset); } else { - fprintf(f_standard_warning, "WARNING: At line %i, the object is missing", i); + fprintf(f_type_warning, "WARNING: At line %i, the object is missing", i); } - fprintf(f_standard_warning, "\n"); + fprintf(f_type_warning, "\n"); continue; } @@ -300,17 +300,17 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const length = firewall_macro_structure_size(local.rule_objects, i); if (length > 0) { - fl_color_print_code(f_standard_warning, data.context.warning); - fprintf(f_standard_warning, "WARNING: At line %i, the object '", i); - f_print_string(f_standard_warning, local.buffer.string + local.rule_objects.array[i].start, length); - fprintf(f_standard_warning, "' has invalid content '"); - f_print_string(f_standard_warning, local.buffer.string + local.rule_contents.array[i].array[0].start, firewall_macro_structure_size(local.rule_contents.array[i], 0)); - fprintf(f_standard_warning, "'"); - fl_color_print_code(f_standard_warning, data.context.reset); - fprintf(f_standard_warning, "\n"); + fl_color_print_code(f_type_warning, data.context.warning); + fprintf(f_type_warning, "WARNING: At line %i, the object '", i); + f_print_string(f_type_warning, local.buffer.string + local.rule_objects.array[i].start, length); + fprintf(f_type_warning, "' has invalid content '"); + f_print_string(f_type_warning, local.buffer.string + local.rule_contents.array[i].array[0].start, firewall_macro_structure_size(local.rule_contents.array[i], 0)); + fprintf(f_type_warning, "'"); + fl_color_print_code(f_type_warning, data.context.reset); + fprintf(f_type_warning, "\n"); } else { - fl_color_print_line(f_standard_warning, data.context.warning, data.context.reset, "WARNING: At line %i, the object has no content", i); + fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "WARNING: At line %i, the object has no content", i); } continue; @@ -550,12 +550,12 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const else { length = firewall_macro_structure_size(local.rule_objects, i); - fl_color_print_code(f_standard_warning, data.context.warning); - fprintf(f_standard_warning, "WARNING: At line %i, the object '", i); - f_print_string(f_standard_warning, local.buffer.string + local.rule_objects.array[i].start, length); - fprintf(f_standard_warning, "' has no content"); - fl_color_print_code(f_standard_warning, data.context.reset); - fprintf(f_standard_warning, "\n"); + fl_color_print_code(f_type_warning, data.context.warning); + fprintf(f_type_warning, "WARNING: At line %i, the object '", i); + f_print_string(f_type_warning, local.buffer.string + local.rule_objects.array[i].start, length); + fprintf(f_type_warning, "' has no content"); + fl_color_print_code(f_type_warning, data.context.reset); + fprintf(f_type_warning, "\n"); break; } @@ -578,67 +578,67 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const file_path.used = file_path.size; file_path.string[file_path.used] = 0; - status = f_file_open(&file, file_path.string); + status = f_file_open(file_path.string, 0, &file); } if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); } else if (status == f_file_not_found) { // the file does not have to exist - fl_color_print_line(f_standard_warning, data.context.warning, data.context.reset, "WARNING: Cannot find the file '%.*s'", file_path.used, file_path.string); + fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "WARNING: Cannot find the file '%.*s'", file_path.used, file_path.string); status = f_none; } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to open the file '%.*s'", file_path.used, file_path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Unable to open the file '%.*s'", file_path.used, file_path.string); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%.*s'", file_path.used, file_path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%.*s'", file_path.used, file_path.string); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } if (status != f_file_not_found) { status = f_status_set_error(status); } - f_file_close(&file); + f_file_close(&file.id); } else { - status = f_file_read(&file, &local_buffer); + status = f_file_read(file, &local_buffer); - f_file_close(&file); + f_file_close(&file.id); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read_position()"); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_read()"); } else if (status == f_number_overflow) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Integer overflow while trying to buffer the file '%.*s'", file_path.used, file_path.string); + 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_not_open) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: The file '%.*s' is no longer open", file_path.used, file_path.string); + 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_error_seek) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A seek error occurred while accessing the file '%.*s'", file_path.used, file_path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: A seek error occurred while accessing the file '%.*s'", file_path.used, file_path.string); } else if (status == f_file_error_read) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%.*s'", file_path.used, file_path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%.*s'", file_path.used, file_path.string); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_read_position()", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read()", status); } status = f_status_set_error(status); @@ -656,16 +656,16 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_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.used, file_path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_read() for the file '%.*s'", file_path.used, file_path.string); } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) { // empty files are to be silently ignored } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_read() for the file '%.*s'", status, file_path.used, file_path.string); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_read() for the file '%.*s'", status, file_path.used, file_path.string); } status = f_status_set_error(status); @@ -698,7 +698,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const } if (f_status_is_error(status)) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); f_macro_string_dynamic_delete_simple(ip_list_action); } @@ -718,7 +718,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const f_macro_string_dynamic_new(status, ip_argument, ip_length); if (f_status_is_error(status)) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); break; } @@ -731,33 +731,33 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const // print command when debugging. #ifdef _en_firewall_debug_ if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_standard_debug, data.context.warning); - fprintf(f_standard_debug, "%s ", current_tool); + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", current_tool); for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_debug, data.context.reset); - fprintf(f_standard_debug, "\n"); + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); } #endif // _en_firewall_debug_ status = fll_execute_program((f_string) current_tool, arguments, &results); if (status == f_failure) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", current_tool); - fprintf(f_standard_error, " "); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", current_tool); + fprintf(f_type_error, " "); - fl_color_print_code(f_standard_error, data.context.error); + fl_color_print_code(f_type_error, data.context.error); - fprintf(f_standard_error, "%s ", current_tool); + fprintf(f_type_error, "%s ", current_tool); for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_error, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_error, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_error, data.context.reset); - fprintf(f_standard_error, "\n"); + fl_color_print_code(f_type_error, data.context.reset); + fprintf(f_type_error, "\n"); // remove ip_argument from arguments string. f_macro_string_dynamic_delete_simple(arguments.array[arguments.used]); @@ -766,7 +766,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const break; } else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); // remove ip_argument from arguments string. f_macro_string_dynamic_delete_simple(arguments.array[arguments.used]); @@ -801,37 +801,37 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const // print command when debugging. #ifdef _en_firewall_debug_ if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_standard_debug, data.context.warning); - fprintf(f_standard_debug, "%s ", current_tool); + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", current_tool); for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_debug, data.context.reset); - fprintf(f_standard_debug, "\n"); + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); } #endif // _en_firewall_debug_ status = fll_execute_program(current_tool, arguments, &results); if (status == f_failure) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", current_tool); - fprintf(f_standard_error, " "); - fl_color_print_code(f_standard_error, data.context.error); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", current_tool); + fprintf(f_type_error, " "); + fl_color_print_code(f_type_error, data.context.error); - fprintf(f_standard_error, "%s ", current_tool); + fprintf(f_type_error, "%s ", current_tool); for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_error, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_error, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_error, data.context.reset); - fprintf(f_standard_error, "\n"); + fl_color_print_code(f_type_error, data.context.reset); + fprintf(f_type_error, "\n"); break; } else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); break; } } @@ -1041,15 +1041,15 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved // print command when debugging. #ifdef _en_firewall_debug_ if (data->parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_standard_debug, data->context.warning); - fprintf(f_standard_debug, "%s ", firewall_tool_iptables); + fl_color_print_code(f_type_debug, data->context.warning); + fprintf(f_type_debug, "%s ", firewall_tool_iptables); for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_debug, data->context.reset); - fprintf(f_standard_debug, "\n"); + fl_color_print_code(f_type_debug, data->context.reset); + fprintf(f_type_debug, "\n"); } #endif // _en_firewall_debug_ @@ -1060,15 +1060,15 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved // print command when debugging. #ifdef _en_firewall_debug_ if (data->parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_standard_debug, data->context.warning); - fprintf(f_standard_debug, "%s ", firewall_tool_ip6tables); + fl_color_print_code(f_type_debug, data->context.warning); + fprintf(f_type_debug, "%s ", firewall_tool_ip6tables); for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_debug, data->context.reset); - fprintf(f_standard_debug, "\n"); + fl_color_print_code(f_type_debug, data->context.reset); + fprintf(f_type_debug, "\n"); } #endif // _en_firewall_debug_ @@ -1081,34 +1081,34 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved if (status == f_failure) { if (tool == firewall_program_iptables) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables); } else if (tool == firewall_program_ip6tables) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_tool_ip6tables); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_tool_ip6tables); } - fprintf(f_standard_error, " "); - fl_color_print_code(f_standard_error, data->context.error); + fprintf(f_type_error, " "); + fl_color_print_code(f_type_error, data->context.error); if (tool == firewall_program_iptables) { - fprintf(f_standard_error, "%s ", firewall_tool_iptables); + fprintf(f_type_error, "%s ", firewall_tool_iptables); } else if (tool == firewall_program_ip6tables) { - fprintf(f_standard_error, "%s ", firewall_tool_ip6tables); + fprintf(f_type_error, "%s ", firewall_tool_ip6tables); } for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_error, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_error, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_error, data->context.reset); - fprintf(f_standard_error, "\n"); + fl_color_print_code(f_type_error, data->context.reset); + fprintf(f_type_error, "\n"); } else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); } f_macro_string_dynamics_delete_simple(arguments); @@ -1147,15 +1147,15 @@ f_return_status firewall_delete_chains(const firewall_data data) { // print command when debugging. #ifdef _en_firewall_debug_ if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_standard_debug, data.context.warning); - fprintf(f_standard_debug, "%s ", tools[i]); + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", tools[i]); for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_debug, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_debug, data.context.reset); - fprintf(f_standard_debug, "\n"); + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); } #endif // _en_firewall_debug_ @@ -1165,24 +1165,24 @@ f_return_status firewall_delete_chains(const firewall_data data) { status = f_status_set_fine(status); if (status == f_failure) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", tools[i]); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", tools[i]); - fprintf(f_standard_error, " "); - fl_color_print_code(f_standard_error, data.context.error); + fprintf(f_type_error, " "); + fl_color_print_code(f_type_error, data.context.error); - fprintf(f_standard_error, "%s ", tools[i]); + fprintf(f_type_error, "%s ", tools[i]); for (f_string_length i = 0; i < arguments.used; i++) { - fprintf(f_standard_error, "%.*s ", arguments.array[i].used, arguments.array[i].string); + fprintf(f_type_error, "%.*s ", arguments.array[i].used, arguments.array[i].string); } // for - fl_color_print_code(f_standard_error, data.context.reset); - fprintf(f_standard_error, "\n"); + fl_color_print_code(f_type_error, data.context.reset); + fprintf(f_type_error, "\n"); } else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); } return status; @@ -1205,15 +1205,15 @@ f_return_status firewall_delete_chains(const firewall_data data) { // print command when debugging. #ifdef _en_firewall_debug_ if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_standard_debug, data.context.warning); - fprintf(f_standard_debug, "%s ", tools[i]); + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", tools[i]); for (f_string_length j = 0; j < arguments.used; j++) { - fprintf(f_standard_debug, "%.*s ", arguments.array[j].used, arguments.array[j].string); + fprintf(f_type_debug, "%.*s ", arguments.array[j].used, arguments.array[j].string); } // for - fl_color_print_code(f_standard_debug, data.context.reset); - fprintf(f_standard_debug, "\n"); + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); } #endif // _en_firewall_debug_ @@ -1223,24 +1223,24 @@ f_return_status firewall_delete_chains(const firewall_data data) { status = f_status_set_fine(status); if (status == f_failure) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", tools[i]); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", tools[i]); - fprintf(f_standard_error, " "); - fl_color_print_code(f_standard_error, data.context.error); + fprintf(f_type_error, " "); + fl_color_print_code(f_type_error, data.context.error); - fprintf(f_standard_error, "%s ", tools[i]); + fprintf(f_type_error, "%s ", tools[i]); for (f_string_length j = 0; j < arguments.used; j++) { - fprintf(f_standard_error, "%.*s ", arguments.array[j].used, arguments.array[j].string); + fprintf(f_type_error, "%.*s ", arguments.array[j].used, arguments.array[j].string); } // for - fl_color_print_code(f_standard_error, data.context.reset); - fprintf(f_standard_error, "\n"); + fl_color_print_code(f_type_error, data.context.reset); + fprintf(f_type_error, "\n"); } else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); } return status; @@ -1284,15 +1284,15 @@ f_return_status firewall_default_lock(const firewall_data data) { // print command when debugging. #ifdef _en_firewall_debug_ if (data.parameters[firewall_parameter_debug].result == f_console_result_found) { - fl_color_print_code(f_standard_debug, data.context.warning); - fprintf(f_standard_debug, "%s ", tools[j]); + fl_color_print_code(f_type_debug, data.context.warning); + fprintf(f_type_debug, "%s ", tools[j]); for (f_string_length k = 0; k < arguments.used; k++) { - fprintf(f_standard_debug, "%.*s ", arguments.array[k].used, arguments.array[k].string); + fprintf(f_type_debug, "%.*s ", arguments.array[k].used, arguments.array[k].string); } // for - fl_color_print_code(f_standard_debug, data.context.reset); - fprintf(f_standard_debug, "\n"); + fl_color_print_code(f_type_debug, data.context.reset); + fprintf(f_type_debug, "\n"); } #endif // _en_firewall_debug_ @@ -1302,24 +1302,24 @@ f_return_status firewall_default_lock(const firewall_data data) { status = f_status_set_fine(status); if (status == f_failure) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", tools[j]); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", tools[j]); - fprintf(f_standard_error, " "); - fl_color_print_code(f_standard_error, data.context.error); + fprintf(f_type_error, " "); + fl_color_print_code(f_type_error, data.context.error); - fprintf(f_standard_error, "%s ", tools[j]); + fprintf(f_type_error, "%s ", tools[j]); for (f_string_length k = 0; k < arguments.used; k++) { - fprintf(f_standard_error, "%.*s ", arguments.array[k].used, arguments.array[k].string); + fprintf(f_type_error, "%.*s ", arguments.array[k].used, arguments.array[k].string); } // for - fl_color_print_code(f_standard_error, data.context.reset); - fprintf(f_standard_error, "\n"); + fl_color_print_code(f_type_error, data.context.reset); + fprintf(f_type_error, "\n"); } else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); } return status; @@ -1334,66 +1334,66 @@ f_return_status firewall_buffer_rules(const f_string filename, const bool option f_file file = f_file_initialize; f_status status = f_none; - status = f_file_open(&file, filename); + status = f_file_open(filename, 0, &file); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (optional) { if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); } else if (status != f_file_not_found && status != f_file_error_open && status != f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); } } else { if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); } else if (status == f_file_not_found) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'.", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'.", filename); } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'.", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'.", filename); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); } } return status; } - status = f_file_read(&file, &local->buffer); + status = f_file_read(file, &local->buffer); - f_file_close(&file); + f_file_close(&file.id); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read_position()."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_read()."); } else if (status == f_number_overflow) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'.", filename); + 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_not_open) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open.", filename); + 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_error_seek) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'.", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'.", filename); } else if (status == f_file_error_read) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'.", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'.", filename); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_read_position().", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read().", status); } return status; @@ -1410,16 +1410,16 @@ f_return_status firewall_buffer_rules(const f_string filename, const bool option status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_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); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", filename); } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: No relevant data was found within the file '%s'.", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: No relevant data was found within the file '%s'.", filename); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, filename); } return status; @@ -1440,13 +1440,13 @@ f_return_status firewall_process_rules(f_string_range *input, firewall_local_dat status = f_status_set_fine(status); if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_failure) { // the error message has already been displayed. } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); } f_macro_fss_objects_delete_simple(local->rule_objects); diff --git a/level_3/firewall/c/private-firewall.h b/level_3/firewall/c/private-firewall.h index 2127eee..e9e7517 100644 --- a/level_3/firewall/c/private-firewall.h +++ b/level_3/firewall/c/private-firewall.h @@ -85,7 +85,7 @@ typedef struct { (structure.array[index].stop - structure.array[index].start) + 1 // TODO: temporarily added, convert this to a function below. -// TODO: also report: fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); +// TODO: also report: fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); #define firewall_macro_append_argument_to_arguments(status, arguments, argument) \ if (arguments.used >= arguments.size) { \ f_macro_string_dynamics_resize(status, arguments, arguments.used + firewall_default_allocation_step); \ 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 8da900b..247877d 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 @@ -29,7 +29,7 @@ extern "C" { fll_program_print_help_usage(context, fss_basic_list_read_name, "filename(s)"); - fl_color_print(f_standard_output, context.important, context.reset, " Notes:"); + fl_color_print(f_type_output, context.important, context.reset, " Notes:"); printf("%c", f_string_eol, f_string_eol); @@ -38,27 +38,27 @@ extern "C" { printf("%c", f_string_eol); printf(" When using the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); printf(" option, an order of operations is enforced on the parameters.%c", f_string_eol); printf(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); printf(": An object index at the specified depth.%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); printf(": A new depth within the specified depth, indexed from the root.%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); printf(": An object name at the specified depth.%c", f_string_eol); printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); printf(" must be in numeric order, but values in between may be skipped.%c", f_string_eol); printf(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%c", f_string_eol); printf(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%c", f_string_eol); @@ -66,53 +66,53 @@ extern "C" { printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); printf(" selects a content index at a given depth.%c", f_string_eol); printf(" (This parameter is not synonymous with the depth parameter and does not relate to nested content).%c", f_string_eol); printf("%c", f_string_eol); printf(" Specify both "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); printf(" and the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total); printf(" parameters to get the total objects.%c", f_string_eol); printf("%c", f_string_eol); printf(" When both "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); printf(" and "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); printf(" parameters are specified (at the same depth), the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); printf(" parameter value will be treated as a position relative to the specified "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); printf(" parameter value.%c", f_string_eol); printf("%c", f_string_eol); printf(" This program may support parameters, such as "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); printf(" or "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); printf(", even if not supported by the standard.%c", f_string_eol); printf(" This is done to help ensure consistency for scripting.%c", f_string_eol); printf("%c", f_string_eol); printf(" For parameters like "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); printf(", if the standard doesn't support nested content, then only a depth of 0 would be valid.%c", f_string_eol); printf(" For parameters like "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); printf(", if the standard doesn't support multiple content groups, then only a select of 0 would be valid.%c", f_string_eol); printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_trim); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_trim); printf(" will remove leading and trailing whitespaces when selecting objects or when printing objects.%c", f_string_eol); printf("%c", f_string_eol); @@ -148,45 +148,45 @@ extern "C" { } else if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[fss_basic_list_read_parameter_at].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_basic_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_list_read_parameter_depth].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_basic_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_basic_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a string."); fss_basic_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_basic_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -194,22 +194,22 @@ extern "C" { if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_basic_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_additional) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_basic_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -218,11 +218,11 @@ extern "C" { if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_line); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_basic_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -232,7 +232,7 @@ extern "C" { fss_basic_list_read_depths depths = fss_basic_list_read_depths_initialize; f_string_length counter = 0; - f_string_length original_size = data->file_position.total; + f_string_length original_size = data->quantity.total; status = fss_basic_list_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { @@ -246,7 +246,7 @@ extern "C" { macro_fss_basic_list_read_depths_delete_simple(depths); if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); fss_basic_list_read_delete_data(data); return f_none; @@ -257,9 +257,9 @@ extern "C" { } if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter requires a positive number."); macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); @@ -269,9 +269,9 @@ extern "C" { if (data->process_pipe) { f_file file = f_file_initialize; - file.address = f_pipe; + file.id = f_type_descriptor_input; - status = fl_file_read(&file, &data->buffer); + status = f_file_read(file, &data->buffer); if (f_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "fl_file_read", "-", f_status_set_fine(status)); @@ -299,9 +299,9 @@ extern "C" { for (; counter < data->remaining.used; counter++) { f_file file = f_file_initialize; - status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); + status = f_file_open(arguments.argv[data->remaining.array[counter]], 0, &file); - data->file_position.total = original_size; + data->quantity.total = original_size; if (f_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); @@ -310,26 +310,28 @@ extern "C" { return status; } - if (data->file_position.total == 0) { - fseek(file.address, 0, SEEK_END); + if (data->quantity.total == 0) { + status = f_file_size_by_id(file.id, &data->quantity.total); - data->file_position.total = ftell(file.address); + if (f_status_is_error(status)) { + fss_basic_list_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); + macro_fss_basic_list_read_depths_delete_simple(depths); + fss_basic_list_read_delete_data(data); + } // Skip past empty files. - if (data->file_position.total == 0) { - f_file_close(&file); + if (data->quantity.total == 0) { + f_file_close(&file.id); continue; } - - fseek(file.address, 0, SEEK_SET); } - status = fl_file_read_position(&file, &data->buffer, data->file_position); + status = f_file_read_until(file, &data->buffer, data->quantity.total); - f_file_close(&file); + f_file_close(&file.id); if (f_status_is_error(status)) { - fss_basic_list_read_print_file_error(data->context, "fl_file_read_position", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); + fss_basic_list_read_print_file_error(data->context, "f_file_read_until", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; @@ -353,7 +355,7 @@ extern "C" { macro_fss_basic_list_read_depths_delete_simple(depths); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); status = f_status_set_error(f_invalid_parameter); } diff --git a/level_3/fss_basic_list_read/c/main.c b/level_3/fss_basic_list_read/c/main.c index 4ccd184..3b2ab3c 100644 --- a/level_3/fss_basic_list_read/c/main.c +++ b/level_3/fss_basic_list_read/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; fss_basic_list_read_data data = fss_basic_list_read_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index 5e93978..95a49c6 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -8,12 +8,12 @@ extern "C" { #ifndef _di_fss_basic_list_read_print_file_error_ void fss_basic_list_read_print_file_error(const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) { - if (fll_file_error_print(f_standard_error, context, function_name, file_name, status) == f_false) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%u", status); - fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "."); + if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == f_false) { + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print_line(f_type_error, context.error, context.reset, "."); } } #endif // _di_fss_basic_list_read_print_file_error_ @@ -22,62 +22,62 @@ extern "C" { void fss_basic_list_read_print_number_argument_error(const fl_color_context context, const f_string function_name, const f_string parameter_name, const f_string argument, const f_status status) { if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print_line(f_type_error, context.error, context.reset, "."); } else if (status == f_number_invalid) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is not a valid number for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is not a valid number for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_underflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is too small for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is too small for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_overflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is too large for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is too large for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_negative) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_positive) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' contains a '"); - fl_color_print(f_standard_error, context.notable, context.reset, "+"); - fl_color_print(f_standard_error, context.error, context.reset, "', which is not allowed for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' contains a '"); + fl_color_print(f_type_error, context.notable, context.reset, "+"); + fl_color_print(f_type_error, context.error, context.reset, "', which is not allowed for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_no_data) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "' must not be an empty string."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "' must not be an empty string."); } else { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%u", status); - fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print(f_standard_error, context.error, context.reset, "' for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(f_standard_error, context.error, context.reset, "' with the value '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print(f_type_error, context.error, context.reset, "' for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print(f_type_error, context.error, context.reset, "' with the value '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } } #endif // _di_fss_basic_list_read_print_number_argument_error_ @@ -95,7 +95,7 @@ extern "C" { macro_fss_basic_list_read_depths_new(status, (*depths), depth_size); if (f_status_is_error(status)) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); return status; } @@ -173,12 +173,12 @@ extern "C" { // @todo: move error printing into common function. if (status_code == f_error_allocation || status_code == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status_code == f_string_length_size) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to process '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_trim); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' because the maximum buffer size was reached."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Unable to process '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_trim); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' because the maximum buffer size was reached."); } else { f_string function = "fl_string_append"; @@ -187,20 +187,20 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%u", status_code); - fl_color_print(f_standard_error, data.context.error, data.context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s()", function); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%u", status_code); + fl_color_print(f_type_error, data.context.error, data.context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s()", function); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); } return status; } if (depths->array[i].value_name.used == 0) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' must not be an empty string."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_name); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' must not be an empty string."); return f_status_set_error(f_invalid_parameter); } @@ -211,22 +211,22 @@ extern "C" { for (f_array_length i = 0; i < depths->used; i++) { for (f_array_length j = i + 1; j < depths->used; j++) { if (depths->array[i].depth == depths->array[j].depth) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' may only be specified once for the parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' may only be specified once for the parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); return f_status_set_error(f_invalid_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' may not have the value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' before the value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[j].depth); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' may not have the value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' before the value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[j].depth); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); return f_status_set_error(f_invalid_parameter); } @@ -253,33 +253,33 @@ extern "C" { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " for the file '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_incomplete_utf_on_stop) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ")."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%d", input.start); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, ")."); } else if (status == f_incomplete_utf_on_eos) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ")."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%d", input.start); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, ")."); } else { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%u", status); - fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%u", status); + fl_color_print(f_type_error, data->context.error, data->context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " for the file '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } return f_status_set_error(status); @@ -365,10 +365,10 @@ extern "C" { if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { if (depths.array[0].index_at > 0) { if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) { - fprintf(f_standard_output, "1%c", f_string_eol); + fprintf(f_type_output, "1%c", f_string_eol); } else { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } } else if (depths.array[0].index_name > 0) { @@ -380,10 +380,10 @@ extern "C" { total++; } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); } else { - fprintf(f_standard_output, "%llu%c", data->objects.used, f_string_eol); + fprintf(f_type_output, "%llu%c", data->objects.used, f_string_eol); } return f_none; @@ -402,8 +402,8 @@ extern "C" { for (; i < data->objects.used; i++) { if (names[i]) { if (at == depths.array[0].value_at) { - print_object(f_standard_output, data->buffer, data->objects.array[i]); - fprintf(f_standard_output, "%c", f_string_eol); + print_object(f_type_output, data->buffer, data->objects.array[i]); + fprintf(f_type_output, "%c", f_string_eol); break; } @@ -417,8 +417,8 @@ extern "C" { for (f_string_length i = 0; i < data->objects.used; i++) { if (names[i] == 0) continue; - print_object(f_standard_output, data->buffer, data->objects.array[i]); - fprintf(f_standard_output, "%c", f_string_eol); + print_object(f_type_output, data->buffer, data->objects.array[i]); + fprintf(f_type_output, "%c", f_string_eol); } // for return f_none; @@ -427,7 +427,7 @@ extern "C" { if (depths.array[0].index_at > 0) { if (depths.array[0].value_at >= data->objects.used) { if (names[depths.array[0].value_at] && data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } return f_none; @@ -441,7 +441,7 @@ extern "C" { if (at == depths.array[0].value_at) { if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { if (data->contents.array[i].used == 0) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } else { f_string_length total = 1; @@ -454,7 +454,7 @@ extern "C" { } } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); } return f_none; @@ -463,7 +463,7 @@ extern "C" { if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { if (data->contents.array[i].used == 0) { if (include_empty && line == 0) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } else { @@ -473,11 +473,11 @@ extern "C" { for (; i <= data->contents.array[i].array[0].stop; i++) { if (data->buffer.string[i] == 0) continue; if (data->buffer.string[i] == f_string_eol) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } - fprintf(f_standard_output, "%c", data->buffer.string[i]); + fprintf(f_type_output, "%c", data->buffer.string[i]); } // for } else { @@ -495,11 +495,11 @@ extern "C" { for (; i <= data->contents.array[i].array[0].stop; i++) { if (data->buffer.string[i] == 0) continue; if (data->buffer.string[i] == f_string_eol) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } - fprintf(f_standard_output, "%c", data->buffer.string[i]); + fprintf(f_type_output, "%c", data->buffer.string[i]); } // for break; @@ -513,10 +513,10 @@ extern "C" { } if (data->contents.array[i].used > 0) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); } else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } break; @@ -552,7 +552,7 @@ extern "C" { } // for } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); return f_none; } @@ -569,7 +569,7 @@ extern "C" { if (data->contents.array[i].used == 0) { if (include_empty) { if (line_current == line) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } @@ -601,11 +601,11 @@ extern "C" { if (data->buffer.string[j] == 0) continue; if (data->buffer.string[j] == f_string_eol) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } - fprintf(f_standard_output, "%c", data->buffer.string[j]); + fprintf(f_type_output, "%c", data->buffer.string[j]); } // for break; @@ -622,13 +622,13 @@ extern "C" { if (data->contents.array[i].used == 0) { if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } continue; } - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); } // for return f_none; 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 d4470e9..cb11c04 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 @@ -62,27 +62,27 @@ extern "C" { f_file file = f_file_initialize; f_string_dynamic input = f_string_dynamic_initialize; - file.address = f_pipe; + file.id = f_type_descriptor_input; - status = fl_file_read(&file, &input); + status = f_file_read(file, &input); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); } else if (status == f_file_not_found) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-"); } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-"); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-"); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } f_macro_string_dynamic_delete_simple(input); @@ -140,48 +140,49 @@ extern "C" { if (data->parameters[fss_basic_list_write_parameter_file].result == f_console_result_additional) { f_file output = f_file_initialize; - output.mode = f_file_write_append; - status = f_file_open(&output, arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + output.flags = f_file_flag_append_wo; + + status = f_file_open(arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], 0, &output); if (f_status_is_error(status)) { status = f_status_set_fine(status); - f_file_close(&output); + f_file_close(&output.id); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); } else if (status == f_file_not_found) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } fss_basic_list_write_delete_data(data); return f_status_set_error(status); } - status = fl_file_write(output, buffer); - f_file_close(&output); + status = f_file_write(output, buffer, 0); + f_file_close(&output.id); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); } else if (status == f_file_error_write) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status); } fss_basic_list_write_delete_data(data); @@ -189,7 +190,7 @@ extern "C" { } } else { - f_print_string_dynamic(f_standard_output, buffer); + f_print_string_dynamic(f_type_output, buffer); } } diff --git a/level_3/fss_basic_list_write/c/main.c b/level_3/fss_basic_list_write/c/main.c index 46161a2..884854b 100644 --- a/level_3/fss_basic_list_write/c/main.c +++ b/level_3/fss_basic_list_write/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; fss_basic_list_write_data data = fss_basic_list_write_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } 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 55f527f..074e4cc 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -29,7 +29,7 @@ extern "C" { fll_program_print_help_usage(context, fss_basic_read_name, "filename(s)"); - fl_color_print(f_standard_output, context.important, context.reset, " Notes:"); + fl_color_print(f_type_output, context.important, context.reset, " Notes:"); printf("%c", f_string_eol, f_string_eol); @@ -38,27 +38,27 @@ extern "C" { printf("%c", f_string_eol); printf(" When using the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); printf(" option, an order of operations is enforced on the parameters.%c", f_string_eol); printf(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); printf(": An object index at the specified depth.%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); printf(": A new depth within the specified depth, indexed from the root.%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); printf(": An object name at the specified depth.%c", f_string_eol); printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); printf(" must be in numeric order, but values in between may be skipped.%c", f_string_eol); printf(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%c", f_string_eol); printf(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%c", f_string_eol); @@ -66,53 +66,53 @@ extern "C" { printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); printf(" selects a content index at a given depth.%c", f_string_eol); printf(" (This parameter is not synonymous with the depth parameter and does not relate to nested content).%c", f_string_eol); printf("%c", f_string_eol); printf(" Specify both "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); printf(" and the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total); printf(" parameters to get the total objects.%c", f_string_eol); printf("%c", f_string_eol); printf(" When both "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); printf(" and "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); printf(" parameters are specified (at the same depth), the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); printf(" parameter value will be treated as a position relative to the specified "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); printf(" parameter value.%c", f_string_eol); printf("%c", f_string_eol); printf(" This program may support parameters, such as "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); printf(" or "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); printf(", even if not supported by the standard.%c", f_string_eol); printf(" This is done to help ensure consistency for scripting.%c", f_string_eol); printf("%c", f_string_eol); printf(" For parameters like "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); printf(", if the standard doesn't support nested content, then only a depth of 0 would be valid.%c", f_string_eol); printf(" For parameters like "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); printf(", if the standard doesn't support multiple content groups, then only a select of 0 would be valid.%c", f_string_eol); printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_trim); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_trim); printf(" will remove leading and trailing whitespaces when selecting objects or when printing objects.%c", f_string_eol); printf("%c", f_string_eol); @@ -148,45 +148,45 @@ extern "C" { } else if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[fss_basic_read_parameter_at].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_basic_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_read_parameter_depth].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_basic_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_basic_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a string."); fss_basic_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_basic_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -194,22 +194,22 @@ extern "C" { if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_basic_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_additional) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_basic_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -218,11 +218,11 @@ extern "C" { if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_line); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_basic_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -232,7 +232,7 @@ extern "C" { fss_basic_read_depths depths = fss_basic_read_depths_initialize; f_string_length counter = 0; - f_string_length original_size = data->file_position.total; + f_string_length original_size = data->quantity.total; status = fss_basic_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { @@ -246,7 +246,7 @@ extern "C" { macro_fss_basic_read_depths_delete_simple(depths); if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); fss_basic_read_delete_data(data); return f_none; @@ -257,9 +257,9 @@ extern "C" { } if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter requires a positive number."); macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); @@ -269,9 +269,9 @@ extern "C" { if (data->process_pipe) { f_file file = f_file_initialize; - file.address = f_pipe; + file.id = f_type_descriptor_input; - status = fl_file_read(&file, &data->buffer); + status = f_file_read(file, &data->buffer); if (f_status_is_error(status)) { fss_basic_read_print_file_error(data->context, "fl_file_read", "-", f_status_set_fine(status)); @@ -299,9 +299,9 @@ extern "C" { for (; counter < data->remaining.used; counter++) { f_file file = f_file_initialize; - status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); + status = f_file_open(arguments.argv[data->remaining.array[counter]], 0, &file); - data->file_position.total = original_size; + data->quantity.total = original_size; if (f_status_is_error(status)) { fss_basic_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); @@ -311,26 +311,28 @@ extern "C" { return status; } - if (data->file_position.total == 0) { - fseek(file.address, 0, SEEK_END); + if (data->quantity.total == 0) { + status = f_file_size_by_id(file.id, &data->quantity.total); - data->file_position.total = ftell(file.address); + if (f_status_is_error(status)) { + fss_basic_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); + macro_fss_basic_read_depths_delete_simple(depths); + fss_basic_read_delete_data(data); + } // Skip past empty files. - if (data->file_position.total == 0) { - f_file_close(&file); + if (data->quantity.total == 0) { + f_file_close(&file.id); continue; } - - fseek(file.address, 0, SEEK_SET); } - status = fl_file_read_position(&file, &data->buffer, data->file_position); + status = f_file_read_until(file, &data->buffer, data->quantity.total); - f_file_close(&file); + f_file_close(&file.id); if (f_status_is_error(status)) { - fss_basic_read_print_file_error(data->context, "fl_file_read_position", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); + fss_basic_read_print_file_error(data->context, "f_file_read_until", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); @@ -355,7 +357,7 @@ extern "C" { macro_fss_basic_read_depths_delete_simple(depths); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); status = f_status_set_error(f_invalid_parameter); } diff --git a/level_3/fss_basic_read/c/main.c b/level_3/fss_basic_read/c/main.c index 7d796b0..e08308b 100644 --- a/level_3/fss_basic_read/c/main.c +++ b/level_3/fss_basic_read/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; fss_basic_read_data data = fss_basic_read_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index c824663..0f0247f 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -8,12 +8,12 @@ extern "C" { #ifndef _di_fss_basic_read_print_file_error_ void fss_basic_read_print_file_error(const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) { - if (fll_file_error_print(f_standard_error, context, function_name, file_name, status) == f_false) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%u", status); - fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "."); + if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == f_false) { + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print_line(f_type_error, context.error, context.reset, "."); } } #endif // _di_fss_basic_read_print_file_error_ @@ -22,62 +22,62 @@ extern "C" { void fss_basic_read_print_number_argument_error(const fl_color_context context, const f_string function_name, const f_string parameter_name, const f_string argument, const f_status status) { if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print_line(f_type_error, context.error, context.reset, "."); } else if (status == f_number_invalid) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is not a valid number for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is not a valid number for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_underflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is too small for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is too small for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_overflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is too large for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is too large for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_negative) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_positive) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' contains a '"); - fl_color_print(f_standard_error, context.notable, context.reset, "+"); - fl_color_print(f_standard_error, context.error, context.reset, "', which is not allowed for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' contains a '"); + fl_color_print(f_type_error, context.notable, context.reset, "+"); + fl_color_print(f_type_error, context.error, context.reset, "', which is not allowed for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_no_data) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "' must not be an empty string."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "' must not be an empty string."); } else { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%u", status); - fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print(f_standard_error, context.error, context.reset, "' for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(f_standard_error, context.error, context.reset, "' with the value '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print(f_type_error, context.error, context.reset, "' for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print(f_type_error, context.error, context.reset, "' with the value '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } } #endif // _di_fss_basic_read_print_number_argument_error_ @@ -95,7 +95,7 @@ extern "C" { macro_fss_basic_read_depths_new(status, (*depths), depth_size); if (f_status_is_error(status)) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); return status; } @@ -173,12 +173,12 @@ extern "C" { // @todo: move error printing into common function. if (status_code == f_error_allocation || status_code == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status_code == f_string_length_size) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to process '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_trim); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' because the maximum buffer size was reached."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Unable to process '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_trim); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' because the maximum buffer size was reached."); } else { f_string function = "fl_string_append"; @@ -187,20 +187,20 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%u", status_code); - fl_color_print(f_standard_error, data.context.error, data.context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s()", function); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%u", status_code); + fl_color_print(f_type_error, data.context.error, data.context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s()", function); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); } return status; } if (depths->array[i].value_name.used == 0) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' must not be an empty string."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_name); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' must not be an empty string."); return f_status_set_error(f_invalid_parameter); } @@ -211,22 +211,22 @@ extern "C" { for (f_array_length i = 0; i < depths->used; i++) { for (f_array_length j = i + 1; j < depths->used; j++) { if (depths->array[i].depth == depths->array[j].depth) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' may only be specified once for the parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' may only be specified once for the parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); return f_status_set_error(f_invalid_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' may not have the value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' before the value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[j].depth); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' may not have the value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' before the value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[j].depth); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); return f_status_set_error(f_invalid_parameter); } @@ -253,33 +253,33 @@ extern "C" { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " for the file '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_incomplete_utf_on_stop) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ")."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%d", input.start); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, ")."); } else if (status == f_incomplete_utf_on_eos) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ")."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%d", input.start); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, ")."); } else { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%u", status); - fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%u", status); + fl_color_print(f_type_error, data->context.error, data->context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " for the file '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } return f_status_set_error(status); @@ -365,10 +365,10 @@ extern "C" { if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { if (depths.array[0].index_at > 0) { if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) { - fprintf(f_standard_output, "1%c", f_string_eol); + fprintf(f_type_output, "1%c", f_string_eol); } else { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } } else if (depths.array[0].index_name > 0) { @@ -380,10 +380,10 @@ extern "C" { total++; } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); } else { - fprintf(f_standard_output, "%llu%c", data->objects.used, f_string_eol); + fprintf(f_type_output, "%llu%c", data->objects.used, f_string_eol); } return f_none; @@ -402,8 +402,8 @@ extern "C" { for (; i < data->objects.used; i++) { if (names[i]) { if (at == depths.array[0].value_at) { - print_object(f_standard_output, data->buffer, data->objects.array[i]); - fprintf(f_standard_output, "%c", f_string_eol); + print_object(f_type_output, data->buffer, data->objects.array[i]); + fprintf(f_type_output, "%c", f_string_eol); break; } @@ -417,8 +417,8 @@ extern "C" { for (f_array_length i = 0; i < data->objects.used; i++) { if (names[i] == 0) continue; - print_object(f_standard_output, data->buffer, data->objects.array[i]); - fprintf(f_standard_output, "%c", f_string_eol); + print_object(f_type_output, data->buffer, data->objects.array[i]); + fprintf(f_type_output, "%c", f_string_eol); } // for return f_none; @@ -427,7 +427,7 @@ extern "C" { if (depths.array[0].index_at > 0) { if (depths.array[0].value_at >= data->objects.used) { if (names[depths.array[0].value_at] && data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } return f_none; @@ -447,28 +447,28 @@ extern "C" { if (at == depths.array[0].value_at) { if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { if (data->contents.array[i].used == 0) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } else { - fprintf(f_standard_output, "1%c", f_string_eol); + fprintf(f_type_output, "1%c", f_string_eol); } } else if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { if (data->contents.array[i].used > 0) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); - fprintf(f_standard_output, "%c", f_string_eol); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); + fprintf(f_type_output, "%c", f_string_eol); } else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } else { if (data->contents.array[i].used > 0) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); - fprintf(f_standard_output, "%c", f_string_eol); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); + fprintf(f_type_output, "%c", f_string_eol); } else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } @@ -497,7 +497,7 @@ extern "C" { total++; } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); return f_none; } @@ -512,7 +512,7 @@ extern "C" { if (data->contents.array[i].used == 0) { if (include_empty) { if (line_current == line) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } @@ -523,8 +523,8 @@ extern "C" { } if (line_current == line) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); - fprintf(f_standard_output, "%c", f_string_eol); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); + fprintf(f_type_output, "%c", f_string_eol); break; } @@ -542,14 +542,14 @@ extern "C" { if (data->contents.array[i].used == 0) { if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } continue; } - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); - fprintf(f_standard_output, "%c", f_string_eol); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]); + fprintf(f_type_output, "%c", f_string_eol); } // for return f_none; 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 e3e85d1..9fdfec3 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -62,27 +62,27 @@ extern "C" { f_file file = f_file_initialize; f_string_dynamic input = f_string_dynamic_initialize; - file.address = f_pipe; + file.id = f_type_descriptor_input; - status = fl_file_read(&file, &input); + status = f_file_read(file, &input); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); } else if (status == f_file_not_found) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-"); } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-"); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-"); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } f_macro_string_dynamic_delete_simple(input); @@ -140,48 +140,49 @@ extern "C" { if (data->parameters[fss_basic_write_parameter_file].result == f_console_result_additional) { f_file output = f_file_initialize; - output.mode = f_file_write_append; - status = f_file_open(&output, arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + output.flags = f_file_flag_append_wo; + + status = f_file_open(arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], 0, &output); if (f_status_is_error(status)) { status = f_status_set_fine(status); - f_file_close(&output); + f_file_close(&output.id); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); } else if (status == f_file_not_found) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } fss_basic_write_delete_data(data); return status; } - status = fl_file_write(output, buffer); - f_file_close(&output); + status = f_file_write(output, buffer, 0); + f_file_close(&output.id); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); } else if (status == f_file_error_write) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status); } fss_basic_write_delete_data(data); @@ -189,7 +190,7 @@ extern "C" { } } else { - f_print_string_dynamic(f_standard_output, buffer); + f_print_string_dynamic(f_type_output, buffer); } } diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 547e203..c144eec 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -29,7 +29,7 @@ extern "C" { fll_program_print_help_usage(context, fss_extended_list_read_name, "filename(s)"); - fl_color_print(f_standard_output, context.important, context.reset, " Notes:"); + fl_color_print(f_type_output, context.important, context.reset, " Notes:"); printf("%c", f_string_eol, f_string_eol); @@ -38,27 +38,27 @@ extern "C" { printf("%c", f_string_eol); printf(" When using the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); printf(" option, an order of operations is enforced on the parameters.%c", f_string_eol); printf(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); printf(": An object index at the specified depth.%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); printf(": A new depth within the specified depth, indexed from the root.%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); printf(": An object name at the specified depth.%c", f_string_eol); printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); printf(" must be in numeric order, but values in between may be skipped.%c", f_string_eol); printf(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%c", f_string_eol); printf(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%c", f_string_eol); @@ -66,53 +66,53 @@ extern "C" { printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); printf(" selects a content index at a given depth.%c", f_string_eol); printf(" (This parameter is not synonymous with the depth parameter and does not relate to nested content).%c", f_string_eol); printf("%c", f_string_eol); printf(" Specify both "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); printf(" and the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total); printf(" parameters to get the total objects.%c", f_string_eol); printf("%c", f_string_eol); printf(" When both "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); printf(" and "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); printf(" parameters are specified (at the same depth), the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); printf(" parameter value will be treated as a position relative to the specified "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); printf(" parameter value.%c", f_string_eol); printf("%c", f_string_eol); printf(" This program may support parameters, such as "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); printf(" or "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); printf(", even if not supported by the standard.%c", f_string_eol); printf(" This is done to help ensure consistency for scripting.%c", f_string_eol); printf("%c", f_string_eol); printf(" For parameters like "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); printf(", if the standard doesn't support nested content, then only a depth of 0 would be valid.%c", f_string_eol); printf(" For parameters like "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); printf(", if the standard doesn't support multiple content groups, then only a select of 0 would be valid.%c", f_string_eol); printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_trim); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_trim); printf(" will remove leading and trailing whitespaces when selecting objects or when printing objects.%c", f_string_eol); printf("%c", f_string_eol); @@ -148,45 +148,45 @@ extern "C" { } else if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[fss_extended_list_read_parameter_at].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_extended_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_list_read_parameter_depth].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_extended_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_extended_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_list_read_parameter_name].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a string."); fss_extended_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_extended_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -194,22 +194,22 @@ extern "C" { if (data->parameters[fss_extended_list_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_extended_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_additional) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_extended_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -218,11 +218,11 @@ extern "C" { if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { if (data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_line); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_extended_list_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -232,7 +232,7 @@ extern "C" { fss_extended_list_read_depths depths = fss_extended_list_read_depths_initialize; f_string_length counter = 0; - f_string_length original_size = data->file_position.total; + f_string_length original_size = data->quantity.total; status = fss_extended_list_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { @@ -242,9 +242,9 @@ extern "C" { } if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter requires a positive number."); macro_fss_extended_list_read_depths_delete_simple(depths); fss_extended_list_read_delete_data(data); @@ -254,9 +254,9 @@ extern "C" { if (data->process_pipe) { f_file file = f_file_initialize; - file.address = f_pipe; + file.id = f_type_descriptor_input; - status = fl_file_read(&file, &data->buffer); + status = f_file_read(file, &data->buffer); if (f_status_is_error(status)) { fss_extended_list_read_print_file_error(data->context, "fl_file_read", "-", f_status_set_fine(status)); @@ -283,9 +283,9 @@ extern "C" { for (; counter < data->remaining.used; counter++) { f_file file = f_file_initialize; - status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); + status = f_file_open(arguments.argv[data->remaining.array[counter]], 0, &file); - data->file_position.total = original_size; + data->quantity.total = original_size; if (f_status_is_error(status)) { fss_extended_list_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); @@ -295,26 +295,28 @@ extern "C" { return status; } - if (data->file_position.total == 0) { - fseek(file.address, 0, SEEK_END); + if (data->quantity.total == 0) { + status = f_file_size_by_id(file.id, &data->quantity.total); - data->file_position.total = ftell(file.address); + if (f_status_is_error(status)) { + fss_extended_list_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); + macro_fss_extended_list_read_depths_delete_simple(depths); + fss_extended_list_read_delete_data(data); + } // Skip past empty files. - if (data->file_position.total == 0) { - f_file_close(&file); + if (data->quantity.total == 0) { + f_file_close(&file.id); continue; } - - fseek(file.address, 0, SEEK_SET); } - status = fl_file_read_position(&file, &data->buffer, data->file_position); + status = f_file_read_until(file, &data->buffer, data->quantity.total); - f_file_close(&file); + f_file_close(&file.id); if (f_status_is_error(status)) { - fss_extended_list_read_print_file_error(data->context, "fl_file_read_position", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); + fss_extended_list_read_print_file_error(data->context, "f_file_read_until", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); macro_fss_extended_list_read_depths_delete_simple(depths); fss_extended_list_read_delete_data(data); @@ -338,7 +340,7 @@ extern "C" { macro_fss_extended_list_read_depths_delete_simple(depths); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); status = f_status_set_error(f_invalid_parameter); } diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.h b/level_3/fss_extended_list_read/c/fss_extended_list_read.h index e842bb4..4f31762 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.h +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.h @@ -135,7 +135,7 @@ extern "C" { f_console_parameter_initialize_fss_extended_list_read, \ f_string_dynamic_initialize, \ f_fss_nest_initialize, \ - f_quantity_initialize, \ + f_string_quantity_initialize, \ f_string_lengths_initialize, \ f_false, \ fl_color_context_initialize, \ diff --git a/level_3/fss_extended_list_read/c/main.c b/level_3/fss_extended_list_read/c/main.c index 8237b4a..958b83d 100644 --- a/level_3/fss_extended_list_read/c/main.c +++ b/level_3/fss_extended_list_read/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; fss_extended_list_read_data data = fss_extended_list_read_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index 2dba501..fec3180 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -8,12 +8,12 @@ extern "C" { #ifndef _di_fss_extended_list_read_print_file_error_ void fss_extended_list_read_print_file_error(const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) { - if (fll_file_error_print(f_standard_error, context, function_name, file_name, status) == f_false) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%u", status); - fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "."); + if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == f_false) { + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print_line(f_type_error, context.error, context.reset, "."); } } #endif // _di_fss_extended_list_read_print_file_error_ @@ -22,62 +22,62 @@ extern "C" { void fss_extended_list_read_print_number_argument_error(const fl_color_context context, const f_string function_name, const f_string parameter_name, const f_string argument, const f_status status) { if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print_line(f_type_error, context.error, context.reset, "."); } else if (status == f_number_invalid) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is not a valid number for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is not a valid number for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_underflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is too small for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is too small for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_overflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is too large for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is too large for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_negative) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_positive) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' contains a '"); - fl_color_print(f_standard_error, context.notable, context.reset, "+"); - fl_color_print(f_standard_error, context.error, context.reset, "', which is not allowed for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' contains a '"); + fl_color_print(f_type_error, context.notable, context.reset, "+"); + fl_color_print(f_type_error, context.error, context.reset, "', which is not allowed for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_no_data) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "' must not be an empty string."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "' must not be an empty string."); } else { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%u", status); - fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print(f_standard_error, context.error, context.reset, "' for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(f_standard_error, context.error, context.reset, "' with the value '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print(f_type_error, context.error, context.reset, "' for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print(f_type_error, context.error, context.reset, "' with the value '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } } #endif // _di_fss_extended_list_read_print_number_argument_error_ @@ -95,7 +95,7 @@ extern "C" { macro_fss_extended_list_read_depths_new(status, (*depths), depth_size); if (f_status_is_error(status)) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); return status; } @@ -173,12 +173,12 @@ extern "C" { // @todo: move error printing into common function. if (status_code == f_error_allocation || status_code == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status_code == f_string_length_size) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to process '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_trim); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' because the maximum buffer size was reached."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Unable to process '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_trim); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' because the maximum buffer size was reached."); } else { f_string function = "fl_string_append"; @@ -187,20 +187,20 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%u", status_code); - fl_color_print(f_standard_error, data.context.error, data.context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s()", function); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%u", status_code); + fl_color_print(f_type_error, data.context.error, data.context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s()", function); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); } return status; } if (depths->array[i].value_name.used == 0) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' must not be an empty string."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_name); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' must not be an empty string."); return f_status_set_error(f_invalid_parameter); } @@ -211,22 +211,22 @@ extern "C" { for (f_array_length i = 0; i < depths->used; i++) { for (f_array_length j = i + 1; j < depths->used; j++) { if (depths->array[i].depth == depths->array[j].depth) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' may only be specified once for the parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' may only be specified once for the parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); return f_status_set_error(f_invalid_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' may not have the value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' before the value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[j].depth); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' may not have the value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' before the value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[j].depth); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); return f_status_set_error(f_invalid_parameter); } @@ -253,33 +253,33 @@ extern "C" { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_extended_list_read()"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "fll_fss_extended_list_read()"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " for the file '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_incomplete_utf_on_stop) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ")."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%d", input.start); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, ")."); } else if (status == f_incomplete_utf_on_eos) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ")."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%d", input.start); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, ")."); } else { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%u", status); - fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_extended_list_read()"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%u", status); + fl_color_print(f_type_error, data->context.error, data->context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "fll_fss_extended_list_read()"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " for the file '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } return f_status_set_error(status); @@ -296,7 +296,7 @@ extern "C" { // Requested depths cannot be greater than contents depth. if (depths.used > data->nest.used) { if (data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); return f_none; } @@ -385,10 +385,10 @@ extern "C" { if (depth_setting.index_at > 0) { if (depth_setting.value_at < items->used && names[depth_setting.value_at]) { - fprintf(f_standard_output, "1%c", f_string_eol); + fprintf(f_type_output, "1%c", f_string_eol); } else { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } return f_none; @@ -402,12 +402,12 @@ extern "C" { total++; } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); return f_none; } - fprintf(f_standard_output, "%llu%c", items->used, f_string_eol); + fprintf(f_type_output, "%llu%c", items->used, f_string_eol); return f_none; } @@ -420,8 +420,8 @@ extern "C" { if (depth_setting.index_at > 0) { if (depth_setting.value_at < items->used && names[depth_setting.value_at]) { - print_object(f_standard_output, data->buffer, items->array[depth_setting.value_at].object); - fprintf(f_standard_output, "%c", f_string_eol); + print_object(f_type_output, data->buffer, items->array[depth_setting.value_at].object); + fprintf(f_type_output, "%c", f_string_eol); } return f_none; @@ -429,8 +429,8 @@ extern "C" { for (f_array_length i = 0; i < items->used; i++) { if (names[i]) { - print_object(f_standard_output, data->buffer, items->array[i].object); - fprintf(f_standard_output, "%c", f_string_eol); + print_object(f_type_output, data->buffer, items->array[i].object); + fprintf(f_type_output, "%c", f_string_eol); } } // for @@ -440,7 +440,7 @@ extern "C" { if (depth_setting.index_at > 0) { if (depth_setting.value_at >= items->used) { if (names[depth_setting.value_at] && data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } return f_none; @@ -454,7 +454,7 @@ extern "C" { if (at == depth_setting.value_at) { if (data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) { if (items->array[i].content.used == 0) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } else { f_string_length total = 1; @@ -467,7 +467,7 @@ extern "C" { } } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); } return f_none; @@ -476,7 +476,7 @@ extern "C" { if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) { if (items->array[i].content.used == 0) { if (include_empty && line == 0) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } else { @@ -486,11 +486,11 @@ extern "C" { for (; i <= items->array[i].content.array[0].stop; i++) { if (data->buffer.string[i] == 0) continue; if (data->buffer.string[i] == f_string_eol) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } - fprintf(f_standard_output, "%c", data->buffer.string[i]); + fprintf(f_type_output, "%c", data->buffer.string[i]); } // for } else { @@ -508,11 +508,11 @@ extern "C" { for (; i <= items->array[i].content.array[0].stop; i++) { if (data->buffer.string[i] == 0) continue; if (data->buffer.string[i] == f_string_eol) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } - fprintf(f_standard_output, "%c", data->buffer.string[i]); + fprintf(f_type_output, "%c", data->buffer.string[i]); } // for break; @@ -526,10 +526,10 @@ extern "C" { } if (items->array[i].content.used > 0) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, items->array[i].content.array[0]); + f_print_string_dynamic_partial(f_type_output, data->buffer, items->array[i].content.array[0]); } else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } break; @@ -565,7 +565,7 @@ extern "C" { } // for } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); return f_none; } @@ -582,7 +582,7 @@ extern "C" { if (items->array[i].content.used == 0) { if (include_empty) { if (line_current == line) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } @@ -614,11 +614,11 @@ extern "C" { if (data->buffer.string[j] == 0) continue; if (data->buffer.string[j] == f_string_eol) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } - fprintf(f_standard_output, "%c", data->buffer.string[j]); + fprintf(f_type_output, "%c", data->buffer.string[j]); } // for break; @@ -635,13 +635,13 @@ extern "C" { if (items->array[i].content.used == 0) { if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } continue; } - f_print_string_dynamic_partial(f_standard_output, data->buffer, items->array[i].content.array[0]); + f_print_string_dynamic_partial(f_type_output, data->buffer, items->array[i].content.array[0]); } // for return f_none; 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 8153fb9..6dfa479 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -29,7 +29,7 @@ extern "C" { fll_program_print_help_usage(context, fss_extended_read_name, "filename(s)"); - fl_color_print(f_standard_output, context.important, context.reset, " Notes:"); + fl_color_print(f_type_output, context.important, context.reset, " Notes:"); printf("%c", f_string_eol, f_string_eol); @@ -38,27 +38,27 @@ extern "C" { printf("%c", f_string_eol); printf(" When using the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); printf(" option, an order of operations is enforced on the parameters.%c", f_string_eol); printf(" When this order of operations is in effect, parameters to the right of a depth parameter are influenced by that depth parameter:%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); printf(": An object index at the specified depth.%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); printf(": A new depth within the specified depth, indexed from the root.%c", f_string_eol); printf(" "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); printf(": An object name at the specified depth.%c", f_string_eol); printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); printf(" must be in numeric order, but values in between may be skipped.%c", f_string_eol); printf(" ('-d 0 -a 1 -d 2 -a 2' would specify index 1 at depth 0, any index at depth 1, and index 2 at depth 2.)%c", f_string_eol); printf(" ('-d 2 -a 1 -d 0 -a 2' would be invalid because depth 2 is before depth 1.)%c", f_string_eol); @@ -66,53 +66,53 @@ extern "C" { printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); printf(" selects a content index at a given depth.%c", f_string_eol); printf(" (This parameter is not synonymous with the depth parameter and does not relate to nested content).%c", f_string_eol); printf("%c", f_string_eol); printf(" Specify both "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); printf(" and the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total); printf(" parameters to get the total objects.%c", f_string_eol); printf("%c", f_string_eol); printf(" When both "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); printf(" and "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); printf(" parameters are specified (at the same depth), the "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); printf(" parameter value will be treated as a position relative to the specified "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); printf(" parameter value.%c", f_string_eol); printf("%c", f_string_eol); printf(" This program may support parameters, such as "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); printf(" or "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); printf(", even if not supported by the standard.%c", f_string_eol); printf(" This is done to help ensure consistency for scripting.%c", f_string_eol); printf("%c", f_string_eol); printf(" For parameters like "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); printf(", if the standard doesn't support nested content, then only a depth of 0 would be valid.%c", f_string_eol); printf(" For parameters like "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); printf(", if the standard doesn't support multiple content groups, then only a select of 0 would be valid.%c", f_string_eol); printf("%c", f_string_eol); printf(" The parameter "); - fl_color_print(f_standard_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_trim); + fl_color_print(f_type_output, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_trim); printf(" will remove leading and trailing whitespaces when selecting objects or when printing objects.%c", f_string_eol); printf("%c", f_string_eol); @@ -148,45 +148,45 @@ extern "C" { } else if (data->remaining.used > 0 || data->process_pipe) { if (data->parameters[fss_extended_read_parameter_at].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_extended_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_read_parameter_depth].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_extended_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_extended_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a string."); fss_extended_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' requires a positive number."); fss_extended_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -194,22 +194,22 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_extended_read_delete_data(data); return f_status_set_error(f_invalid_parameter); } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_extended_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -218,11 +218,11 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_line); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); fss_extended_read_delete_data(data); return f_status_set_error(f_invalid_parameter); @@ -232,7 +232,7 @@ extern "C" { fss_extended_read_depths depths = fss_extended_read_depths_initialize; f_string_length counter = 0; - f_string_length original_size = data->file_position.total; + f_string_length original_size = data->quantity.total; status = fss_extended_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { @@ -246,7 +246,7 @@ extern "C" { macro_fss_extended_read_depths_delete_simple(depths); if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); fss_extended_read_delete_data(data); return f_none; @@ -257,9 +257,9 @@ extern "C" { } if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter requires a positive number."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_select); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter requires a positive number."); macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); @@ -269,9 +269,9 @@ extern "C" { if (data->process_pipe) { f_file file = f_file_initialize; - file.address = f_pipe; + file.id = f_type_descriptor_input; - status = fl_file_read(&file, &data->buffer); + status = f_file_read(file, &data->buffer); if (f_status_is_error(status)) { fss_extended_read_print_file_error(data->context, "fl_file_read", "-", f_status_set_fine(status)); @@ -299,9 +299,9 @@ extern "C" { for (; counter < data->remaining.used; counter++) { f_file file = f_file_initialize; - status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); + status = f_file_open(arguments.argv[data->remaining.array[counter]], 0, &file); - data->file_position.total = original_size; + data->quantity.total = original_size; if (f_status_is_error(status)) { fss_extended_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); @@ -311,26 +311,28 @@ extern "C" { return status; } - if (data->file_position.total == 0) { - fseek(file.address, 0, SEEK_END); + if (data->quantity.total == 0) { + status = f_file_size_by_id(file.id, &data->quantity.total); - data->file_position.total = ftell(file.address); + if (f_status_is_error(status)) { + fss_extended_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); + macro_fss_extended_read_depths_delete_simple(depths); + fss_extended_read_delete_data(data); + } // Skip past empty files. - if (data->file_position.total == 0) { - f_file_close(&file); + if (data->quantity.total == 0) { + f_file_close(&file.id); continue; } - - fseek(file.address, 0, SEEK_SET); } - status = fl_file_read_position(&file, &data->buffer, data->file_position); + status = f_file_read_until(file, &data->buffer, data->quantity.total); - f_file_close(&file); + f_file_close(&file.id); if (f_status_is_error(status)) { - fss_extended_read_print_file_error(data->context, "fl_file_read_position", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); + fss_extended_read_print_file_error(data->context, "f_file_read_until", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); @@ -355,7 +357,7 @@ extern "C" { macro_fss_extended_read_depths_delete_simple(depths); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); status = f_status_set_error(f_invalid_parameter); } diff --git a/level_3/fss_extended_read/c/main.c b/level_3/fss_extended_read/c/main.c index d11baad..85576bc 100644 --- a/level_3/fss_extended_read/c/main.c +++ b/level_3/fss_extended_read/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; fss_extended_read_data data = fss_extended_read_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index 2b2166f..1f874a6 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -8,12 +8,12 @@ extern "C" { #ifndef _di_fss_extended_read_print_file_error_ void fss_extended_read_print_file_error(const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) { - if (fll_file_error_print(f_standard_error, context, function_name, file_name, status) == f_false) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%u", status); - fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "."); + if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == f_false) { + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print_line(f_type_error, context.error, context.reset, "."); } } #endif // _di_fss_extended_read_print_file_error_ @@ -22,62 +22,62 @@ extern "C" { void fss_extended_read_print_number_argument_error(const fl_color_context context, const f_string function_name, const f_string parameter_name, const f_string argument, const f_status status) { if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print_line(f_type_error, context.error, context.reset, "."); } else if (status == f_number_invalid) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is not a valid number for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is not a valid number for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_underflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is too small for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is too small for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_overflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is too large for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is too large for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_negative) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_number_positive) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print(f_standard_error, context.error, context.reset, "' contains a '"); - fl_color_print(f_standard_error, context.notable, context.reset, "+"); - fl_color_print(f_standard_error, context.error, context.reset, "', which is not allowed for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The argument '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print(f_type_error, context.error, context.reset, "' contains a '"); + fl_color_print(f_type_error, context.notable, context.reset, "+"); + fl_color_print(f_type_error, context.error, context.reset, "', which is not allowed for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } else if (status == f_no_data) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "' must not be an empty string."); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print_line(f_type_error, context.error, context.reset, "' must not be an empty string."); } else { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, context.notable, context.reset, "%u", status); - fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name); - fl_color_print(f_standard_error, context.error, context.reset, "' for the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); - fl_color_print(f_standard_error, context.error, context.reset, "' with the value '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); + fl_color_print(f_type_error, context.error, context.reset, "' for the parameter '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter_name); + fl_color_print(f_type_error, context.error, context.reset, "' with the value '"); + fl_color_print(f_type_error, context.notable, context.reset, "%s", argument); + fl_color_print_line(f_type_error, context.error, context.reset, "'."); } } #endif // _di_fss_extended_read_print_number_argument_error_ @@ -95,7 +95,7 @@ extern "C" { macro_fss_extended_read_depths_new(status, (*depths), depth_size); if (f_status_is_error(status)) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); return status; } @@ -173,12 +173,12 @@ extern "C" { // @todo: move error printing into common function. if (status_code == f_error_allocation || status_code == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status_code == f_string_length_size) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to process '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_trim); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' because the maximum buffer size was reached."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Unable to process '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_trim); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' because the maximum buffer size was reached."); } else { f_string function = "fl_string_append"; @@ -187,20 +187,20 @@ extern "C" { function = "fl_string_rip"; } - fl_color_print(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%u", status_code); - fl_color_print(f_standard_error, data.context.error, data.context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s()", function); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%u", status_code); + fl_color_print(f_type_error, data.context.error, data.context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s()", function); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); } return status; } if (depths->array[i].value_name.used == 0) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' must not be an empty string."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_name); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' must not be an empty string."); return f_status_set_error(f_invalid_parameter); } @@ -211,22 +211,22 @@ extern "C" { for (f_array_length i = 0; i < depths->used; i++) { for (f_array_length j = i + 1; j < depths->used; j++) { if (depths->array[i].depth == depths->array[j].depth) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' may only be specified once for the parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' may only be specified once for the parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); return f_status_set_error(f_invalid_parameter); } else if (depths->array[i].depth > depths->array[j].depth) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' may not have the value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); - fl_color_print(f_standard_error, data.context.error, data.context.reset, "' before the value '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%llu", depths->array[j].depth); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "'."); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' may not have the value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[i].depth); + fl_color_print(f_type_error, data.context.error, data.context.reset, "' before the value '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", depths->array[j].depth); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); return f_status_set_error(f_invalid_parameter); } @@ -253,33 +253,33 @@ extern "C" { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_extended_read()"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "fll_fss_extended_read()"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " for the file '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_incomplete_utf_on_stop) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ")."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%d", input.start); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, ")."); } else if (status == f_incomplete_utf_on_eos) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ")."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%d", input.start); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, ")."); } else { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%u", status); - fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occurred while calling "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_extended_read()"); - fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error ("); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%u", status); + fl_color_print(f_type_error, data->context.error, data->context.reset, ") has occurred while calling "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "fll_fss_extended_read()"); + fl_color_print(f_type_error, data->context.error, data->context.reset, " for the file '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", filename); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); } return f_status_set_error(status); @@ -360,10 +360,10 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { if (depths.array[0].index_at > 0) { if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) { - fprintf(f_standard_output, "1%c", f_string_eol); + fprintf(f_type_output, "1%c", f_string_eol); } else { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } } else if (depths.array[0].index_name > 0) { @@ -375,10 +375,10 @@ extern "C" { total++; } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); } else { - fprintf(f_standard_output, "%llu%c", data->objects.used, f_string_eol); + fprintf(f_type_output, "%llu%c", data->objects.used, f_string_eol); } return f_none; @@ -397,8 +397,8 @@ extern "C" { for (; i < data->objects.used; i++) { if (names[i]) { if (at == depths.array[0].value_at) { - print_object(f_standard_output, data->buffer, data->objects.array[i]); - fprintf(f_standard_output, "%c", f_string_eol); + print_object(f_type_output, data->buffer, data->objects.array[i]); + fprintf(f_type_output, "%c", f_string_eol); break; } @@ -412,8 +412,8 @@ extern "C" { for (f_string_length i = 0; i < data->objects.used; i++) { if (names[i] == 0) continue; - print_object(f_standard_output, data->buffer, data->objects.array[i]); - fprintf(f_standard_output, "%c", f_string_eol); + print_object(f_type_output, data->buffer, data->objects.array[i]); + fprintf(f_type_output, "%c", f_string_eol); } // for return f_none; @@ -422,7 +422,7 @@ extern "C" { if (depths.array[0].index_at > 0) { if (depths.array[0].value_at >= data->objects.used) { if (names[depths.array[0].value_at] && data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } return f_none; @@ -436,10 +436,10 @@ extern "C" { if (at == depths.array[0].value_at) { if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { if (data->contents.array[i].used == 0) { - fprintf(f_standard_output, "0%c", f_string_eol); + fprintf(f_type_output, "0%c", f_string_eol); } else { - fprintf(f_standard_output, "1%c", f_string_eol); + fprintf(f_type_output, "1%c", f_string_eol); } return f_none; @@ -452,30 +452,30 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { if (select < data->contents.array[i].used) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[select]); - fprintf(f_standard_output, "%c", f_string_eol); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[select]); + fprintf(f_type_output, "%c", f_string_eol); } } else { for (j = 0; j < data->contents.array[i].used; j++) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[j]); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[j]); if (j + 1 < data->contents.array[i].used) { printf(" "); } } // for - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } else if (include_empty) { if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { if (select == 0) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } else { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } } @@ -488,30 +488,30 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { if (select < data->contents.array[i].used) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[select]); - fprintf(f_standard_output, "%c", f_string_eol); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[select]); + fprintf(f_type_output, "%c", f_string_eol); } } else { for (j = 0; j < data->contents.array[i].used; j++) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[j]); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[j]); if (j + 1 < data->contents.array[i].used) { printf(" "); } } // for - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } else if (include_empty) { if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { if (select == 0) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } else { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } @@ -540,7 +540,7 @@ extern "C" { total++; } // for - fprintf(f_standard_output, "%llu%c", total, f_string_eol); + fprintf(f_type_output, "%llu%c", total, f_string_eol); return f_none; } @@ -557,7 +557,7 @@ extern "C" { if (data->contents.array[i].used == 0) { if (include_empty) { if (line_current == line) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); break; } @@ -570,20 +570,20 @@ extern "C" { if (line_current == line) { if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { if (select < data->contents.array[i].used) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[select]); - fprintf(f_standard_output, "%c", f_string_eol); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[select]); + fprintf(f_type_output, "%c", f_string_eol); } } else { for (j = 0; j < data->contents.array[i].used; j++) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[j]); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[j]); if (j + 1 < data->contents.array[i].used) { printf(" "); } } // for - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } break; @@ -605,7 +605,7 @@ extern "C" { if (data->contents.array[i].used == 0) { if (include_empty && select == 0) { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } continue; @@ -613,20 +613,20 @@ extern "C" { if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { if (select < data->contents.array[i].used) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[select]); - fprintf(f_standard_output, "%c", f_string_eol); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[select]); + fprintf(f_type_output, "%c", f_string_eol); } } else { for (j = 0; j < data->contents.array[i].used; j++) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[j]); + f_print_string_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[j]); if (j + 1 < data->contents.array[i].used) { printf(" "); } } // for - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_type_output, "%c", f_string_eol); } } // for 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 2dadede..caeab35 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -50,22 +50,22 @@ extern "C" { status = f_status_set_fine(status); if (status == f_no_data) { - fl_color_print_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."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass."); // TODO: there is a way to identify which parameter is incorrect // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0 // nothing can be 0 as that represents the program name, unless arguments.argv[] is improperly created } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_invalid_utf) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling f_console_parameter_process()."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling f_console_parameter_process()."); } else if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_console_parameter_process()."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_console_parameter_process()."); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_console_parameter_process().", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_console_parameter_process().", status); } fss_extended_write_delete_data(data); @@ -89,27 +89,27 @@ extern "C" { f_file file = f_file_initialize; f_string_dynamic input = f_string_dynamic_initialize; - file.address = f_pipe; + file.id = f_type_descriptor_input; - status = fl_file_read(&file, &input); + status = f_file_read(file, &input); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); } else if (status == f_file_not_found) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-"); } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-"); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-"); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } f_macro_string_dynamic_delete_simple(input); @@ -205,48 +205,49 @@ extern "C" { if (data->parameters[fss_extended_write_parameter_file].result == f_console_result_additional) { f_file output = f_file_initialize; - output.mode = f_file_write_append; - status = f_file_open(&output, arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + output.flags = f_file_flag_append_wo; + + status = f_file_open(arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], 0, &output); if (f_status_is_error(status)) { status = f_status_set_fine(status); - f_file_close(&output); + f_file_close(&output.id); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()"); } else if (status == f_file_not_found) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } fss_extended_write_delete_data(data); return status; } - status = fl_file_write(output, buffer); - f_file_close(&output); + status = f_file_write(output, buffer, 0); + f_file_close(&output.id); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()"); } else if (status == f_file_error_write) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]); } else { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status); } fss_extended_write_delete_data(data); @@ -254,7 +255,7 @@ extern "C" { } } else { - f_print_string_dynamic(f_standard_output, buffer); + f_print_string_dynamic(f_type_output, buffer); } } diff --git a/level_3/fss_extended_write/c/main.c b/level_3/fss_extended_write/c/main.c index e556376..24fc41a 100644 --- a/level_3/fss_extended_write/c/main.c +++ b/level_3/fss_extended_write/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; fss_extended_write_data data = fss_extended_write_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index 66b34c1..c485d7a 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -60,39 +60,39 @@ extern "C" { if (data->parameters[fss_status_code_parameter_is_error].result == f_console_result_found) { if (data->parameters[fss_status_code_parameter_is_warning].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); fss_status_code_delete_data(data); return f_status_set_error(status); } else if (data->parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_error); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); fss_status_code_delete_data(data); return f_status_set_error(status); } } else if (data->parameters[fss_status_code_parameter_is_warning].result == f_console_result_found && data->parameters[fss_status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_warning); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fss_status_code_long_is_fine); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); fss_status_code_delete_data(data); return f_status_set_error(status); } if (data->remaining.used == 0 && !data->process_pipe) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify an error code."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: you failed to specify an error code."); fss_status_code_delete_data(data); return f_status_set_error(f_invalid_parameter); diff --git a/level_3/fss_status_code/c/main.c b/level_3/fss_status_code/c/main.c index 9d899c3..f7ef4e2 100644 --- a/level_3/fss_status_code/c/main.c +++ b/level_3/fss_status_code/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; fss_status_code_data data = fss_status_code_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/fss_status_code/c/private-fss_status_code.c b/level_3/fss_status_code/c/private-fss_status_code.c index 9c0cf9d..9ac19aa 100644 --- a/level_3/fss_status_code/c/private-fss_status_code.c +++ b/level_3/fss_status_code/c/private-fss_status_code.c @@ -53,13 +53,13 @@ extern "C" { status = fl_console_parameter_to_number_unsigned(value, &number); if (status == f_none) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "invalid name"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "invalid name"); return f_status_set_error(f_invalid_parameter); } if (status == f_no_data || f_status_set_fine(status) == f_invalid_parameter) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "invalid data"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "invalid data"); return status; } @@ -76,10 +76,10 @@ extern "C" { if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_invalid_data) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "unknown name"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "unknown name"); } else { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "failed to convert"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "failed to convert"); } return status; @@ -87,7 +87,7 @@ extern "C" { } if (status == f_invalid_data) { - fl_color_print_line(f_standard_output, data.context.warning, data.context.reset, "unknown code"); + fl_color_print_line(f_type_output, data.context.warning, data.context.reset, "unknown code"); return f_none; } @@ -114,10 +114,10 @@ extern "C" { if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_invalid_data) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "unknown code"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "unknown code"); } else { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "failed to convert"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "failed to convert"); } return status; @@ -134,17 +134,17 @@ extern "C" { f_status status = fl_console_parameter_to_number_unsigned(value, number); if (*number > f_status_size_max_with_signal) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "out of range"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "out of range"); return status; } if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_number_negative) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "out of range"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "out of range"); } else { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "invalid number"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "invalid number"); } return status; diff --git a/level_3/init/c/init.c b/level_3/init/c/init.c index e4fa957..d745226 100644 --- a/level_3/init/c/init.c +++ b/level_3/init/c/init.c @@ -117,13 +117,13 @@ extern "C" { pid_t pid_services = clone(init_handler_child_services, stack_memory.services + init_stack_size_small_services, init_flags_clone, stack_memory.services); if (pid_services < 0) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to clone services process (errno = %i).", errno); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Failed to clone services process (errno = %i).", errno); } pid_t pid_control_file = clone(init_handler_child_control_file, stack_memory.control_file + init_stack_size_control_file, init_flags_clone, stack_memory.control_file); if (pid_control_file < 0) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to clone control via file process (errno = %i).", errno); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: Failed to clone control via file process (errno = %i).", errno); } */ @@ -151,11 +151,11 @@ extern "C" { continue; } else if (errno != EINTR) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: sigwaitinfo() failed (errno = %i).", errno); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: sigwaitinfo() failed (errno = %i).", errno); signal_problem_count++; if (signal_problem_count > problem_count_max_signal_size) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: max signal problem count has been reached, sleeping for a period of time.", errno); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: max signal problem count has been reached, sleeping for a period of time.", errno); sleep(init_panic_signal_sleep_seconds); signal_problem_count = 0; } diff --git a/level_3/init/c/main.c b/level_3/init/c/main.c index e78f97f..c1bcfd1 100644 --- a/level_3/init/c/main.c +++ b/level_3/init/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; init_data data = init_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/init/c/private-init.c b/level_3/init/c/private-init.c index 09b99ef..97dcdc1 100644 --- a/level_3/init/c/private-init.c +++ b/level_3/init/c/private-init.c @@ -10,28 +10,28 @@ f_status status = f_none; f_string_quantity quantity = f_string_quantity_initialize; - status = f_file_open(&file, filename); + status = f_file_open(filename, 0, 0, &file); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (optional) { if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); } else if (status != f_file_not_found && status != f_file_error_open && status != f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); } } else { if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()."); } else if (status == f_file_not_found) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to find the file '%s'.", filename); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Unable to find the file '%s'.", filename); } else if (status == f_file_error_open) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to open the file '%s'.", filename); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Unable to open the file '%s'.", filename); } else if (status == f_file_error_descriptor) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open().", status); } } @@ -41,27 +41,27 @@ f_macro_file_reset_position(quantity, file) fflush(stdout); - status = fl_file_read_position(&file, buffer, quantity); + status = f_file_read_until(file, buffer, quantity); - f_file_close(&file); + f_file_close(&file.id); if (f_status_is_error(status)) { status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read_position()."); + 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_standard_error, data.context.error, data.context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'.", filename); + 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_not_open) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: The file '%s' is no longer open.", filename); + 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_error_seek) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A seek error occurred while accessing the file '%s'.", filename); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: A seek error occurred while accessing the file '%s'.", filename); } else if (status == f_file_error_read) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%s'.", filename); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%s'.", filename); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_read_position().", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_read_until().", status); } return f_status_set_error(status); @@ -77,13 +77,13 @@ status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_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); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", filename); } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: No relevant data was found within the file '%s'.", filename); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: No relevant data was found within the file '%s'.", filename); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, filename); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, filename); } return f_status_set_error(status); @@ -107,11 +107,11 @@ status = f_status_set_fine(status); if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_failure) { // the error message has already been displayed. } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); } f_macro_fss_objects_delete_simple(local->rule_objects); @@ -495,13 +495,13 @@ status = f_status_set_fine(status); if (status == f_invalid_parameter) { - fl_color_print_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'.", init_rule_core_file); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", init_rule_core_file); } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: No relevant data was found within the file '%s'.", init_rule_core_file); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: No relevant data was found within the file '%s'.", init_rule_core_file); } else if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, init_rule_core_file); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.", status, init_rule_core_file); } f_macro_string_dynamic_delete(buffer); @@ -526,10 +526,10 @@ if (f_status_is_error(status_process)) { if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); } // @todo: init_delete_data((*data)); @@ -552,11 +552,11 @@ status = f_status_set_fine(status); if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, data.context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, data.context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else if (status == f_failure) { // the error message has already been displayed. } else { - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); } f_macro_fss_objects_delete_simple((*rule_objects)); @@ -566,10 +566,10 @@ } else { if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory."); + fl_color_print_line(f_type_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory."); } else { - fl_color_print_line(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); + fl_color_print_line(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling init_load_main_rule().", status); } } diff --git a/level_3/status_code/c/main.c b/level_3/status_code/c/main.c index 820b4cf..ad0a6e2 100644 --- a/level_3/status_code/c/main.c +++ b/level_3/status_code/c/main.c @@ -4,7 +4,7 @@ int main(const unsigned long argc, const f_string *argv) { const f_console_arguments arguments = { argc, argv }; status_code_data data = status_code_data_initialize; - if (f_pipe_exists()) { + if (f_pipe_input_exists()) { data.process_pipe = f_true; } diff --git a/level_3/status_code/c/private-status_code.c b/level_3/status_code/c/private-status_code.c index 07f0526..2c81ed7 100644 --- a/level_3/status_code/c/private-status_code.c +++ b/level_3/status_code/c/private-status_code.c @@ -53,13 +53,13 @@ extern "C" { status = fl_console_parameter_to_number_unsigned(value, &number); if (status == f_none) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "invalid name"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "invalid name"); return f_status_set_error(f_invalid_parameter); } if (status == f_no_data || f_status_set_fine(status) == f_invalid_parameter) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "invalid data"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "invalid data"); return status; } @@ -71,17 +71,17 @@ extern "C" { if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_invalid_data) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "unknown name"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "unknown name"); } else { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "failed to convert"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "failed to convert"); } return status; } if (status == f_invalid_data) { - fl_color_print_line(f_standard_output, data.context.warning, data.context.reset, "unknown code"); + fl_color_print_line(f_type_output, data.context.warning, data.context.reset, "unknown code"); return f_none; } @@ -108,10 +108,10 @@ extern "C" { if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_invalid_data) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "unknown code"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "unknown code"); } else { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "failed to convert"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "failed to convert"); } return status; @@ -128,17 +128,17 @@ extern "C" { f_status status = fl_console_parameter_to_number_unsigned(value, number); if (*number > f_status_size_max_with_signal) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "out of range"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "out of range"); return status; } if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_number_negative) { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "out of range"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "out of range"); } else { - fl_color_print_line(f_standard_output, data.context.error, data.context.reset, "invalid number"); + fl_color_print_line(f_type_output, data.context.error, data.context.reset, "invalid number"); } return status; diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index d7a92d5..6ff0b7e 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -60,39 +60,39 @@ extern "C" { if (data->parameters[status_code_parameter_is_error].result == f_console_result_found) { if (data->parameters[status_code_parameter_is_warning].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); status_code_delete_data(data); return f_status_set_error(status); } else if (data->parameters[status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_error); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); status_code_delete_data(data); return f_status_set_error(status); } } else if (data->parameters[status_code_parameter_is_warning].result == f_console_result_found && data->parameters[status_code_parameter_is_fine].result == f_console_result_found) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "."); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_warning); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' cannot be used with the parameter "); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, status_code_long_is_fine); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "."); status_code_delete_data(data); return f_status_set_error(status); } if (data->remaining.used == 0 && !data->process_pipe) { - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify a status code."); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: you failed to specify a status code."); status_code_delete_data(data); return f_status_set_error(f_invalid_parameter); -- 1.8.3.1