Add explicit dark mode console option.
Add support for order of operations priority on parameters ("+n +l +d" would result in colors for dark background because +d overrides both +n and +l due to being the right-most parameter).
Rewrite level_3 programs to utilize the new fll_program_process_parameters() helper function.
Fix some screwed up macro definitions and uses.
* Create some standard command line parameter options required by the kevux/fss/fll specifications.
*/
#ifndef _di_f_standard_console_parameters_
- #define f_console_standard_short_debug "d"
+ #define f_console_standard_short_dark "d"
+ #define f_console_standard_short_debug "D"
#define f_console_standard_short_help "h"
#define f_console_standard_short_light "l"
#define f_console_standard_short_no_color "n"
#define f_console_standard_short_version "v"
+ #define f_console_standard_long_dark "dark"
#define f_console_standard_long_debug "debug"
#define f_console_standard_long_help "help"
#define f_console_standard_long_light "light"
#define f_console_default_allocation_step 4
#endif // _di_f_console_default_allocation_step_
-
/**
* Provide console type enumerations:
*
* - type: One of the f_console_type_* codes, defining how this parameter is to be processed.
* - result: A code representing that the parameter was found and how it was found ('-h' vs '--help').
* - total: A number representing the total number of times this parameter was found ('-h -h' would result in a total of 2).
+ * - location: The last location in argv[] where this parameter was found.
+ * - location_sub: The last sub-location at location in argv (only used by short parameters, such as -h or +l).
* - additional: An array of locations representing where in the argv[] the additional arguments are found.
*/
#ifndef _di_f_console_parameter_
uint8_t result;
uint8_t total;
+ f_string_length location;
+ f_string_length location_sub;
f_string_lengths additional;
} f_console_parameter;
- #define f_console_parameter_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value) \
- { symbol_short, symbol_long, symbol_other, has_additional, type_value, f_console_result_none, 0, f_string_lengths_initialize }
+ #define f_console_parameter_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value) { symbol_short, symbol_long, symbol_other, has_additional, type_value, f_console_result_none, 0, 0, 0, f_string_lengths_initialize }
#endif // _di_f_console_parameter_
/**
#define f_fss_headers_initialize { 0, 0, 0 }
- #define f_clear_fss_headers(headers) f_macro_memory_structure_clear(headers)
+ #define f_macro_fss_headers_clear(headers) f_macro_memory_structure_clear(headers)
#define f_macro_fss_headers_new(status, headers, length) f_macro_memory_structure_new(status, headers, f_fss_header, length)
#define f_string_lengths_initialize { 0, 0, 0 }
- #define f_macro_string_lengths_new(status, lengths) \
- f_macro_memory_structure_new(status, lengths, f_string_length)
+ #define f_macro_string_lengths_clear(lengths) f_macro_memory_structure_clear(lengths)
- #define f_macro_string_lengths_delete(status, lengths) \
- f_macro_memory_structure_delete(status, lengths, f_string_length)
+ #define f_macro_string_lengths_new(status, lengths, length) f_macro_memory_structure_new(status, lengths, f_string_length, length)
- #define f_macro_string_lengths_destroy(status, lengths) \
- f_macro_memory_structure_destroy(status, lengths, f_string_length)
+ #define f_macro_string_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_string_length)
+ #define f_macro_string_lengths_destroy(status, lengths) f_macro_memory_structure_destroy(status, lengths, f_string_length)
- #define f_macro_string_lengths_resize(status, lengths, new_length) \
- f_macro_memory_structure_resize(status, lengths, f_string_length, new_length)
-
- #define f_macro_string_lengths_adjust(status, lengths, new_length) \
- f_macro_memory_structure_adjust(status, lengths, f_string_length, new_length)
+ #define f_macro_string_lengths_resize(status, lengths, new_length) f_macro_memory_structure_resize(status, lengths, f_string_length, new_length)
+ #define f_macro_string_lengths_adjust(status, lengths, new_length) f_macro_memory_structure_adjust(status, lengths, f_string_length, new_length)
#endif // _di_f_string_lengths_
/**
#define f_string_locations_initialize {0, 0, 0}
- #define f_clear_string_locations(locations) \
- f_macro_memory_structure_clear(locations)
-
- #define f_macro_string_locations_new(status, locations, length) \
- f_macro_memory_structure_new(status, locations, f_string_location, length)
-
- #define f_macro_string_locations_delete(status, locations) \
- f_macro_memory_structure_delete(status, locations, f_string_location)
+ #define f_clear_string_locations(locations) f_macro_memory_structure_clear(locations)
- #define f_macro_string_locations_destroy(status, locations) \
- f_macro_memory_structure_destroy(status, locations, f_string_location)
+ #define f_macro_string_locations_new(status, locations, length) f_macro_memory_structure_new(status, locations, f_string_location, length)
- #define f_macro_string_locations_resize(status, locations, new_length) \
- f_macro_memory_structure_resize(status, locations, f_string_location, new_length)
+ #define f_macro_string_locations_delete(status, locations) f_macro_memory_structure_delete(status, locations, f_string_location)
+ #define f_macro_string_locations_destroy(status, locations) f_macro_memory_structure_destroy(status, locations, f_string_location)
- #define f_macro_string_locations_adjust(status, locations, new_length) \
- f_macro_memory_structure_adjust(status, locations, f_string_location, new_length)
+ #define f_macro_string_locations_resize(status, locations, new_length) f_macro_memory_structure_resize(status, locations, f_string_location, new_length)
+ #define f_macro_string_locations_adjust(status, locations, new_length) f_macro_memory_structure_adjust(status, locations, f_string_location, new_length)
#endif // _di_f_string_locations_
/**
#define f_array_lengths_initialize { 0, 0, 0 }
- #define f_macro_array_lengths_new(status, lengths, length) \
- f_macro_memory_structure_new(status, lengths, f_array_length, length)
+ #define f_macro_array_lengths_clear(lengths) f_macro_memory_structure_clear(lengths)
- #define f_macro_array_lengths_delete(status, lengths) \
- f_macro_memory_structure_delete(status, lengths, f_array_length)
+ #define f_macro_array_lengths_new(status, lengths, length) f_macro_memory_structure_new(status, lengths, f_array_length, length)
- #define f_macro_array_lengths_destroy(status, lengths) \
- f_macro_memory_structure_destroy(status, lengths, f_array_length)
+ #define f_macro_array_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_array_length)
+ #define f_macro_array_lengths_destroy(status, lengths) f_macro_memory_structure_destroy(status, lengths, f_array_length)
- #define f_macro_array_lengths_resize(status, lengths, new_length) \
- f_macro_memory_structure_resize(status, lengths, f_array_length, new_length)
-
- #define f_macro_array_lengths_adjust(status, lengths, new_length) \
- f_macro_memory_structure_adjust(status, lengths, f_array_length, new_length)
+ #define f_macro_array_lengths_resize(status, lengths, new_length) f_macro_memory_structure_resize(status, lengths, f_array_length, new_length)
+ #define f_macro_array_lengths_adjust(status, lengths, new_length) f_macro_memory_structure_adjust(status, lengths, f_array_length, new_length)
#endif // _di_f_array_lengths_
#ifdef __cplusplus
#define f_utf_string_initialize f_utf_character_eos
#define f_macro_utf_string_new(status, string, length) status = f_memory_new((void **) & string, sizeof(f_utf_string), length)
+
#define f_macro_utf_string_delete(status, string, size) status = f_memory_delete((void **) & string, sizeof(f_utf_string), size)
#define f_macro_utf_string_destroy(status, string, size) status = f_memory_destroy((void **) & string, sizeof(f_utf_string), size)
- #define f_macro_utf_string_resize(status, string, old_length, new_length) \
- status = f_memory_resize((void **) & string, sizeof(f_utf_string), old_length, new_length)
-
- #define f_macro_utf_string_adjust(status, string, old_length, new_length) \
- status = f_memory_adjust((void **) & string, sizeof(f_utf_string), old_length, new_length)
+ #define f_macro_utf_string_resize(status, string, old_length, new_length) status = f_memory_resize((void **) & string, sizeof(f_utf_string), old_length, new_length)
+ #define f_macro_utf_string_adjust(status, string, old_length, new_length) status = f_memory_adjust((void **) & string, sizeof(f_utf_string), old_length, new_length)
#endif // _di_f_utf_string_
/**
typedef f_s_long f_utf_string_length;
#define f_macro_utf_string_length_new(status, string, length) status = f_memory_new((void **) & string, sizeof(f_utf_string_length), length)
+
#define f_macro_utf_string_length_delete(status, string, length) status = f_memory_delete((void **) & string, sizeof(f_utf_string_length), length)
#define f_macro_utf_string_length_destroy(status, string, size) status = f_memory_destroy((f_void_P *) & string, sizeof(f_utf_string_length), size)
- #define f_macro_utf_string_length_resize(status, length, old_length, new_length) \
- status = f_memory_resize((void **) & length, sizeof(f_utf_string_length), old_length, new_length)
-
- #define f_macro_utf_string_length_adjust(status, length, old_length, new_length) \
- status = f_memory_adjust((void **) & length, sizeof(f_utf_string_length), old_length, new_length)
+ #define f_macro_utf_string_length_resize(status, length, old_length, new_length) status = f_memory_resize((void **) & length, sizeof(f_utf_string_length), old_length, new_length)
+ #define f_macro_utf_string_length_adjust(status, length, old_length, new_length) status = f_memory_adjust((void **) & length, sizeof(f_utf_string_length), old_length, new_length)
#endif // _di_f_utf_string_length_
/**
#define f_utf_string_lengths_initialize { 0, 0, 0 }
- #define f_macro_utf_string_length_news(status, lengths) \
- f_macro_memory_structure_new(status, lengths, f_utf_string_length)
+ #define f_macro_utf_string_lengths_clear(lengths) f_macro_memory_structure_clear(lengths)
- #define f_macro_utf_string_length_deletes(status, lengths) \
- f_macro_memory_structure_delete(status, lengths, f_utf_string_length)
+ #define f_macro_utf_string_lengths_new(status, lengths, length) f_macro_memory_structure_new(status, lengths, f_utf_string_length, length)
- #define f_macro_utf_string_length_destroys(status, lengths) \
- f_macro_memory_structure_destroy(status, lengths, f_utf_string_length)
+ #define f_macro_utf_string_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_utf_string_length)
+ #define f_macro_utf_string_lengths_destroy(status, lengths) f_macro_memory_structure_destroy(status, lengths, f_utf_string_length)
- #define f_macro_utf_string_length_resizes(status, lengths, new_length) \
- f_macro_memory_structure_resize(status, lengths, f_utf_string_length, new_length)
-
- #define f_macro_utf_string_length_adjusts(status, lengths, new_length) \
- f_macro_memory_structure_adjust(status, lengths, f_utf_string_length, new_length)
+ #define f_macro_utf_string_lengths_resize(status, lengths, new_length) f_macro_memory_structure_resize(status, lengths, f_utf_string_length, new_length)
+ #define f_macro_utf_string_lengths_adjust(status, lengths, new_length) f_macro_memory_structure_adjust(status, lengths, f_utf_string_length, new_length)
#endif // _di_f_utf_string_lengths_
/**
#define f_utf_string_locations_initialize {0, 0, 0}
- #define f_clear_utf_string_locations(locations) \
- f_macro_memory_structure_clear(locations)
-
- #define f_macro_utf_string_location_news(status, locations, length) \
- f_macro_memory_structure_new(status, locations, f_utf_string_location, length)
-
- #define f_macro_utf_string_location_deletes(status, locations) \
- f_macro_memory_structure_delete(status, locations, f_utf_string_location)
+ #define f_clear_utf_string_locations(locations) f_macro_memory_structure_clear(locations)
- #define f_macro_utf_string_location_destroys(status, locations) \
- f_macro_memory_structure_destroy(status, locations, f_utf_string_location)
+ #define f_macro_utf_string_location_news(status, locations, length) f_macro_memory_structure_new(status, locations, f_utf_string_location, length)
- #define f_macro_utf_string_location_resizes(status, locations, new_length) \
- f_macro_memory_structure_resize(status, locations, f_utf_string_location, new_length)
+ #define f_macro_utf_string_location_deletes(status, locations) f_macro_memory_structure_delete(status, locations, f_utf_string_location)
+ #define f_macro_utf_string_location_destroys(status, locations) f_macro_memory_structure_destroy(status, locations, f_utf_string_location)
- #define f_macro_utf_string_location_adjusts(status, locations, new_length) \
- f_macro_memory_structure_adjust(status, locations, f_utf_string_location, new_length)
+ #define f_macro_utf_string_location_resizes(status, locations, new_length) f_macro_memory_structure_resize(status, locations, f_utf_string_location, new_length)
+ #define f_macro_utf_string_location_adjusts(status, locations, new_length) f_macro_memory_structure_adjust(status, locations, f_utf_string_location, new_length)
#endif // _di_f_utf_string_locations_
/**
}
parameters[parameter_counter].result = f_console_result_found;
+ parameters[parameter_counter].location = location;
+ parameters[parameter_counter].location_sub = 0;
parameters[parameter_counter].total++;
+ if (result == console_short) {
+ parameters[parameter_counter].location_sub = sub_location;
+ }
+
if (parameters[parameter_counter].has_additional) {
if (needs_additional.used + parameters[parameter_counter].has_additional > needs_additional.size) {
f_status allocation_status = f_none;
}
parameters[parameter_counter].result = f_console_result_found;
+ parameters[parameter_counter].location = location;
+ parameters[parameter_counter].location_sub = 0;
parameters[parameter_counter].total++;
if (parameters[parameter_counter].has_additional) {
#endif // _di_fll_program_print_version_
#ifndef _di_fll_program_process_parameters_
- f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, f_string_lengths *remaining, fl_color_context *context) {
+ f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, const f_array_length parameter_dark, f_string_lengths *remaining, fl_color_context *context) {
f_status status = f_none;
f_status allocation_status = f_none;
status = fl_process_parameters(argc, argv, parameters, total_parameters, remaining);
- // load colors when not told to show no colors
- if (parameters[parameter_no_color].result == f_console_result_none) {
+ f_string_length color_mode = parameter_dark;
+
+ if (parameters[parameter_no_color].result == f_console_result_found) {
+ if (parameters[parameter_light].result == f_console_result_none) {
+ if (parameters[parameter_dark].result == f_console_result_none || parameters[parameter_no_color].location > parameters[parameter_dark].location) {
+ color_mode = parameter_no_color;
+ }
+ else if (parameters[parameter_no_color].location == parameters[parameter_dark].location && parameters[parameter_no_color].location_sub > parameters[parameter_dark].location_sub) {
+ color_mode = parameter_no_color;
+ }
+ }
+ else {
+ if (parameters[parameter_dark].result == f_console_result_none) {
+ if (parameters[parameter_no_color].location > parameters[parameter_light].location) {
+ color_mode = parameter_no_color;
+ }
+ else if (parameters[parameter_no_color].location == parameters[parameter_light].location && parameters[parameter_no_color].location_sub > parameters[parameter_light].location_sub) {
+ color_mode = parameter_no_color;
+ }
+ else {
+ color_mode = parameter_light;
+ }
+ }
+ else if (parameters[parameter_no_color].location > parameters[parameter_dark].location) {
+ if (parameters[parameter_no_color].location > parameters[parameter_light].location) {
+ color_mode = parameter_no_color;
+ }
+ else if (parameters[parameter_no_color].location == parameters[parameter_light].location && parameters[parameter_no_color].location_sub > parameters[parameter_light].location_sub) {
+ color_mode = parameter_no_color;
+ }
+ else {
+ color_mode = parameter_light;
+ }
+ }
+ else if (parameters[parameter_no_color].location == parameters[parameter_dark].location && parameters[parameter_no_color].location_sub > parameters[parameter_dark].location_sub) {
+ if (parameters[parameter_no_color].location > parameters[parameter_light].location) {
+ color_mode = parameter_no_color;
+ }
+ else if (parameters[parameter_no_color].location == parameters[parameter_light].location && parameters[parameter_no_color].location_sub > parameters[parameter_light].location_sub) {
+ color_mode = parameter_no_color;
+ }
+ else {
+ color_mode = parameter_light;
+ }
+ }
+ else if (parameters[parameter_light].location > parameters[parameter_dark].location) {
+ color_mode = parameter_light;
+ }
+ else if (parameters[parameter_light].location == parameters[parameter_dark].location && parameters[parameter_light].location_sub > parameters[parameter_dark].location_sub) {
+ color_mode = parameter_light;
+ }
+ }
+ }
+ else if (parameters[parameter_light].result == f_console_result_found) {
+ if (parameters[parameter_dark].result == f_console_result_none) {
+ color_mode = parameter_light;
+ }
+ else if (parameters[parameter_light].location > parameters[parameter_dark].location) {
+ color_mode = parameter_light;
+ }
+ else if (parameters[parameter_light].location == parameters[parameter_dark].location && parameters[parameter_light].location_sub > parameters[parameter_dark].location_sub) {
+ color_mode = parameter_light;
+ }
+ }
+
+ // load colors unless told not to.
+ if (color_mode != parameter_no_color) {
fl_macro_color_context_new(allocation_status, (*context));
if (f_status_is_error(allocation_status)) {
return allocation_status;
}
- fl_color_load_context(context, parameters[parameter_light].result == f_console_result_found);
+ fl_color_load_context(context, color_mode == parameter_light);
}
if (f_status_is_error(status)) {
* The parameter in the parameters array representing the no-color option.
* @param parameter_light
* The parameter in the parameters array representing the light-color option.
+ * @param parameter_dark
+ * The parameter in the parameters array representing the dark-color option.
* @param remaining
* A list of remaining parameters not associated with anything.
* @param context
* f_reallocation_error (with error bit) on memory reallocation error.
*/
#ifndef _di_fll_program_process_parameters_
- extern f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, f_string_lengths *remaining, fl_color_context *context);
+ extern f_return_status fll_program_process_parameters(const f_array_length argc, const f_string argv[], f_console_parameter parameters[], const f_array_length total_parameters, const f_array_length parameter_no_color, const f_array_length parameter_light, const f_array_length parameter_dark, f_string_lengths *remaining, fl_color_context *context);
#endif // _di_fll_program_process_parameters_
#ifdef __cplusplus
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
#ifndef _di_firewall_main_
f_return_status firewall_main(const f_s_int argc, const f_string argv[], firewall_data *data) {
- f_status status = f_none;
- f_status status2 = f_none;
-
- 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) {
- fl_macro_color_context_new(status2, data->context);
-
- if (status2 == f_none) {
- fl_color_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");
- firewall_delete_data(data);
- return status2;
- }
- }
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, firewall_total_parameters, firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- }
- else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- }
- else if (f_status_set_fine(status) == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
- }
- else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status));
- }
-
firewall_delete_data(data);
return f_status_set_error(status);
}
+ status = f_none;
+
// execute parameter results
if (data->parameters[firewall_parameter_help].result == f_console_result_found) {
firewall_print_help(*data);
status = firewall_buffer_rules(file_path.string, f_true, &local, data);
+ f_status status2 = f_none;
f_macro_string_dynamic_delete(status2, file_path);
}
status = firewall_create_custom_chains(&reserved, &local, data);
if (f_status_is_error(status)) {
+ f_status status2 = f_none;
+
firewall_macro_delete_fss_buffers(status2, local.buffer, local.chain_objects, local.chain_contents)
firewall_delete_data(data);
return status;
enum {
firewall_parameter_help,
firewall_parameter_light,
+ firewall_parameter_dark,
firewall_parameter_no_color,
firewall_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(0, 0, firewall_command_show, f_false, f_console_type_other), \
}
- #define firewall_total_parameters 10
+ #define firewall_total_parameters 11
#else
#define f_console_parameter_initialize_firewall \
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(0, 0, firewall_command_start, f_false, f_console_type_other), \
f_console_parameter_initialize(0, 0, firewall_command_show, f_false, f_console_type_other), \
}
- #define firewall_total_parameters 9
+ #define firewall_total_parameters 10
#endif // _en_firewall_debug_
#endif // _di_firewall_defines_
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
f_return_status fss_basic_list_read_main_process_file(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data, const f_string filename, const f_string_length target) __attribute__((visibility ("internal")));
f_return_status fss_basic_list_read_main(const f_array_length argc, const f_string argv[], fss_basic_list_read_data *data) {
- f_status status = f_none;
- f_status status2 = f_none;
-
- 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) {
- fl_macro_color_context_new(status2, data->context);
-
- if (f_status_is_error(status2)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- fss_basic_list_read_delete_data(data);
- return status2;
- }
- else {
- fl_color_load_context(&data->context, data->parameters[fss_basic_list_read_parameter_light].result == f_console_result_found);
- }
- }
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_list_read_total_parameters, fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- }
- else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- }
- else if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
- }
- else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status));
- }
-
fss_basic_list_read_delete_data(data);
return f_status_set_error(status);
}
+ f_status status2 = f_none;
+ status = f_none;
+
// execute parameter results
if (data->parameters[fss_basic_list_read_parameter_help].result == f_console_result_found) {
fss_basic_list_read_print_help(*data);
enum {
fss_basic_list_read_parameter_help,
fss_basic_list_read_parameter_light,
+ fss_basic_list_read_parameter_dark,
fss_basic_list_read_parameter_no_color,
fss_basic_list_read_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(fss_basic_list_read_short_name, fss_basic_list_read_long_name, 0, f_true, f_console_type_normal), \
f_console_parameter_initialize(fss_basic_list_read_short_line, fss_basic_list_read_long_line, 0, f_true, f_console_type_normal), \
}
- #define fss_basic_list_read_total_parameters 10
+ #define fss_basic_list_read_total_parameters 11
#endif // _di_fss_basic_list_read_defines_
#ifndef _di_fss_basic_list_read_data_
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
#ifndef _di_fss_basic_list_write_main_
f_return_status fss_basic_list_write_main(const f_array_length argc, const f_string argv[], fss_basic_list_write_data *data) {
- f_status status = f_none;
- f_status status2 = f_none;
-
- status = fl_process_parameters(argc, argv, data->parameters, fss_basic_list_write_total_parameters, &data->remaining);
-
- // load colors when not told to show no colors
- if (data->parameters[fss_basic_list_write_parameter_no_color].result == f_console_result_none) {
- fl_macro_color_context_new(status2, data->context);
-
- if (f_status_is_error(status2)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- fss_basic_list_write_delete_data(data);
- return status2;
- }
- else {
- fl_color_load_context(&data->context, data->parameters[fss_basic_list_write_parameter_light].result == f_console_result_found);
- }
- }
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_list_write_total_parameters, fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- }
- else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
- }
- else if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
- }
- else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", f_status_set_error(status));
- }
-
fss_basic_list_write_delete_data(data);
return f_status_set_error(status);
}
+ status = f_none;
+
// execute parameter results
if (data->parameters[fss_basic_list_write_parameter_help].result == f_console_result_found) {
fss_basic_list_write_print_help(*data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
}
+ f_status status2 = f_none;
+
f_macro_string_dynamic_delete(status2, input);
fss_basic_list_write_delete_data(data);
return f_status_set_error(status);
enum {
fss_basic_list_write_parameter_help,
fss_basic_list_write_parameter_light,
+ fss_basic_list_write_parameter_dark,
fss_basic_list_write_parameter_no_color,
fss_basic_list_write_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(fss_basic_list_write_short_object, fss_basic_list_write_long_object, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(fss_basic_list_write_short_string, fss_basic_list_write_long_string, 0, f_true, f_console_type_normal), \
}
- #define fss_basic_list_write_total_parameters 7
+ #define fss_basic_list_write_total_parameters 8
#endif // _di_fss_basic_list_write_defines_
#ifndef _di_fss_basic_list_write_data_
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
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_gcc_attribute_visibility_internal;
f_return_status fss_basic_read_main(const f_array_length argc, const f_string argv[], fss_basic_read_data *data) {
- f_status status = f_none;
- f_status status2 = f_none;
-
- 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) {
- fl_macro_color_context_new(status2, data->context);
-
- if (f_status_is_error(status2)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- fss_basic_read_delete_data(data);
- return status2;
- }
- else {
- fl_color_load_context(&data->context, data->parameters[fss_basic_read_parameter_light].result == f_console_result_found);
- }
- }
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_read_total_parameters, fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- }
- else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- }
- else if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
- }
- else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status));
- }
-
fss_basic_read_delete_data(data);
return f_status_set_error(status);
}
+ f_status status2 = f_none;
+ status = f_none;
+
// execute parameter results
if (data->parameters[fss_basic_read_parameter_help].result == f_console_result_found) {
fss_basic_read_print_help(*data);
enum {
fss_basic_read_parameter_help,
fss_basic_read_parameter_light,
+ fss_basic_read_parameter_dark,
fss_basic_read_parameter_no_color,
fss_basic_read_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(fss_basic_read_short_name, fss_basic_read_long_name, 0, f_true, f_console_type_normal), \
f_console_parameter_initialize(fss_basic_read_short_object, fss_basic_read_long_object, 0, f_false, f_console_type_normal), \
}
- #define fss_basic_read_total_parameters 8
+ #define fss_basic_read_total_parameters 9
#endif // _di_fss_basic_read_defines_
#ifndef _di_fss_basic_read_data_
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
#ifndef _di_fss_basic_write_main_
f_return_status fss_basic_write_main(const f_array_length argc, const f_string argv[], fss_basic_write_data *data) {
- f_status status = f_none;
- f_status status2 = f_none;
-
- status = fl_process_parameters(argc, argv, data->parameters, fss_basic_write_total_parameters, &data->remaining);
-
- // load colors when not told to show no colors
- if (data->parameters[fss_basic_write_parameter_no_color].result == f_console_result_none) {
- fl_macro_color_context_new(status2, data->context);
-
- if (f_status_is_error(status2)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- fss_basic_write_delete_data(data);
- return status2;
- }
- else {
- fl_color_load_context(&data->context, data->parameters[fss_basic_write_parameter_light].result == f_console_result_found);
- }
- }
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_basic_write_total_parameters, fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- }
- else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
- }
- else if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
- }
- else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", f_status_set_error(status));
- }
-
fss_basic_write_delete_data(data);
return f_status_set_error(status);
}
+ status = f_none;
+
// execute parameter results
if (data->parameters[fss_basic_write_parameter_help].result == f_console_result_found) {
fss_basic_write_print_help(*data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
}
+ f_status status2 = f_none;
+
f_macro_string_dynamic_delete(status2, input);
fss_basic_write_delete_data(data);
return f_status_set_error(status);
enum {
fss_basic_write_parameter_help,
fss_basic_write_parameter_light,
+ fss_basic_write_parameter_dark,
fss_basic_write_parameter_no_color,
fss_basic_write_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(fss_basic_write_short_object, fss_basic_write_long_object, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(fss_basic_write_short_string, fss_basic_write_long_string, 0, f_true, f_console_type_normal), \
}
- #define fss_basic_write_total_parameters 7
+ #define fss_basic_write_total_parameters 8
#endif // _di_fss_basic_write_defines_
#ifndef _di_fss_basic_write_data_
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
f_return_status fss_extended_read_main_process_file(const f_array_length argc, const f_string argv[], fss_extended_read_data *data, const f_string filename, const f_string_length target, const f_string_length select) f_gcc_attribute_visibility_internal;
f_return_status fss_extended_read_main(const f_array_length argc, const f_string argv[], fss_extended_read_data *data) {
- f_status status = f_none;
- f_status status2 = f_none;
-
- 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) {
- fl_macro_color_context_new(status2, data->context);
-
- if (f_status_is_error(status2)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- fss_extended_read_delete_data(data);
- return status2;
- }
- else {
- fl_color_load_context(&data->context, data->parameters[fss_extended_read_parameter_light].result == f_console_result_found);
- }
- }
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_extended_read_total_parameters, fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- }
- else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory");
- }
- else if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
- }
- else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status));
- }
-
fss_extended_read_delete_data(data);
return f_status_set_error(status);
}
+ f_status status2 = f_none;
+ status = f_none;
+
// execute parameter results
if (data->parameters[fss_extended_read_parameter_help].result == f_console_result_found) {
fss_extended_read_print_help(*data);
enum {
fss_extended_read_parameter_help,
fss_extended_read_parameter_light,
+ fss_extended_read_parameter_dark,
fss_extended_read_parameter_no_color,
fss_extended_read_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(fss_extended_read_short_name, fss_extended_read_long_name, 0, f_true, f_console_type_normal), \
f_console_parameter_initialize(fss_extended_read_short_select, fss_extended_read_long_select, 0, f_true, f_console_type_normal), \
}
- #define fss_extended_read_total_parameters 9
+ #define fss_extended_read_total_parameters 10
#endif // _di_fss_extended_read_defines_
#ifndef _di_fss_extended_read_data_
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
#ifndef _di_fss_extended_write_main_
f_return_status fss_extended_write_main(const f_array_length argc, const f_string argv[], fss_extended_write_data *data) {
- f_status status = f_none;
- f_status status2 = f_none;
-
- status = fl_process_parameters(argc, argv, data->parameters, fss_extended_write_total_parameters, &data->remaining);
-
- // load colors when not told to show no colors
- if (data->parameters[fss_extended_write_parameter_no_color].result == f_console_result_none) {
- fl_macro_color_context_new(status2, data->context);
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_extended_write_total_parameters, fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark, &data->remaining, &data->context);
- if (f_status_is_error(status2)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- fss_extended_write_delete_data(data);
- return status2;
- }
- else {
- fl_color_load_context(&data->context, data->parameters[fss_extended_write_parameter_light].result == f_console_result_found);
- }
+ if (f_status_is_error(status)) {
+ fss_extended_write_delete_data(data);
+ return f_status_set_error(status);
}
+ status = f_none;
+
if (f_status_is_error(status)) {
status = f_status_set_fine(status);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", f_status_set_error(status));
}
+ f_status status2 = f_none;
+
f_macro_string_dynamic_delete(status2, input);
fss_extended_write_delete_data(data);
return f_status_set_error(status);
enum {
fss_extended_write_parameter_help,
fss_extended_write_parameter_light,
+ fss_extended_write_parameter_dark,
fss_extended_write_parameter_no_color,
fss_extended_write_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(fss_extended_write_short_object, fss_extended_write_long_object, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(fss_extended_write_short_partial, fss_extended_write_long_partial, 0, f_false, f_console_type_normal), \
}
- #define fss_extended_write_total_parameters 8
+ #define fss_extended_write_total_parameters 9
#endif // _di_fss_extended_write_defines_
#ifndef _di_fss_extended_write_data_
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
#ifndef _di_fss_status_code_main_
f_return_status fss_status_code_main(const f_array_length argc, const f_string argv[], fss_status_code_data *data) {
- f_status status = f_none;
- f_status allocation_status = f_none;
-
- status = fl_process_parameters(argc, argv, data->parameters, fss_status_code_total_parameters, &data->remaining);
-
- // load colors when not told to show no colors
- if (data->parameters[fss_status_code_parameter_no_color].result == f_console_result_none) {
- fl_macro_color_context_new(allocation_status, data->context);
-
- if (f_status_is_error(allocation_status)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- fss_status_code_delete_data(data);
- return allocation_status;
- }
-
- fl_color_load_context(&data->context, data->parameters[fss_status_code_parameter_light].result == f_console_result_found);
- }
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, fss_status_code_total_parameters, fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- }
- else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
- }
- else if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
- }
- else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
- }
-
fss_status_code_delete_data(data);
return f_status_set_error(status);
}
+ status = f_none;
+
// execute parameter results
if (data->parameters[fss_status_code_parameter_help].result == f_console_result_found) {
fss_status_code_print_help(*data);
enum {
fss_status_code_parameter_help,
fss_status_code_parameter_light,
+ fss_status_code_parameter_dark,
fss_status_code_parameter_no_color,
fss_status_code_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(fss_status_code_short_is_fine, fss_status_code_long_is_fine, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(fss_status_code_short_number, fss_status_code_long_number, 0, f_false, f_console_type_normal), \
}
- #define fss_status_code_total_parameters 8
+ #define fss_status_code_total_parameters 9
#endif // _di_fss_status_code_defines_
#ifndef _di_fss_status_code_data_
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
fll_program_print_help_option(data.context, f_console_standard_short_debug, f_console_standard_long_debug, " Enable debugging.");
#ifndef _di_init_main_
f_return_status init_main(const f_s_int argc, const f_string argv[], init_argument *argument) {
f_status status = f_none;
- f_status status2 = f_none;
f_autochar run_level[init_kernel_runlevel_buffer];
memset(run_level, 0, sizeof(f_autochar) * init_kernel_runlevel_buffer);
f_u_short do_socket_file = f_true;
f_u_short do_socket_port = f_false;
- status = fl_process_parameters(argc, argv, argument->parameters, init_total_parameters, &argument->remaining);
-
- // load colors when not told to show no colors
- if (argument->parameters[init_parameter_no_color].result == f_console_result_none) {
- fl_macro_color_context_new(status2, argument->context);
-
- if (status2 == f_none) {
- fl_color_load_context(&argument->context, argument->parameters[init_parameter_light].result == f_console_result_found);
- } else {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- init_delete_argument((*argument));
- return status2;
- }
- }
+ status = fll_program_process_parameters(argc, argv, data->parameters, init_total_parameters, init_parameter_no_color, init_parameter_light, init_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- } else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "CRITICAL ERROR: unable to allocate memory");
- } else if (f_status_set_fine(status) == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters()");
- } else {
- fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters()", f_status_set_error(status));
- }
-
- init_delete_argument((*argument));
+ init_delete_data(data);
return f_status_set_error(status);
}
+ status = f_none;
+
if (argument->parameters[init_parameter_runlevel].result == f_console_result_found) {
const f_u_int parameter_length = strlen(argv[argument->parameters[init_parameter_runlevel].additional.array[0]]);
enum {
init_parameter_help,
init_parameter_light,
+ init_parameter_dark,
init_parameter_no_color,
init_parameter_version,
- init_parameter_debug,
+
+ #ifdef _en_init_debug_
+ init_parameter_debug,
+ #endif // _en_init_debug_
+
init_parameter_runlevel,
init_parameter_no_prepare,
};
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(init_parameter_no_prepare_short_name, init_parameter_no_prepare_long_name, 0, f_true, f_console_type_normal), \
}
- #define init_total_parameters 7
+ #define init_total_parameters 8
#else
#define f_console_parameter_initialize_init \
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(init_parameter_runlevel_short_name, init_parameter_runlevel_long_name, 0, f_true, f_console_type_normal), \
f_console_parameter_initialize(init_parameter_no_prepare_short_name, init_parameter_no_prepare_long_name, 0, f_true, f_console_type_normal), \
}
- #define init_total_parameters 6
+ #define init_total_parameters 7
#endif // _en_init_debug_
#endif // _di_init_defines_
f_string_location location = f_string_location_initialize;
f_fss_objects objects = f_fss_objects_initialize;
f_fss_contents contents = f_fss_contents_initialize;
- f_string_length position = f_string_length_initialize;
+ f_string_length position = 0;
// load the main file into memory.
status = init_rule_buffer(init_rule_core_file, &buffer, &objects, &contents);
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, " Print this help message.");
fll_program_print_help_option(data.context, f_console_standard_short_light, f_console_standard_long_light, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(data.context, f_console_standard_short_dark, f_console_standard_long_dark, " Output using colors that show up better on dark backgrounds.");
fll_program_print_help_option(data.context, f_console_standard_short_no_color, f_console_standard_long_no_color, "Do not output in color.");
fll_program_print_help_option(data.context, f_console_standard_short_version, f_console_standard_long_version, " Print only the version number.");
#ifndef _di_status_code_main_
f_return_status status_code_main(const f_array_length argc, const f_string argv[], status_code_data *data) {
- f_status status = f_none;
- f_status allocation_status = f_none;
-
- status = fl_process_parameters(argc, argv, data->parameters, status_code_total_parameters, &data->remaining);
-
- // load colors when not told to show no colors
- if (data->parameters[status_code_parameter_no_color].result == f_console_result_none) {
- fl_macro_color_context_new(allocation_status, data->context);
-
- if (f_status_is_error(allocation_status)) {
- fprintf(f_standard_error, "Critical Error: unable to allocate memory\n");
- status_code_delete_data(data);
- return allocation_status;
- }
-
- fl_color_load_context(&data->context, data->parameters[status_code_parameter_light].result == f_console_result_found);
- }
+ f_status status = fll_program_process_parameters(argc, argv, data->parameters, status_code_total_parameters, status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark, &data->remaining, &data->context);
if (f_status_is_error(status)) {
- status = f_status_set_fine(status);
-
- if (status == f_no_data) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless argv[] is improperly created
- }
- else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
- }
- else if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_process_parameters().");
- }
- else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_process_parameters().", status);
- }
-
status_code_delete_data(data);
return f_status_set_error(status);
}
+ status = f_none;
+
// execute parameter results
if (data->parameters[status_code_parameter_help].result == f_console_result_found) {
status_code_print_help(*data);
enum {
status_code_parameter_help,
status_code_parameter_light,
+ status_code_parameter_dark,
status_code_parameter_no_color,
status_code_parameter_version,
{ \
f_console_parameter_initialize(f_console_standard_short_help, f_console_standard_long_help, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, f_false, f_console_type_inverse), \
+ f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \
f_console_parameter_initialize(status_code_short_is_fine, status_code_long_is_fine, 0, f_false, f_console_type_normal), \
f_console_parameter_initialize(status_code_short_number, status_code_long_number, 0, f_false, f_console_type_normal), \
}
- #define status_code_total_parameters 8
+ #define status_code_total_parameters 9
#endif // _di_status_code_defines_
#ifndef _di_status_code_data_