I ended up liking how I made iki_write better than how I made the fss write functions.
Work began to make these more similar and consistent and I stumbled on some other things that need to be centralized.
This would be the verbosity options and parameter decision making.
This includes related changes.
I also noticed that I started working on the "++status" parameter idea but left it very incomplete.
This formalizes the basic plan where I will instead have a "++status_in" and a "++status_out".
This should be very useful for having programs return status codes as well as read those via environment variables given than the status code the Linux code uses reserves the higher order bits for process signals.
It would be too risky and likely buggy to mix my internal status code system with the standard Linux signal/error status code design.
A sting can be read very easily in an environment variable and converted to the appropriate uint16_t digit.
The work in regards to making FSS and other programs more consistent is incompletely and will likely result in uncompilable code with this commit.
* It is acceptable for any of these options, when specified multiple times, for that number of times to represent the "level".
* For example, a "+D +D" means more debug output than simply "+D".
*
- * The following options are subjective in interpretation but are expected to follow the general interpretation:
+ * The verbosity interpretation used as the default for many of the level 3 programs in this process, is to treat verbosity modes as a scale from quiet to debug with quiet as the least verbose and debug as the most verbose.
+ * This is not stricly a requirement, but expect level 3 projects to work this way.
+ *
+ * The following options are subjective in interpretation of the verbosity but are expected to be follow the general interpretation:
* - debug: Enable debugging, which will likely increase output verbosity.
+ * - normal: Use normal printing (don't use debug/quiet/verbose).
* - quiet: Decrease verbosity, print less, in some use cases this could mean printing nothing.
* - verbose: Increase verbosity, print more, in some use cases this could mean printing just about everything.
*
* - version: Should always print only the version number, no colors, but what represents the version number is undefined by this project.
*
* The following options are for special purposes:
- * - status: Represents the return status code from another program.
- * Because it is associated with the status from another program, its structure is very subjective.
- * The only expectation is that it somehow communicates the fss status codes.
- * Example of complex use: "failed_program_name:error:123".
- * Example of simple use: "123".
+ * - status_in: Is intended to accept the name of an environment variable in which to read the status from.
+ * - status_out: Is intended to accept the name of an environment variable in which to ride the status to.
+ *
+ * In the case of "status_in" and "status_out", the environment variable will store a string representing the base-10 unsigned 16-bit status code.
+ * - In the case of "status_in" the environment variable is being read in, which means that it should be the status from some previous execution.
+ * - In the case of "status_out" the environment variable is being written to, which means that it should store the status this program exits with.
+ * - To avoid problems with the status code after a program is forcibly killed, the status_out environment variable should be cleared at program start.
*/
#ifndef _di_f_standard_console_parameters_
- #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_quiet "q"
- #define f_console_standard_short_verbose "V"
- #define f_console_standard_short_version "v"
-
- #define f_console_standard_short_dark_length 1
- #define f_console_standard_short_debug_length 1
- #define f_console_standard_short_help_length 1
- #define f_console_standard_short_light_length 1
- #define f_console_standard_short_no_color_length 1
- #define f_console_standard_short_quiet_length 1
- #define f_console_standard_short_verbose_length 1
- #define f_console_standard_short_version_length 1
-
- #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_standard_long_no_color "no_color"
- #define f_console_standard_long_status "status"
- #define f_console_standard_long_quiet "quiet"
- #define f_console_standard_long_verbose "verbose"
- #define f_console_standard_long_version "version"
-
- #define f_console_standard_long_dark_length 4
- #define f_console_standard_long_debug_length 5
- #define f_console_standard_long_help_length 4
- #define f_console_standard_long_light_length 5
- #define f_console_standard_long_no_color_length 8
- #define f_console_standard_long_status_length 6
- #define f_console_standard_long_quiet_length 5
- #define f_console_standard_long_verbose_length 7
- #define f_console_standard_long_version_length 7
+ #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_normal "N"
+ #define f_console_standard_short_quiet "q"
+ #define f_console_standard_short_status_in "s"
+ #define f_console_standard_short_status_out "S"
+ #define f_console_standard_short_verbose "V"
+ #define f_console_standard_short_version "v"
+
+ #define f_console_standard_short_dark_length 1
+ #define f_console_standard_short_debug_length 1
+ #define f_console_standard_short_help_length 1
+ #define f_console_standard_short_light_length 1
+ #define f_console_standard_short_no_color_length 1
+ #define f_console_standard_short_normal_length 1
+ #define f_console_standard_short_quiet_length 1
+ #define f_console_standard_short_status_in_length 1
+ #define f_console_standard_short_status_out_length 1
+ #define f_console_standard_short_verbose_length 1
+ #define f_console_standard_short_version_length 1
+
+ #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_standard_long_no_color "no_color"
+ #define f_console_standard_long_normal "normal"
+ #define f_console_standard_long_quiet "quiet"
+ #define f_console_standard_long_status_in "status_in"
+ #define f_console_standard_long_status_out "status_out"
+ #define f_console_standard_long_verbose "verbose"
+ #define f_console_standard_long_version "version"
+
+ #define f_console_standard_long_dark_length 4
+ #define f_console_standard_long_debug_length 5
+ #define f_console_standard_long_help_length 4
+ #define f_console_standard_long_light_length 5
+ #define f_console_standard_long_no_color_length 8
+ #define f_console_standard_long_normal_length 6
+ #define f_console_standard_long_quiet_length 5
+ #define f_console_standard_long_status_in_length 9
+ #define f_console_standard_long_status_out_length 10
+ #define f_console_standard_long_verbose_length 7
+ #define f_console_standard_long_version_length 7
#endif // _di_f_standard_console_parameters_
/**
} f_console_parameter_t;
#define f_console_parameter_t_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_t_initialize, f_string_lengths_t_initialize }
+
+ #define f_macro_console_parameter_t_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value, result, total, location, location_sub, locations, additional) { symbol_short, symbol_long, symbol_other, has_additional, type_value, result, total, location, location_sub, locations, additional }
#endif // _di_f_console_parameter_t_
/**
} f_console_parameters_t;
#define f_console_parameters_t_initialize { 0, 0 }
+
+ #define f_macro_console_parameters_t_initialize(parameter, used) { parameter, used }
#endif // _di_f_console_parameters_t_
/**
} f_console_parameter_ids_t;
#define f_console_parameter_ids_t_initialize { 0, 0 }
+
+ #define f_macro_console_parameter_ids_t_initialize(id, used) { id, used }
#endif // _di_f_console_parameter_id_t_
/**
const f_string_t *argv;
} f_console_arguments_t;
+
+ #define f_console_arguments_t_initialize { 0, 0 }
+
+ #define f_macro_console_arguments_t_initialize(argc, argv) { argc, argv }
#endif // _di_f_console_arguments_t_
#ifdef __cplusplus
fll_program_print_help_header(context, byte_dump_name_long, byte_dump_version);
- fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
- fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
- fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, " Do not output in color.");
- fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
+ fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
+ fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
f_status_t status = F_none;
{
- const f_console_parameters_t parameters = { data->parameters, byte_dump_total_parameters };
- f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize;
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, byte_dump_total_parameters);
// Identify priority of color parameters.
{
f_console_parameter_id_t ids[3] = { byte_dump_parameter_no_color, byte_dump_parameter_light, byte_dump_parameter_dark };
-
- choices.id = ids;
- choices.used = 3;
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
status = F_none;
}
+ // Identify priority of verbosity related parameters.
+ {
+ f_console_parameter_id_t ids[4] = { byte_dump_parameter_verbosity_quiet, byte_dump_parameter_verbosity_normal, byte_dump_parameter_verbosity_verbose, byte_dump_parameter_verbosity_debug };
+ f_console_parameter_id_t choice = 0;
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4);
+
+ status = f_console_parameter_prioritize_right(parameters, choices, &choice);
+
+ if (F_status_is_error(status)) {
+ byte_dump_delete_data(data);
+ return status;
+ }
+
+ if (choice == byte_dump_parameter_verbosity_quiet) {
+ data->verbosity = f_console_verbosity_quiet;
+ }
+ else if (choice == byte_dump_parameter_verbosity_normal) {
+ data->verbosity = f_console_verbosity_normal;
+ }
+ else if (choice == byte_dump_parameter_verbosity_verbose) {
+ data->verbosity = f_console_verbosity_verbose;
+ }
+ else if (choice == byte_dump_parameter_verbosity_debug) {
+ data->verbosity = f_console_verbosity_debug;
+ }
+ }
+
// Identify priority of mode parameters.
{
f_console_parameter_id_t ids[5] = { byte_dump_parameter_hexidecimal, byte_dump_parameter_duodecimal, byte_dump_parameter_octal, byte_dump_parameter_binary, byte_dump_parameter_decimal };
f_console_parameter_id_t choice = byte_dump_parameter_hexidecimal;
-
- choices.id = ids;
- choices.used = 5;
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 5);
status = f_console_parameter_prioritize_right(parameters, choices, &choice);
{
f_console_parameter_id_t ids[3] = { byte_dump_parameter_normal, byte_dump_parameter_simple, byte_dump_parameter_classic };
f_console_parameter_id_t choice = byte_dump_parameter_normal;
-
- choices.id = ids;
- choices.used = 3;
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
status = f_console_parameter_prioritize_right(parameters, choices, &choice);
data->presentation = byte_dump_presentation_classic;
}
}
- }
- status = F_none;
+ status = F_none;
+ }
if (data->parameters[byte_dump_parameter_help].result == f_console_result_found) {
byte_dump_print_help(data->context);
+
+ byte_dump_delete_data(data);
+ return F_none;
}
- else if (data->parameters[byte_dump_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[byte_dump_parameter_version].result == f_console_result_found) {
fll_program_print_version(byte_dump_version);
+
+ byte_dump_delete_data(data);
+ return F_none;
}
- else if (data->remaining.used > 0 || data->process_pipe) {
+
+ if (data->remaining.used > 0 || data->process_pipe) {
if (data->parameters[byte_dump_parameter_width].result == f_console_result_found) {
fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '");
fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, byte_dump_long_width);
byte_dump_parameter_light,
byte_dump_parameter_dark,
byte_dump_parameter_no_color,
+ byte_dump_parameter_verbosity_quiet,
+ byte_dump_parameter_verbosity_normal,
+ byte_dump_parameter_verbosity_verbose,
+ byte_dump_parameter_verbosity_debug,
byte_dump_parameter_version,
byte_dump_parameter_binary,
f_console_parameter_t_initialize(f_console_standard_short_light, f_console_standard_long_light, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_console_type_inverse), \
+ f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \
+ f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \
+ f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \
+ f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(byte_dump_short_binary, byte_dump_long_binary, 0, 0, f_console_type_normal), \
f_console_parameter_t_initialize(byte_dump_short_decimal, byte_dump_long_decimal, 0, 0, f_console_type_normal), \
f_console_parameter_t_initialize(0, byte_dump_long_classic, 0, 0, f_console_type_normal), \
}
- #define byte_dump_total_parameters 18
+ #define byte_dump_total_parameters 22
#endif // _di_byte_dump_defines_
#ifndef _di_byte_dump_data_t_
f_string_lengths_t remaining;
bool process_pipe;
+ uint8_t verbosity;
+
uint64_t first;
uint64_t last;
uint8_t width;
byte_dump_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
0, \
0, \
8, \
fll_program_print_help_header(context, fake_name_long, fake_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
f_status_t status = F_none;
{
- const f_console_parameters_t parameters = { data->parameters, fake_total_parameters };
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fake_total_parameters);
// Load all parameters and identify priority of color parameters.
{
f_console_parameter_id_t ids[3] = { fake_parameter_no_color, fake_parameter_light, fake_parameter_dark };
- f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize;
-
- choices.id = ids;
- choices.used = 3;
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
// Identify priority of verbosity related parameters.
{
- f_console_parameter_id_t ids[3] = { fake_parameter_quiet, fake_parameter_verbose, fake_parameter_debug };
- f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize;
+ f_console_parameter_id_t ids[4] = { fake_parameter_quiet, fake_parameter_normal, fake_parameter_verbose, fake_parameter_debug };
f_console_parameter_id_t choice = 0;
-
- choices.id = ids;
- choices.used = 3;
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 4);
status = f_console_parameter_prioritize_right(parameters, choices, &choice);
if (choice == fake_parameter_quiet) {
data->verbosity = f_console_verbosity_quiet;
}
+ else if (choice == fake_parameter_normal) {
+ data->verbosity = f_console_verbosity_normal;
+ }
else if (choice == fake_parameter_verbose) {
data->verbosity = f_console_verbosity_verbose;
}
if (data->parameters[fake_parameter_help].result == f_console_result_found) {
fake_print_help(data->context);
+
+ fake_delete_data(data);
+ return F_none;
}
- else if (data->parameters[fake_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fake_parameter_version].result == f_console_result_found) {
fll_program_print_version(fake_version);
+
+ fake_delete_data(data);
+ return F_none;
}
- else if (operations_length) {
+
+ if (operations_length) {
bool validate_parameter_directories = F_true;
status = fake_process_console_parameters(arguments, data);
fake_parameter_dark,
fake_parameter_debug,
fake_parameter_no_color,
+ fake_parameter_normal,
fake_parameter_quiet,
fake_parameter_verbose,
fake_parameter_version,
f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, 0, f_console_type_inverse), \
+ f_console_parameter_t_initialize(f_console_standard_short_normal, f_console_standard_long_normal, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_quiet, f_console_standard_long_quiet, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \
f_console_parameter_t_initialize(0, 0, fake_other_operation_skeleton, 0, f_console_type_other), \
}
- #define fake_total_parameters 27
+ #define fake_total_parameters 28
#endif // _di_fake_defines_
#ifndef _di_fake_data_t_
f_string_lengths_t remaining;
bool process_pipe;
+
+ uint8_t verbosity;
+ uint8_t operation;
+
mode_t umask;
f_signal_t signal;
- uint8_t operation;
- uint8_t verbosity;
f_string_dynamics_t define;
f_string_dynamic_t fakefile;
fake_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
0, \
- f_signal_t_initialize, \
0, \
- f_console_verbosity_normal, \
+ f_signal_t_initialize, \
f_string_dynamics_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamics_t_initialize, \
fll_program_print_help_header(context, firewall_name_long, firewall_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
#ifdef _en_firewall_debug_
{
f_console_parameter_id_t ids[3] = { firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, firewall_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, firewall_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[firewall_parameter_help].result == f_console_result_found) {
firewall_print_help(data->context);
+
+ firewall_delete_data(data);
+ return F_none;
}
- else if (data->parameters[firewall_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[firewall_parameter_version].result == f_console_result_found) {
fll_program_print_version(firewall_version);
+
+ firewall_delete_data(data);
+ return F_none;
}
- else {
- // now determine which command was placed first
- bool found_command = F_false;
- unsigned int command = 0;
- if (data->parameters[firewall_parameter_command_start].result == f_console_result_found) {
- command = firewall_parameter_command_start;
- found_command = F_true;
- }
+ // now determine which command was placed first
+ bool found_command = F_false;
+ unsigned int command = 0;
- if (data->parameters[firewall_parameter_command_stop].result == f_console_result_found) {
- if (found_command) {
- if (data->parameters[command].additional.array[0] > data->parameters[firewall_parameter_command_stop].additional.array[0]) {
- command = firewall_parameter_command_stop;
- }
- }
- else {
+ 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.array[0] > data->parameters[firewall_parameter_command_stop].additional.array[0]) {
command = firewall_parameter_command_stop;
- found_command = F_true;
}
}
+ else {
+ command = firewall_parameter_command_stop;
+ found_command = F_true;
+ }
+ }
- if (data->parameters[firewall_parameter_command_restart].result == f_console_result_found) {
- if (found_command) {
- if (data->parameters[command].additional.array[0] > data->parameters[firewall_parameter_command_restart].additional.array[0]) {
- command = firewall_parameter_command_restart;
- }
- }
- else {
+ if (data->parameters[firewall_parameter_command_restart].result == f_console_result_found) {
+ if (found_command) {
+ if (data->parameters[command].additional.array[0] > data->parameters[firewall_parameter_command_restart].additional.array[0]) {
command = firewall_parameter_command_restart;
- found_command = F_true;
}
}
+ else {
+ command = firewall_parameter_command_restart;
+ found_command = F_true;
+ }
+ }
- if (data->parameters[firewall_parameter_command_lock].result == f_console_result_found) {
- if (found_command) {
- if (data->parameters[command].additional.array[0] > data->parameters[firewall_parameter_command_lock].additional.array[0]) {
- command = firewall_parameter_command_lock;
- }
- }
- else {
+ if (data->parameters[firewall_parameter_command_lock].result == f_console_result_found) {
+ if (found_command) {
+ if (data->parameters[command].additional.array[0] > data->parameters[firewall_parameter_command_lock].additional.array[0]) {
command = firewall_parameter_command_lock;
- found_command = F_true;
}
}
+ else {
+ command = firewall_parameter_command_lock;
+ found_command = F_true;
+ }
+ }
- if (data->parameters[firewall_parameter_command_show].result == f_console_result_found) {
- if (found_command) {
- if (data->parameters[command].additional.array[0] > data->parameters[firewall_parameter_command_show].additional.array[0]) {
- command = firewall_parameter_command_show;
- }
- }
- else {
+ if (data->parameters[firewall_parameter_command_show].result == f_console_result_found) {
+ if (found_command) {
+ if (data->parameters[command].additional.array[0] > data->parameters[firewall_parameter_command_show].additional.array[0]) {
command = firewall_parameter_command_show;
- found_command = F_true;
}
}
+ else {
+ command = firewall_parameter_command_show;
+ found_command = F_true;
+ }
+ }
- if (found_command) {
- firewall_local_data_t local = firewall_local_data_t_initialize;
- firewall_reserved_chains_t reserved = firewall_reserved_chains_t_initialize;
- f_string_range_t input = f_string_range_t_initialize;
-
- 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)
- bool show_nat = F_true;
- bool show_mangle = F_true;
- bool show_ports = F_true;
-
- f_string_dynamics_t parameters = f_string_dynamics_t_initialize;
- int return_code = 0;
-
- if (data->remaining.used > 0) {
- show_nat = F_false;
- show_mangle = F_false;
- show_ports = F_false;
-
- f_string_length_t counter = 0;
-
- for (; counter < data->remaining.used; counter++) {
-
- if (strncmp("nat", arguments.argv[data->remaining.array[counter]], 4) != 0) {
- if (strncmp("mangle", arguments.argv[data->remaining.array[counter]], 7) != 0) {
- if (strncmp("ports", arguments.argv[data->remaining.array[counter]], 6) != 0) {
- fl_color_print_line(f_type_warning, data->context.set.warning, "WARNING: '%s' is not a valid show option", arguments.argv[data->remaining.array[counter]]);
- }
- else {
- show_ports = F_true;
- }
- }
- else {
- show_mangle = F_true;
- }
- }
- else {
- show_nat = F_true;
- }
- } // for
- }
-
- f_macro_string_dynamics_resize(status, parameters, 7);
-
- if (F_status_is_error(status)) {
- fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.");
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- }
+ if (found_command) {
+ firewall_local_data_t local = firewall_local_data_t_initialize;
+ firewall_reserved_chains_t reserved = firewall_reserved_chains_t_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
- if (show_nat) {
- fl_color_print(f_type_output, data->context.set.standout, "=========================== ");
- fl_color_print(f_type_output, data->context.set.title, "NAT");
- fl_color_print_line(f_type_output, data->context.set.standout, " ============================");
- fflush(f_type_output);
+ 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)
+ bool show_nat = F_true;
+ bool show_mangle = F_true;
+ bool show_ports = F_true;
- parameters.used = 6;
+ f_string_dynamics_t parameters = f_string_dynamics_t_initialize;
+ int return_code = 0;
- parameters.array[0].string = (f_string_t) "-x";
- parameters.array[1].string = (f_string_t) "-v";
- parameters.array[2].string = (f_string_t) "-t";
- parameters.array[3].string = (f_string_t) "nat";
- parameters.array[4].string = (f_string_t) "--numeric";
- parameters.array[5].string = (f_string_t) "--list";
+ if (data->remaining.used > 0) {
+ show_nat = F_false;
+ show_mangle = F_false;
+ show_ports = F_false;
- parameters.array[0].used = 2;
- parameters.array[1].used = 2;
- parameters.array[2].used = 2;
- parameters.array[3].used = 3;
- parameters.array[4].used = 9;
- parameters.array[5].used = 6;
+ f_string_length_t counter = 0;
- status = fll_execute_program((f_string_t) firewall_tool_iptables, parameters, 0, &return_code);
+ for (; counter < data->remaining.used; counter++) {
- fprintf(f_type_output, "\n");
- fflush(f_type_output);
- }
+ if (strncmp("nat", arguments.argv[data->remaining.array[counter]], 4) != 0) {
+ if (strncmp("mangle", arguments.argv[data->remaining.array[counter]], 7) != 0) {
+ if (strncmp("ports", arguments.argv[data->remaining.array[counter]], 6) != 0) {
+ fl_color_print_line(f_type_warning, data->context.set.warning, "WARNING: '%s' is not a valid show option", arguments.argv[data->remaining.array[counter]]);
+ }
+ else {
+ show_ports = F_true;
+ }
+ }
+ else {
+ show_mangle = F_true;
+ }
+ }
+ else {
+ show_nat = F_true;
+ }
+ } // for
+ }
- if (F_status_is_error_not(status) && show_mangle) {
- fl_color_print(f_type_output, data->context.set.standout, "========================== ");
- fl_color_print(f_type_output, data->context.set.title, "MANGLE");
- fl_color_print_line(f_type_output, data->context.set.standout, " ==========================");
- fflush(f_type_output);
+ f_macro_string_dynamics_resize(status, parameters, 7);
- parameters.used = 6;
+ if (F_status_is_error(status)) {
+ fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.");
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
+ }
- parameters.array[0].string = (f_string_t) "-x";
- parameters.array[1].string = (f_string_t) "-v";
- parameters.array[2].string = (f_string_t) "-t";
- parameters.array[3].string = (f_string_t) "mangle";
- parameters.array[4].string = (f_string_t) "--numeric";
- parameters.array[5].string = (f_string_t) "--list";
+ if (show_nat) {
+ fl_color_print(f_type_output, data->context.set.standout, "=========================== ");
+ fl_color_print(f_type_output, data->context.set.title, "NAT");
+ fl_color_print_line(f_type_output, data->context.set.standout, " ============================");
+ fflush(f_type_output);
- parameters.array[0].used = 2;
- parameters.array[1].used = 2;
- parameters.array[2].used = 2;
- parameters.array[3].used = 6;
- parameters.array[4].used = 9;
- parameters.array[5].used = 6;
+ parameters.used = 6;
- status = fll_execute_program((f_string_t) firewall_tool_iptables, parameters, 0, &return_code);
+ parameters.array[0].string = (f_string_t) "-x";
+ parameters.array[1].string = (f_string_t) "-v";
+ parameters.array[2].string = (f_string_t) "-t";
+ parameters.array[3].string = (f_string_t) "nat";
+ parameters.array[4].string = (f_string_t) "--numeric";
+ parameters.array[5].string = (f_string_t) "--list";
- fprintf(f_type_output, "\n");
- fflush(f_type_output);
- }
+ parameters.array[0].used = 2;
+ parameters.array[1].used = 2;
+ parameters.array[2].used = 2;
+ parameters.array[3].used = 3;
+ parameters.array[4].used = 9;
+ parameters.array[5].used = 6;
- if (F_status_is_error_not(status) && show_ports) {
- fl_color_print(f_type_output, data->context.set.standout, "========================== ");
- fl_color_print(f_type_output, data->context.set.title, "FILTER");
- fl_color_print_line(f_type_output, data->context.set.standout, " ==========================");
- fflush(f_type_output);
+ status = fll_execute_program((f_string_t) firewall_tool_iptables, parameters, 0, &return_code);
- parameters.used = 4;
+ fprintf(f_type_output, "\n");
+ fflush(f_type_output);
+ }
- parameters.array[0].string = (f_string_t) "-x";
- parameters.array[1].string = (f_string_t) "-v";
- parameters.array[2].string = (f_string_t) "--numeric";
- parameters.array[3].string = (f_string_t) "--list";
+ if (F_status_is_error_not(status) && show_mangle) {
+ fl_color_print(f_type_output, data->context.set.standout, "========================== ");
+ fl_color_print(f_type_output, data->context.set.title, "MANGLE");
+ fl_color_print_line(f_type_output, data->context.set.standout, " ==========================");
+ fflush(f_type_output);
- parameters.array[0].used = 2;
- parameters.array[1].used = 2;
- parameters.array[2].used = 9;
- parameters.array[3].used = 6;
+ parameters.used = 6;
- status = fll_execute_program((f_string_t) firewall_tool_iptables, parameters, 0, &return_code);
+ parameters.array[0].string = (f_string_t) "-x";
+ parameters.array[1].string = (f_string_t) "-v";
+ parameters.array[2].string = (f_string_t) "-t";
+ parameters.array[3].string = (f_string_t) "mangle";
+ parameters.array[4].string = (f_string_t) "--numeric";
+ parameters.array[5].string = (f_string_t) "--list";
- fprintf(f_type_output, "\n");
- fflush(f_type_output);
- }
+ parameters.array[0].used = 2;
+ parameters.array[1].used = 2;
+ parameters.array[2].used = 2;
+ parameters.array[3].used = 6;
+ parameters.array[4].used = 9;
+ parameters.array[5].used = 6;
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = fll_execute_program((f_string_t) firewall_tool_iptables, parameters, 0, &return_code);
- if (status == F_memory_allocation || status == F_memory_reallocation) {
- fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.");
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables);
- fprintf(f_type_error, " ");
+ fprintf(f_type_output, "\n");
+ fflush(f_type_output);
+ }
- f_string_length_t i = 0;
+ if (F_status_is_error_not(status) && show_ports) {
+ fl_color_print(f_type_output, data->context.set.standout, "========================== ");
+ fl_color_print(f_type_output, data->context.set.title, "FILTER");
+ fl_color_print_line(f_type_output, data->context.set.standout, " ==========================");
+ fflush(f_type_output);
- fl_color_print_code(f_type_error, data->context.error);
+ parameters.used = 4;
- fprintf(f_type_error, "%s ", firewall_tool_iptables);
- for (; i < parameters.used; i++) {
- fprintf(f_type_error, "%s ", parameters.array[i].string);
- } // for
+ parameters.array[0].string = (f_string_t) "-x";
+ parameters.array[1].string = (f_string_t) "-v";
+ parameters.array[2].string = (f_string_t) "--numeric";
+ parameters.array[3].string = (f_string_t) "--list";
- fl_color_print_code(f_type_error, data->context.reset);
- fprintf(f_type_error, "\n");
- }
+ parameters.array[0].used = 2;
+ parameters.array[1].used = 2;
+ parameters.array[2].used = 9;
+ parameters.array[3].used = 6;
- status = F_status_set_error(status);
- }
+ status = fll_execute_program((f_string_t) firewall_tool_iptables, parameters, 0, &return_code);
- parameters.array[0].string = 0;
- parameters.array[1].string = 0;
- parameters.array[2].string = 0;
- parameters.array[3].string = 0;
- parameters.array[4].string = 0;
- parameters.array[5].string = 0;
- parameters.array[6].string = 0;
- parameters.array[0].used = 0;
- parameters.array[1].used = 0;
- parameters.array[2].used = 0;
- parameters.array[3].used = 0;
- parameters.array[4].used = 0;
- parameters.array[5].used = 0;
- parameters.array[6].used = 0;
-
- f_macro_string_dynamics_t_delete_simple( parameters);
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
+ fprintf(f_type_output, "\n");
+ fflush(f_type_output);
}
- // load all network devices
- status = f_directory_list((f_string_t) network_devices, 0, alphasort, &data->devices);
-
if (F_status_is_error(status)) {
status = F_status_set_fine(status);
if (status == F_memory_allocation || status == F_memory_reallocation) {
fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.");
}
- else if (status == F_data_not) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Could not find any network devices");
- }
- else if (status == F_failure) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to read the device directory '%s'", network_devices);
- }
-
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return F_status_set_error(status);
- }
-
- // remove "lo" (loopback) from the device listing
- {
- f_string_length_t i = 0;
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform requested %s operation:", firewall_tool_iptables);
+ fprintf(f_type_error, " ");
- for (; i < data->devices.used; i++) {
- if (fl_string_compare((f_string_t) firewall_device_loop, data->devices.array[i].string, firewall_device_loop_length + 1, data->devices.array[i].used) == F_equal_to) {
- f_string_dynamic_t swap_string = data->devices.array[i];
+ f_string_length_t i = 0;
- data->devices.used--;
+ fl_color_print_code(f_type_error, data->context.error);
- for (; i < data->devices.used; i++) {
- data->devices.array[i] = data->devices.array[i+1];
- } // for
-
- data->devices.array[data->devices.used] = swap_string;
- }
- } // for
- }
-
- if (command == firewall_parameter_command_stop || command == firewall_parameter_command_restart || command == firewall_parameter_command_lock) {
- status = firewall_buffer_rules(network_path firewall_file_other, F_false, &local, data);
+ fprintf(f_type_error, "%s ", firewall_tool_iptables);
+ for (; i < parameters.used; i++) {
+ fprintf(f_type_error, "%s ", parameters.array[i].string);
+ } // for
- if (F_status_is_error(status)) {
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
+ fl_color_print_code(f_type_error, data->context.reset);
+ fprintf(f_type_error, "\n");
}
- {
- f_array_length_t i = 0;
- f_string_length_t length = 0;
+ status = F_status_set_error(status);
+ }
- for (; i < local.chain_objects.used; i++) {
- length = local.chain_objects.array[i].stop - local.chain_objects.array[i].start + 1;
+ parameters.array[0].string = 0;
+ parameters.array[1].string = 0;
+ parameters.array[2].string = 0;
+ parameters.array[3].string = 0;
+ parameters.array[4].string = 0;
+ parameters.array[5].string = 0;
+ parameters.array[6].string = 0;
+ parameters.array[0].used = 0;
+ parameters.array[1].used = 0;
+ parameters.array[2].used = 0;
+ parameters.array[3].used = 0;
+ parameters.array[4].used = 0;
+ parameters.array[5].used = 0;
+ parameters.array[6].used = 0;
+
+ f_macro_string_dynamics_t_delete_simple( parameters);
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
+ }
- if (!reserved.has_stop && fl_string_compare((f_string_t) firewall_group_stop, local.buffer.string + local.chain_objects.array[i].start, firewall_group_stop_length, length) == F_equal_to) {
- reserved.stop_at = i;
- reserved.has_stop = F_true;
- }
- else if (!reserved.has_lock && fl_string_compare((f_string_t) firewall_group_lock, local.buffer.string + local.chain_objects.array[i].start, firewall_group_lock_length, length) == F_equal_to) {
- reserved.lock_at = i;
- reserved.has_lock = F_true;
- }
- } // for
- }
+ // load all network devices
+ status = f_directory_list((f_string_t) network_devices, 0, alphasort, &data->devices);
- if (command == firewall_parameter_command_lock) {
- if (reserved.has_lock) {
- status = firewall_delete_chains(*data);
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
- if (F_status_is_error_not(status)) {
- status = firewall_default_lock(*data);
- }
+ if (status == F_memory_allocation || status == F_memory_reallocation) {
+ fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.");
+ }
+ else if (status == F_data_not) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Could not find any network devices");
+ }
+ else if (status == F_failure) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to read the device directory '%s'", network_devices);
+ }
- if (F_status_is_error(status)) {
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- }
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return F_status_set_error(status);
+ }
- local.is_main = F_false;
- local.is_stop = F_false;
- local.is_lock = F_true;
- local.chain = reserved.lock_at;
+ // remove "lo" (loopback) from the device listing
+ {
+ f_string_length_t i = 0;
- input.start = local.chain_contents.array[reserved.lock_at].array[0].start;
- input.stop = local.chain_contents.array[reserved.lock_at].array[0].stop;
+ for (; i < data->devices.used; i++) {
+ if (fl_string_compare((f_string_t) firewall_device_loop, data->devices.array[i].string, firewall_device_loop_length + 1, data->devices.array[i].used) == F_equal_to) {
+ f_string_dynamic_t swap_string = data->devices.array[i];
- status = firewall_process_rules(&input, &local, data);
+ data->devices.used--;
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform lock request because the lock instructions are missing from: %s.", network_path firewall_file_other);
+ for (; i < data->devices.used; i++) {
+ data->devices.array[i] = data->devices.array[i+1];
+ } // for
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return F_status_set_error(F_data);
- }
+ data->devices.array[data->devices.used] = swap_string;
}
+ } // for
+ }
- if (command == firewall_parameter_command_stop || command == firewall_parameter_command_restart) {
- if (reserved.has_stop) {
- status = firewall_delete_chains(*data);
+ if (command == firewall_parameter_command_stop || command == firewall_parameter_command_restart || command == firewall_parameter_command_lock) {
+ status = firewall_buffer_rules(network_path firewall_file_other, F_false, &local, data);
- if (F_status_is_error_not(status)) {
- status = firewall_default_lock(*data);
- }
+ if (F_status_is_error(status)) {
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
+ }
- if (F_status_is_error(status)) {
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- }
+ {
+ f_array_length_t i = 0;
+ f_string_length_t length = 0;
- local.is_global = F_true;
- local.is_main = F_false;
- local.is_stop = F_true;
- local.is_lock = F_false;
- local.chain = reserved.stop_at;
+ for (; i < local.chain_objects.used; i++) {
+ length = local.chain_objects.array[i].stop - local.chain_objects.array[i].start + 1;
- input.start = local.chain_contents.array[reserved.stop_at].array[0].start;
- input.stop = local.chain_contents.array[reserved.stop_at].array[0].stop;
+ if (!reserved.has_stop && fl_string_compare((f_string_t) firewall_group_stop, local.buffer.string + local.chain_objects.array[i].start, firewall_group_stop_length, length) == F_equal_to) {
+ reserved.stop_at = i;
+ reserved.has_stop = F_true;
+ }
+ else if (!reserved.has_lock && fl_string_compare((f_string_t) firewall_group_lock, local.buffer.string + local.chain_objects.array[i].start, firewall_group_lock_length, length) == F_equal_to) {
+ reserved.lock_at = i;
+ reserved.has_lock = F_true;
+ }
+ } // for
+ }
- status = firewall_process_rules(&input, &local, data);
+ if (command == firewall_parameter_command_lock) {
+ if (reserved.has_lock) {
+ status = firewall_delete_chains(*data);
- if (F_status_is_error(status) || command == firewall_parameter_command_stop) {
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- }
+ if (F_status_is_error_not(status)) {
+ status = firewall_default_lock(*data);
}
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform stop request because the lock instructions are missing from: %s.", network_path firewall_file_other);
+ if (F_status_is_error(status)) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
- return F_status_set_error(F_data);
+ return status;
}
- }
- firewall_delete_local_data(&local);
- }
+ local.is_main = F_false;
+ local.is_stop = F_false;
+ local.is_lock = F_true;
+ local.chain = reserved.lock_at;
- if (command == firewall_parameter_command_start || command == firewall_parameter_command_restart) {
- status = firewall_buffer_rules(network_path firewall_file_first, F_false, &local, data);
+ input.start = local.chain_contents.array[reserved.lock_at].array[0].start;
+ input.stop = local.chain_contents.array[reserved.lock_at].array[0].stop;
+
+ status = firewall_process_rules(&input, &local, data);
- if (F_status_is_error(status)) {
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
}
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform lock request because the lock instructions are missing from: %s.", network_path firewall_file_other);
- if (command == firewall_parameter_command_start) {
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return F_status_set_error(F_data);
+ }
+ }
+
+ if (command == firewall_parameter_command_stop || command == firewall_parameter_command_restart) {
+ if (reserved.has_stop) {
status = firewall_delete_chains(*data);
if (F_status_is_error_not(status)) {
firewall_delete_data(data);
return status;
}
- }
-
- status = firewall_create_custom_chains(&reserved, &local, data);
-
- if (F_status_is_error(status)) {
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- }
-
- f_array_length_t i = 0;
-
- local.is_global = F_true;
- local.is_stop = F_false;
- local.is_lock = F_false;
- while (i < local.chain_contents.used) {
-
- input.start = local.chain_contents.array[i].array[0].start;
- input.stop = local.chain_contents.array[i].array[0].stop;
+ local.is_global = F_true;
+ local.is_main = F_false;
+ local.is_stop = F_true;
+ local.is_lock = F_false;
+ local.chain = reserved.stop_at;
- local.is_main = reserved.has_main && i == reserved.main_at ? F_true : F_false;
- local.chain = i;
+ input.start = local.chain_contents.array[reserved.stop_at].array[0].start;
+ input.stop = local.chain_contents.array[reserved.stop_at].array[0].stop;
status = firewall_process_rules(&input, &local, data);
firewall_delete_data(data);
return status;
}
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Failed to perform stop request because the lock instructions are missing from: %s.", network_path firewall_file_other);
+
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return F_status_set_error(F_data);
+ }
+ }
- i++;
- } // while
+ firewall_delete_local_data(&local);
+ }
+
+ if (command == firewall_parameter_command_start || command == firewall_parameter_command_restart) {
+ status = firewall_buffer_rules(network_path firewall_file_first, F_false, &local, data);
+ if (F_status_is_error(status)) {
firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
+ }
- for (i = 0; i < data->devices.used; i++) {
- local.device = i;
+ if (command == firewall_parameter_command_start) {
+ status = firewall_delete_chains(*data);
- {
- f_string_dynamic_t file_path = f_string_dynamic_t_initialize;
+ if (F_status_is_error_not(status)) {
+ status = firewall_default_lock(*data);
+ }
- f_macro_string_dynamic_t_resize(status, file_path, network_path_length + data->devices.array[i].used + firewall_file_suffix_length + 1);
+ if (F_status_is_error(status)) {
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
+ }
+ }
- if (F_status_is_error(status)) {
- fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.");
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- }
+ status = firewall_create_custom_chains(&reserved, &local, data);
+
+ if (F_status_is_error(status)) {
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
+ }
- memcpy((void *)file_path.string, network_path, network_path_length);
- memcpy((void *)(file_path.string + network_path_length), data->devices.array[i].string, data->devices.array[i].used);
- memcpy((void *)(file_path.string + network_path_length + data->devices.array[i].used), firewall_file_suffix, firewall_file_suffix_length);
+ f_array_length_t i = 0;
- file_path.used = network_path_length + data->devices.array[i].used + firewall_file_suffix_length;
- file_path.string[file_path.used] = 0;
+ local.is_global = F_true;
+ local.is_stop = F_false;
+ local.is_lock = F_false;
- status = firewall_buffer_rules(file_path.string, F_true, &local, data);
+ while (i < local.chain_contents.used) {
- f_macro_string_dynamic_t_delete_simple(file_path);
- }
+ input.start = local.chain_contents.array[i].array[0].start;
+ input.stop = local.chain_contents.array[i].array[0].stop;
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ local.is_main = reserved.has_main && i == reserved.main_at ? F_true : F_false;
+ local.chain = i;
- firewall_delete_local_data(&local);
+ status = firewall_process_rules(&input, &local, data);
- if (status == F_file_found_not || status == F_file_open || status == F_file_descriptor || status == FL_fss_found_object_content_not) {
- status = F_status_set_error(status);
- continue;
- }
+ if (F_status_is_error(status) || command == firewall_parameter_command_stop) {
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
+ }
- firewall_delete_data(data);
- return F_status_set_error(status);
- }
+ i++;
+ } // while
+
+ firewall_delete_local_data(&local);
+
+ for (i = 0; i < data->devices.used; i++) {
+ local.device = i;
- status = firewall_create_custom_chains(&reserved, &local, data);
+ {
+ f_string_dynamic_t file_path = f_string_dynamic_t_initialize;
+
+ f_macro_string_dynamic_t_resize(status, file_path, network_path_length + data->devices.array[i].used + firewall_file_suffix_length + 1);
if (F_status_is_error(status)) {
+ fl_color_print_line(f_type_error, data->context.set.error, "CRITICAL ERROR: Unable to allocate memory.");
firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
}
- f_array_length_t j = 0;
+ memcpy((void *)file_path.string, network_path, network_path_length);
+ memcpy((void *)(file_path.string + network_path_length), data->devices.array[i].string, data->devices.array[i].used);
+ memcpy((void *)(file_path.string + network_path_length + data->devices.array[i].used), firewall_file_suffix, firewall_file_suffix_length);
- local.is_global = F_false;
- local.is_stop = F_false;
- local.is_lock = F_false;
+ file_path.used = network_path_length + data->devices.array[i].used + firewall_file_suffix_length;
+ file_path.string[file_path.used] = 0;
- for (; j < local.chain_contents.used; j++) {
+ status = firewall_buffer_rules(file_path.string, F_true, &local, data);
- input.start = local.chain_contents.array[j].array[0].start;
- input.stop = local.chain_contents.array[j].array[0].stop;
-
- local.is_main = reserved.has_main && j == reserved.main_at ? F_true : F_false;
- local.chain = j;
-
- status = firewall_process_rules(&input, &local, data);
+ f_macro_string_dynamic_t_delete_simple(file_path);
+ }
- if (F_status_is_error(status) || command == firewall_parameter_command_stop) {
- firewall_delete_local_data(&local);
- firewall_delete_data(data);
- return status;
- }
- } // for
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
firewall_delete_local_data(&local);
- } // for
- status = firewall_buffer_rules(network_path firewall_file_last, F_false, &local, data);
+ if (status == F_file_found_not || status == F_file_open || status == F_file_descriptor || status == FL_fss_found_object_content_not) {
+ status = F_status_set_error(status);
+ continue;
+ }
- if (F_status_is_error(status)) {
- firewall_delete_local_data(&local);
firewall_delete_data(data);
- return status;
+ return F_status_set_error(status);
}
status = firewall_create_custom_chains(&reserved, &local, data);
if (F_status_is_error(status)) {
- f_status_t status2 = F_none;
-
- firewall_macro_delete_fss_buffers(status2, local.buffer, local.chain_objects, local.chain_contents)
+ firewall_delete_local_data(&local);
firewall_delete_data(data);
return status;
}
- i = 0;
+ f_array_length_t j = 0;
- local.is_global = F_true;
+ local.is_global = F_false;
local.is_stop = F_false;
local.is_lock = F_false;
- while (i < local.chain_contents.used) {
+ for (; j < local.chain_contents.used; j++) {
- input.start = local.chain_contents.array[i].array[0].start;
- input.stop = local.chain_contents.array[i].array[0].stop;
+ input.start = local.chain_contents.array[j].array[0].start;
+ input.stop = local.chain_contents.array[j].array[0].stop;
- local.is_main = reserved.has_main && i == reserved.main_at ? F_true : F_false;
- local.chain = i;
+ local.is_main = reserved.has_main && j == reserved.main_at ? F_true : F_false;
+ local.chain = j;
status = firewall_process_rules(&input, &local, data);
firewall_delete_data(data);
return status;
}
+ } // for
+
+ firewall_delete_local_data(&local);
+ } // for
- i++;
- } // while
+ status = firewall_buffer_rules(network_path firewall_file_last, F_false, &local, data);
+
+ if (F_status_is_error(status)) {
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
}
- // cleanup
- firewall_delete_local_data(&local);
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You did not pass a command");
- status = F_status_set_error(F_parameter);
+ status = firewall_create_custom_chains(&reserved, &local, data);
+
+ if (F_status_is_error(status)) {
+ f_status_t status2 = F_none;
+
+ firewall_macro_delete_fss_buffers(status2, local.buffer, local.chain_objects, local.chain_contents)
+ firewall_delete_data(data);
+ return status;
+ }
+
+ i = 0;
+
+ local.is_global = F_true;
+ local.is_stop = F_false;
+ local.is_lock = F_false;
+
+ while (i < local.chain_contents.used) {
+
+ input.start = local.chain_contents.array[i].array[0].start;
+ input.stop = local.chain_contents.array[i].array[0].stop;
+
+ local.is_main = reserved.has_main && i == reserved.main_at ? F_true : F_false;
+ local.chain = i;
+
+ status = firewall_process_rules(&input, &local, data);
+
+ if (F_status_is_error(status) || command == firewall_parameter_command_stop) {
+ firewall_delete_local_data(&local);
+ firewall_delete_data(data);
+ return status;
+ }
+
+ i++;
+ } // while
}
+
+ // cleanup
+ firewall_delete_local_data(&local);
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: You did not pass a command");
+ status = F_status_set_error(F_parameter);
}
firewall_delete_data(data);
typedef struct {
f_console_parameter_t parameters[firewall_total_parameters];
- f_string_dynamics_t chains;
f_string_lengths_t remaining;
bool process_pipe;
+
+ uint8_t verbosity;
+
+ f_string_dynamics_t chains;
f_string_dynamics_t devices;
f_color_context_t context;
#define firewall_data_t_initialize \
{ \
firewall_console_parameter_t_initialize, \
- f_string_dynamics_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
+ f_string_dynamics_t_initialize, \
f_string_dynamics_t_initialize, \
f_color_context_t_initialize, \
}
fll_program_print_help_header(context, fss_basic_list_read_name_long, fss_basic_list_read_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark };
const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, fss_basic_list_read_total_parameters };
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_basic_list_read_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[fss_basic_list_read_parameter_help].result == f_console_result_found) {
fss_basic_list_read_print_help(data->context);
+
+ fss_basic_list_read_delete_data(data);
+ return status;
}
- else if (data->parameters[fss_basic_list_read_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fss_basic_list_read_parameter_version].result == f_console_result_found) {
fll_program_print_version(fss_basic_list_read_version);
+
+ fss_basic_list_read_delete_data(data);
+ return status;
}
- else if (data->remaining.used > 0 || data->process_pipe) {
+
+ if (data->remaining.used > 0 || data->process_pipe) {
if (data->parameters[fss_basic_list_read_parameter_at].result == f_console_result_found) {
fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '");
fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_at);
typedef struct {
f_console_parameter_t parameters[fss_basic_list_read_total_parameters];
+ f_string_lengths_t remaining;
+ bool process_pipe;
+
+ uint8_t verbosity;
+
f_string_dynamic_t buffer;
f_fss_objects_t objects;
f_fss_contents_t contents;
f_string_quantity_t quantity;
- f_string_lengths_t remaining;
- bool process_pipe;
f_color_context_t context;
} fss_basic_list_read_data_t;
#define fss_basic_list_read_data_t_initialize \
{ \
fss_basic_list_read_console_parameter_t_initialize, \
+ f_string_lengths_t_initialize, \
+ F_false, \
+ f_console_verbosity_normal, \
f_string_dynamic_t_initialize, \
f_fss_objects_t_initialize, \
f_fss_contents_t_initialize, \
f_string_quantity_t_initialize, \
- f_string_lengths_t_initialize, \
- F_false, \
f_color_context_t_initialize, \
}
#endif // _di_fss_basic_list_read_data_t_
fll_program_print_help_header(context, fss_basic_list_write_name_long, fss_basic_list_write_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
+ fll_program_print_help_option(context, fss_basic_list_write_short_content, fss_basic_list_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output.");
+ fll_program_print_help_option(context, fss_basic_list_write_short_double, fss_basic_list_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default).");
fll_program_print_help_option(context, fss_basic_list_write_short_file, fss_basic_list_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
- fll_program_print_help_option(context, fss_basic_list_write_short_object, fss_basic_list_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
- fll_program_print_help_option(context, fss_basic_list_write_short_partial, fss_basic_list_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output the final end of object or end of content character.");
- fll_program_print_help_option(context, fss_basic_list_write_short_string, fss_basic_list_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
+ fll_program_print_help_option(context, fss_basic_list_write_short_object, fss_basic_list_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output.");
+ fll_program_print_help_option(context, fss_basic_list_write_short_partial, fss_basic_list_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character.");
+ fll_program_print_help_option(context, fss_basic_list_write_short_single, fss_basic_list_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes.");
fll_program_print_help_usage(context, fss_basic_list_write_name, "");
{
f_console_parameter_id_t ids[3] = { fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, fss_basic_list_write_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_basic_list_write_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
+
if (F_status_is_error(status)) {
fss_basic_list_write_delete_data(data);
return F_status_set_error(status);
if (data->parameters[fss_basic_list_write_parameter_help].result == f_console_result_found) {
fss_basic_list_write_print_help(data->context);
+
+ fss_basic_list_write_delete_data(data);
+ return status;
}
- else if (data->parameters[fss_basic_list_write_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fss_basic_list_write_parameter_version].result == f_console_result_found) {
fll_program_print_version(fss_basic_list_write_version);
+
+ fss_basic_list_write_delete_data(data);
+ return status;
}
- else {
- f_array_length_t counter = 0;
- bool object = (data->parameters[fss_basic_list_write_parameter_object].result == f_console_result_found);
- f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
- f_string_range_t range = f_string_range_t_initialize;
+ f_array_length_t counter = 0;
+ bool object = (data->parameters[fss_basic_list_write_parameter_object].result == f_console_result_found);
- if (data->process_pipe) {
- f_file_t file = f_file_t_initialize;
- f_string_dynamic_t input = f_string_dynamic_t_initialize;
+ f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
- file.id = f_type_descriptor_input;
+ if (data->process_pipe) {
+ f_file_t file = f_file_t_initialize;
+ f_string_dynamic_t input = f_string_dynamic_t_initialize;
- status = f_file_read(file, &input);
+ file.id = f_type_descriptor_input;
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = f_file_read(file, &input);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- }
- else if (status == F_file_found_not) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-");
- }
- else if (status == F_file_open) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-");
- }
- else if (status == F_file_descriptor) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-");
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
- }
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
- f_macro_string_dynamic_t_delete_simple(buffer);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_basic_list_write_delete_data(data);
- return F_status_set_error(status);
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+ }
+ else if (status == F_file_found_not) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-");
+ }
+ else if (status == F_file_open) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-");
+ }
+ else if (status == F_file_descriptor) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-");
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
- if (input.used) {
- range.start = 0;
- range.stop = input.used - 1;
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(input);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- if (object) {
- status = fl_fss_basic_list_object_write(input, &range, &buffer);
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_basic_list_write_delete_data(data);
- return F_status_set_error(status);
- }
+ if (object) {
+ status = fl_fss_basic_list_object_write(input, &range, &buffer);
- // this should remove both the closing newline and the colon.
- if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
- buffer.used -= 2;
- }
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(input);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
}
- else {
- status = fl_fss_basic_list_content_write(input, &range, &buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_basic_list_write_delete_data(data);
- return F_status_set_error(status);
- }
-
- if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
- buffer.used--;
- }
+
+ // this should remove both the closing newline and the colon.
+ if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
+ buffer.used -= 2;
}
}
+ else {
+ status = fl_fss_basic_list_content_write(input, &range, &buffer);
+
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(input);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- f_macro_string_dynamic_t_delete_simple(input);
+ if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
+ }
}
- else if (data->parameters[fss_basic_list_write_parameter_string].result == f_console_result_additional) {
- f_string_dynamic_t input = f_string_dynamic_t_initialize;
- input.string = arguments.argv[data->parameters[fss_basic_list_write_parameter_string].additional.array[0]];
- input.used = strlen(input.string);
+ f_macro_string_dynamic_t_delete_simple(input);
+ }
+ else if (data->parameters[fss_basic_list_write_parameter_string].result == f_console_result_additional) {
+ f_string_dynamic_t input = f_string_dynamic_t_initialize;
- if (input.used) {
- range.start = 0;
- range.stop = input.used - 1;
+ input.string = arguments.argv[data->parameters[fss_basic_list_write_parameter_string].additional.array[0]];
+ input.used = strlen(input.string);
- if (object) {
- status = fl_fss_basic_list_object_write(input, &range, &buffer);
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_basic_list_write_delete_data(data);
- return F_status_set_error(status);
- }
+ if (object) {
+ status = fl_fss_basic_list_object_write(input, &range, &buffer);
- // this should remove both the closing newline and the colon.
- if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
- buffer.used -= 2;
- }
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
}
- else {
- status = fl_fss_basic_list_content_write(input, &range, &buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_basic_list_write_delete_data(data);
- return F_status_set_error(status);
- }
-
- if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
- buffer.used--;
- }
+
+ // this should remove both the closing newline and the colon.
+ if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
+ buffer.used -= 2;
}
}
+ else {
+ status = fl_fss_basic_list_content_write(input, &range, &buffer);
- status = F_none;
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
+
+ if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
+ }
}
- if (data->parameters[fss_basic_list_write_parameter_file].result == f_console_result_additional) {
- f_file_t output = f_file_t_initialize;
+ status = F_none;
+ }
- output.flag = f_file_flag_append_wo;
+ if (data->parameters[fss_basic_list_write_parameter_file].result == f_console_result_additional) {
+ f_file_t output = f_file_t_initialize;
- status = f_file_open(arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], 0, &output);
+ output.flag = f_file_flag_append_wo;
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = f_file_open(arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]], 0, &output);
- f_file_close(&output.id);
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- }
- else if (status == F_file_found_not) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
- }
- else if (status == F_file_open) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
- }
- else if (status == F_file_descriptor) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
- }
+ f_file_close(&output.id);
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_basic_list_write_delete_data(data);
- return F_status_set_error(status);
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+ }
+ else if (status == F_file_found_not) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+ }
+ else if (status == F_file_open) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+ }
+ else if (status == F_file_descriptor) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
- status = f_file_write(output, buffer, 0);
- f_file_close(&output.id);
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = f_file_write(output, buffer, 0);
+ f_file_close(&output.id);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()");
- }
- else if (status == F_file_write) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
- }
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_basic_list_write_delete_data(data);
- return F_status_set_error(status);
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()");
+ }
+ else if (status == F_file_write) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
}
- }
- else {
- f_print_dynamic(f_type_output, buffer);
- }
- f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
}
+ else {
+ f_print_dynamic(f_type_output, buffer);
+ }
+
+ f_macro_string_dynamic_t_delete_simple(buffer);
fss_basic_list_write_delete_data(data);
return status;
#endif // _di_fss_basic_list_write_name_
#ifndef _di_fss_basic_list_write_defines_
- #define fss_basic_list_write_short_object "o"
+ #define fss_basic_list_write_short_content "c"
+ #define fss_basic_list_write_short_double "d"
#define fss_basic_list_write_short_file "f"
- #define fss_basic_list_write_short_string "s"
+ #define fss_basic_list_write_short_object "o"
#define fss_basic_list_write_short_partial "p"
+ #define fss_basic_list_write_short_single "s"
- #define fss_basic_list_write_long_object "object"
+ #define fss_basic_list_write_long_content "content"
+ #define fss_basic_list_write_long_double "double"
#define fss_basic_list_write_long_file "file"
- #define fss_basic_list_write_long_string "string"
+ #define fss_basic_list_write_long_object "object"
#define fss_basic_list_write_long_partial "partial"
+ #define fss_basic_list_write_long_single "single"
enum {
fss_basic_list_write_parameter_help,
fss_basic_list_write_parameter_no_color,
fss_basic_list_write_parameter_version,
+ fss_basic_list_write_parameter_content,
+ fss_basic_list_write_parameter_double,
fss_basic_list_write_parameter_file,
fss_basic_list_write_parameter_object,
fss_basic_list_write_parameter_partial,
- fss_basic_list_write_parameter_string,
+ fss_basic_list_write_parameter_single,
};
#define fss_basic_list_write_console_parameter_t_initialize \
f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \
+ f_console_parameter_t_initialize(fss_basic_list_write_short_content, fss_basic_list_write_long_content, 0, F_true, f_console_type_normal), \
+ f_console_parameter_t_initialize(fss_basic_list_write_short_double, fss_basic_list_write_long_double, 0, F_true, f_console_type_normal), \
f_console_parameter_t_initialize(fss_basic_list_write_short_file, fss_basic_list_write_long_file, 0, F_true, f_console_type_normal), \
f_console_parameter_t_initialize(fss_basic_list_write_short_object, fss_basic_list_write_long_object, 0, F_false, f_console_type_normal), \
f_console_parameter_t_initialize(fss_basic_list_write_short_partial, fss_basic_list_write_long_partial, 0, F_true, f_console_type_normal), \
- f_console_parameter_t_initialize(fss_basic_list_write_short_string, fss_basic_list_write_long_string, 0, F_true, f_console_type_normal), \
+ f_console_parameter_t_initialize(fss_basic_list_write_short_single, fss_basic_list_write_long_single, 0, F_true, f_console_type_normal), \
}
- #define fss_basic_list_write_total_parameters 9
+ #define fss_basic_list_write_total_parameters 11
#endif // _di_fss_basic_list_write_defines_
#ifndef _di_fss_basic_list_write_data_t_
f_string_lengths_t remaining;
bool process_pipe;
+ uint8_t verbosity;
+
f_color_context_t context;
} fss_basic_list_write_data_t;
fss_basic_list_write_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
f_color_context_t_initialize, \
}
#endif // _di_fss_basic_list_write_data_t_
fll_program_print_help_header(context, fss_basic_read_name_long, fss_basic_read_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, fss_basic_read_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_basic_read_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[fss_basic_read_parameter_help].result == f_console_result_found) {
fss_basic_read_print_help(data->context);
+
+ fss_basic_read_delete_data(data);
+ return status;
}
- else if (data->parameters[fss_basic_read_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fss_basic_read_parameter_version].result == f_console_result_found) {
fll_program_print_version(fss_basic_read_version);
+
+ fss_basic_read_delete_data(data);
+ return status;
}
- else if (data->remaining.used > 0 || data->process_pipe) {
+
+ if (data->remaining.used > 0 || data->process_pipe) {
if (data->parameters[fss_basic_read_parameter_at].result == f_console_result_found) {
fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '");
fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_at);
typedef struct {
f_console_parameter_t parameters[fss_basic_read_total_parameters];
+ f_string_lengths_t remaining;
+ bool process_pipe;
+
+ uint8_t verbosity;
+
f_string_dynamic_t buffer;
f_fss_objects_t objects;
f_fss_contents_t contents;
f_string_quantity_t quantity;
- f_string_lengths_t remaining;
- bool process_pipe;
f_color_context_t context;
} fss_basic_read_data_t;
#define fss_basic_read_data_t_initialize \
{ \
fss_basic_read_console_parameter_t_initialize, \
+ f_string_lengths_t_initialize, \
+ F_false, \
+ f_console_verbosity_normal, \
f_string_dynamic_t_initialize, \
f_fss_objects_t_initialize, \
f_fss_contents_t_initialize, \
f_string_quantity_t_initialize, \
- f_string_lengths_t_initialize, \
- F_false, \
f_color_context_t_initialize, \
}
#endif // _di_fss_basic_read_data_t_
fll_program_print_help_header(context, fss_basic_write_name_long, fss_basic_write_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
+ fll_program_print_help_option(context, fss_basic_write_short_content, fss_basic_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output.");
+ fll_program_print_help_option(context, fss_basic_write_short_double, fss_basic_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default).");
fll_program_print_help_option(context, fss_basic_write_short_file, fss_basic_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
- fll_program_print_help_option(context, fss_basic_write_short_object, fss_basic_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
- fll_program_print_help_option(context, fss_basic_write_short_partial, fss_basic_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output the final end of object or end of content character.");
- fll_program_print_help_option(context, fss_basic_write_short_string, fss_basic_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
+ fll_program_print_help_option(context, fss_basic_write_short_object, fss_basic_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output.");
+ fll_program_print_help_option(context, fss_basic_write_short_partial, fss_basic_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character.");
+ fll_program_print_help_option(context, fss_basic_write_short_single, fss_basic_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes.");
fll_program_print_help_usage(context, fss_basic_write_name, "");
{
f_console_parameter_id_t ids[3] = { fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, fss_basic_write_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_basic_write_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[fss_basic_write_parameter_help].result == f_console_result_found) {
fss_basic_write_print_help(data->context);
+
+ fss_basic_write_delete_data(data);
+ return status;
}
- else if (data->parameters[fss_basic_write_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fss_basic_write_parameter_version].result == f_console_result_found) {
fll_program_print_version(fss_basic_write_version);
+
+ fss_basic_write_delete_data(data);
+ return status;
}
- else {
- f_array_length_t counter = 0;
- bool object = (data->parameters[fss_basic_write_parameter_object].result == f_console_result_found);
- f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
- f_string_range_t range = f_string_range_t_initialize;
+ f_array_length_t counter = 0;
+ bool object = (data->parameters[fss_basic_write_parameter_object].result == f_console_result_found);
- if (data->process_pipe) {
- f_file_t file = f_file_t_initialize;
- f_string_dynamic_t input = f_string_dynamic_t_initialize;
+ f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
- file.id = f_type_descriptor_input;
+ if (data->process_pipe) {
+ f_file_t file = f_file_t_initialize;
+ f_string_dynamic_t input = f_string_dynamic_t_initialize;
- status = f_file_read(file, &input);
+ file.id = f_type_descriptor_input;
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = f_file_read(file, &input);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- }
- else if (status == F_file_found_not) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-");
- }
- else if (status == F_file_open) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-");
- }
- else if (status == F_file_descriptor) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-");
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
- }
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_basic_write_delete_data(data);
- return F_status_set_error(status);
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+ }
+ else if (status == F_file_found_not) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-");
+ }
+ else if (status == F_file_open) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-");
+ }
+ else if (status == F_file_descriptor) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-");
}
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
+ }
+
+ f_macro_string_dynamic_t_delete_simple(input);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- if (input.used) {
- range.start = 0;
- range.stop = input.used - 1;
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (object) {
- status = fl_fss_basic_object_write(input, 0, &range, &buffer);
+ if (object) {
+ status = fl_fss_basic_object_write(input, 0, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_basic_write_delete_data(data);
- return F_status_set_error(status);
- }
- }
- else {
- status = fl_fss_basic_content_write(input, &range, &buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_basic_write_delete_data(data);
- return F_status_set_error(status);
- }
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(input);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
}
-
- if (data->parameters[fss_basic_write_parameter_partial].result == f_console_result_found) {
- buffer.used--;
+ }
+ else {
+ status = fl_fss_basic_content_write(input, &range, &buffer);
+
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(input);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
}
}
- f_macro_string_dynamic_t_delete_simple(input);
+ if (data->parameters[fss_basic_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
}
- else if (data->parameters[fss_basic_write_parameter_string].result == f_console_result_additional) {
- f_string_dynamic_t input = f_string_dynamic_t_initialize;
- input.string = arguments.argv[data->parameters[fss_basic_write_parameter_string].additional.array[0]];
- input.used = strnlen(input.string, f_console_length_size);
+ f_macro_string_dynamic_t_delete_simple(input);
+ }
+ else if (data->parameters[fss_basic_write_parameter_string].result == f_console_result_additional) {
+ f_string_dynamic_t input = f_string_dynamic_t_initialize;
- if (input.used) {
- range.start = 0;
- range.stop = input.used - 1;
+ input.string = arguments.argv[data->parameters[fss_basic_write_parameter_string].additional.array[0]];
+ input.used = strnlen(input.string, f_console_length_size);
- if (object) {
- status = fl_fss_basic_object_write(input, 0, &range, &buffer);
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_basic_write_delete_data(data);
- return F_status_set_error(status);
- }
- }
- else {
- status = fl_fss_basic_content_write(input, &range, &buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_basic_write_delete_data(data);
- return F_status_set_error(status);
- }
+ if (object) {
+ status = fl_fss_basic_object_write(input, 0, &range, &buffer);
+
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
}
+ }
+ else {
+ status = fl_fss_basic_content_write(input, &range, &buffer);
- if (data->parameters[fss_basic_write_parameter_partial].result == f_console_result_found) {
- buffer.used--;
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
}
}
- status = F_none;
+ if (data->parameters[fss_basic_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
}
- if (data->parameters[fss_basic_write_parameter_file].result == f_console_result_additional) {
- f_file_t output = f_file_t_initialize;
+ status = F_none;
+ }
- output.flag = f_file_flag_append_wo;
+ if (data->parameters[fss_basic_write_parameter_file].result == f_console_result_additional) {
+ f_file_t output = f_file_t_initialize;
- status = f_file_open(arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], 0, &output);
+ output.flag = f_file_flag_append_wo;
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = f_file_open(arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]], 0, &output);
- f_file_close(&output.id);
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- }
- else if (status == F_file_found_not) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
- }
- else if (status == F_file_open) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
- }
- else if (status == F_file_descriptor) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
- }
+ f_file_close(&output.id);
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_basic_write_delete_data(data);
- return status;
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+ }
+ else if (status == F_file_found_not) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+ }
+ else if (status == F_file_open) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+ }
+ else if (status == F_file_descriptor) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
- status = f_file_write(output, buffer, 0);
- f_file_close(&output.id);
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_basic_write_delete_data(data);
+ return status;
+ }
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = f_file_write(output, buffer, 0);
+ f_file_close(&output.id);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()");
- }
- else if (status == F_file_write) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
- }
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_basic_write_delete_data(data);
- return F_status_set_error(status);
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()");
+ }
+ else if (status == F_file_write) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
}
- }
- else {
- f_print_dynamic(f_type_output, buffer);
- }
- f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
+ }
}
+ else {
+ f_print_dynamic(f_type_output, buffer);
+ }
+
+ f_macro_string_dynamic_t_delete_simple(buffer);
fss_basic_write_delete_data(data);
return status;
#endif // _di_fss_basic_write_name_
#ifndef _di_fss_basic_write_defines_
- #define fss_basic_write_short_object "o"
+ #define fss_basic_write_short_content "c"
+ #define fss_basic_write_short_double "d"
#define fss_basic_write_short_file "f"
- #define fss_basic_write_short_string "s"
+ #define fss_basic_write_short_object "o"
#define fss_basic_write_short_partial "p"
+ #define fss_basic_write_short_single "s"
- #define fss_basic_write_long_object "object"
+ #define fss_basic_write_long_content "content"
+ #define fss_basic_write_long_double "double"
#define fss_basic_write_long_file "file"
- #define fss_basic_write_long_string "string"
+ #define fss_basic_write_long_object "object"
#define fss_basic_write_long_partial "partial"
+ #define fss_basic_write_long_single "single"
enum {
fss_basic_write_parameter_help,
fss_basic_write_parameter_no_color,
fss_basic_write_parameter_version,
+ fss_basic_write_parameter_content,
+ fss_basic_write_parameter_double,
fss_basic_write_parameter_file,
fss_basic_write_parameter_object,
fss_basic_write_parameter_partial,
- fss_basic_write_parameter_string,
+ fss_basic_write_parameter_single,
};
#define fss_basic_write_console_parameter_t_initialize \
f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \
+ f_console_parameter_t_initialize(fss_basic_write_short_content, fss_basic_write_long_content, 0, F_true, f_console_type_normal), \
+ f_console_parameter_t_initialize(fss_basic_write_short_double, fss_basic_write_long_double, 0, F_true, f_console_type_normal), \
f_console_parameter_t_initialize(fss_basic_write_short_file, fss_basic_write_long_file, 0, F_true, f_console_type_normal), \
f_console_parameter_t_initialize(fss_basic_write_short_object, fss_basic_write_long_object, 0, F_false, f_console_type_normal), \
f_console_parameter_t_initialize(fss_basic_write_short_partial, fss_basic_write_long_partial, 0, F_true, f_console_type_normal), \
- f_console_parameter_t_initialize(fss_basic_write_short_string, fss_basic_write_long_string, 0, F_true, f_console_type_normal), \
+ f_console_parameter_t_initialize(fss_basic_write_short_single, fss_basic_write_long_single, 0, F_true, f_console_type_normal), \
}
- #define fss_basic_write_total_parameters 9
+ #define fss_basic_write_total_parameters 11
#endif // _di_fss_basic_write_defines_
#ifndef _di_fss_basic_write_data_
f_string_lengths_t remaining;
bool process_pipe;
+ uint8_t verbosity;
+
f_color_context_t context;
} fss_basic_write_data;
fss_basic_write_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
f_color_context_t_initialize, \
}
#endif // _di_fss_basic_write_data_
fll_program_print_help_header(context, fss_extended_list_read_name_long, fss_extended_list_read_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { fss_extended_list_read_parameter_no_color, fss_extended_list_read_parameter_light, fss_extended_list_read_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, fss_extended_list_read_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_extended_list_read_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[fss_extended_list_read_parameter_help].result == f_console_result_found) {
fss_extended_list_read_print_help(data->context);
+
+ fss_extended_list_write_delete_data(data);
+ return F_none;
}
- else if (data->parameters[fss_extended_list_read_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fss_extended_list_read_parameter_version].result == f_console_result_found) {
fll_program_print_version(fss_extended_list_read_version);
+
+ fss_extended_list_write_delete_data(data);
+ return F_none;
}
- else if (data->remaining.used > 0 || data->process_pipe) {
+
+ if (data->remaining.used > 0 || data->process_pipe) {
if (data->parameters[fss_extended_list_read_parameter_at].result == f_console_result_found) {
fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '");
fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_at);
typedef struct {
f_console_parameter_t parameters[fss_extended_list_read_total_parameters];
+ f_string_lengths_t remaining;
+ bool process_pipe;
+
+ uint8_t verbosity;
+
f_string_dynamic_t buffer;
f_fss_nest_t nest;
f_string_quantity_t quantity;
- f_string_lengths_t remaining;
- bool process_pipe;
f_color_context_t context;
} fss_extended_list_read_data_t;
#define fss_extended_list_read_data_t_initialize \
{ \
fss_extended_list_read_console_parameter_t_initialize, \
+ f_string_lengths_t_initialize, \
+ F_false, \
+ f_console_verbosity_normal, \
f_string_dynamic_t_initialize, \
f_fss_nest_t_initialize, \
f_string_quantity_t_initialize, \
- f_string_lengths_t_initialize, \
- F_false, \
f_color_context_t_initialize, \
}
#endif // _di_fss_extended_list_read_data_t_
fll_program_print_help_header(context, fss_extended_read_name_long, fss_extended_read_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, fss_extended_read_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_extended_read_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[fss_extended_read_parameter_help].result == f_console_result_found) {
fss_extended_read_print_help(data->context);
+
+ fss_extended_read_delete_data(data);
+ return F_none;
}
- else if (data->parameters[fss_extended_read_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fss_extended_read_parameter_version].result == f_console_result_found) {
fll_program_print_version(fss_extended_read_version);
+
+ fss_extended_read_delete_data(data);
+ return F_none;
}
- else if (data->remaining.used > 0 || data->process_pipe) {
+
+ if (data->remaining.used > 0 || data->process_pipe) {
if (data->parameters[fss_extended_read_parameter_at].result == f_console_result_found) {
fl_color_print(f_type_error, data->context.set.error, "ERROR: The parameter '");
fl_color_print(f_type_error, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_at);
typedef struct {
f_console_parameter_t parameters[fss_extended_read_total_parameters];
+ f_string_lengths_t remaining;
+ bool process_pipe;
+
+ uint8_t verbosity;
+
f_string_dynamic_t buffer;
f_fss_objects_t objects;
f_fss_contents_t contents;
f_string_quantity_t quantity;
- f_string_lengths_t remaining;
- bool process_pipe;
f_color_context_t context;
} fss_extended_read_data_t;
#define fss_extended_read_data_initialize \
{ \
fss_extended_read_console_parameter_t_initialize, \
+ f_string_lengths_t_initialize, \
+ F_false, \
+ f_console_verbosity_normal, \
f_string_dynamic_t_initialize, \
f_fss_objects_t_initialize, \
f_fss_contents_t_initialize, \
f_string_quantity_t_initialize, \
- f_string_lengths_t_initialize, \
- F_false, \
f_color_context_t_initialize, \
}
#endif // _di_fss_extended_read_data_t_
fll_program_print_help_header(context, fss_extended_write_name_long, fss_extended_write_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
+ fll_program_print_help_option(context, fss_extended_write_short_content, fss_extended_write_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " The content to output.");
+ fll_program_print_help_option(context, fss_extended_write_short_double, fss_extended_write_long_double, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use double quotes (default).");
fll_program_print_help_option(context, fss_extended_write_short_file, fss_extended_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
- fll_program_print_help_option(context, fss_extended_write_short_object, fss_extended_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
- fll_program_print_help_option(context, fss_extended_write_short_partial, fss_extended_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output the final end of object or end of content character.");
- fll_program_print_help_option(context, fss_extended_write_short_string, fss_extended_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
+ fll_program_print_help_option(context, fss_extended_write_short_object, fss_extended_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " The object to output.");
+ fll_program_print_help_option(context, fss_extended_write_short_partial, fss_extended_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output end of object/content character.");
+ fll_program_print_help_option(context, fss_extended_write_short_single, fss_extended_write_long_single, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use single quotes.");
fll_program_print_help_usage(context, fss_extended_write_name, "");
{
f_console_parameter_id_t ids[3] = { fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, fss_extended_write_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_extended_write_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[fss_extended_write_parameter_help].result == f_console_result_found) {
fss_extended_write_print_help(data->context);
+
+ fss_extended_write_delete_data(data);
+ return F_none;
}
- else if (data->parameters[fss_extended_write_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fss_extended_write_parameter_version].result == f_console_result_found) {
fll_program_print_version(fss_extended_write_version);
+
+ fss_extended_write_delete_data(data);
+ return F_none;
}
- else {
- f_array_length_t counter = 0;
- bool object = (data->parameters[fss_extended_write_parameter_object].result == f_console_result_found);
- f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
- f_string_range_t range = f_string_range_t_initialize;
+ f_array_length_t counter = 0;
+ bool object = (data->parameters[fss_extended_write_parameter_object].result == f_console_result_found);
- if (data->process_pipe) {
- f_file_t file = f_file_t_initialize;
- f_string_dynamic_t input = f_string_dynamic_t_initialize;
+ f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
- file.id = f_type_descriptor_input;
+ if (data->process_pipe) {
+ f_file_t file = f_file_t_initialize;
+ f_string_dynamic_t input = f_string_dynamic_t_initialize;
- status = f_file_read(file, &input);
+ file.id = f_type_descriptor_input;
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = f_file_read(file, &input);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- }
- else if (status == F_file_found_not) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-");
- }
- else if (status == F_file_open) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-");
- }
- else if (status == F_file_descriptor) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-");
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
- }
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_extended_write_delete_data(data);
- return F_status_set_error(status);
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
}
-
- if (input.used) {
- range.start = 0;
- range.stop = input.used - 1;
-
- if (object) {
- status = fl_fss_extended_object_write(input, 0, &range, &buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_extended_write_delete_data(data);
- return F_status_set_error(status);
- }
-
- if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_found) {
- buffer.used--;
- }
- }
- else {
- status = fl_fss_extended_content_write(input, 0, &range, &buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_extended_write_delete_data(data);
- return F_status_set_error(status);
- }
-
- // remove the last whitespace separator before possibly appending the newline.
- if (buffer.used) {
- buffer.used--;
- }
-
- if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_none) {
- if (buffer.used == buffer.size) {
- f_macro_string_dynamic_t_resize(status, buffer, buffer.used + f_fss_default_allocation_step_string);
-
- if (F_status_is_error(status)) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- f_macro_string_dynamic_t_delete_simple(input);
- fss_extended_write_delete_data(data);
- return status;
- }
- }
-
- buffer.string[buffer.used] = f_fss_extended_close;
- buffer.used++;
- }
- }
+ else if (status == F_file_found_not) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", "-");
+ }
+ else if (status == F_file_open) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", "-");
+ }
+ else if (status == F_file_descriptor) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", "-");
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
f_macro_string_dynamic_t_delete_simple(input);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
}
- else if (data->parameters[fss_extended_write_parameter_string].result == f_console_result_additional) {
- const f_console_parameter_t *parameter = &data->parameters[fss_extended_write_parameter_string];
- f_string_dynamic_t input = f_string_dynamic_t_initialize;
-
- if (object) {
- input.string = arguments.argv[parameter->additional.array[0]];
- input.used = strnlen(input.string, f_console_length_size);
- if (input.used) {
- range.start = 0;
- range.stop = input.used - 1;
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- status = fl_fss_extended_object_write(input, 0, &range, &buffer);
+ if (object) {
+ status = fl_fss_extended_object_write(input, 0, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_extended_write_delete_data(data);
- return F_status_set_error(status);
- }
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(input);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_found) {
- buffer.used--;
- }
+ if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
}
}
else {
- for (f_string_length_t i = 0; i < parameter->additional.used; i++) {
- input.string = arguments.argv[parameter->additional.array[i]];
- input.used = strnlen(input.string, f_console_length_size);
-
- if (input.used) {
- range.start = 0;
- range.stop = input.used - 1;
+ status = fl_fss_extended_content_write(input, 0, &range, &buffer);
- status = fl_fss_extended_content_write(input, 0, &range, &buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_extended_write_delete_data(data);
- return F_status_set_error(status);
- }
- }
- } // for
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(input);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
+ }
// remove the last whitespace separator before possibly appending the newline.
if (buffer.used) {
if (F_status_is_error(status)) {
f_macro_string_dynamic_t_delete_simple(buffer);
+ f_macro_string_dynamic_t_delete_simple(input);
fss_extended_write_delete_data(data);
return status;
}
buffer.used++;
}
}
-
- status = F_none;
}
- if (data->parameters[fss_extended_write_parameter_file].result == f_console_result_additional) {
- f_file_t output = f_file_t_initialize;
-
- output.flag = f_file_flag_append_wo;
+ f_macro_string_dynamic_t_delete_simple(input);
+ }
+ else if (data->parameters[fss_extended_write_parameter_string].result == f_console_result_additional) {
+ const f_console_parameter_t *parameter = &data->parameters[fss_extended_write_parameter_string];
+ f_string_dynamic_t input = f_string_dynamic_t_initialize;
- status = f_file_open(arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], 0, &output);
+ if (object) {
+ input.string = arguments.argv[parameter->additional.array[0]];
+ input.used = strnlen(input.string, f_console_length_size);
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- f_file_close(&output.id);
+ status = fl_fss_extended_object_write(input, 0, &range, &buffer);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
- }
- else if (status == F_file_found_not) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
- }
- else if (status == F_file_open) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
- }
- else if (status == F_file_descriptor) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
- }
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
}
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_extended_write_delete_data(data);
- return status;
+ if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
}
+ }
+ else {
+ for (f_string_length_t i = 0; i < parameter->additional.used; i++) {
+ input.string = arguments.argv[parameter->additional.array[i]];
+ input.used = strnlen(input.string, f_console_length_size);
- status = f_file_write(output, buffer, 0);
- f_file_close(&output.id);
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
+ status = fl_fss_extended_content_write(input, 0, &range, &buffer);
- if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()");
- }
- else if (status == F_file_write) {
- fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
+ }
}
- else {
- fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
+ } // for
+
+ // remove the last whitespace separator before possibly appending the newline.
+ if (buffer.used) {
+ buffer.used--;
+ }
+
+ if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_none) {
+ if (buffer.used == buffer.size) {
+ f_macro_string_dynamic_t_resize(status, buffer, buffer.used + f_fss_default_allocation_step_string);
+
+ if (F_status_is_error(status)) {
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_extended_write_delete_data(data);
+ return status;
+ }
}
- f_macro_string_dynamic_t_delete_simple(buffer);
- fss_extended_write_delete_data(data);
- return F_status_set_error(status);
+ buffer.string[buffer.used] = f_fss_extended_close;
+ buffer.used++;
}
}
- else {
- f_print_dynamic(f_type_output, buffer);
+
+ status = F_none;
+ }
+
+ if (data->parameters[fss_extended_write_parameter_file].result == f_console_result_additional) {
+ f_file_t output = f_file_t_initialize;
+
+ output.flag = f_file_flag_append_wo;
+
+ status = f_file_open(arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]], 0, &output);
+
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
+
+ f_file_close(&output.id);
+
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_open()");
+ }
+ else if (status == F_file_found_not) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to find the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+ }
+ else if (status == F_file_open) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+ }
+ else if (status == F_file_descriptor) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
+ }
+
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_extended_write_delete_data(data);
+ return status;
}
- f_macro_string_dynamic_t_delete_simple(buffer);
+ status = f_file_write(output, buffer, 0);
+ f_file_close(&output.id);
+
+ if (F_status_is_error(status)) {
+ status = F_status_set_fine(status);
+
+ if (status == F_parameter) {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: Invalid parameter when calling f_file_write()");
+ }
+ else if (status == F_file_write) {
+ fl_color_print_line(f_type_error, data->context.set.error, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
+ }
+ else {
+ fl_color_print_line(f_type_error, data->context.set.error, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
+ }
+
+ f_macro_string_dynamic_t_delete_simple(buffer);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
+ }
+ }
+ else {
+ f_print_dynamic(f_type_output, buffer);
}
+ f_macro_string_dynamic_t_delete_simple(buffer);
+
fss_extended_write_delete_data(data);
return status;
}
#endif // _di_fss_extended_write_name_
#ifndef _di_fss_extended_write_defines_
- #define fss_extended_write_short_object "o"
- #define fss_extended_write_short_file "f"
- #define fss_extended_write_short_string "s"
- #define fss_extended_write_short_partial "p"
-
- #define fss_extended_write_long_object "object"
+ #define fss_extended_write_short_content "c"
+ #define fss_extended_write_short_double "d"
+ #define fss_extended_write_short_file "f"
+ #define fss_extended_write_short_object "o"
+ #define fss_extended_write_short_partial "p"
+ #define fss_extended_write_short_single "s"
+
+ #define fss_extended_write_long_content "content"
+ #define fss_extended_write_long_double "double"
#define fss_extended_write_long_file "file"
- #define fss_extended_write_long_string "string"
+ #define fss_extended_write_long_object "object"
#define fss_extended_write_long_partial "partial"
+ #define fss_extended_write_long_single "single"
enum {
fss_extended_write_parameter_help,
fss_extended_write_parameter_no_color,
fss_extended_write_parameter_version,
+ fss_extended_write_parameter_content,
+ fss_extended_write_parameter_double,
fss_extended_write_parameter_file,
fss_extended_write_parameter_object,
fss_extended_write_parameter_partial,
- fss_extended_write_parameter_string,
+ fss_extended_write_parameter_single,
};
#define fss_extended_write_console_parameter_t_initialize \
f_console_parameter_t_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \
f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \
+ f_console_parameter_t_initialize(fss_extended_write_short_content, fss_extended_write_long_content, 0, F_true, f_console_type_normal), \
+ f_console_parameter_t_initialize(fss_extended_write_short_double, fss_extended_write_long_double, 0, F_true, f_console_type_normal), \
f_console_parameter_t_initialize(fss_extended_write_short_file, fss_extended_write_long_file, 0, F_true, f_console_type_normal), \
f_console_parameter_t_initialize(fss_extended_write_short_object, fss_extended_write_long_object, 0, F_false, f_console_type_normal), \
f_console_parameter_t_initialize(fss_extended_write_short_partial, fss_extended_write_long_partial, 0, F_false, f_console_type_normal), \
- f_console_parameter_t_initialize(fss_extended_write_short_string, fss_extended_write_long_string, 0, F_true, f_console_type_normal), \
+ f_console_parameter_t_initialize(fss_extended_write_short_single, fss_extended_write_long_single, 0, F_true, f_console_type_normal), \
}
- #define fss_extended_write_total_parameters 9
+ #define fss_extended_write_total_parameters 11
#endif // _di_fss_extended_write_defines_
#ifndef _di_fss_extended_write_data_t_
f_string_lengths_t remaining;
bool process_pipe;
+ uint8_t verbosity;
+
f_color_context_t context;
} fss_extended_write_data_t;
fss_extended_write_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
f_color_context_t_initialize, \
}
#endif // _di_fss_extended_write_data_t_
fll_program_print_help_header(context, fss_status_code_name_long, fss_status_code_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, fss_status_code_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, fss_status_code_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[fss_status_code_parameter_help].result == f_console_result_found) {
fss_status_code_print_help(data->context);
+
fss_status_code_delete_data(data);
return F_none;
}
- else if (data->parameters[fss_status_code_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[fss_status_code_parameter_version].result == f_console_result_found) {
fll_program_print_version(fss_status_code_version);
+
fss_status_code_delete_data(data);
return F_none;
}
f_string_lengths_t remaining;
bool process_pipe;
+ uint8_t verbosity;
+
f_color_context_t context;
} fss_status_code_data_t;
fss_status_code_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
f_color_context_t_initialize, \
}
#endif // _di_fss_status_code_data_t_
fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { iki_read_parameter_no_color, iki_read_parameter_light, iki_read_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, iki_read_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, iki_read_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
iki_read_print_help(data->context);
iki_read_delete_data(data);
- return status;
+ return F_none;
}
- else if (data->parameters[iki_read_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[iki_read_parameter_version].result == f_console_result_found) {
fll_program_print_version(iki_read_version);
iki_read_delete_data(data);
- return status;
+ return F_none;
}
if (data->parameters[iki_read_parameter_verbose].result == f_console_result_found) {
f_string_lengths_t remaining;
bool process_pipe;
+ uint8_t verbosity;
+ uint8_t mode;
+
f_number_unsigned_t at;
f_number_unsigned_t line;
- uint8_t mode;
- uint8_t verbosity;
-
f_string_dynamic_t buffer;
iki_read_substitutions_t replacements;
iki_read_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
- 0, \
+ f_console_verbosity_normal, \
0, \
0, \
0, \
fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { iki_write_parameter_no_color, iki_write_parameter_light, iki_write_parameter_dark };
- const f_console_parameters_t parameters = { data->parameters, iki_write_total_parameters };
- const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, iki_write_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
iki_write_print_help(data->context);
iki_write_delete_data(data);
- return status;
+ return F_none;
}
- else if (data->parameters[iki_write_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[iki_write_parameter_version].result == f_console_result_found) {
fll_program_print_version(iki_write_version);
iki_write_delete_data(data);
- return status;
+ return F_none;
}
if (data->parameters[iki_write_parameter_verbose].result == f_console_result_found) {
else if (data->parameters[iki_write_parameter_quiet].result == f_console_result_found) {
data->verbosity = f_console_verbosity_quiet;
}
- else {
- data->verbosity = f_console_verbosity_normal;
- }
f_file_t output = f_file_t_initialize;
iki_write_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
- 0, \
+ f_console_verbosity_normal, \
f_string_dynamic_t_initialize, \
f_color_context_t_initialize, \
}
fll_program_print_help_header(context, init_name_long, init_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
- fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { init_parameter_no_color, init_parameter_light, init_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, init_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, init_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
f_string_lengths_t remaining;
bool process_pipe;
+ uint8_t verbosity;
+
f_color_context_t context;
} init_data_t;
init_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
f_color_context_t_initialize, \
}
fll_program_print_help_header(context, status_code_name_long, status_code_version);
fll_program_print_help_option(context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
- fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_dark, f_console_standard_long_dark, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on dark backgrounds.");
+ fll_program_print_help_option(context, f_console_standard_short_light, f_console_standard_long_light, f_console_symbol_short_disable, f_console_symbol_long_disable, " Output using colors that show up better on light backgrounds.");
fll_program_print_help_option(context, f_console_standard_short_no_color, f_console_standard_long_no_color, f_console_symbol_short_disable, f_console_symbol_long_disable, "Do not output in color.");
+ fll_program_print_help_option(context, f_console_standard_short_quiet, f_console_standard_long_quiet, f_console_symbol_short_disable, f_console_symbol_long_disable, " Decrease verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_normal, f_console_standard_long_normal, f_console_symbol_short_disable, f_console_symbol_long_disable, " Set verbosity to normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_verbose, f_console_standard_long_verbose, f_console_symbol_short_disable, f_console_symbol_long_disable, " Increase verbosity beyond normal output.");
+ fll_program_print_help_option(context, f_console_standard_short_debug, f_console_standard_long_debug, f_console_symbol_short_disable, f_console_symbol_long_disable, " Enable debugging, inceasing verbosity beyond normal output.");
fll_program_print_help_option(context, f_console_standard_short_version, f_console_standard_long_version, f_console_symbol_short_disable, f_console_symbol_long_disable, " Print only the version number.");
printf("%c", f_string_eol[0]);
{
f_console_parameter_id_t ids[3] = { status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark };
- const f_console_parameter_ids_t choices = { ids, 3 };
- const f_console_parameters_t parameters = { data->parameters, status_code_total_parameters };
+ const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3);
+ const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, status_code_total_parameters);
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (data->parameters[status_code_parameter_help].result == f_console_result_found) {
status_code_print_help(data->context);
- status_code_delete_data(data);
+ status_code_delete_data(data);
return F_none;
}
- else if (data->parameters[status_code_parameter_version].result == f_console_result_found) {
+
+ if (data->parameters[status_code_parameter_version].result == f_console_result_found) {
fll_program_print_version(status_code_version);
- status_code_delete_data(data);
+ status_code_delete_data(data);
return F_none;
}
f_string_lengths_t remaining;
bool process_pipe;
+ uint8_t verbosity;
+
f_color_context_t context;
} status_code_data_t;
status_code_console_parameter_t_initialize, \
f_string_lengths_t_initialize, \
F_false, \
+ f_console_verbosity_normal, \
f_color_context_t_initialize, \
}
#endif // _di_status_code_data_t_