I have decided that the syntax style should have a space between ){ from now on.
I did this change in mass via a sed script.
I did not notice any incorrect changes, but there is more to review than I am willing to review.
#endif
#ifndef _di_f_console_identify_
- f_return_status f_console_identify(const f_string input, f_console_id *result){
+ f_return_status f_console_identify(const f_string input, f_console_id *result) {
#ifndef _di_level_0_parameter_checking_
if (result == f_null) return f_invalid_parameter;
#endif // _di_level_0_parameter_checking_
const f_string_length length = strnlen(input, 4);
- if (length == 0){
+ if (length == 0) {
*result = f_console_none;
return f_none;
}
- if (input[0] == f_console_symbol_enable){
- if (length > 1){
- if (input[1] == f_console_symbol_enable){
- if (length > 2){
- if (input[2] == f_console_symbol_enable){
- if (length > 3){
+ if (input[0] == f_console_symbol_enable) {
+ if (length > 1) {
+ if (input[1] == f_console_symbol_enable) {
+ if (length > 2) {
+ if (input[2] == f_console_symbol_enable) {
+ if (length > 3) {
*result = f_console_extra_enable;
} else *result = f_console_empty_extra_enable;
} else *result = f_console_long_enable;
} else *result = f_console_empty_long_enable;
} else *result = f_console_short_enable;
} else *result = f_console_empty_short_enable;
- } else if (input[0] == f_console_symbol_disable){
- if (length > 1){
- if (input[1] == f_console_symbol_disable){
- if (length > 2){
- if (input[2] == f_console_symbol_disable){
- if (length > 3){
+ } else if (input[0] == f_console_symbol_disable) {
+ if (length > 1) {
+ if (input[1] == f_console_symbol_disable) {
+ if (length > 2) {
+ if (input[2] == f_console_symbol_disable) {
+ if (length > 3) {
*result = f_console_extra_disable;
} else *result = f_console_empty_extra_disable;
} else *result = f_console_long_disable;
#endif
#ifndef _di_f_is_digit_
- f_return_status f_is_digit(const f_autochar character){
+ f_return_status f_is_digit(const f_autochar character) {
// at this point, it seems that it would incur more overhead to use the libc isdigit here, so just use one less call and test it here
- switch(character){
+ switch(character) {
case '0':
case '1':
case '2':
#endif // _di_f_is_digit_
#ifndef _di_f_is_hexdigit_
- f_return_status f_is_hexdigit(const f_autochar character){
+ f_return_status f_is_hexdigit(const f_autochar character) {
- switch(character){
+ switch(character) {
case '0':
case '1':
case '2':
#endif // _di_f_is_hexdigit_
#ifndef _di_f_character_to_digit_
- f_return_status f_character_to_digit(const f_autochar character, f_u_long *digit){
+ f_return_status f_character_to_digit(const f_autochar character, f_u_long *digit) {
#ifndef _di_level_0_parameter_checking_
if (digit == f_null) return f_invalid_parameter;
#endif // _di_level_0_parameter_checking_
- switch(character){
+ switch(character) {
case '0': *digit = 0; break;
case '1': *digit = 1; break;
case '2': *digit = 2; break;
#endif // _di_f_character_to_digit_
#ifndef _di_f_character_to_hexdigit_
- f_return_status f_character_to_hexdigit(const f_autochar character, f_u_long *digit){
+ f_return_status f_character_to_hexdigit(const f_autochar character, f_u_long *digit) {
#ifndef _di_level_0_parameter_checking_
if (digit == f_null) return f_invalid_parameter;
#endif // _di_level_0_parameter_checking_
- switch(character){
+ switch(character) {
case '0': *digit = 0; break;
case '1': *digit = 1; break;
case '2': *digit = 2; break;
#endif // _di_f_character_to_hexdigit_
#ifndef _di_f_string_to_digit_
- f_return_status f_string_to_digit(const f_string string, f_u_long *digit, const f_string_location location){
+ f_return_status f_string_to_digit(const f_string string, f_u_long *digit, const f_string_location location) {
#ifndef _di_level_0_parameter_checking_
if (digit == f_null) return f_invalid_parameter;
if (location.start < 0) return f_invalid_parameter;
f_u_long scale = 0;
f_u_long temp_digit = 0;
- while(current_location < location.stop){
- if (f_character_to_digit(string[current_location], &temp_digit) == f_none){
+ while(current_location < location.stop) {
+ if (f_character_to_digit(string[current_location], &temp_digit) == f_none) {
// when the scale exists, then we need to make the number larger, for this function the scale is base 10
- if (scale > 0){
+ if (scale > 0) {
*digit = 10 * *digit;
*digit += temp_digit;
} else {
#endif // _di_f_string_to_digit_
#ifndef _di_f_string_to_hexdigit_
- f_return_status f_string_to_hexdigit(const f_string string, f_u_long *digit, const f_string_location location){
+ f_return_status f_string_to_hexdigit(const f_string string, f_u_long *digit, const f_string_location location) {
#ifndef _di_level_0_parameter_checking_
if (digit == f_null) return f_invalid_parameter;
if (location.start < 0) return f_invalid_parameter;
f_u_long scale = 0;
f_u_long temp_digit = 0;
- while(current_location < location.stop){
- if (f_character_to_hexdigit(string[current_location], &temp_digit) == f_none){
+ while(current_location < location.stop) {
+ if (f_character_to_hexdigit(string[current_location], &temp_digit) == f_none) {
// when the scale exists, then we need to make the number larger, for this function the scale is base 16
- if (scale > 0){
+ if (scale > 0) {
*digit <<= 4;
*digit += temp_digit;
} else {
#endif
#ifndef _di_f_file_open_
- f_return_status f_file_open(f_file *file_information, const f_string filename){
+ f_return_status f_file_open(f_file *file_information, const f_string filename) {
#ifndef _di_level_0_parameter_checking_
if (file_information == f_null) return f_invalid_parameter;
#endif // _di_level_0_parameter_checking_
#endif // _di_f_file_open_
#ifndef _di_f_file_close_
- f_return_status f_file_close(f_file *file_information){
+ f_return_status f_file_close(f_file *file_information) {
#ifndef _di_level_0_parameter_checking_
if (file_information == f_null) return f_invalid_parameter;
#endif // _di_level_0_parameter_checking_
if (file_information->file == 0) return f_file_not_open;
// if we were given a file descriptor as well, make sure to flush all changes to the disk that are not flushed by the 'fflush()' command
- if (file_information->id != 0){
+ if (file_information->id != 0) {
// make sure all unfinished data gets completed
if (fsync(file_information->id) != 0) return f_file_synchronize_error;
}
- if (fclose(file_information->file) == 0){
+ if (fclose(file_information->file) == 0) {
file_information->file = 0;
return f_none;
}
#endif // _di_f_file_close_
#ifndef _di_f_file_flush_
- f_return_status f_file_flush(f_file *file_information){
+ f_return_status f_file_flush(f_file *file_information) {
#ifndef _di_level_0_parameter_checking_
if (file_information == f_null) return f_invalid_parameter;
#endif // _di_level_0_parameter_checking_
#endif // _di_f_file_flush_
#ifndef _di_f_file_read_
- f_return_status f_file_read(f_file *file_information, f_dynamic_string *buffer, const f_file_position location){
+ f_return_status f_file_read(f_file *file_information, f_dynamic_string *buffer, const f_file_position location) {
#ifndef _di_level_0_parameter_checking_
if (file_information == f_null) return f_invalid_parameter;
if (buffer->used >= buffer->size) return f_invalid_parameter;
if (location.total_elements < 0) return f_invalid_parameter;
// when the available buffer size is smaller than the total elements, then there is not enough allocated memory available to read the file
- if (location.total_elements > 0){
+ if (location.total_elements > 0) {
if (buffer->size - location.buffer_start < location.total_elements) return f_invalid_parameter;
}
#endif // _di_level_0_parameter_checking_
f_s_int result = 0;
- if (current_file_position > location.file_start){
+ if (current_file_position > location.file_start) {
result = f_file_seek_from_current(file_information->file, file_information->byte_size * (0 - (current_file_position - location.file_start)));
- } else if (current_file_position < location.file_start){
+ } else if (current_file_position < location.file_start) {
result = f_file_seek_from_current(file_information->file, file_information->byte_size * (location.file_start - current_file_position));
}
if (result != 0) return f_file_seek_error;
// now do the actual read
- if (location.total_elements == 0){
+ if (location.total_elements == 0) {
result = fread(buffer->string + location.buffer_start, file_information->byte_size, buffer->size - buffer->used - 1, file_information->file);
} else {
result = fread(buffer->string + location.buffer_start, file_information->byte_size, location.total_elements, file_information->file);
// now save how much of our allocated buffer is actually used
// also make sure that we aren't making used space vanish
- if (location.buffer_start + result > buffer->used){
+ if (location.buffer_start + result > buffer->used) {
buffer->used = location.buffer_start + (result / file_information->byte_size);
}
// append an EOS only when the total elements were set to 0
- if (location.total_elements == 0){
+ if (location.total_elements == 0) {
buffer->string[buffer->used] = f_eos;
}
// make sure to communicate that we are done without a problem and the eof was reached
- if (feof(file_information->file)){
+ if (feof(file_information->file)) {
return f_none_on_eof;
}
#endif // _di_f_file_read_
#ifndef _di_f_file_read_fifo_
- f_return_status f_file_read_fifo(f_file *file_information, f_dynamic_string *buffer){
+ f_return_status f_file_read_fifo(f_file *file_information, f_dynamic_string *buffer) {
#ifndef _di_level_0_parameter_checking_
if (file_information == f_null) return f_invalid_parameter;
if (buffer->used >= buffer->size) return f_invalid_parameter;
buffer->used += (result / file_information->byte_size);
// make sure to communicate that we are done without a problem and the eof was reached
- if (feof(file_information->file)){
+ if (feof(file_information->file)) {
return f_none_on_eof;
}
#endif
#ifndef _di_f_new_
- f_return_status f_new_array(void **pointer, const f_memory_size_t type, const f_memory_length length){
+ f_return_status f_new_array(void **pointer, const f_memory_size_t type, const f_memory_length length) {
#ifndef _di_level_0_parameter_checking_
if (type <= 0) return f_invalid_parameter;
if (pointer == 0) return f_invalid_parameter;
// I have noticed this sometimes causes an increase in L1/L2 cache misses (0.02% L1 increase, 0.01% L2 increase)
*pointer = calloc(type, length);
- if (*pointer){
+ if (*pointer) {
//memset(*pointer, 0, type * length);
return f_none;
}
#endif // _di_f_new_
#if ! ( defined (_di_f_delete_) || defined (_f_memory_FORCE_secure_memory_) )
- f_return_status f_delete(void **pointer, const f_memory_size_t type, const f_memory_length length){
+ f_return_status f_delete(void **pointer, const f_memory_size_t type, const f_memory_length length) {
#ifndef _di_level_0_parameter_checking_
if (pointer == 0) return f_invalid_parameter;
#endif // _di_level_0_parameter_checking_
#endif // ! ( defined (_di_f_delete_) || defined (_f_memory_FORCE_secure_memory_) )
#if ! ( defined (_di_f_destroy_) || defined (_f_memory_FORCE_fast_memory_) )
- f_return_status f_destroy(void **pointer, const f_memory_size_t type, const f_memory_length length){
+ f_return_status f_destroy(void **pointer, const f_memory_size_t type, const f_memory_length length) {
#ifndef _di_level_0_parameter_checking_
if (length < 0) return f_invalid_parameter;
if (type <= 0) return f_invalid_parameter;
// prevent double-frees
if (*pointer == 0) return f_none;
- if (length > 0){
+ if (length > 0) {
memset(*pointer, 0, type * length);
}
#endif // ! ( defined (_di_f_destroy_) || defined (_f_memory_FORCE_fast_memory_) )
#if ! ( defined (_di_f_resize_) || defined (_f_memory_FORCE_secure_memory_) )
- f_return_status f_resize(void **pointer, const f_memory_size_t type, const f_memory_length old_length, const f_memory_length new_length){
+ f_return_status f_resize(void **pointer, const f_memory_size_t type, const f_memory_length old_length, const f_memory_length new_length) {
#ifndef _di_level_0_parameter_checking_
if (type <= 0) return f_invalid_parameter;
if (old_length < 0) return f_invalid_parameter;
// don't be wasteful
if (old_length == new_length) return f_none;
- if (*pointer != 0){
+ if (*pointer != 0) {
void *new_pointer = 0;
// allocate new space
- if (new_length > 0){
+ if (new_length > 0) {
new_pointer = realloc(*pointer, type * new_length);
} else {
free(*pointer);
return f_none;
}
- if (new_pointer){
- if (new_pointer != *pointer){
- if (new_length > old_length){
+ if (new_pointer) {
+ if (new_pointer != *pointer) {
+ if (new_length > old_length) {
// bool * is of a data type size of 1, casting it to bool should result in a single-length increment
// this is done to avoid problems with (void *) having arithmetic issues
memset(((char *) new_pointer) + (type * old_length), 0, type * (new_length - old_length));
return f_none;
}
- } else if (new_length > 0){
+ } else if (new_length > 0) {
*pointer = calloc(type, new_length);
- if (*pointer){
+ if (*pointer) {
return f_none;
}
} else {
#endif // ! ( defined (_di_f_resize_) || defined (_f_memory_FORCE_secure_memory_) )
#if ! ( defined (_di_f_adjust_) || defined (_f_memory_FORCE_fast_memory_) )
- f_return_status f_adjust(void **pointer, const f_memory_size_t type, const f_memory_length old_length, const f_memory_length new_length){
+ f_return_status f_adjust(void **pointer, const f_memory_size_t type, const f_memory_length old_length, const f_memory_length new_length) {
#ifndef _di_level_0_parameter_checking_
if (type <= 0) return f_invalid_parameter;
if (old_length < 0) return f_invalid_parameter;
// don't be wasteful
if (old_length == new_length) return f_none;
- if (*pointer != 0){
+ if (*pointer != 0) {
void *new_pointer = 0;
- if (old_length > 0){
- if (new_length < old_length){
+ if (old_length > 0) {
+ if (new_length < old_length) {
// bool * is of a data type size of 1, casting it to bool should result in a single-length increment
// this is done to avoid problems with (void *) having arithmetic issues
memset(((char *)*pointer) + new_length, 0, type * (old_length - new_length));
}
// allocate new space
- if (new_length > 0){
+ if (new_length > 0) {
new_pointer = realloc(*pointer, type * new_length);
} else {
free(*pointer);
return f_none;
}
- if (new_pointer){
- if (new_pointer != *pointer){
- if (new_length > old_length){
+ if (new_pointer) {
+ if (new_pointer != *pointer) {
+ if (new_length > old_length) {
// char * is of a data type size of 1, casting it to bool should result in a single-length increment
// this is done to avoid problems with (void *) having arithmetic issues
memset(((char *)new_pointer) + (type * old_length), 0, type * (new_length - old_length));
return f_none;
}
- } else if (new_length > 0){
+ } else if (new_length > 0) {
*pointer = calloc(type, new_length);
- if (*pointer){
+ if (*pointer) {
return f_none;
}
} else {
// type: the structure type
#define f_delete_structure(status, structure, type) \
status = f_delete((void **) & structure.array, sizeof(type), structure.size); \
- if (status == f_none){ \
+ if (status == f_none) { \
structure.size = 0; \
structure.used = 0; \
}
// type: the structure type
#define f_destroy_structure(status, structure, type) \
status = f_destroy((void **) & structure.array, sizeof(type), structure.size); \
- if (status == f_none){ \
+ if (status == f_none) { \
structure.size = 0; \
structure.used = 0; \
}
// type: the structure type
#define f_resize_structure(status, structure, type, new_length) \
status = f_resize((void **) & structure.array, sizeof(type), structure.size, new_length); \
- if (status == f_none){ \
+ if (status == f_none) { \
structure.size = new_length; \
if (structure.used > structure.size) structure.used = new_length; \
}
// type: the structure type
#define f_adjust_structure(status, structure, type, new_length) \
status = f_adjust((void **) & structure.array, sizeof(type), structure.size, new_length); \
- if (status == f_none){ \
+ if (status == f_none) { \
structure.size = new_length; \
if (structure.used > structure.size) structure.used = new_length; \
}
// type: the structure type
#define f_delete_structures(status, structures, type) \
status = f_none; \
- while (structures.size > 0){ \
+ while (structures.size > 0) { \
--structures.size; \
f_delete_structure(status, structures.array[structures.size], type); \
if (status != f_none) break; \
// type: the structure type
#define f_destroy_structures(status, structures, type) \
status = f_none; \
- while (structures.size > 0){ \
+ while (structures.size > 0) { \
--structures.size; \
f_destroy_structure(status, structures.array[structures.size], type); \
if (status != f_none) break; \
// type: the structure type
#define f_resize_structures(status, structures, type, new_length, length_variable) \
status = f_none; \
- if (new_length < structures.size){ \
+ if (new_length < structures.size) { \
length_variable i = structures.size - new_length; \
- for (; i < structures.size; ++i){ \
+ for (; i < structures.size; ++i) { \
f_delete_structure(status, structures.array[i], type); \
if (status != f_none) break; \
} \
} \
if (status == f_none) status = f_resize((void **) & structures.array, sizeof(type), structures.size, new_length); \
if (status == f_none) { \
- if (new_length > structures.size){ \
+ 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)); \
} \
} \
// type: the structure type
#define f_adjust_structures(status, structures, type, new_length, length_variable) \
status = f_none; \
- if (new_length < structures.size){ \
+ if (new_length < structures.size) { \
length_variable i = structures.size - new_length; \
- for (; i < structures.size; ++i){ \
+ for (; i < structures.size; ++i) { \
f_destroy_structure(status, structures.array[i], type); \
if (status != f_none) break; \
} \
} \
if (status == f_none) status = f_adjust((void **) & structures.array, sizeof(type), structures.size, new_length); \
if (status == f_none) { \
- if (new_length > structures.size){ \
+ 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)); \
} \
} \
#endif
#ifndef _di_f_print_string_
- f_return_status f_print_string(f_file_type output, const f_string string, const f_string_length length){
+ f_return_status f_print_string(f_file_type output, const f_string string, const f_string_length length) {
register f_string_length i = 0;
- for (; i < length; i++){
- if (string[i] != f_eos){
+ for (; i < length; i++) {
+ if (string[i] != f_eos) {
if (fputc(string[i], output) == 0) return f_output_error;
}
}
#endif // _di_f_print_string_
#ifndef _di_f_print_dynamic_string_
- f_return_status f_print_dynamic_string(f_file_type output, const f_dynamic_string buffer){
+ f_return_status f_print_dynamic_string(f_file_type output, const f_dynamic_string buffer) {
#ifndef _di_level_0_parameter_checking_
if (buffer.used <= 0) return f_invalid_parameter;
#endif // _di_level_0_parameter_checking_
register f_string_length i = 0;
- for (; i < buffer.used; i++){
- if (buffer.string[i] != f_eos){
+ for (; i < buffer.used; i++) {
+ if (buffer.string[i] != f_eos) {
if (fputc(buffer.string[i], output) == 0) return f_output_error;
}
}
#endif // _di_f_print_dynamic_string_
#ifndef _di_f_print_partial_dynamic_string_
- f_return_status f_print_partial_dynamic_string(f_file_type output, const f_dynamic_string buffer, const f_string_location location){
+ f_return_status f_print_partial_dynamic_string(f_file_type output, const f_dynamic_string buffer, const f_string_location location) {
#ifndef _di_level_0_parameter_checking_
if (location.start < 0) return f_invalid_parameter;
if (location.stop < location.start) return f_invalid_parameter;
register f_string_length i = location.start;
- for (; i <= location.stop; i++){
- if (buffer.string[i] != f_eos){
+ for (; i <= location.stop; i++) {
+ if (buffer.string[i] != f_eos) {
if (fputc(buffer.string[i], output) == 0) return f_output_error;
}
}
#ifndef _di_f_pipe_exists_
// returns f_true if the standard input contains piped data.
- f_return_status f_pipe_exists(){
+ f_return_status f_pipe_exists() {
struct stat st_info;
if (fstat(fileno(f_pipe), &st_info) != 0) {
#define f_delete_dynamic_string(status, dynamic) \
status = f_delete((void **) & dynamic.string, sizeof(f_string), dynamic.size); \
- if (status == f_none){ \
+ if (status == f_none) { \
dynamic.size = 0; \
dynamic.used = 0; \
}
#define f_destroy_dynamic_string(status, dynamic) \
status = f_destroy((void **) & dynamic.string, sizeof(f_string), dynamic.size); \
- if (status == f_none){ \
+ if (status == f_none) { \
dynamic.size = 0; \
dynamic.used = 0; \
}
#define f_resize_dynamic_string(status, dynamic, new_length) \
status = f_resize((void **) & dynamic.string, sizeof(f_string), dynamic.size, new_length); \
- if (status == f_none){ \
+ if (status == f_none) { \
dynamic.size = new_length; \
if (dynamic.used > dynamic.size) dynamic.used = new_length; \
}
#define f_adjust_dynamic_string(status, dynamic, new_length) \
status = f_adjust((void **) & dynamic.string, sizeof(f_string), dynamic.size, new_length); \
- if (status == f_none){ \
+ if (status == f_none) { \
dynamic.size = new_length; \
if (dynamic.used > dynamic.size) dynamic.used = new_length; \
}
#define f_delete_dynamic_strings(status, dynamics) \
status = f_none; \
- while (dynamics.size > 0){ \
+ while (dynamics.size > 0) { \
--dynamics.size; \
f_delete_dynamic_string(status, dynamics.array[dynamics.size]); \
if (status != f_none) break; \
#define f_destroy_dynamic_strings(status, dynamics) \
status = f_none; \
- while (dynamics.size > 0){ \
+ while (dynamics.size > 0) { \
--dynamics.size; \
f_destroy_dynamic_string(status, dynamics.array[dynamics.size]); \
if (status != f_none) break; \
#define f_resize_dynamic_strings(status, dynamics, new_length) \
status = f_none; \
- if (new_length < dynamics.size){ \
+ if (new_length < dynamics.size) { \
f_string_length i = dynamics.size - new_length; \
- for (; i < dynamics.size; ++i){ \
+ for (; i < dynamics.size; ++i) { \
f_delete_dynamic_string(status, dynamics.array[i]); \
if (status != f_none) break; \
} \
} \
if (status == f_none) status = f_resize((void **) & dynamics.array, sizeof(f_dynamic_string), dynamics.size, new_length); \
if (status == f_none) { \
- if (new_length > dynamics.size){ \
+ 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)); \
} \
} \
#define f_adjust_dynamic_strings(status, dynamics, new_length) \
status = f_none; \
- if (new_length < dynamics.size){ \
+ if (new_length < dynamics.size) { \
f_string_length i = dynamics.size - new_length; \
- for (; i < dynamics.size; ++i){ \
+ for (; i < dynamics.size; ++i) { \
f_destroy_dynamic_string(status, dynamics.array[i]); \
if (status != f_none) break; \
} \
} \
if (status == f_none) status = f_adjust((void **) & dynamics.array, sizeof(f_dynamic_string), dynamics.size, new_length); \
if (status == f_none) { \
- if (new_length > dynamics.size){ \
+ 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_dynamic_string)); \
} \
} \
#endif
#ifndef _di_fl_set_color_
- f_return_status fl_set_color(f_file_type file, const f_colors_format format, const f_autochar *color1, const f_autochar *color2, const f_autochar *color3, const f_autochar *color4, const f_autochar *color5){
+ f_return_status fl_set_color(f_file_type file, const f_colors_format format, const f_autochar *color1, const f_autochar *color2, const f_autochar *color3, const f_autochar *color4, const f_autochar *color5) {
#ifndef _di_level_1_parameter_checking_
if (file == f_null) return f_invalid_parameter;
if (color1 == f_null) return f_invalid_parameter;
#endif // _di_fl_set_color_
#ifndef _di_fl_save_color_
- f_return_status fl_save_color(f_dynamic_string *buffer, const f_colors_format format, const f_autochar *color1, const f_autochar *color2, const f_autochar *color3, const f_autochar *color4, const f_autochar *color5){
+ f_return_status fl_save_color(f_dynamic_string *buffer, const f_colors_format format, const f_autochar *color1, const f_autochar *color2, const f_autochar *color3, const f_autochar *color4, const f_autochar *color5) {
#ifndef _di_level_1_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (color1 == f_null) return f_invalid_parameter;
else string_size += strnlen(color1, f_color_max_size) + strnlen(color2, f_color_max_size) + strnlen(color3, f_color_max_size) + strnlen(color4, f_color_max_size) + strnlen(color5, f_color_max_size);
// make sure there is enough allocated space, if not, then allocate some more
- if (buffer->size - buffer->used - 1 < string_size){
+ if (buffer->size - buffer->used - 1 < string_size) {
f_status status = f_status_initialize;
f_resize_dynamic_string(status, (*buffer), buffer->used + string_size + 1); // the additional 1 is the EOS
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
}
- if (color2 == f_null){
+ if (color2 == f_null) {
strncat(buffer->string, format.begin, f_color_max_size);
strncat(buffer->string, color1, f_color_max_size);
strncat(buffer->string, format.end, f_color_max_size);
- } else if (color3 == f_null){
+ } else if (color3 == f_null) {
strncat(buffer->string, format.begin, f_color_max_size);
strncat(buffer->string, color1, f_color_max_size);
strncat(buffer->string, format.medium, f_color_max_size);
strncat(buffer->string, color2, f_color_max_size);
strncat(buffer->string, format.end, f_color_max_size);
- } else if (color4 == f_null){
+ } else if (color4 == f_null) {
strncat(buffer->string, format.begin, f_color_max_size);
strncat(buffer->string, color1, f_color_max_size);
strncat(buffer->string, format.medium, f_color_max_size);
strncat(buffer->string, format.medium, f_color_max_size);
strncat(buffer->string, color3, f_color_max_size);
strncat(buffer->string, format.end, f_color_max_size);
- } else if (color5 == f_null){
+ } else if (color5 == f_null) {
strncat(buffer->string, format.begin, f_color_max_size);
strncat(buffer->string, color1, f_color_max_size);
strncat(buffer->string, format.medium, f_color_max_size);
#endif // _di_fl_save_color_
#ifndef _di_fl_print_color_
- f_return_status fl_print_color(f_file_type file, const f_dynamic_string start_color, const f_dynamic_string end_color, const f_autochar *string, ...){
+ f_return_status fl_print_color(f_file_type file, const f_dynamic_string start_color, const f_dynamic_string end_color, const f_autochar *string, ...) {
#ifndef _di_level_1_parameter_checking_
if (file == f_null) return f_invalid_parameter;
if (string == f_null) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
- if (start_color.used != 0){
+ if (start_color.used != 0) {
fprintf(file, "%s", start_color.string);
}
va_end(ap);
- if (end_color.used != 0){
+ if (end_color.used != 0) {
fprintf(file, "%s", end_color.string);
}
#endif // _di_fl_print_color_
#ifndef _di_fl_print_color_line_
- f_return_status fl_print_color_line(f_file_type file, const f_dynamic_string start_color, const f_dynamic_string end_color, const f_autochar *string, ...){
+ f_return_status fl_print_color_line(f_file_type file, const f_dynamic_string start_color, const f_dynamic_string end_color, const f_autochar *string, ...) {
#ifndef _di_level_1_parameter_checking_
if (file == f_null) return f_invalid_parameter;
if (string == f_null) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
- if (start_color.used != 0){
+ if (start_color.used != 0) {
fprintf(file, "%s", start_color.string);
}
va_end(ap);
- if (end_color.used != 0){
+ if (end_color.used != 0) {
fprintf(file, "%s", end_color.string);
}
#endif // _di_fl_print_color_line_
#ifndef _di_fl_print_color_code_
- f_return_status fl_print_color_code(f_file_type file, const f_dynamic_string color){
- if (color.used != 0){
+ f_return_status fl_print_color_code(f_file_type file, const f_dynamic_string color) {
+ if (color.used != 0) {
fprintf(file, "%s", color.string);
}
#endif
#ifndef _di_fl_process_parameters_
- f_return_status fl_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, f_string_lengths *remaining){
+ f_return_status fl_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, f_string_lengths *remaining) {
#ifndef _di_level_1_parameter_checking_
if (remaining == f_null) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
// loop through and read all parameters
- while (location < argc){
+ while (location < argc) {
f_console_identify(argv[location], &result);
string_length = strnlen(argv[location], f_console_max_size);
}
// Now handle the normal commands
- if (argv[location][0] == f_console_symbol_enable){
- while (sub_location < string_length){
- for (parameter_counter = 0; parameter_counter < total_parameters; parameter_counter++){
- if (parameters[parameter_counter].type == f_console_type_normal){
- if (parameters[parameter_counter].symbol_short != 0 && parameters[parameter_counter].symbol_long != 0){
- if (f_console_is_enable(result, &argv[location][sub_location], parameters[parameter_counter].symbol_short, parameters[parameter_counter].symbol_long, string_length + 1)){
+ if (argv[location][0] == f_console_symbol_enable) {
+ while (sub_location < string_length) {
+ for (parameter_counter = 0; parameter_counter < total_parameters; parameter_counter++) {
+ if (parameters[parameter_counter].type == f_console_type_normal) {
+ if (parameters[parameter_counter].symbol_short != 0 && parameters[parameter_counter].symbol_long != 0) {
+ if (f_console_is_enable(result, &argv[location][sub_location], parameters[parameter_counter].symbol_short, parameters[parameter_counter].symbol_long, string_length + 1)) {
parameters[parameter_counter].result = f_console_result_found;
- if (parameters[parameter_counter].has_additional){
- if (extra_initiator.used >= extra_initiator.size){
+ if (parameters[parameter_counter].has_additional) {
+ if (extra_initiator.used >= extra_initiator.size) {
f_status allocation_status = f_status_initialize;
f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)){
+ if (f_macro_test_for_allocation_errors(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
return allocation_status;
}
}
if (parameters[parameter_counter].symbol_extra != 0) {
- if (f_console_is_extra_enable(result, &argv[location][sub_location], parameters[parameter_counter].symbol_extra, string_length + 1)){
+ if (f_console_is_extra_enable(result, &argv[location][sub_location], parameters[parameter_counter].symbol_extra, string_length + 1)) {
parameters[parameter_counter].result = f_console_result_found;
- if (parameters[parameter_counter].has_additional){
- if (extra_initiator.used >= extra_initiator.size){
+ if (parameters[parameter_counter].has_additional) {
+ if (extra_initiator.used >= extra_initiator.size) {
f_status allocation_status = f_status_initialize;
f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)){
+ if (f_macro_test_for_allocation_errors(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
return allocation_status;
}
// now handle the inverse commands
} else if (argv[location][0] == f_console_symbol_disable) {
- while (sub_location < string_length){
- for (parameter_counter = 0; parameter_counter < total_parameters; parameter_counter++){
- if (parameters[parameter_counter].type == f_console_type_inverse){
- if (parameters[parameter_counter].symbol_short != 0 && parameters[parameter_counter].symbol_long != 0){
- if (f_console_is_disable(result, &argv[location][sub_location], parameters[parameter_counter].symbol_short, parameters[parameter_counter].symbol_long, string_length + 1)){
+ while (sub_location < string_length) {
+ for (parameter_counter = 0; parameter_counter < total_parameters; parameter_counter++) {
+ if (parameters[parameter_counter].type == f_console_type_inverse) {
+ if (parameters[parameter_counter].symbol_short != 0 && parameters[parameter_counter].symbol_long != 0) {
+ if (f_console_is_disable(result, &argv[location][sub_location], parameters[parameter_counter].symbol_short, parameters[parameter_counter].symbol_long, string_length + 1)) {
parameters[parameter_counter].result = f_console_result_found;
- if (parameters[parameter_counter].has_additional){
- if (extra_initiator.used >= extra_initiator.size){
+ if (parameters[parameter_counter].has_additional) {
+ if (extra_initiator.used >= extra_initiator.size) {
f_status allocation_status = f_status_initialize;
f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)){
+ if (f_macro_test_for_allocation_errors(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
return allocation_status;
}
}
if (parameters[parameter_counter].symbol_extra != 0) {
- if (f_console_is_extra_disable(result, &argv[location][sub_location], parameters[parameter_counter].symbol_extra, string_length + 1)){
+ if (f_console_is_extra_disable(result, &argv[location][sub_location], parameters[parameter_counter].symbol_extra, string_length + 1)) {
parameters[parameter_counter].result = f_console_result_found;
- if (parameters[parameter_counter].has_additional){
- if (extra_initiator.used >= extra_initiator.size){
+ if (parameters[parameter_counter].has_additional) {
+ if (extra_initiator.used >= extra_initiator.size) {
f_status allocation_status = f_status_initialize;
f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)){
+ if (f_macro_test_for_allocation_errors(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
return allocation_status;
}
// use found to determine if the remaining parameter should be populated
found = f_false;
- for (parameter_counter = 0; parameter_counter < total_parameters; parameter_counter++){
- if (parameters[parameter_counter].type == f_console_type_other){
- if (parameters[parameter_counter].length > 0 && parameters[parameter_counter].symbol_other != 0){
- if (strncmp(argv[location], parameters[parameter_counter].symbol_other, parameters[parameter_counter].length + 1) == 0){
+ for (parameter_counter = 0; parameter_counter < total_parameters; parameter_counter++) {
+ if (parameters[parameter_counter].type == f_console_type_other) {
+ if (parameters[parameter_counter].length > 0 && parameters[parameter_counter].symbol_other != 0) {
+ if (strncmp(argv[location], parameters[parameter_counter].symbol_other, parameters[parameter_counter].length + 1) == 0) {
parameters[parameter_counter].result = f_console_result_found;
// when "other" is supplied, the extra will be recycled to represent the location of the "other" such that ordering can be determined by the caller
}
} // for()
- if (!found){
- if (extra_initiator.used > 0){
+ if (!found) {
+ if (extra_initiator.used > 0) {
parameters[extra_initiator.array[0]].result = f_console_result_additional;
parameters[extra_initiator.array[0]].additional = location;
f_string_length i = 0;
- for (; i < extra_initiator.used; i++){
+ for (; i < extra_initiator.used; i++) {
extra_initiator.array[i] = extra_initiator.array[i + 1];
}
} else {
- if (remaining->used >= remaining->size){
+ if (remaining->used >= remaining->size) {
f_status allocation_status = f_status_initialize;
f_resize_string_lengths(allocation_status, (*remaining), remaining->size + f_console_default_allocation_step);
- if (f_macro_test_for_allocation_errors(allocation_status)){
+ if (f_macro_test_for_allocation_errors(allocation_status)) {
f_delete_string_lengths(status, extra_initiator);
return allocation_status;
}
++location;
} // while()
- if (extra_initiator.used > 0){
+ if (extra_initiator.used > 0) {
status = f_no_data;
} else {
status = f_none;
#ifndef _di_fl_directory_list_
// put the names of each file and/or directory inside the names parameter
- f_return_status fl_directory_list(const f_string directory_path, f_dynamic_strings *names){
+ f_return_status fl_directory_list(const f_string directory_path, f_dynamic_strings *names) {
#ifndef _di_level_1_parameter_checking_
if (names == f_null) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
size = strnlen(listing[counter]->d_name, 256); // as far as I can tell 256 is the max directory name length
// there is no reason to include "." and ".." in the directory listing
- if (strncmp(listing[counter]->d_name, "..", 3) != 0 && strncmp(listing[counter]->d_name, ".", 2) != 0){
- if (names->used >= names->size){
+ if (strncmp(listing[counter]->d_name, "..", 3) != 0 && strncmp(listing[counter]->d_name, ".", 2) != 0) {
+ if (names->used >= names->size) {
f_resize_dynamic_strings(status, (*names), names->used + fl_directory_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
}
f_resize_dynamic_string(status, names->array[names->used], size);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
// FIXME: the second and third paramater are probably wrong
f_delete((void **) & listing, sizeof(struct dirent *), 0);
- if (length == 0){
+ if (length == 0) {
// an empty directory
return f_no_data;
- } else if (length == -1){
+ } else if (length == -1) {
if (errno == ENOMEM) return f_allocation_error;
else return f_failure;
}
if (string == f_null) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
- switch(error){
+ switch(error) {
#ifndef _di_fl_errors_booleans_
case f_false:
*string = "f_false";
#ifndef _di_fl_errors_is_warning_
f_return_status fl_errors_is_warning(const f_status error) {
- switch(error){
+ switch(error) {
#ifndef _di_fl_errors_basic_
case f_no_data:
return f_true;
// Returns true or false depending on whether the standard context of the error code represents an normal return status and not an error.
// Keep in mind that many of the error codes are context-specific and may be reported as an "okay" here when it is in fact not okay.
f_return_status fl_errors_is_okay(const f_status error) {
- switch(error){
+ switch(error) {
#ifndef _di_fl_errors_booleans_
case f_false:
return f_true;
#endif
#ifndef _di_fl_file_read_
- f_return_status fl_file_read(f_file file, const f_file_position position, f_dynamic_string *buffer){
+ f_return_status fl_file_read(f_file file, const f_file_position position, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
f_bool infinite = f_false;
// when total_elements is 0, this means the file read will until EOF is reached
- if (position.total_elements == 0){
+ if (position.total_elements == 0) {
infinite = f_true;
size = f_file_default_read_size;
} else {
// populate the buffer
do{
- if (buffer->size <= size){
+ if (buffer->size <= size) {
f_resize_dynamic_string(status, (*buffer), size);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
}
status = f_file_read(&file, buffer, position);
- if (status == f_none_on_eof){
+ if (status == f_none_on_eof) {
break;
- } else if (status != f_none){
+ } else if (status != f_none) {
return status;
}
- if (infinite){
- if (size + f_file_default_read_size > f_string_max_size){
+ if (infinite) {
+ if (size + f_file_default_read_size > f_string_max_size) {
return f_overflow;
}
#endif // _di_fl_file_read_
#ifndef _di_fl_file_read_fifo_
- f_return_status fl_file_read_fifo(f_file file, f_dynamic_string *buffer){
+ f_return_status fl_file_read_fifo(f_file file, f_dynamic_string *buffer) {
#ifndef _di_level_1_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
// populate the buffer
do {
- if (buffer->size <= size){
+ if (buffer->size <= size) {
f_resize_dynamic_string(status, (*buffer), size);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
}
status = f_file_read_fifo(&file, buffer);
- if (status == f_none_on_eof){
+ if (status == f_none_on_eof) {
break;
- } else if (status != f_none){
+ } else if (status != f_none) {
return status;
}
- if (size + f_file_default_read_size > f_string_max_size){
+ if (size + f_file_default_read_size > f_string_max_size) {
return f_overflow;
}
#endif
#ifndef _di_fl_fss_identify_
- f_return_status fl_fss_identify(const f_dynamic_string buffer, f_fss_header *header){
+ f_return_status fl_fss_identify(const f_dynamic_string buffer, f_fss_header *header) {
#ifndef _di_level_1_parameter_checking_
if (header == f_null) return f_invalid_parameter;
if (buffer.used <= 0) return f_invalid_parameter;
register f_string_length i = 0;
// If this correctly follows the FSS specification, then this should be all that needs to be done (as well as atoh for ascii to hex)
- if (buffer.string[i] == f_fss_type_header_open){ i++;
- if (buffer.string[i] == f_fss_type_header_part1){ i++;
- if (buffer.string[i] == f_fss_type_header_part2){ i++;
- if (buffer.string[i] == f_fss_type_header_part3){ i++;
- if (buffer.string[i] == f_fss_type_header_part4){ i++;
- if (buffer.string[i] == f_fss_type_header_part5){ i++;
- if (f_is_hexdigit(buffer.string[i]) == f_true){ i++;
- if (f_is_hexdigit(buffer.string[i]) == f_true){ i++;
- if (f_is_hexdigit(buffer.string[i]) == f_true){ i++;
- if (f_is_hexdigit(buffer.string[i]) == f_true){ i++;
+ if (buffer.string[i] == f_fss_type_header_open) { i++;
+ if (buffer.string[i] == f_fss_type_header_part1) { i++;
+ if (buffer.string[i] == f_fss_type_header_part2) { i++;
+ if (buffer.string[i] == f_fss_type_header_part3) { i++;
+ if (buffer.string[i] == f_fss_type_header_part4) { i++;
+ if (buffer.string[i] == f_fss_type_header_part5) { i++;
+ if (f_is_hexdigit(buffer.string[i]) == f_true) { i++;
+ if (f_is_hexdigit(buffer.string[i]) == f_true) { i++;
+ if (f_is_hexdigit(buffer.string[i]) == f_true) { i++;
+ if (f_is_hexdigit(buffer.string[i]) == f_true) { i++;
f_string_location location = f_string_location_initialize;
f_string_to_hexdigit(buffer.string, &header->type, location);
// 2: At this point, we can still know the proper format for the file and still have a invalid header, handle accordingly
- if (buffer.string[i] == f_fss_type_header_close){
+ if (buffer.string[i] == f_fss_type_header_close) {
i++;
header->length = i;
}
}
// people can miss spaces, so lets accept in an attempt to interpret the file anyway, but return values at this point are to be flagged as invalid
- } else if (buffer.string[i] == f_fss_type_header_part2){ i++;
- if (buffer.string[i] == f_fss_type_header_part3){ i++;
- if (buffer.string[i] == f_fss_type_header_part4){ i++;
- if (buffer.string[i] == f_fss_type_header_part5){ i++;
- if (f_is_hexdigit(buffer.string[i]) == f_true){ i++;
- if (f_is_hexdigit(buffer.string[i]) == f_true){ i++;
- if (f_is_hexdigit(buffer.string[i]) == f_true){ i++;
- if (f_is_hexdigit(buffer.string[i]) == f_true){ i++;
+ } else if (buffer.string[i] == f_fss_type_header_part2) { i++;
+ if (buffer.string[i] == f_fss_type_header_part3) { i++;
+ if (buffer.string[i] == f_fss_type_header_part4) { i++;
+ if (buffer.string[i] == f_fss_type_header_part5) { i++;
+ if (f_is_hexdigit(buffer.string[i]) == f_true) { i++;
+ if (f_is_hexdigit(buffer.string[i]) == f_true) { i++;
+ if (f_is_hexdigit(buffer.string[i]) == f_true) { i++;
+ if (f_is_hexdigit(buffer.string[i]) == f_true) { i++;
f_string_location location = f_string_location_initialize;
#endif // _di_fl_fss_identify_
#ifndef _di_fl_fss_identify_file_
- f_return_status fl_fss_identify_file(f_file *file_information, f_fss_header *header){
+ f_return_status fl_fss_identify_file(f_file *file_information, f_fss_header *header) {
#ifndef _di_level_1_parameter_checking_
if (file_information == f_null) return f_invalid_parameter;
if (header == f_null) return f_invalid_parameter;
f_adjust_dynamic_string(status, buffer, location.total_elements + 1);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
// 2: buffer the file
status = f_file_read(file_information, &buffer, location);
- if (f_macro_test_for_basic_errors(status) || f_macro_test_for_file_errors(status)){
+ if (f_macro_test_for_basic_errors(status) || f_macro_test_for_file_errors(status)) {
return status;
}
#endif // _di_fl_fss_identify_file_
#ifndef _di_fl_fss_shift_delimiters_
-f_return_status fl_fss_shift_delimiters(f_dynamic_string *buffer, const f_string_location location){
+f_return_status fl_fss_shift_delimiters(f_dynamic_string *buffer, const f_string_location location) {
#ifndef _di_level_1_parameter_checking_
if (buffer->used <= 0) return f_invalid_parameter;
if (location.start < 0) return f_invalid_parameter;
position = location.start;
- while (position < buffer->used && position <= location.stop){
- if (buffer->string[position] == f_fss_delimit_placeholder){
+ while (position < buffer->used && position <= location.stop) {
+ if (buffer->string[position] == f_fss_delimit_placeholder) {
distance++;
}
// do not waste time trying to process what is only going to be replaced with a delimit placeholder
- if (position + distance >= buffer->used || position + distance > location.stop){
+ if (position + distance >= buffer->used || position + distance > location.stop) {
break;
}
// shift everything down one for each placeholder found
- if (distance > 0){
+ if (distance > 0) {
buffer->string[position] = buffer->string[position + distance];
}
++position;
}
- if (distance > 0){
- while (position < buffer->used + distance && position <= location.stop){
+ if (distance > 0) {
+ while (position < buffer->used + distance && position <= location.stop) {
buffer->string[position] = f_fss_delimit_placeholder;
++position;
}
#endif
#ifndef _di_fl_fss_basic_object_read_
- f_return_status fl_fss_basic_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found){
+ f_return_status fl_fss_basic_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (input == f_null) return f_invalid_parameter;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_fss_basic_close){
+ if (buffer->string[input->start] == f_fss_basic_close) {
input->start++;
return fl_fss_found_no_object;
}
found->start = input->start;
// ignore all comment lines
- if (buffer->string[input->start] == f_fss_comment){
+ if (buffer->string[input->start] == f_fss_comment) {
fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop)
input->start++;
f_autochar quoted = f_eos;
// identify where the object begins
- if (buffer->string[input->start] == f_fss_delimit_slash){
+ if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length first_slash = input->start;
input->start++;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits if a delimit quote would follow the slash (or a slash and a delimit quote follows)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
location = first_slash;
has_delimit = f_true;
quoted = buffer->string[input->start];
input->start++;
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
do{
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
location = first_slash;
has_delimit = f_true;
quoted = buffer->string[input->start];
}
} while (buffer->string[input->start] == f_fss_delimit_slash);
}
- } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
quoted = buffer->string[input->start];
input->start++;
location = input->start;
}
// identify where the object ends
- if (quoted == f_eos){
- while (isgraph(buffer->string[input->start]) || buffer->string[input->start] == f_fss_delimit_placeholder){
+ if (quoted == f_eos) {
+ while (isgraph(buffer->string[input->start]) || buffer->string[input->start] == f_fss_delimit_placeholder) {
++input->start;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
} // while
- if (isspace(buffer->string[input->start])){
+ if (isspace(buffer->string[input->start])) {
found->stop = input->start - 1;
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
input->start++;
return fl_fss_found_object_no_content;
}
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_eol){
- if (found_space){
+ if (buffer->string[input->start] == f_eol) {
+ if (found_space) {
found->stop = pre_space;
input->start = pre_space;
} else {
f_status status = f_status_initialize;
f_delete_string_lengths(status, delimits)
- if (found_space){
+ if (found_space) {
return fl_fss_found_object;
} else {
return fl_fss_found_object_no_content;
}
} else if (isspace(buffer->string[input->start])) {
- if (!found_space){
+ if (!found_space) {
pre_space = input->start - 1;
found_space = f_true;
}
if (isspace(buffer->string[input->start])) {
// this quote is a valid object close quote, so handle appropriately
- if (has_delimit){
+ if (has_delimit) {
buffer->string[location] = f_fss_delimit_placeholder;
- if (ignore_quotes){
- if (found_space){
+ if (ignore_quotes) {
+ if (found_space) {
found->stop = pre_space;
input->start = pre_space;
} else {
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits here if whitespace would follow the quote
- if (buffer->string[input->start] == quoted){
+ if (buffer->string[input->start] == quoted) {
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (isspace(buffer->string[input->start])){
- if (delimits.used >= delimits.size){
+ if (isspace(buffer->string[input->start])) {
+ if (delimits.used >= delimits.size) {
f_status status = f_status_initialize;
f_resize_string_lengths(status, delimits, delimits.size + f_fss_default_allocation_step);
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits here if whitespace would follow the quote
- if (buffer->string[input->start] == quoted){
+ if (buffer->string[input->start] == quoted) {
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (isspace(buffer->string[input->start])){
- if (delimits.used >= delimits.size){
+ if (isspace(buffer->string[input->start])) {
+ if (delimits.used >= delimits.size) {
f_status status = f_status_initialize;
f_resize_string_lengths(status, delimits, delimits.size + f_fss_default_allocation_step);
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
input->start++;
return fl_fss_found_no_content;
}
#endif
#ifndef _di_fl_fss_basic_list_object_read_
- f_return_status fl_fss_basic_list_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found){
+ f_return_status fl_fss_basic_list_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (input == f_null) return f_invalid_parameter;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
input->start++;
return fl_fss_found_no_object;
- } else if (buffer->string[input->start] == f_fss_basic_list_open){
+ } else if (buffer->string[input->start] == f_fss_basic_list_open) {
fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop)
input->start++;
found->start = input->start;
// ignore all comment lines
- if (buffer->string[input->start] == f_fss_comment){
+ if (buffer->string[input->start] == f_fss_comment) {
fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop)
input->start++;
f_autochar quoted = f_eos;
// identify where the object begins
- if (buffer->string[input->start] == f_fss_delimit_slash){
+ if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length first_slash = input->start;
input->start++;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
// A slash only delimits if a delimit quote would follow the slash (or a slash and a delimit quote follows)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
// because the slash properly delimited the quote, the quote then becomes the start of the content
found->start = first_slash + 1;
quote_delimit = first_slash;
has_quote_delimit = f_true;
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
// only apply a slash delimit if the line begins with slashes followed by a quote
do {
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
found->start = first_slash + 1;
quote_delimit = first_slash;
has_quote_delimit = f_true;
}
} while (buffer->string[input->start] == f_fss_delimit_slash);
}
- } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
quoted = buffer->string[input->start];
input->start++;
}
// identify where the object ends
- if (quoted == f_eos){
+ if (quoted == f_eos) {
do{
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
- if (!isgraph(buffer->string[input->start])){
+ if (!isgraph(buffer->string[input->start])) {
break;
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length first_slash = input->start;
++input->start;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
// A slash only delimits here if a basic list opener would follow the slash
- if (buffer->string[input->start] == f_fss_basic_list_open){
+ if (buffer->string[input->start] == f_fss_basic_list_open) {
++input->start;
fl_macro_fss_skip_past_whitespace((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
// found a would be valid basic list object that has been delimited to not be a valid objecy, so exit
- if (buffer->string[input->start] == f_fss_basic_list_close){
+ if (buffer->string[input->start] == f_fss_basic_list_close) {
input->start++;
return fl_fss_found_no_object;
} else {
input->start++;
return fl_fss_found_no_object;
}
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length second_slash = input->start;
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
- if (buffer->string[input->start] == f_fss_basic_list_open){
+ if (buffer->string[input->start] == f_fss_basic_list_open) {
f_string_length open_position = input->start;
++input->start;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
// found a valid basic list object, so apply the delimit
- if (buffer->string[input->start] == f_eol){
- if (has_quote_delimit){
+ if (buffer->string[input->start] == f_eol) {
+ if (has_quote_delimit) {
buffer->string[quote_delimit] = f_fss_delimit_placeholder;
}
input->start = second_slash;
}
}
- } else if (buffer->string[input->start] == f_fss_basic_list_open){
+ } else if (buffer->string[input->start] == f_fss_basic_list_open) {
f_string_length open_position = input->start;
input->start++;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
// found a valid basic list object
- if (buffer->string[input->start] == f_eol){
- if (has_quote_delimit){
+ if (buffer->string[input->start] == f_eol) {
+ if (has_quote_delimit) {
buffer->string[quote_delimit] = f_fss_delimit_placeholder;
}
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
input->start++;
return fl_fss_found_no_object;
}
// close quotes do not need to be delimited in this case as a valid quoted object must end with: ":\n
- if (buffer->string[input->start] == quoted){
+ if (buffer->string[input->start] == quoted) {
// at this point, a valid object will need to be determined
// if nothing else is between the colon and the newline, then a valid object has been found
// otherwise restart the loop at this new position, looking for the next proper close quote
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop)
- if (buffer->string[input->start] == f_fss_basic_list_open){
+ if (buffer->string[input->start] == f_fss_basic_list_open) {
input->start++;
fl_macro_fss_skip_past_whitespace((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
found->stop = quote_location - 1;
input->start++;
return fl_fss_found_object;
#endif // _di_fl_fss_basic_list_object_read_
#ifndef _di_fl_fss_basic_list_content_read_
- f_return_status fl_fss_basic_list_content_read(f_dynamic_string *buffer, f_string_location *input, f_fss_content *found){
+ f_return_status fl_fss_basic_list_content_read(f_dynamic_string *buffer, f_string_location *input, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (input == f_null) return f_invalid_parameter;
// search until stop point, end of string, or until a valid basic list object is found
do{
- if (has_quote_delimit){
+ if (has_quote_delimit) {
has_quote_delimit = f_false;
}
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
has_newlines = f_true;
last_newline = input->start;
++input->start;
continue;
- } else if (buffer->string[input->start] == f_fss_basic_list_open){
+ } else if (buffer->string[input->start] == f_fss_basic_list_open) {
// a line that begins with only the basic list opener cannot be a valid list object so skip to next line
fl_macro_fss_content_seek_till_newline((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
last_newline = input->start;
++input->start;
continue;
- } else if (buffer->string[input->start] == f_fss_comment){
+ } else if (buffer->string[input->start] == f_fss_comment) {
// comment lines are not valid objects so skip to next line
fl_macro_fss_content_seek_till_newline((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
f_autochar quoted = f_eos;
// identify where the object begins
- if (buffer->string[input->start] == f_fss_delimit_slash){
+ if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length first_slash = input->start;
input->start++;
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits if a delimit quote would follow the slash (or a slash and a delimit quote follows)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
// because the slash properly delimited the quote, the quote then becomes the start of the content
quote_delimit = first_slash;
has_quote_delimit = f_true;
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
// only apply a slash delimit if the line begins with slashes followed by a quote
do {
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
quote_delimit = first_slash;
has_quote_delimit = f_true;
break;
continue;
}
}
- } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
quoted = buffer->string[input->start];
input->start++;
}
// identify where the potential object ends
- if (quoted == f_eos){
+ if (quoted == f_eos) {
do{
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (!isgraph(buffer->string[input->start])){
- while(buffer->string[input->start] != f_eol){
+ if (!isgraph(buffer->string[input->start])) {
+ while(buffer->string[input->start] != f_eol) {
++input->start;
- if (input->start >= buffer->used){
+ if (input->start >= buffer->used) {
found->array[found->used].stop = input->stop;
found->used++;
return f_none_on_eos;
}
- if (input->start > input->stop){
+ if (input->start > input->stop) {
found->array[found->used].stop = input->stop;
found->used++;
return f_none_on_stop;
has_newlines = f_true;
last_newline = input->start;
break;
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length first_slash = input->start;
++input->start;
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits here if a basic list opener would follow the slash
- if (buffer->string[input->start] == f_fss_basic_list_open){
+ if (buffer->string[input->start] == f_fss_basic_list_open) {
f_string_length open_position = input->start;
++input->start;
fl_macro_fss_skip_past_whitespace((*buffer), (*input))
- if (has_newlines){
+ if (has_newlines) {
// In this case, assume a valid object was found when eos/eof was reached and reset the start position
fl_macro_fss_content_return_on_overflow_reset((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop, last_newline)
} else {
}
// found a would be valid basic list object, so apply the delimit
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
buffer->string[first_slash] = f_fss_delimit_placeholder;
has_newlines = f_true;
last_newline = input->start;
++input->start;
continue;
}
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length second_slash = input->start;
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_basic_list_open){
+ if (buffer->string[input->start] == f_fss_basic_list_open) {
f_string_length open_position = input->start;
++input->start;
fl_macro_fss_skip_past_whitespace((*buffer), (*input))
- if (has_newlines){
+ if (has_newlines) {
// In this case, assume a valid object was found when eos/eof was reached and reset the start position
fl_macro_fss_content_return_on_overflow_reset((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop, last_newline)
} else {
}
// found a valid basic list object
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
// the content should not apply delimits for valid objects
- if (has_newlines){
+ if (has_newlines) {
input->start = last_newline;
found->array[found->used].stop = input->start - 1;
input->start++;
continue;
}
}
- } else if (buffer->string[input->start] == f_fss_basic_list_open){
+ } else if (buffer->string[input->start] == f_fss_basic_list_open) {
f_string_length open_position = input->start;
input->start++;
fl_macro_fss_skip_past_whitespace((*buffer), (*input))
- if (has_newlines){
+ if (has_newlines) {
// In this case, assume a valid object was found when eos/eof was reached and reset the start position
fl_macro_fss_content_return_on_overflow_reset((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop, last_newline)
} else {
}
// found a valid basic list object
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
// the content should not apply delimits for valid objects
- if (has_newlines){
+ if (has_newlines) {
input->start = last_newline;
found->array[found->used].stop = input->start - 1;
input->start++;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop)
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
has_newlines = f_true;
last_newline = input->start;
break;
}
// close quotes do not need to be delimited in this case as a valid quoted object must end with: ":\n
- if (buffer->string[input->start] == quoted){
+ if (buffer->string[input->start] == quoted) {
// at this point, a valid object will need to be determined
// if nothing else is between the colon and the newline, then a valid object has been found
// otherwise restart the loop at this new position, looking for the next proper close quote
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop)
- if (buffer->string[input->start] == f_fss_basic_list_open){
+ if (buffer->string[input->start] == f_fss_basic_list_open) {
input->start++;
fl_macro_fss_skip_past_whitespace((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
- if (buffer->string[input->start] == f_eol){
- if (has_newlines){
+ if (buffer->string[input->start] == f_eol) {
+ if (has_newlines) {
input->start = last_newline;
found->array[found->used].stop = input->start - 1;
input->start++;
#endif
#ifndef _di_fl_fss_extended_object_read_
- f_return_status fl_fss_extended_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found){
+ f_return_status fl_fss_extended_object_read(f_dynamic_string *buffer, f_string_location *input, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (input == f_null) return f_invalid_parameter;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_error_on_eos, f_error_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_fss_extended_close){
+ if (buffer->string[input->start] == f_fss_extended_close) {
input->start++;
return fl_fss_found_no_object;
}
found->start = input->start;
// ignore all comment lines
- if (buffer->string[input->start] == f_fss_comment){
+ if (buffer->string[input->start] == f_fss_comment) {
fl_macro_fss_object_seek_till_newline((*buffer), (*input), f_error_on_eos, f_error_on_stop)
input->start++;
f_autochar quoted = f_eos;
// identify where the object begins
- if (buffer->string[input->start] == f_fss_delimit_slash){
+ if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length first_slash = input->start;
input->start++;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits if a delimit quote would follow the slash (or a slash and a delimit quote follows)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
location = first_slash;
has_delimit = f_true;
quoted = buffer->string[input->start];
input->start++;
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
do{
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
location = first_slash;
has_delimit = f_true;
quoted = buffer->string[input->start];
}
} while (buffer->string[input->start] == f_fss_delimit_slash);
}
- } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
quoted = buffer->string[input->start];
input->start++;
location = input->start;
}
// identify where the object ends
- if (quoted == f_eos){
- while (isgraph(buffer->string[input->start]) || buffer->string[input->start] == f_fss_delimit_placeholder){
+ if (quoted == f_eos) {
+ while (isgraph(buffer->string[input->start]) || buffer->string[input->start] == f_fss_delimit_placeholder) {
++input->start;
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
} // while
- if (isspace(buffer->string[input->start])){
+ if (isspace(buffer->string[input->start])) {
found->stop = input->start - 1;
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
input->start++;
return fl_fss_found_object_no_content;
}
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_eol){
- if (found_space){
+ if (buffer->string[input->start] == f_eol) {
+ if (found_space) {
found->stop = pre_space;
input->start = pre_space;
} else {
f_status status = f_status_initialize;
f_delete_string_lengths(status, delimits)
- if (found_space){
+ if (found_space) {
return fl_fss_found_object;
} else {
return fl_fss_found_object_no_content;
}
} else if (isspace(buffer->string[input->start])) {
- if (!found_space){
+ if (!found_space) {
pre_space = input->start - 1;
found_space = f_true;
}
if (isspace(buffer->string[input->start])) {
// this quote is a valid object close quote, so handle appropriately
- if (has_delimit){
+ if (has_delimit) {
buffer->string[location] = f_fss_delimit_placeholder;
- if (ignore_quotes){
- if (found_space){
+ if (ignore_quotes) {
+ if (found_space) {
found->stop = pre_space;
input->start = pre_space;
} else {
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits here if whitespace would follow the quote
- if (buffer->string[input->start] == quoted){
+ if (buffer->string[input->start] == quoted) {
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (isspace(buffer->string[input->start])){
- if (delimits.used >= delimits.size){
+ if (isspace(buffer->string[input->start])) {
+ if (delimits.used >= delimits.size) {
f_status status = f_status_initialize;
f_resize_string_lengths(status, delimits, delimits.size + f_fss_default_allocation_step);
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits here if whitespace would follow the quote
- if (buffer->string[input->start] == quoted){
+ if (buffer->string[input->start] == quoted) {
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (isspace(buffer->string[input->start])){
- if (delimits.used >= delimits.size){
+ if (isspace(buffer->string[input->start])) {
+ if (delimits.used >= delimits.size) {
f_status status = f_status_initialize;
f_resize_string_lengths(status, delimits, delimits.size + f_fss_default_allocation_step);
}
// seek to the end of the line
- while(input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_eol){
+ while(input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_eol) {
++input->start;
}
#endif // _di_fl_fss_extended_object_read_
#ifndef _di_fl_fss_extended_content_read_
- f_return_status fl_fss_extended_content_read(f_dynamic_string *buffer, f_string_location *input, f_fss_content *found){
+ f_return_status fl_fss_extended_content_read(f_dynamic_string *buffer, f_string_location *input, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (input == f_null) return f_invalid_parameter;
fl_macro_fss_allocate_content_if_necessary((*found))
found->array[found->used].start = input->start;
- while (input->start <= input->stop){
+ while (input->start <= input->stop) {
// get past all leading spaces/tabs (allowed)
fl_macro_fss_skip_past_whitespace((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_eol){
+ if (buffer->string[input->start] == f_eol) {
break;
}
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// handle delimited quotes, single quotes, and double quotes
- if (buffer->string[input->start] == f_fss_delimit_slash){
+ if (buffer->string[input->start] == f_fss_delimit_slash) {
do{
f_string_length first_slash = input->start;
++input->start;
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits if a delimit quote would follow the slash (or a slash and a delimit quote follows)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
// because the slash properly delimited the quote, the quote then becomes the start of the content
found->array[found->used].start = input->start;
buffer->string[first_slash] = f_fss_delimit_placeholder;
break;
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length second_slash = input->start;
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
buffer->string[first_slash] = f_fss_delimit_placeholder;
quoted = buffer->string[input->start];
break;
}
} while (f_true);
- } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote){
+ } else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
quoted = buffer->string[input->start];
input->start++;
}
// when quoted is null, then spaces will end the content, otherwise the quote defined in quoted will end the content (or a newline)
- if (quoted == f_eos){
+ if (quoted == f_eos) {
do{
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_extended_close){
+ if (buffer->string[input->start] == f_fss_extended_close) {
// Save the stop point
found->array[found->used].stop = input->start - 1;
found->used++;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_extended_close){
+ if (buffer->string[input->start] == f_fss_extended_close) {
input->start++;
return f_unterminated_group;
}
// handle delimited quotes
- if (buffer->string[input->start] == f_fss_delimit_slash){
+ if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length first_slash = input->start;
++input->start;
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_none_on_eos, f_none_on_stop)
// A slash only delimits if a delimit quote would follow the slash (or a slash and a delimit quote follows)
- if (buffer->string[input->start] == quoted){
+ if (buffer->string[input->start] == quoted) {
buffer->string[first_slash] = f_fss_delimit_placeholder;
++input->start;
continue;
- } else if (buffer->string[input->start] == f_fss_delimit_slash){
+ } else if (buffer->string[input->start] == f_fss_delimit_slash) {
f_string_length second_slash = input->start;
++input->start;
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), f_unterminated_group_on_eos, f_unterminated_group_on_stop)
- if (buffer->string[input->start] == quoted){
+ if (buffer->string[input->start] == quoted) {
buffer->string[first_slash] = f_fss_delimit_placeholder;
quoted = f_eos;
break;
continue;
}
}
- } else if (buffer->string[input->start] == quoted){
+ } else if (buffer->string[input->start] == quoted) {
quoted = f_eos;
break;
}
}
// When original is the same as the current found->used, then there was no data found
- if (original == found->used){
+ if (original == found->used) {
input->start++;
return fl_fss_found_no_content;
}
#ifndef _di_fl_macro_fss_skip_past_whitespace_
#define fl_macro_fss_skip_past_whitespace(buffer, input) \
- while (!isgraph(buffer.string[input.start]) || buffer.string[input.start] == f_fss_delimit_placeholder){ \
+ while (!isgraph(buffer.string[input.start]) || buffer.string[input.start] == f_fss_delimit_placeholder) { \
if (buffer.string[input.start] == f_eol) break; \
\
++input.start;\
#ifndef _di_fl_macro_fss_skip_past_all_whitespace_
#define fl_macro_fss_skip_past_all_whitespace(buffer, input) \
- while (!isgraph(buffer.string[input.start]) || buffer.string[input.start] == f_fss_delimit_placeholder){ \
+ while (!isgraph(buffer.string[input.start]) || buffer.string[input.start] == f_fss_delimit_placeholder) { \
++input.start;\
\
if (input.start >= buffer.used) break; \
#ifndef _di_fl_macro_fss_skip_past_delimit_placeholders_
#define fl_macro_fss_skip_past_delimit_placeholders(buffer, input) \
- while (buffer.string[input.start] == f_fss_delimit_placeholder){ \
+ while (buffer.string[input.start] == f_fss_delimit_placeholder) { \
++input.start;\
\
if (input.start >= buffer.used) break; \
#ifndef _di_fl_macro_fss_object_return_on_overflow_
#define fl_macro_fss_object_return_on_overflow(buffer, input, found, eos_status, stop_status) \
- if (input.start >= buffer.used){ \
+ if (input.start >= buffer.used) { \
found.stop = buffer.used - 1; \
return eos_status; \
- } else if (input.start > input.stop){ \
+ } else if (input.start > input.stop) { \
found.stop = input.stop; \
return stop_status; \
}
#ifndef _di_fl_macro_fss_content_return_on_overflow_
#define fl_macro_fss_content_return_on_overflow(buffer, input, found, eos_status, stop_status) \
- if (input.start >= buffer.used){ \
+ if (input.start >= buffer.used) { \
found.array[found.used].stop = buffer.used - 1; \
return eos_status; \
- } else if (input.start > input.stop){ \
+ } else if (input.start > input.stop) { \
found.array[found.used].stop = input.stop; \
return stop_status; \
}
#ifndef _di_fl_macro_fss_content_return_on_overflow_reset_
#define fl_macro_fss_content_return_on_overflow_reset(buffer, input, found, eos_status, stop_status, set_stop) \
- if (input.start >= buffer.used){ \
+ if (input.start >= buffer.used) { \
input.start = set_stop; \
found.array[found.used].stop = set_stop; \
return eos_status; \
- } else if (input.start > input.stop){ \
+ } else if (input.start > input.stop) { \
input.start = set_stop; \
found.array[found.used].stop = set_stop; \
return stop_status; \
#ifndef _di_fl_macro_fss_allocate_content_if_necessary_
#define fl_macro_fss_allocate_content_if_necessary(content) \
- if (content.used >= content.size){ \
+ if (content.used >= content.size) { \
f_status status = f_status_initialize; \
\
f_resize_fss_content(status, content, content.size + f_fss_default_allocation_step); \
#ifndef _di_fl_macro_fss_object_seek_till_newline_
#define fl_macro_fss_object_seek_till_newline(buffer, input, eos_status, stop_status) \
- while(buffer.string[input.start] != f_eol){ \
+ while(buffer.string[input.start] != f_eol) { \
++input.start; \
- if (input.start >= buffer.used){ \
+ if (input.start >= buffer.used) { \
return eos_status; \
} \
- if (input.start > input.stop){ \
+ if (input.start > input.stop) { \
return stop_status; \
} \
} // while
#ifndef _di_fl_macro_fss_content_seek_till_newline_
#define fl_macro_fss_content_seek_till_newline(buffer, input, found, eos_status, stop_status) \
- while(buffer.string[input.start] != f_eol){ \
+ while(buffer.string[input.start] != f_eol) { \
++input.start; \
- if (input.start >= buffer.used){ \
+ if (input.start >= buffer.used) { \
found.array[found.used].stop = input.stop; \
return eos_status; \
} \
- if (input.start > input.stop){ \
+ if (input.start > input.stop) { \
found.array[found.used].stop = input.stop; \
return stop_status; \
} \
location->stop = 0;
while (i < serialized.used) {
- if (current == index){
+ if (current == index) {
if (location->start > location->stop) {
location->start = i;
location->stop = i;
#endif
#ifndef _di_fl_rip_string_
- f_return_status fl_rip_string(const f_dynamic_string buffer, const f_string_location position, f_dynamic_string *results){
+ f_return_status fl_rip_string(const f_dynamic_string buffer, const f_string_location position, f_dynamic_string *results) {
#ifndef _di_level_1_parameter_checking_
if (results == f_null) return f_invalid_parameter;
if (position.start < 0) return f_invalid_parameter;
// the start and stop point are inclusive locations, and therefore start - stop is actually 1 too few locations
f_string_length size = position.stop - position.start + 1;
- if (size > 0){
+ if (size > 0) {
f_status status = f_status_initialize;
f_resize_dynamic_string(status, (*results), size);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
#endif // _di_fl_rip_string_
#ifndef _di_fl_seek_line_past_non_graph_
- f_return_status fl_seek_line_past_non_graph(const f_dynamic_string buffer, f_string_location *position, const f_autochar placeholder){
+ f_return_status fl_seek_line_past_non_graph(const f_dynamic_string buffer, f_string_location *position, const f_autochar placeholder) {
#ifndef _di_level_1_parameter_checking_
if (position == f_null) return f_invalid_parameter;
if (position->start < 0) return f_invalid_parameter;
if (position->start >= buffer.used) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
- while (!isgraph(buffer.string[position->start]) || buffer.string[position->start] == placeholder){
+ while (!isgraph(buffer.string[position->start]) || buffer.string[position->start] == placeholder) {
if (buffer.string[position->start] == f_eol) return f_none;
++position->start;
#endif // _di_fl_seek_line_past_non_graph_
#ifndef _di_fl_seek_line_until_non_graph_
- f_return_status fl_seek_line_until_non_graph(const f_dynamic_string buffer, f_string_location *position, const f_autochar placeholder){
+ f_return_status fl_seek_line_until_non_graph(const f_dynamic_string buffer, f_string_location *position, const f_autochar placeholder) {
#ifndef _di_level_1_parameter_checking_
if (position->start < 0) return f_invalid_parameter;
if (position->stop < position->start) return f_invalid_parameter;
if (position->start >= buffer.used) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
- while (isgraph(buffer.string[position->start]) || buffer.string[position->start] == placeholder){
+ while (isgraph(buffer.string[position->start]) || buffer.string[position->start] == placeholder) {
if (buffer.string[position->start] == f_eol) return f_none;
++position->start;
#endif // _di_fl_seek_line_until_non_graph_
#ifndef _di_fl_seek_to_
- f_return_status fl_seek_to(const f_dynamic_string buffer, f_string_location *position, const f_autochar seek_to_this){
+ f_return_status fl_seek_to(const f_dynamic_string buffer, f_string_location *position, const f_autochar seek_to_this) {
#ifndef _di_level_1_parameter_checking_
if (position->start < 0) return f_invalid_parameter;
if (position->stop < position->start) return f_invalid_parameter;
if (position->start >= buffer.used) return f_invalid_parameter;
#endif // _di_level_1_parameter_checking_
- while (buffer.string[position->start] != seek_to_this){
+ while (buffer.string[position->start] != seek_to_this) {
if (buffer.string[position->start] == f_eol) return f_none;
++position->start;
#endif // _di_fl_seek_to_
#ifndef _di_fl_compare_strings_
- f_return_status fl_compare_strings(const f_string string1, const f_string string2, const f_string_length length1, const f_string_length length2){
+ f_return_status fl_compare_strings(const f_string string1, const f_string string2, const f_string_length length1, const f_string_length length2) {
#ifndef _di_level_1_parameter_checking_
if (length1 <= 0) return f_invalid_parameter;
if (length2 <= 0) return f_invalid_parameter;
f_string_length stop1 = length1;
f_string_length stop2 = length2;
- for (; i1 < stop1 && i2 < stop2; i1++, i2++){
+ for (; i1 < stop1 && i2 < stop2; i1++, i2++) {
while (i1 < stop1 && string1[i1] == f_eos) i1++;
while (i2 < stop2 && string2[i2] == f_eos) i2++;
if (string1[i1] != string2[i2]) return f_not_equal_to;
} // for()
- while (i1 < stop1){
+ while (i1 < stop1) {
if (string1[i1] != f_eos) return f_not_equal_to;
i1++;
} // while()
- while (i2 < stop2){
+ while (i2 < stop2) {
if (string2[i2] != f_eos) return f_not_equal_to;
i2++;
} // while()
#endif // _di_fl_compare_strings_
#ifndef _di_fl_compare_dynamic_strings_
- f_return_status fl_compare_dynamic_strings(const f_dynamic_string string1, const f_dynamic_string string2){
+ f_return_status fl_compare_dynamic_strings(const f_dynamic_string string1, const f_dynamic_string string2) {
#ifndef _di_level_1_parameter_checking_
if (string1.used <= 0) return f_invalid_parameter;
if (string2.used <= 0) return f_invalid_parameter;
f_string_length stop1 = string1.used;
f_string_length stop2 = string2.used;
- for (; i1 < stop1 && i2 < stop2; i1++, i2++){
+ for (; i1 < stop1 && i2 < stop2; i1++, i2++) {
while (i1 < stop1 && string1.string[i1] == f_eos) i1++;
while (i2 < stop2 && string2.string[i2] == f_eos) i2++;
if (string1.string[i1] != string2.string[i2]) return f_not_equal_to;
} // for()
- while (i1 < stop1){
+ while (i1 < stop1) {
if (string1.string[i1] != f_eos) return f_not_equal_to;
i1++;
} // while()
- while (i2 < stop2){
+ while (i2 < stop2) {
if (string2.string[i2] != f_eos) return f_not_equal_to;
i2++;
} // while()
#endif // _di_fl_compare_dynamic_strings_
#ifndef _di_fl_compare_partial_dynamic_strings_
- f_return_status fl_compare_partial_dynamic_strings(const f_dynamic_string string1, const f_dynamic_string string2, const f_string_location offset1, const f_string_location offset2){
+ f_return_status fl_compare_partial_dynamic_strings(const f_dynamic_string string1, const f_dynamic_string string2, const f_string_location offset1, const f_string_location offset2) {
#ifndef _di_level_1_parameter_checking_
if (string1.used <= 0) return f_invalid_parameter;
if (string2.used <= 0) return f_invalid_parameter;
f_string_length stop1 = offset1.stop + 1;
f_string_length stop2 = offset2.stop + 1;
- for (; i1 < stop1 && i2 < stop2; i1++, i2++){
+ for (; i1 < stop1 && i2 < stop2; i1++, i2++) {
while (i1 < stop1 && string1.string[i1] == f_eos) i1++;
while (i2 < stop2 && string2.string[i2] == f_eos) i2++;
if (string1.string[i1] != string2.string[i2]) return f_not_equal_to;
} // for()
- while (i1 < stop1){
+ while (i1 < stop1) {
if (string1.string[i1] != f_eos) return f_not_equal_to;
i1++;
} // while()
- while (i2 < stop2){
+ while (i2 < stop2) {
if (string2.string[i2] != f_eos) return f_not_equal_to;
i2++;
} // while()
#endif
#ifndef _di_fll_colors_load_context_
- f_return_status fll_colors_load_context(fll_color_context *data, f_bool use_light_colors){
+ f_return_status fll_colors_load_context(fll_color_context *data, f_bool use_light_colors) {
#ifndef _di_level_2_parameter_checking_
if (data == 0) return f_invalid_parameter;
#endif // _di_level_2_parameter_checking_
{
f_autochar *environment = getenv("TERM");
- if (!environment || strncmp(environment, "linux", 6) == 0){
+ if (!environment || strncmp(environment, "linux", 6) == 0) {
data->color_list = f_colors_linux;
} else {
data->color_list = f_colors_xterminal;
}
// load the colors
- if (use_light_colors){
+ if (use_light_colors) {
status = fl_save_color1(&data->reset, data->color_format, data->color_list.reset);
if (status == f_none) status = fl_save_color1(&data->warning, data->color_format, data->color_list.yellow);
#endif
#ifndef _di_fll_execute_path_
- f_return_status fll_execute_path(const f_string program_path, const f_dynamic_strings arguments, f_s_int *results){
+ f_return_status fll_execute_path(const f_string program_path, const f_dynamic_strings arguments, f_s_int *results) {
#ifndef _di_level_2_parameter_checking_
if (results == f_null) return f_invalid_parameter;
last_slash = strrchr(program_path, '/');
- if (last_slash != f_null){
+ if (last_slash != f_null) {
name_size = strnlen(last_slash, PATH_MAX);
- if (name_size > 1){
+ if (name_size > 1) {
f_new_string(status, program_name, name_size + 1);
if (f_macro_test_for_allocation_errors(status)) return status;
status = f_new_array((void **) & arguments_array, sizeof(f_autochar **), arguments.used + 2);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
f_status tmp_status = f_status_initialize;
f_delete_string(tmp_status, program_name, name_size);
arguments_array[0] = program_name;
counter++;
- for (; counter < arguments.used; counter++){
+ for (; counter < arguments.used; counter++) {
arguments_array[counter] = arguments.array[counter].string;
}
process_id = vfork();
- if (process_id < 0){
+ if (process_id < 0) {
return f_fork_failed;
}
- if (process_id == 0){ // child
+ if (process_id == 0) { // child
execv(program_path, arguments_array);
// according to manpages, calling _exit() is safer and should be called here instead of exit()
#endif // _di_fll_execute_path_
#ifndef _di_fll_execute_program_
- f_return_status fll_execute_program(const f_string program_name, const f_dynamic_strings arguments, f_s_int *results){
+ f_return_status fll_execute_program(const f_string program_name, const f_dynamic_strings arguments, f_s_int *results) {
#ifndef _di_level_2_parameter_checking_
if (results == f_null) return f_invalid_parameter;
arguments_array[0] = program_name;
counter++;
- for (; counter < arguments.used; counter++){
+ for (; counter < arguments.used; counter++) {
arguments_array[counter] = arguments.array[counter].string;
}
process_id = vfork();
- if (process_id < 0){
+ if (process_id < 0) {
return f_fork_failed;
}
- if (process_id == 0){ // child
+ if (process_id == 0) { // child
execvp(program_name, arguments_array);
// according to manpages, calling _exit() is safer and should be called here instead of exit()
#endif
#ifndef _di_fll_fss_basic_read_
- f_return_status fll_fss_basic_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents){
+ f_return_status fll_fss_basic_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents) {
#ifndef _di_level_2_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (objects == f_null) return f_invalid_parameter;
f_bool found_data = f_false;
do {
- if (objects->used >= objects->size){
+ if (objects->used >= objects->size) {
f_resize_fss_objects(status, (*objects), objects->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
f_resize_fss_contents(status, (*contents), contents->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
}
do {
status = fl_fss_basic_object_read(buffer, input, &objects->array[objects->used]);
- if (input->start >= input->stop || input->start >= buffer->used){
- if (status == fl_fss_found_object || status == fl_fss_found_object_no_content){
+ if (input->start >= input->stop || input->start >= buffer->used) {
+ if (status == fl_fss_found_object || status == fl_fss_found_object_no_content) {
objects->used++;
fl_macro_fss_allocate_content_if_necessary(contents->array[contents->used]);
return fl_fss_found_object_no_content;
}
- if (found_data){
- if (input->start >= buffer->used){
+ if (found_data) {
+ if (input->start >= buffer->used) {
return f_none_on_eos;
}
return f_none_on_stop;
} else {
- if (input->start >= buffer->used){
+ if (input->start >= buffer->used) {
return f_no_data_on_eos;
}
}
}
- if (status == fl_fss_found_object){
+ if (status == fl_fss_found_object) {
found_data = f_true;
status = fl_fss_basic_content_read(buffer, input, &contents->array[contents->used]);
break;
- } else if (status == fl_fss_found_object_no_content){
+ } else if (status == fl_fss_found_object_no_content) {
found_data = f_true;
fl_macro_fss_allocate_content_if_necessary(contents->array[contents->used]);
}
} while (status == fl_fss_found_no_object);
- if (status == f_none_on_eos || status == f_none_on_stop){
+ if (status == f_none_on_eos || status == f_none_on_stop) {
contents->array[contents->used].used++;
objects->used++;
contents->used++;
return status;
- } else if (status == f_no_data_on_eos || status == f_no_data_on_stop){
+ } 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 (objects->used > initial_used){
+ 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;
}
return status;
- } 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){
+ } 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
- } 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){
+ } 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++;
contents->used++;
}
- if (input->start >= buffer->used){
+ if (input->start >= buffer->used) {
return f_none_on_eos;
}
#endif
#ifndef _di_fll_fss_basic_list_read_
- f_return_status fll_fss_basic_list_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents){
+ f_return_status fll_fss_basic_list_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents) {
#ifndef _di_level_2_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (objects == f_null) return f_invalid_parameter;
f_bool found_data = f_false;
do {
- if (objects->used >= objects->size){
+ if (objects->used >= objects->size) {
f_resize_fss_objects(status, (*objects), objects->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
f_resize_fss_contents(status, (*contents), contents->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
}
do {
status = fl_fss_basic_list_object_read(buffer, input, &objects->array[objects->used]);
- if (input->start >= input->stop || input->start >= buffer->used){
- if (status == fl_fss_found_object || status == fl_fss_found_object_no_content){
+ if (input->start >= input->stop || input->start >= buffer->used) {
+ if (status == fl_fss_found_object || status == fl_fss_found_object_no_content) {
objects->used++;
fl_macro_fss_allocate_content_if_necessary(contents->array[contents->used]);
return fl_fss_found_object_no_content;
}
- if (found_data){
- if (input->start >= buffer->used){
+ if (found_data) {
+ if (input->start >= buffer->used) {
return f_none_on_eos;
}
return f_none_on_stop;
} else {
- if (input->start >= buffer->used){
+ if (input->start >= buffer->used) {
return f_no_data_on_eos;
}
}
}
- if (status == fl_fss_found_object){
+ if (status == fl_fss_found_object) {
found_data = f_true;
status = fl_fss_basic_list_content_read(buffer, input, &contents->array[contents->used]);
break;
- } else if (status == fl_fss_found_object_no_content){
+ } else if (status == fl_fss_found_object_no_content) {
found_data = f_true;
fl_macro_fss_allocate_content_if_necessary(contents->array[contents->used]);
}
} while (status == fl_fss_found_no_object);
- if (status == f_none_on_eos || status == f_none_on_stop){
+ if (status == f_none_on_eos || status == f_none_on_stop) {
contents->array[contents->used].used++;
objects->used++;
contents->used++;
return status;
- } else if (status == f_no_data_on_eos || status == f_no_data_on_stop){
+ } 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 equivalents
- if (objects->used > initial_used){
+ 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;
}
return status;
- } 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){
+ } 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
- } 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){
+ } 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++;
contents->used++;
}
- if (input->start >= buffer->used){
+ if (input->start >= buffer->used) {
return f_none_on_eos;
}
if (string == f_null) return f_invalid_parameter;
#endif // _di_level_2_parameter_checking_
- switch(error){
+ switch(error) {
#ifndef _di_fll_fss_errors_error_
case fl_fss_invalid_format:
*string = "fl_fss_invalid_format";
#ifndef _di_fll_fss_errors_is_warning_
f_return_status fll_fss_errors_is_warning(const f_status error) {
- switch(error){
+ switch(error) {
#ifndef _di_fll_fss_errors_basic_
case f_no_data:
return f_true;
#ifndef _di_fll_fss_errors_is_okay_
f_return_status fll_fss_errors_is_okay(const f_status error) {
- switch(error){
+ switch(error) {
#ifndef _di_fll_fss_errors_booleans_
case f_false:
return f_true;
#endif
#ifndef _di_fll_fss_extended_read_
- f_return_status fll_fss_extended_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents){
+ f_return_status fll_fss_extended_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents) {
#ifndef _di_level_2_parameter_checking_
if (buffer == f_null) return f_invalid_parameter;
if (objects == f_null) return f_invalid_parameter;
f_bool found_data = f_false;
do {
- if (objects->used >= objects->size){
+ if (objects->used >= objects->size) {
f_resize_fss_objects(status, (*objects), objects->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
f_resize_fss_contents(status, (*contents), contents->used + f_fss_default_allocation_step);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
return status;
}
}
do {
status = fl_fss_extended_object_read(buffer, input, &objects->array[objects->used]);
- if (input->start >= input->stop || input->start >= buffer->used){
- if (status == fl_fss_found_object || status == fl_fss_found_object_no_content){
+ if (input->start >= input->stop || input->start >= buffer->used) {
+ if (status == fl_fss_found_object || status == fl_fss_found_object_no_content) {
objects->used++;
fl_macro_fss_allocate_content_if_necessary(contents->array[contents->used]);
return fl_fss_found_object_no_content;
}
- if (found_data){
- if (input->start >= buffer->used){
+ if (found_data) {
+ if (input->start >= buffer->used) {
return f_none_on_eos;
}
return f_none_on_stop;
} else {
- if (input->start >= buffer->used){
+ if (input->start >= buffer->used) {
return f_no_data_on_eos;
}
}
}
- if (status == fl_fss_found_object){
+ if (status == fl_fss_found_object) {
found_data = f_true;
status = fl_fss_extended_content_read(buffer, input, &contents->array[contents->used]);
break;
- } else if (status == fl_fss_found_object_no_content){
+ } else if (status == fl_fss_found_object_no_content) {
found_data = f_true;
fl_macro_fss_allocate_content_if_necessary(contents->array[contents->used]);
}
} while (status == fl_fss_found_no_object);
- if (status == f_none_on_eos || status == f_none_on_stop){
+ if (status == f_none_on_eos || status == f_none_on_stop) {
contents->array[contents->used].used++;
objects->used++;
contents->used++;
return status;
- } else if (status == f_no_data_on_eos || status == f_no_data_on_stop){
+ } 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 (objects->used > initial_used){
+ 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;
}
return status;
- } 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){
+ } 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
- } 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){
+ } 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++;
contents->used++;
}
- if (input->start >= buffer->used){
+ if (input->start >= buffer->used) {
return f_none_on_eos;
}
// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
#ifndef _di_firewall_print_version_
- f_return_status firewall_print_version(const firewall_data data){
+ f_return_status firewall_print_version(const firewall_data data) {
printf("%s\n", firewall_version);
return f_none;
#endif // _firewall_print_version_
#ifndef _di_firewall_print_help_
- f_return_status firewall_print_help(const firewall_data data){
+ f_return_status firewall_print_help(const firewall_data data) {
printf("\n");
fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", firewall_name_long);
#ifndef _di_firewall_main_
f_return_status firewall_perform_commands(const f_fss_objects objects, const f_fss_contents contents, const f_bool is_global, const f_string_length this_device, const f_dynamic_string buffer, const firewall_data data) __attribute__((visibility("internal")));
- f_return_status firewall_main(const f_s_int argc, const f_string argv[], firewall_data *data){
+ f_return_status firewall_main(const f_s_int argc, const f_string argv[], firewall_data *data) {
f_status status = f_status_initialize;
f_status allocation_status = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, firewall_total_parameters, &data->remaining);
// load colors when not told to show no colors
- if (data->parameters[firewall_parameter_no_color].result == f_console_result_none){
+ if (data->parameters[firewall_parameter_no_color].result == f_console_result_none) {
fll_new_color_context(allocation_status, data->context);
- if (allocation_status == f_none){
+ if (allocation_status == f_none) {
fll_colors_load_context(&data->context, data->parameters[firewall_parameter_light].result == f_console_result_found);
} else {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
}
}
- if (status != f_none){
- if (status == f_no_data){
+ if (status != f_none) {
+ if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
// to do this, one must look for any "has_additional" and then see if the "additiona" location is set to 0
// nothing can be 0 as that represents the program name, unless argv[] is improperly created
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- } else if (status == f_invalid_parameter){
+ } else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", status);
}
// execute parameter results
- if (data->parameters[firewall_parameter_help].result == f_console_result_found){
+ if (data->parameters[firewall_parameter_help].result == f_console_result_found) {
firewall_print_help(*data);
- } else if (data->parameters[firewall_parameter_version].result == f_console_result_found){
+ } else if (data->parameters[firewall_parameter_version].result == f_console_result_found) {
firewall_print_version(*data);
} else {
// now determine which command was placed first
f_bool found_command = f_false;
f_u_int command = 0;
- if (data->parameters[firewall_parameter_command_start].result == f_console_result_found){
+ if (data->parameters[firewall_parameter_command_start].result == f_console_result_found) {
command = firewall_parameter_command_start;
found_command = f_true;
}
- if (data->parameters[firewall_parameter_command_stop].result == f_console_result_found){
- if (found_command){
- if (data->parameters[command].additional > data->parameters[firewall_parameter_command_stop].additional){
+ if (data->parameters[firewall_parameter_command_stop].result == f_console_result_found) {
+ if (found_command) {
+ if (data->parameters[command].additional > data->parameters[firewall_parameter_command_stop].additional) {
command = firewall_parameter_command_stop;
}
} else {
}
}
- if (data->parameters[firewall_parameter_command_restart].result == f_console_result_found){
- if (found_command){
- if (data->parameters[command].additional > data->parameters[firewall_parameter_command_restart].additional){
+ if (data->parameters[firewall_parameter_command_restart].result == f_console_result_found) {
+ if (found_command) {
+ if (data->parameters[command].additional > data->parameters[firewall_parameter_command_restart].additional) {
command = firewall_parameter_command_restart;
}
} else {
}
}
- if (data->parameters[firewall_parameter_command_lock].result == f_console_result_found){
- if (found_command){
- if (data->parameters[command].additional > data->parameters[firewall_parameter_command_lock].additional){
+ if (data->parameters[firewall_parameter_command_lock].result == f_console_result_found) {
+ if (found_command) {
+ if (data->parameters[command].additional > data->parameters[firewall_parameter_command_lock].additional) {
command = firewall_parameter_command_lock;
}
} else {
}
}
- if (data->parameters[firewall_parameter_command_show].result == f_console_result_found){
- if (found_command){
- if (data->parameters[command].additional > data->parameters[firewall_parameter_command_show].additional){
+ if (data->parameters[firewall_parameter_command_show].result == f_console_result_found) {
+ if (found_command) {
+ if (data->parameters[command].additional > data->parameters[firewall_parameter_command_show].additional) {
command = firewall_parameter_command_show;
}
} else {
}
}
- if (found_command){
+ if (found_command) {
// load the global file
{
f_file file = f_file_initialize;
status = f_file_open(&file, (f_string) network_path firewall_file_default);
- if (status != f_none){
- if (status == f_invalid_parameter){
+ if (status != f_none) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- } else if (status == f_file_not_found){
+ } else if (status == f_file_not_found) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", network_path firewall_file_default);
- } else if (status == f_file_open_error){
+ } else if (status == f_file_open_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", network_path firewall_file_default);
- } else if (status == f_file_descriptor_error){
+ } else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", network_path firewall_file_default);
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
// TODO: this file size set functionality might be turned into an fl_file (or f_file) function
- if (data->file_position.total_elements == 0){
+ if (data->file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
data->file_position.total_elements = ftell(file.file);
fseek(file.file, 0, SEEK_SET);
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eof) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
- } else if (status == f_overflow){
+ } else if (status == f_overflow) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", network_path firewall_file_default);
- } else if (status == f_file_not_open){
+ } else if (status == f_file_not_open) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", network_path firewall_file_default);
- } else if (status == f_file_seek_error){
+ } else if (status == f_file_seek_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", network_path firewall_file_default);
- } else if (status == f_file_read_error){
+ } else if (status == f_file_read_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", network_path firewall_file_default);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", status);
status = fll_fss_basic_list_read(&data->buffer, &input, &data->objects, &data->contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", network_path firewall_file_default);
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop){
+ } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: No relevant data was found within the file '%s'", network_path firewall_file_default);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", status, network_path firewall_file_default);
}
}
- if (command == firewall_parameter_command_show){
+ if (command == firewall_parameter_command_show) {
// Warning: these are hardcoded print commands (I am not certain how I am going to implement external 'show' rules as the default-firewall setting file is the wrong place to put this)
f_bool show_nat = f_true;
f_bool show_mangle = f_true;
f_dynamic_strings arguments = f_dynamic_strings_initialize;
f_s_int results = 0;
- if (data->remaining.used > 0){
+ if (data->remaining.used > 0) {
show_nat = f_false;
show_mangle = f_false;
show_ports = f_false;
f_string_length counter = f_string_length_initialize;
- for (; counter < data->remaining.used; counter++){
- if (strncmp("nat", argv[data->remaining.array[counter]], 4) != 0){
- if (strncmp("mangle", argv[data->remaining.array[counter]], 7) != 0){
- if (strncmp("ports", argv[data->remaining.array[counter]], 6) != 0){
+ for (; counter < data->remaining.used; counter++) {
+ if (strncmp("nat", argv[data->remaining.array[counter]], 4) != 0) {
+ if (strncmp("mangle", argv[data->remaining.array[counter]], 7) != 0) {
+ if (strncmp("ports", argv[data->remaining.array[counter]], 6) != 0) {
fl_print_color_line(f_standard_warning, data->context.warning, data->context.reset, "WARNING: '%s' is not a valid show option", argv[data->remaining.array[counter]]);
} else {
show_ports = f_true;
f_resize_dynamic_strings(status, arguments, 7);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
firewall_delete_data(data);
return status;
}
- if (show_nat){
+ if (show_nat) {
fl_print_color(f_standard_output, data->context.standout, data->context.reset, "=========================== ");
fl_print_color(f_standard_output, data->context.title, data->context.reset, "NAT");
fl_print_color_line(f_standard_output, data->context.standout, data->context.reset, " ============================");
fflush(f_standard_output);
}
- if (status != f_failure && show_mangle){
+ if (status != f_failure && show_mangle) {
fl_print_color(f_standard_output, data->context.standout, data->context.reset, "========================== ");
fl_print_color(f_standard_output, data->context.title, data->context.reset, "MANGLE");
fl_print_color_line(f_standard_output, data->context.standout, data->context.reset, " ==========================");
fflush(f_standard_output);
}
- if (status != f_failure && show_ports){
+ if (status != f_failure && show_ports) {
fl_print_color(f_standard_output, data->context.standout, data->context.reset, "========================== ");
fl_print_color(f_standard_output, data->context.title, data->context.reset, "PORTS");
fl_print_color_line(f_standard_output, data->context.standout, data->context.reset, " ===========================");
fflush(f_standard_output);
}
- if (status == f_failure){
+ if (status == f_failure) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to perform requested %s operation:", firewall_program_name);
fprintf(f_standard_error, " ");
fl_print_color_code(f_standard_error, data->context.error);
- for (; i < arguments.used; i++){
+ for (; i < arguments.used; i++) {
fprintf(f_standard_error, "%s ", arguments.array[i].string);
}
fl_print_color_code(f_standard_error, data->context.reset);
fprintf(f_standard_error, "\n");
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
}
// load all network devices
status = fl_directory_list((f_string) network_devices, &data->devices);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
firewall_delete_data(data);
return status;
- } else if (status == f_no_data){
+ } else if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: could not find any network devices");
firewall_delete_data(data);
return status;
- } else if (status == f_failure){
+ } else if (status == f_failure) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to read the device directory '%s'", network_devices);
firewall_delete_data(data);
return status;
{
f_string_length counter = f_string_length_initialize;
- for (; counter < data->devices.used; counter++){
- if (fl_compare_strings((f_string) "lo", data->devices.array[counter].string, 3, data->devices.array[counter].used) == f_equal_to){
+ for (; counter < data->devices.used; counter++) {
+ if (fl_compare_strings((f_string) "lo", data->devices.array[counter].string, 3, data->devices.array[counter].used) == f_equal_to) {
f_dynamic_string swap_string = data->devices.array[counter];
data->devices.used--;
- for (; counter < data->devices.used; counter++){
+ for (; counter < data->devices.used; counter++) {
data->devices.array[counter] = data->devices.array[counter+1];
}
}
// if at least one specific device was specified, then only use the specified devices, otherwise use all
- if (data->remaining.used > 0){
+ if (data->remaining.used > 0) {
f_string_length device = f_string_length_initialize;
f_string_length counter = f_string_length_initialize;
f_string_length total = f_string_length_initialize;
f_string_length i = f_string_length_initialize;
f_bool matched = f_false;
- for (total = data->devices.used; device < total; device++){
+ for (total = data->devices.used; device < total; device++) {
matched = f_false;
- for (counter = 0; counter < data->remaining.used; counter++){
- if (strncmp(data->devices.array[device].string, argv[data->remaining.array[counter]], strlen(argv[data->remaining.array[counter]])) == 0){
+ for (counter = 0; counter < data->remaining.used; counter++) {
+ if (strncmp(data->devices.array[device].string, argv[data->remaining.array[counter]], strlen(argv[data->remaining.array[counter]])) == 0) {
matched = f_true;
}
}
- if (!matched){
+ if (!matched) {
f_dynamic_string swap_string = data->devices.array[device];
data->devices.used--;
- for (i = device; i < data->devices.used; i++){
+ for (i = device; i < data->devices.used; i++) {
data->devices.array[i] = data->devices.array[i+1];
}
f_string_length counter = f_string_length_initialize;
f_bool matched = f_false;
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
matched = f_false;
- for (device = 0; device < data->devices.used; device++){
- if (strncmp(data->devices.array[device].string, argv[data->remaining.array[counter]], strlen(argv[data->remaining.array[counter]])) == 0){
+ for (device = 0; device < data->devices.used; device++) {
+ if (strncmp(data->devices.array[device].string, argv[data->remaining.array[counter]], strlen(argv[data->remaining.array[counter]])) == 0) {
matched = f_true;
}
}
- if (!matched){
+ if (!matched) {
fl_print_color_line(f_standard_warning, data->context.warning, data->context.reset, "WARNING: There is no device by the name of '%s'", argv[data->remaining.array[counter]]);
}
}
f_string_length counter = f_string_length_initialize;
// identify which position is which
- for (; counter < data->objects.used; counter++){
+ for (; counter < data->objects.used; counter++) {
length = data->objects.array[counter].stop - data->objects.array[counter].start + 1;
- if (!found_first && length >= firewall_group_first_length){
- if (fl_compare_strings((f_string) firewall_group_first, data->buffer.string + data->objects.array[counter].start, firewall_group_first_length, length) == f_equal_to){
+ if (!found_first && length >= firewall_group_first_length) {
+ if (fl_compare_strings((f_string) firewall_group_first, data->buffer.string + data->objects.array[counter].start, firewall_group_first_length, length) == f_equal_to) {
first = counter;
found_first = f_true;
}
}
- if (!found_last && length >= firewall_group_last_length){
- if (fl_compare_strings((f_string) firewall_group_last, data->buffer.string + data->objects.array[counter].start, firewall_group_last_length, length) == f_equal_to){
+ if (!found_last && length >= firewall_group_last_length) {
+ if (fl_compare_strings((f_string) firewall_group_last, data->buffer.string + data->objects.array[counter].start, firewall_group_last_length, length) == f_equal_to) {
last = counter;
found_last = f_true;
}
}
- if (!found_stop && length >= firewall_group_stop_length){
- if (fl_compare_strings((f_string) firewall_group_stop, data->buffer.string + data->objects.array[counter].start, firewall_group_stop_length, length) == f_equal_to){
+ if (!found_stop && length >= firewall_group_stop_length) {
+ if (fl_compare_strings((f_string) firewall_group_stop, data->buffer.string + data->objects.array[counter].start, firewall_group_stop_length, length) == f_equal_to) {
stop = counter;
found_stop = f_true;
}
}
- if (!found_lock && length >= firewall_group_lock_length){
- if (fl_compare_strings((f_string) firewall_group_lock, data->buffer.string + data->objects.array[counter].start, firewall_group_lock_length, length) == f_equal_to){
+ if (!found_lock && length >= firewall_group_lock_length) {
+ if (fl_compare_strings((f_string) firewall_group_lock, data->buffer.string + data->objects.array[counter].start, firewall_group_lock_length, length) == f_equal_to) {
lock = counter;
found_lock = f_true;
}
}
}
- if (found_first && found_last && found_stop && found_lock){
+ if (found_first && found_last && found_stop && found_lock) {
f_string_length error_file = f_string_length_initialize;
status = f_none;
f_fss_objects extended_objects = f_fss_objects_initialize;
f_fss_contents extended_contents = f_fss_contents_initialize;
- if (command == firewall_parameter_command_lock){
+ if (command == firewall_parameter_command_lock) {
f_string_location input = f_string_location_initialize;
input.start = data->contents.array[lock].array[0].start;
status = fll_fss_extended_read(&data->buffer, &input, &extended_objects, &extended_contents);
- if (status == f_none || status == f_none_on_stop || status == f_none_on_eos){
+ if (status == f_none || status == f_none_on_stop || status == f_none_on_eos) {
status = firewall_perform_commands(extended_objects, extended_contents, f_true, 0, data->buffer, *data);
- if (status != f_none){
- if (f_macro_test_for_allocation_errors(status)){
+ if (status != f_none) {
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
- } else if (status == f_failure){
+ } else if (status == f_failure) {
// the error message has already been displayed
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands()", status);
}
}
} else {
- if (command == firewall_parameter_command_stop || command == firewall_parameter_command_restart){
+ if (command == firewall_parameter_command_stop || command == firewall_parameter_command_restart) {
f_string_location input = f_string_location_initialize;
input.start = data->contents.array[stop].array[0].start;
status = fll_fss_extended_read(&data->buffer, &input, &extended_objects, &extended_contents);
- if (status == f_none || status == f_none_on_stop || status == f_none_on_eos){
+ if (status == f_none || status == f_none_on_stop || status == f_none_on_eos) {
status = firewall_perform_commands(extended_objects, extended_contents, f_true, 0, data->buffer, *data);
}
}
- if ((status == f_none || status == f_none_on_stop || status == f_none_on_eos) && (command == firewall_parameter_command_start || command == firewall_parameter_command_restart)){
+ if ((status == f_none || status == f_none_on_stop || status == f_none_on_eos) && (command == firewall_parameter_command_start || command == firewall_parameter_command_restart)) {
f_delete_fss_objects(status, extended_objects);
f_delete_fss_contents(status, extended_contents);
status = fll_fss_extended_read(&data->buffer, &input, &extended_objects, &extended_contents);
- if (status == f_none || status == f_none_on_stop || status == f_none_on_eos){
+ if (status == f_none || status == f_none_on_stop || status == f_none_on_eos) {
status = firewall_perform_commands(extended_objects, extended_contents, f_true, 0, data->buffer, *data);
- if (status != f_none){
- if (f_macro_test_for_allocation_errors(status)){
+ if (status != f_none) {
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
- } else if (status == f_failure){
+ } else if (status == f_failure) {
// the error message has already been displayed
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands()", status);
f_string_length counter = f_string_length_initialize;
- for (; counter < data->devices.used; counter++){
+ for (; counter < data->devices.used; counter++) {
f_file file = f_file_initialize;
f_dynamic_string file_path = f_dynamic_string_initialize;
f_dynamic_string buffer = f_dynamic_string_initialize;
f_resize_dynamic_string(status, file_path, network_path_length + data->devices.array[counter].used + firewall_file_suffix_length + 1);
- if (status == f_none){
+ if (status == f_none) {
strncat(file_path.string, network_path, network_path_length);
strncat(file_path.string + network_path_length, data->devices.array[counter].string, data->devices.array[counter].used);
strncat(file_path.string, firewall_file_suffix, firewall_file_suffix_length);
status = f_file_open(&file, file_path.string);
}
- if (status != f_none){
- if (status == f_invalid_parameter){
+ if (status != f_none) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- } else if (status == f_file_not_found){
+ } else if (status == f_file_not_found) {
// If these files do not exist, it is not a problem (they are not required)
- } else if (status == f_file_open_error){
+ } else if (status == f_file_open_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", file_path.string);
- } else if (status == f_file_descriptor_error){
+ } else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", file_path.string);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
f_file_close(&file);
}
- if (data->file_position.total_elements == 0){
+ if (data->file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
data->file_position.total_elements = ftell(file.file);
fseek(file.file, 0, SEEK_SET);
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eof) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
- } else if (status == f_overflow){
+ } else if (status == f_overflow) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", file_path.string);
- } else if (status == f_file_not_open){
+ } else if (status == f_file_not_open) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", file_path.string);
- } else if (status == f_file_seek_error){
+ } else if (status == f_file_seek_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", file_path.string);
- } else if (status == f_file_read_error){
+ } else if (status == f_file_read_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", file_path.string);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
f_delete_dynamic_string(allocation_status, buffer);
status = fll_fss_basic_list_read(&buffer, &input, &list_objects, &list_contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", file_path.string);
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop){
+ } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: No relevant data was found within the file '%s'", file_path.string);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'", status, file_path.string);
f_string_length buffer_counter = f_string_length_initialize;
f_string_length name_length = f_string_length_initialize;
- for (; buffer_counter < list_objects.used; buffer_counter++){
+ for (; buffer_counter < list_objects.used; buffer_counter++) {
name_length = list_objects.array[buffer_counter].stop - list_objects.array[buffer_counter].start + 1;
- if (name_length >= firewall_group_main_length){
- if (fl_compare_strings((f_string) firewall_group_main, buffer.string + list_objects.array[buffer_counter].start, firewall_group_main_length, length) == f_equal_to){
+ if (name_length >= firewall_group_main_length) {
+ if (fl_compare_strings((f_string) firewall_group_main, buffer.string + list_objects.array[buffer_counter].start, firewall_group_main_length, length) == f_equal_to) {
f_string_location input = f_string_location_initialize;
input.start = list_contents.array[buffer_counter].array[0].start;
status = fll_fss_extended_read(&buffer, &input, &extended_objects, &extended_contents);
- if (status == f_none || status == f_none_on_stop || status == f_none_on_eos){
+ if (status == f_none || status == f_none_on_stop || status == f_none_on_eos) {
status = firewall_perform_commands(extended_objects, extended_contents, f_false, counter, buffer, *data);
- if (status != f_none){
- if (f_macro_test_for_allocation_errors(status)){
+ if (status != f_none) {
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
- } else if (status == f_failure){
+ } else if (status == f_failure) {
// the error message has already been displayed
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands()", status);
}
}
} else {
- if (status == f_invalid_parameter){
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_extended_read() for the file '%s'", file_path.string);
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop){
+ } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: No relevant data was found within the file '%s'", file_path.string);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_extended_read() for the file '%s'", status, file_path.string);
status = fll_fss_extended_read(&data->buffer, &input, &extended_objects, &extended_contents);
- if (status == f_none || status == f_none_on_stop || status == f_none_on_eos){
+ if (status == f_none || status == f_none_on_stop || status == f_none_on_eos) {
status = firewall_perform_commands(extended_objects, extended_contents, f_true, 0, data->buffer, *data);
- if (status != f_none){
- if (f_macro_test_for_allocation_errors(status)){
+ if (status != f_none) {
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
- } else if (status == f_failure){
+ } else if (status == f_failure) {
// the error message has already been displayed
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands()", status);
}
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (status == f_invalid_parameter) {
fl_print_color_code(f_standard_error, data->context.error);
fprintf(f_standard_error, "INTERNAL ERROR: Invalid parameter when calling fll_fss_extended_read() for the file '");
f_print_partial_dynamic_string(f_standard_error, data->buffer, data->contents.array[error_file].array[0]);
fprintf(f_standard_error, "'");
fl_print_color_code(f_standard_error, data->context.reset);
fprintf(f_standard_error, "\n");
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop){
- if (error_file == first || error_file == last || error_file == stop || error_file == lock){
+ } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
+ if (error_file == first || error_file == last || error_file == stop || error_file == lock) {
fl_print_color_code(f_standard_error, data->context.error);
fprintf(f_standard_error, "ERROR: No relevant data was found within the file '");
f_print_partial_dynamic_string(f_standard_error, data->buffer, data->contents.array[error_file].array[0]);
fl_print_color_code(f_standard_error, data->context.reset);
fprintf(f_standard_error, "\n");
}
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory", status);
- } else if (status == f_failure){
+ } else if (status == f_failure) {
// the error message has already been displayed
} else {
fl_print_color_code(f_standard_error, data->context.error);
} else {
const f_autochar *string = f_null;
- if (!found_first){
+ if (!found_first) {
string = firewall_group_first;
- } else if (!found_last){
+ } else if (!found_last) {
string = firewall_group_last;
- } else if (!found_stop){
+ } else if (!found_stop) {
string = firewall_group_stop;
- } else if (!found_lock){
+ } else if (!found_lock) {
string = firewall_group_lock;
}
return status;
}
- f_return_status firewall_perform_commands(const f_fss_objects objects, const f_fss_contents contents, const f_bool is_global, const f_string_length this_device, const f_dynamic_string buffer, const firewall_data data){
+ f_return_status firewall_perform_commands(const f_fss_objects objects, const f_fss_contents contents, const f_bool is_global, const f_string_length this_device, const f_dynamic_string buffer, const firewall_data data) {
f_status status = f_status_initialize;
f_status allocation_status = f_status_initialize;
f_dynamic_string device = f_dynamic_string_initialize;
f_string_length action = firewall_action_append_id;
- if (is_global){
+ if (is_global) {
device_all = f_true;
} else {
f_resize_dynamic_string(status, device, data.devices.array[this_device].used);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
f_delete_dynamic_string(allocation_status, device);
return status;
device.used = data.devices.array[this_device].used;
}
- for (; counter < objects.used; counter++){
+ for (; counter < objects.used; counter++) {
length = (objects.array[counter].stop - objects.array[counter].start) + 1;
invalid = f_false;
f_delete_dynamic_string(allocation_status, ip_list);
- if (length >= firewall_direction_length && fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_direction, length, firewall_direction_length) == f_equal_to){
+ if (length >= firewall_direction_length && fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_direction, length, firewall_direction_length) == f_equal_to) {
length = (contents.array[counter].array[0].stop - contents.array[counter].array[0].start) + 1;
- if (contents.array[counter].used <= 0 || contents.array[counter].used > 1){
+ if (contents.array[counter].used <= 0 || contents.array[counter].used > 1) {
invalid = f_true;
} else {
- if (length < firewall_direction_input_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_input, length, firewall_direction_input_length) == f_not_equal_to){
- if (length < firewall_direction_output_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_output, length, firewall_direction_output_length) == f_not_equal_to){
- if (length < firewall_direction_forward_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_forward, length, firewall_direction_forward_length) == f_not_equal_to){
- if (length < firewall_direction_postrouting_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_postrouting, length, firewall_direction_postrouting_length) == f_not_equal_to){
- if (length < firewall_direction_prerouting_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_prerouting, length, firewall_direction_prerouting_length) == f_not_equal_to){
- if (length < firewall_direction_none_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_none, length, firewall_direction_none_length) == f_not_equal_to){
- if (length < firewall_direction_forward_input_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_forward_input, length, firewall_direction_forward_input_length) == f_not_equal_to){
- if (length < firewall_direction_forward_output_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_forward_output, length, firewall_direction_forward_output_length) == f_not_equal_to){
- if (length < firewall_direction_postrouting_input_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_postrouting_input, length, firewall_direction_postrouting_input_length) == f_not_equal_to){
- if (length < firewall_direction_postrouting_output_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_postrouting_output, length, firewall_direction_postrouting_output_length) == f_not_equal_to){
- if (length < firewall_direction_prerouting_input_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_prerouting_input, length, firewall_direction_prerouting_input_length) == f_not_equal_to){
- if (length < firewall_direction_prerouting_output_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_prerouting_output, length, firewall_direction_prerouting_output_length) == f_not_equal_to){
+ if (length < firewall_direction_input_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_input, length, firewall_direction_input_length) == f_not_equal_to) {
+ if (length < firewall_direction_output_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_output, length, firewall_direction_output_length) == f_not_equal_to) {
+ if (length < firewall_direction_forward_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_forward, length, firewall_direction_forward_length) == f_not_equal_to) {
+ if (length < firewall_direction_postrouting_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_postrouting, length, firewall_direction_postrouting_length) == f_not_equal_to) {
+ if (length < firewall_direction_prerouting_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_prerouting, length, firewall_direction_prerouting_length) == f_not_equal_to) {
+ if (length < firewall_direction_none_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_none, length, firewall_direction_none_length) == f_not_equal_to) {
+ if (length < firewall_direction_forward_input_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_forward_input, length, firewall_direction_forward_input_length) == f_not_equal_to) {
+ if (length < firewall_direction_forward_output_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_forward_output, length, firewall_direction_forward_output_length) == f_not_equal_to) {
+ if (length < firewall_direction_postrouting_input_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_postrouting_input, length, firewall_direction_postrouting_input_length) == f_not_equal_to) {
+ if (length < firewall_direction_postrouting_output_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_postrouting_output, length, firewall_direction_postrouting_output_length) == f_not_equal_to) {
+ if (length < firewall_direction_prerouting_input_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_prerouting_input, length, firewall_direction_prerouting_input_length) == f_not_equal_to) {
+ if (length < firewall_direction_prerouting_output_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_direction_prerouting_output, length, firewall_direction_prerouting_output_length) == f_not_equal_to) {
invalid = f_true;
} else {
direction_input = f_false;
}
if (!invalid) continue;
- } else if (length >= firewall_device_length && fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_device, length, firewall_device_length) == f_equal_to){
+ } else if (length >= firewall_device_length && fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_device, length, firewall_device_length) == f_equal_to) {
length = (contents.array[counter].array[0].stop - contents.array[counter].array[0].start) + 1;
- if (contents.array[counter].used <= 0 || contents.array[counter].used > 1){
+ if (contents.array[counter].used <= 0 || contents.array[counter].used > 1) {
invalid = f_true;
- } else if (length >= firewall_device_all_length && fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_device_all, length, firewall_device_all_length) == f_equal_to){
+ } else if (length >= firewall_device_all_length && fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_device_all, length, firewall_device_all_length) == f_equal_to) {
f_delete_dynamic_string(status, device);
device_all = f_true;
continue;
- } else if (length >= firewall_device_this_length && fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_device_this, length, firewall_device_this_length) == f_equal_to){
+ } else if (length >= firewall_device_this_length && fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_device_this, length, firewall_device_this_length) == f_equal_to) {
f_delete_dynamic_string(status, device);
f_resize_dynamic_string(status, device, data.devices.array[this_device].used);
continue;
}
- if (!invalid){
+ if (!invalid) {
f_delete_dynamic_string(status, device);
f_resize_dynamic_string(status, device, length);
device_all = f_false;
continue;
}
- } else if (length >= firewall_action_length && fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_action, length, firewall_action_length) == f_equal_to){
+ } else if (length >= firewall_action_length && fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_action, length, firewall_action_length) == f_equal_to) {
length = (contents.array[counter].array[0].stop - contents.array[counter].array[0].start) + 1;
- if (contents.array[counter].used <= 0 || contents.array[counter].used > 1){
+ if (contents.array[counter].used <= 0 || contents.array[counter].used > 1) {
invalid = f_true;
- } else if (length < firewall_action_append_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_action_append, length, firewall_action_append_length) == f_not_equal_to){
- if (length < firewall_action_insert_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_action_insert, length, firewall_action_insert_length) == f_not_equal_to){
- if (length < firewall_action_policy_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_action_policy, length, firewall_action_policy_length) == f_not_equal_to){
- if (length < firewall_action_none_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_action_none, length, firewall_action_none_length) == f_not_equal_to){
+ } else if (length < firewall_action_append_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_action_append, length, firewall_action_append_length) == f_not_equal_to) {
+ if (length < firewall_action_insert_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_action_insert, length, firewall_action_insert_length) == f_not_equal_to) {
+ if (length < firewall_action_policy_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_action_policy, length, firewall_action_policy_length) == f_not_equal_to) {
+ if (length < firewall_action_none_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_action_none, length, firewall_action_none_length) == f_not_equal_to) {
invalid = f_true;
} else {
action = firewall_action_none_id;
}
if (!invalid) continue;
- } else if (length >= firewall_ip_list_length && fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_ip_list, length, firewall_ip_list_length) == f_equal_to){
+ } else if (length >= firewall_ip_list_length && fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_ip_list, length, firewall_ip_list_length) == f_equal_to) {
length = (contents.array[counter].array[0].stop - contents.array[counter].array[0].start) + 1;
is_ip_list = f_true;
- if (length >= firewall_ip_list_source_length && fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_ip_list_source, length, firewall_ip_list_source_length) == f_equal_to){
+ if (length >= firewall_ip_list_source_length && fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_ip_list_source, length, firewall_ip_list_source_length) == f_equal_to) {
ip_list_direction = f_false;
- } else if (length >= firewall_ip_list_destination_length && fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_ip_list_destination, length, firewall_ip_list_destination_length) == f_equal_to){
+ } else if (length >= firewall_ip_list_destination_length && fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_ip_list_destination, length, firewall_ip_list_destination_length) == f_equal_to) {
ip_list_direction = f_true;
} else {
invalid = f_true;
}
- } else if (length < firewall_rule_length || fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_rule, length, firewall_rule_length) == f_not_equal_to){
- if (length > 0){
+ } else if (length < firewall_rule_length || fl_compare_strings(buffer.string + objects.array[counter].start, (f_string) firewall_rule, length, firewall_rule_length) == f_not_equal_to) {
+ if (length > 0) {
fl_print_color_code(f_standard_warning, data.context.warning);
fprintf(f_standard_warning, "WARNING: At line %u, the object '", (unsigned int) counter);
f_print_string(f_standard_warning, buffer.string + objects.array[counter].start, length);
continue;
}
- if (invalid){
+ if (invalid) {
length = (objects.array[counter].stop - objects.array[counter].start) + 1;
- if (length > 0){
+ if (length > 0) {
fl_print_color_code(f_standard_warning, data.context.warning);
fprintf(f_standard_warning, "WARNING: At line %u, the object '", (unsigned int) counter);
f_print_string(f_standard_warning, buffer.string + objects.array[counter].start, length);
// FIXME: (this issue is probably everywhere) Implement an strncat function for dynamic strings or if I already have one implement, make sure it is used in every applicable place
// (this way I can automatically handle updating the used buffer)
// also look into auto-allocated space if necessary with the said function
- if (action == firewall_action_append_id){
+ if (action == firewall_action_append_id) {
f_resize_dynamic_string(status, argument, firewall_action_append_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
strncat(argument.string, firewall_action_append_command, firewall_action_append_command_length);
argument.used = firewall_action_append_command_length;
- } else if (action == firewall_action_insert_id){
+ } else if (action == firewall_action_insert_id) {
f_resize_dynamic_string(status, argument, firewall_action_insert_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
strncat(argument.string, firewall_action_insert_command, firewall_action_insert_command_length);
argument.used = firewall_action_insert_command_length;
- } else if (action == firewall_action_policy_id){
+ } else if (action == firewall_action_policy_id) {
f_resize_dynamic_string(status, argument, firewall_action_policy_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
argument.used = firewall_action_policy_command_length;
}
- if (argument.used > 0){
+ if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
if (f_macro_test_for_allocation_errors(status)) break;
argument.used = 0;
}
- if (action != firewall_action_none_id){
- if (direction == firewall_direction_forward_id){
+ if (action != firewall_action_none_id) {
+ if (direction == firewall_direction_forward_id) {
f_resize_dynamic_string(status, argument, firewall_direction_forward_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
strncat(argument.string, firewall_direction_forward_command, firewall_direction_forward_command_length);
argument.used = firewall_direction_forward_command_length;
- } else if (direction == firewall_direction_postrouting_id){
+ } else if (direction == firewall_direction_postrouting_id) {
f_resize_dynamic_string(status, argument, firewall_direction_postrouting_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
strncat(argument.string, firewall_direction_postrouting_command, firewall_direction_postrouting_command_length);
argument.used += firewall_direction_postrouting_command_length;
- } else if (direction == firewall_direction_prerouting_id){
+ } else if (direction == firewall_direction_prerouting_id) {
f_resize_dynamic_string(status, argument, firewall_direction_prerouting_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
strncat(argument.string, firewall_direction_prerouting_command, firewall_direction_prerouting_command_length);
argument.used = firewall_direction_prerouting_command_length;
- } else if (direction_input){
+ } else if (direction_input) {
f_resize_dynamic_string(status, argument, firewall_direction_input_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
strncat(argument.string, firewall_direction_input_command, firewall_direction_input_command_length);
argument.used = firewall_direction_input_command_length;
- } else if (direction_output){
+ } else if (direction_output) {
f_resize_dynamic_string(status, argument, firewall_direction_output_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
}
}
- if (argument.used > 0){
+ if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
if (f_macro_test_for_allocation_errors(status)) break;
argument.used = 0;
}
- if (device.used > 0){
- if (length < firewall_device_all_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_device_all, length, firewall_device_all_length) == f_not_equal_to){
- if (direction_input){
+ if (device.used > 0) {
+ if (length < firewall_device_all_length || fl_compare_strings(buffer.string + contents.array[counter].array[0].start, (f_string) firewall_device_all, length, firewall_device_all_length) == f_not_equal_to) {
+ if (direction_input) {
f_resize_dynamic_string(status, argument, firewall_device_input_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
strncat(argument.string, firewall_device_input_command, firewall_device_input_command_length);
argument.used = firewall_device_input_command_length;
- } else if (direction_output){
+ } else if (direction_output) {
f_resize_dynamic_string(status, argument, firewall_device_output_command_length);
if (f_macro_test_for_allocation_errors(status)) break;
}
}
- if (argument.used > 0){
+ if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
if (f_macro_test_for_allocation_errors(status)) break;
argument.used = 0;
}
- if (direction_input || direction_output){
+ if (direction_input || direction_output) {
f_resize_dynamic_string(status, argument, device.used);
if (f_macro_test_for_allocation_errors(status)) break;
}
}
- if (argument.used > 0){
+ if (argument.used > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
if (f_macro_test_for_allocation_errors(status)) break;
}
// last up is the "rule"
- if ((!is_ip_list && contents.array[counter].used > 0) || (is_ip_list && contents.array[counter].used > 1)){
+ if ((!is_ip_list && contents.array[counter].used > 0) || (is_ip_list && contents.array[counter].used > 1)) {
f_string_length subcounter = f_string_length_initialize;
- if (is_ip_list){
+ if (is_ip_list) {
// skip past the direction
subcounter++;
f_resize_dynamic_string(status, ip_list, length);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
subcounter = contents.array[counter].used;
} else {
strncat(ip_list.string, buffer.string + contents.array[counter].array[subcounter].start, length);
}
}
- for (; subcounter < contents.array[counter].used; subcounter++){
+ for (; subcounter < contents.array[counter].used; subcounter++) {
length = (contents.array[counter].array[subcounter].stop - contents.array[counter].array[subcounter].start) + 1;
f_resize_dynamic_string(status, argument, length);
strncat(argument.string, buffer.string + contents.array[counter].array[subcounter].start, length);
argument.used = length;
- if (length > 0){
+ if (length > 0) {
f_resize_dynamic_strings(status, arguments, arguments.used + 1);
if (f_macro_test_for_allocation_errors(status)) break;
break;
}
- if (arguments.used > 1){
- if (is_ip_list){
+ if (arguments.used > 1) {
+ if (is_ip_list) {
f_file file = f_file_initialize;
f_dynamic_string file_path = f_dynamic_string_initialize;
f_dynamic_string local_buffer = f_dynamic_string_initialize;
f_resize_dynamic_string(status, file_path, network_path_length + ip_list.used + 1);
- if (status == f_none){
+ if (status == f_none) {
strncat(file_path.string, network_path, network_path_length);
strncat(file_path.string + network_path_length, ip_list.string, ip_list.used);
file_path.used = file_path.size;
status = f_file_open(&file, file_path.string);
}
- if (status != f_none){
- if (status == f_invalid_parameter){
+ if (status != f_none) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- } else if (status == f_file_not_found){
+ } else if (status == f_file_not_found) {
// the file does not have to exist
fl_print_color_line(f_standard_warning, data.context.warning, data.context.reset, "WARNING: Cannot find the file '%s'", file_path.string);
status = f_none;
- } else if (status == f_file_open_error){
+ } else if (status == f_file_open_error) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to open the file '%s'", file_path.string);
- } else if (status == f_file_descriptor_error){
+ } else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%s'", file_path.string);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
} else {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
f_file_close(&file);
} else {
- if (file_position.total_elements == 0){
+ if (file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
file_position.total_elements = ftell(file.file);
fseek(file.file, 0, SEEK_SET);
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eof) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
- } else if (status == f_overflow){
+ } else if (status == f_overflow) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", file_path.string);
- } else if (status == f_file_not_open){
+ } else if (status == f_file_not_open) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: The file '%s' is no longer open", file_path.string);
- } else if (status == f_file_seek_error){
+ } else if (status == f_file_seek_error) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A seek error occurred while accessing the file '%s'", file_path.string);
- } else if (status == f_file_read_error){
+ } else if (status == f_file_read_error) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%s'", file_path.string);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
} else {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", status);
status = fll_fss_basic_read(&local_buffer, &input, &basic_objects, &basic_contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_read() for the file '%s'", file_path.string);
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop){
+ } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
// empty files are to be silently ignored
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
} else {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_read() for the file '%s'", status, file_path.string);
f_dynamic_string ip_argument = f_dynamic_string_initialize;
f_dynamic_string ip_list_action = f_dynamic_string_initialize;
- if (ip_list_direction){
+ if (ip_list_direction) {
f_resize_dynamic_string(status, ip_list_action, firewall_ip_list_destination_action_length + 1);
strncat(ip_list_action.string, firewall_ip_list_destination_action, firewall_ip_list_destination_action_length);
} else {
ip_list_action.used = ip_list_action.size;
ip_list_action.string[ip_list_action.used] = 0;
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
} else {
ip_list_action.used = ip_list_action.size;
f_resize_dynamic_strings(status, arguments, arguments.used + 2);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
} else {
arguments.array[arguments.used].string = ip_list_action.string;
arguments.used++;
// the ip_list file contains objects and no content, all objects are what matter an nothing else
- for (; buffer_counter < basic_objects.used; buffer_counter++){
+ for (; buffer_counter < basic_objects.used; buffer_counter++) {
ip_length = (basic_objects.array[buffer_counter].stop - basic_objects.array[buffer_counter].start) + 1;
f_resize_dynamic_string(status, ip_argument, ip_length);
- if (f_macro_test_for_allocation_errors(status)){
+ if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory", status);
break;
}
status = fll_execute_program((f_string) firewall_program_name, arguments, &results);
- if (status == f_failure){
+ if (status == f_failure) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", firewall_program_name);
fprintf(f_standard_error, " ");
fl_print_color_code(f_standard_error, data.context.error);
- for (; i < arguments.used; i++){
+ for (; i < arguments.used; i++) {
fprintf(f_standard_error, "%s ", arguments.array[i].string);
}
arguments.array[arguments.used].used = 0;
break;
- } else if (status == f_invalid_parameter){
+ } else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_execute_path()");
arguments.used--;
} else {
status = fll_execute_program((f_string) firewall_program_name, arguments, &results);
- if (status == f_failure){
+ if (status == f_failure) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to perform requested %s operation:", firewall_program_name);
fprintf(f_standard_error, " ");
fl_print_color_code(f_standard_error, data.context.error);
- for (; i < arguments.used; i++){
+ for (; i < arguments.used; i++) {
fprintf(f_standard_error, "%s ", arguments.array[i].string);
}
fprintf(f_standard_error, "\n");
break;
- } else if (status == f_invalid_parameter){
+ } else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_execute_path()");
break;
}
#endif // _di_firewall_main_
#ifndef _di_firewall_delete_data_
- f_return_status firewall_delete_data(firewall_data *data){
+ f_return_status firewall_delete_data(firewall_data *data) {
f_status status = f_status_initialize;
f_delete_fss_contents(status, data->contents);
#include <level_3/firewall.h>
-int main(const f_s_int argc, const f_string argv[]){
+int main(const f_s_int argc, const f_string argv[]) {
firewall_data data = firewall_data_initialize;
return firewall_main(argc, argv, &data);
// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
#ifndef _di_fss_basic_list_read_print_version_
- f_return_status fss_basic_list_read_print_version(const fss_basic_list_read_data data){
+ f_return_status fss_basic_list_read_print_version(const fss_basic_list_read_data data) {
printf("%s\n", fss_basic_list_read_version);
return f_none;
#endif // _fss_basic_list_read_print_version_
#ifndef _di_fss_basic_list_read_print_help_
- f_return_status fss_basic_list_read_print_help(const fss_basic_list_read_data data){
+ f_return_status fss_basic_list_read_print_help(const fss_basic_list_read_data data) {
printf("\n");
fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_basic_list_read_name_long);
#ifndef _di_fss_basic_list_read_main_
f_return_status fss_basic_list_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility ("internal")));
- f_return_status fss_basic_list_read_main(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data){
+ f_return_status fss_basic_list_read_main(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data) {
f_status status = f_status_initialize;
f_status allocation_status = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_basic_list_read_total_parameters, &data->remaining);
// load colors when not told to show no colors
- if (data->parameters[fss_basic_list_read_parameter_no_color].result == f_console_result_none){
+ if (data->parameters[fss_basic_list_read_parameter_no_color].result == f_console_result_none) {
fll_new_color_context(allocation_status, data->context);
- if (allocation_status == f_none){
+ if (allocation_status == f_none) {
fll_colors_load_context(&data->context, data->parameters[fss_basic_list_read_parameter_light].result == f_console_result_found);
} else {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
}
}
- if (status != f_none){
- if (status == f_no_data){
+ if (status != f_none) {
+ if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
// to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
// nothing can be 0 as that represents the program name, unless argv[] is improperly created
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- } else if (status == f_invalid_parameter){
+ } else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", status);
}
// execute parameter results
- if (data->parameters[fss_basic_list_read_parameter_help].result == f_console_result_found){
+ if (data->parameters[fss_basic_list_read_parameter_help].result == f_console_result_found) {
fss_basic_list_read_print_help(*data);
- } else if (data->parameters[fss_basic_list_read_parameter_version].result == f_console_result_found){
+ } else if (data->parameters[fss_basic_list_read_parameter_version].result == f_console_result_found) {
fss_basic_list_read_print_version(*data);
- } else if (data->remaining.used > 0 || data->process_pipe){
+ } else if (data->remaining.used > 0 || data->process_pipe) {
f_string_length counter = f_string_length_initialize;
f_string_length target = f_string_length_initialize;
f_string_length original_size = data->file_position.total_elements;
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional){
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
target = (f_string_length) atoll(argv[data->parameters[fss_basic_list_read_parameter_count].additional]);
}
status = fl_file_read_fifo(file, &data->buffer);
- if (status != f_none){
- if (status == f_invalid_parameter){
+ if (status != f_none) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- } else if (status == f_file_not_found){
+ } else if (status == f_file_not_found) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-");
- } else if (status == f_file_open_error){
+ } else if (status == f_file_open_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-");
- } else if (status == f_file_descriptor_error){
+ } else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
status = fss_basic_list_read_main_process_file(argc, argv, data, "-", target);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
return status;
}
f_delete_dynamic_string(allocation_status, data->buffer);
}
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
f_file file = f_file_initialize;
status = f_file_open(&file, argv[data->remaining.array[counter]]);
data->file_position.total_elements = original_size;
- if (status != f_none){
- if (status == f_invalid_parameter){
+ if (status != f_none) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- } else if (status == f_file_not_found){
+ } else if (status == f_file_not_found) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_open_error){
+ } else if (status == f_file_open_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_descriptor_error){
+ } else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
// TODO: this file size set functionality might be turned into an fl_file (or f_file) function
- if (data->file_position.total_elements == 0){
+ if (data->file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
data->file_position.total_elements = ftell(file.file);
// skip past empty files
- if (data->file_position.total_elements == 0){
+ if (data->file_position.total_elements == 0) {
f_file_close(&file);
continue;
}
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
- } else if (status == f_overflow){
+ } else if (status == f_overflow) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_not_open){
+ } else if (status == f_file_not_open) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", argv[data->remaining.array[counter]]);
- } else if (status == f_file_seek_error){
+ } else if (status == f_file_seek_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_read_error){
+ } else if (status == f_file_read_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", status);
status = fss_basic_list_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
return status;
}
status = fll_fss_basic_list_read(&data->buffer, &input, &data->objects, &data->contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
fss_basic_list_read_delete_data(data);
return status;
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof){
+ } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof) {
// not an error in this case
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
fss_basic_list_read_delete_data(data);
}
// now that all of the files have been read, process the objects and contents
- if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_none){
+ if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_none) {
fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
} else {
current = 0;
- if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_none){
- if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none){
- for (; current < data->objects.used; current++){
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)){
+ if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_none) {
+ if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none) {
+ for (; current < data->objects.used; current++) {
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
- if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found){
- if (data->contents.array[current].used > 0){
+ if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found) {
+ if (data->contents.array[current].used > 0) {
f_string_length counter = data->contents.array[current].array[0].start;
f_string_length size = 0;
- for (; counter <= data->contents.array[current].array[0].stop; counter++){
+ for (; counter <= data->contents.array[current].array[0].stop; counter++) {
if (data->buffer.string[counter] == f_eol) size++;
} // for
} else {
fprintf(f_standard_output, "0\n");
}
- } else if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional){
- if (data->contents.array[current].used > 0){
+ } else if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
+ if (data->contents.array[current].used > 0) {
f_string_length counter = data->contents.array[current].array[0].start;
f_string_length position = 0;
f_string_length target = (f_string_length) atoll(argv[data->parameters[fss_basic_list_read_parameter_line].additional]);
range.start = 1;
range.stop = 0;
- for (; counter <= data->contents.array[current].array[0].stop; counter++){
- if (position == target){
+ for (; counter <= data->contents.array[current].array[0].stop; counter++) {
+ if (position == target) {
range.start = counter;
// explicit use of < instead of <= is done here so that the range.stop will always be accurate
- for (; counter < data->contents.array[current].array[0].stop; counter++){
- if (data->buffer.string[counter] == f_eol){
+ for (; counter < data->contents.array[current].array[0].stop; counter++) {
+ if (data->buffer.string[counter] == f_eol) {
break;
}
} // for
break;
}
- if (data->buffer.string[counter] == f_eol){
+ if (data->buffer.string[counter] == f_eol) {
position++;
}
} // for
- if (range.start <= range.stop){
+ if (range.start <= range.stop) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, range);
}
}
} else {
- if (data->contents.array[current].used > 0){
+ if (data->contents.array[current].used > 0) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[0]);
fprintf(f_standard_output, "\n");
}
}
}
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
}
} // for
} else {
- for (; current < data->objects.used; current++){
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)){
+ for (; current < data->objects.used; current++) {
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->objects.array[current]);
fprintf(f_standard_output, "\n");
}
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
f_string_length name_length = f_string_length_initialize;
f_string_length argv_length = f_string_length_initialize;
- if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_additional){
+ if (data->parameters[fss_basic_list_read_parameter_name].result == f_console_result_additional) {
argv_length = strlen(argv[data->parameters[fss_basic_list_read_parameter_name].additional]);
- if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none){
- for (; current < data->objects.used; current++){
+ if (data->parameters[fss_basic_list_read_parameter_object].result == f_console_result_none) {
+ for (; current < data->objects.used; current++) {
name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
- if (name_length == argv_length){
- if (fl_compare_strings(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_basic_list_read_parameter_name].additional], name_length, argv_length) == f_equal_to){
+ if (name_length == argv_length) {
+ if (fl_compare_strings(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_basic_list_read_parameter_name].additional], name_length, argv_length) == f_equal_to) {
- if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found){
- if (data->contents.array[current].used > 0){
+ if (data->parameters[fss_basic_list_read_parameter_size].result == f_console_result_found) {
+ if (data->contents.array[current].used > 0) {
f_string_length counter = data->contents.array[current].array[0].start;
f_string_length size = 0;
- for (; counter <= data->contents.array[current].array[0].stop; counter++){
+ for (; counter <= data->contents.array[current].array[0].stop; counter++) {
if (data->buffer.string[counter] == f_eol) size++;
} // for
} else {
fprintf(f_standard_output, "0\n");
}
- } else if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional){
- if (data->contents.array[current].used > 0){
+ } else if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
+ if (data->contents.array[current].used > 0) {
f_string_length counter = data->contents.array[current].array[0].start;
f_string_length position = 0;
f_string_length target = (f_string_length) atoll(argv[data->parameters[fss_basic_list_read_parameter_line].additional]);
range.start = 1;
range.stop = 0;
- for (; counter <= data->contents.array[current].array[0].stop; counter++){
- if (position == target){
+ for (; counter <= data->contents.array[current].array[0].stop; counter++) {
+ if (position == target) {
range.start = counter;
// explicit use of < instead of <= is done here so that the range.stop will always be accurate
- for (; counter < data->contents.array[current].array[0].stop; counter++){
- if (data->buffer.string[counter] == f_eol){
+ for (; counter < data->contents.array[current].array[0].stop; counter++) {
+ if (data->buffer.string[counter] == f_eol) {
break;
}
} // for
break;
}
- if (data->buffer.string[counter] == f_eol){
+ if (data->buffer.string[counter] == f_eol) {
position++;
}
} // for
- if (range.start <= range.stop){
+ if (range.start <= range.stop) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, range);
}
}
} else {
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)){
- if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found){
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
+ if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
total++;
} else {
- if (data->contents.array[current].used > 0){
+ if (data->contents.array[current].used > 0) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[0]);
fprintf(f_standard_output, "\n");
}
}
}
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
}
} // for
- if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none){
+ if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none) {
fprintf(f_standard_output, f_string_length_printf "\n", total);
}
} 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 (; current < data->contents.used; current++){
- if (data->contents.array[current].used > 0){
+ for (; current < data->contents.used; current++) {
+ if (data->contents.array[current].used > 0) {
name_length = data->contents.array[current].array[0].stop - data->contents.array[current].array[0].start + 1;
- if (name_length == argv_length){
- if (fl_compare_strings(data->buffer.string + data->contents.array[current].array[0].start, argv[data->parameters[fss_basic_list_read_parameter_name].additional], name_length, argv_length) == f_equal_to){
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)){
+ if (name_length == argv_length) {
+ if (fl_compare_strings(data->buffer.string + data->contents.array[current].array[0].start, argv[data->parameters[fss_basic_list_read_parameter_name].additional], name_length, argv_length) == f_equal_to) {
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->objects.array[current]);
fprintf(f_standard_output, "\n");
}
- if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
#endif // _di_fss_basic_list_read_main_
#ifndef _di_fss_basic_list_read_delete_data_
- f_return_status fss_basic_list_read_delete_data(fss_basic_list_read_data *data){
+ f_return_status fss_basic_list_read_delete_data(fss_basic_list_read_data *data) {
f_status status = f_status_initialize;
f_delete_fss_contents(status, data->contents);
#include <level_3/fss_basic_list_read.h>
-int main(const f_array_length argc, const f_string argv[]){
+int main(const f_array_length argc, const f_string argv[]) {
fss_basic_list_read_data data = fss_basic_list_read_data_initialize;
- if (f_pipe_exists()){
+ if (f_pipe_exists()) {
data.process_pipe = f_true;
}
// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
#ifndef _di_fss_basic_read_print_version_
- f_return_status fss_basic_read_print_version(const fss_basic_read_data data){
+ f_return_status fss_basic_read_print_version(const fss_basic_read_data data) {
printf("%s\n", fss_basic_read_version);
return f_none;
#endif // _fss_basic_read_print_version_
#ifndef _di_fss_basic_read_print_help_
- f_return_status fss_basic_read_print_help(const fss_basic_read_data data){
+ f_return_status fss_basic_read_print_help(const fss_basic_read_data data) {
printf("\n");
fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_basic_read_name_long);
#ifndef _di_fss_basic_read_main_
f_return_status fss_basic_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility("internal")));
- f_return_status fss_basic_read_main(const f_array_length argc, const f_string argv[], fss_basic_read_data *data){
+ f_return_status fss_basic_read_main(const f_array_length argc, const f_string argv[], fss_basic_read_data *data) {
f_status status = f_status_initialize;
f_status allocation_status = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_basic_read_total_parameters, &data->remaining);
// load colors when not told to show no colors
- if (data->parameters[fss_basic_read_parameter_no_color].result == f_console_result_none){
+ if (data->parameters[fss_basic_read_parameter_no_color].result == f_console_result_none) {
fll_new_color_context(allocation_status, data->context);
- if (allocation_status == f_none){
+ if (allocation_status == f_none) {
fll_colors_load_context(&data->context, data->parameters[fss_basic_read_parameter_light].result == f_console_result_found);
} else {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
}
}
- if (status != f_none){
- if (status == f_no_data){
+ if (status != f_none) {
+ if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
// to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
// nothing can be 0 as that represents the program name, unless argv[] is improperly created
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- } else if (status == f_invalid_parameter){
+ } else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", status);
}
// execute parameter results
- if (data->parameters[fss_basic_read_parameter_help].result == f_console_result_found){
+ if (data->parameters[fss_basic_read_parameter_help].result == f_console_result_found) {
fss_basic_read_print_help(*data);
- } else if (data->parameters[fss_basic_read_parameter_version].result == f_console_result_found){
+ } else if (data->parameters[fss_basic_read_parameter_version].result == f_console_result_found) {
fss_basic_read_print_version(*data);
- } else if (data->remaining.used > 0 || data->process_pipe){
+ } else if (data->remaining.used > 0 || data->process_pipe) {
f_string_length counter = f_string_length_initialize;
f_string_length target = f_string_length_initialize;
f_string_length original_size = data->file_position.total_elements;
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional){
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
target = (f_string_length) atoll(argv[data->parameters[fss_basic_read_parameter_count].additional]);
}
status = fl_file_read_fifo(file, &data->buffer);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
- } else if (status == f_overflow){
+ } else if (status == f_overflow) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", "-");
- } else if (status == f_file_not_open){
+ } else if (status == f_file_not_open) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", "-");
- } else if (status == f_file_seek_error){
+ } else if (status == f_file_seek_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", "-");
- } else if (status == f_file_read_error){
+ } else if (status == f_file_read_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", "-");
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", "-");
status = fss_basic_read_main_process_file(argc, argv, data, "-", target);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
return status;
}
f_delete_dynamic_string(allocation_status, data->buffer);
}
- if (data->remaining.used > 0){
- for (; counter < data->remaining.used; counter++){
+ if (data->remaining.used > 0) {
+ for (; counter < data->remaining.used; counter++) {
f_file file = f_file_initialize;
status = f_file_open(&file, argv[data->remaining.array[counter]]);
data->file_position.total_elements = original_size;
- if (status != f_none){
- if (status == f_invalid_parameter){
+ if (status != f_none) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- } else if (status == f_file_not_found){
+ } else if (status == f_file_not_found) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_open_error){
+ } else if (status == f_file_open_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_descriptor_error){
+ } else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
// TODO: this file size set functionality might be turned into an fl_file (or f_file) function
- if (data->file_position.total_elements == 0){
+ if (data->file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
data->file_position.total_elements = ftell(file.file);
// skip past empty files
- if (data->file_position.total_elements == 0){
+ if (data->file_position.total_elements == 0) {
f_file_close(&file);
continue;
}
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
- } else if (status == f_overflow){
+ } else if (status == f_overflow) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_not_open){
+ } else if (status == f_file_not_open) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", argv[data->remaining.array[counter]]);
- } else if (status == f_file_seek_error){
+ } else if (status == f_file_seek_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_read_error){
+ } else if (status == f_file_read_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", argv[data->remaining.array[counter]]);
status = fss_basic_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
return status;
}
return status;
}
- f_return_status fss_basic_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_read_data *data, const f_string filename, const f_string_length target){
+ f_return_status fss_basic_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_read_data *data, const f_string filename, const f_string_length target) {
f_status status = f_status_initialize;
f_status allocation_status = f_status_initialize;
status = fll_fss_basic_read(&data->buffer, &input, &data->objects, &data->contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'", filename);
fss_basic_read_delete_data(data);
return status;
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof){
+ } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof) {
// not an error in this case
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
fss_basic_read_delete_data(data);
}
// now that the file has been read, process the objects and contents
- if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_name].result == f_console_result_none){
+ if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_name].result == f_console_result_none) {
fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
} else {
current = 0;
- if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_none){
- if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none){
- for (; current < data->objects.used; current++){
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)){
- if (data->contents.array[current].used > 0){
+ if (data->parameters[fss_basic_read_parameter_name].result == f_console_result_none) {
+ if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
+ for (; current < data->objects.used; current++) {
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
+ if (data->contents.array[current].used > 0) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[0]);
fprintf(f_standard_output, "\n");
} else {
}
}
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
}
} // for
} else {
- for (; current < data->objects.used; current++){
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)){
+ for (; current < data->objects.used; current++) {
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->objects.array[current]);
fprintf(f_standard_output, "\n");
}
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
f_string_length name_length = f_string_length_initialize;
f_string_length argv_length = f_string_length_initialize;
- 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) {
argv_length = strlen(argv[data->parameters[fss_basic_read_parameter_name].additional]);
- if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none){
- for (; current < data->objects.used; current++){
+ if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_none) {
+ for (; current < data->objects.used; current++) {
name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
- if (name_length == argv_length){
- if (fl_compare_strings(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_basic_read_parameter_name].additional], name_length, argv_length) == f_equal_to){
+ if (name_length == argv_length) {
+ if (fl_compare_strings(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_basic_read_parameter_name].additional], name_length, argv_length) == f_equal_to) {
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)){
- if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found){
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].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[current].used > 0){
+ if (data->contents.array[current].used > 0) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[0]);
fprintf(f_standard_output, "\n");
} else {
}
}
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
}
} // for
- if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_count].result == f_console_result_none){
+ if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_count].result == f_console_result_none) {
fprintf(f_standard_output, f_string_length_printf "\n", total);
}
} 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 (; current < data->contents.used; current++){
- if (data->contents.array[current].used > 0){
+ for (; current < data->contents.used; current++) {
+ if (data->contents.array[current].used > 0) {
name_length = data->contents.array[current].array[0].stop - data->contents.array[current].array[0].start + 1;
- if (name_length == argv_length){
- if (fl_compare_strings(data->buffer.string + data->contents.array[current].array[0].start, argv[data->parameters[fss_basic_read_parameter_name].additional], name_length, argv_length) == f_equal_to){
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)){
+ if (name_length == argv_length) {
+ if (fl_compare_strings(data->buffer.string + data->contents.array[current].array[0].start, argv[data->parameters[fss_basic_read_parameter_name].additional], name_length, argv_length) == f_equal_to) {
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->objects.array[current]);
fprintf(f_standard_output, "\n");
}
- if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
#endif // _di_fss_basic_read_main_
#ifndef _di_fss_basic_read_delete_data_
- f_return_status fss_basic_read_delete_data(fss_basic_read_data *data){
+ f_return_status fss_basic_read_delete_data(fss_basic_read_data *data) {
f_status status = f_status_initialize;
f_delete_fss_contents(status, data->contents);
#include <level_3/fss_basic_read.h>
-int main(const f_array_length argc, const f_string argv[]){
+int main(const f_array_length argc, const f_string argv[]) {
fss_basic_read_data data = fss_basic_read_data_initialize;
- if (f_pipe_exists()){
+ if (f_pipe_exists()) {
data.process_pipe = f_true;
}
// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
#ifndef _di_fss_extended_read_print_version_
- f_return_status fss_extended_read_print_version(const fss_extended_read_data data){
+ f_return_status fss_extended_read_print_version(const fss_extended_read_data data) {
printf("%s\n", fss_extended_read_version);
return f_none;
#endif // _fss_extended_read_print_version_
#ifndef _di_fss_extended_read_print_help_
- f_return_status fss_extended_read_print_help(const fss_extended_read_data data){
+ f_return_status fss_extended_read_print_help(const fss_extended_read_data data) {
printf("\n");
fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_extended_read_name_long);
#ifndef _di_fss_extended_read_main_
f_return_status fss_extended_read_main_process_file(const f_array_length argc, const f_string argv[], fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) __attribute__((visibility("internal")));
- f_return_status fss_extended_read_main(const f_array_length argc, const f_string argv[], fss_extended_read_data *data){
+ f_return_status fss_extended_read_main(const f_array_length argc, const f_string argv[], fss_extended_read_data *data) {
f_status status = f_status_initialize;
f_status allocation_status = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_extended_read_total_parameters, &data->remaining);
// load colors when not told to show no colors
- if (data->parameters[fss_extended_read_parameter_no_color].result == f_console_result_none){
+ if (data->parameters[fss_extended_read_parameter_no_color].result == f_console_result_none) {
fll_new_color_context(allocation_status, data->context);
- if (allocation_status == f_none){
+ if (allocation_status == f_none) {
fll_colors_load_context(&data->context, data->parameters[fss_extended_read_parameter_light].result == f_console_result_found);
} else {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
}
}
- if (status != f_none){
- if (status == f_no_data){
+ if (status != f_none) {
+ if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
// to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
// nothing can be 0 as that represents the program name, unless argv[] is improperly created
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- } else if (status == f_invalid_parameter){
+ } else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", status);
}
// execute parameter results
- if (data->parameters[fss_extended_read_parameter_help].result == f_console_result_found){
+ if (data->parameters[fss_extended_read_parameter_help].result == f_console_result_found) {
fss_extended_read_print_help(*data);
- } else if (data->parameters[fss_extended_read_parameter_version].result == f_console_result_found){
+ } else if (data->parameters[fss_extended_read_parameter_version].result == f_console_result_found) {
fss_extended_read_print_version(*data);
- } else if (data->remaining.used > 0 || data->process_pipe){
+ } else if (data->remaining.used > 0 || data->process_pipe) {
f_string_length counter = f_string_length_initialize;
f_string_length target = f_string_length_initialize;
f_string_length select = f_string_length_initialize;
f_string_length original_size = data->file_position.total_elements;
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional){
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
target = (f_string_length) atoll(argv[data->parameters[fss_extended_read_parameter_count].additional]);
}
- if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional){
+ if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
select = (f_string_length) atoll(argv[data->parameters[fss_extended_read_parameter_select].additional]);
}
status = fl_file_read_fifo(file, &data->buffer);
- if (status != f_none){
- if (status == f_invalid_parameter){
+ if (status != f_none) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- } else if (status == f_file_not_found){
+ } else if (status == f_file_not_found) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", "-");
- } else if (status == f_file_open_error){
+ } else if (status == f_file_open_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", "-");
- } else if (status == f_file_descriptor_error){
+ } else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
status = fss_extended_read_main_process_file(argc, argv, data, "-", target, select);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
return status;
}
f_delete_dynamic_string(allocation_status, data->buffer);
}
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
f_file file = f_file_initialize;
status = f_file_open(&file, argv[data->remaining.array[counter]]);
data->file_position.total_elements = original_size;
- if (status != f_none){
- if (status == f_invalid_parameter){
+ if (status != f_none) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- } else if (status == f_file_not_found){
+ } else if (status == f_file_not_found) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_open_error){
+ } else if (status == f_file_open_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_descriptor_error){
+ } else if (status == f_file_descriptor_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", argv[data->remaining.array[counter]]);
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
}
// TODO: this file size set functionality might be turned into an fl_file (or f_file) function
- if (data->file_position.total_elements == 0){
+ if (data->file_position.total_elements == 0) {
fseek(file.file, 0, SEEK_END);
data->file_position.total_elements = ftell(file.file);
// skip past empty files
- if (data->file_position.total_elements == 0){
+ if (data->file_position.total_elements == 0) {
f_file_close(&file);
continue;
}
f_file_close(&file);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read()");
- } else if (status == f_overflow){
+ } else if (status == f_overflow) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_not_open){
+ } else if (status == f_file_not_open) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open", argv[data->remaining.array[counter]]);
- } else if (status == f_file_seek_error){
+ } else if (status == f_file_seek_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
- } else if (status == f_file_read_error){
+ } else if (status == f_file_read_error) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'", argv[data->remaining.array[counter]]);
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read()", status);
status = fss_extended_read_main_process_file(argc, argv, data, argv[data->remaining.array[counter]], target, select);
- if (status != f_none && status != f_none_on_eof && status != f_none_on_eos){
+ if (status != f_none && status != f_none_on_eof && status != f_none_on_eos) {
return status;
}
status = fll_fss_extended_read(&data->buffer, &input, &data->objects, &data->contents);
}
- if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content){
- if (status == f_invalid_parameter){
+ if (status != f_none && status != f_none_on_eos && status != f_none_on_stop && status != fl_fss_found_object_no_content) {
+ if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_extended_read() for the file '%s'", filename);
fss_extended_read_delete_data(data);
return status;
- } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof){
+ } else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop || status == f_no_data_on_eof) {
// not an error in this case
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
fss_extended_read_delete_data(data);
}
// now that all of the files have been read, process the objects and contents
- if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found && data->parameters[fss_extended_read_parameter_name].result == f_console_result_none){
+ if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found && data->parameters[fss_extended_read_parameter_name].result == f_console_result_none) {
fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
} else {
current = 0;
- if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_none){
- if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none){
- for (; current < data->objects.used; current++){
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)){
- if (data->contents.array[current].used > select){
+ if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_none) {
+ if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none) {
+ for (; current < data->objects.used; current++) {
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
+ if (data->contents.array[current].used > select) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[select]);
fprintf(f_standard_output, "\n");
} else {
}
}
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
}
} // for
} else {
- for (; current < data->objects.used; current++){
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)){
+ for (; current < data->objects.used; current++) {
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->objects.array[current]);
fprintf(f_standard_output, "\n");
}
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
f_string_length name_length = f_string_length_initialize;
f_string_length argv_length = f_string_length_initialize;
- if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_additional){
+ if (data->parameters[fss_extended_read_parameter_name].result == f_console_result_additional) {
argv_length = strlen(argv[data->parameters[fss_extended_read_parameter_name].additional]);
- if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none){
- for (; current < data->objects.used; current++){
+ if (data->parameters[fss_extended_read_parameter_object].result == f_console_result_none) {
+ for (; current < data->objects.used; current++) {
name_length = data->objects.array[current].stop - data->objects.array[current].start + 1;
- if (name_length == argv_length){
- if (fl_compare_strings(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_extended_read_parameter_name].additional], name_length, argv_length) == f_equal_to){
+ if (name_length == argv_length) {
+ if (fl_compare_strings(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_extended_read_parameter_name].additional], name_length, argv_length) == f_equal_to) {
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)){
- if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found){
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
+ if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
total++;
} else {
- if (data->contents.array[current].used > select){
+ if (data->contents.array[current].used > select) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[select]);
fprintf(f_standard_output, "\n");
} else {
}
}
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
}
} // for
- if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found && data->parameters[fss_extended_read_parameter_count].result == f_console_result_none){
+ if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found && data->parameters[fss_extended_read_parameter_count].result == f_console_result_none) {
fprintf(f_standard_output, f_string_length_printf "\n", total);
}
} 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 (; current < data->contents.used; current++){
- if (data->contents.array[current].used > select){
+ for (; current < data->contents.used; current++) {
+ if (data->contents.array[current].used > select) {
name_length = data->contents.array[current].array[select].stop - data->contents.array[current].array[select].start + 1;
- if (name_length == argv_length){
- if (fl_compare_strings(data->buffer.string + data->contents.array[current].array[select].start, argv[data->parameters[fss_extended_read_parameter_name].additional], name_length, argv_length) == f_equal_to){
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)){
+ if (name_length == argv_length) {
+ if (fl_compare_strings(data->buffer.string + data->contents.array[current].array[select].start, argv[data->parameters[fss_extended_read_parameter_name].additional], name_length, argv_length) == f_equal_to) {
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)) {
f_print_partial_dynamic_string(f_standard_output, data->buffer, data->objects.array[current]);
fprintf(f_standard_output, "\n");
}
- if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional){
- if (found == target){
+ if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional) {
+ if (found == target) {
break;
} else {
found++;
#endif // _di_fss_extended_read_main_
#ifndef _di_fss_extended_read_delete_data_
- f_return_status fss_extended_read_delete_data(fss_extended_read_data *data){
+ f_return_status fss_extended_read_delete_data(fss_extended_read_data *data) {
f_status status = f_status_initialize;
f_delete_fss_contents(status, data->contents);
#include <level_3/fss_extended_read.h>
-int main(const f_array_length argc, const f_string argv[]){
+int main(const f_array_length argc, const f_string argv[]) {
fss_extended_read_data data = fss_extended_read_data_initialize;
- if (f_pipe_exists()){
+ if (f_pipe_exists()) {
data.process_pipe = f_true;
}
// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
#ifndef _di_fss_return_code_print_version_
- f_return_status fss_return_code_print_version(const fss_return_code_data data){
+ f_return_status fss_return_code_print_version(const fss_return_code_data data) {
printf("%s\n", fss_return_code_version);
return f_none;
#endif // _fss_return_code_print_version_
#ifndef _di_fss_return_code_print_help_
- f_return_status fss_return_code_print_help(const fss_return_code_data data){
+ f_return_status fss_return_code_print_help(const fss_return_code_data data) {
printf("\n");
fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", fss_return_code_name_long);
#endif // _di_fss_return_code_print_help_
#ifndef _di_fss_return_code_main_
- f_return_status fss_return_code_main(const f_array_length argc, const f_string argv[], fss_return_code_data *data){
+ f_return_status fss_return_code_main(const f_array_length argc, const f_string argv[], fss_return_code_data *data) {
f_status status = f_status_initialize;
f_status allocation_status = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, fss_return_code_total_parameters, &data->remaining);
// load colors when not told to show no colors
- if (data->parameters[fss_return_code_parameter_no_color].result == f_console_result_none){
+ if (data->parameters[fss_return_code_parameter_no_color].result == f_console_result_none) {
fll_new_color_context(allocation_status, data->context);
- if (allocation_status == f_none){
+ if (allocation_status == f_none) {
fll_colors_load_context(&data->context, data->parameters[fss_return_code_parameter_light].result == f_console_result_found);
} else {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
}
}
- if (status != f_none){
- if (status == f_no_data){
+ if (status != f_none) {
+ if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
// to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
// nothing can be 0 as that represents the program name, unless argv[] is improperly created
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
- } else if (status == f_invalid_parameter){
+ } else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
}
// execute parameter results
- if (data->parameters[fss_return_code_parameter_help].result == f_console_result_found){
+ if (data->parameters[fss_return_code_parameter_help].result == f_console_result_found) {
fss_return_code_print_help(*data);
- } else if (data->parameters[fss_return_code_parameter_version].result == f_console_result_found){
+ } else if (data->parameters[fss_return_code_parameter_version].result == f_console_result_found) {
fss_return_code_print_version(*data);
- } else if (data->parameters[fss_return_code_parameter_is_error].result == f_console_result_found && data->remaining.used > 0){
+ } else if (data->parameters[fss_return_code_parameter_is_error].result == f_console_result_found && data->remaining.used > 0) {
f_array_length counter = f_array_length_initialize;
f_status code = f_status_initialize;
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fll_fss_errors_is_error(code)){
+ if (fll_fss_errors_is_error(code)) {
fss_return_code_delete_data(data);
return f_true;
}
fss_return_code_delete_data(data);
return f_false;
- } else if (data->parameters[fss_return_code_parameter_is_warning].result == f_console_result_found && data->remaining.used > 0){
+ } else if (data->parameters[fss_return_code_parameter_is_warning].result == f_console_result_found && data->remaining.used > 0) {
f_array_length counter = f_array_length_initialize;
f_status code = f_status_initialize;
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fll_fss_errors_is_warning(code)){
+ if (fll_fss_errors_is_warning(code)) {
fss_return_code_delete_data(data);
return f_true;
}
fss_return_code_delete_data(data);
return f_false;
- } else if (data->parameters[fss_return_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0){
+ } else if (data->parameters[fss_return_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0) {
f_array_length counter = f_array_length_initialize;
f_status code = f_status_initialize;
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fll_fss_errors_is_okay(code)){
+ if (fll_fss_errors_is_okay(code)) {
fss_return_code_delete_data(data);
return f_true;
}
fss_return_code_delete_data(data);
return f_false;
- } else if (data->remaining.used > 0 || data->process_pipe){
+ } else if (data->remaining.used > 0 || data->process_pipe) {
f_array_length counter = f_array_length_initialize;
if (data->process_pipe) {
// TODO: how should this be done?
}
- if (data->remaining.used > 0){
- for (; counter < data->remaining.used; counter++){
+ if (data->remaining.used > 0) {
+ for (; counter < data->remaining.used; counter++) {
f_status code = (f_status) atoll(argv[data->remaining.array[counter]]);
f_string string = f_null;
- if (fll_fss_errors_to_string(code, &string) == f_none){
+ if (fll_fss_errors_to_string(code, &string) == f_none) {
printf("%s\n", string);
}
} // for
#endif // _di_fss_return_code_main_
#ifndef _di_fss_return_code_delete_data_
- f_return_status fss_return_code_delete_data(fss_return_code_data *data){
+ f_return_status fss_return_code_delete_data(fss_return_code_data *data) {
f_status status = f_status_initialize;
f_delete_string_lengths(status, data->remaining);
#include <level_3/fss_return_code.h>
-int main(const f_array_length argc, const f_string argv[]){
+int main(const f_array_length argc, const f_string argv[]) {
fss_return_code_data data = fss_return_code_data_initialize;
/*
- if (f_pipe_exists()){
+ if (f_pipe_exists()) {
data.process_pipe = f_true;
}
*/
#include <level_3/return_code.h>
-int main(const f_array_length argc, const f_string argv[]){
+int main(const f_array_length argc, const f_string argv[]) {
return_code_data data = return_code_data_initialize;
/*
- if (f_pipe_exists()){
+ if (f_pipe_exists()) {
data.process_pipe = f_true;
}
*/
// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
#ifndef _di_return_code_print_version_
- f_return_status return_code_print_version(const return_code_data data){
+ f_return_status return_code_print_version(const return_code_data data) {
printf("%s\n", return_code_version);
return f_none;
#endif // _return_code_print_version_
#ifndef _di_return_code_print_help_
- f_return_status return_code_print_help(const return_code_data data){
+ f_return_status return_code_print_help(const return_code_data data) {
printf("\n");
fl_print_color(f_standard_output, data.context.title, data.context.reset, " %s", return_code_name_long);
#endif // _di_return_code_print_help_
#ifndef _di_return_code_main_
- f_return_status return_code_main(const f_array_length argc, const f_string argv[], return_code_data *data){
+ f_return_status return_code_main(const f_array_length argc, const f_string argv[], return_code_data *data) {
f_status status = f_status_initialize;
f_status allocation_status = f_status_initialize;
status = fl_process_parameters(argc, argv, data->parameters, return_code_total_parameters, &data->remaining);
// load colors when not told to show no colors
- if (data->parameters[return_code_parameter_no_color].result == f_console_result_none){
+ if (data->parameters[return_code_parameter_no_color].result == f_console_result_none) {
fll_new_color_context(allocation_status, data->context);
- if (allocation_status == f_none){
+ if (allocation_status == f_none) {
fll_colors_load_context(&data->context, data->parameters[return_code_parameter_light].result == f_console_result_found);
} else {
fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
}
}
- if (status != f_none){
- if (status == f_no_data){
+ if (status != f_none) {
+ if (status == f_no_data) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
// TODO: there is a way to identify which parameter is incorrect
// to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
// nothing can be 0 as that represents the program name, unless argv[] is improperly created
- } else if (f_macro_test_for_allocation_errors(status)){
+ } else if (f_macro_test_for_allocation_errors(status)) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
- } else if (status == f_invalid_parameter){
+ } else if (status == f_invalid_parameter) {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
} else {
fl_print_color_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
}
// execute parameter results
- if (data->parameters[return_code_parameter_help].result == f_console_result_found){
+ if (data->parameters[return_code_parameter_help].result == f_console_result_found) {
return_code_print_help(*data);
- } else if (data->parameters[return_code_parameter_version].result == f_console_result_found){
+ } else if (data->parameters[return_code_parameter_version].result == f_console_result_found) {
return_code_print_version(*data);
- } else if (data->parameters[return_code_parameter_is_error].result == f_console_result_found && data->remaining.used > 0){
+ } else if (data->parameters[return_code_parameter_is_error].result == f_console_result_found && data->remaining.used > 0) {
f_array_length counter = f_array_length_initialize;
f_status code = f_status_initialize;
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fl_errors_is_error(code)){
+ if (fl_errors_is_error(code)) {
return_code_delete_data(data);
return f_true;
}
return_code_delete_data(data);
return f_false;
- } else if (data->parameters[return_code_parameter_is_warning].result == f_console_result_found && data->remaining.used > 0){
+ } else if (data->parameters[return_code_parameter_is_warning].result == f_console_result_found && data->remaining.used > 0) {
f_array_length counter = f_array_length_initialize;
f_status code = f_status_initialize;
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fl_errors_is_warning(code)){
+ if (fl_errors_is_warning(code)) {
return_code_delete_data(data);
return f_true;
}
return_code_delete_data(data);
return f_false;
- } else if (data->parameters[return_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0){
+ } else if (data->parameters[return_code_parameter_is_okay].result == f_console_result_found && data->remaining.used > 0) {
f_array_length counter = f_array_length_initialize;
f_status code = f_status_initialize;
- for (; counter < data->remaining.used; counter++){
+ for (; counter < data->remaining.used; counter++) {
code = (f_status) atoll(argv[data->remaining.array[counter]]);
- if (fl_errors_is_okay(code)){
+ if (fl_errors_is_okay(code)) {
return_code_delete_data(data);
return f_true;
}
return_code_delete_data(data);
return f_false;
- } else if (data->remaining.used > 0 || data->process_pipe){
+ } else if (data->remaining.used > 0 || data->process_pipe) {
f_array_length counter = f_array_length_initialize;
if (data->process_pipe) {
// TODO: how should this be done?
}
- if (data->remaining.used > 0){
- for (; counter < data->remaining.used; counter++){
+ if (data->remaining.used > 0) {
+ for (; counter < data->remaining.used; counter++) {
f_status code = (f_status) atoll(argv[data->remaining.array[counter]]);
f_string string = f_null;
- if (fl_errors_to_string(code, &string) == f_none){
+ if (fl_errors_to_string(code, &string) == f_none) {
printf("%s\n", string);
}
} // for
#endif // _di_return_code_main_
#ifndef _di_return_code_delete_data_
- f_return_status return_code_delete_data(return_code_data *data){
+ f_return_status return_code_delete_data(return_code_data *data) {
f_status status = f_status_initialize;
f_delete_string_lengths(status, data->remaining);