I decided to allow --at and --name to be used at the same time (and therefore at the same --depth).
The depth code is to be rewritten and that is only partially rewritten.
Many of the parameters are now written and the fss_basic_read needs to be tested and reviewed.
(There fss_basic_read is still incomplete, but there is enough working code to begin testing.)
if (location.stop < location.start) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
+ if (string[0] == '\0') {
+ return f_status_set_error(f_no_data);
+ }
+
uint8_t width = 0;
uint8_t width_max = 0;
uint8_t mode = 0;
} // for
if (mode == 0) {
- return f_no_data;
+ return f_status_set_error(f_invalid_number);
}
f_string_location location_offset = f_string_location_initialize;
if (location.stop < location.start) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
+ if (string[0] == '\0') {
+ return f_status_set_error(f_no_data);
+ }
+
uint8_t width = 0;
uint8_t width_max = 0;
uint8_t mode = 0;
f_string_length j = 0;
f_string_length offset = 0;
f_status status = f_none;
+ int8_t sign_found = 0;
for (f_string_length i = location.start; i <= location.stop; i++) {
width = f_macro_utf_byte_width_is(string[i]);
break;
}
- // plus sign is not allowed.
if (string[i] == 0x2b) {
- return f_status_set_error(f_invalid_number);
+ offset++;
+ sign_found = 1;
}
- // negative sign is not allowed.
if (string[i] == 0x2d) {
- return f_status_set_error(f_negative_number);
+ offset++;
+ sign_found = -1;
}
if (f_conversion_character_is_decimal(string[i]) == f_true) {
} // for
if (mode == 0) {
- return f_no_data;
+ return f_status_set_error(f_invalid_number);
}
f_string_location location_offset = f_string_location_initialize;
location_offset.stop = location.stop;
if (mode == 10) {
- return f_conversion_string_to_decimal_unsigned(string, number, location_offset);
+ status = f_conversion_string_to_decimal_unsigned(string, number, location_offset);
}
-
- if (mode == 16) {
- return f_conversion_string_to_hexidecimal_unsigned(string, number, location_offset);
+ else if (mode == 16) {
+ status = f_conversion_string_to_hexidecimal_unsigned(string, number, location_offset);
}
-
- if (mode == 12) {
- return f_conversion_string_to_duodecimal_unsigned(string, number, location_offset);
+ else if (mode == 12) {
+ status = f_conversion_string_to_duodecimal_unsigned(string, number, location_offset);
+ }
+ else if (mode == 8) {
+ status = f_conversion_string_to_octal_unsigned(string, number, location_offset);
+ }
+ else {
+ status = f_conversion_string_to_binary_unsigned(string, number, location_offset);
}
- if (mode == 8) {
- return f_conversion_string_to_octal_unsigned(string, number, location_offset);
+ // +/- signs are not allowed.
+ if (sign_found) {
+ if (status == f_none) {
+ if (sign_found == -1) {
+ return f_status_set_error(f_negative_number);
+ }
+
+ return f_status_set_error(f_positive_number);
+ }
+
+ return f_status_set_error(f_invalid_number);
}
- return f_conversion_string_to_binary_unsigned(string, number, location_offset);
+ return status;
}
#endif // _di_f_conversion_string_to_number_unsigned_
*
* @return
* f_none on success.
- * f_no_data is returned if string only contains valid whitespace.
+ * f_no_data (with error bit) if string starts with a null (length is 0).
* f_invalid_parameter (with error bit) if a parameter is invalid.
* f_invalid_number (with error bit) if parameter is not a number.
* f_overflow (with error bit) on integer overflow.
*
* @return
* f_none on success.
- * f_no_data is returned if string only contains valid whitespace.
+ * f_no_data (with error bit) if string starts with a null (length is 0).
* f_invalid_parameter (with error bit) if a parameter is invalid.
* f_invalid_number (with error bit) if parameter is not a number.
* f_negative_number (with error bit) on negative value.
+ * f_positive_number (with error bit) on positive value (has a +, such as '+1', when only '1' is valid here).
* f_overflow (with error bit) on integer overflow.
* f_incomplete_utf (with error bit) if an incomplete UTF-8 fragment is found.
*
status = f_none; \
if (new_length < content_childs.size) { \
f_array_length i = content_childs.size - new_length; \
- for (; i < content_childs.size; ++i) { \
+ for (; i < content_childs.size; i++) { \
f_macro_fss_content_child_delete(status, content_childs.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > content_childs.size) { \
f_array_length i = content_childs.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&content_childs.array[i], 0, sizeof(f_fss_content_child)); \
} \
} \
status = f_none; \
if (new_length < content_childs.size) { \
length_variable i = content_childs.size - new_length; \
- for (; i < content_childs.size; ++i) { \
+ for (; i < content_childs.size; i++) { \
f_macro_fss_content_child_destroy(status, content_childs.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > content_childs.size) { \
length_variable i = content_childs.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&content_childs.array[i], 0, sizeof(f_fss_content_child)); \
} \
} \
status = f_none; \
if (new_length < content_nest.size) { \
f_array_length i = content_nest.size - new_length; \
- for (; i < content_nest.size; ++i) { \
+ for (; i < content_nest.size; i++) { \
f_macro_fss_content_childs_delete(status, content_nest.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > content_nest.size) { \
f_array_length i = content_nest.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&content_nest.array[i], 0, sizeof(f_fss_content_childs)); \
} \
} \
status = f_none; \
if (new_length < content_nest.size) { \
f_array_length i = content_nest.size - new_length; \
- for (; i < content_nest.size; ++i) { \
+ for (; i < content_nest.size; i++) { \
f_macro_fss_content_childs_destroy(status, content_nest.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > content_nest.size) { \
f_array_length i = content_nest.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&content_childs.array[i], 0, sizeof(f_fss_content_child)); \
} \
} \
status = f_none; \
if (new_length < content_nests.size) { \
f_array_length i = content_nests.size - new_length; \
- for (; i < content_nests.size; ++i) { \
+ for (; i < content_nests.size; i++) { \
f_macro_fss_content_nest_delete(status, content_nests.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > content_nests.size) { \
f_array_length i = content_nests.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&content_nests.array[i], 0, sizeof(f_fss_content_nest)); \
} \
} \
status = f_none; \
if (new_length < content_nests.size) { \
f_array_length i = content_nests.size - new_length; \
- for (; i < content_nests.size; ++i) { \
+ for (; i < content_nests.size; i++) { \
f_macro_fss_content_nest_destroy(status, content_nests.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > content_nests.size) { \
f_array_length i = content_nests.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&content_nests.array[i], 0, sizeof(f_fss_content_nest)); \
} \
} \
status = f_none; \
if (new_length < structures.size) { \
length_variable i = structures.size - new_length; \
- for (; i < structures.size; ++i) { \
+ for (; i < structures.size; i++) { \
f_macro_memory_structure_delete(status, structures.array[i], type); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > structures.size) { \
length_variable i = structures.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&structures.array[i], 0, sizeof(type)); \
} \
} \
status = f_none; \
if (new_length < structures.size) { \
length_variable i = structures.size - new_length; \
- for (; i < structures.size; ++i) { \
+ for (; i < structures.size; i++) { \
f_macro_memory_structure_destroy(status, structures.array[i], type); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > structures.size) { \
length_variable i = structures.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&structures.array[i], 0, sizeof(type)); \
} \
} \
f_failure,
f_interrupted, // usually by a signal.
f_loop, // such as infinite recursion.
+ f_incomplete, // incomplete information
#endif // _di_f_status_basic_
#ifndef _di_f_status_invalid_
status = f_none; \
if (new_length < dynamics.size) { \
f_string_length i = dynamics.size - new_length; \
- for (; i < dynamics.size; ++i) { \
+ for (; i < dynamics.size; i++) { \
f_macro_string_dynamic_destroy(status, dynamics.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > dynamics.size) { \
f_string_length i = dynamics.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&dynamics.array[i], 0, sizeof(f_string_dynamic)); \
} \
} \
status = f_none; \
if (new_length < dynamics.size) { \
f_string_length i = dynamics.size - new_length; \
- for (; i < dynamics.size; ++i) { \
+ for (; i < dynamics.size; i++) { \
f_macro_string_dynamic_destroy(status, dynamics.array[i], f_string_dynamic); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > dynamics.size) { \
f_string_length i = dynamics.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&dynamics.array[i], 0, sizeof(f_string_dynamic)); \
} \
} \
status = f_none; \
if (new_length < dynamics.size) { \
f_utf_string_length i = dynamics.size - new_length; \
- for (; i < dynamics.size; ++i) { \
+ for (; i < dynamics.size; i++) { \
f_macro_utf_string_dynamic_destroy(status, dynamics.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > dynamics.size) { \
f_utf_string_length i = dynamics.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&dynamics.array[i], 0, sizeof(f_utf_string_dynamic)); \
} \
} \
status = f_none; \
if (new_length < dynamics.size) { \
f_utf_string_length i = dynamics.size - new_length; \
- for (; i < dynamics.size; ++i) { \
+ for (; i < dynamics.size; i++) { \
f_macro_utf_string_dynamic_destroy(status, dynamics.array[i], f_utf_string_dynamic); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > dynamics.size) { \
f_utf_string_length i = dynamics.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&dynamics.array[i], 0, sizeof(f_utf_string_dynamic)); \
} \
} \
#endif // _di_level_0_parameter_checking_f
if (argument[0] == '\0') {
- return f_no_data;
+ return f_status_set_error(f_no_data);
}
f_string_location location = f_string_location_initialize;
#endif // _di_level_0_parameter_checking_f
if (argument[0] == '\0') {
- return f_no_data;
+ return f_status_set_error(f_no_data);
}
f_string_location location = f_string_location_initialize;
*
* @return
* f_none on success.
- * f_no_data the argument is empty or only contains valid whitespace.
+ * f_no_data (with error bit) if string starts wth a null (length is 0).
* f_invalid_parameter (with error bit) if a parameter is invalid.
* f_invalid_number (with error bit) if parameter is not a number.
* f_overflow (with error bit) on integer overflow.
*
* @return
* f_none on success.
- * f_no_data the argument is empty or only contains valid whitespace.
+ * f_no_data (with error bit) if string starts wth a null (length is 0).
* f_invalid_parameter (with error bit) if a parameter is invalid.
* f_invalid_number (with error bit) if parameter is not a number.
* f_negative_number (with error bit) on negative value.
max_width = buffer.used - location->start;
}
- while (buffer.string[location->start] == f_string_eos || (status = f_utf_is_graph(buffer.string + location->start, max_width)) == f_false) {
+ while (buffer.string[location->start] == f_string_eos || (status = f_utf_is_whitespace(buffer.string + location->start, max_width)) == f_true) {
if (f_status_is_error(status)) {
return status;
}
if (distance > 0) {
while (position < buffer->used + distance && position <= location.stop) {
buffer->string[position] = f_fss_delimit_placeholder;
- ++position;
+ position++;
}
}
// identify where the object ends
if (quoted == f_string_eos) {
status = f_none;
- while (buffer->string[location->start] == f_fss_delimit_placeholder || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ while (buffer->string[location->start] == f_fss_delimit_placeholder || (status = fl_fss_is_space(*buffer, *location)) == f_false) {
status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
-
status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
return fl_fss_found_no_object;
}
-
status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
f_macro_string_lengths_delete(allocation_status, delimits);
}
-
status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
if (buffer->string[location->start] == f_fss_basic_close) break;
- ++location->start;
+ location->start++;
} while (f_true);
// Save the stop length
continue;
}
- else if ((status = fl_fss_is_graph(*buffer, *location)) == f_false) {
+ else if ((status = fl_fss_is_space(*buffer, *location)) == f_true) {
found->stop = location->start - 1;
status = fl_fss_increment_buffer(*buffer, location, 1);
continue;
}
- else if ((status = fl_fss_is_graph(*buffer, *location)) == f_false) {
+ else if ((status = fl_fss_is_space(*buffer, *location)) == f_true) {
found->array[found->used].stop = location->start - 1;
status = fl_fss_increment_buffer(*buffer, location, 1);
return f_none_on_eol;
}
- if (content.string[location->start] != f_fss_delimit_placeholder && (status = fl_fss_is_graph(*buffer, *location)) == f_false) {
+ if (content.string[location->start] != f_fss_delimit_placeholder && (status = fl_fss_is_space(*buffer, *location)) == f_true) {
quoted = f_fss_delimit_double_quote;
pre_allocate_size += 2;
#ifndef _di_fl_macro_fss_skip_past_delimit_placeholders_
#define fl_macro_fss_skip_past_delimit_placeholders(buffer, location) \
while (buffer.string[location.start] == f_fss_delimit_placeholder) { \
- ++location.start;\
+ location.start++;\
\
if (location.start >= buffer.used) break; \
if (location.start > location.stop) break; \
#ifndef _di_fl_macro_fss_object_seek_till_newline_
#define fl_macro_fss_object_seek_till_newline(buffer, location, delimits, eos_status, stop_status) \
while (buffer.string[location.start] != f_string_eol) { \
- ++location.start; \
+ location.start++; \
if (location.start >= buffer.used) { \
f_status macro_allocation_status = f_none; \
f_macro_string_lengths_delete(macro_allocation_status, delimits); \
#ifndef _di_fl_macro_fss_object_delimited_seek_till_newline_
#define fl_macro_fss_object_delimited_seek_till_newline(buffer, location, delimits, eos_status, stop_status) \
while (buffer.string[location.start] != f_string_eol) { \
- ++location.start; \
+ location.start++; \
if (location.start >= buffer.used) { \
f_status macro_allocation_status = f_none; \
f_string_length i = 0; \
#ifndef _di_fl_macro_fss_content_seek_till_newline_
#define fl_macro_fss_content_seek_till_newline(buffer, location, found, delimits, eos_status, stop_status) \
while (buffer.string[location.start] != f_string_eol) { \
- ++location.start; \
+ location.start++; \
if (location.start >= buffer.used) { \
f_status macro_allocation_status = f_none; \
f_macro_string_lengths_delete(macro_allocation_status, delimits); \
#ifndef _di_fl_macro_fss_content_delimited_seek_till_newline_
#define fl_macro_fss_content_delimited_seek_till_newline(buffer, location, found, delimits, eos_status, stop_status) \
while (buffer.string[location.start] != f_string_eol) { \
- ++location.start; \
+ location.start++; \
if (location.start >= buffer.used) { \
f_status macro_allocation_status = f_none; \
f_string_length i = 0; \
case f_loop:
*string = fl_status_string_loop;
break;
+ case f_incomplete:
+ *string = fl_status_string_incomplete;
+ break;
#endif // _di_fl_status_basic_
#ifdef _di_fl_status_invalid_
#define fl_status_string_loop "f_loop"
#define fl_status_string_loop_length 7
+
+ #define fl_status_string_incomplete "f_incomplete"
+ #define fl_status_string_incomplete_length 13
#endif // _di_fl_status_basic_
#ifndef _di_fl_status_invalid_
if (status == fl_fss_found_object) {
found_data = f_true;
- status = fl_fss_basic_content_read(buffer, input, &contents->array[contents->used]);
+ status = fl_fss_basic_content_read(buffer, input, &contents->array[contents->used]);
break;
}
}
else if (status == f_no_data_on_eos || status == f_no_data_on_stop) {
- // if at least some valid object was found, then return f_none equivelents
+ // If at least some valid object was found, then return f_none equivelents.
if (objects->used > initial_used) {
if (status == f_no_data_on_eos) return f_none_on_eos;
if (status == f_no_data_on_stop) return f_none_on_stop;
else if (status != fl_fss_found_object && status != fl_fss_found_content && status != fl_fss_found_no_content && status != fl_fss_found_object_no_content) {
return status;
}
- // when content is found, the input->start is incremented, if content is found at input->stop, then input->start will be > input.stop
+ // When content is found, the input->start is incremented, if content is found at input->stop, then input->start will be > input.stop.
else if (input->start >= input->stop || input->start >= buffer->used) {
if (status == fl_fss_found_object || status == fl_fss_found_content || status == fl_fss_found_no_content || status == fl_fss_found_object_no_content) {
objects->used++;
objects->used++;
contents->used++;
- } while (f_true);
+ } while (input->start < f_string_max_size);
- return f_unknown;
+ return f_overflow;
}
#endif // _di_fll_fss_basic_read_
* f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
* f_reallocation_error (with error bit) on reallocation error.
* f_invalid_parameter (with error bit) if a parameter is invalid.
- * f_unknown (with error bit) if a (what should be) impossible execution point is reached.
+ * f_overflow (with error bit) if the maximimum buffer size is reached.
*/
#ifndef _di_fll_fss_basic_read_
extern f_return_status fll_fss_basic_read(f_string_dynamic *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents);
objects->used++;
contents->used++;
- } while (f_true);
+ } while (input->start < f_string_max_size);
- return f_status_is_error(f_unknown);
+ return f_status_is_error(f_overflow);
}
#endif // _di_fll_fss_basic_list_read_
* f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
* f_reallocation_error (with error bit) on reallocation error.
* f_invalid_parameter (with error bit) if a parameter is invalid.
- * f_unknown (with error bit) if a (what should be) impossible execution point is reached.
+ * f_overflow (with error bit) if the maximimum buffer size is reached.
*/
#ifndef _di_fll_fss_basic_list_read_
extern f_return_status fll_fss_basic_list_read(f_string_dynamic *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents);
objects->used++;
contents->used++;
- } while (f_true);
+ } while (input->start < f_string_max_size);
- return f_status_is_error(f_unknown);
+ return f_status_is_error(f_overflow);
}
#endif // _di_fll_fss_extended_read_
* f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
* f_reallocation_error (with error bit) on reallocation error.
* f_invalid_parameter (with error bit) if a parameter is invalid.
- * f_unknown (with error bit) if a (what should be) impossible execution point is reached.
+ * f_overflow (with error bit) if the maximimum buffer size is reached.
*/
#ifndef _di_fll_fss_extended_read_
extern f_return_status fll_fss_extended_read(f_string_dynamic *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents);
objects->used++;
contents->used++;
- } while (f_true);
+ } while (input->start < f_string_max_size);
- return f_status_is_error(f_unknown);
+ return f_status_is_error(f_overflow);
}
#endif // _di_fll_fss_extended_list_read_
* f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
* f_reallocation_error (with error bit) on reallocation error.
* f_invalid_parameter (with error bit) if a parameter is invalid.
- * f_unknown (with error bit) if a (what should be) impossible execution point is reached.
+ * f_overflow (with error bit) if the maximimum buffer size is reached.
*/
#ifndef _di_fll_fss_extended_list_read_
extern f_return_status fll_fss_extended_list_read(f_string_dynamic *buffer, f_string_location *input, f_fss_objects *objects, f_fss_content_nests *contents);
fl_macro_color_context_new(allocation_status, (*context));
if (f_status_is_error(allocation_status)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory.\n");
+ fprintf(f_standard_error, "CRITICAL ERROR: Unable to allocate memory.\n");
return allocation_status;
}
// nothing can be 0 as that represents the program name, unless argv[] is improperly created
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, context->error, context->reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, context->error, context->reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else if (status == f_invalid_utf) {
- fl_color_print_line(f_standard_error, context->error, context->reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling fl_console_parameter_process().");
+ fl_color_print(f_standard_error, context->error, context->reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling ");
+ fl_color_print(f_standard_error, context->notable, context->reset, "fl_console_parameter_process()");
+ fl_color_print_line(f_standard_error, context->error, context->reset, ".");
}
else if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, context->error, context->reset, "INTERNAL ERROR: Invalid parameter when calling fl_console_parameter_process().");
+ fl_color_print(f_standard_error, context->error, context->reset, "INTERNAL ERROR: Invalid parameter when calling ");
+ fl_color_print(f_standard_error, context->notable, context->reset, "fl_console_parameter_process()");
+ fl_color_print_line(f_standard_error, context->error, context->reset, ".");
}
else {
- fl_color_print_line(f_standard_error, context->error, context->reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_console_parameter_process().", status);
+ fl_color_print(f_standard_error, context->error, context->reset, "INTERNAL ERROR: An unhandled error (");
+ fl_color_print(f_standard_error, context->notable, context->reset, "%u", status);
+ fl_color_print(f_standard_error, context->error, context->reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, context->notable, context->reset, "fl_console_parameter_process()");
+ fl_color_print_line(f_standard_error, context->error, context->reset, ".");
}
return f_status_set_error(status);
*code = f_loop;
return f_none;
}
+
+ if (fl_string_compare(string, fl_status_string_incomplete, length, fl_status_string_incomplete_length) == f_equal_to) {
+ *code = f_incomplete;
+ return f_none;
+ }
#endif // _di_fll_status_basic_
#ifndef _di_fll_status_invalid_
}
if (error == f_out_of_memory) {
- fl_color_print(f_standard_error, context.error, context.reset, "CRITICAL ERROR: unable to allocate memory, while trying to access file '");
+ fl_color_print(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to access file '");
fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
return;
f_macro_string_dynamics_resize(status, parameters, 7);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_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;
status = f_status_set_fine(status);
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables);
status = f_status_set_fine(status);
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_no_data) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: could not find any network devices");
f_macro_string_dynamic_resize(status, file_path, network_path_length + data->devices.array[i].used + firewall_file_suffix_length + 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_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;
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%.*s'", file_path.used, file_path.string);
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
+ fl_color_print_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_file_not_found) {
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%.*s'", file_path.used, file_path.string);
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", status);
}
status = f_status_set_error(status);
// empty files are to be silently ignored
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_read() for the file '%.*s'", f_status_set_error(status), file_path.used, file_path.string);
+ fl_color_print_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.used, file_path.string);
}
status = f_status_set_error(status);
}
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory");
f_macro_string_dynamic_delete(status2, ip_list_action);
}
f_macro_string_dynamic_new(status, ip_argument, ip_length);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory");
break;
}
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", status);
}
f_macro_string_dynamics_delete(status2, arguments);
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()");
}
else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", status);
}
return status;
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()");
}
else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", status);
}
return status;
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()");
}
else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_execute_program()", status);
}
return status;
fl_color_print_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_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", status);
}
} else {
if (status == f_invalid_parameter) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_status_set_error(status));
+ fl_color_print_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_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'.", filename);
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read().", status);
}
return status;
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: No relevant data was found within the file '%s'.", filename);
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", f_status_set_error(status), filename);
+ fl_color_print_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);
}
return status;
status = f_status_set_fine(status);
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_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_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", status);
}
f_macro_fss_objects_delete(status2, local->rule_objects);
(structure.array[index].stop - structure.array[index].start) + 1
// TODO: temporarily added, convert this to a function below.
-// TODO: also report: fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory");
+// TODO: also report: fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory");
#define firewall_macro_append_argument_to_arguments(status, arguments, argument) \
if (arguments.used >= arguments.size) { \
f_macro_string_dynamics_resize(status, arguments, arguments.used + firewall_default_allocation_step); \
* This is the FSS Basic List Read program
* This program utilizes the Featureless Linux Library.
* This program processes files or other input in fss format and stores the results in the fss_basic_list_read_data.
+ *
+ * This processes in accordance to the FSS-0002 Basic List specification.
*/
#ifndef _fss_basic_list_read_h
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
macro_fss_basic_list_read_depths_new(status, (*depths), data.parameters[fss_basic_list_read_parameter_depth].locations.used);
if (f_status_is_error(status)) {
f_status status2 = f_none;
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
macro_fss_basic_list_read_depths_delete(status2, (*depths));
return f_status_set_error(f_invalid_parameter);
macro_fss_basic_list_read_depths_new(status, (*depths), 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
return f_status_set_error(f_invalid_parameter);
}
else if (data.parameters[fss_basic_list_read_parameter_name].result == f_console_result_additional) {
macro_fss_basic_list_read_depths_new(status, (*depths), 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
return f_status_set_error(f_invalid_parameter);
}
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_incomplete_utf_on_stop) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
}
else {
- fl_color_print_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_status_set_error(status), filename);
+ fl_color_print_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);
}
fss_basic_list_read_delete_data(data);
#define fss_basic_list_read_depth_initialize \
{ \
0, \
- f_array_length_initialize, \
- f_array_length_initialize, \
+ 0, \
+ 0, \
}
#endif // _di_fss_basic_list_read_depth_
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
f_status status2 = f_none;
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
fss_basic_list_write_delete_data(data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
}
fss_basic_list_write_delete_data(data);
fll_program_print_help_option(data.context, fss_basic_read_short_name, fss_basic_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name.");
fll_program_print_help_option(data.context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content.");
fll_program_print_help_option(data.context, fss_basic_read_short_select, fss_basic_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select sub-content at this index.");
- fll_program_print_help_option(data.context, fss_basic_read_short_total, fss_basic_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of objects.");
+ fll_program_print_help_option(data.context, fss_basic_read_short_total, fss_basic_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of lines.");
fll_program_print_help_usage(data.context, fss_basic_read_name, "filename(s)");
printf("%c", f_string_eol);
printf(" Specify both ");
- fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_total);
+ fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_object);
printf(" and the ");
fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_line);
- printf(" parameters to get the total lines.%c", f_string_eol);
+ printf(" parameters to get the total objects.%c", f_string_eol);
printf("%c", f_string_eol);
fll_program_print_version(fss_basic_read_version);
}
else if (data->remaining.used > 0 || data->process_pipe) {
+ if (data->parameters[fss_basic_read_parameter_at].result == f_console_result_found) {
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '");
+ fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_at);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
+
+ return f_status_set_error(f_invalid_parameter);
+ }
+
+ if (data->parameters[fss_basic_read_parameter_depth].result == f_console_result_found) {
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '");
+ fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_depth);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
+
+ return f_status_set_error(f_invalid_parameter);
+ }
+
+ if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_found) {
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '");
+ fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_line);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
+
+ return f_status_set_error(f_invalid_parameter);
+ }
+
+ if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_found) {
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '");
+ fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_name);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a string.");
+
+ return f_status_set_error(f_invalid_parameter);
+ }
+
+ if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_found) {
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: The parameter '");
+ fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_select);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' requires a positive number.");
+
+ return f_status_set_error(f_invalid_parameter);
+ }
+
if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_found) {
- if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_found) {
+ if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_object);
fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '");
}
}
+ if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
+ if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '");
+ fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_line);
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameter with the '");
+ fl_color_print(f_standard_error, data->context.notable, data->context.reset, "--%s", fss_basic_read_long_total);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' parameter.");
+
+ return f_status_set_error(f_invalid_parameter);
+ }
+ }
+
fss_basic_read_depths depths = fss_basic_read_depths_initialize;
f_status status2 = f_none;
* This is the FSS Basic Read program
* This program utilizes the Featureless Linux Library.
* This program processes files or other input in fss format and stores the results in the fss_basic_read_data.
+ *
+ * This processes in accordance to the FSS-0000 Basic specification.
*/
#ifndef _fss_basic_read_h
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print_line(f_standard_error, context.error, context.reset, ".");
}
else if (status == f_invalid_number) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: the argument '");
+ fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '");
fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument);
fl_color_print(f_standard_error, context.error, context.reset, "' is not a valid number for the parameter '");
fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
}
else if (status == f_underflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: the argument '");
+ fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '");
fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument);
fl_color_print(f_standard_error, context.error, context.reset, "' is too small for the parameter '");
fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
}
else if (status == f_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: the argument '");
+ fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '");
fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument);
fl_color_print(f_standard_error, context.error, context.reset, "' is too large for the parameter '");
fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
}
else if (status == f_negative_number) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: the argument '");
+ fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '");
fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument);
fl_color_print(f_standard_error, context.error, context.reset, "' is negative, which is not allowed for the parameter '");
fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
}
+ else if (status == f_positive_number) {
+ fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The argument '");
+ fl_color_print(f_standard_error, context.notable, context.reset, "%s", argument);
+ fl_color_print(f_standard_error, context.error, context.reset, "' contains a '");
+ fl_color_print(f_standard_error, context.notable, context.reset, "+");
+ fl_color_print(f_standard_error, context.error, context.reset, "', which is not allowed for the parameter '");
+ fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
+ fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
+ }
+ else if (status == f_no_data) {
+ fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The parameter '");
+ fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
+ fl_color_print_line(f_standard_error, context.error, context.reset, "' must not be an empty string.");
+ }
else {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, context.notable, context.reset, "%u", status);
f_return_status fss_basic_read_main_preprocess_depth(const f_console_arguments arguments, const fss_basic_read_data data, fss_basic_read_depths *depths) {
f_status status = f_none;
- // pre-process the depth and depth-sensitive parameters.
- if (data.parameters[fss_basic_read_parameter_depth].result == f_console_result_additional) {
- macro_fss_basic_read_depths_new(status, (*depths), data.parameters[fss_basic_read_parameter_depth].locations.used);
- if (f_status_is_error(status)) {
- f_status status2 = f_none;
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
-
- macro_fss_basic_read_depths_delete(status2, (*depths));
- return f_status_set_error(f_invalid_parameter);
- }
-
- f_array_length depth_position = data.parameters[fss_basic_read_parameter_depth].additional.array[0];
- f_array_length at_index = 0;
- f_array_length name_index = 0;
+ macro_fss_basic_read_depths_new(status, (*depths), 1);
+ if (f_status_is_error(status)) {
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
+ return status;
+ }
- depths->array[0].depth = (f_string_length) atoll(arguments.argv[depth_position]);
- depths->array[0].parameter = 0;
- depths->array[0].position = 0;
- depths->used = 1;
+ depths->array[0].depth = 0;
+ depths->array[0].index_at = 0;
+ depths->array[0].index_name = 0;
+ depths->array[0].value_at = 0;
+ depths->array[0].value_name = f_string_eos;
+ depths->used = 1;
- f_string_length depth_previous = depths->array[0].depth;
- f_string_length depth_current = depths->array[0].depth;
+ // @todo: walk through all depth parameters and build the loop, get and validate all --at and --name parameters on a per depth basis.
+ if (data.parameters[fss_basic_read_parameter_depth].result == f_console_result_additional) {
+ f_array_length depth_position = data.parameters[fss_basic_read_parameter_depth].additional.array[data.parameters[fss_basic_read_parameter_depth].additional.used - 1];
- if (data.parameters[fss_basic_read_parameter_at].result == f_console_result_additional) {
- for (; at_index < data.parameters[fss_basic_read_parameter_at].additional.used; at_index++) {
- if (data.parameters[fss_basic_read_parameter_at].additional.array[at_index] > depth_position) {
- if (data.parameters[fss_basic_read_parameter_depth].additional.used > 1) {
- if (data.parameters[fss_basic_read_parameter_at].additional.array[at_index] > data.parameters[fss_basic_read_parameter_depth].additional.array[1]) {
- break;
- }
- }
-
- depths->array[0].parameter = fss_basic_read_parameter_at;
- }
- } // for
- }
+ status = fl_console_parameter_to_number_unsigned(arguments.argv[depth_position], &depths->array[0].depth);
- if (data.parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
- for (; name_index < data.parameters[fss_basic_read_parameter_name].additional.used; name_index++) {
- if (data.parameters[fss_basic_read_parameter_name].additional.array[name_index] > depth_position) {
- if (data.parameters[fss_basic_read_parameter_depth].additional.used > 1) {
- if (data.parameters[fss_basic_read_parameter_name].additional.array[name_index] > data.parameters[fss_basic_read_parameter_depth].additional.array[1]) {
- break;
- }
- }
-
- if (depths->array[0].parameter == fss_basic_read_parameter_at) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: The '--%s' and '--%s' parameters cannot be specified at the same time (specified for depth '%llu').", fss_basic_read_long_at, fss_basic_read_long_name, depth_current);
- return f_status_set_error(f_invalid_parameter);
- }
-
- depths->array[0].parameter = fss_basic_read_parameter_name;
- }
- } // for
+ if (f_status_is_error(status)) {
+ fss_basic_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_basic_read_long_depth, arguments.argv[depth_position], f_status_set_fine(status));
+ return status;
}
-
- for (f_array_length i = 1; i < data.parameters[fss_basic_read_parameter_depth].locations.used; i++) {
- depth_position = data.parameters[fss_basic_read_parameter_depth].additional.array[i];
- depth_current = (f_string_length) atoll(arguments.argv[depth_position]);
-
- if (depth_current > depth_previous) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: The depth '%llu' cannot be specified before the depth '%llu'.", depth_previous, depth_current);
- return f_status_set_error(f_invalid_parameter);
- }
-
- if (depth_current == depth_previous) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: The depth '%llu' cannot be the same as the depth '%llu'.", depth_previous, depth_current);
- return f_status_set_error(f_invalid_parameter);
- }
-
- if (data.parameters[fss_basic_read_parameter_at].result == f_console_result_additional) {
- for (; at_index < data.parameters[fss_basic_read_parameter_at].additional.used; at_index++) {
- if (data.parameters[fss_basic_read_parameter_at].additional.array[at_index] > depth_position) {
- if (data.parameters[fss_basic_read_parameter_depth].additional.used > 1) {
- if (data.parameters[fss_basic_read_parameter_at].additional.array[at_index] > data.parameters[fss_basic_read_parameter_depth].additional.array[i+1]) {
- break;
- }
- }
-
- depths->array[i].parameter = fss_basic_read_parameter_at;
- depths->array[i].position = data.parameters[fss_basic_read_parameter_at].additional.array[i];
- }
- } // for
- }
-
- if (data.parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
- for (; name_index < data.parameters[fss_basic_read_parameter_name].additional.used; name_index++) {
- if (data.parameters[fss_basic_read_parameter_name].additional.array[name_index] > depth_position) {
- if (data.parameters[fss_basic_read_parameter_depth].additional.used > 1) {
- if (data.parameters[fss_basic_read_parameter_name].additional.array[name_index] > data.parameters[fss_basic_read_parameter_depth].additional.array[i+1]) {
- break;
- }
- }
-
- if (depths->array[i].parameter == fss_basic_read_parameter_at) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: The '--%s' and '--%s' parameters cannot be specified at the same time (specified for depth '%llu').", fss_basic_read_long_at, fss_basic_read_long_name, depth_current);
- return f_status_set_error(f_invalid_parameter);
- }
-
- depths->array[i].parameter = fss_basic_read_parameter_name;
- depths->array[i].position = data.parameters[fss_basic_read_parameter_name].additional.array[i];
- }
- } // for
- }
-
- depths->array[i].depth = (f_string_length) atoll(arguments.argv[depth_position]);
- depths->used++;
- } // for
}
- // when no depth parameter is specified, provide a implicit depth of 0 when depth-sensitive parameters are in use.
else {
+ // @todo: walk though each --at and --name parameter, validating them (consider warning for multiple values because only the last one will be used).
if (data.parameters[fss_basic_read_parameter_at].result == f_console_result_additional) {
- if (data.parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: The '%s' and '%s' parameters must not be specified at the same time.", fss_basic_read_long_name, fss_basic_read_long_object);
- return f_status_set_error(f_invalid_parameter);
- }
+ depths->array[0].index_at = data.parameters[fss_basic_read_parameter_at].additional.array[data.parameters[fss_basic_read_parameter_at].additional.used - 1];
+
+ status = fl_console_parameter_to_number_unsigned(arguments.argv[depths->array[0].index_at], &depths->array[0].value_at);
- macro_fss_basic_read_depths_new(status, (*depths), 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
- return f_status_set_error(f_invalid_parameter);
+ fss_basic_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_basic_read_long_at, arguments.argv[depths->array[0].index_at], f_status_set_fine(status));
+ return status;
}
-
- depths->array[0].depth = (f_string_length) atoll(arguments.argv[data.parameters[fss_basic_read_parameter_depth].additional.array[0]]);
- depths->array[0].parameter = fss_basic_read_parameter_at;
- depths->array[0].position = 0;
- depths->used = 1;
}
- else if (data.parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
+
+ if (data.parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
macro_fss_basic_read_depths_new(status, (*depths), 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
- return f_status_set_error(f_invalid_parameter);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
+ return status;
}
- depths->array[0].depth = (f_string_length) atoll(arguments.argv[data.parameters[fss_basic_read_parameter_depth].additional.array[0]]);
- depths->array[0].parameter = fss_basic_read_parameter_name;
- depths->array[0].position = 0;
- depths->used = 1;
+ depths->array[0].index_name = data.parameters[fss_basic_read_parameter_name].additional.array[data.parameters[fss_basic_read_parameter_name].additional.used - 1];
+ depths->array[0].value_name = arguments.argv[depths->array[0].index_name];
+
+ if (depths->array[0].value_name[0] == '\0') {
+ fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The '");
+ fl_color_print(f_standard_error, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_name);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' must not be an empty string.");
+
+ return f_status_set_error(f_invalid_parameter);
+ }
}
}
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_incomplete_utf_on_stop) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
}
else {
- fl_color_print_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_status_set_error(status), filename);
+ fl_color_print_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);
}
return f_status_set_error(status);
}
}
- // depth is always 0 in this standard, so when specifying --total with --object, just print the total of all.
- if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
- if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
- fprintf(f_standard_output, "%llu%c", data->objects.used, f_string_eol);
- return f_none;
- }
- }
-
f_string_length select = 0;
+
if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_basic_read_parameter_select].additional.array[0]], &select);
+ status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_basic_read_parameter_select].additional.array[data->parameters[fss_basic_read_parameter_select].additional.used - 1]], &select);
if (f_status_is_error(status)) {
fss_basic_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_basic_read_long_select, arguments.argv[data->parameters[fss_basic_read_parameter_select].additional.array[0]], f_status_set_fine(status));
return status;
}
- // this standard does not support multiple content groups, so a select value of anything other than 0 should return nothing.
+ // this standard does not support multiple content groups.
if (select > 0) {
return f_none;
}
}
- // now that the file has been read, process the objects and contents.
- if (depths.used > 0 && depths.array[0].parameter == fss_basic_read_parameter_name) {
- /*
- // @todo: this if-block is not updated.
- // @todo: printing conditions need to handle --line as well as --relative.
- // @todo: when --total is specified, process it here (and --relative will matter).
- f_string_length total = 0;
+ f_string_length line = 0;
+
+ if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
+ status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_basic_read_parameter_line].additional.array[data->parameters[fss_basic_read_parameter_line].additional.used - 1]], &line);
+
+ if (f_status_is_error(status)) {
+ fss_basic_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_basic_read_long_line, arguments.argv[data->parameters[fss_basic_read_parameter_line].additional.array[0]], f_status_set_fine(status));
+ return status;
+ }
+ }
+
+ bool names[data->objects.used];
+
+ if (depths.array[0].index_name > 0) {
+ memset(names, 0, sizeof(bool) * data->objects.used);
+
+ f_string_length argv_length = strlen(depths.array[0].value_name);
f_string_length name_length = 0;
- f_string_length argv_length = 0;
- f_string_length found = 0;
- if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_additional) {
- argv_length = strlen(arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]]);
+ for (f_string_length i = 0; i < data->objects.used; i++) {
+ name_length = data->objects.array[i].stop - data->objects.array[i].start + 1;
+
+ if (name_length == argv_length) {
+ if (fl_string_compare(data->buffer.string + data->objects.array[i].start, depths.array[0].value_name, name_length, argv_length) == f_equal_to) {
+ names[i] = 1;
+ }
+ }
+ } // for
+ }
+ else {
+ memset(names, 1, sizeof(bool) * data->objects.used);
+ }
+
+ if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_found) {
+ if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
+ if (depths.array[0].index_at > 0) {
+ if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) {
+ fprintf(f_standard_output, "1%c", f_string_eol);
+ }
+ else {
+ fprintf(f_standard_output, "0%c", f_string_eol);
+ }
+ }
+ else if (depths.array[0].index_name > 0) {
+ f_string_length total = 0;
- if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
for (f_string_length i = 0; i < data->objects.used; i++) {
- name_length = data->objects.array[i].stop - data->objects.array[i].start + 1;
-
- if (name_length == argv_length) {
- if (fl_string_compare(data->buffer.string + data->objects.array[i].start, arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
-
- if (data->parameters[fss_basic_read_parameter_at].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_at].result == f_console_result_additional && found == target)) {
- if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
- total++;
- }
- else {
- if (data->contents.array[i].used > 0) {
- f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]);
- fprintf(f_standard_output, "%c", f_string_eol);
- }
- else {
- // for all objects with no data, print a newline.
- fprintf(f_standard_output, "%c", f_string_eol);
- }
- }
- }
-
- if (data->parameters[fss_basic_read_parameter_at].result == f_console_result_additional) {
- if (found == target) {
- break;
- }
- else {
- found++;
- }
- }
- }
- }
+ if (names[i] == 0) continue;
+
+ total++;
} // for
- if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_at].result == f_console_result_none) {
- fprintf(f_standard_output, f_string_length_printf "%s%c", total, f_string_eol);
- }
+ fprintf(f_standard_output, "%llu%c", total, f_string_eol);
}
else {
- // when and because the object parameter is specified, the name parameter refers to the content instead of the object.
- // therefore, make the search on the content and display the object.
- for (f_string_length i = 0; i < data->contents.used; i++) {
- if (data->contents.array[i].used > 0) {
- name_length = data->contents.array[i].array[0].stop - data->contents.array[i].array[0].start + 1;
-
- if (name_length == argv_length) {
- if (fl_string_compare(data->buffer.string + data->contents.array[i].array[0].start, arguments.argv[data->parameters[fss_basic_read_parameter_name].additional.array[0]], name_length, argv_length) == f_equal_to) {
- if (data->parameters[fss_basic_read_parameter_at].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_at].result == f_console_result_additional && found == target)) {
- f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]);
- fprintf(f_standard_output, "%c", f_string_eol);
- }
-
- if (data->parameters[fss_basic_read_parameter_at].result == f_console_result_additional) {
- if (found == target) {
- break;
- }
- else {
- found++;
- }
- }
- }
- }
- }
- } // for
+ fprintf(f_standard_output, "%llu%c", data->objects.used, f_string_eol);
}
+
+ return f_none;
}
-*/
+
+ if (depths.array[0].index_at > 0) {
+ if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) {
+ f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[depths.array[0].value_at]);
+ fprintf(f_standard_output, "%c", f_string_eol);
+ }
+
+ return f_none;
+ }
+
+ for (f_string_length i = 0; i < data->objects.used; i++) {
+ if (names[i] == 0) continue;
+
+ f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]);
+ fprintf(f_standard_output, "%c", f_string_eol);
+ } // for
+
return f_none;
}
- if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
- if (depths.used > 0 && depths.array[0].parameter == fss_basic_read_parameter_at) {
- f_string_length target = (f_string_length) atoll(arguments.argv[depths.array[0].position]);
-
- if (target >= data->objects.used) {
- if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_additional) {
+ if (depths.array[0].index_at > 0) {
+ if (names[depths.array[0].value_at]) {
+ if (depths.array[0].value_at >= data->objects.used) {
+ if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
fprintf(f_standard_output, "0%c", f_string_eol);
}
return f_none;
}
-
- if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
- if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_additional) {
- f_string_length total = 0;
-
- for (f_string_length i = data->contents.array[target].array[0].start; i < data->contents.array[target].array[0].stop; i++) {
- if (data->buffer.string[i] == f_string_eol) {
- total++;
- }
- } // for
-
- fprintf(f_standard_output, "%llu%c", total, f_string_eol);
+ else if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
+ if (data->contents.array[depths.array[0].value_at].used == 0) {
+ fprintf(f_standard_output, "0%c", f_string_eol);
}
else {
- f_string_length line = (f_string_length) atoll(arguments.argv[data->parameters[fss_basic_read_parameter_line].additional.array[0]]);
- f_string_length total = 0;
- f_string_location line_position = f_string_location_initialize;
-
- line_position.start = data->contents.array[target].array[0].start;
- for (f_string_length i = line_position.start; i <= data->contents.array[target].array[0].stop; i++) {
- if (data->buffer.string[i] == f_string_eol) {
- total++;
-
- if (total == line) {
- if (i != line_position.start) {
- line_position.stop = i - 1;
-
- f_print_string_dynamic_partial(f_standard_output, data->buffer, line_position);
- }
-
- fprintf(f_standard_output, "%c", f_string_eol);
- break;
- }
- }
- } // for
+ fprintf(f_standard_output, "1%c", f_string_eol);
}
return f_none;
}
- f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[target].array[0]);
+ if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
+ if (data->contents.array[depths.array[0].value_at].used > 0 && line == 0) {
+ f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[0]);
+ fprintf(f_standard_output, "%c", f_string_eol);
+ }
- // newline is printed even when there is no content for this object.
- fprintf(f_standard_output, "%c", f_string_eol);
+ return f_none;
+ }
- return f_none;
+ if (data->contents.array[depths.array[0].value_at].used > 0) {
+ f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[0]);
+ fprintf(f_standard_output, "%c", f_string_eol);
+ }
}
+ return f_none;
+ }
+
+ if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
+ f_string_length total = 0;
+
for (f_string_length i = 0; i < data->objects.used; i++) {
- if (data->contents.array[i].used > 0) {
- f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]);
- }
+ if (names[i] == 0 || data->contents.array[i].used == 0) continue;
- // newline is printed even when there is no content for this object.
- fprintf(f_standard_output, "%c", f_string_eol);
+ total++;
} // for
+ fprintf(f_standard_output, "%llu%c", total, f_string_eol);
return f_none;
}
- if (depths.used > 0 && depths.array[0].parameter == fss_basic_read_parameter_at) {
- f_string_length target = (f_string_length) atoll(arguments.argv[depths.array[0].position]);
+ if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
+ f_string_length line_current = 0;
- f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[target]);
+ for (f_string_length i = 0; i < data->contents.used; i++) {
+ if (names[i] == 0 || data->contents.array[i].used == 0) continue;
- // newline is printed even when there is no content for this object.
- fprintf(f_standard_output, "%c", f_string_eol);
+ if (line_current == line) {
+ f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]);
+ fprintf(f_standard_output, "%c", f_string_eol);
+
+ break;
+ }
+
+ line_current++;
+ } // for
return f_none;
}
- // @todo: when --total is specified, process it here (and --relative will matter) for standards that support nesting (also handle other nesting state changes here).
- for (f_string_length i = 0; i < data->objects.used; i++) {
- f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]);
+ for (f_string_length i = 0; i < data->contents.used; i++) {
+ if (!names[i] || data->contents.array[i].used == 0) continue;
- // newline is printed for all objects.
+ f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]);
fprintf(f_standard_output, "%c", f_string_eol);
} // for
typedef struct {
f_string_length depth;
- f_array_length parameter;
- f_array_length position;
+ f_array_length index_at;
+ f_array_length index_name;
+
+ f_number_unsigned value_at;
+ f_string value_name;
} fss_basic_read_depth;
#define fss_basic_read_depth_initialize \
{ \
0, \
- f_array_length_initialize, \
- f_array_length_initialize, \
+ 0, \
+ 0, \
+ 0, \
+ f_string_initialize, \
}
#endif // _di_fss_basic_read_depth_
#define macro_fss_basic_read_depths_clear(depths) f_macro_memory_structure_clear(depths)
- #define macro_fss_basic_read_depths_new(status, depths, length) f_macro_memory_structure_new(status, depths, fss_basic_read_depths, length)
+ #define macro_fss_basic_read_depths_new(status, depths, length) f_macro_memory_structure_new(status, depths, fss_basic_read_depth, length)
- #define macro_fss_basic_read_depths_delete(status, depths) f_macro_memory_structure_delete(status, depths, fss_basic_read_depths)
- #define macro_fss_basic_read_depths_destroy(status, depths) f_macro_memory_structure_destroy(status, depths, fss_basic_read_depths)
+ #define macro_fss_basic_read_depths_delete(status, depths) f_macro_memory_structure_delete(status, depths, fss_basic_read_depth)
+ #define macro_fss_basic_read_depths_destroy(status, depths) f_macro_memory_structure_destroy(status, depths, fss_basic_read_depth)
- #define macro_fss_basic_read_depths_resize(status, depths, new_length) f_macro_memory_structure_resize(status, depths, fss_basic_read_depths, new_length)
- #define macro_fss_basic_read_depths_adjust(status, depths, new_length) f_macro_memory_structure_adjust(status, depths, fss_basic_read_depths, new_length)
+ #define macro_fss_basic_read_depths_resize(status, depths, new_length) f_macro_memory_structure_resize(status, depths, fss_basic_read_depth, new_length)
+ #define macro_fss_basic_read_depths_adjust(status, depths, new_length) f_macro_memory_structure_adjust(status, depths, fss_basic_read_depth, new_length)
#endif // _di_fss_basic_read_depths_
/**
/**
* Pre-process the parameters, parsing out and handling the depth and depth related parameters.
*
+ * Will handle depth-sensitive parameter conflicts, such as --name being used with --at (which is not allowed).
+ *
* @param arguments
* The console arguments to pre-process.
* @param data
- * The Program specific data.
+ * The program specific data.
* @param depths
* This stores the pre-processed depth parameters.
*
extern f_return_status fss_basic_read_main_preprocess_depth(const f_console_arguments arguments, const fss_basic_read_data data, fss_basic_read_depths *depths) f_gcc_attribute_visibility_internal;
#endif // _di_fss_basic_read_main_preprocess_depth_
+/**
+ * Process a given file.
+ *
+ * @param arguments
+ * The console arguments passed to the program.
+ * @param data
+ * The program specific data.
+ * @param file_name
+ * The name of the file being processed.
+ * @param depths
+ * The processed depth parameters.
+ *
+ * @see fss_basic_read_main_preprocess_depth()
+ */
#ifndef _di_fss_basic_read_main_process_file_
- extern f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string filename, const fss_basic_read_depths depths) f_gcc_attribute_visibility_internal;
+ extern f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string file_name, const fss_basic_read_depths depths) f_gcc_attribute_visibility_internal;
#endif // _di_fss_basic_read_main_process_file_
#ifdef __cplusplus
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
f_status status2 = f_none;
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
fss_basic_write_delete_data(data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
}
fss_basic_write_delete_data(data);
* This is the FSS Basic List Read program
* This program utilizes the Featureless Linux Library.
* This program processes files or other input in fss format and stores the results in the fss_extended_list_read_data.
+ *
+ * This processes in accordance to the FSS-0003 Extended List specification.
*/
#ifndef _fss_extended_list_read_h
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
macro_fss_extended_list_read_depths_new(status, (*depths), data.parameters[fss_extended_list_read_parameter_depth].locations.used);
if (f_status_is_error(status)) {
f_status status2 = f_none;
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
macro_fss_extended_list_read_depths_delete(status2, (*depths));
return f_status_set_error(f_invalid_parameter);
macro_fss_extended_list_read_depths_new(status, (*depths), 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
return f_status_set_error(f_invalid_parameter);
}
else if (data.parameters[fss_extended_list_read_parameter_name].result == f_console_result_additional) {
macro_fss_extended_list_read_depths_new(status, (*depths), 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
return f_status_set_error(f_invalid_parameter);
}
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_extended_list_read() for the file '%s'", filename);
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_incomplete_utf_on_stop) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_extended_list_read() for the file '%s'", f_status_set_error(status), filename);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_extended_list_read() for the file '%s'", status, filename);
}
fss_extended_list_read_delete_data(data);
#define fss_extended_list_read_depth_initialize \
{ \
0, \
- f_array_length_initialize, \
- f_array_length_initialize, \
+ 0, \
+ 0, \
}
#endif // _di_fss_extended_list_read_depth_
* This is the FSS Basic Read program
* This program utilizes the Featureless Linux Library.
* This program processes files or other input in fss format and stores the results in the fss_extended_read_data.
+ *
+ * This processes in accordance to the FSS-0001 Extended specification.
*/
#ifndef _fss_extended_read_h
fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
macro_fss_extended_read_depths_new(status, (*depths), data.parameters[fss_extended_read_parameter_depth].locations.used);
if (f_status_is_error(status)) {
f_status status2 = f_none;
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
macro_fss_extended_read_depths_delete(status2, (*depths));
return f_status_set_error(f_invalid_parameter);
macro_fss_extended_read_depths_new(status, (*depths), 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
return f_status_set_error(f_invalid_parameter);
}
else if (data.parameters[fss_extended_read_parameter_name].result == f_console_result_additional) {
macro_fss_extended_read_depths_new(status, (*depths), 1);
if (f_status_is_error(status)) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
return f_status_set_error(f_invalid_parameter);
}
fl_color_print_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);
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_incomplete_utf_on_stop) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
}
else {
- fl_color_print_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_status_set_error(status), filename);
+ fl_color_print_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);
}
fss_extended_read_delete_data(data);
#define fss_extended_read_depth_initialize \
{ \
0, \
- f_array_length_initialize, \
- f_array_length_initialize, \
+ 0, \
+ 0, \
}
#endif // _di_fss_extended_read_depth_
// nothing can be 0 as that represents the program name, unless arguments.argv[] is improperly created
}
else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else if (status == f_invalid_utf) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling fl_console_parameter_process().");
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_console_parameter_process().");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_console_parameter_process().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_console_parameter_process().", status);
}
fss_extended_write_delete_data(data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
f_status status2 = f_none;
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
fss_extended_write_delete_data(data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
}
fss_extended_write_delete_data(data);
if (status == f_invalid_parameter) {
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
} else if (status != f_file_not_found && status != f_file_open_error && status != f_file_descriptor_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", status);
}
} else {
if (status == f_invalid_parameter) {
} else if (status == f_file_descriptor_error) {
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename);
} else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", status);
}
}
} else if (status == f_file_read_error) {
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%s'.", filename);
} else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
} else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read().", status);
}
return f_status_set_error(status);
} else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: No relevant data was found within the file '%s'.", filename);
} else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
} else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", f_status_set_error(status), filename);
+ fl_color_print_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);
}
return f_status_set_error(status);
status = f_status_set_fine(status);
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_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_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", status);
}
f_macro_fss_objects_delete(status2, local->rule_objects);
} else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: No relevant data was found within the file '%s'.", init_rule_core_file);
} else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
} else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", f_status_set_error(status), init_rule_core_file);
+ fl_color_print_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, init_rule_core_file);
}
f_macro_string_dynamic_delete(buffer);
if (f_status_is_error(status_process)) {
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling init_load_main_rule().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling init_load_main_rule().", status);
}
// @todo: init_delete_data((*data));
status = f_status_set_fine(status);
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data.context.error, context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
} else if (status == f_failure) {
// the error message has already been displayed.
} else {
- fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", status);
}
f_macro_fss_objects_delete(status2, (*rule_objects));
}
else {
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
}
else {
- fl_color_print_line(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling init_load_main_rule().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling init_load_main_rule().", status);
}
}
status = f_none; \
if (new_length < rules.size) { \
f_string_length i = rules.size - new_length; \
- for (; i < rules.size; ++i) { \
+ for (; i < rules.size; i++) { \
delete_init_rule(status, rules.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > rules.size) { \
f_string_length i = rules.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&rules.array[i], 0, sizeof(f_string)); \
} \
} \
status = f_none; \
if (new_length < rules.size) { \
f_string_length i = rules.size - new_length; \
- for (; i < rules.size; ++i) { \
+ for (; i < rules.size; i++) { \
destroy_init_rule(status, rules.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > rules.size) { \
f_string_length i = rules.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&rules.array[i], 0, sizeof(init_rule)); \
} \
} \
status = f_none; \
if (new_length < categorys.size) { \
f_string_length i = categorys.size - new_length; \
- for (; i < categorys.size; ++i) { \
+ for (; i < categorys.size; i++) { \
delete_init_category(status, categorys.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > categorys.size) { \
f_string_length i = categorys.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&categorys.array[i], 0, sizeof(f_string)); \
} \
} \
status = f_none; \
if (new_length < categorys.size) { \
f_string_length i = categorys.size - new_length; \
- for (; i < categorys.size; ++i) { \
+ for (; i < categorys.size; i++) { \
destroy_init_category(status, categorys.array[i]); \
if (status != f_none) break; \
} \
if (status == f_none) { \
if (new_length > categorys.size) { \
f_string_length i = categorys.size; \
- for (; i < new_length; ++i) { \
+ for (; i < new_length; i++) { \
memset(&categorys.array[i], 0, sizeof(init_category)); \
} \
} \