I like this idea that I implemented for fll_program_print_copyright().
The version now prints a new line before and after like everything else now.
The first and last can be disabled using the appropriate parameters.
#endif // _di_fll_program_print_signal_received_
#ifndef _di_fll_program_print_version_
- f_status_t fll_program_print_version(const fl_print_t print, const f_string_static_t version) {
+ f_status_t fll_program_print_version(const fl_print_t print, const uint8_t first_last, const f_string_static_t version) {
+
+ f_file_stream_lock(print.to);
+
+ if (first_last & 0x1) {
+ f_print_dynamic_raw(f_string_eol_s, print.to);
+ }
f_print_dynamic(version, print.to);
f_print_dynamic_raw(f_string_eol_s, print.to);
+ if (first_last & 0x2) {
+ f_print_dynamic_raw(f_string_eol_s, print.to);
+ }
+
+ f_file_stream_unlock(print.to);
+
return F_none;
}
#endif // _di_fll_program_print_version_
* @param print
* The output structure to print to.
* The print.verbosity is used to determine how much detail is printed (except for when _di_detailed_copyright_ is set).
- * @param uint8_t
+ * @param first_last
* Bitwise variable representing whether or not to print the first and last new line.
* Set bit 0x1 to printing first line.
* Set bit 0x2 to printing last line.
* The output structure to print to.
* This uses but does not lock or unlock file stream.
* This requires print.set to be non-NULL.
+ * @param first_last
+ * Bitwise variable representing whether or not to print the first and last new line.
+ * Set bit 0x1 to printing first line.
+ * Set bit 0x2 to printing last line.
* @param version
* The version number of the program.
*
* @see fl_print_format()
*/
#ifndef _di_fll_program_print_version_
- extern f_status_t fll_program_print_version(const fl_print_t print, const f_string_static_t version);
+ extern f_status_t fll_program_print_version(const fl_print_t print, const uint8_t first_last, const f_string_static_t version);
#endif // _di_fll_program_print_version_
#ifdef __cplusplus
}
if (main->parameters.array[byte_dump_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, byte_dump_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), byte_dump_program_version_s);
return F_none;
}
}
if (main->parameters.array[control_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, control_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), control_program_version_s);
return F_none;
}
}
if (main->parameters.array[controller_parameter_version_e].result & f_console_result_found_e) {
- controller_lock_print(main->output.to, 0);
-
- fll_program_print_version(main->message, controller_program_version_s);
-
- controller_unlock_print_flush(main->output.to, 0);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), controller_program_version_s);
return F_none;
}
}
if (setting->flag & fake_main_flag_version_e) {
- fll_program_print_version(main->message, fake_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fake_program_version_s);
return;
}
}
if (main->parameters.array[firewall_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, firewall_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), firewall_program_version_s);
return F_none;
}
}
if (main->parameters.array[fss_basic_list_read_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, fss_basic_list_read_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_basic_list_read_program_version_s);
return F_none;
}
}
if (main->parameters.array[fss_basic_read_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, fss_basic_read_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_basic_read_program_version_s);
return F_none;
}
}
if (main->parameters.array[fss_embedded_list_read_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, fss_embedded_list_read_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_embedded_list_read_program_version_s);
return F_none;
}
}
if (main->parameters.array[fss_extended_list_read_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, fss_extended_list_read_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_extended_list_read_program_version_s);
return status;
}
}
if (main->parameters.array[fss_extended_read_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, fss_extended_read_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_extended_read_program_version_s);
return status;
}
}
if (main->parameters.array[fss_identify_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, fss_identify_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_identify_program_version_s);
return F_none;
}
}
if (main->parameters.array[fss_payload_read_parameter_version_e].result & f_console_result_found_e) {
- fll_program_print_version(main->message, fss_payload_read_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_payload_read_program_version_s);
return status;
}
}
if (setting->flag & fss_write_flag_version_e) {
- fll_program_print_version(main->message, fss_write_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), fss_write_program_version_s);
return;
}
}
if (setting->flag & iki_read_main_flag_version_e) {
- fll_program_print_version(main->message, iki_read_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), iki_read_program_version_s);
return;
}
}
if (setting->flag & iki_write_main_flag_version_e) {
- fll_program_print_version(main->message, iki_write_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), iki_write_program_version_s);
return;
}
}
if (setting->flag & status_code_main_flag_version_e) {
- fll_program_print_version(main->message, status_code_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), status_code_program_version_s);
return;
}
}
if (setting->flag & utf8_main_flag_version_e) {
- fll_program_print_version(main->message, utf8_program_version_s);
+ fll_program_print_version(main->message, (setting->line_first.used ? 0x1 : 0x0) | (setting->line_last.used ? 0x2 : 0x0), utf8_program_version_s);
return;
}