Minor improvement to comments and specifications.
I've identified the structure I wanted and this is progress towards implementing the fss_write code across all currently supported formats.
* signal: The process signal management structure.
*
* message: The output file for normal output messages (often stdout).
- * output: The output file for normal/non-message output (often stdout or a file).
+ * output: The output file for normal/non-message output, aka data output (often stdout or a file).
* error: The output file for error output messages.
* warning: The output file for warning output messages.
*
extern "C" {
#endif
+#ifndef _di_fss_write_basic_process_content_
+ void fss_write_basic_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_basic_content_write(
+ *content,
+ f_fss_complete_none_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_basic_content_write(
+ *content,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_basic_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_basic_content_write");
+
+ return;
+ }
+ }
+#endif // _di_fss_write_basic_process_content_
+
#ifndef _di_fss_write_basic_process_help_
void fss_write_basic_process_help(fll_program_data_t * const main, void * const setting) {
- fss_write_basic_print_help((fss_write_setting_t *) setting, main->message);
+ fss_write_basic_print_help(macro_fss_write_setting(setting), main->message);
}
#endif // _di_fss_write_basic_process_help_
+#ifndef _di_fss_write_basic_process_object_
+ void fss_write_basic_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_basic_object_write(
+ *object,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_single_e) ? f_fss_quote_type_single_e : f_fss_quote_type_double_e,
+ f_fss_complete_none_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_basic_object_write(
+ *object,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_single_e) ? f_fss_quote_type_single_e : f_fss_quote_type_double_e,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_basic_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_basic_object_write");
+ }
+ }
+#endif // _di_fss_write_basic_process_object_
+
#ifndef _di_fss_write_basic_process_normal_
void fss_write_basic_process_normal(fll_program_data_t * const main, void * const setting) {
- // @todo
+ f_string_statics_t * const data = (macro_fss_write_setting(setting)->flag & fss_write_flag_object_e) ? ¯o_fss_write_setting(setting)->objects : ¯o_fss_write_setting(setting)->contents;
+
+ for (f_array_length_t i = 0; i < data->used; ++i) {
+
+ // @todo replace all signal checks with forked main process that independently checks and assigns main->signal_received.
+ if (!((++main->signal_check) % fss_write_signal_check_d)) {
+ if (fll_program_standard_signal_received(main)) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_interrupt);
+
+ return;
+ }
+
+ main->signal_check = 0;
+ }
+
+ fss_write_process_set(
+ main,
+ macro_fss_write_setting(setting),
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_object_e) ? ¯o_fss_write_setting(setting)->objects.array[i] : 0,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_content_e) ? ¯o_fss_write_setting(setting)->contents.array[i] : 0
+ );
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) break;
+ } // for
}
#endif // _di_fss_write_basic_process_normal_
// FLL-2 includes.
#include <fll/level_2/error.h>
-#include <fll/level_2/fss/basic.h>
#include <fll/level_2/print.h>
#include <fll/level_2/program.h>
#endif
/**
+ * Process a single Content, printing the FSS-0000 (Basic) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param content
+ * The string representing the Content to write to the buffer.
+ */
+#ifndef _di_fss_write_basic_process_content_
+ extern void fss_write_basic_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content);
+#endif // _di_fss_write_basic_process_content_
+
+/**
* Process help for FSS-0000 (Basic).
*
* @param main
#endif // _di_fss_write_basic_process_help_
/**
- * Process normally, writing to the output.
+ * Process normally, writing to the output for FSS-0000 (Basic).
*
* @param main
* The main program data.
#endif // _di_fss_write_basic_process_normal_
/**
- * Process the pipe, reading from the pipe and writing to the output.
+ * Process a single Object, printing the FSS-0000 (Basic) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param object
+ * The string representing the Object to write to the buffer.
+ */
+#ifndef _di_fss_write_basic_process_object_
+ extern void fss_write_basic_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object);
+#endif // _di_fss_write_basic_process_object_
+
+/**
+ * Process the pipe, reading from the pipe and writing to the output for FSS-0000 (Basic).
*
* @param main
* The main program data.
fll_program_data_t data = fll_program_data_t_initialize;
fss_write_setting_t setting = fss_write_setting_t_initialize;
setting.state.data = (void *) &data;
+ setting.program_name = &fss_write_basic_program_name_s;
+ setting.program_name_long = &fss_write_basic_program_name_long_s;
setting.process_help = &fss_write_basic_process_help;
setting.process_pipe = &fss_write_basic_process_pipe;
setting.process_normal = &fss_write_basic_process_normal;
- setting.program_name = &fss_write_basic_program_name_s;
- setting.program_name_long = &fss_write_basic_program_name_long_s;
+ setting.process_object = &fss_write_basic_process_object;
+ setting.process_content = &fss_write_basic_process_content;
f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize;
data.parameters.array = parameters;
extern "C" {
#endif
+#ifndef _di_fss_write_basic_list_process_content_
+ void fss_write_basic_list_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_basic_list_content_write(
+ *content,
+ f_fss_complete_none_e,
+ ¯o_fss_write_setting(setting)->prepend,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_basic_list_content_write(
+ *content,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ ¯o_fss_write_setting(setting)->prepend,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_basic_list_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_basic_list_content_write");
+
+ return;
+ }
+ }
+#endif // _di_fss_write_basic_list_process_content_
+
#ifndef _di_fss_write_basic_list_process_help_
void fss_write_basic_list_process_help(fll_program_data_t * const main, void * const setting) {
- fss_write_basic_list_print_help((fss_write_setting_t *) setting, main->message);
+ fss_write_basic_list_print_help(macro_fss_write_setting(setting), main->message);
}
#endif // _di_fss_write_basic_list_process_help_
}
#endif // _di_fss_write_basic_list_process_normal_
+#ifndef _di_fss_write_basic_list_process_object_
+ void fss_write_basic_list_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_basic_list_object_write(
+ *object,
+ f_fss_complete_none_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_basic_list_object_write(
+ *object,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_basic_list_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_basic_list_object_write");
+ }
+ }
+#endif // _di_fss_write_basic_list_process_object_
+
#ifndef _di_fss_write_basic_list_process_pipe_
void fss_write_basic_list_process_pipe(fll_program_data_t * const main, void * const setting) {
#endif
/**
+ * Process a single Content, printing the FSS-0002 (Basic List) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param content
+ * The string representing the Content to write to the buffer.
+ */
+#ifndef _di_fss_write_basic_list_process_content_
+ extern void fss_write_basic_list_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content);
+#endif // _di_fss_write_basic_list_process_content_
+
+/**
* Process help for FSS-0002 (Basic List).
*
* @param main
#endif // _di_fss_write_basic_list_process_normal_
/**
+ * Process a single Object, printing the FSS-0002 (Basic List) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param object
+ * The string representing the Object to write to the buffer.
+ */
+#ifndef _di_fss_write_basic_list_process_object_
+ extern void fss_write_basic_list_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object);
+#endif // _di_fss_write_basic_list_process_object_
+
+/**
* Process the pipe, reading from the pipe and writing to the output.
*
* @param main
fll_program_data_t data = fll_program_data_t_initialize;
fss_write_setting_t setting = fss_write_setting_t_initialize;
setting.state.data = (void *) &data;
+ setting.program_name = &fss_write_basic_list_program_name_s;
+ setting.program_name_long = &fss_write_basic_list_program_name_long_s;
setting.process_help = &fss_write_basic_list_process_help;
setting.process_pipe = &fss_write_basic_list_process_pipe;
setting.process_normal = &fss_write_basic_list_process_normal;
- setting.program_name = &fss_write_basic_list_program_name_s;
- setting.program_name_long = &fss_write_basic_list_program_name_long_s;
+ setting.process_object = &fss_write_basic_list_process_object;
+ setting.process_content = &fss_write_basic_list_process_content;
f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize;
data.parameters.array = parameters;
extern "C" {
#endif
+#ifndef _di_fss_write_embedded_list_process_content_
+ void fss_write_embedded_list_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_embedded_list_content_write(
+ *content,
+ f_fss_complete_none_e,
+ ¯o_fss_write_setting(setting)->prepend,
+ ¯o_fss_write_setting(setting)->ignores,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_embedded_list_content_write(
+ *content,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ ¯o_fss_write_setting(setting)->prepend,
+ ¯o_fss_write_setting(setting)->ignores,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_embedded_list_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_embedded_list_content_write");
+
+ return;
+ }
+ }
+#endif // _di_fss_write_embedded_list_process_content_
+
#ifndef _di_fss_write_embedded_list_process_help_
void fss_write_embedded_list_process_help(fll_program_data_t * const main, void * const setting) {
- fss_write_embedded_list_print_help((fss_write_setting_t *) setting, main->message);
+ fss_write_embedded_list_print_help(macro_fss_write_setting(setting), main->message);
}
#endif // _di_fss_write_embedded_list_process_help_
}
#endif // _di_fss_write_embedded_list_process_normal_
+#ifndef _di_fss_write_embedded_list_process_object_
+ void fss_write_embedded_list_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_embedded_list_object_write(
+ *object,
+ f_fss_complete_none_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_embedded_list_object_write(
+ *object,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_embedded_list_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_embedded_list_object_write");
+ }
+ }
+#endif // _di_fss_write_embedded_list_process_object_
+
#ifndef _di_fss_write_embedded_list_process_pipe_
void fss_write_embedded_list_process_pipe(fll_program_data_t * const main, void * const setting) {
#endif
/**
+ * Process a single Content, printing the FSS-0008 (Embedded List) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param content
+ * The string representing the Content to write to the buffer.
+ */
+#ifndef _di_fss_write_embedded_list_process_content_
+ extern void fss_write_embedded_list_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content);
+#endif // _di_fss_write_embedded_list_process_content_
+
+/**
* Process help for FSS-0008 (Embedded List).
*
* @param main
#endif // _di_fss_write_embedded_list_process_normal_
/**
+ * Process a single Object, printing the FSS-0008 (Embedded List) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param object
+ * The string representing the Object to write to the buffer.
+ */
+#ifndef _di_fss_write_embedded_list_process_object_
+ extern void fss_write_embedded_list_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object);
+#endif // _di_fss_write_embedded_list_process_object_
+
+/**
* Process the pipe, reading from the pipe and writing to the output.
*
* @param main
fll_program_data_t data = fll_program_data_t_initialize;
fss_write_setting_t setting = fss_write_setting_t_initialize;
setting.state.data = (void *) &data;
+ setting.program_name = &fss_write_embedded_list_program_name_s;
+ setting.program_name_long = &fss_write_embedded_list_program_name_long_s;
setting.process_help = &fss_write_embedded_list_process_help;
setting.process_pipe = &fss_write_embedded_list_process_pipe;
setting.process_normal = &fss_write_embedded_list_process_normal;
- setting.program_name = &fss_write_embedded_list_program_name_s;
- setting.program_name_long = &fss_write_embedded_list_program_name_long_s;
+ setting.process_object = &fss_write_embedded_list_process_object;
+ setting.process_content = &fss_write_embedded_list_process_content;
f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize;
data.parameters.array = parameters;
extern "C" {
#endif
+#ifndef _di_fss_write_extended_process_content_
+ void fss_write_extended_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_extended_content_write(
+ *content,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_single_e) ? f_fss_quote_type_single_e : f_fss_quote_type_double_e,
+ f_fss_complete_none_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_extended_content_write(
+ *content,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_single_e) ? f_fss_quote_type_single_e : f_fss_quote_type_double_e,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_extended_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_extended_content_write");
+
+ return;
+ }
+ }
+#endif // _di_fss_write_extended_process_content_
+
#ifndef _di_fss_write_extended_process_help_
void fss_write_extended_process_help(fll_program_data_t * const main, void * const setting) {
- fss_write_extended_print_help((fss_write_setting_t *) setting, main->message);
+ fss_write_extended_print_help(macro_fss_write_setting(setting), main->message);
}
#endif // _di_fss_write_extended_process_help_
}
#endif // _di_fss_write_extended_process_normal_
+#ifndef _di_fss_write_extended_process_object_
+ void fss_write_extended_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_extended_object_write(
+ *object,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_single_e) ? f_fss_quote_type_single_e : f_fss_quote_type_double_e,
+ f_fss_complete_none_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_extended_object_write(
+ *object,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_single_e) ? f_fss_quote_type_single_e : f_fss_quote_type_double_e,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_extended_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_extended_object_write");
+ }
+ }
+#endif // _di_fss_write_extended_process_object_
+
#ifndef _di_fss_write_extended_process_pipe_
void fss_write_extended_process_pipe(fll_program_data_t * const main, void * const setting) {
// FLL-2 includes.
#include <fll/level_2/error.h>
-#include <fll/level_2/fss/extended.h>
#include <fll/level_2/print.h>
#include <fll/level_2/program.h>
#ifdef __cplusplus
extern "C" {
#endif
+
+/**
+ * Process a single Content, printing the FSS-0001 (Extended) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param content
+ * The string representing the Content to write to the buffer.
+ */
+#ifndef _di_fss_write_extended_process_content_
+ extern void fss_write_extended_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content);
+#endif // _di_fss_write_extended_process_content_
+
/**
* Process help for FSS-0001 (Extended).
*
#endif // _di_fss_write_extended_process_normal_
/**
+ * Process a single Object, printing the FSS-0001 (Extended) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param object
+ * The string representing the Object to write to the buffer.
+ */
+#ifndef _di_fss_write_extended_process_object_
+ extern void fss_write_extended_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object);
+#endif // _di_fss_write_extended_process_object_
+
+/**
* Process the pipe, reading from the pipe and writing to the output.
*
* @param main
fll_program_data_t data = fll_program_data_t_initialize;
fss_write_setting_t setting = fss_write_setting_t_initialize;
setting.state.data = (void *) &data;
+ setting.program_name = &fss_write_extended_program_name_s;
+ setting.program_name_long = &fss_write_extended_program_name_long_s;
setting.process_help = &fss_write_extended_process_help;
setting.process_pipe = &fss_write_extended_process_pipe;
setting.process_normal = &fss_write_extended_process_normal;
- setting.program_name = &fss_write_extended_program_name_s;
- setting.program_name_long = &fss_write_extended_program_name_long_s;
+ setting.process_object = &fss_write_exended_process_object;
+ setting.process_content = &fss_write_exended_process_content;
f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize;
data.parameters.array = parameters;
extern "C" {
#endif
+#ifndef _di_fss_write_extended_list_process_content_
+ void fss_write_extended_list_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_extended_list_content_write(
+ *content,
+ f_fss_complete_none_e,
+ ¯o_fss_write_setting(setting)->prepend,
+ ¯o_fss_write_setting(setting)->ignores,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_extended_list_content_write(
+ *content,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ ¯o_fss_write_setting(setting)->prepend,
+ ¯o_fss_write_setting(setting)->ignores,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_extended_list_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_extended_list_content_write");
+
+ return;
+ }
+ }
+#endif // _di_fss_write_extended_list_process_content_
+
#ifndef _di_fss_write_extended_list_process_help_
void fss_write_extended_list_process_help(fll_program_data_t * const main, void * const setting) {
- fss_write_extended_list_print_help((fss_write_setting_t *) setting, main->message);
+ fss_write_extended_list_print_help(macro_fss_write_setting(setting), main->message);
}
#endif // _di_fss_write_extended_list_process_help_
}
#endif // _di_fss_write_extended_list_process_normal_
+#ifndef _di_fss_write_extended_list_process_object_
+ void fss_write_extended_list_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object) {
+
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ macro_fss_write_setting(setting)->status = fl_fss_extended_list_object_write(
+ *object,
+ f_fss_complete_none_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+ else {
+ macro_fss_write_setting(setting)->status = fl_fss_extended_list_object_write(
+ *object,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_trim_e) ? f_fss_complete_full_trim_e : f_fss_complete_full_e,
+ macro_fss_write_setting(setting)->state,
+ ¯o_fss_write_setting(setting)->range,
+ ¯o_fss_write_setting(setting)->buffer
+ );
+ }
+
+ if (F_status_set_fine(macro_fss_write_setting(setting)->status) == F_none_eol) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
+
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_unsupported_eol(macro_fss_write_setting(setting), main->error, fss_write_extended_list_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
+
+ return;
+ }
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "fl_fss_extended_list_object_write");
+ }
+ }
+#endif // _di_fss_write_extended_list_process_object_
+
#ifndef _di_fss_write_extended_list_process_pipe_
void fss_write_extended_list_process_pipe(fll_program_data_t * const main, void * const setting) {
// FLL-1 includes.
#include <fll/level_1/conversion.h>
-#include <fll/level_1/fss/extended.h>
+#include <fll/level_1/fss/extended_list.h>
#include <fll/level_1/print.h>
#include <fll/level_1/string.h>
// FLL-2 includes.
#include <fll/level_2/error.h>
-#include <fll/level_2/fss/extended.h>
#include <fll/level_2/print.h>
#include <fll/level_2/program.h>
#endif
/**
+ * Process a single Content, printing the FSS-0003 (Extended List) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param content
+ * The string representing the Content to write to the buffer.
+ */
+#ifndef _di_fss_write_extended_list_process_content_
+ extern void fss_write_extended_list_process_content(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content);
+#endif // _di_fss_write_extended_list_process_content_
+
+/**
* Process help for FSS-0003 (Extended List).
*
* @param main
#endif // _di_fss_write_extended_list_process_normal_
/**
+ * Process a single Object, printing the FSS-0003 (Extended List) if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ * Must be of type (fss_write_setting_t *).
+ *
+ * This alters setting.status.
+ * This uses and alters setting.buffer.
+ * @param object
+ * The string representing the Object to write to the buffer.
+ */
+#ifndef _di_fss_write_extended_list_process_object_
+ extern void fss_write_extended_list_process_object(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object);
+#endif // _di_fss_write_extended_list_process_object_
+
+/**
* Process the pipe, reading from the pipe and writing to the output.
*
* @param main
fll_program_data_t data = fll_program_data_t_initialize;
fss_write_setting_t setting = fss_write_setting_t_initialize;
setting.state.data = (void *) &data;
+ setting.program_name = &fss_write_extended_list_program_name_s;
+ setting.program_name_long = &fss_write_extended_list_program_name_long_s;
setting.process_help = &fss_write_extended_list_process_help;
setting.process_pipe = &fss_write_extended_list_process_pipe;
setting.process_normal = &fss_write_extended_list_process_normal;
- setting.program_name = &fss_write_extended_list_program_name_s;
- setting.program_name_long = &fss_write_extended_list_program_name_long_s;
+ setting.process_object = &fss_write_exended_list_process_object;
+ setting.process_content = &fss_write_exended_list_process_content;
f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize;
data.parameters.array = parameters;
main->output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d;
if (main->parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) {
- setting->flag |= fss_write_main_flag_help_e;
+ setting->flag |= fss_write_flag_help_e;
}
if (main->parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) {
- setting->flag |= fss_write_main_flag_version_e;
+ setting->flag |= fss_write_flag_version_e;
}
if (callback) {
if (main->parameters.array[fss_write_parameter_help_e].result & f_console_result_found_e) return;
if (main->parameters.array[fss_write_parameter_version_e].result & f_console_result_found_e) return;
- if (main->parameters.array[fss_write_parameter_file_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_file_e].values.used) {
+ if ((main->parameters.array[fss_write_parameter_file_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_file_e].values.used) {
if (main->parameters.array[fss_write_parameter_file_e].values.used > 1) {
setting->status = F_status_set_error(F_parameter);
return;
}
- setting->flag |= fss_write_main_flag_file_to_e;
+ setting->flag |= fss_write_flag_file_to_e;
}
else if (main->parameters.array[fss_write_parameter_file_e].result & f_console_result_found_e) {
setting->status = F_status_set_error(F_parameter);
setting->objects.array[setting->objects.used++].size = 0;
} // for
- setting->flag |= fss_write_main_flag_object_e;
+ setting->flag |= fss_write_flag_object_e;
}
else if (main->parameters.array[fss_write_parameter_object_e].result & f_console_result_found_e) {
setting->status = F_status_set_error(F_parameter);
return;
}
- if (main->parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_content_e].values.used) {
+ if ((main->parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_content_e].values.used) {
f_array_lengths_t * const values = &main->parameters.array[fss_write_parameter_content_e].values;
setting->contents.used = 0;
setting->contents.array[setting->contents.used++].size = 0;
} // for
- setting->flag |= fss_write_main_flag_content_e;
+ setting->flag |= fss_write_flag_content_e;
}
else if (main->parameters.array[fss_write_parameter_content_e].result & f_console_result_found_e) {
setting->status = F_status_set_error(F_parameter);
return;
}
- if (main->parameters.array[fss_write_parameter_prepend_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_prepend_e].values.used) {
+ if ((main->parameters.array[fss_write_parameter_prepend_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_prepend_e].values.used) {
const f_array_length_t index = main->parameters.array[fss_write_parameter_prepend_e].values.array[main->parameters.array[fss_write_parameter_prepend_e].values.used - 1];
setting->prepend.used = 0;
} // for
}
- setting->flag |= fss_write_main_flag_prepend_e;
+ setting->flag |= fss_write_flag_prepend_e;
}
else if (main->parameters.array[fss_write_parameter_prepend_e].result & f_console_result_found_e) {
setting->status = F_status_set_error(F_parameter);
return;
}
- if (main->parameters.array[fss_write_parameter_ignore_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_ignore_e].values.used) {
+ if ((main->parameters.array[fss_write_parameter_ignore_e].result & f_console_result_value_e) && main->parameters.array[fss_write_parameter_ignore_e].values.used) {
if (main->parameters.array[fss_write_parameter_ignore_e].values.used % 2 != 0) {
setting->status = F_status_set_error(F_parameter);
++setting->ignores.used;
} // for
- setting->flag |= fss_write_main_flag_ignore_e;
+ setting->flag |= fss_write_flag_ignore_e;
}
else if (main->parameters.array[fss_write_parameter_ignore_e].result & f_console_result_found_e) {
setting->status = F_status_set_error(F_parameter);
}
if (main->parameters.array[fss_write_parameter_partial_e].result & f_console_result_found_e) {
- setting->flag |= fss_write_main_flag_partial_e;
+ setting->flag |= fss_write_flag_partial_e;
}
- if (setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e)) {
- if (setting->flag & fss_write_main_flag_object_e) {
+ if (setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e)) {
+ if (setting->flag & fss_write_flag_object_e) {
if (main->parameters.array[fss_write_parameter_object_e].locations.used != main->parameters.array[fss_write_parameter_object_e].values.used) {
setting->status = F_status_set_error(F_parameter);
return;
}
- if (main->parameters.array[fss_write_parameter_object_e].locations.used != main->parameters.array[fss_write_parameter_content_e].locations.used && !(setting->flag & fss_write_main_flag_partial_e)) {
+ if (main->parameters.array[fss_write_parameter_object_e].locations.used != main->parameters.array[fss_write_parameter_content_e].locations.used && !(setting->flag & fss_write_flag_partial_e)) {
setting->status = F_status_set_error(F_parameter);
fss_write_print_line_first_locked(setting, main->error);
return;
}
- if ((setting->flag & fss_write_main_flag_content_e) && (setting->flag & fss_write_main_flag_partial_e)) {
+ if ((setting->flag & fss_write_flag_content_e) && (setting->flag & fss_write_flag_partial_e)) {
if (main->parameters.array[fss_write_parameter_content_e].result & f_console_result_value_e) {
setting->status = F_status_set_error(F_parameter);
return;
}
}
-
- if (setting->flag & fss_write_main_flag_content_e) {
- f_array_length_t location_object = 0;
- f_array_length_t location_content = 0;
- f_array_length_t location_sub_object = 0;
- f_array_length_t location_sub_content = 0;
-
- for (f_array_length_t i = 0; i < main->parameters.array[fss_write_parameter_object_e].locations.used; ++i) {
-
- location_object = main->parameters.array[fss_write_parameter_object_e].locations.array[i];
- location_content = main->parameters.array[fss_write_parameter_content_e].locations.array[i];
- location_sub_object = main->parameters.array[fss_write_parameter_object_e].locations_sub.array[i];
- location_sub_content = main->parameters.array[fss_write_parameter_content_e].locations_sub.array[i];
-
- if (location_object > location_content || location_object == location_content && location_sub_object > location_sub_content) {
- setting->status = F_status_set_error(F_parameter);
-
- fss_write_print_line_first_locked(setting, main->error);
- fss_write_print_error_object_not_before_content(setting, main->error);
- fss_write_print_line_last_locked(setting, main->error);
-
- break;
- }
- } // for
- }
}
}
}
if (main->parameters.array[fss_write_parameter_trim_e].result & f_console_result_found_e) {
- setting->flag |= fss_write_main_flag_trim_e;
+ setting->flag |= fss_write_flag_trim_e;
}
- if (!(setting->flag & (fll_program_data_pipe_input_e | fss_write_main_flag_content_e | fss_write_parameter_object_e))) {
+ if (!(setting->flag & (fll_program_data_pipe_input_e | fss_write_flag_content_e | fss_write_parameter_object_e))) {
setting->status = F_data_not;
}
}
/**
* The program defines.
*
+ * The fss_write_pipe_content_*_s strings are strings rather than characters to allow for wide characters.
+ *
* payload_write_common_allocation_*:
* - large: An allocation step used for buffers that are anticipated to have large buffers.
* - small: An allocation step used for buffers that are anticipated to have small buffers.
+ *
+ * fss_write_pipe_content_*_s:
+ * - end: The character representing the end of content.
+ * - ignore: The character representing the start of or end of a set of characters to ignore.
+ * - start: The character representing the start of content.
+ *
+ * macro_fss_write_setting:
+ * - Used to represent a cast to ((fss_write_setting_t *) setting).
+ * - Simplifies the number of parenthesis used to make code slightly cleaner.
+ * - Is wrapped in a parenthesis and not a block.
*/
#ifndef _di_fss_write_defines_
#define fss_write_signal_check_d 20000
extern const f_string_static_t fss_write_pipe_content_end_s;
extern const f_string_static_t fss_write_pipe_content_ignore_s;
extern const f_string_static_t fss_write_pipe_content_start_s;
+
+ #define macro_fss_write_setting(setting) ((fss_write_setting_t *) setting)
#endif // _di_fss_write_defines_
/**
/**
* Flags used to represent flags passed to the main function.
*
- * fss_write_main_flag_*_e:
+ * fss_write_flag_*_e:
* - none: No modes in use.
* - content: The Content being written is specified.
* - double: Operate using double quotes.
* - object: The Object being written is specified.
* - partial: Do not write end of Object/Content character.
* - prepend: Prepend the given white space characters to the start of each multi-line Content.
+ * - printed: Designate that the first line has been print for the main output.
* - single: Operate using single quotes.
* - trim: Trim Object names.
* - version: Print version.
*/
-#ifndef _di_fss_write_main_flag_e_
+#ifndef _di_fss_write_flag_e_
enum {
- fss_write_main_flag_none_e = 0x0,
- fss_write_main_flag_content_e = 0x1,
- fss_write_main_flag_double_e = 0x2,
- fss_write_main_flag_file_to_e = 0x4,
- fss_write_main_flag_help_e = 0x8,
- fss_write_main_flag_ignore_e = 0x10,
- fss_write_main_flag_object_e = 0x20,
- fss_write_main_flag_partial_e = 0x40,
- fss_write_main_flag_prepend_e = 0x80,
- fss_write_main_flag_single_e = 0x100,
- fss_write_main_flag_trim_e = 0x200,
- fss_write_main_flag_version_e = 0x400,
+ fss_write_flag_none_e = 0x0,
+ fss_write_flag_content_e = 0x1,
+ fss_write_flag_double_e = 0x2,
+ fss_write_flag_file_to_e = 0x4,
+ fss_write_flag_help_e = 0x8,
+ fss_write_flag_ignore_e = 0x10,
+ fss_write_flag_object_e = 0x20,
+ fss_write_flag_partial_e = 0x40,
+ fss_write_flag_prepend_e = 0x80,
+ fss_write_flag_printed_e = 0x100,
+ fss_write_flag_single_e = 0x200,
+ fss_write_flag_trim_e = 0x400,
+ fss_write_flag_version_e = 0x800,
};
-#endif // _di_fss_write_main_flag_e_
+#endif // _di_fss_write_flag_e_
/**
* The fss payload write main program settings.
void (*process_help)(fll_program_data_t * const main, void * const setting);
void (*process_normal)(fll_program_data_t * const main, void * const setting);
void (*process_pipe)(fll_program_data_t * const main, void * const setting);
+ void (*process_object)(fll_program_data_t * const main, void * const setting, const f_string_static_t * const object);
+ void (*process_content)(fll_program_data_t * const main, void * const setting, const f_string_static_t * const content);
} fss_write_setting_t;
#define fss_write_setting_t_initialize \
{ \
- fss_write_main_flag_none_e, \
+ fss_write_flag_none_e, \
F_none, \
macro_f_state_t_initialize(fss_write_common_allocation_large_d, fss_write_common_allocation_small_d, 0, 0, &fll_program_standard_signal_state, 0, 0, 0), \
f_string_range_t_initialize, \
0, \
0, \
0, \
+ 0, \
+ 0, \
}
#endif // _di_fss_write_setting_t_
setting->status = F_none;
- if (setting->flag & fss_write_main_flag_help_e) {
+ if (setting->flag & fss_write_flag_help_e) {
setting->process_help(main, (void *) setting);
return;
}
- if (setting->flag & fss_write_main_flag_version_e) {
+ if (setting->flag & fss_write_flag_version_e) {
fll_program_print_version(main->message, fss_write_program_version_s);
return;
if (F_status_is_error(setting->status)) return;
}
- if (setting->flag & (fss_write_main_flag_object_e | fss_write_main_flag_content_e)) {
+ if (setting->flag & (fss_write_flag_object_e | fss_write_flag_content_e)) {
setting->process_normal(main, setting);
if (F_status_is_error(setting->status)) return;
}
- // Ensure a new line is always put at the end of the program execution, unless in quiet mode.
+ // Ensure a new line is always put at the end of the program execution.
fss_write_print_line_last_locked(setting, main->message);
}
#endif // _di_fss_write_main_
+#ifndef _di_fss_write_process_set_
+ void fss_write_process_set(fll_program_data_t * const main, fss_write_setting_t * const setting, const f_string_static_t * const object, const f_string_static_t * const content) {
+
+ setting->buffer.used = 0;
+
+ if (object) {
+ if (object->used) {
+ setting->range.start = 0;
+ setting->range.stop = object->used - 1;
+ }
+ else {
+ setting->range.start = 1;
+ setting->range.stop = 0;
+ }
+
+ setting->process_object(main, (void *) setting, object);
+ if (F_status_is_error(setting->status)) return;
+ }
+
+ if (content) {
+ if (content->used) {
+ setting->range.start = 0;
+ setting->range.stop = content->used - 1;
+ }
+ else {
+ setting->range.start = 1;
+ setting->range.stop = 0;
+ }
+
+ setting->process_content(main, (void *) setting, content);
+ if (F_status_is_error(setting->status)) return;
+ }
+
+ if (setting->buffer.used) {
+ fss_write_print_line_first_locked(setting, main->message);
+
+ f_file_stream_lock(main->output.to);
+
+ f_print_dynamic(setting->buffer, main->output.to);
+ f_print_dynamic_raw(f_string_eol_s, main->output.to);
+
+ f_file_stream_unlock(main->output.to);
+ }
+ }
+#endif // _di_fss_write_process_set_
+
#ifdef __cplusplus
} // extern "C"
#endif
extern void fss_write_main(fll_program_data_t * const main, fss_write_setting_t * const setting);
#endif // _di_fss_write_main_
+/**
+ * Process a given Object and Content, printing the assigned FSS format if valid or an error if invalid.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ *
+ * This alters setting.status:
+ * F_none on success.
+ * F_interrupt on (exit) signal received.
+ *
+ * F_parameter (with error bit) if main is NULL or setting is NULL.
+ * @param object
+ * The object to validate and print.
+ * Set pointer address to 0 to not use.
+ * @param content
+ * The content to escape and print.
+ * Set pointer address to 0 to not use.
+ */
+#ifndef _di_fss_write_process_set_
+ extern void fss_write_process_set(fll_program_data_t * const main, fss_write_setting_t * const setting, const f_string_static_t * const object, const f_string_static_t * const content);
+#endif // _di_fss_write_process_set_
+
#ifdef __cplusplus
} // extern "C"
#endif
#ifndef _di_fss_write_main_process_help_
void fss_write_main_process_help(fll_program_data_t * const main, void * const setting) {
- fss_write_main_print_help((fss_write_setting_t *) setting, main->message);
+ fss_write_main_print_help(macro_fss_write_setting(setting), main->message);
}
#endif // _di_fss_write_main_process_help_
#ifndef _di_fss_write_main_setting_load_as_
void fss_write_main_setting_load_as(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting) {
- if (!main || !setting || F_status_is_error(setting->status) || (setting->flag & fss_write_main_flag_version_e)) return;
+ if (!main || !setting || F_status_is_error(setting->status) || (setting->flag & fss_write_flag_version_e)) return;
setting->program_name = &fss_write_program_name_s;
setting->program_name_long = &fss_write_program_name_long_s;
setting->process_help = &fss_write_main_process_help;
setting->process_pipe = &fss_write_basic_process_pipe;
setting->process_normal = &fss_write_basic_process_normal;
+ setting->process_object = &fss_write_basic_process_object;
+ setting->process_content = &fss_write_basic_process_content;
if (main->parameters.array[fss_write_parameter_as_e].result & f_console_result_value_e && main->parameters.array[fss_write_parameter_as_e].values.used) {
setting->process_help = &fss_write_basic_process_help;
setting->process_pipe = &fss_write_basic_process_pipe;
setting->process_normal = &fss_write_basic_process_normal;
+ setting->process_object = &fss_write_basic_process_object;
+ setting->process_content = &fss_write_basic_process_content;
}
else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0001_s) == F_equal_to ||
fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0001_s) == F_equal_to ||
setting->process_help = &fss_write_extended_process_help;
setting->process_pipe = &fss_write_extended_process_pipe;
setting->process_normal = &fss_write_extended_process_normal;
+ setting->process_object = &fss_write_extended_process_object;
+ setting->process_content = &fss_write_extended_process_content;
}
else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0002_s) == F_equal_to ||
fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0002_s) == F_equal_to ||
setting->process_help = &fss_write_basic_list_process_help;
setting->process_pipe = &fss_write_basic_list_process_pipe;
setting->process_normal = &fss_write_basic_list_process_normal;
+ setting->process_object = &fss_write_basic_list_process_object;
+ setting->process_content = &fss_write_basic_list_process_content;
}
else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0003_s) == F_equal_to ||
fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0003_s) == F_equal_to ||
setting->process_help = &fss_write_extended_list_process_help;
setting->process_pipe = &fss_write_extended_list_process_pipe;
setting->process_normal = &fss_write_extended_list_process_normal;
+ setting->process_object = &fss_write_extended_list_process_object;
+ setting->process_content = &fss_write_extended_list_process_content;
}
else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_0008_s) == F_equal_to ||
fl_string_dynamic_compare(argv[index], fss_write_format_code_long_0008_s) == F_equal_to ||
setting->process_help = &fss_write_embedded_list_process_help;
setting->process_pipe = &fss_write_embedded_list_process_pipe;
setting->process_normal = &fss_write_embedded_list_process_normal;
+ setting->process_object = &fss_write_embedded_list_process_object;
+ setting->process_content = &fss_write_embedded_list_process_content;
}
else if (fl_string_dynamic_compare(argv[index], fss_write_format_code_short_000e_s) == F_equal_to ||
fl_string_dynamic_compare(argv[index], fss_write_format_code_long_000e_s) == F_equal_to ||
setting->process_help = &fss_write_payload_process_help;
setting->process_pipe = &fss_write_payload_process_pipe;
setting->process_normal = &fss_write_payload_process_normal;
-
+ setting->process_object = 0; // Not used by payload.
+ setting->process_content = 0; // Not used by payload.
}
else {
- if (setting->flag & fss_write_main_flag_help_e) {
+ if (setting->flag & fss_write_flag_help_e) {
setting->status = F_status_set_error(F_parameter);
break;
} // for
if (F_status_is_error(setting->status)) {
- if (setting->flag & fss_write_main_flag_help_e) {
+ if (setting->flag & fss_write_flag_help_e) {
fss_write_main_process_help(main, setting);
}
else {
else if (main->parameters.array[fss_write_parameter_as_e].result & f_console_result_found_e) {
setting->status = F_status_set_error(F_parameter);
- if (setting->flag & fss_write_main_flag_help_e) {
+ if (setting->flag & fss_write_flag_help_e) {
fss_write_main_process_help(main, setting);
return;
}
#endif // _di_fss_write_print_error_file_
-#ifndef _di_fss_write_print_error_object_not_before_content_
- f_status_t fss_write_print_error_object_not_before_content(fss_write_setting_t * const setting, const fl_print_t print) {
+#ifndef _di_fss_write_print_error_parameter_same_times_
+ f_status_t fss_write_print_error_parameter_same_times(fss_write_setting_t * const setting, const fl_print_t print) {
if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not;
f_file_stream_lock(print.to);
- fl_print_format("%r%[%QEach '%]", print.to, f_string_eol_s, print.set->error, print.prefix, print.set->error);
- fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_object_s, print.set->notable);
- fl_print_format("%[' parameter must be specified before a '%]", print.to, print.set->error, print.set->error);
- fl_print_format("%[%r%r%]", print.to, print.set->notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.set->notable);
- fl_print_format("%[' parameter.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+ fss_write_print_line_first_unlocked(setting, print);
+ fl_print_format("%[%QMust specify the '%]", print.to, print.context, print.prefix, print.context);
+ fl_print_format("%[%r%r%]", print.to, print.notable, f_console_symbol_long_normal_s, fss_write_long_object_s, print.notable);
+ fl_print_format("%[' parameter and the '%]", print.to, print.context, print.context);
+ fl_print_format("%[%r%r%]", print.to, print.notable, f_console_symbol_long_normal_s, fss_write_long_content_s, print.notable);
+ fl_print_format("%[' parameter the same number of times when not specifying the '%]", print.to, print.context, print.context);
+ fl_print_format("%[%r%r%]", print.to, print.notable, f_console_symbol_long_normal_s, fss_write_long_partial_s, print.notable);
+ fl_print_format("%[' parameter.%]%r", print.to, print.context, print.context, f_string_eol_s);
+ fss_write_print_line_last_unlocked(setting, print);
f_file_stream_unlock(print.to);
return F_none;
}
-#endif // _di_fss_write_print_error_object_not_before_content_
+#endif // _di_fss_write_print_error_parameter_same_times_
+
+// @todo replace fss_basic_write_error_parameter_value_missing_print with fll_program_print_error_parameter_missing_value.
+
+#ifndef _di_fss_write_print_error_parameter_unsupported_eol_object_
+ f_status_t fss_write_print_error_parameter_unsupported_eol_object(fss_write_setting_t * const setting, const fl_print_t print, const f_string_static_t standard) {
+
+ if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not;
+
+ f_file_stream_lock(print.to);
+
+ fss_write_print_line_first_unlocked(setting, print);
+ fl_print_format("%[%QThe %r standard does not support end of line character '%]", print.to, print.context, print.prefix, standard, print.context);
+ fl_print_format("%[\\n%]", print.to, print.notable, print.notable);
+ fl_print_format("%[' (%]", print.to, print.context, print.context);
+ fl_print_format("%[U+000A%]", print.to, print.notable, print.notable);
+ fl_print_format("%[) in objects.%]%r", print.to, print.context, print.context, f_string_eol_s);
+ fss_write_print_line_last_unlocked(setting, print);
+
+ f_file_stream_unlock(print.to);
+
+ return F_none;
+ }
+#endif // _di_fss_write_print_error_parameter_unsupported_eol_object_
#ifndef _di_fss_write_print_error_one_content_only_
f_status_t fss_write_print_error_one_content_only(fss_write_setting_t * const setting, const fl_print_t print, const f_string_static_t standard) {
#ifndef _di_fss_write_print_line_first_locked_
f_status_t fss_write_print_line_first_locked(fss_write_setting_t * const setting, const fl_print_t print) {
- if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not;
+ if (setting->flag & fss_write_flag_printed_e) return F_output_not;
- if (!F_status_is_error(setting->status)) {
+ if (F_status_is_error(setting->status)) {
+ if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not;
+ }
+ else {
+
+ // Always set to true to regardless of whether printed actually happened for non-errors.
+ setting->flag |= fss_write_flag_printed_e;
+
+ if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not;
if (print.verbosity == f_console_verbosity_error_e) return F_output_not;
}
#ifndef _di_fss_write_print_line_first_unlocked_
f_status_t fss_write_print_line_first_unlocked(fss_write_setting_t * const setting, const fl_print_t print) {
- if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not;
+ if (setting->flag & fss_write_flag_printed_e) return F_output_not;
- if (!F_status_is_error(setting->status)) {
+ if (F_status_is_error(setting->status)) {
+ if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not;
+ }
+ else {
+
+ // Always set to true to regardless of whether printed actually happened for non-errors.
+ setting->flag |= fss_write_flag_printed_e;
+
+ if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not;
if (print.verbosity == f_console_verbosity_error_e) return F_output_not;
}
if (!F_status_is_error(setting->status)) {
if (print.verbosity == f_console_verbosity_error_e) return F_output_not;
- if (setting->flag & fss_write_main_flag_file_to_e) return F_output_not;
+ if (setting->flag & fss_write_flag_file_to_e) return F_output_not;
}
fll_print_dynamic_raw(setting->line_last, print.to);
if (!F_status_is_error(setting->status)) {
if (print.verbosity == f_console_verbosity_error_e) return F_output_not;
- if (setting->flag & fss_write_main_flag_file_to_e) return F_output_not;
+ if (setting->flag & fss_write_flag_file_to_e) return F_output_not;
}
f_print_dynamic_raw(setting->line_last, print.to);
#endif // _di_fss_write_print_error_file_
/**
- * Print error message about each Object parameter not being specified before a Content parameter.
+ * Print an error message about the object and content parameters not being specified the same number of times.
*
* @param setting
* The main program settings.
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * @see fll_error_print()
+ */
+#ifndef _di_fss_write_print_error_parameter_same_times_
+ extern f_status_t fss_write_print_error_parameter_same_times(fss_write_setting_t * const setting, const fl_print_t print);
+#endif // _di_fss_write_print_error_parameter_same_times_
+
+/**
+ * Print an error message about a parameter a new line character '\n' (U+000A) being unsupported for an Object for the given standard.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param standard
+ * The string used to communicate the standad that does not support the EOL character.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * @see fll_error_print()
*/
-#ifndef _di_fss_write_print_error_object_not_before_content_
- extern f_status_t fss_write_print_error_object_not_before_content(fss_write_setting_t * const setting, const fl_print_t print);
-#endif // _di_fss_write_print_error_object_not_before_content_
+#ifndef _di_fss_write_print_error_parameter_unsupported_eol_object_
+ extern f_status_t fss_write_print_error_parameter_unsupported_eol_object(fss_write_setting_t * const setting, const fl_print_t print, const f_string_static_t standard);
+#endif // _di_fss_write_print_error_parameter_unsupported_eol_object_
/**
* Print an message about a multiple Content being unsupported.
const f_string_static_t fss_write_format_code_human_000e_s = macro_f_string_static_t_initialize(FSS_WRITE_format_code_human_000e_s, 0, FSS_WRITE_format_code_human_000e_s_length);
#endif // _di_fss_write_payload_strings_
-#ifndef _di_fss_write_payload_setting_load_
- void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting) {
-
- if (!main || !setting) return;
-
- f_array_lengths_t * const values = &main->parameters.array[fss_write_parameter_object_e].values;
- f_string_static_t * const argv = main->parameters.arguments.array;
-
- if ((main->parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && values->used) {
-
- for (f_array_length_t i = 0; i < values->used; ++i) {
-
- if (fl_string_dynamic_compare(argv[values->array[i]], fss_write_payload_s) == F_equal_to && i + 1 < values->used) {
- setting->status = F_status_set_error(F_parameter);
-
- fss_write_payload_print_error_payload_not_last(setting, main->error);
-
- return;
- }
- } // for
- }
- }
-#endif // _di_fss_write_payload_setting_load_
-
#ifdef __cplusplus
} // extern "C"
#endif
extern const f_string_static_t fss_write_format_code_human_000e_s;
#endif // _di_fss_write_payload_strings_
-/**
- * Perform the payload-specific program setting load process.
- *
- * This prints error messages as appropriate.
- *
- * If either main or setting is NULL, then this immediately retuns without doing anything.
- *
- * @param arguments
- * The parameters passed to the process (often referred to as command line arguments).
- * @param main
- * The main program data.
- * @param setting
- * The main program settings.
- *
- * This alters setting.process_help, setting.process_normal, and setting.process_pipe.
- *
- * This alters setting.status:
- * F_none on success.
- * F_interrupt on (exit) signal received.
- *
- * F_parameter (with error bit) if main is NULL or setting is NULL.
- * F_parameter (with error bit) on parameter error.
- *
- * This alters setting.status:
- * F_none on success.
- * F_data_not on success but nothing was provided to operate with.
- *
- * @see fss_write_setting_load()
- */
-#ifndef _di_fss_write_payload_setting_load_
- extern void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting);
-#endif // _di_fss_write_payload_setting_load_
-
#ifdef __cplusplus
} // extern "C"
#endif
#ifndef _di_fss_write_payload_process_help_
void fss_write_payload_process_help(fll_program_data_t * const main, void * const setting) {
- fss_write_payload_print_help((fss_write_setting_t *) setting, main->message);
+ fss_write_payload_print_help(macro_fss_write_setting(setting), main->message);
}
#endif // _di_fss_write_payload_process_help_
#ifndef _di_fss_write_payload_process_normal_
- void fss_write_payload_process_normal(fll_program_data_t * const main, void * const void_setting) {
+ void fss_write_payload_process_normal(fll_program_data_t * const main, void * const setting) {
- fss_write_setting_t * const setting = (fss_write_setting_t *) void_setting;
- f_string_statics_t *objects = &setting->objects;
- f_string_statics_t *contents = &setting->contents;
- f_string_statics_t *data = &setting->objects;
-
- if (setting->flag & fss_write_main_flag_partial_e) {
- if (setting->flag & fss_write_main_flag_content_e) {
- data = &setting->contents;
- objects = 0;
- }
- else {
- contents = 0;
- }
- }
+ f_string_statics_t * const data = (macro_fss_write_setting(setting)->flag & fss_write_flag_object_e) ? ¯o_fss_write_setting(setting)->objects : ¯o_fss_write_setting(setting)->contents;
for (f_array_length_t i = 0; i < data->used; ++i) {
+ // @todo replace all signal checks with forked main process that independently checks and assigns main->signal_received.
if (!((++main->signal_check) % fss_write_signal_check_d)) {
if (fll_program_standard_signal_received(main)) {
- setting->status = F_status_set_error(F_interrupt);
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_interrupt);
return;
}
main->signal_check = 0;
}
- fss_write_payload_process_set(main, setting, objects ? &objects->array[i] : 0, contents ? &contents->array[i] : 0);
- if (F_status_is_error(setting->status)) return;
+ fss_write_payload_process_set(
+ main,
+ macro_fss_write_setting(setting),
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_object_e) ? ¯o_fss_write_setting(setting)->objects.array[i] : 0,
+ (macro_fss_write_setting(setting)->flag & fss_write_flag_content_e) ? ¯o_fss_write_setting(setting)->contents.array[i] : 0
+ );
+
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) break;
} // for
}
#endif // _di_fss_write_payload_process_normal_
#ifndef _di_fss_write_payload_process_pipe_
- void fss_write_payload_process_pipe(fll_program_data_t * const main, void * const void_setting) {
+ void fss_write_payload_process_pipe(fll_program_data_t * const main, void * const setting) {
- fss_write_setting_t * const setting = (fss_write_setting_t *) void_setting;
f_status_t status_pipe = F_none;
f_file_t input = f_file_t_initialize;
input.id = F_type_descriptor_input_d;
if (!((++main->signal_check) % fss_write_signal_check_d)) {
if (fll_program_standard_signal_received(main)) {
- fll_program_print_signal_received(main->warning, setting->line_first, main->signal_received);
+ fll_program_print_signal_received(main->warning, macro_fss_write_setting(setting)->line_first, main->signal_received);
- setting->status = F_status_set_error(F_interrupt);
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_interrupt);
break;
}
if (range.start > range.stop) {
if (status_pipe == F_none_eof) break;
- setting->block.used = 0;
+ macro_fss_write_setting(setting)->block.used = 0;
- status_pipe = f_file_read_block(input, &setting->block);
+ status_pipe = f_file_read_block(input, ¯o_fss_write_setting(setting)->block);
if (F_status_is_error(status_pipe)) {
- fss_write_print_error(setting, main->error, "f_file_read_block");
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "f_file_read_block");
status_pipe = F_status_set_error(F_pipe);
break;
}
- if (!setting->block.used) break;
+ if (!macro_fss_write_setting(setting)->block.used) break;
range.start = 0;
- range.stop = setting->block.used - 1;
+ range.stop = macro_fss_write_setting(setting)->block.used - 1;
}
if (!state || state == 0x1) {
if (!state) {
- setting->object.used = 0;
- setting->content.used = 0;
+ macro_fss_write_setting(setting)->object.used = 0;
+ macro_fss_write_setting(setting)->content.used = 0;
state = 0x1;
}
- if (setting->object.used + setting->block.used > setting->object.size) {
- setting->status = f_string_dynamic_increase_by(setting->block.used, &setting->object);
+ if (macro_fss_write_setting(setting)->object.used + macro_fss_write_setting(setting)->block.used > macro_fss_write_setting(setting)->object.size) {
+ macro_fss_write_setting(setting)->status = f_string_dynamic_increase_by(macro_fss_write_setting(setting)->block.used, ¯o_fss_write_setting(setting)->object);
- if (F_status_is_error(setting->status)) {
- fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by");
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "f_string_dynamic_increase_by");
break;
}
for (; range.start <= range.stop; ++range.start) {
- if (setting->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) {
+ if (macro_fss_write_setting(setting)->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) {
state = 0x2;
++range.start;
break;
}
- if (setting->block.string[range.start] == fss_write_pipe_content_end_s.string[0]) {
+ if (macro_fss_write_setting(setting)->block.string[range.start] == fss_write_pipe_content_end_s.string[0]) {
state = 0x3;
++range.start;
break;
}
- if (setting->block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) {
+ if (macro_fss_write_setting(setting)->block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) {
// This is not used by objects.
continue;
}
- setting->object.string[setting->object.used++] = setting->block.string[range.start];
+ macro_fss_write_setting(setting)->object.string[macro_fss_write_setting(setting)->object.used++] = macro_fss_write_setting(setting)->block.string[range.start];
} // for
- if (F_status_is_error(setting->status)) break;
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) break;
// If the start of content was not found, then fetch the next block.
if (state == 0x1) continue;
}
// When payload is provided, all data at this point is part of the payload until the end of the pipe.
- if (fl_string_dynamic_compare(f_fss_string_payload_s, setting->object) == F_equal_to) {
+ if (fl_string_dynamic_compare(f_fss_string_payload_s, macro_fss_write_setting(setting)->object) == F_equal_to) {
if (total > 1) {
- setting->status = f_string_dynamic_increase_by(total, &setting->content);
+ macro_fss_write_setting(setting)->status = f_string_dynamic_increase_by(total, ¯o_fss_write_setting(setting)->content);
- if (F_status_is_error(setting->status)) {
- fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by");
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "f_string_dynamic_increase_by");
break;
}
- memcpy(setting->content.string, setting->block.string + range.start, sizeof(f_char_t) * total);
+ memcpy(macro_fss_write_setting(setting)->content.string, macro_fss_write_setting(setting)->block.string + range.start, sizeof(f_char_t) * total);
- setting->content.used += total;
+ macro_fss_write_setting(setting)->content.used += total;
}
state = 0x4;
}
if (total) {
- setting->status = f_string_dynamic_increase_by(total, &setting->content);
+ macro_fss_write_setting(setting)->status = f_string_dynamic_increase_by(total, ¯o_fss_write_setting(setting)->content);
- if (F_status_is_error(setting->status)) {
- fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by");
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "f_string_dynamic_increase_by");
break;
}
for (; range.start <= range.stop; ++range.start) {
- if (setting->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) {
- setting->status = F_status_set_error(F_supported_not);
+ if (macro_fss_write_setting(setting)->block.string[range.start] == fss_write_pipe_content_start_s.string[0]) {
+ macro_fss_write_setting(setting)->status = F_status_set_error(F_supported_not);
if (main->error.verbosity > f_console_verbosity_quiet_e) {
- fss_write_print_line_first_locked(setting, main->error);
- fss_write_print_error_one_content_only(setting, main->error, fss_write_payload_standard_s);
- fss_write_print_line_last_locked(setting, main->error);
+ fss_write_print_line_first_locked(macro_fss_write_setting(setting), main->error);
+ fss_write_print_error_one_content_only(macro_fss_write_setting(setting), main->error, fss_write_payload_standard_s);
+ fss_write_print_line_last_locked(macro_fss_write_setting(setting), main->error);
}
break;
}
- if (setting->block.string[range.start] == fss_write_pipe_content_end_s.string[0]) {
+ if (macro_fss_write_setting(setting)->block.string[range.start] == fss_write_pipe_content_end_s.string[0]) {
state = 0x3;
++range.start;
break;
}
- if (setting->block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) {
+ if (macro_fss_write_setting(setting)->block.string[range.start] == fss_write_pipe_content_ignore_s.string[0]) {
// This is not used by this program.
continue;
}
- setting->content.string[setting->content.used++] = setting->block.string[range.start];
+ macro_fss_write_setting(setting)->content.string[macro_fss_write_setting(setting)->content.used++] = macro_fss_write_setting(setting)->block.string[range.start];
} // for
- if (F_status_is_error(setting->status)) break;
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) break;
}
else {
state = 0x3;
}
if (state == 0x3) {
- if (setting->flag & fss_write_main_flag_partial_e) {
- if (setting->flag & fss_write_main_flag_content_e) {
- fss_write_payload_process_set(main, setting, 0, &setting->content);
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_content_e) {
+ fss_write_payload_process_set(main, macro_fss_write_setting(setting), 0, ¯o_fss_write_setting(setting)->content);
}
else {
- fss_write_payload_process_set(main, setting, &setting->object, 0);
+ fss_write_payload_process_set(main, macro_fss_write_setting(setting), ¯o_fss_write_setting(setting)->object, 0);
}
}
else {
- fss_write_payload_process_set(main, setting, &setting->object, &setting->content);
+ fss_write_payload_process_set(main, macro_fss_write_setting(setting), ¯o_fss_write_setting(setting)->object, ¯o_fss_write_setting(setting)->content);
}
- if (F_status_is_error(setting->status)) break;
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) break;
state = 0;
printed |= 0x1;
}
if (state == 0x4) {
- if (setting->block.used && range.start <= range.stop) {
+ if (macro_fss_write_setting(setting)->block.used && range.start <= range.stop) {
length = (range.stop - range.start) + 1;
- setting->status = f_string_dynamic_increase_by(length + 1, &setting->content);
+ macro_fss_write_setting(setting)->status = f_string_dynamic_increase_by(length + 1, ¯o_fss_write_setting(setting)->content);
- if (F_status_is_error(setting->status)) {
- fss_write_print_error(setting, main->error, "f_string_dynamic_increase_by");
+ if (F_status_is_error(macro_fss_write_setting(setting)->status)) {
+ fss_write_print_error(macro_fss_write_setting(setting), main->error, "f_string_dynamic_increase_by");
break;
}
- memcpy(setting->content.string + range.start, setting->block.string, sizeof(f_char_t) * length);
+ memcpy(macro_fss_write_setting(setting)->content.string + range.start, macro_fss_write_setting(setting)->block.string, sizeof(f_char_t) * length);
- setting->content.used += length;
+ macro_fss_write_setting(setting)->content.used += length;
}
// Designate to read next block from pipe.
} // for
// If the pipe ended before finishing, then attempt to wrap up.
- if (F_status_is_error_not(setting->status) && status_pipe == F_none_eof && state) {
- if (setting->flag & fss_write_main_flag_partial_e) {
- if (setting->flag & fss_write_main_flag_content_e) {
- fss_write_payload_process_set(main, setting, 0, &setting->content);
+ if (F_status_is_error_not(macro_fss_write_setting(setting)->status) && status_pipe == F_none_eof && state) {
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) {
+ if (macro_fss_write_setting(setting)->flag & fss_write_flag_content_e) {
+ fss_write_payload_process_set(main, macro_fss_write_setting(setting), 0, ¯o_fss_write_setting(setting)->content);
}
else {
- fss_write_payload_process_set(main, setting, &setting->object, 0);
+ fss_write_payload_process_set(main, macro_fss_write_setting(setting), ¯o_fss_write_setting(setting)->object, 0);
}
}
else {
- fss_write_payload_process_set(main, setting, &setting->object, &setting->content);
+ fss_write_payload_process_set(main, macro_fss_write_setting(setting), ¯o_fss_write_setting(setting)->object, ¯o_fss_write_setting(setting)->content);
}
printed |= 0x1;
}
- setting->block.used = 0;
- setting->object.used = 0;
- setting->content.used = 0;
- setting->buffer.used = 0;
+ macro_fss_write_setting(setting)->block.used = 0;
+ macro_fss_write_setting(setting)->object.used = 0;
+ macro_fss_write_setting(setting)->content.used = 0;
+ macro_fss_write_setting(setting)->buffer.used = 0;
- if (F_status_is_error_not(setting->status)) {
+ if (F_status_is_error_not(macro_fss_write_setting(setting)->status)) {
if (printed & 0x1) {
if (printed & 0x2) {
- setting->status = F_payload;
+ macro_fss_write_setting(setting)->status = F_payload;
}
else {
- setting->status = F_none;
+ macro_fss_write_setting(setting)->status = F_none;
}
}
else {
- setting->status = F_data_not;
+ macro_fss_write_setting(setting)->status = F_data_not;
}
// Print newline character to separate data printed from pipe.
- if ((setting->flag & fss_write_main_flag_partial_e) && setting->objects.used) {
+ if ((macro_fss_write_setting(setting)->flag & fss_write_flag_partial_e) && macro_fss_write_setting(setting)->objects.used) {
fll_print_dynamic(f_string_eol_s, main->output.to);
}
- else if (setting->contents.used) {
+ else if (macro_fss_write_setting(setting)->contents.used) {
fll_print_dynamic(f_fss_payload_header_close_s, main->output.to);
}
}
setting->range.stop = 0;
}
- setting->status = fll_fss_payload_write(*object, *content, setting->flag & fss_write_main_flag_trim_e, setting->flag & fss_write_main_flag_prepend_e ? &setting->prepend : 0, setting->state, &setting->buffer);
+ setting->status = fll_fss_payload_write(*object, *content, setting->flag & fss_write_flag_trim_e, setting->flag & fss_write_flag_prepend_e ? &setting->prepend : 0, setting->state, &setting->buffer);
if (F_status_set_fine(setting->status) == F_none_eol) {
setting->status = F_status_set_error(F_supported_not);
const f_string_static_t *prepend = 0;
- if (setting->flag & fss_write_main_flag_prepend_e) {
+ if (setting->flag & fss_write_flag_prepend_e) {
const f_array_length_t index = main->parameters.array[fss_write_parameter_prepend_e].values.array[main->parameters.array[fss_write_parameter_prepend_e].values.used - 1];
prepend = &main->parameters.arguments.array[index];
}
#endif // _di_fss_write_payload_process_set_
+#ifndef _di_fss_write_payload_setting_load_
+ void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting) {
+
+ if (!main || !setting) return;
+
+ f_array_lengths_t * const values = &main->parameters.array[fss_write_parameter_object_e].values;
+ f_string_static_t * const argv = main->parameters.arguments.array;
+
+ if ((main->parameters.array[fss_write_parameter_object_e].result & f_console_result_value_e) && values->used) {
+
+ for (f_array_length_t i = 0; i < values->used; ++i) {
+
+ if (fl_string_dynamic_compare(argv[values->array[i]], fss_write_payload_s) == F_equal_to && i + 1 < values->used) {
+ setting->status = F_status_set_error(F_parameter);
+
+ fss_write_payload_print_error_payload_not_last(setting, main->error);
+
+ return;
+ }
+ } // for
+ }
+ }
+#endif // _di_fss_write_payload_setting_load_
+
#ifdef __cplusplus
} // extern "C"
#endif
extern void fss_write_payload_process_set(fll_program_data_t * const main, fss_write_setting_t * const setting, const f_string_static_t *object, const f_string_static_t *content);
#endif // _di_fss_write_payload_process_set_
+/**
+ * Perform the payload-specific program setting load process.
+ *
+ * This prints error messages as appropriate.
+ *
+ * If either main or setting is NULL, then this immediately retuns without doing anything.
+ *
+ * @param arguments
+ * The parameters passed to the process (often referred to as command line arguments).
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ *
+ * This alters setting.process_help, setting.process_normal, and setting.process_pipe.
+ *
+ * This alters setting.status:
+ * F_none on success.
+ * F_interrupt on (exit) signal received.
+ *
+ * F_parameter (with error bit) if main is NULL or setting is NULL.
+ * F_parameter (with error bit) on parameter error.
+ *
+ * This alters setting.status:
+ * F_none on success.
+ * F_data_not on success but nothing was provided to operate with.
+ *
+ * @see fss_write_setting_load()
+ */
+#ifndef _di_fss_write_payload_setting_load_
+ extern void fss_write_payload_setting_load(const f_console_arguments_t arguments, fll_program_data_t * const main, fss_write_setting_t * const setting);
+#endif // _di_fss_write_payload_setting_load_
+
#ifdef __cplusplus
} // extern "C"
#endif
fll_program_data_t data = fll_program_data_t_initialize;
fss_write_setting_t setting = fss_write_setting_t_initialize;
setting.state.data = (void *) &data;
+ setting.program_name = &fss_write_payload_program_name_s;
+ setting.program_name_long = &fss_write_payload_program_name_long_s;
setting.process_help = &fss_write_payload_process_help;
setting.process_pipe = &fss_write_payload_process_pipe;
setting.process_normal = &fss_write_payload_process_normal;
- setting.program_name = &fss_write_payload_program_name_s;
- setting.program_name_long = &fss_write_payload_program_name_long_s;
+ setting.process_object = 0; // Not used by payload.
+ setting.process_content = 0; // Not used by payload.
f_console_parameter_t parameters[] = fss_write_console_parameter_t_initialize;
data.parameters.array = parameters;
# fss-0005 iki-0002
+#
+# Builds the fss_write library and all programs.
+#
+# An optional "install" is provided as a convience and a sort of documentation.
+# This "install" only provides a very basic setup and it is strongly recommended to install manually or through some other means.
+#
settings:
fail exit
- compiler gcc
- indexer ar
- indexer_arguments rcs
-
environment PATH LD_LIBRARY_PATH
main:
#build settings.extended_list parameter:'mode:value'
#build settings.embedded_list parameter:'mode:value'
build settings.payload parameter:'mode:value'
+
+install:
+ shell ./install.sh parameter:'work'
+ #shell ./install.sh parameter:'work' -s data/build/settings.main
+ #shell ./install.sh parameter:'work' -s data/build/settings.basic
+ #shell ./install.sh parameter:'work' -s data/build/settings.basic_list
+ #shell ./install.sh parameter:'work' -s data/build/settings.extended
+ #shell ./install.sh parameter:'work' -s data/build/settings.extended_list
+ #shell ./install.sh parameter:'work' -s data/build/settings.embedded_list
+ shell ./install.sh parameter:'work' -s data/build/settings.payload
}
}
- // Ensure a new line is always put at the end of the program execution, unless in quiet mode.
+ // Ensure a new line is always put at the end of the program execution.
iki_read_print_line_last_locked(setting, main->message);
}
#endif // _di_iki_read_main_
fll_print_dynamic_raw(f_string_eol_s, main->output.to);
} // for
- // Ensure a new line is always put at the end of the program execution, unless in quiet mode.
+ // Ensure a new line is always put at the end of the program execution.
iki_write_print_line_last_locked(setting, main->message);
}
#endif // _di_iki_write_main_
Key\:
code:"\s" = White space, except newline.
code:"\b" = Either white space or printable, except newline.
- code:"\q" = Non-white space or quoted white space with no white space outside of the quotes.
+ code:"\q" = Non-white space or quoted white space (and non-whitespace) with no white space outside of the quotes.
code:"\n" = Newline.
code:"*" = Zero or more occurrences.
code:"+" = One or more occurrences.
Key\:
code:"\s" = White space, except newline.
code:"\b" = Either white space or printable, except newline.
- code:"\q" = Non-white space or quoted white space, no white space outside of quotes.
+ code:"\q" = Non-white space or quoted white space (and non-whitespace) with no white space outside of the quotes.
code:"\n" = Newline.
code:"*" = Zero or more occurrences.
code:"+" = One or more occurrences.
Key\:
code:"\s" = White space, except newline.
code:"\b" = Either white space or printable, except newline.
- code:"\q" = Non-white space or quoted white space with no white space outside of the quotes.
+ code:"\q" = Non-white space or quoted white space (and non-whitespace) with no white space outside of the quotes.
code:"\n" = Newline.
code:"*" = Zero or more occurrences.
code:"+" = One or more occurrences.
Key\:
code:"\s" = White space, except newline.
code:"\b" = Either white space or printable, except newline.
- code:"\q" = Non-white space or quoted white space, no white space outside of quotes.
+ code:"\q" = Non-white space or quoted white space (and non-whitespace) with no white space outside of the quotes.
code:"\n" = Newline.
code:"*" = Zero or more occurrences.
code:"+" = One or more occurrences.