This is a major rewrite of the error code system.
Previously, the error system did the following:
- used an unsigned short data type
- allowed for all 16 bits to be used
- because it was unsigned short, different architectures might have different size.
- it is rather inefficient and ugly to check for errors when there may be as many as 30 different error codes to compare against.
The new error system does the following:
- enforce exactly 16-bit unsigned integer by using uint16_t.
- reserves the first two high order bits in the following manner:
- bit 1 = error bit (1000 0000 0000 0000)
- bit 2 = warning bit (0100 0000 0000 0000)
- (note setting both bit 1 and bit 2 is unsupported)
- provide a series of macros to quickly detect and manage the new bits
- limits the total available number of error codes to 14-bits instead of 16-bits
The advantage of the new system is that what the status code is can be detected in one or two conditionals (using bitwise operations).
This should speed up performance and make the code easier to read.
#ifndef _di_f_console_identify_
f_return_status f_console_identify(const f_string input, f_console_id *result) {
#ifndef _di_level_0_parameter_checking_
- if (result == f_null) return f_invalid_parameter;
+ if (result == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
const f_string_length length = strnlen(input, 4);
#ifndef _di_f_character_to_digit_
f_return_status f_character_to_digit(const f_autochar character, f_u_long *digit) {
#ifndef _di_level_0_parameter_checking_
- if (digit == f_null) return f_invalid_parameter;
+ if (digit == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
switch (character) {
#ifndef _di_f_character_to_hexdigit_
f_return_status f_character_to_hexdigit(const f_autochar character, f_u_long *digit) {
#ifndef _di_level_0_parameter_checking_
- if (digit == f_null) return f_invalid_parameter;
+ if (digit == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
switch (character) {
#ifndef _di_f_string_to_digit_
f_return_status f_string_to_digit(const f_string string, f_u_long *digit, const f_string_location location) {
#ifndef _di_level_0_parameter_checking_
- if (digit == f_null) return f_invalid_parameter;
- if (location.start < 0) return f_invalid_parameter;
- if (location.stop <= location.start) return f_invalid_parameter;
- if (string == 0) return f_invalid_parameter;
+ if (digit == f_null) return f_error_set_error(f_invalid_parameter);
+ if (location.start < 0) return f_error_set_error(f_invalid_parameter);
+ if (location.stop <= location.start) return f_error_set_error(f_invalid_parameter);
+ if (string == 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_string_length current_location = location.start;
- f_u_long scale = 0;
- f_u_long temp_digit = 0;
+ f_u_long scale = 0;
+ f_u_long temp_digit = 0;
while (current_location < location.stop) {
if (f_character_to_digit(string[current_location], &temp_digit) == f_none) {
#ifndef _di_f_string_to_hexdigit_
f_return_status f_string_to_hexdigit(const f_string string, f_u_long *digit, const f_string_location location) {
#ifndef _di_level_0_parameter_checking_
- if (digit == f_null) return f_invalid_parameter;
- if (location.start < 0) return f_invalid_parameter;
- if (location.stop <= location.start) return f_invalid_parameter;
- if (string == 0) return f_invalid_parameter;
+ if (digit == f_null) return f_error_set_error(f_invalid_parameter);
+ if (location.start < 0) return f_error_set_error(f_invalid_parameter);
+ if (location.stop <= location.start) return f_error_set_error(f_invalid_parameter);
+ if (string == 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_string_length current_location = location.start;
- f_u_long scale = 0;
- f_u_long temp_digit = 0;
+ f_u_long scale = 0;
+ f_u_long temp_digit = 0;
while (current_location < location.stop) {
if (f_character_to_hexdigit(string[current_location], &temp_digit) == f_none) {
#define _F_conversion_h
// fll includes
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
#include <level_0/strings.h>
#ifdef __cplusplus
potential_error == f_unterminated_group_on_stop)
#endif // _di_f_macro_test_for_unterminated_group_errors_
+#ifndef _di_f_error_masks_
+ // f_status is required to be exactly 16 bits, the first two high order bits represent error and warning respectively.
+ #define f_error_bit_error 32768
+ #define f_error_bit_warning 16384
+ #define f_error_bit_mask 49152
+ #define f_error_bit_fine 16383
+ #define f_error_bit_not_error 32767
+
+ #define f_error_is_error(status) status & f_error_bit_error
+ #define f_error_is_warning(status) status & f_error_bit_warning
+ #define f_error_is_problem(status) status & f_error_bit_mask // this is either a warning or an error
+ #define f_error_is_fine(status) (status & f_error_bit_mask) == 0
+ #define f_error_is_not_error(status) (status & f_error_bit_not_error) == 0
+
+ #define f_error_set_error(status) status | f_error_bit_error
+ #define f_error_set_warning(status) status | f_error_bit_warning
+
+ // use f_error_unmask to remove the error and warning bits
+ #define f_error_unmask(status) status & f_error_bit_fine
+#endif // _di_f_error_masks_
+
// use of an enumerator makes more sense here than explicitly defining every error code
enum {
#ifndef _di_f_errors_booleans_
#ifndef _di_f_file_open_
f_return_status f_file_open(f_file *file_information, const f_string filename) {
#ifndef _di_level_0_parameter_checking_
- if (file_information == f_null) return f_invalid_parameter;
+ if (file_information == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
// if file->mode is unset, then this may cause a segfault, depending on whether or not the libc will handle this appropriately
- if (file_information->mode == 0) return f_invalid_parameter;
+ if (file_information->mode == 0) return f_error_set_error(f_invalid_parameter);
file_information->file = fopen(filename, file_information->mode);
- if (file_information->file == 0) return f_file_not_found;
- if (ferror(file_information->file) != 0) return f_file_open_error;
+ if (file_information->file == 0) return f_error_set_error(f_file_not_found);
+ if (ferror(file_information->file) != 0) return f_error_set_error(f_file_open_error);
file_information->id = fileno(file_information->file);
- if (file_information->id == -1) return f_file_descriptor_error;
+ if (file_information->id == -1) return f_error_set_error(f_file_descriptor_error);
return f_none;
}
#ifndef _di_f_file_close_
f_return_status f_file_close(f_file *file_information) {
#ifndef _di_level_0_parameter_checking_
- if (file_information == f_null) return f_invalid_parameter;
+ if (file_information == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
- if (file_information->file == 0) return f_file_not_open;
+ if (file_information->file == 0) return f_error_set_error(f_file_not_open);
// if we were given a file descriptor as well, make sure to flush all changes to the disk that are not flushed by the 'fflush()' command
if (file_information->id != 0) {
// make sure all unfinished data gets completed
- if (fsync(file_information->id) != 0) return f_file_synchronize_error;
+ if (fsync(file_information->id) != 0) return f_error_set_error(f_file_synchronize_error);
}
if (fclose(file_information->file) == 0) {
file_information->file = 0;
return f_none;
}
- else return f_file_close_error;
+ else return f_error_set_error(f_file_close_error);
}
#endif // _di_f_file_close_
#ifndef _di_f_file_flush_
f_return_status f_file_flush(f_file *file_information) {
#ifndef _di_level_0_parameter_checking_
- if (file_information == f_null) return f_invalid_parameter;
+ if (file_information == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
- if (file_information->file == 0) return f_file_not_open;
+ if (file_information->file == 0) return f_error_set_error(f_file_not_open);
if (fflush(file_information->file) == 0) return f_none;
- else return f_file_flush_error;
+ else return f_error_set_error(f_file_flush_error);
}
#endif // _di_f_file_flush_
#ifndef _di_f_file_read_
f_return_status f_file_read(f_file *file_information, f_dynamic_string *buffer, const f_file_position location) {
#ifndef _di_level_0_parameter_checking_
- if (file_information == f_null) return f_invalid_parameter;
- if (buffer->used >= buffer->size) return f_invalid_parameter;
+ if (file_information == f_null) return f_error_set_error(f_invalid_parameter);
+ if (buffer->used >= buffer->size) return f_error_set_error(f_invalid_parameter);
- if (location.buffer_start < 0) return f_invalid_parameter;
- if (location.file_start < 0) return f_invalid_parameter;
- if (location.total_elements < 0) return f_invalid_parameter;
+ if (location.buffer_start < 0) return f_error_set_error(f_invalid_parameter);
+ if (location.file_start < 0) return f_error_set_error(f_invalid_parameter);
+ if (location.total_elements < 0) return f_error_set_error(f_invalid_parameter);
// when the available buffer size is smaller than the total elements, then there is not enough allocated memory available to read the file
if (location.total_elements > 0) {
- if (buffer->size - location.buffer_start < location.total_elements) return f_invalid_parameter;
+ if (buffer->size - location.buffer_start < location.total_elements) return f_error_set_error(f_invalid_parameter);
}
#endif // _di_level_0_parameter_checking_
- if (file_information->file == 0) return f_file_not_open;
+ if (file_information->file == 0) return f_error_set_error(f_file_not_open);
// first seek to 'where' we need to begin the read
f_u_long current_file_position = ftell(file_information->file);
- if (current_file_position == (f_u_long) -1) return f_file_seek_error;
+ if (current_file_position == (f_u_long) -1) return f_error_set_error(f_file_seek_error);
f_s_int result = 0;
result = f_file_seek_from_current(file_information->file, file_information->byte_size * (location.file_start - current_file_position));
}
- if (result != 0) return f_file_seek_error;
+ if (result != 0) return f_error_set_error(f_file_seek_error);
// now do the actual read
if (location.total_elements == 0) {
result = fread(buffer->string + location.buffer_start, file_information->byte_size, location.total_elements, file_information->file);
}
- if (file_information->file == 0) return f_file_read_error;
- if (ferror(file_information->file) != 0) return f_file_read_error;
+ if (file_information->file == 0) return f_error_set_error(f_file_read_error);
+ if (ferror(file_information->file) != 0) return f_error_set_error(f_file_read_error);
// now save how much of our allocated buffer is actually used
// also make sure that we aren't making used space vanish
#ifndef _di_f_file_read_fifo_
f_return_status f_file_read_fifo(f_file *file_information, f_dynamic_string *buffer) {
#ifndef _di_level_0_parameter_checking_
- if (file_information == f_null) return f_invalid_parameter;
- if (buffer->used >= buffer->size) return f_invalid_parameter;
+ if (file_information == f_null) return f_error_set_error(f_invalid_parameter);
+ if (buffer->used >= buffer->size) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
- if (file_information->file == 0) return f_file_not_open;
+ if (file_information->file == 0) return f_error_set_error(f_file_not_open);
f_s_int result = 0;
// now do the actual read
result = fread(buffer->string + buffer->used, file_information->byte_size, buffer->size - buffer->used - 1, file_information->file);
- if (file_information->file == 0) return f_file_read_error;
- if (ferror(file_information->file) != 0) return f_file_read_error;
+ if (file_information->file == 0) return f_error_set_error(f_file_read_error);
+ if (ferror(file_information->file) != 0) return f_error_set_error(f_file_read_error);
buffer->used += (result / file_information->byte_size);
#include <unistd.h>
// fll-0 includes
-#include <level_0/strings.h>
#include <level_0/types.h>
#include <level_0/errors.h>
+#include <level_0/strings.h>
#ifdef __cplusplus
extern "C"{
#ifndef _di_f_new_
f_return_status f_new_array(void **pointer, const f_memory_size_t type, const f_memory_length length) {
#ifndef _di_level_0_parameter_checking_
- if (type <= 0) return f_invalid_parameter;
- if (pointer == 0) return f_invalid_parameter;
+ if (type <= 0) return f_error_set_error(f_invalid_parameter);
+ if (pointer == 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
// prevent double-allocations
return f_none;
}
- return f_allocation_error;
+ return f_error_set_error(f_allocation_error);
}
#endif // _di_f_new_
#if ! ( defined (_di_f_delete_) || defined (_f_memory_FORCE_secure_memory_) )
f_return_status f_delete(void **pointer, const f_memory_size_t type, const f_memory_length length) {
#ifndef _di_level_0_parameter_checking_
- if (pointer == 0) return f_invalid_parameter;
+ if (pointer == 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
// prevent double-frees
#if ! ( defined (_di_f_destroy_) || defined (_f_memory_FORCE_fast_memory_) )
f_return_status f_destroy(void **pointer, const f_memory_size_t type, const f_memory_length length) {
#ifndef _di_level_0_parameter_checking_
- if (length < 0) return f_invalid_parameter;
- if (type <= 0) return f_invalid_parameter;
- if (pointer == 0) return f_invalid_parameter;
+ if (length < 0) return f_error_set_error(f_invalid_parameter);
+ if (type <= 0) return f_error_set_error(f_invalid_parameter);
+ if (pointer == 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
// prevent double-frees
#if ! ( defined (_di_f_resize_) || defined (_f_memory_FORCE_secure_memory_) )
f_return_status f_resize(void **pointer, const f_memory_size_t type, const f_memory_length old_length, const f_memory_length new_length) {
#ifndef _di_level_0_parameter_checking_
- if (type <= 0) return f_invalid_parameter;
- if (old_length < 0) return f_invalid_parameter;
- if (new_length < 0) return f_invalid_parameter;
- if (pointer == 0) return f_invalid_parameter;
+ if (type <= 0) return f_error_set_error(f_invalid_parameter);
+ if (old_length < 0) return f_error_set_error(f_invalid_parameter);
+ if (new_length < 0) return f_error_set_error(f_invalid_parameter);
+ if (pointer == 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
// don't be wasteful
return f_none;
}
- return f_reallocation_error;
+ return f_error_set_error(f_reallocation_error);
}
#endif // ! ( defined (_di_f_resize_) || defined (_f_memory_FORCE_secure_memory_) )
#if ! ( defined (_di_f_adjust_) || defined (_f_memory_FORCE_fast_memory_) )
f_return_status f_adjust(void **pointer, const f_memory_size_t type, const f_memory_length old_length, const f_memory_length new_length) {
#ifndef _di_level_0_parameter_checking_
- if (type <= 0) return f_invalid_parameter;
- if (old_length < 0) return f_invalid_parameter;
- if (new_length < 0) return f_invalid_parameter;
- if (pointer == 0) return f_invalid_parameter;
+ if (type <= 0) return f_error_set_error(f_invalid_parameter);
+ if (old_length < 0) return f_error_set_error(f_invalid_parameter);
+ if (new_length < 0) return f_error_set_error(f_invalid_parameter);
+ if (pointer == 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
// don't be wasteful
return f_none;
}
- return f_reallocation_error;
+ return f_error_set_error(f_reallocation_error);
}
#endif // ! ( defined (_di_f_adjust_) || defined (_f_memory_FORCE_fast_memory_) )
#include <malloc.h>
// fll includes
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
#ifdef __cplusplus
extern "C"{
for (; i < length; i++) {
if (string[i] != f_eos) {
- if (fputc(string[i], output) == 0) return f_output_error;
+ if (fputc(string[i], output) == 0) return f_error_set_error(f_output_error);
}
}
for (; i < buffer.used; i++) {
if (buffer.string[i] != f_eos) {
- if (fputc(buffer.string[i], output) == 0) return f_output_error;
+ if (fputc(buffer.string[i], output) == 0) return f_error_set_error(f_output_error);
}
}
#ifndef _di_f_print_partial_dynamic_string_
f_return_status f_print_partial_dynamic_string(f_file_type output, const f_dynamic_string buffer, const f_string_location location) {
#ifndef _di_level_0_parameter_checking_
- if (location.start < 0) return f_invalid_parameter;
- if (location.stop < location.start) return f_invalid_parameter;
- if (buffer.used <= 0) return f_invalid_parameter;
- if (location.start >= buffer.used) return f_invalid_parameter;
- if (location.stop >= buffer.used) return f_invalid_parameter;
+ if (location.start < 0) return f_error_set_error(f_invalid_parameter);
+ if (location.stop < location.start) return f_error_set_error(f_invalid_parameter);
+ if (buffer.used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (location.start >= buffer.used) return f_error_set_error(f_invalid_parameter);
+ if (location.stop >= buffer.used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
register f_string_length i = location.start;
for (; i <= location.stop; i++) {
if (buffer.string[i] != f_eos) {
- if (fputc(buffer.string[i], output) == 0) return f_output_error;
+ if (fputc(buffer.string[i], output) == 0) return f_error_set_error(f_output_error);
}
}
#include <sys/stat.h>
// fll-0 includes
-#include <level_0/strings.h>
#include <level_0/types.h>
#include <level_0/errors.h>
+#include <level_0/strings.h>
#ifdef __cplusplus
extern "C"{
struct stat st_info;
if (fstat(fileno(f_pipe), &st_info) != 0) {
- return f_file_stat_error;
+ return f_error_set_error(f_file_stat_error);
}
if (S_ISFIFO(st_info.st_mode)) {
#include <sys/stat.h>
// fll includes
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
#ifdef __cplusplus
extern "C"{
#include <string.h>
// fll-0 includes
-#include <level_0/strings.h>
#include <level_0/types.h>
+#include <level_0/strings.h>
#ifdef __cplusplus
extern "C"{
* long: 2^128 = 3.40282e38
* long long: 2^256 = 1.15792e77
*
+ * If you need exact size, use one of the following:
+ * int8_t: 2^8 (signed)
+ * uint8_t: 2^8 (unsigned)
+ * int16_t: 2^16 (signed)
+ * uint16_t: 2^16 (unsigned)
+ * int32_t: 2^32 (signed)
+ * uint32_t: 2^32 (unsigned)
+ * int64_t: 2^64 (signed)
+ * uint64_t: 2^64 (unsigned)
+ *
* TODO: Should a range type be implemented? (ie: f_range_short_long -> min=short, max=long)
*/
#ifndef _F_types_h
// libc includes
#include <sys/stat.h> // contains mode_t, dev_t, gid_t, uid_t, etc..
#include <signal.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C"{
#endif // _di_f_types_max
#ifndef _di_f_status_
- typedef f_u_short f_status;
+ typedef uint16_t f_status;
#define f_status_initialize 0
#ifndef _di_fl_set_color_
f_return_status fl_set_color(f_file_type file, const f_colors_format format, const f_autochar *color1, const f_autochar *color2, const f_autochar *color3, const f_autochar *color4, const f_autochar *color5) {
#ifndef _di_level_1_parameter_checking_
- if (file == f_null) return f_invalid_parameter;
- if (color1 == f_null) return f_invalid_parameter;
+ if (file == f_null) return f_error_set_error(f_invalid_parameter);
+ if (color1 == f_null) return f_error_set_error(f_invalid_parameter);
// make sure all data is in the proper order
if (color2 == f_null && (color3 != f_null || color4 != f_null || color5 != f_null)) return f_invalid_parameter;
#ifndef _di_fl_save_color_
f_return_status fl_save_color(f_dynamic_string *buffer, const f_colors_format format, const f_autochar *color1, const f_autochar *color2, const f_autochar *color3, const f_autochar *color4, const f_autochar *color5) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (color1 == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (color1 == f_null) return f_error_set_error(f_invalid_parameter);
// make sure all data is in the proper order
- if (color2 == f_null && (color3 != f_null || color4 != f_null || color5 != f_null)) return f_invalid_parameter;
- if (color3 == f_null && (color4 != f_null || color5 != f_null)) return f_invalid_parameter;
- if (color4 == f_null && color5 != f_null) return f_invalid_parameter;
+ if (color2 == f_null && (color3 != f_null || color4 != f_null || color5 != f_null)) return f_error_set_error(f_invalid_parameter);
+ if (color3 == f_null && (color4 != f_null || color5 != f_null)) return f_error_set_error(f_invalid_parameter);
+ if (color4 == f_null && color5 != f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length string_size = strnlen(format.begin, f_color_max_size) + strnlen(format.end, f_color_max_size) + 1;
#ifndef _di_fl_print_color_
f_return_status fl_print_color(f_file_type file, const f_dynamic_string start_color, const f_dynamic_string end_color, const f_autochar *string, ...) {
#ifndef _di_level_1_parameter_checking_
- if (file == f_null) return f_invalid_parameter;
- if (string == f_null) return f_invalid_parameter;
+ if (file == f_null) return f_error_set_error(f_invalid_parameter);
+ if (string == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
if (start_color.used != 0) {
#ifndef _di_fl_print_color_line_
f_return_status fl_print_color_line(f_file_type file, const f_dynamic_string start_color, const f_dynamic_string end_color, const f_autochar *string, ...) {
#ifndef _di_level_1_parameter_checking_
- if (file == f_null) return f_invalid_parameter;
- if (string == f_null) return f_invalid_parameter;
+ if (file == f_null) return f_error_set_error(f_invalid_parameter);
+ if (string == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
if (start_color.used != 0) {
#ifndef _di_fl_process_parameters_
f_return_status fl_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, f_string_lengths *remaining) {
#ifndef _di_level_1_parameter_checking_
- if (remaining == f_null) return f_invalid_parameter;
+ if (remaining == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
- f_status status = f_status_initialize;
+ f_status status = f_status_initialize;
f_console_id result = 0;
- f_bool found = f_false;
+ f_bool found = f_false;
- f_array_length location = 1; // parameter 0 represents the program name so skip it
- f_string_length sub_location = 0;
- f_string_length increments = 0;
- f_string_length string_length = 0;
+ f_array_length location = 1; // parameter 0 represents the program name so skip it
+ f_string_length sub_location = 0;
+ f_string_length increments = 0;
+ f_string_length string_length = 0;
f_array_length parameter_counter = 0;
f_string_lengths extra_initiator = f_string_lengths_initialize;
f_status allocation_status = f_status_initialize;
f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
- return allocation_status;
+ return f_error_set_error(allocation_status);
}
}
f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
- return allocation_status;
+ return f_error_set_error(allocation_status);
}
}
f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
- return allocation_status;
+ return f_error_set_error(allocation_status);
}
}
f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
- return allocation_status;
+ return f_error_set_error(allocation_status);
}
}
f_resize_string_lengths(allocation_status, parameters[parameter_counter].additional, parameters[parameter_counter].additional.size + f_console_default_allocation_step);
}
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
- return allocation_status;
+ return f_error_set_error(allocation_status);
}
parameters[parameter_counter].result = f_console_result_found;
f_resize_string_lengths(allocation_status, parameters[extra_initiator.array[0]].additional, parameters[extra_initiator.array[0]].additional.size + f_console_default_allocation_step);
}
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
- return allocation_status;
+ return f_error_set_error(allocation_status);
}
parameters[extra_initiator.array[0]].result = f_console_result_additional;
f_resize_string_lengths(allocation_status, (*remaining), remaining->size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
- return allocation_status;
+ return f_error_set_error(allocation_status);
}
}
extern f_return_status fl_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, f_string_lengths *remaining);
#endif // _di_fl_process_parameters_
-
#ifdef __cplusplus
} // extern "C"
#endif
// put the names of each file and/or directory inside the names parameter
f_return_status fl_directory_list(const f_string directory_path, f_dynamic_strings *names) {
#ifndef _di_level_1_parameter_checking_
- if (names == f_null) return f_invalid_parameter;
+ if (names == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
struct dirent **listing = 0;
- f_s_int length = 0;
- f_s_int counter = 0;
- f_string_length size = f_string_length_initialize;
- f_status status = f_status_initialize;
+ f_s_int length = 0;
+ f_s_int counter = 0;
+ f_string_length size = f_string_length_initialize;
+ f_status status = f_status_initialize;
length = scandir(directory_path, &listing, 0, alphasort);
if (names->used >= names->size) {
f_resize_dynamic_strings(status, (*names), names->used + fl_directory_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
f_resize_dynamic_string(status, names->array[names->used], size);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
// an empty directory
return f_no_data;
} else if (length == -1) {
- if (errno == ENOMEM) return f_allocation_error;
- else return f_failure;
+ if (errno == ENOMEM) return f_error_set_error(f_allocation_error);
+ else return f_error_set_error(f_failure);
}
return f_none;
#include <errno.h>
// fll-0 includes
-#include <level_0/strings.h>
#include <level_0/types.h>
#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
#ifdef __cplusplus
#ifndef _di_fl_errors_to_string_
f_return_status fl_errors_to_string(const f_status error, f_string *string) {
#ifndef _di_level_1_parameter_checking_
- if (string == f_null) return f_invalid_parameter;
+ if (string == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
- switch (error) {
+ f_status umasked_error = f_error_unmask(error);
+
+ switch (umasked_error) {
#ifndef _di_fl_errors_booleans_
case f_false:
*string = "f_false";
#ifndef _di_fl_errors_is_error_
f_return_status fl_errors_is_error(const f_status error) {
- if (fl_errors_is_okay(error) == f_true) {
+ if (fl_errors_is_fine(error) == f_true) {
return f_false;
} else if (fl_errors_is_warning(error) == f_true) {
return f_false;
}
#endif // _di_fl_errors_is_warning_
-#ifndef _di_fl_errors_is_okay_
- // Returns true or false depending on whether the standard context of the error code represents an normal return status and not an error.
- // Keep in mind that many of the error codes are context-specific and may be reported as an "okay" here when it is in fact not okay.
- f_return_status fl_errors_is_okay(const f_status error) {
+#ifndef _di_fl_errors_is_fine_
+ f_return_status fl_errors_is_fine(const f_status error) {
switch (error) {
#ifndef _di_fl_errors_booleans_
case f_false:
return f_false;
}
-#endif // _di_fl_errors_is_okay_
+#endif // _di_fl_errors_is_fine_
#ifdef __cplusplus
} // extern "C"
#define _FL_errors_h
// fll-0 includes
+#include <level_0/types.h>
#include <level_0/errors.h>
#include <level_0/strings.h>
extern f_return_status fl_errors_is_warning(const f_status error);
#endif // _di_fl_errors_is_warning_
-
-#ifndef _di_fl_errors_is_okay_
+#ifndef _di_fl_errors_is_fine_
// Returns true or false depending on whether the standard context of the error code represents an normal return status and not an error.
- // Keep in mind that many of the error codes are context-specific and may be reported as an "okay" here when it is in fact not okay.
- extern f_return_status fl_errors_is_okay(const f_status error);
-#endif // _di_fl_errors_is_okay_
+ // Keep in mind that many of the error codes are context-specific and may be reported as an "fine" here when it is in fact not fine.
+ extern f_return_status fl_errors_is_fine(const f_status error);
+#endif // _di_fl_errors_is_fine_
#ifdef __cplusplus
} // extern "C"
#ifndef _di_fl_file_read_
f_return_status fl_file_read(f_file file, const f_file_position position, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
- if (position.buffer_start < 0) return f_invalid_parameter;
- if (position.file_start < 0) return f_invalid_parameter;
- if (position.total_elements < 0) return f_invalid_parameter;
+ if (position.buffer_start < 0) return f_error_set_error(f_invalid_parameter);
+ if (position.file_start < 0) return f_error_set_error(f_invalid_parameter);
+ if (position.total_elements < 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
- if (file.file == 0) return f_file_not_open;
+ if (file.file == 0) return f_error_set_warning(f_file_not_open);
- f_status status = f_status_initialize;
- f_string_length size = f_string_length_initialize;
- f_bool infinite = f_false;
+ f_status status = f_status_initialize;
+ f_string_length size = f_string_length_initialize;
+ f_bool infinite = f_false;
// when total_elements is 0, this means the file read will until EOF is reached
if (position.total_elements == 0) {
if (buffer->size <= size) {
f_resize_dynamic_string(status, (*buffer), size);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
if (status == f_none_on_eof) {
break;
- } else if (status != f_none) {
+ } else if (f_error_is_error(status)) {
return status;
}
if (infinite) {
if (size + f_file_default_read_size > f_string_max_size) {
- return f_overflow;
+ return f_error_set_error(f_overflow);
}
size += f_file_default_read_size;
#ifndef _di_fl_file_read_fifo_
f_return_status fl_file_read_fifo(f_file file, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
- if (file.file == 0) return f_file_not_open;
+ if (file.file == 0) return f_error_set_warning(f_file_not_open);
- f_status status = f_status_initialize;
- f_string_length size = f_string_length_initialize;
+ f_status status = f_status_initialize;
+ f_string_length size = f_string_length_initialize;
size = f_file_default_read_size;
if (buffer->size <= size) {
f_resize_dynamic_string(status, (*buffer), size);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
if (status == f_none_on_eof) {
break;
- } else if (status != f_none) {
+ } else if (f_error_is_error(status)) {
return status;
}
if (size + f_file_default_read_size > f_string_max_size) {
- return f_overflow;
+ return f_error_set_error(f_overflow);
}
size += f_file_default_read_size;
#ifndef _di_fl_file_write_
f_return_status fl_file_write(f_file file, const f_dynamic_string buffer) {
- if (file.file == 0) return f_file_not_open;
+ if (file.file == 0) return f_error_set_error(f_file_not_open);
f_status status = f_status_initialize;
- f_size_t size = 0;
+ f_size_t size = 0;
size = fwrite(buffer.string, file.byte_size, buffer.used, file.file);
if (size < buffer.used * file.byte_size) {
- return f_file_write_error;
+ return f_error_set_error(f_file_write_error);
}
return f_none;
#ifndef _di_fl_file_write_partial_
f_return_status fl_file_write_partial(f_file file, const f_dynamic_string buffer, const f_string_location position) {
#ifndef _di_level_1_parameter_checking_
- if (position.start < position.stop) return f_invalid_parameter;
+ if (position.start < position.stop) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
if (file.file == 0) return f_file_not_open;
f_status status = f_status_initialize;
- f_size_t size = 0;
+ f_size_t size = 0;
f_string_length total = buffer.used - (position.stop - position.start + 1);
size = fwrite(buffer.string + position.start, file.byte_size, total, file.file);
if (size < total * file.byte_size) {
- return f_file_write_error;
+ return f_error_set_error(f_file_write_error);
}
return f_none;
#ifndef _di_fl_fss_identify_
f_return_status fl_fss_identify(const f_dynamic_string buffer, f_fss_header *header) {
#ifndef _di_level_1_parameter_checking_
- if (header == f_null) return f_invalid_parameter;
- if (buffer.used <= 0) return f_invalid_parameter;
+ if (header == f_null) return f_error_set_error(f_invalid_parameter);
+ if (buffer.used <= 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
register f_string_length i = 0;
i++;
header->length = i;
- return fl_fss_accepted_but_invalid;
+ return f_error_is_warning(fl_fss_accepted_but_invalid);
}
}
}
header->length = i + 1;
- return fl_fss_accepted_but_invalid;
+ return f_error_is_warning(fl_fss_accepted_but_invalid);
}
}
}
#ifndef _di_fl_fss_identify_file_
f_return_status fl_fss_identify_file(f_file *file_information, f_fss_header *header) {
#ifndef _di_level_1_parameter_checking_
- if (file_information == f_null) return f_invalid_parameter;
- if (header == f_null) return f_invalid_parameter;
- if (file_information->file == 0) return f_file_not_open;
- if (ferror(file_information->file) != 0) return f_file_error;
+ if (file_information == f_null) return f_error_set_error(f_invalid_parameter);
+ if (header == f_null) return f_error_set_error(f_invalid_parameter);
+ if (file_information->file == 0) return f_file_not_open;
+ if (ferror(file_information->file) != 0) return f_file_error;
#endif // _di_level_1_parameter_checking_
clearerr(file_information->file);
f_adjust_dynamic_string(status, buffer, location.total_elements + 1);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
// 2: buffer the file
status = f_file_read(file_information, &buffer, location);
- if (f_macro_test_for_basic_errors(status) || f_macro_test_for_file_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
#ifndef _di_fl_fss_shift_delimiters_
f_return_status fl_fss_shift_delimiters(f_dynamic_string *buffer, const f_string_location location) {
#ifndef _di_level_1_parameter_checking_
- if (buffer->used <= 0) return f_invalid_parameter;
- if (location.start < 0) return f_invalid_parameter;
- if (location.stop < location.start) return f_invalid_parameter;
- if (location.start >= buffer->used) return f_invalid_parameter;
+ if (buffer->used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (location.start < 0) return f_error_set_error(f_invalid_parameter);
+ if (location.stop < location.start) return f_error_set_error(f_invalid_parameter);
+ if (location.start >= buffer->used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length position = f_string_length_initialize;
#include <ctype.h>
// fll-0 includes
-#include <level_0/strings.h>
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/fss.h>
#include <level_0/file.h>
#include <level_0/conversion.h>
#ifndef _di_fl_fss_basic_object_read_
f_return_status fl_fss_basic_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (input == f_null) return f_invalid_parameter;
- if (found == f_null) return f_invalid_parameter;
- if (input->start < 0) return f_invalid_parameter;
- if (input->stop < input->start) return f_invalid_parameter;
- if (buffer->used <= 0) return f_invalid_parameter;
- if (input->start >= buffer->used) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input == f_null) return f_error_set_error(f_invalid_parameter);
+ if (found == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (input->stop < input->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer->used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (input->start >= buffer->used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
// delimits must only be applied once a valid object is found
f_resize_string_lengths(allocation_status, delimits, delimits.size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
input->start++;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
if (buffer->string[input->start] == quoted) {
f_string_length location = input->start;
f_resize_string_lengths(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
f_resize_string_lengths(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
input->start++;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
}
// seek to the end of the line when no valid object is found
#ifndef _di_fl_fss_basic_content_read_
f_return_status fl_fss_basic_content_read(f_dynamic_string *buffer, f_string_location *input, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (input == f_null) return f_invalid_parameter;
- if (found == f_null) return f_invalid_parameter;
- if (input->start < 0) return f_invalid_parameter;
- if (input->stop < input->start) return f_invalid_parameter;
- if (buffer->used <= 0) return f_invalid_parameter;
- if (input->start >= buffer->used) return f_invalid_parameter;
- if (found->used > found->size) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input == f_null) return f_error_set_error(f_invalid_parameter);
+ if (found == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (input->stop < input->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer->used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (input->start >= buffer->used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
// delimits must only be applied once a valid object is found
#ifndef _di_fl_fss_basic_object_write_
f_return_status fl_fss_basic_object_write(const f_dynamic_string object, f_string_location *input, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_status_initialize;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer_position.start = buffer->used;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
// restart the loop searching for f_fss_delimit_double_quote.
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
break;
#ifndef _di_fl_fss_basic_content_write_
f_return_status fl_fss_basic_content_write(const f_dynamic_string content, f_string_location *input, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_status_initialize;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
while (input->start <= input->stop && input->start < content.used) {
#include <ctype.h>
// fll-0 includes
-#include <level_0/strings.h>
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
#include <level_0/fss.h>
#ifndef _di_fl_fss_basic_list_object_read_
f_return_status fl_fss_basic_list_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (input == f_null) return f_invalid_parameter;
- if (found == f_null) return f_invalid_parameter;
- if (input->start < 0) return f_invalid_parameter;
- if (input->stop < input->start) return f_invalid_parameter;
- if (buffer->used <= 0) return f_invalid_parameter;
- if (input->start >= buffer->used) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input == f_null) return f_error_set_error(f_invalid_parameter);
+ if (found == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (input->stop < input->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer->used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (input->start >= buffer->used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
// delimits must only be applied once a valid object is found
f_resize_string_lengths(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
#ifndef _di_fl_fss_basic_list_content_read_
f_return_status fl_fss_basic_list_content_read(f_dynamic_string *buffer, f_string_location *input, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (input == f_null) return f_invalid_parameter;
- if (found == f_null) return f_invalid_parameter;
- if (input->start < 0) return f_invalid_parameter;
- if (input->stop < input->start) return f_invalid_parameter;
- if (buffer->used <= 0) return f_invalid_parameter;
- if (input->start >= buffer->used) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input == f_null) return f_error_set_error(f_invalid_parameter);
+ if (found == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (input->stop < input->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer->used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (input->start >= buffer->used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
// delimits must only be applied once a valid object is found
f_resize_string_lengths(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
#ifndef _di_fl_fss_basic_list_object_write_
f_return_status fl_fss_basic_list_object_write(const f_dynamic_string object, f_string_location *input, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_status_initialize;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer_position.start = buffer->used;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
while (slash_count > 0) {
#ifndef _di_fl_fss_basic_list_content_write_
f_return_status fl_fss_basic_list_content_write(const f_dynamic_string content, f_string_location *input, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_status_initialize;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer_position.start = buffer->used;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
while (slash_count > 0) {
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
#include <ctype.h>
// fll-0 includes
-#include <level_0/strings.h>
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
#include <level_0/fss.h>
#ifndef _di_fl_fss_extended_object_read_
f_return_status fl_fss_extended_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (input == f_null) return f_invalid_parameter;
- if (found == f_null) return f_invalid_parameter;
- if (input->start < 0) return f_invalid_parameter;
- if (input->stop < input->start) return f_invalid_parameter;
- if (buffer->used <= 0) return f_invalid_parameter;
- if (input->start >= buffer->used) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input == f_null) return f_error_set_error(f_invalid_parameter);
+ if (found == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (input->stop < input->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer->used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (input->start >= buffer->used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
// delimits must only be applied once a valid object is found
f_resize_string_lengths(allocation_status, delimits, delimits.size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
input->start++;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
if (buffer->string[input->start] == quoted) {
f_string_length location = input->start;
f_resize_string_lengths(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
input->start = location + 1;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
if (isgraph(buffer->string[input->start])) {
while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_eol) {
f_resize_string_lengths(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
input->start++;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
}
// seek to the end of the line when no valid object is found
#ifndef _di_fl_fss_extended_content_read_
f_return_status fl_fss_extended_content_read(f_dynamic_string *buffer, f_string_location *input, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (input == f_null) return f_invalid_parameter;
- if (found == f_null) return f_invalid_parameter;
- if (input->start < 0) return f_invalid_parameter;
- if (input->stop < input->start) return f_invalid_parameter;
- if (buffer->used <= 0) return f_invalid_parameter;
- if (input->start >= buffer->used) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input == f_null) return f_error_set_error(f_invalid_parameter);
+ if (found == f_null) return f_error_set_error(f_invalid_parameter);
+ if (input->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (input->stop < input->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer->used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (input->start >= buffer->used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
// delimits must only be applied once a valid object is found
if (found->used >= found->size) {
f_resize_fss_content(status, (*found), found->size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_error_is_error(status)){
f_status allocation_status = f_status_initialize;
f_delete_string_lengths(allocation_status, delimits);
f_resize_string_lengths(allocation_status, delimits, delimits.size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
input->start++;
} // while
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
if (buffer->string[input->start] == quoted) {
location = input->start;
f_resize_string_lengths(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
input->start++;
} // while
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
input->start++;
- return f_unterminated_group;
+ return f_error_is_warning(f_unterminated_group);
} else if (buffer->string[input->start] == f_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
f_resize_string_lengths(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)) {
+ if (f_error_is_error(allocation_status)) {
f_delete_string_lengths(allocation_status, delimits);
return allocation_status;
}
input->start++;
} // while
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
input->start++;
- return f_unterminated_group;
+ return f_error_is_warning(f_unterminated_group);
}
input->start++;
input->start++;
} // while
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_unterminated_group_on_eos, f_unterminated_group_on_stop)
+ fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_error_is_warning(f_unterminated_group_on_eos), f_error_is_warning(f_unterminated_group_on_stop))
}
if (continue_main_loop) {
#ifndef _di_fl_fss_extended_object_write_
f_return_status fl_fss_extended_object_write(const f_dynamic_string object, f_string_location *input, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_status_initialize;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer_position.start = buffer->used;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
// restart the loop searching for f_fss_delimit_double_quote.
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
break;
#ifndef _di_fl_fss_extended_content_write_
f_return_status fl_fss_extended_content_write(const f_dynamic_string content, f_string_location *input, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_status_initialize;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
fl_macro_fss_skip_past_delimit_placeholders(content, (*input))
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
input->start = start_position;
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
while (slash_count > 0) {
if (pre_allocate_size > buffer->size) {
f_resize_dynamic_string(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
#include <ctype.h>
// fll-0 includes
-#include <level_0/strings.h>
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
#include <level_0/fss.h>
f_status status = f_status_initialize; \
\
f_resize_fss_content(status, content, content.size + f_fss_default_allocation_step); \
- if (f_macro_test_for_allocation_errors(status)) { \
+ if (f_error_is_error(status)) { \
f_status allocation_status = f_status_initialize; \
f_delete_string_lengths(allocation_status, delimits); \
\
#ifndef _di_fl_serialize_simple_
f_return_status fl_serialize_simple(const f_dynamic_string value, f_dynamic_string *serialized) {
#ifndef _di_level_0_parameter_checking_
- if (serialized == f_null) return f_invalid_parameter;
+ if (serialized == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_status status = f_status_initialize;
if (serialized->used + value.used + 1 >= serialized->size) {
f_resize_dynamic_string(status, (*serialized), serialized->size + value.used + f_serialized_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
if (serialized->used == 0) {
#ifndef _di_fl_unserialize_simple_
f_return_status fl_unserialize_simple(const f_dynamic_string serialized, f_string_locations *locations) {
#ifndef _di_level_0_parameter_checking_
- if (locations == f_null) return f_invalid_parameter;
+ if (locations == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_status status = f_status_initialize;
- f_array_length i = 0;
+ f_array_length i = 0;
f_array_length start = 0;
while (i <= serialized.used) {
if (locations->used + 1 >= locations->size) {
f_resize_string_locations(status, (*locations), locations->size + f_serialized_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
if (start == i) {
#ifndef _di_fl_unserialize_simple_get_
f_return_status fl_unserialize_simple_get(const f_dynamic_string serialized, const f_array_length index, f_string_location *location) {
#ifndef _di_level_0_parameter_checking_
- if (location == f_null) return f_invalid_parameter;
+ if (location == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_status status = f_status_initialize;
- f_array_length i = 0;
+ f_array_length i = 0;
f_array_length current = 0;
location->start = 1;
#include <string.h>
// fll-0 includes
-#include <level_0/strings.h>
#include <level_0/types.h>
#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/serialized.h>
#ifdef __cplusplus
#ifndef _di_fl_rip_string_
f_return_status fl_rip_string(const f_dynamic_string buffer, const f_string_location position, f_dynamic_string *results) {
#ifndef _di_level_1_parameter_checking_
- if (results == f_null) return f_invalid_parameter;
- if (position.start < 0) return f_invalid_parameter;
- if (position.stop < position.start) return f_invalid_parameter;
- if (buffer.used <= 0) return f_invalid_parameter;
- if (position.start >= buffer.used) return f_invalid_parameter;
+ if (results == f_null) return f_error_set_error(f_invalid_parameter);
+ if (position.start < 0) return f_error_set_error(f_invalid_parameter);
+ if (position.stop < position.start) return f_error_set_error(f_invalid_parameter);
+ if (buffer.used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (position.start >= buffer.used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
// the start and stop point are inclusive locations, and therefore start - stop is actually 1 too few locations
f_resize_dynamic_string(status, (*results), size);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
#ifndef _di_fl_seek_line_past_non_graph_
f_return_status fl_seek_line_past_non_graph(const f_dynamic_string buffer, f_string_location *position, const f_autochar placeholder) {
#ifndef _di_level_1_parameter_checking_
- if (position == f_null) return f_invalid_parameter;
- if (position->start < 0) return f_invalid_parameter;
- if (position->stop < position->start) return f_invalid_parameter;
- if (buffer.used <= 0) return f_invalid_parameter;
- if (position->start >= buffer.used) return f_invalid_parameter;
+ if (position == f_null) return f_error_set_error(f_invalid_parameter);
+ if (position->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (position->stop < position->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer.used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (position->start >= buffer.used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
while (!isgraph(buffer.string[position->start]) || buffer.string[position->start] == placeholder) {
++position->start;
- if (position->start >= buffer.used) return f_none_on_eos;
- if (position->start > position->stop) return f_none_on_stop;
+ if (position->start >= buffer.used) return f_none_on_eos;
+ if (position->start > position->stop) return f_none_on_stop;
} // while
return f_none;
#ifndef _di_fl_seek_line_until_non_graph_
f_return_status fl_seek_line_until_non_graph(const f_dynamic_string buffer, f_string_location *position, const f_autochar placeholder) {
#ifndef _di_level_1_parameter_checking_
- if (position->start < 0) return f_invalid_parameter;
- if (position->stop < position->start) return f_invalid_parameter;
- if (buffer.used <= 0) return f_invalid_parameter;
- if (position->start >= buffer.used) return f_invalid_parameter;
+ if (position->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (position->stop < position->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer.used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (position->start >= buffer.used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
while (isgraph(buffer.string[position->start]) || buffer.string[position->start] == placeholder) {
++position->start;
- if (position->start >= buffer.used) return f_none_on_eos;
- if (position->start > position->stop) return f_none_on_stop;
+ if (position->start >= buffer.used) return f_none_on_eos;
+ if (position->start > position->stop) return f_none_on_stop;
} // while
return f_none;
#ifndef _di_fl_seek_to_
f_return_status fl_seek_to(const f_dynamic_string buffer, f_string_location *position, const f_autochar seek_to_this) {
#ifndef _di_level_1_parameter_checking_
- if (position->start < 0) return f_invalid_parameter;
- if (position->stop < position->start) return f_invalid_parameter;
- if (buffer.used <= 0) return f_invalid_parameter;
- if (position->start >= buffer.used) return f_invalid_parameter;
+ if (position->start < 0) return f_error_set_error(f_invalid_parameter);
+ if (position->stop < position->start) return f_error_set_error(f_invalid_parameter);
+ if (buffer.used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (position->start >= buffer.used) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
while (buffer.string[position->start] != seek_to_this) {
++position->start;
- if (position->start >= buffer.used) return f_none_on_eos;
- if (position->start > position->stop) return f_none_on_stop;
+ if (position->start >= buffer.used) return f_none_on_eos;
+ if (position->start > position->stop) return f_none_on_stop;
} // while
return f_none;
#ifndef _di_fl_compare_strings_
f_return_status fl_compare_strings(const f_string string1, const f_string string2, const f_string_length length1, const f_string_length length2) {
#ifndef _di_level_1_parameter_checking_
- if (length1 <= 0) return f_invalid_parameter;
- if (length2 <= 0) return f_invalid_parameter;
+ if (length1 <= 0) return f_error_set_error(f_invalid_parameter);
+ if (length2 <= 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length i1 = f_string_length_initialize;
#ifndef _di_fl_compare_dynamic_strings_
f_return_status fl_compare_dynamic_strings(const f_dynamic_string string1, const f_dynamic_string string2) {
#ifndef _di_level_1_parameter_checking_
- if (string1.used <= 0) return f_invalid_parameter;
- if (string2.used <= 0) return f_invalid_parameter;
+ if (string1.used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (string2.used <= 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length i1 = f_string_length_initialize;
#ifndef _di_fl_compare_partial_dynamic_strings_
f_return_status fl_compare_partial_dynamic_strings(const f_dynamic_string string1, const f_dynamic_string string2, const f_string_location offset1, const f_string_location offset2) {
#ifndef _di_level_1_parameter_checking_
- if (string1.used <= 0) return f_invalid_parameter;
- if (string2.used <= 0) return f_invalid_parameter;
+ if (string1.used <= 0) return f_error_set_error(f_invalid_parameter);
+ if (string2.used <= 0) return f_error_set_error(f_invalid_parameter);
- if (offset1.start > offset1.stop) return f_invalid_parameter;
- if (offset2.start > offset2.stop) return f_invalid_parameter;
+ if (offset1.start > offset1.stop) return f_error_set_error(f_invalid_parameter);
+ if (offset2.start > offset2.stop) return f_error_set_error(f_invalid_parameter);
- if (string1.used <= offset1.stop) return f_invalid_parameter;
- if (string2.used <= offset2.stop) return f_invalid_parameter;
+ if (string1.used <= offset1.stop) return f_error_set_error(f_invalid_parameter);
+ if (string2.used <= offset2.stop) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length i1 = offset1.start;
#include <ctype.h>
// fll includes
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
#include <level_0/strings.h>
#include <level_0/memory.h>
#ifndef _di_fll_colors_load_context_
f_return_status fll_colors_load_context(fll_color_context *data, f_bool use_light_colors) {
#ifndef _di_level_2_parameter_checking_
- if (data == 0) return f_invalid_parameter;
+ if (data == 0) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
f_status status = f_status_initialize;
if (use_light_colors) {
status = fl_save_color1(&data->reset, data->color_format, data->color_list.reset);
- if (status == f_none) status = fl_save_color1(&data->warning, data->color_format, data->color_list.yellow);
- if (status == f_none) status = fl_save_color2(&data->error, data->color_format, data->color_list.bold, data->color_list.red);
- if (status == f_none) status = fl_save_color2(&data->title, data->color_format, data->color_list.bold, data->color_list.blue);
- if (status == f_none) status = fl_save_color1(&data->notable, data->color_format, data->color_list.bold);
- if (status == f_none) status = fl_save_color1(&data->important, data->color_format, data->color_list.blue);
- if (status == f_none) status = fl_save_color1(&data->standout, data->color_format, data->color_list.purple);
+ if (f_error_is_not_error(status)) status = fl_save_color1(&data->warning, data->color_format, data->color_list.yellow);
+ if (f_error_is_not_error(status)) status = fl_save_color2(&data->error, data->color_format, data->color_list.bold, data->color_list.red);
+ if (f_error_is_not_error(status)) status = fl_save_color2(&data->title, data->color_format, data->color_list.bold, data->color_list.blue);
+ if (f_error_is_not_error(status)) status = fl_save_color1(&data->notable, data->color_format, data->color_list.bold);
+ if (f_error_is_not_error(status)) status = fl_save_color1(&data->important, data->color_format, data->color_list.blue);
+ if (f_error_is_not_error(status)) status = fl_save_color1(&data->standout, data->color_format, data->color_list.purple);
} else {
status = fl_save_color1(&data->reset, data->color_format, data->color_list.reset);
- if (status == f_none) status = fl_save_color1(&data->warning, data->color_format, data->color_list.yellow);
- if (status == f_none) status = fl_save_color2(&data->error, data->color_format, data->color_list.bold, data->color_list.red);
- if (status == f_none) status = fl_save_color2(&data->title, data->color_format, data->color_list.bold, data->color_list.yellow);
- if (status == f_none) status = fl_save_color1(&data->notable, data->color_format, data->color_list.bold);
- if (status == f_none) status = fl_save_color2(&data->important, data->color_format, data->color_list.bold, data->color_list.green);
- if (status == f_none) status = fl_save_color1(&data->standout, data->color_format, data->color_list.green);
+ if (f_error_is_not_error(status)) status = fl_save_color1(&data->warning, data->color_format, data->color_list.yellow);
+ if (f_error_is_not_error(status)) status = fl_save_color2(&data->error, data->color_format, data->color_list.bold, data->color_list.red);
+ if (f_error_is_not_error(status)) status = fl_save_color2(&data->title, data->color_format, data->color_list.bold, data->color_list.yellow);
+ if (f_error_is_not_error(status)) status = fl_save_color1(&data->notable, data->color_format, data->color_list.bold);
+ if (f_error_is_not_error(status)) status = fl_save_color2(&data->important, data->color_format, data->color_list.bold, data->color_list.green);
+ if (f_error_is_not_error(status)) status = fl_save_color1(&data->standout, data->color_format, data->color_list.green);
}
return status;
#define fll_new_color_context(status, color_context) \
f_resize_dynamic_string(status, color_context.reset, f_color_max_size + 1); \
- if (status == f_none) f_resize_dynamic_string(status, color_context.warning, f_color_max_size + 1); \
- if (status == f_none) f_resize_dynamic_string(status, color_context.error, f_color_max_size + 1); \
- if (status == f_none) f_resize_dynamic_string(status, color_context.title, f_color_max_size + 1); \
- if (status == f_none) f_resize_dynamic_string(status, color_context.notable, f_color_max_size + 1); \
- if (status == f_none) f_resize_dynamic_string(status, color_context.important, f_color_max_size + 1); \
- if (status == f_none) f_resize_dynamic_string(status, color_context.standout, f_color_max_size + 1); \
- if (status == f_none) f_resize_dynamic_string(status, color_context.normal, f_color_max_size + 1); \
- if (status == f_none) f_resize_dynamic_string(status, color_context.normal_reset, f_color_max_size + 1);
+ if (f_error_is_not_error(status)) f_resize_dynamic_string(status, color_context.warning, f_color_max_size + 1); \
+ if (f_error_is_not_error(status)) f_resize_dynamic_string(status, color_context.error, f_color_max_size + 1); \
+ if (f_error_is_not_error(status)) f_resize_dynamic_string(status, color_context.title, f_color_max_size + 1); \
+ if (f_error_is_not_error(status)) f_resize_dynamic_string(status, color_context.notable, f_color_max_size + 1); \
+ if (f_error_is_not_error(status)) f_resize_dynamic_string(status, color_context.important, f_color_max_size + 1); \
+ if (f_error_is_not_error(status)) f_resize_dynamic_string(status, color_context.standout, f_color_max_size + 1); \
+ if (f_error_is_not_error(status)) f_resize_dynamic_string(status, color_context.normal, f_color_max_size + 1); \
+ if (f_error_is_not_error(status)) f_resize_dynamic_string(status, color_context.normal_reset, f_color_max_size + 1);
#define fll_delete_color_context(status, color_context) \
f_delete_dynamic_string(status, color_context.reset); \
- if (status == f_none) f_delete_dynamic_string(status, color_context.warning); \
- if (status == f_none) f_delete_dynamic_string(status, color_context.error); \
- if (status == f_none) f_delete_dynamic_string(status, color_context.title); \
- if (status == f_none) f_delete_dynamic_string(status, color_context.notable); \
- if (status == f_none) f_delete_dynamic_string(status, color_context.important); \
- if (status == f_none) f_delete_dynamic_string(status, color_context.standout); \
- if (status == f_none) f_delete_dynamic_string(status, color_context.normal); \
- if (status == f_none) f_delete_dynamic_string(status, color_context.normal_reset);
+ if (f_error_is_not_error(status)) f_delete_dynamic_string(status, color_context.warning); \
+ if (f_error_is_not_error(status)) f_delete_dynamic_string(status, color_context.error); \
+ if (f_error_is_not_error(status)) f_delete_dynamic_string(status, color_context.title); \
+ if (f_error_is_not_error(status)) f_delete_dynamic_string(status, color_context.notable); \
+ if (f_error_is_not_error(status)) f_delete_dynamic_string(status, color_context.important); \
+ if (f_error_is_not_error(status)) f_delete_dynamic_string(status, color_context.standout); \
+ if (f_error_is_not_error(status)) f_delete_dynamic_string(status, color_context.normal); \
+ if (f_error_is_not_error(status)) f_delete_dynamic_string(status, color_context.normal_reset);
#define fll_destroy_color_context(status, color_context, size) \
f_destroy_dynamic_string(status, color_context.reset); \
- if (status == f_none) f_destroy_dynamic_string(status, color_context.warning, size); \
- if (status == f_none) f_destroy_dynamic_string(status, color_context.error, size); \
- if (status == f_none) f_destroy_dynamic_string(status, color_context.title, size); \
- if (status == f_none) f_destroy_dynamic_string(status, color_context.notable, size); \
- if (status == f_none) f_destroy_dynamic_string(status, color_context.important, size); \
- if (status == f_none) f_destroy_dynamic_string(status, color_context.standout, size); \
- if (status == f_none) f_destroy_dynamic_string(status, color_context.normal); \
- if (status == f_none) f_destroy_dynamic_string(status, color_context.normal_reset);
+ if (f_error_is_not_error(status)) f_destroy_dynamic_string(status, color_context.warning, size); \
+ if (f_error_is_not_error(status)) f_destroy_dynamic_string(status, color_context.error, size); \
+ if (f_error_is_not_error(status)) f_destroy_dynamic_string(status, color_context.title, size); \
+ if (f_error_is_not_error(status)) f_destroy_dynamic_string(status, color_context.notable, size); \
+ if (f_error_is_not_error(status)) f_destroy_dynamic_string(status, color_context.important, size); \
+ if (f_error_is_not_error(status)) f_destroy_dynamic_string(status, color_context.standout, size); \
+ if (f_error_is_not_error(status)) f_destroy_dynamic_string(status, color_context.normal); \
+ if (f_error_is_not_error(status)) f_destroy_dynamic_string(status, color_context.normal_reset);
#endif // _di_fll_color_context_
#ifndef _di_fll_colors_load_context_
#ifndef _di_fll_execute_path_
f_return_status fll_execute_path(const f_string program_path, const f_dynamic_strings arguments, f_s_int *results) {
#ifndef _di_level_2_parameter_checking_
- if (results == f_null) return f_invalid_parameter;
+ if (results == f_null) return f_error_set_error(f_invalid_parameter);
- if (arguments.used < 0) return f_invalid_parameter;
- if (arguments.used > arguments.size) return f_invalid_parameter;
+ if (arguments.used < 0) return f_error_set_error(f_invalid_parameter);
+ if (arguments.used > arguments.size) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
// create a string array that is compatible with execv() calls
if (name_size > 1) {
f_new_string(status, program_name, name_size + 1);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
memcpy(program_name, last_slash + 1, name_size);
memset(program_name, name_size, 0);
status = f_new_array((void **) & arguments_array, sizeof(f_autochar **), arguments.used + 2);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
f_status tmp_status = f_status_initialize;
f_delete_string(tmp_status, program_name, name_size);
process_id = vfork();
if (process_id < 0) {
- return f_fork_failed;
+ return f_error_set_error(f_fork_failed);
}
if (process_id == 0) { // child
if (name_size > 0) f_delete_string(status, program_name, name_size);
f_delete((void **) & arguments_array, sizeof(f_autochar), arguments.used + 2);
- if (*results != 0) return f_failure;
+ if (*results != 0) return f_error_set_error(f_failure);
return f_none;
}
#ifndef _di_fll_execute_program_
f_return_status fll_execute_program(const f_string program_name, const f_dynamic_strings arguments, f_s_int *results) {
#ifndef _di_level_2_parameter_checking_
- if (results == f_null) return f_invalid_parameter;
+ if (results == f_null) return f_error_set_error(f_invalid_parameter);
- if (arguments.used < 0) return f_invalid_parameter;
- if (arguments.used > arguments.size) return f_invalid_parameter;
+ if (arguments.used < 0) return f_error_set_error(f_invalid_parameter);
+ if (arguments.used > arguments.size) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
// create a string array that is compatible with execv() calls
status = f_new_array((void **) & arguments_array, sizeof(f_autochar **), arguments.used + 2);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
{
f_string_length counter = f_string_length_initialize;
process_id = vfork();
if (process_id < 0) {
- return f_fork_failed;
+ return f_error_set_error(f_fork_failed);
}
if (process_id == 0) { // child
f_delete((void **) & arguments_array, sizeof(f_autochar), arguments.used + 2);
- if (*results != 0) return f_failure;
+ if (*results != 0) return f_error_set_error(f_failure);
return f_none;
}
#include <memory.h>
// fll-0 includes
-#include <level_0/strings.h>
#include <level_0/types.h>
#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
// fll-1 includes
#ifndef _di_fll_fss_basic_read_
f_return_status fll_fss_basic_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents) {
#ifndef _di_level_2_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (objects == f_null) return f_invalid_parameter;
- if (contents == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (objects == f_null) return f_error_set_error(f_invalid_parameter);
+ if (contents == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
f_status status = f_status_initialize;
if (objects->used >= objects->size) {
f_resize_fss_objects(status, (*objects), objects->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
f_resize_fss_contents(status, (*contents), contents->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
f_resize_fss_content(status, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
f_resize_fss_content(status, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
#ifndef _di_fll_fss_basic_write_
f_return_status fll_fss_basic_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer) {
#ifndef _di_level_2_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (contents.used > contents.size) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (contents.used > contents.size) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
f_status status = 0;
} else {
if (buffer->used >= buffer->size) {
f_resize_dynamic_string(status, (*buffer), buffer->size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer->used] = f_eol;
#define _FLL_fss_basic_h
// fll-0 includes
-#include <level_0/strings.h>
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
#include <level_0/fss.h>
#ifndef _di_fll_fss_basic_list_read_
f_return_status fll_fss_basic_list_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents) {
#ifndef _di_level_2_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (objects == f_null) return f_invalid_parameter;
- if (contents == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (objects == f_null) return f_error_set_error(f_invalid_parameter);
+ if (contents == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
f_status status = f_status_initialize;
if (objects->used >= objects->size) {
f_resize_fss_objects(status, (*objects), objects->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
f_resize_fss_contents(status, (*contents), contents->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
f_resize_fss_content(status, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
f_resize_fss_content(status, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
contents->used++;
} while (f_true);
- return f_unknown;
+ return f_error_is_error(f_unknown);
}
#endif // _di_fll_fss_basic_list_read_
#ifndef _di_fll_fss_basic_list_write_
f_return_status fll_fss_basic_list_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer) {
#ifndef _di_level_2_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (contents.used > contents.size) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (contents.used > contents.size) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
f_status status = 0;
} else {
if (buffer->used >= buffer->size) {
f_resize_dynamic_string(status, (*buffer), buffer->size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) return status;
+ if (f_error_is_error(status)) return status;
}
buffer->string[buffer->used] = f_eol;
#define _FLL_fss_basic_list_h
// fll-0 includes
-#include <level_0/strings.h>
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
#include <level_0/fss.h>
#ifndef _di_fll_fss_errors_to_string_
f_return_status fll_fss_errors_to_string(const f_status error, f_string *string) {
#ifndef _di_level_2_parameter_checking_
- if (string == f_null) return f_invalid_parameter;
+ if (string == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
- switch (error) {
+ f_status unmasked_error = f_error_unmask(error);
+
+ switch (unmasked_error) {
#ifndef _di_fll_fss_errors_error_
case fl_fss_invalid_format:
*string = "fl_fss_invalid_format";
#ifndef _di_fll_fss_errors_is_error_
f_return_status fll_fss_errors_is_error(const f_status error) {
- if (fll_fss_errors_is_okay(error) == f_true) {
+ if (fll_fss_errors_is_fine(error) == f_true) {
return f_false;
} else if (fll_fss_errors_is_warning(error) == f_true) {
return f_false;
}
#endif // _di_fll_fss_errors_is_warning_
-#ifndef _di_fll_fss_errors_is_okay_
- f_return_status fll_fss_errors_is_okay(const f_status error) {
+#ifndef _di_fll_fss_errors_is_fine_
+ f_return_status fll_fss_errors_is_fine(const f_status error) {
switch (error) {
#ifndef _di_fll_fss_errors_booleans_
case f_false:
return f_false;
}
-#endif // _di_fll_fss_errors_is_okay_
+#endif // _di_fll_fss_errors_is_fine_
#ifdef __cplusplus
} // extern "C"
#define _FLL_fss_errors_h
// fll-0 includes
-#include <level_0/strings.h>
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
#include <level_0/fss.h>
#endif // _di_fll_fss_errors_is_warning_
-#ifndef _di_fll_fss_errors_is_okay_
+#ifndef _di_fll_fss_errors_is_fine_
// Returns true or false depending on whether the standard context of the error code represents an normal return status and not an error.
- // Keep in mind that many of the error codes are context-specific and may be reported as "okay" here when it is in fact not okay.
- extern f_return_status fll_fss_errors_is_okay(const f_status error);
-#endif // _di_fll_fss_errors_is_okay_
+ // Keep in mind that many of the error codes are context-specific and may be reported as "fine" here when it is in fact not fine.
+ extern f_return_status fll_fss_errors_is_fine(const f_status error);
+#endif // _di_fll_fss_errors_is_fine_
#ifdef __cplusplus
} // extern "C"
#ifndef _di_fll_fss_extended_read_
f_return_status fll_fss_extended_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents) {
#ifndef _di_level_2_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (objects == f_null) return f_invalid_parameter;
- if (contents == f_null) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (objects == f_null) return f_error_set_error(f_invalid_parameter);
+ if (contents == f_null) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
f_status status = f_status_initialize;
if (objects->used >= objects->size) {
f_resize_fss_objects(status, (*objects), objects->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
f_resize_fss_contents(status, (*contents), contents->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
f_resize_fss_content(status, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
f_resize_fss_content(status, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
#ifndef _di_fll_fss_extended_write_
f_return_status fll_fss_extended_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer) {
#ifndef _di_level_2_parameter_checking_
- if (buffer == f_null) return f_invalid_parameter;
- if (contents.used > contents.size) return f_invalid_parameter;
+ if (buffer == f_null) return f_error_set_error(f_invalid_parameter);
+ if (contents.used > contents.size) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_2_parameter_checking_
f_status status = 0;
#define _FLL_fss_extended_h
// fll-0 includes
-#include <level_0/strings.h>
-#include <level_0/errors.h>
#include <level_0/types.h>
+#include <level_0/errors.h>
+#include <level_0/strings.h>
#include <level_0/memory.h>
#include <level_0/fss.h>
}
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
// nothing can be 0 as that represents the program name, unless argv[] is improperly created
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- } else if (status == f_invalid_parameter) {
+ } else if (f_error_unmask(status) == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_error_set_error(status));
}
firewall_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
f_resize_dynamic_strings(status, arguments, 7);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
firewall_delete_local_data(&local);
firewall_delete_data(data);
fflush(f_standard_output);
}
- if (status != f_failure && show_mangle) {
+ if (f_error_is_not_error(status) && show_mangle) {
fl_print_color(f_standard_output, data->context.standout, data->context.reset, "========================== ");
fl_print_color(f_standard_output, data->context.title, data->context.reset, "MANGLE");
fl_print_color_line(f_standard_output, data->context.standout, data->context.reset, " ==========================");
fflush(f_standard_output);
}
- if (status != f_failure && show_ports) {
+ if (f_error_is_not_error(status) && show_ports) {
fl_print_color(f_standard_output, data->context.standout, data->context.reset, "========================== ");
fl_print_color(f_standard_output, data->context.title, data->context.reset, "PORTS");
fl_print_color_line(f_standard_output, data->context.standout, data->context.reset, " ===========================");
fflush(f_standard_output);
}
- if (status == f_failure) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_program_name);
- fprintf(f_standard_error, " ");
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
+ if (f_macro_test_for_allocation_errors(status)) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ } else {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_program_name);
+ fprintf(f_standard_error, " ");
+
+ f_string_length i = f_string_length_initialize;
- f_string_length i = f_string_length_initialize;
+ fl_print_color_code(f_standard_error, data->context.error);
- fl_print_color_code(f_standard_error, data->context.error);
+ for (; i < arguments.used; i++) {
+ fprintf(f_standard_error, "%s ", arguments.array[i].string);
+ }
- for (; i < arguments.used; i++) {
- fprintf(f_standard_error, "%s ", arguments.array[i].string);
+ fl_print_color_code(f_standard_error, data->context.reset);
+ fprintf(f_standard_error, "\n");
}
- fl_print_color_code(f_standard_error, data->context.reset);
- fprintf(f_standard_error, "\n");
- } else if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ status = f_error_set_error(status);
}
arguments.array[0].string = 0;
f_delete_dynamic_strings(status, arguments);
firewall_delete_local_data(&local);
firewall_delete_data(data);
- return f_none;
+ return status;
}
// load all network devices
status = fl_directory_list((f_string) network_devices, &data->devices);
- if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- } else if (status == f_no_data) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: could not find any network devices");
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- } else if (status == f_failure) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to read the device directory '%s'", network_devices);
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
+ if (f_macro_test_for_allocation_errors(status)) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ } else if (status == f_no_data) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: could not find any network devices");
+ } else if (status == f_failure) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to read the device directory '%s'", network_devices);
+ }
+
firewall_delete_local_data(&local);
firewall_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// remove "lo" (loopback) from the device listing
if (command == firewall_parameter_command_stop || command == firewall_parameter_command_restart || command == firewall_parameter_command_lock) {
status = firewall_buffer_rules(network_path firewall_file_other, f_false, &local, data);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (f_error_is_error(status)) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
status = firewall_process_rules(&input, &local, data);
- if (status != f_none || command == firewall_parameter_command_stop) {
+ if (f_error_is_error(status) || command == firewall_parameter_command_stop) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
if (command == firewall_parameter_command_start || command == firewall_parameter_command_restart) {
status = firewall_buffer_rules(network_path firewall_file_first, f_false, &local, data);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (f_error_is_error(status)) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
status = firewall_create_custom_chains(&reserved, &local, data);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
status = firewall_process_rules(&input, &local, data);
- if ((status != f_none && status != f_no_data && status != f_no_data_on_stop) || command == firewall_parameter_command_stop) {
+ if (f_error_is_error(status) || command == firewall_parameter_command_stop) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
f_resize_dynamic_string(status, file_path, network_path_length + data->devices.array[i].used + firewall_file_suffix_length + 1);
- if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.", status);
+ if (f_error_is_error(status)) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
f_delete_dynamic_string(status2, file_path);
}
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos && status != f_none_on_stop) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
firewall_delete_local_data(&local);
if (status == f_file_not_found || status == f_file_open_error || status == f_file_descriptor_error || status == fl_fss_found_object_no_content) {
+ status = f_error_set_error(status);
continue;
}
firewall_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
status = firewall_create_custom_chains(&reserved, &local, data);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
status = firewall_process_rules(&input, &local, data);
- if ((status != f_none && status != f_no_data && status != f_no_data_on_stop) || command == firewall_parameter_command_stop) {
+ if (f_error_is_error(status) || command == firewall_parameter_command_stop) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
status = firewall_buffer_rules(network_path firewall_file_last, f_false, &local, data);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (f_error_is_error(status)) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
status = firewall_create_custom_chains(&reserved, &local, data);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
firewall_macro_delete_fss_buffers(status2, local.buffer, local.chain_objects, local.chain_contents)
firewall_delete_data(data);
return status;
status = firewall_process_rules(&input, &local, data);
- if (status != f_none || command == firewall_parameter_command_stop) {
+ if (f_error_is_error(status) || command == firewall_parameter_command_stop) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
firewall_delete_local_data(&local);
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: You did not pass a command");
- status = f_invalid_parameter;
+ status = f_error_set_error(f_invalid_parameter);
}
}
} else {
f_resize_dynamic_string(status, device, data.devices.array[local.device].used);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
f_delete_dynamic_string(status2, device);
return status;
f_delete_dynamic_string(status, device);
f_resize_dynamic_string(status, device, data.devices.array[local.device].used);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(device.string, data.devices.array[local.device].string, data.devices.array[local.device].used);
device.used = data.devices.array[local.device].used;
f_delete_dynamic_string(status, device);
f_resize_dynamic_string(status, device, length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(device.string, local.buffer.string + local.rule_contents.array[i].array[0].start, length);
device.used = length;
f_delete_dynamic_string(status, protocol);
f_resize_dynamic_string(status, protocol, length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
if (fl_compare_strings(local.buffer.string + local.rule_objects.array[i].start, (f_string) firewall_protocol_none, length, firewall_protocol_none_length) == f_equal_to) {
use_protocol = f_false;
f_delete_dynamic_strings(status, arguments);
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
f_resize_dynamic_string(status, argument, firewall_program_name_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_program_name, firewall_program_name_length);
argument.used = firewall_program_name_length;
if (action == firewall_action_append_id) {
f_resize_dynamic_string(status, argument, firewall_action_append_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_action_append_command, firewall_action_append_command_length);
argument.used = firewall_action_append_command_length;
} else if (action == firewall_action_insert_id) {
f_resize_dynamic_string(status, argument, firewall_action_insert_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_action_insert_command, firewall_action_insert_command_length);
argument.used = firewall_action_insert_command_length;
} else if (action == firewall_action_policy_id) {
f_resize_dynamic_string(status, argument, firewall_action_policy_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_action_policy_command, firewall_action_policy_command_length);
argument.used = firewall_action_policy_command_length;
if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
arguments.array[arguments.used].string = argument.string;
arguments.array[arguments.used].size = argument.size;
if (!(local.is_main || local.is_stop || local.is_lock)) {
f_resize_dynamic_string(status, argument, data.chains.array[local.chain_ids.array[local.chain]].used);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, data.chains.array[local.chain_ids.array[local.chain]].string, data.chains.array[local.chain_ids.array[local.chain]].used);
argument.used = data.chains.array[local.chain].used;
} else if (direction == firewall_direction_forward_id) {
f_resize_dynamic_string(status, argument, firewall_direction_forward_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_direction_forward_command, firewall_direction_forward_command_length);
argument.used = firewall_direction_forward_command_length;
} else if (direction == firewall_direction_postrouting_id) {
f_resize_dynamic_string(status, argument, firewall_direction_postrouting_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_direction_postrouting_command, firewall_direction_postrouting_command_length);
argument.used += firewall_direction_postrouting_command_length;
} else if (direction == firewall_direction_prerouting_id) {
f_resize_dynamic_string(status, argument, firewall_direction_prerouting_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_direction_prerouting_command, firewall_direction_prerouting_command_length);
argument.used = firewall_direction_prerouting_command_length;
} else if (direction_input) {
f_resize_dynamic_string(status, argument, firewall_direction_input_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_direction_input_command, firewall_direction_input_command_length);
argument.used = firewall_direction_input_command_length;
} else if (direction_output) {
f_resize_dynamic_string(status, argument, firewall_direction_output_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_direction_output_command, firewall_direction_output_command_length);
argument.used = firewall_direction_output_command_length;
if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
arguments.array[arguments.used].string = argument.string;
arguments.array[arguments.used].size = argument.size;
if (length < firewall_device_all_length || fl_compare_strings(local.buffer.string + local.rule_contents.array[i].array[0].start, (f_string) firewall_device_all, length, firewall_device_all_length) == f_not_equal_to) {
if (direction_input) {
f_resize_dynamic_string(status, argument, firewall_device_input_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_device_input_command, firewall_device_input_command_length);
argument.used = firewall_device_input_command_length;
} else if (direction_output) {
f_resize_dynamic_string(status, argument, firewall_device_output_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_device_output_command, firewall_device_output_command_length);
argument.used = firewall_device_output_command_length;
if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
arguments.array[arguments.used].string = argument.string;
arguments.array[arguments.used].size = argument.size;
if (direction_input || direction_output) {
f_resize_dynamic_string(status, argument, device.used);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, device.string, device.used);
argument.used = device.used;
if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
arguments.array[arguments.used].string = argument.string;
arguments.array[arguments.used].size = argument.size;
if (use_protocol) {
f_resize_dynamic_string(status, argument, firewall_protocol_command_length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, firewall_protocol_command, firewall_protocol_command_length);
argument.used = firewall_protocol_command_length;
if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
arguments.array[arguments.used].string = argument.string;
arguments.array[arguments.used].size = argument.size;
}
f_resize_dynamic_string(status, argument, protocol.used);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, protocol.string, protocol.used);
argument.used = protocol.used;
if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
arguments.array[arguments.used].string = argument.string;
arguments.array[arguments.used].size = argument.size;
f_resize_dynamic_string(status, ip_list, length);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
subcounter = local.rule_contents.array[i].used;
} else {
strncat(ip_list.string, local.buffer.string + local.rule_contents.array[i].array[subcounter].start, length);
f_resize_dynamic_string(status, argument, length);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
strncat(argument.string, local.buffer.string + local.rule_contents.array[i].array[subcounter].start, length);
argument.used = length;
if (length > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
- if (f_macro_test_for_allocation_errors(status)) break;
+ if (f_error_is_error(status)) break;
arguments.array[arguments.used].string = argument.string;
arguments.array[arguments.used].size = argument.size;
status = f_file_open(&file, file_path.string);
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%s'", file_path.string);
} else if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
+ }
+
+ if (status != f_file_not_found) {
+ status = f_error_set_error(status);
}
f_file_close(&file);
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
} else if (status == f_overflow) {
} else if (status == f_file_read_error) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%s'", file_path.string);
} else if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", status);
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", f_error_set_error(status));
}
+
+ status = f_error_set_error(status);
} else {
{
f_string_location input = f_string_location_initialize;
status = fll_fss_basic_read(&local_buffer, &input, &basic_objects, &basic_contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (f_error_set_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_read() for the file '%s'", file_path.string);
} 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 (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_read() for the file '%s'", status, file_path.string);
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_read() for the file '%s'", f_error_set_error(status), file_path.string);
}
+
+ status = f_error_set_error(status);
} else {
f_string_length buffer_counter = f_string_length_initialize;
f_string_length ip_length = f_string_length_initialize;
ip_list_action.used = ip_list_action.size;
ip_list_action.string[ip_list_action.used] = 0;
- if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
+ if (f_error_is_error(status)) {
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
ip_list_action.used = ip_list_action.size;
f_resize_dynamic_strings(status, arguments, arguments.used + 2);
- if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
+ if (f_error_is_error(status)) {
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
arguments.array[arguments.used].string = ip_list_action.string;
arguments.array[arguments.used].size = ip_list_action.size;
f_resize_dynamic_string(status, ip_argument, ip_length);
- if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
+ if (f_error_is_error(status)) {
+ fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
break;
}
local->chain_ids.used = 0;
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
f_resize_dynamic_strings(status, arguments, 3);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
f_resize_dynamic_string(status, arguments.array[0], firewall_program_name_length);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
f_delete_dynamic_strings(status2, arguments);
return status;
f_resize_dynamic_string(status, arguments.array[1], firewall_chain_create_command_length);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
f_delete_dynamic_strings(status2, arguments);
return status;
if (data->chains.used >= data->chains.size) {
f_resize_dynamic_strings(status, data->chains, data->chains.used + firewall_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
f_delete_dynamic_strings(status2, arguments);
return status;
if (length >= arguments.array[2].size) {
f_resize_dynamic_string(status, arguments.array[2], length + firewall_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
f_delete_dynamic_strings(status2, arguments);
return status;
f_resize_dynamic_string(status, data->chains.array[data->chains.used], length);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
f_delete_dynamic_strings(status2, arguments);
return status;
f_resize_dynamic_string(status, data->chains.array[data->chains.used], data->chains.array[data->chains.used].used);
- if (f_macro_test_for_allocation_errors(status)) {
+ if (f_error_is_error(status)) {
f_delete_dynamic_strings(status2, arguments);
return status;
status = fll_execute_program((f_string) firewall_program_name, arguments, &results);
- if (status == f_failure) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_program_name);
- fprintf(f_standard_error, " ");
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
- f_string_length i = f_string_length_initialize;
+ if (status == f_failure) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_program_name);
+ fprintf(f_standard_error, " ");
- fl_print_color_code(f_standard_error, data->context.error);
+ f_string_length i = f_string_length_initialize;
- for (; i < arguments.used; i++) {
- fprintf(f_standard_error, "%s ", arguments.array[i].string);
- }
+ fl_print_color_code(f_standard_error, data->context.error);
- fl_print_color_code(f_standard_error, data->context.reset);
- fprintf(f_standard_error, "\n");
+ for (; i < arguments.used; i++) {
+ fprintf(f_standard_error, "%s ", arguments.array[i].string);
+ }
- f_delete_dynamic_strings(status2, arguments);
+ fl_print_color_code(f_standard_error, data->context.reset);
+ fprintf(f_standard_error, "\n");
+ } else if (status == f_invalid_parameter) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_execute_path()");
+ } else {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", f_error_set_error(status));
+ }
- return status;
- } else if (status == f_invalid_parameter) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_execute_path()");
f_delete_dynamic_strings(status2, arguments);
-
- return status;
+ return f_error_set_error(status);
}
data->chains.used++;
status = f_file_open(&file, filename);
- if (optional && status != f_none) {
- if (status == f_invalid_parameter) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
- } else if (status != f_file_not_found && status != f_file_open_error && status != f_file_descriptor_error) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", status);
- }
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
- return status;
- } else if (status != f_none) {
- if (status == f_invalid_parameter) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
- } else if (status == f_file_not_found) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'.", filename);
- } else if (status == f_file_open_error) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'.", filename);
- } else if (status == f_file_descriptor_error) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename);
+ if (optional) {
+ if (status == f_invalid_parameter) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
+ } else if (status != f_file_not_found && status != f_file_open_error && status != f_file_descriptor_error) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_error_set_error(status));
+ }
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", status);
+ if (status == f_invalid_parameter) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
+ } else if (status == f_file_not_found) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'.", filename);
+ } else if (status == f_file_open_error) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'.", filename);
+ } else if (status == f_file_descriptor_error) {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename);
+ } else {
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_error_set_error(status));
+ }
}
- return status;
+ return f_error_set_error(status);
}
f_macro_file_reset_position(local->file_position, file)
+
+ fflush(stdout);
status = fl_file_read(file, local->file_position, &local->buffer);
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read().");
} else if (status == f_overflow) {
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read().", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read().", f_error_set_error(status));
}
- return status;
+ return f_error_set_error(status);
} else {
f_string_location input = f_string_location_initialize;
status = fll_fss_basic_list_read(&local->buffer, &input, &local->chain_objects, &local->chain_contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", filename);
} else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", status, filename);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", f_error_set_error(status), filename);
}
- return status;
+ return f_error_set_error(status);
}
return status;
status = fll_fss_extended_read(&local->buffer, input, &local->rule_objects, &local->rule_contents);
-
- if (status == f_none || status == f_none_on_stop || status == f_none_on_eos) {
+ if (f_error_is_not_error(status)) {
status = firewall_perform_commands(*local, *data);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (f_macro_test_for_allocation_errors(status)) {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.", status);
+ fl_print_color_line(f_standard_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_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", f_error_set_error(status));
}
f_delete_fss_objects(status2, local->rule_objects);
f_delete_fss_contents(status2, local->rule_contents);
- return status;
+ return f_error_set_error(status);
}
}
f_return_status fss_basic_list_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility ("internal")));
f_return_status fss_basic_list_read_main(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_basic_list_read_total_parameters, &data->remaining);
// load colors when not told to show no colors
if (data->parameters[fss_basic_list_read_parameter_no_color].result == f_console_result_none) {
- fll_new_color_context(allocation_status, data->context);
+ fll_new_color_context(status2, data->context);
- if (allocation_status == f_none) {
- fll_colors_load_context(&data->context, data->parameters[fss_basic_list_read_parameter_light].result == f_console_result_found);
- } else {
+ if (f_error_is_error(status2)) {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
fss_basic_list_read_delete_data(data);
- return allocation_status;
+ return status2;
+ } else {
+ fll_colors_load_context(&data->context, data->parameters[fss_basic_list_read_parameter_light].result == f_console_result_found);
}
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
} else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_error_set_error(status));
}
fss_basic_list_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
status = fl_file_read_fifo(file, &data->buffer);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
fss_basic_list_read_delete_data(data);
status = fss_basic_list_read_main_process_file(argc, argv, data, "-", target);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
return status;
}
// clear buffers before continuing
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
}
for (; counter < data->remaining.used; counter++) {
data->file_position.total_elements = original_size;
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
fss_basic_list_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
- // TODO: this file size set functionality might be turned into an fl_file (or f_file) function
if (data->file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
} else if (status == f_overflow) {
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", f_error_set_error(status));
}
fss_basic_list_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
status = fss_basic_list_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
return status;
}
// clear buffers before repeating the loop
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
} // for
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files");
- status = f_invalid_parameter;
+ status = f_error_set_error(f_invalid_parameter);
}
fss_basic_list_read_delete_data(data);
}
f_return_status fss_basic_list_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data, const f_string filename, const f_string_length target) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
f_string_length current = f_string_length_initialize;
- f_string_length found = f_string_length_initialize;
+ f_string_length found = f_string_length_initialize;
{
f_string_location input = f_string_location_initialize;
status = fll_fss_basic_list_read(&data->buffer, &input, &data->objects, &data->contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
-
- fss_basic_list_read_delete_data(data);
- return status;
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof) {
- // not an error in this case
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
-
- fss_basic_list_read_delete_data(data);
- return status;
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", status, filename);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", f_error_set_error(status), filename);
}
+ fss_basic_list_read_delete_data(data);
+ return f_error_set_error(status);
+ } else if (f_macro_test_for_no_data_errors(status)) {
// clear buffers, then attempt the next file
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
- return status;
+ return f_error_set_warning(status);
}
// now that all of the files have been read, process the objects and contents
#ifndef _di_fss_basic_list_write_main_
f_return_status fss_basic_list_write_main(const f_array_length argc, const f_string argv[], fss_basic_list_write_data *data) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_basic_list_write_total_parameters, &data->remaining);
// load colors when not told to show no colors
if (data->parameters[fss_basic_list_write_parameter_no_color].result == f_console_result_none) {
- fll_new_color_context(allocation_status, data->context);
+ fll_new_color_context(status2, data->context);
- if (allocation_status == f_none) {
- fll_colors_load_context(&data->context, data->parameters[fss_basic_list_write_parameter_light].result == f_console_result_found);
- } else {
+ if (f_error_is_error(status2)) {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
fss_basic_list_write_delete_data(data);
- return allocation_status;
+ return status2;
+ } else {
+ fll_colors_load_context(&data->context, data->parameters[fss_basic_list_write_parameter_light].result == f_console_result_found);
}
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
} else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", f_error_set_error(status));
}
fss_basic_list_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
status = fl_file_read_fifo(file, &input);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
- f_delete_dynamic_string(status, input);
+ f_delete_dynamic_string(status2, input);
fss_basic_list_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
location.start = 0;
if (object) {
status = fl_fss_basic_list_object_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
} else {
status = fl_fss_basic_list_content_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
}
if (object) {
status = fl_fss_basic_list_object_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
} else {
status = fl_fss_basic_list_content_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
}
output.mode = f_file_write_append;
status = f_file_open(&output, argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
f_file_close(&output);
if (status == f_invalid_parameter) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
fss_basic_list_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
status = fl_file_write(output, buffer);
f_file_close(&output);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
} else if (status == f_file_write_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_error_set_error(status));
}
fss_basic_list_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
} else {
f_print_dynamic_string(f_standard_output, buffer);
#ifndef _di_fss_basic_list_write_delete_data_
f_return_status fss_basic_list_write_delete_data(fss_basic_list_write_data *data) {
- f_status status = f_status_initialize;
- f_string_length i = 0;
+ f_status status = f_status_initialize;
+ f_string_length i = 0;
while (i < fss_basic_list_write_total_parameters) {
f_delete_string_lengths(status, data->parameters[i].additional);
f_return_status fss_basic_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility("internal")));
f_return_status fss_basic_read_main(const f_array_length argc, const f_string argv[], fss_basic_read_data *data) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_basic_read_total_parameters, &data->remaining);
// load colors when not told to show no colors
if (data->parameters[fss_basic_read_parameter_no_color].result == f_console_result_none) {
- fll_new_color_context(allocation_status, data->context);
+ fll_new_color_context(status2, data->context);
- if (allocation_status == f_none) {
- fll_colors_load_context(&data->context, data->parameters[fss_basic_read_parameter_light].result == f_console_result_found);
- } else {
+ if (f_error_is_error(status2)) {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
fss_basic_read_delete_data(data);
- return allocation_status;
+ return status2;
+ } else {
+ fll_colors_load_context(&data->context, data->parameters[fss_basic_read_parameter_light].result == f_console_result_found);
}
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
} else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_error_set_error(status));
}
fss_basic_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
status = fl_file_read_fifo(file, &data->buffer);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
} else if (status == f_overflow) {
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", "-");
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", f_error_set_error(status));
}
fss_basic_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
status = fss_basic_read_main_process_file(argc, argv, data, "-", target);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
return status;
}
// clear buffers before continuing
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
}
if (data->remaining.used > 0) {
data->file_position.total_elements = original_size;
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
fss_basic_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
- // TODO: this file size set functionality might be turned into an fl_file (or f_file) function
if (data->file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
} else if (status == f_overflow) {
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", argv[data->remaining.array[counter]]);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", f_error_set_error(status));
}
fss_basic_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
status = fss_basic_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
return status;
}
// clear buffers before repeating the loop
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
} // for
}
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files");
- status = f_invalid_parameter;
+ status = f_error_set_error(f_invalid_parameter);
}
fss_basic_read_delete_data(data);
}
f_return_status fss_basic_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_read_data *data, const f_string filename, const f_string_length target) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
f_string_length current = f_string_length_initialize;
- f_string_length found = f_string_length_initialize;
+ f_string_length found = f_string_length_initialize;
{
f_string_location input = f_string_location_initialize;
status = fll_fss_basic_read(&data->buffer, &input, &data->objects, &data->contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
-
- fss_basic_read_delete_data(data);
- return status;
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof) {
- // not an error in this case
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
-
- fss_basic_read_delete_data(data);
- return status;
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", status, filename);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", f_error_set_error(status), filename);
}
+ fss_basic_read_delete_data(data);
+ return f_error_set_error(status);
+ } else if (f_macro_test_for_no_data_errors(status)) {
// clear buffers, then attempt the next file
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
- return f_none;
+ return f_error_set_warning(status);
}
// now that the file has been read, process the objects and contents
#ifndef _di_fss_basic_write_main_
f_return_status fss_basic_write_main(const f_array_length argc, const f_string argv[], fss_basic_write_data *data) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_basic_write_total_parameters, &data->remaining);
// load colors when not told to show no colors
if (data->parameters[fss_basic_write_parameter_no_color].result == f_console_result_none) {
- fll_new_color_context(allocation_status, data->context);
+ fll_new_color_context(status2, data->context);
- if (allocation_status == f_none) {
- fll_colors_load_context(&data->context, data->parameters[fss_basic_write_parameter_light].result == f_console_result_found);
- } else {
+ if (f_error_is_error(status2)) {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
fss_basic_write_delete_data(data);
- return allocation_status;
+ return status2;
+ } else {
+ fll_colors_load_context(&data->context, data->parameters[fss_basic_write_parameter_light].result == f_console_result_found);
}
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
} else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", f_error_set_error(status));
}
fss_basic_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
status = fl_file_read_fifo(file, &input);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
- f_delete_dynamic_string(status, input);
+ f_delete_dynamic_string(status2, input);
fss_basic_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
location.start = 0;
if (object) {
status = fl_fss_basic_object_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
} else {
status = fl_fss_basic_content_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
}
if (object) {
status = fl_fss_basic_object_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
} else {
status = fl_fss_basic_content_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
}
output.mode = f_file_write_append;
status = f_file_open(&output, argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
f_file_close(&output);
if (status == f_invalid_parameter) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
fss_basic_write_delete_data(data);
status = fl_file_write(output, buffer);
f_file_close(&output);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
} else if (status == f_file_write_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_error_set_error(status));
}
fss_basic_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
} else {
f_print_dynamic_string(f_standard_output, buffer);
#ifndef _di_fss_basic_write_delete_data_
f_return_status fss_basic_write_delete_data(fss_basic_write_data *data) {
- f_status status = f_status_initialize;
- f_string_length i = 0;
+ f_status status = f_status_initialize;
+ f_string_length i = 0;
while (i < fss_basic_write_total_parameters) {
f_delete_string_lengths(status, data->parameters[i].additional);
f_return_status fss_extended_read_main_process_file(const f_array_length argc, const f_string argv[], fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) __attribute__((visibility("internal")));
f_return_status fss_extended_read_main(const f_array_length argc, const f_string argv[], fss_extended_read_data *data) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_extended_read_total_parameters, &data->remaining);
// load colors when not told to show no colors
if (data->parameters[fss_extended_read_parameter_no_color].result == f_console_result_none) {
- fll_new_color_context(allocation_status, data->context);
+ fll_new_color_context(status2, data->context);
- if (allocation_status == f_none) {
- fll_colors_load_context(&data->context, data->parameters[fss_extended_read_parameter_light].result == f_console_result_found);
- } else {
+ if (f_error_is_error(status2)) {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
fss_extended_read_delete_data(data);
- return allocation_status;
+ return status2;
+ } else {
+ fll_colors_load_context(&data->context, data->parameters[fss_extended_read_parameter_light].result == f_console_result_found);
}
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
} else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_error_set_error(status));
}
fss_extended_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
status = fl_file_read_fifo(file, &data->buffer);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
fss_extended_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
status = fss_extended_read_main_process_file(argc, argv, data, "-", target, select);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
return status;
}
// clear buffers before continuing
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
}
for (; counter < data->remaining.used; counter++) {
data->file_position.total_elements = original_size;
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
fss_extended_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
+ } else if (f_macro_test_for_no_data_errors(status)) {
+ // clear buffers, then attempt the next file
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
+
+ return f_error_set_warning(status);
}
- // TODO: this file size set functionality might be turned into an fl_file (or f_file) function
if (data->file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
} else if (status == f_overflow) {
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", f_error_set_error(status));
}
fss_extended_read_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
status = fss_extended_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target, select);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (f_error_is_error(status)) {
return status;
}
// clear buffers before repeating the loop
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
} // for
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files");
- status = f_invalid_parameter;
+ status = f_error_set_error(f_invalid_parameter);
}
fss_extended_read_delete_data(data);
}
f_return_status fss_extended_read_main_process_file(const f_array_length argc, const f_string argv[], fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
f_string_length current = f_string_length_initialize;
- f_string_length found = f_string_length_initialize;
+ f_string_length found = f_string_length_initialize;
{
f_string_location input = f_string_location_initialize;
status = fll_fss_extended_read(&data->buffer, &input, &data->objects, &data->contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_extended_read() for the file '%s'", filename);
-
- fss_extended_read_delete_data(data);
- return status;
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof) {
- // not an error in this case
} else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
-
- fss_extended_read_delete_data(data);
- return status;
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_extended_read() for the file '%s'", status, filename);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_extended_read() for the file '%s'", f_error_set_error(status), filename);
}
+ fss_extended_read_delete_data(data);
+ return f_error_set_error(status);
+ } else if (f_macro_test_for_no_data_errors(status)) {
// clear buffers, then attempt the next file
- f_delete_fss_contents(allocation_status, data->contents);
- f_delete_fss_objects(allocation_status, data->objects);
- f_delete_dynamic_string(allocation_status, data->buffer);
+ f_delete_fss_contents(status2, data->contents);
+ f_delete_fss_objects(status2, data->objects);
+ f_delete_dynamic_string(status2, data->buffer);
- return status;
+ return f_error_set_warning(status);
}
// now that all of the files have been read, process the objects and contents
#ifndef _di_fss_extended_write_main_
f_return_status fss_extended_write_main(const f_array_length argc, const f_string argv[], fss_extended_write_data *data) {
- f_status status = f_status_initialize;
- f_status allocation_status = f_status_initialize;
+ f_status status = f_status_initialize;
+ f_status status2 = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_extended_write_total_parameters, &data->remaining);
// load colors when not told to show no colors
if (data->parameters[fss_extended_write_parameter_no_color].result == f_console_result_none) {
- fll_new_color_context(allocation_status, data->context);
+ fll_new_color_context(status2, data->context);
- if (allocation_status == f_none) {
- fll_colors_load_context(&data->context, data->parameters[fss_extended_write_parameter_light].result == f_console_result_found);
- } else {
+ if (f_error_is_error(status2)) {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
fss_extended_write_delete_data(data);
- return allocation_status;
+ return status2;
+ } else {
+ fll_colors_load_context(&data->context, data->parameters[fss_extended_write_parameter_light].result == f_console_result_found);
}
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
} else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", f_error_set_error(status));
}
fss_extended_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
status = fl_file_read_fifo(file, &input);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
} else if (status == f_file_not_found) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
- f_delete_dynamic_string(status, input);
+ f_delete_dynamic_string(status2, input);
fss_extended_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
location.start = 0;
if (object) {
status = fl_fss_extended_object_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
} else {
status = fl_fss_extended_content_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_none) {
if (buffer.used >= buffer.size) {
f_resize_dynamic_string(status, buffer, buffer.used + f_fss_default_allocation_step);
- if (f_macro_test_for_no_data_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
status = fl_fss_extended_object_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
} else {
f_string_length i = 0;
status = fl_fss_extended_content_write(input, &location, &buffer);
- if (f_macro_test_for_no_data_errors(status)) {
- return status;
+ if (f_error_is_error(status) || f_macro_test_for_no_data_errors(status)) {
+ return f_error_set_error(status);
}
i++;
if (buffer.used >= buffer.size) {
f_resize_dynamic_string(status, buffer, buffer.used + f_fss_default_allocation_step);
- if (f_macro_test_for_no_data_errors(status)) {
+ if (f_error_is_error(status)) {
return status;
}
}
output.mode = f_file_write_append;
status = f_file_open(&output, argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
f_file_close(&output);
if (status == f_invalid_parameter) {
} else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_error_set_error(status));
}
fss_extended_write_delete_data(data);
status = fl_file_write(output, buffer);
f_file_close(&output);
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_write()");
} else if (status == f_file_write_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
} else {
- fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+ fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_error_set_error(status));
}
fss_extended_write_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
} else {
f_print_dynamic_string(f_standard_output, buffer);
#ifndef _di_fss_extended_write_delete_data_
f_return_status fss_extended_write_delete_data(fss_extended_write_data *data) {
- f_status status = f_status_initialize;
- f_string_length i = 0;
+ f_status status = f_status_initialize;
+ f_string_length i = 0;
while (i < fss_extended_write_total_parameters) {
f_delete_string_lengths(status, data->parameters[i].additional);
printf("\n");
printf("\n %s", f_console_symbol_short_enable);
- fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_short_is_okay);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_short_is_fine);
printf(", %s", f_console_symbol_long_enable);
- fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_long_is_okay);
- printf(" Returns true if the error code is not an error.");
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_long_is_fine);
+ printf(" Returns true if the error code is not an error.");
printf("\n %s", f_console_symbol_short_enable);
fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_short_is_warning);
printf(", %s", f_console_symbol_long_enable);
fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_long_is_warning);
- printf(" Returns true if the error code is a warning.");
+ printf(" Returns true if the error code is a warning.");
printf("\n %s", f_console_symbol_short_enable);
fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_short_is_error);
printf(", %s", f_console_symbol_long_enable);
fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_long_is_error);
- printf(" Returns true if the error code is an error.");
+ printf(" Returns true if the error code is an error.");
+
+ printf("\n %s", f_console_symbol_short_enable);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_short_context);
+
+ printf(", %s", f_console_symbol_long_enable);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, fss_return_code_long_context);
+ printf(" Guess error state from context of error (ignores masks).");
printf("\n\n");
if (data->parameters[fss_return_code_parameter_no_color].result == f_console_result_none) {
fll_new_color_context(allocation_status, data->context);
- if (allocation_status == f_none) {
- fll_colors_load_context(&data->context, data->parameters[fss_return_code_parameter_light].result == f_console_result_found);
- } else {
+ if (f_error_is_error(allocation_status)) {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
fss_return_code_delete_data(data);
return allocation_status;
}
+
+ fll_colors_load_context(&data->context, data->parameters[fss_return_code_parameter_light].result == f_console_result_found);
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
}
fss_return_code_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fll_fss_errors_is_error(code)) {
- fss_return_code_delete_data(data);
- return f_true;
+ if (data->parameters[fss_return_code_parameter_context].result == f_console_result_found) {
+ if (fll_fss_errors_is_error(code)) {
+ fss_return_code_delete_data(data);
+ return f_true;
+ }
+ } else {
+ if (f_error_is_error(code)) {
+ fss_return_code_delete_data(data);
+ return f_true;
+ }
}
}
for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fll_fss_errors_is_warning(code)) {
- fss_return_code_delete_data(data);
- return f_true;
+ if (data->parameters[fss_return_code_parameter_context].result == f_console_result_found) {
+ if (fll_fss_errors_is_warning(code)) {
+ fss_return_code_delete_data(data);
+ return f_true;
+ }
+ } else {
+ if (f_error_is_warning(code)) {
+ fss_return_code_delete_data(data);
+ return f_true;
+ }
}
}
fss_return_code_delete_data(data);
return f_false;
- } else if (data->parameters[fss_return_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0) {
+ } else if (data->parameters[fss_return_code_parameter_is_fine].result == f_console_result_found && data->remaining.used > 0) {
f_array_length counter = f_array_length_initialize;
f_status code = f_status_initialize;
for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fll_fss_errors_is_okay(code)) {
- fss_return_code_delete_data(data);
- return f_true;
+ if (data->parameters[fss_return_code_parameter_context].result == f_console_result_found) {
+ if (fll_fss_errors_is_fine(code)) {
+ fss_return_code_delete_data(data);
+ return f_true;
+ }
+ } else {
+ if (f_error_is_fine(code)) {
+ fss_return_code_delete_data(data);
+ return f_true;
+ }
}
}
}
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify an error code.");
- status = f_invalid_parameter;
+ status = f_error_set_error(f_invalid_parameter);
}
fss_return_code_delete_data(data);
#endif // _di_fss_return_code_name_
#ifndef _di_fss_return_code_defines_
- #define fss_return_code_short_is_okay "o"
+ #define fss_return_code_short_is_fine "f"
#define fss_return_code_short_is_warning "w"
#define fss_return_code_short_is_error "e"
+ #define fss_return_code_short_context "c"
- #define fss_return_code_long_is_okay "is_okay"
+ #define fss_return_code_long_is_fine "is_fine"
#define fss_return_code_long_is_warning "is_warning"
#define fss_return_code_long_is_error "is_error"
+ #define fss_return_code_long_context "context"
enum {
fss_return_code_parameter_help,
fss_return_code_parameter_no_color,
fss_return_code_parameter_version,
- fss_return_code_parameter_is_okay,
+ fss_return_code_parameter_is_fine,
fss_return_code_parameter_is_warning,
fss_return_code_parameter_is_error,
+ fss_return_code_parameter_context,
};
#define f_console_parameter_initialize_fss_return_code \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \
- f_console_parameter_initialize(fss_return_code_short_is_okay, fss_return_code_long_is_okay, 0, 0, f_false, f_console_type_normal, 0), \
+ f_console_parameter_initialize(fss_return_code_short_is_fine, fss_return_code_long_is_fine, 0, 0, f_false, f_console_type_normal, 0), \
f_console_parameter_initialize(fss_return_code_short_is_warning, fss_return_code_long_is_warning, 0, 0, f_false, f_console_type_normal, 0), \
f_console_parameter_initialize(fss_return_code_short_is_error, fss_return_code_long_is_error, 0, 0, f_false, f_console_type_normal, 0), \
+ f_console_parameter_initialize(fss_return_code_short_context, fss_return_code_long_context, 0, 0, f_false, f_console_type_normal, 0), \
}
- #define fss_return_code_total_parameters 7
+ #define fss_return_code_total_parameters 8
#endif // _di_fss_return_code_defines_
#ifndef _di_fss_return_code_data_
printf("\n");
printf("\n %s", f_console_symbol_short_enable);
- fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_short_is_okay);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_short_is_fine);
printf(", %s", f_console_symbol_long_enable);
- fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_long_is_okay);
- printf(" Returns true if the error code is not an error.");
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_long_is_fine);
+ printf(" Returns true if the error code is not an error.");
printf("\n %s", f_console_symbol_short_enable);
fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_short_is_warning);
printf(", %s", f_console_symbol_long_enable);
fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_long_is_warning);
- printf(" Returns true if the error code is a warning.");
+ printf(" Returns true if the error code is a warning.");
printf("\n %s", f_console_symbol_short_enable);
fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_short_is_error);
printf(", %s", f_console_symbol_long_enable);
fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_long_is_error);
- printf(" Returns true if the error code is an error.");
+ printf(" Returns true if the error code is an error.");
+
+ printf("\n %s", f_console_symbol_short_enable);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_short_context);
+
+ printf(", %s", f_console_symbol_long_enable);
+ fl_print_color(f_standard_output, data.context.standout, data.context.reset, return_code_long_context);
+ printf(" Guess error state from context of error (ignores masks).");
printf("\n\n");
if (data->parameters[return_code_parameter_no_color].result == f_console_result_none) {
fll_new_color_context(allocation_status, data->context);
- if (allocation_status == f_none) {
- fll_colors_load_context(&data->context, data->parameters[return_code_parameter_light].result == f_console_result_found);
- } else {
+ if (f_error_is_error(allocation_status)) {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
return_code_delete_data(data);
return allocation_status;
}
+
+ fll_colors_load_context(&data->context, data->parameters[return_code_parameter_light].result == f_console_result_found);
}
- if (status != f_none) {
+ if (f_error_is_error(status)) {
+ status = f_error_unmask(status);
+
if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
}
return_code_delete_data(data);
- return status;
+ return f_error_set_error(status);
}
// execute parameter results
for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fl_errors_is_error(code)) {
- return_code_delete_data(data);
- return f_true;
+ if (data->parameters[return_code_parameter_context].result == f_console_result_found) {
+ if (fl_errors_is_error(code)) {
+ return_code_delete_data(data);
+ return f_true;
+ }
+ } else {
+ if (f_error_is_error(code)) {
+ return_code_delete_data(data);
+ return f_true;
+ }
}
}
for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fl_errors_is_warning(code)) {
- return_code_delete_data(data);
- return f_true;
+ if (data->parameters[return_code_parameter_context].result == f_console_result_found) {
+ if (fl_errors_is_warning(code)) {
+ return_code_delete_data(data);
+ return f_true;
+ }
+ } else {
+ if (f_error_is_warning(code)) {
+ return_code_delete_data(data);
+ return f_true;
+ }
}
}
return_code_delete_data(data);
return f_false;
- } else if (data->parameters[return_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0) {
+ } else if (data->parameters[return_code_parameter_is_fine].result == f_console_result_found && data->remaining.used > 0) {
f_array_length counter = f_array_length_initialize;
f_status code = f_status_initialize;
for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fl_errors_is_okay(code)) {
- return_code_delete_data(data);
- return f_true;
+ if (data->parameters[return_code_parameter_context].result == f_console_result_found) {
+ if (fl_errors_is_fine(code)) {
+ return_code_delete_data(data);
+ return f_true;
+ }
+ } else {
+ if (f_error_is_fine(code)) {
+ return_code_delete_data(data);
+ return f_true;
+ }
}
}
}
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify an error code.");
- status = f_invalid_parameter;
+ status = f_error_set_error(f_invalid_parameter);
}
return_code_delete_data(data);
#endif // _di_return_code_name_
#ifndef _di_return_code_defines_
- #define return_code_short_is_okay "o"
+ #define return_code_short_is_fine "f"
#define return_code_short_is_warning "w"
#define return_code_short_is_error "e"
+ #define return_code_short_context "c"
- #define return_code_long_is_okay "is_okay"
+ #define return_code_long_is_fine "is_fine"
#define return_code_long_is_warning "is_warning"
#define return_code_long_is_error "is_error"
+ #define return_code_long_context "context"
enum {
return_code_parameter_help,
return_code_parameter_no_color,
return_code_parameter_version,
- return_code_parameter_is_okay,
+ return_code_parameter_is_fine,
return_code_parameter_is_warning,
return_code_parameter_is_error,
+ return_code_parameter_context,
};
#define f_console_parameter_initialize_return_code \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_false, f_console_type_inverse, 0), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_false, f_console_type_inverse, 0), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_false, f_console_type_normal, 0), \
- f_console_parameter_initialize(return_code_short_is_okay, return_code_long_is_okay, 0, 0, f_false, f_console_type_normal, 0), \
+ f_console_parameter_initialize(return_code_short_is_fine, return_code_long_is_fine, 0, 0, f_false, f_console_type_normal, 0), \
f_console_parameter_initialize(return_code_short_is_warning, return_code_long_is_warning, 0, 0, f_false, f_console_type_normal, 0), \
f_console_parameter_initialize(return_code_short_is_error, return_code_long_is_error, 0, 0, f_false, f_console_type_normal, 0), \
+ f_console_parameter_initialize(return_code_short_context, return_code_long_context, 0, 0, f_false, f_console_type_normal, 0), \
}
- #define return_code_total_parameters 7
+ #define return_code_total_parameters 8
#endif // _di_return_code_defines_
#ifndef _di_return_code_data_