Do more clean up in regards to utf8.
Update the first and last line printing logic.
Update the file structure.
Do the same for status_code.
I did not get to working on the first and last line printing logic.
build_sources_program fll/level_2/print.c
build_sources_program fll/level_2/program.c fll/level_2/program/common.c fll/level_2/program/print.c fll/level_2/private-program.c
-build_sources_program program/utf8/common.c program/utf8/bytesequence.c program/utf8/codepoint.c program/utf8/print.c program/utf8/process.c program/utf8/utf8.c
-
+build_sources_program program/utf8/main/common.c program/utf8/main/common/print.c program/utf8/main/common/string.c program/utf8/main/common/type.c program/utf8/main/bytesequence.c program/utf8/main/codepoint.c program/utf8/main/print.c program/utf8/main/print-error.c program/utf8/main/print-data.c program/utf8/main/process.c program/utf8/main/utf8.c
build_sources_program program/utf8/main.c
build_sources_documentation man
#endif
#ifndef _di_status_code_fss_print_help_detail_
- void status_code_fss_print_help_detail(void * const setting, const fl_print_t print) {
+ f_status_t status_code_fss_print_help_detail(void * const setting, const fl_print_t print) {
+
+ if (!setting) return F_status_set_error(F_output_not);
fl_print_format(" The FLL programs use a %[16-bit unsigned integer%] to represent the return status of programs and functions.%r%r", print.to, print.set->notable, print.set->notable, f_string_eol_s, f_string_eol_s);
fl_print_format(" Each code will be printed on its own line.%r", print.to, f_string_eol_s);
fl_print_format(" Errors regarding each code may be printed on its own line.%r", print.to, f_string_eol_s);
+
+ return F_none;
}
#endif // _di_status_code_fss_print_help_detail_
* @param print
* The output structure to print to.
*
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fl_print_format()
+ *
* @see status_code_print_help()
*/
#ifndef _di_status_code_fss_print_help_detail_
- extern void status_code_fss_print_help_detail(void * const setting, const fl_print_t print);
+ extern f_status_t status_code_fss_print_help_detail(void * const setting, const fl_print_t print);
#endif // _di_status_code_fss_print_help_detail_
#ifdef __cplusplus
#include <fll/level_2/program.h>
// Status Code includes.
-#include <program/status_code/main/common-print.h>
-#include <program/status_code/main/common-string.h>
-#include <program/status_code/main/common-type.h>
+#include <program/status_code/main/common/print.h>
+#include <program/status_code/main/common/string.h>
+#include <program/status_code/main/common/type.h>
#include <program/status_code/main/common.h>
#include <program/status_code/fss/common.h>
+#include <program/status_code/main/convert.h>
#include <program/status_code/main/print.h>
+#include <program/status_code/main/print-error.h>
+#include <program/status_code/main/process.h>
#ifdef __cplusplus
extern "C" {
-#include "status_code.h"
+#include "../status_code.h"
#ifdef __cplusplus
extern "C" {
-#include "status_code.h"
+#include "../status_code.h"
#ifdef __cplusplus
extern "C" {
-#include "status_code.h"
+#include "../status_code.h"
#ifdef __cplusplus
extern "C" {
* When number mode is not specified, then mode is "string" mode (there is no flag for "string" mode).
*
* status_code_main_flag_*_e:
- * - none: No flags set.
- * - copyright: Print copyright.
- * - error: Check if status is "error".
- * - fine: Check if status is "fine".
- * - help: Print help.
- * - number: Operate in number mode.
- * - version: Print version.
- * - warning: Check if status is "warning".
+ * - none: No flags set.
+ * - copyright: Print copyright.
+ * - error: Check if status is "error".
+ * - fine: Check if status is "fine".
+ * - help: Print help.
+ * - number: Operate in number mode.
+ * - print_first: When set, the first character printing logic is to be processed (this is usually automatic).
+ * - version: Print version.
+ * - warning: Check if status is "warning".
*/
#ifndef _di_status_code_main_flag_e_
enum {
- status_code_main_flag_none_e = 0x0,
- status_code_main_flag_copyright_e = 0x1,
- status_code_main_flag_error_e = 0x2,
- status_code_main_flag_fine_e = 0x4,
- status_code_main_flag_help_e = 0x8,
- status_code_main_flag_number_e = 0x10,
- status_code_main_flag_version_e = 0x20,
- status_code_main_flag_warning_e = 0x40,
- };
+ status_code_main_flag_none_e = 0x0,
+ status_code_main_flag_copyright_e = 0x1,
+ status_code_main_flag_error_e = 0x2,
+ status_code_main_flag_fine_e = 0x4,
+ status_code_main_flag_help_e = 0x8,
+ status_code_main_flag_number_e = 0x10,
+ status_code_main_flag_print_first_e = 0x20,
+ status_code_main_flag_version_e = 0x40,
+ status_code_main_flag_warning_e = 0x80,
+ }; // enum
#endif // _di_status_code_main_flag_e_
/**
f_status_t (*status_string_from)(const f_string_static_t name, f_status_t * const code);
f_status_t (*status_string_to)(const f_status_t code, f_string_static_t * const name);
- void (*status_string_help_detail)(void * const setting, const fl_print_t print);
+ f_status_t (*status_string_help_detail)(void * const setting, const fl_print_t print);
} status_code_setting_t;
#define status_code_setting_t_initialize \
{ \
- status_code_main_flag_none_e, \
+ status_code_main_flag_print_first_e, \
f_state_t_initialize, \
f_string_static_t_initialize, \
f_string_static_t_initialize, \
--- /dev/null
+#include "status_code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_status_code_convert_number_
+ void status_code_convert_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value, f_number_unsigned_t *number) {
+
+ if (!main || !setting) return;
+
+ setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, value, number);
+
+ if (*number > F_status_size_max_with_bits_d) {
+ status_code_print_line_first_data(setting, main->message);
+
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_out_of_range_s);
+
+ setting->state.status = F_status_set_error(F_number_overflow);
+
+ return;
+ }
+
+ if (F_status_is_error(setting->state.status)) {
+ status_code_print_line_first_data(setting, main->message);
+
+ if (F_status_set_fine(setting->state.status) == F_number_negative) {
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_out_of_range_s);
+ }
+ else {
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_invalid_number_s);
+ }
+ }
+ else {
+ setting->state.status = F_none;
+ }
+ }
+#endif // _di_status_code_convert_number_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Status Code
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ */
+#ifndef _PRIVATE_status_code_convert_h
+#define _PRIVATE_status_code_convert_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Convert the value string to the number, reporting any errors.
+ *
+ * @param main
+ * The main program data.
+ * @param value
+ * The parameter value to process.
+ * @param number
+ * The converted number.
+ * Will not be updated on error.
+ *
+ * This alters setting.state.status:
+ * F_none on success.
+ * F_data_not if string starts wth a null (length is 0).
+ * F_complete_not_utf (with error bit) if an incomplete UTF-8 fragment is found.
+ * F_number (with error bit) if parameter is not a number.
+ * F_number_negative (with error bit) on negative value.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: fl_console_parameter_to_number_unsigned().
+ *
+ * @see fl_console_parameter_to_number_unsigned()
+ */
+#ifndef _di_status_code_convert_number_
+ extern void status_code_convert_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value, f_number_unsigned_t *number);
+#endif // _di_status_code_convert_number_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_status_code_convert_h
#include "status_code.h"
-#include "print.h"
#ifdef __cplusplus
extern "C" {
#endif
+#ifndef _di_status_code_print_code_
+ f_status_t status_code_print_code(status_code_setting_t * const setting, const fl_print_t print, const uint16_t code) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
+
+ fll_print_format("%ui%r", print.to, code, f_string_eol_s);
+
+ return F_none;
+ }
+#endif // _di_status_code_print_code_
+
+#ifndef _di_status_code_print_context_value_
+ f_status_t status_code_print_context_value(status_code_setting_t * const setting, const fl_print_t print, const f_color_set_t context, const f_string_static_t value) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
+
+ fll_print_format("%[%Q%]%r", print.to, context, value, context, f_string_eol_s);
+
+ return F_none;
+ }
+#endif // _di_status_code_print_context_value_
+
#ifndef _di_status_code_print_error_
f_status_t status_code_print_error(status_code_setting_t * const setting, const fl_print_t print, const f_string_t function) {
+ if (!setting) return F_status_set_error(F_output_not);
if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
status_code_print_line_first_locked(setting, print);
#ifndef _di_status_code_print_error_cannot_error_warning_number_
f_status_t status_code_print_error_cannot_error_warning_number(status_code_setting_t * const setting, const fl_print_t print) {
+ if (!setting) return F_status_set_error(F_output_not);
if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
f_file_stream_lock(print.to);
#ifndef _di_status_code_print_error_no_status_codes_
f_status_t status_code_print_error_no_status_codes(status_code_setting_t * const setting, const fl_print_t print) {
+ if (!setting) return F_status_set_error(F_output_not);
if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
fll_print_format("%[No status code is specified.%]%r", print.to, print.context, print.context, f_string_eol_s);
#ifndef _di_status_code_print_error_invalid_callback_
f_status_t status_code_print_error_invalid_callback(status_code_setting_t * const setting, const fl_print_t print, const f_string_t name) {
+ if (!setting) return F_status_set_error(F_output_not);
if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
f_file_stream_lock(print.to);
#ifndef _di_status_code_print_help_
f_status_t status_code_print_help(status_code_setting_t * const setting, const fl_print_t print) {
+ if (!setting) return F_status_set_error(F_output_not);
+
f_file_stream_lock(print.to);
f_print_dynamic_raw(setting->line_first, print.to);
status_code_program_help_parameters_s
);
- if (setting->state.status_string_help_detail) {
- setting->state.status_string_help_detail(setting, print);
+ if (setting->status_string_help_detail) {
+ setting->status_string_help_detail(setting, print);
}
f_print_dynamic_raw(setting->line_last, print.to);
#endif // _di_status_code_print_help_
#ifndef _di_status_code_print_help_detail_
- void status_code_print_help_detail(void * const void_setting, const fl_print_t print) {
+ f_status_t status_code_print_help_detail(void * const void_setting, const fl_print_t print) {
+
+ if (!void_setting) return F_status_set_error(F_output_not);
fl_print_format(" The FLL programs use a %[16-bit unsigned integer%] to represent the return status of programs and functions.%r%r", print.to, print.set->notable, print.set->notable, f_string_eol_s, f_string_eol_s);
fl_print_format(" Each code will be printed on its own line.%r", print.to, print.set->notable, print.set->notable, f_string_eol_s);
fl_print_format(" Errors regarding each code may be printed on its own line.%r", print.to, f_string_eol_s);
+
+ return F_none;
}
#endif // _di_status_code_print_help_detail_
+#ifndef _di_status_code_print_line_first_data_
+ f_status_t status_code_print_line_first_data(status_code_setting_t * const setting, const fl_print_t print) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
+
+ if (setting->flag & status_code_main_flag_print_first_e) {
+ fll_print_dynamic_raw(setting->line_first, print.to);
+
+ setting->flag -= status_code_main_flag_print_first_e;
+ }
+
+ return F_none;
+ }
+#endif // _di_status_code_print_line_first_data_
+
#ifndef _di_status_code_print_line_first_locked_
f_status_t status_code_print_line_first_locked(status_code_setting_t * const setting, const fl_print_t print) {
- if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not;
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ if (setting->flag & status_code_main_flag_print_first_e) {
+ fll_print_dynamic_raw(setting->line_first, print.to);
- if (F_status_is_error_not(setting->state.status)) {
- if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
+ setting->flag -= status_code_main_flag_print_first_e;
+ }
+ else {
+ fll_print_dynamic_raw(f_string_eol_s, print.to);
}
-
- f_print_dynamic_raw(setting->line_first, print.to);
return F_none;
}
#ifndef _di_status_code_print_line_first_unlocked_
f_status_t status_code_print_line_first_unlocked(status_code_setting_t * const setting, const fl_print_t print) {
- if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not;
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
- if (F_status_is_error_not(setting->state.status)) {
- if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
- }
+ if (setting->flag & status_code_main_flag_print_first_e) {
+ fll_print_dynamic_raw(setting->line_first, print.to);
- fll_print_dynamic_raw(setting->line_first, print.to);
+ setting->flag -= status_code_main_flag_print_first_e;
+ }
+ else {
+ fll_print_dynamic_raw(f_string_eol_s, print.to);
+ }
return F_none;
}
#ifndef _di_status_code_print_line_last_locked_
f_status_t status_code_print_line_last_locked(status_code_setting_t * const setting, const fl_print_t print) {
- if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- if (F_status_is_error_not(setting->state.status)) {
- if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
- }
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
fll_print_dynamic_raw(setting->line_last, print.to);
#ifndef _di_status_code_print_line_last_unlocked_
f_status_t status_code_print_line_last_unlocked(status_code_setting_t * const setting, const fl_print_t print) {
- if (!setting || print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- if (F_status_is_error_not(setting->state.status)) {
- if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
- }
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
f_print_dynamic_raw(setting->line_last, print.to);
#endif
/**
+ * Print generic code.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param code
+ * The code to print.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_print_format()
+ */
+#ifndef _di_status_code_print_code_
+ f_status_t status_code_print_code(status_code_setting_t * const setting, const fl_print_t print, const uint16_t code);
+#endif // _di_status_code_print_code_
+
+/**
+ * Print generic context wrapped value.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param context
+ * The context string to wrap the variable with.
+ * @param value
+ * The value string.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_print_format()
+ */
+#ifndef _di_status_code_print_context_value_
+ f_status_t status_code_print_context_value(status_code_setting_t * const setting, const fl_print_t print, const f_color_set_t context, const f_string_static_t value);
+#endif // _di_status_code_print_context_value_
+
+/**
* Print generic error message regarding a function failing in some way.
*
* @param setting
* F_none on success.
* F_output_not on success, but no printing is performed.
*
+ * F_output_not (with error bit) if setting is NULL.
+ *
* @see fll_error_print()
+ *
+ * @see status_code_print_line_first_locked()
*/
#ifndef _di_status_code_print_error_
extern f_status_t status_code_print_error(status_code_setting_t * const setting, const fl_print_t print, const f_string_t function);
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see fl_print_format()
*/
#ifndef _di_status_code_print_error_cannot_error_warning_number_
extern f_status_t status_code_print_error_cannot_error_warning_number(status_code_setting_t * const setting, const fl_print_t print);
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_print_format()
*/
#ifndef _di_status_code_print_error_no_status_codes_
extern f_status_t status_code_print_error_no_status_codes(status_code_setting_t * const setting, const fl_print_t print);
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see fl_print_format()
*/
#ifndef _di_status_code_print_error_invalid_callback_
extern f_status_t status_code_print_error_invalid_callback(status_code_setting_t * const setting, const fl_print_t print, const f_string_t name);
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see f_file_stream_flush()
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see f_print_dynamic_raw()
+ * @see fl_print_format()
+ *
+ * @see fll_program_print_help_header()
+ * @see fll_program_print_help_option()
+ * @see fll_program_print_help_option_standard()
+ * @see fll_program_print_help_usage()
*/
#ifndef _di_status_code_print_help_
extern f_status_t status_code_print_help(status_code_setting_t * const setting, const fl_print_t print);
* @param print
* The output structure to print to.
*
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fl_print_format()
+ *
* @see status_code_print_help()
*/
#ifndef _di_status_code_print_help_detail_
- extern void status_code_print_help_detail(void * const setting, const fl_print_t print);
+ extern f_status_t status_code_print_help_detail(void * const setting, const fl_print_t print);
#endif // _di_status_code_print_help_detail_
/**
+ * Print first new line, if applicable, otherwise nothing.
+ *
+ * This is generally intended to be used before data prints.
+ * This should probably be printed to setting.message while data goes to setting.output.
+ *
+ * This ensures a first line is printed if the data is the first output to be performed.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_print_dynamic_raw()
+ */
+#ifndef _di_status_code_print_line_first_data_
+ extern f_status_t status_code_print_line_first_data(status_code_setting_t * const setting, const fl_print_t print);
+#endif // _di_status_code_print_line_first_data_
+
+/**
* Print first new line, unless verbosity says otherwise.
*
* This is generally either the first line in the program or the first line printed before an error message.
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_print_dynamic_raw()
*/
#ifndef _di_status_code_print_line_first_locked_
extern f_status_t status_code_print_line_first_locked(status_code_setting_t * const setting, const fl_print_t print);
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_print_dynamic_raw()
*/
#ifndef _di_status_code_print_line_first_unlocked_
extern f_status_t status_code_print_line_first_unlocked(status_code_setting_t * const setting, const fl_print_t print);
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_print_dynamic_raw()
*/
#ifndef _di_status_code_print_line_last_locked_
extern f_status_t status_code_print_line_last_locked(status_code_setting_t * const setting, const fl_print_t print);
* @return
* F_none on success.
* F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see f_print_dynamic_raw()
*/
#ifndef _di_status_code_print_line_last_unlocked_
extern f_status_t status_code_print_line_last_unlocked(status_code_setting_t * const setting, const fl_print_t print);
+++ /dev/null
-#include "status_code.h"
-#include "private-status_code.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _di_status_code_process_check_
- f_status_t status_code_process_check(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) {
-
- f_number_unsigned_t number = 0;
-
- {
- f_status_t status = status_code_convert_number(main, setting, value, &number);
- if (F_status_is_error(status)) return status;
- }
-
- if ((setting->flag & status_code_main_flag_error_e) && F_status_is_error(number) || (setting->flag & status_code_main_flag_warning_e) && F_status_is_warning(number) || (setting->flag & status_code_main_flag_fine_e) && F_status_is_fine(number)) {
- f_print_dynamic_raw(f_status_true_s, main->output.to);
- }
- else {
- f_print_dynamic_raw(f_status_false_s, main->output.to);
- }
-
- f_print_dynamic_raw(f_string_eol_s, main->output.to);
-
- return F_none;
- }
-#endif // _di_status_code_process_check_
-
-#ifndef _di_status_code_process_number_
- f_status_t status_code_process_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) {
-
- f_status_t status = F_none;
-
- {
- f_number_unsigned_t number = 0;
-
- status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, value, &number);
-
- if (status == F_none) {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_invalid_name_s, main->context.set.error, f_string_eol_s);
-
- return F_status_set_error(F_parameter);
- }
-
- if (status == F_data_not || F_status_set_fine(status) == F_parameter) {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_invalid_main_s, main->context.set.error, f_string_eol_s);
-
- return status;
- }
- }
-
- f_status_t code = F_none;
-
- status = setting->status_string_from(value, &code);
-
- if (F_status_is_error(status)) {
- if (F_status_set_fine(status) == F_data) {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_unknown_name_s, main->context.set.error, f_string_eol_s);
- }
- else {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_failed_to_convert_s, main->context.set.error, f_string_eol_s);
- }
-
- return status;
- }
-
- if (status == F_data) {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_unknown_code_s, main->context.set.error, f_string_eol_s);
-
- return F_none;
- }
-
- if (setting->flag & status_code_main_flag_error_e) {
- code = F_status_set_error(code);
- }
-
- if (setting->flag & status_code_main_flag_warning_e) {
- code = F_status_set_warning(code);
- }
-
- fl_print_format("%ui%r", main->output.to, code, f_string_eol_s);
-
- return F_none;
- }
-#endif // _di_status_code_process_number_
-
-#ifndef _di_status_code_process_normal_
- f_status_t status_code_process_normal(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) {
-
- f_number_unsigned_t number = 0;
-
- f_status_t status = status_code_convert_number(main, setting, value, &number);
- if (F_status_is_error(status)) return status;
-
- f_string_static_t name = f_string_static_t_initialize;
-
- status = setting->status_string_to((f_status_t) number, &name);
-
- if (F_status_is_error(status)) {
- if (F_status_set_fine(status) == F_data) {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_unknown_code_s, main->context.set.error, f_string_eol_s);
- }
- else {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_failed_to_convert_s, main->context.set.error, f_string_eol_s);
- }
-
- return status;
- }
-
- fl_print_format("%Q%r", main->output.to, name, f_string_eol_s);
-
- return F_none;
- }
-#endif // _di_status_code_process_normal_
-
-#ifndef _di_status_code_convert_number_
- f_status_t status_code_convert_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value, f_number_unsigned_t *number) {
-
- const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, value, number);
-
- if (*number > F_status_size_max_with_bits_d) {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_out_of_range_s, main->context.set.error, f_string_eol_s);
-
- return F_status_set_error(F_number_overflow);
- }
-
- if (F_status_is_error(status)) {
- if (F_status_set_fine(status) == F_number_negative) {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_out_of_range_s, main->context.set.error, f_string_eol_s);
- }
- else {
- fl_print_format("%[%r%]%r", main->output.to, main->context.set.error, status_code_invalid_number_s, main->context.set.error, f_string_eol_s);
- }
-
- return status;
- }
-
- return F_none;
- }
-#endif // _di_status_code_convert_number_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
--- /dev/null
+#include "status_code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_status_code_process_check_
+ void status_code_process_check(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) {
+
+ if (!main || !setting) return;
+
+ f_number_unsigned_t number = 0;
+
+ {
+ status_code_convert_number(main, setting, value, &number);
+ if (F_status_is_error(setting->state.status)) return;
+ }
+
+ f_file_stream_lock(main->output.to);
+
+ status_code_print_line_first_unlocked(setting, main->output);
+
+ if ((setting->flag & status_code_main_flag_error_e) && F_status_is_error(number) || (setting->flag & status_code_main_flag_warning_e) && F_status_is_warning(number) || (setting->flag & status_code_main_flag_fine_e) && F_status_is_fine(number)) {
+ f_print_dynamic_raw(f_status_true_s, main->output.to);
+ }
+ else {
+ f_print_dynamic_raw(f_status_false_s, main->output.to);
+ }
+
+ f_print_dynamic_raw(f_string_eol_s, main->output.to);
+
+ f_file_stream_unlock(main->output.to);
+
+ setting->state.status = F_none;
+ }
+#endif // _di_status_code_process_check_
+
+#ifndef _di_status_code_process_number_
+ void status_code_process_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) {
+
+ if (!main || !setting) return;
+
+ {
+ f_number_unsigned_t number = 0;
+
+ setting->state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, value, &number);
+
+ if (setting->state.status == F_none) {
+ status_code_print_line_first_data(setting, main->message);
+
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_invalid_name_s);
+
+ setting->state.status = F_status_set_error(F_parameter);
+
+ return;
+ }
+
+ if (setting->state.status == F_data_not || F_status_set_fine(setting->state.status) == F_parameter) {
+ status_code_print_line_first_data(setting, main->message);
+
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_invalid_main_s);
+
+ return;
+ }
+ }
+
+ f_status_t code = F_none;
+
+ setting->state.status = setting->status_string_from(value, &code);
+
+ if (F_status_is_error(setting->state.status)) {
+ status_code_print_line_first_data(setting, main->message);
+
+ if (F_status_set_fine(setting->state.status) == F_data) {
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_unknown_name_s);
+ }
+ else {
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_failed_to_convert_s);
+ }
+
+ return;
+ }
+
+ if (setting->state.status == F_data) {
+ status_code_print_line_first_data(setting, main->message);
+
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_unknown_code_s);
+
+ setting->state.status = F_none;
+
+ return;
+ }
+
+ if (setting->flag & status_code_main_flag_error_e) {
+ code = F_status_set_error(code);
+ }
+
+ if (setting->flag & status_code_main_flag_warning_e) {
+ code = F_status_set_warning(code);
+ }
+
+ status_code_print_line_first_data(setting, main->message);
+
+ status_code_print_code(setting, main->output, code);
+
+ setting->state.status = F_none;
+ }
+#endif // _di_status_code_process_number_
+
+#ifndef _di_status_code_process_normal_
+ void status_code_process_normal(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) {
+
+ if (!main || !setting) return;
+
+ f_string_static_t name = f_string_static_t_initialize;
+
+ {
+ f_number_unsigned_t number = 0;
+
+ status_code_convert_number(main, setting, value, &number);
+ if (F_status_is_error(setting->state.status)) return;
+
+ setting->state.status = setting->status_string_to((f_status_t) number, &name);
+ }
+
+ status_code_print_line_first_data(setting, main->message);
+
+ if (F_status_is_error(setting->state.status)) {
+ if (F_status_set_fine(setting->state.status) == F_data) {
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_unknown_code_s);
+ }
+ else {
+ status_code_print_context_value(setting, main->output, main->context.set.error, status_code_failed_to_convert_s);
+ }
+
+ return;
+ }
+
+ status_code_print_context_value(setting, main->output, f_color_set_empty_s, name);
+
+ setting->state.status = F_none;
+ }
+#endif // _di_status_code_process_normal_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*/
-#ifndef _PRIVATE_status_code_h
-#define _PRIVATE_status_code_h
+#ifndef _PRIVATE_status_code_process_h
+#define _PRIVATE_status_code_process_h
#ifdef __cplusplus
extern "C" {
* @see fss_status_code_convert_number()
*/
#ifndef _di_status_code_process_check_
- extern void status_code_process_check(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d;
+ extern void status_code_process_check(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value);
#endif // _di_status_code_process_check_
/**
* @see fll_status_string_from()
*/
#ifndef _di_status_code_process_number_
- extern void status_code_process_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d;
+ extern void status_code_process_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value);
#endif // _di_status_code_process_number_
/**
* @see fss_status_code_convert_number()
*/
#ifndef _di_status_code_process_normal_
- extern void status_code_process_normal(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value) F_attribute_visibility_internal_d;
+ extern void status_code_process_normal(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value);
#endif // _di_status_code_process_normal_
-/**
- * Convert the value string to the number, reporting any errors.
- *
- * @param main
- * The main program data.
- * @param value
- * The parameter value to process.
- * @param number
- * The converted number.
- * Will not be updated on error.
- *
- * This alters setting.state.status:
- * F_none on success.
- * F_data_not if string starts wth a null (length is 0).
- * F_complete_not_utf (with error bit) if an incomplete UTF-8 fragment is found.
- * F_number (with error bit) if parameter is not a number.
- * F_number_negative (with error bit) on negative value.
- * F_number_overflow (with error bit) on integer overflow.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: fl_console_parameter_to_number_unsigned().
- *
- * @see fl_console_parameter_to_number_unsigned()
- */
-#ifndef _di_status_code_convert_number_
- extern void status_code_convert_number(fll_program_data_t * const main, status_code_setting_t * const setting, const f_string_static_t value, f_number_unsigned_t *number) F_attribute_visibility_internal_d;
-#endif // _di_status_code_convert_number_
-
#ifdef __cplusplus
} // extern "C"
#endif
-#endif // _PRIVATE_status_code_h
+#endif // _PRIVATE_status_code_process_h
#include "status_code.h"
-#include "private-status_code.h"
#ifdef __cplusplus
extern "C" {
return;
}
- if (!setting->state.status_string_from || !setting->state.status_string_to) {
+ if (!setting->status_string_from || !setting->status_string_to) {
- if (!setting->state.status_string_from) {
+ if (!setting->status_string_from) {
status_code_print_error_invalid_callback(setting, main->error, macro_status_code_f(status_string_from));
}
- if (!setting->state.status_string_to) {
+ if (!setting->status_string_to) {
status_code_print_error_invalid_callback(setting, main->error, macro_status_code_f(status_string_to));
}
return;
}
- f_status_t status2 = F_none;
+ f_status_t status = F_none;
if (setting->flag & status_code_main_flag_number_e) {
if (main->pipe & fll_program_data_pipe_input_e) {
main->signal_check = 0;
}
- status2 = status_code_process_number(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]);
+ status = setting->state.status;
- if (F_status_is_error(status2) && setting->state.status == F_none) {
- setting->state.status = status2;
+ status_code_process_number(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]);
+
+ if (F_status_is_error_not(setting->state.status)) {
+ setting->state.status = status;
}
} // for
f_file_stream_unlock(main->output.to);
}
}
- else if (setting->flag & status_code_main_flag_error_e || setting->flag & status_code_main_flag_warning_e || setting->flag & status_code_main_flag_fine_e) {
+ else if ((setting->flag & status_code_main_flag_error_e) || (setting->flag & status_code_main_flag_warning_e) || (setting->flag & status_code_main_flag_fine_e)) {
if (main->pipe & fll_program_data_pipe_input_e) {
// @todo call status_code_process_check() here for all main from pipe that is space separated.
}
main->signal_check = 0;
}
- status2 = status_code_process_check(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]);
+ status = setting->state.status;
+
+ status_code_process_check(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]);
- if (F_status_is_error(status2) && setting->state.status == F_none) {
- setting->state.status = status2;
+ if (F_status_is_error_not(setting->state.status)) {
+ setting->state.status = status;
}
} // for
main->signal_check = 0;
}
- status2 = status_code_process_normal(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]);
+ status = setting->state.status;
+
+ status_code_process_normal(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]);
- if (F_status_is_error(status2) && setting->state.status == F_none) {
- setting->state.status = status2;
+ if (F_status_is_error_not(setting->state.status)) {
+ setting->state.status = status;
}
} // for
#include <fll/level_2/status_string.h>
// Status Code includes.
-#include <program/status_code/main/common-print.h>
-#include <program/status_code/main/common-string.h>
-#include <program/status_code/main/common-type.h>
+#include <program/status_code/main/common/print.h>
+#include <program/status_code/main/common/string.h>
+#include <program/status_code/main/common/type.h>
#include <program/status_code/main/common.h>
+#include <program/status_code/main/convert.h>
#include <program/status_code/main/print.h>
+#include <program/status_code/main/print-error.h>
+#include <program/status_code/main/process.h>
#ifdef __cplusplus
extern "C" {
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
-build_sources_library main/status_code.c main/common.c main/common-print.c main/common-string.c main/common-type.c main/print.c main/private-status_code.c
+build_sources_library main/status_code.c main/common.c main/common/print.c main/common/string.c main/common/type.c main/convert.c main/print.c main/print-error.c main/process.c
build_sources_library fss/status_code.c fss/common.c
-build_sources_headers main/status_code.h main/common.h main/common-print.h main/common-string.h main/common-type.h main/print.h
+build_sources_headers main/status_code.h main/common.h main/common/print.h main/common/string.h main/common/type.h main/convert.h main/print.h main/print-error.h main/process.h
build_sources_headers fss/status_code.h fss/common.h
build_sources_documentation man
if (setting->state.status == F_failure || setting->state.status == F_utf_not || setting->state.status == F_complete_not_utf || setting->state.status == F_utf_fragment || setting->state.status == F_valid_not) {
valid_not = F_true;
- utf8_print_character_invalid(setting, main->output, sequence);
+ utf8_print_data_character_invalid(setting, main->output, sequence);
}
else {
setting->state.status = F_status_set_error(setting->state.status);
}
else if (!(setting->flag & utf8_main_flag_verify_e)) {
if (setting->mode & utf8_mode_to_bytesequence_e) {
- utf8_print_bytesequence(setting, main->output, sequence);
+ utf8_print_data_bytesequence(setting, main->output, sequence);
}
else if (setting->mode & utf8_mode_to_codepoint_e) {
- utf8_print_codepoint(setting, main->output, codepoint);
+ utf8_print_data_codepoint(setting, main->output, codepoint);
}
else {
- utf8_print_combining_or_width(setting, main->output, sequence);
+ utf8_print_data_combining_or_width(setting, main->output, sequence);
}
}
* Errors (with error bit) from: f_utf_unicode_to()
*/
#ifndef _di_utf8_convert_bytesequence_
- extern void utf8_convert_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence) F_attribute_visibility_internal_d;
+ extern void utf8_convert_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t sequence);
#endif // _di_utf8_convert_bytesequence_
/**
* @see utf8_detect_codepoint()
*/
#ifndef _di_utf8_process_file_bytesequence_
- extern void utf8_process_file_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) F_attribute_visibility_internal_d;
+ extern void utf8_process_file_bytesequence(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file);
#endif // _di_utf8_process_file_bytesequence_
#ifdef __cplusplus
if (setting->state.status == F_failure || setting->state.status == F_utf_not || setting->state.status == F_complete_not_utf || setting->state.status == F_utf_fragment || setting->state.status == F_valid_not) {
valid_not = F_true;
- utf8_print_character_invalid(setting, main->output, unicode);
+ utf8_print_data_character_invalid(setting, main->output, unicode);
}
else {
setting->state.status = F_status_set_error(setting->state.status);
}
else if (!(setting->flag & utf8_main_flag_verify_e)) {
if (setting->mode & utf8_mode_to_codepoint_e) {
- utf8_print_codepoint(setting, main->output, codepoint);
+ utf8_print_data_codepoint(setting, main->output, codepoint);
}
else {
f_char_t byte[4] = { 0, 0, 0, 0 };
utf8_print_error_encode(setting, main->error, codepoint);
}
else {
- utf8_print_combining_or_width_invalid(setting, main->output);
+ utf8_print_data_combining_or_width_invalid(setting, main->output);
}
}
else if (setting->mode & utf8_mode_to_bytesequence_e) {
setting->state.status = F_none;
unicode.used = macro_f_utf_byte_width(unicode.string[0]);
- utf8_print_bytesequence(setting, main->output, unicode);
+ utf8_print_data_bytesequence(setting, main->output, unicode);
}
else {
setting->state.status = F_none;
- utf8_print_combining_or_width(setting, main->output, unicode);
+ utf8_print_data_combining_or_width(setting, main->output, unicode);
}
}
}
else if (*mode == utf8_codepoint_mode_bad_end_e) {
setting->state.status = F_none;
- utf8_print_character_invalid(setting, main->output, unicode);
+ utf8_print_data_character_invalid(setting, main->output, unicode);
}
else {
setting->state.status = F_none;
if (setting->state.status == F_number || setting->state.status == F_utf_not || setting->state.status == F_complete_not_utf || setting->state.status == F_utf_fragment || setting->state.status == F_number_decimal || setting->state.status == F_number_negative || setting->state.status == F_number_positive || setting->state.status == F_number_overflow) {
valid_not = F_true;
- utf8_print_character_invalid(setting, main->output, hex);
+ utf8_print_data_character_invalid(setting, main->output, hex);
}
else {
setting->state.status = F_status_set_error(setting->state.status);
}
if (setting->mode & utf8_mode_to_bytesequence_e) {
- utf8_print_raw_bytesequence(setting, main->output, raw, width);
+ utf8_print_data_raw_bytesequence(setting, main->output, raw, width);
}
else if (setting->mode & utf8_mode_to_codepoint_e) {
- utf8_print_raw_codepoint(setting, main->output, setting->text);
+ utf8_print_data_raw_codepoint(setting, main->output, setting->text);
}
else {
- utf8_print_raw_combining_or_width(setting, main->output, width);
+ utf8_print_data_raw_combining_or_width(setting, main->output, width);
}
}
}
else if (*mode == utf8_codepoint_mode_bad_end_e) {
setting->state.status = F_none;
- utf8_print_character_invalid(setting, main->output, hex);
+ utf8_print_data_character_invalid(setting, main->output, hex);
}
else {
setting->state.status = F_none;
* @see f_utf_unicode_to()
*/
#ifndef _di_utf8_convert_codepoint_
- extern void utf8_convert_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) F_attribute_visibility_internal_d;
+ extern void utf8_convert_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode);
#endif // _di_utf8_convert_codepoint_
/**
* @see fl_conversion_dynamic_to_unsigned_detect()
*/
#ifndef _di_utf8_convert_raw_
- extern void utf8_convert_raw(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t hex, uint8_t *mode) F_attribute_visibility_internal_d;
+ extern void utf8_convert_raw(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t hex, uint8_t *mode);
#endif // _di_utf8_convert_raw_
/**
* Errors (with error bit) from: f_utf_is_whitespace()
*/
#ifndef _di_utf8_detect_codepoint_
- extern void utf8_detect_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode) F_attribute_visibility_internal_d;
+ extern void utf8_detect_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_string_static_t unicode, uint8_t *mode);
#endif // _di_utf8_detect_codepoint_
/**
* @see utf8_detect_codepoint()
*/
#ifndef _di_utf8_process_file_codepoint_
- extern void utf8_process_file_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file) F_attribute_visibility_internal_d;
+ extern void utf8_process_file_codepoint(fll_program_data_t * const main, utf8_setting_t * const setting, const f_file_t file);
#endif // _di_utf8_process_file_codepoint_
#ifdef __cplusplus
if (!main || !setting) return;
- setting->flag = 0;
-
f_console_parameter_process(arguments, &main->parameters, &setting->state, 0);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_process));
return;
setting->state.status = fll_program_parameter_process_context(choices, modes, F_true, main);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(fll_program_parameter_process_context));
return;
setting->state.status = fll_program_parameter_process_verbosity(choices, verbosity, F_true, main);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(fll_program_parameter_process_verbosity));
return;
setting->state.status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_prioritize_right));
return;
setting->state.status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(f_console_parameter_prioritize_right));
return;
setting->state.status = f_string_dynamics_increase_by(1, &setting->path_files_to);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamics_increase_by));
return;
setting->state.status = f_string_dynamic_append_nulless(main->parameters.arguments.array[main->parameters.array[utf8_parameter_to_file_e].values.array[0]], &setting->path_files_to.array[0]);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamic_append_nulless));
return;
setting->flag |= utf8_main_flag_file_to_e;
}
else {
- utf8_print_line_first_locked(setting, main->error);
+ utf8_print_line_first(setting, main->message);
utf8_print_error_parameter_file_name_empty(setting, main->error, main->parameters.array[utf8_parameter_to_file_e].values.array[0]);
setting->state.status = F_status_set_error(F_parameter);
else if (main->parameters.array[utf8_parameter_to_file_e].result & f_console_result_found_e) {
setting->state.status = F_status_set_error(F_parameter);
- utf8_print_line_first_locked(setting, main->error);
+ utf8_print_line_first(setting, main->message);
fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, utf8_long_to_file_s);
return;
setting->state.status = f_string_dynamics_increase_by(main->parameters.array[utf8_parameter_from_file_e].values.used, &setting->path_files_from);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamics_increase_by));
return;
setting->state.status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &setting->path_files_from.array[i]);
if (F_status_is_error(setting->state.status)) {
- utf8_print_line_first_locked(setting, main->error);
+ utf8_print_line_first(setting, main->message);
fll_error_print(main->error, F_status_set_fine(setting->state.status), macro_utf8_f(f_string_dynamic_append_nulless), fll_error_file_flag_fallback_e);
break;
else if (main->parameters.array[utf8_parameter_from_file_e].result & f_console_result_found_e) {
setting->state.status = F_status_set_error(F_parameter);
- utf8_print_line_first_locked(setting, main->error);
+ utf8_print_line_first(setting, main->message);
fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, utf8_long_from_file_s);
return;
setting->state.status = f_string_dynamics_increase_by(main->parameters.remaining.used, &setting->remaining);
if (F_status_is_error(setting->state.status)) {
+ utf8_print_line_first(setting, main->message);
utf8_print_error(setting, main->error, macro_utf8_f(f_string_dynamics_increase_by));
return;
if (!(main->parameters.array[utf8_parameter_from_file_e].result & f_console_result_found_e) && !((main->pipe & fll_program_data_pipe_input_e) || main->parameters.remaining.used)) {
setting->state.status = F_status_set_error(F_parameter);
- utf8_print_line_first_locked(setting, main->error);
+ utf8_print_line_first(setting, main->message);
utf8_print_error_no_from(setting, main->error);
return;
}
if (main->parameters.array[utf8_parameter_headers_e].result & f_console_result_found_e) {
- setting->flag |= utf8_main_flag_header_e;
+ if (main->parameters.array[utf8_parameter_separate_e].result & f_console_result_found_e) {
+ if (main->parameters.array[utf8_parameter_headers_e].location < main->parameters.array[utf8_parameter_separate_e].location) {
+ setting->flag |= utf8_main_flag_separate_e;
+ }
+ else if (main->parameters.array[utf8_parameter_headers_e].location == main->parameters.array[utf8_parameter_separate_e].location) {
+ if (main->parameters.array[utf8_parameter_headers_e].location_sub < main->parameters.array[utf8_parameter_separate_e].location_sub) {
+ setting->flag |= utf8_main_flag_separate_e;
+ }
+ else {
+ setting->flag |= utf8_main_flag_header_e;
+ }
+ }
+ else {
+ setting->flag |= utf8_main_flag_header_e;
+ }
+ }
+ else {
+ setting->flag |= utf8_main_flag_header_e;
+ }
}
-
- if (main->parameters.array[utf8_parameter_separate_e].result & f_console_result_found_e) {
+ else if (main->parameters.array[utf8_parameter_separate_e].result & f_console_result_found_e) {
setting->flag |= utf8_main_flag_separate_e;
}
-#include "utf8.h"
+#include "../utf8.h"
#ifdef __cplusplus
extern "C" {
-#include "utf8.h"
+#include "../utf8.h"
#ifdef __cplusplus
extern "C" {
-#include "utf8.h"
+#include "../utf8.h"
#ifdef __cplusplus
extern "C" {
* - header: Enable printing of headers.
* - help: Print help.
* - pipe: Use the input pipe.
+ * - print_first: When set, the first character printing logic is to be processed (this is usually automatic).
* - separate: Enable printing of separators.
* - strip_invalid: Using strip invalid character mode.
* - verify: Using verify mode.
utf8_main_flag_header_e = 0x8,
utf8_main_flag_help_e = 0x10,
utf8_main_flag_pipe_e = 0x20,
- utf8_main_flag_separate_e = 0x40,
- utf8_main_flag_strip_invalid_e = 0x80,
- utf8_main_flag_verify_e = 0x100,
- utf8_main_flag_version_e = 0x200,
+ utf8_main_flag_print_first_e = 0x40,
+ utf8_main_flag_separate_e = 0x80,
+ utf8_main_flag_strip_invalid_e = 0x100,
+ utf8_main_flag_verify_e = 0x200,
+ utf8_main_flag_version_e = 0x400,
}; // enum
#endif // _di_utf8_main_flag_e_
#define utf8_setting_t_initialize \
{ \
utf8_mode_from_bytesequence_e | utf8_mode_to_codepoint_e, \
- utf8_main_flag_none_e, \
+ utf8_main_flag_print_first_e, \
f_state_t_initialize, \
f_color_set_t_initialize, \
f_color_set_t_initialize, \
--- /dev/null
+#include "utf8.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_utf8_print_data_bytesequence_
+ f_status_t utf8_print_data_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) {
+
+ if (!setting) return F_output_not;
+
+ fl_print_format("%r%r%r", print.to, setting->prepend, sequence, setting->append);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_bytesequence_
+
+#ifndef _di_utf8_print_data_character_invalid_
+ f_status_t utf8_print_data_character_invalid(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid) {
+
+ if (!setting) return F_output_not;
+ if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
+ if (!invalid.used) return F_output_not;
+
+ if ((setting->mode & utf8_mode_to_combining_e) || (setting->mode & utf8_mode_to_width_e)) {
+ utf8_print_data_combining_or_width(setting, print, invalid);
+ }
+ else if (setting->mode & utf8_mode_to_bytesequence_e) {
+ fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, invalid, setting->valid_not, setting->append);
+ }
+ else if (setting->mode & utf8_mode_from_codepoint_e) {
+ fl_print_format("%r%[%Q%]%r", print.to, setting->prepend, setting->valid_not, invalid, setting->valid_not, setting->append);
+ }
+ else {
+ fl_print_format("%r%[0x", print.to, setting->prepend, setting->valid_not);
+
+ for (uint8_t i = 0; i < invalid.used; ++i) {
+ fl_print_format("%02_uii", print.to, (uint8_t) invalid.string[i]);
+ } // for
+
+ fl_print_format("%]%r", print.to, setting->valid_not, setting->append);
+ }
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_character_invalid_
+
+#ifndef _di_utf8_print_data_codepoint_
+ f_status_t utf8_print_data_codepoint(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint) {
+
+ if (!setting) return F_output_not;
+
+ if (codepoint < 0x10000) {
+ fl_print_format("%rU+%04_U%r", print.to, setting->prepend, codepoint, setting->append);
+ }
+ else if (codepoint < 0x100000) {
+ fl_print_format("%rU+%05_U%r", print.to, setting->prepend, codepoint, setting->append);
+ }
+ else {
+ fl_print_format("%rU+%06_U%r", print.to, setting->prepend, codepoint, setting->append);
+ }
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_codepoint_
+
+#ifndef _di_utf8_print_data_combining_or_width_
+ f_status_t utf8_print_data_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) {
+
+ if (!setting) return F_output_not;
+
+ if (setting->mode & utf8_mode_to_combining_e) {
+ f_status_t status = f_utf_is_combining(sequence.string, sequence.used);
+
+ if (status == F_true) {
+ fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_combining_is_s, setting->append);
+ }
+ else if (status == F_false) {
+ status = f_utf_is_private(sequence.string, sequence.used);
+
+ if (status == F_true) {
+ fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_unknown_s, setting->append);
+ }
+ else if (setting->mode & utf8_mode_to_width_e) {
+ utf8_print_data_width(setting, print, sequence);
+ }
+ else {
+ fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_combining_not_s, setting->append);
+ }
+ }
+ else {
+ utf8_print_data_combining_or_width_invalid(setting, print);
+ }
+ }
+ else if (setting->mode & utf8_mode_to_width_e) {
+ utf8_print_data_width(setting, print, sequence);
+ }
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_combining_or_width_
+
+#ifndef _di_utf8_print_data_combining_or_width_invalid_
+ f_status_t utf8_print_data_combining_or_width_invalid(utf8_setting_t * const setting, const fl_print_t print) {
+
+ if (!setting) return F_output_not;
+ if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
+
+ fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, utf8_string_unknown_s, setting->valid_not, setting->append);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_combining_or_width_invalid_
+
+#ifndef _di_utf8_print_data_raw_bytesequence_
+ f_status_t utf8_print_data_raw_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_utf_char_t raw, const uint8_t width) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
+
+ f_string_static_t character = macro_f_string_static_t_initialize(0, 0, width);
+
+ f_char_t byte[character.used + 1];
+ character.string = byte;
+ byte[character.used] = 0;
+
+ if (raw) {
+ if (width == 1) {
+ byte[0] = macro_f_utf_char_t_to_char_4_be(raw);
+ }
+ else if (width == 2) {
+ byte[0] = macro_f_utf_char_t_to_char_3_be(raw);
+ byte[1] = macro_f_utf_char_t_to_char_4_be(raw);
+ }
+ else if (width == 3) {
+ byte[0] = macro_f_utf_char_t_to_char_2_be(raw);
+ byte[1] = macro_f_utf_char_t_to_char_3_be(raw);
+ byte[2] = macro_f_utf_char_t_to_char_4_be(raw);
+ }
+ else {
+ byte[0] = macro_f_utf_char_t_to_char_1_be(raw);
+ byte[1] = macro_f_utf_char_t_to_char_2_be(raw);
+ byte[2] = macro_f_utf_char_t_to_char_3_be(raw);
+ byte[3] = macro_f_utf_char_t_to_char_4_be(raw);
+ }
+ }
+ else {
+ memset(byte, 0, sizeof(f_char_t) * width);
+ }
+
+ fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, character, setting->valid_not, setting->append);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_raw_bytesequence_
+
+#ifndef _di_utf8_print_data_raw_codepoint_
+ f_status_t utf8_print_data_raw_codepoint(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t raw) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
+
+ fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, raw, setting->valid_not, setting->append);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_raw_codepoint_
+
+#ifndef _di_utf8_print_data_raw_combining_or_width_
+ f_status_t utf8_print_data_raw_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const uint8_t width) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
+
+ if (setting->mode & utf8_mode_to_combining_e) {
+ utf8_print_data_combining_or_width_invalid(setting, print);
+ }
+ else if (setting->mode & utf8_mode_to_width_e) {
+ const f_string_static_t *character = 0;
+
+ switch (width) {
+ case 1:
+ character = &utf8_string_width_1_s;
+ break;
+
+ case 2:
+ character = &utf8_string_width_2_s;
+ break;
+
+ case 3:
+ character = &utf8_string_width_3_s;
+ break;
+
+ case 4:
+ character = &utf8_string_width_4_s;
+ break;
+
+ default:
+ character = &utf8_string_width_0_s;
+ }
+
+ fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, *character, setting->valid_not, setting->append);
+ }
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_raw_combining_or_width_
+
+#ifndef _di_utf8_print_data_section_header_file_
+ f_status_t utf8_print_data_section_header_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t name, const f_array_length_t index) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not;
+ if (setting->flag & utf8_main_flag_verify_e) return F_output_not;
+
+ f_file_stream_lock(print.to);
+
+ if (!setting->line_first.used || index) {
+ f_print_dynamic_raw(f_string_eol_s, print.to);
+ }
+
+ if (setting->flag & utf8_main_flag_header_e) {
+ fl_print_format("%[File%] ", print.to, print.set->title, print.set->title);
+
+ if (setting->flag & utf8_main_flag_file_to_e) {
+ fl_print_format("%[%Q%]: %Q.%r", print.to, print.set->notable, name, print.set->notable, setting->path_files_to.array[0], f_string_eol_s);
+ }
+ else {
+ fl_print_format("%[%Q%]:%r", print.to, print.set->notable, name, print.set->notable, f_string_eol_s);
+ }
+ }
+
+ f_file_stream_unlock(print.to);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_section_header_file_
+
+#ifndef _di_utf8_print_data_section_header_parameter_
+ f_status_t utf8_print_data_section_header_parameter(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not;
+ if (setting->flag & utf8_main_flag_verify_e) return F_output_not;
+
+ f_file_stream_lock(print.to);
+
+ if (setting->flag & utf8_main_flag_header_e) {
+ if ((setting->flag & (utf8_main_flag_pipe_e | utf8_main_flag_file_from_e)) || index) {
+ f_print_dynamic_raw(f_string_eol_s, print.to);
+ }
+
+ fl_print_format("%[Parameter%] ", print.to, print.set->title, print.set->title);
+ fl_print_format("%[%ul%]:%r", print.to, print.set->notable, index, print.set->notable, f_string_eol_s);
+ }
+ else {
+ if ((setting->flag & (utf8_main_flag_pipe_e | utf8_main_flag_file_from_e)) || index) {
+ f_print_dynamic_raw(f_string_eol_s, print.to);
+ }
+ }
+
+ f_file_stream_unlock(print.to);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_section_header_parameter_
+
+#ifndef _di_utf8_print_data_section_header_pipe_
+ f_status_t utf8_print_data_section_header_pipe(utf8_setting_t * const setting, const fl_print_t print) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not;
+ if (setting->flag & utf8_main_flag_verify_e) return F_output_not;
+
+ if (setting->flag & utf8_main_flag_header_e) {
+ fll_print_format("%[Pipe%]:%r", print.to, print.set->title, print.set->title, f_string_eol_s);
+ }
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_section_header_pipe_
+
+#ifndef _di_utf8_print_data_width_
+ f_status_t utf8_print_data_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ f_status_t status = f_utf_is_wide(sequence.string, sequence.used);
+
+ if (status == F_true) {
+ fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_width_2_s, setting->append);
+
+ return F_output_not;
+ }
+
+ if (status == F_false) {
+ status = f_utf_is_graph(sequence.string, sequence.used);
+
+ if (status == F_true) {
+ fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_width_1_s, setting->append);
+
+ return F_output_not;
+ }
+
+ if (status == F_false) {
+ fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_width_0_s, setting->append);
+
+ return F_output_not;
+ }
+ }
+
+ utf8_print_data_combining_or_width_invalid(setting, print);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_data_width_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: UTF8
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ */
+#ifndef _utf8_print_data_h
+#define _utf8_print_data_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Print the byte sequence character (such as '豸').
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ * @param sequence
+ * A byte sequences representing a single character to print.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_bytesequence_
+ extern f_status_t utf8_print_data_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence);
+#endif // _di_utf8_print_data_bytesequence_
+
+/**
+ * Print an invalid character either as a Unicode codeblock or as a byte sequence.
+ *
+ * This handles whether or not the invalid character should be printed or not based on program parameters.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ * @param invalid
+ * The byte sequence string or unicode codepoint string representing a single character to print.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see utf8_print_combining_or_width()
+ */
+#ifndef _di_utf8_print_data_character_invalid_
+ extern f_status_t utf8_print_data_character_invalid(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid);
+#endif // _di_utf8_print_data_character_invalid_
+
+/**
+ * Print the codepoint number as a codepoint string (such as U+8C78).
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ * @param codepoint
+ * The codepoint to print.
+ * This is the code that represents a single character.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_codepoint_
+ extern f_status_t utf8_print_data_codepoint(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint);
+#endif // _di_utf8_print_data_codepoint_
+
+/**
+ * Print the width or combining state of the given character.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ * @param sequence
+ * A byte sequences representing a single character to print.
+ *
+ * @see utf8_print_width()
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_combining_or_width_
+ extern f_status_t utf8_print_data_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence);
+#endif // _di_utf8_print_data_combining_or_width_
+
+/**
+ * Print an error regarding the width or combining state of a some character.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_combining_or_width_invalid_
+ extern f_status_t utf8_print_data_combining_or_width_invalid(utf8_setting_t * const setting, const fl_print_t print);
+#endif // _di_utf8_print_data_combining_or_width_invalid_
+
+/**
+ * Print the raw character data (binary / byte sequence).
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param raw
+ * The raw string in integer format.
+ * @param width
+ * The width the raw character represents (a value inclusively from 1 to 4).
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_raw_bytesequence_
+ extern f_status_t utf8_print_data_raw_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_utf_char_t raw, const uint8_t width);
+#endif // _di_utf8_print_data_raw_bytesequence_
+
+/**
+ * Print the raw character data (codepoint).
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param raw
+ * The raw string already in codepoint format.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_raw_codepoint_
+ extern f_status_t utf8_print_data_raw_codepoint(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t raw);
+#endif // _di_utf8_print_data_raw_codepoint_
+
+/**
+ * Print the width or combining state of the for a raw character.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param width
+ * The pre-calculated width.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see utf8_print_data_width()
+ */
+#ifndef _di_utf8_print_data_raw_combining_or_width_
+ extern f_status_t utf8_print_data_raw_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const uint8_t width);
+#endif // _di_utf8_print_data_raw_combining_or_width_
+
+/**
+ * Print the input file section header.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param name
+ * The name of the file.
+ * @param index
+ * The index position of the file.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_section_header_file_
+ extern f_status_t utf8_print_data_section_header_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t name, const f_array_length_t index);
+#endif // _di_utf8_print_data_section_header_file_
+
+/**
+ * Print the input parameter section header.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param index
+ * The index position of the parameter.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_section_header_parameter_
+ extern f_status_t utf8_print_data_section_header_parameter(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index);
+#endif // _di_utf8_print_data_section_header_parameter_
+
+/**
+ * Print the input pipe section header.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_section_header_pipe_
+ extern f_status_t utf8_print_data_section_header_pipe(utf8_setting_t * const setting, const fl_print_t print);
+#endif // _di_utf8_print_data_section_header_pipe_
+
+/**
+ * Print the width of the given character.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param sequence
+ * A byte sequences representing a single character whose width is to be printed.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_utf8_print_data_width_
+ extern f_status_t utf8_print_data_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence);
+#endif // _di_utf8_print_data_width_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _utf8_print_data_h
--- /dev/null
+#include "utf8.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_utf8_print_error_
+ f_status_t utf8_print_error(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_error_
+
+#ifndef _di_utf8_print_error_decode_
+ f_status_t utf8_print_error_decode(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+ if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
+
+ fl_print_format("%[%QFailed to decode character code '%]", print.to, print.set->error, print.prefix, print.set->error);
+
+ if (invalid.used) {
+ fl_print_format("%[0x", print.to, print.set->notable);
+
+ for (uint8_t i = 0; i < invalid.used; ++i) {
+ fl_print_format("%02_uii", print.to, (uint8_t) invalid.string[i]);
+ } // for
+
+ fl_print_format("%]", print.to, print.set->notable);
+ }
+
+ if (F_status_set_fine(setting->state.status) == F_utf_not) {
+ fl_print_format("%[', not a valid UTF-8 character sequence.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+ }
+ else if (F_status_set_fine(setting->state.status) == F_complete_not_utf) {
+ fl_print_format("%[', invalid UTF-8 (truncated).%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+ }
+ else if (F_status_set_fine(setting->state.status) == F_utf_fragment) {
+ fl_print_format("%[', invalid UTF-8 fragment.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+ }
+ else {
+ fl_print_format("%[', error status code%] ", print.to, print.set->error, print.set->error, f_string_eol_s);
+ fl_print_format("%[%ui%]", print.to, print.set->notable, F_status_set_fine(setting->state.status), print.set->notable);
+ fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+ }
+
+ return F_none;
+ }
+#endif // _di_utf8_print_error_decode_
+
+#ifndef _di_utf8_print_error_encode_
+ f_status_t utf8_print_error_encode(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+ if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
+
+ fl_print_format("%[%QFailed to encode Unicode codepoint '%]", print.to, print.set->error, print.prefix, print.set->error);
+ fl_print_format("%[U+%_U%]", print.to, print.set->notable, codepoint, print.set->notable);
+
+ if (F_status_set_fine(setting->state.status) == F_utf_not) {
+ fl_print_format("%[', not a valid Unicode codepoint.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+ }
+ else {
+ fl_print_format("%[', error status code%] ", print.to, print.set->error, print.set->error, f_string_eol_s);
+ fl_print_format("%[%ui%]", print.to, print.set->notable, F_status_set_fine(setting->state.status), print.set->notable);
+ fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+ }
+
+ return F_none;
+ }
+#endif // _di_utf8_print_error_encode_
+
+#ifndef _di_utf8_print_error_file_
+ f_status_t utf8_print_error_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_error_file_
+
+#ifndef _di_utf8_print_error_no_from_
+ f_status_t utf8_print_error_no_from(utf8_setting_t * const setting, const fl_print_t print) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ fll_print_format("%[%QNo from sources are specified, please pipe data, designate a file, or add parameters.%]%r", print.to, print.set->error, print.prefix, print.set->error, f_string_eol_s);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_error_no_from_
+
+#ifndef _di_utf8_print_error_parameter_file_name_empty_
+ f_status_t utf8_print_error_parameter_file_name_empty(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ f_file_stream_lock(print.to);
+
+ fl_print_format("%[%QNo file specified at parameter index%] ", print.to, print.set->error, print.prefix, print.set->error);
+ fl_print_format("%[%ul%]", print.to, print.set->notable, index, print.set->notable);
+ fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+
+ f_file_stream_unlock(print.to);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_error_parameter_file_name_empty_
+
+#ifndef _di_utf8_print_error_parameter_file_not_found_
+ f_status_t utf8_print_error_parameter_file_not_found(utf8_setting_t * const setting, const fl_print_t print, const bool from, const f_string_static_t name) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ f_file_stream_lock(print.to);
+
+ fl_print_format("%[%QFailed to find the %r file '%]", print.to, print.set->error, print.prefix, from ? utf8_string_from_s : utf8_string_to_s, print.set->error);
+ fl_print_format("%[%Q%]", print.to, print.set->notable, name, print.set->notable);
+ fl_print_format("%['.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
+
+ f_file_stream_unlock(print.to);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_error_parameter_file_not_found_
+
+#ifndef _di_utf8_print_error_parameter_file_to_too_many_
+ f_status_t utf8_print_error_parameter_file_to_too_many(utf8_setting_t * const setting, const fl_print_t print) {
+
+ if (!setting) return F_status_set_error(F_output_not);
+ if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ utf8_print_line_first(setting, print);
+
+ fll_print_format("%[%QToo many '%r' files specified, there may only be one '%r' file.%]%r", print.to, print.set->error, print.prefix, utf8_string_to_s, utf8_string_to_s, print.set->error, f_string_eol_s);
+
+ return F_none;
+ }
+#endif // _di_utf8_print_error_parameter_file_to_too_many_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: UTF8
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ */
+#ifndef _utf8_print_error_h
+#define _utf8_print_error_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Print generic error message regarding a function failing in some way.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_error_print()
+ */
+#ifndef _di_utf8_print_error_
+ extern f_status_t utf8_print_error(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function);
+#endif // _di_utf8_print_error_
+
+/**
+ * Print error message when attempt to decode the character failed.
+ *
+ * @param main
+ * The main program data.
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param invalid
+ * The byte sequence string or unicode codepoint string representing a single character to print.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fl_print_format()
+ */
+#ifndef _di_utf8_print_error_decode_
+ extern f_status_t utf8_print_error_decode(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid);
+#endif // _di_utf8_print_error_decode_
+
+/**
+ * Print error message when attempt to encode the character failed.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates the how and where to print.
+ * @param codepoint
+ * The codepoint that is invalid.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fl_print_format()
+ */
+#ifndef _di_utf8_print_error_encode_
+ extern f_status_t utf8_print_error_encode(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint);
+#endif // _di_utf8_print_error_encode_
+
+/**
+ * Print file related error or warning messages.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ * @param function
+ * The name of the function where the error happened.
+ * Set to 0 to disable.
+ * @param name
+ * The name of the file or directory.
+ * @param operation
+ * The operation that fails, such as 'create' or 'access'.
+ * @param type
+ * A valid file type code from the fll_error_file_type enum.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_error_file_print()
+ */
+#ifndef _di_utf8_print_error_file_
+ extern f_status_t utf8_print_error_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type);
+#endif // _di_utf8_print_error_file_
+
+/**
+ * Print error message for when no sources are provided.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_error_file_print()
+ */
+#ifndef _di_utf8_print_error_no_from_
+ extern f_status_t utf8_print_error_no_from(utf8_setting_t * const setting, const fl_print_t print);
+#endif // _di_utf8_print_error_no_from_
+
+/**
+ * Print error message for when the file parameter is an empty string.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ * @param index
+ * The index within the argv[] array where the empty string is found.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see fl_print_format()
+ */
+#ifndef _di_utf8_print_error_parameter_file_name_empty_
+ extern f_status_t utf8_print_error_parameter_file_name_empty(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index);
+#endif // _di_utf8_print_error_parameter_file_name_empty_
+
+/**
+ * Print error message for when no sources are provided in the main program parameters.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ * @param from
+ * If TRUE, then this is a from file (source file).
+ * If FALSE, then this is a to file (destination file).
+ * @param name
+ * The file path name.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see fl_print_format()
+ */
+#ifndef _di_utf8_print_error_parameter_file_not_found_
+ extern f_status_t utf8_print_error_parameter_file_not_found(utf8_setting_t * const setting, const fl_print_t print, const bool from, const f_string_static_t name);
+#endif // _di_utf8_print_error_parameter_file_not_found_
+
+/**
+ * Print error message for when too many 'to' destinations are specified.
+ *
+ * @param setting
+ * The main program settings.
+ *
+ * This does not alter setting.state.status.
+ * @param print
+ * Designates how printing is to be performed.
+ *
+ * @return
+ * F_none on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_print_format()
+ *
+ * @see utf8_print_line_first()
+ */
+#ifndef _di_utf8_print_error_parameter_file_to_too_many_
+ extern f_status_t utf8_print_error_parameter_file_to_too_many(utf8_setting_t * const setting, const fl_print_t print);
+#endif // _di_utf8_print_error_parameter_file_to_too_many_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _utf8_print_error_h
extern "C" {
#endif
-#ifndef _di_utf8_print_error_
- f_status_t utf8_print_error(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- utf8_print_line_first_locked(setting, print);
- fll_error_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e);
-
- return F_none;
- }
-#endif // _di_utf8_print_error_
-
-#ifndef _di_utf8_print_error_decode_
- f_status_t utf8_print_error_decode(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
- if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
-
- utf8_print_line_first_unlocked(setting, print);
-
- fl_print_format("%[%QFailed to decode character code '%]", print.to, print.set->error, print.prefix, print.set->error);
-
- if (invalid.used) {
- fl_print_format("%[0x", print.to, print.set->notable);
-
- for (uint8_t i = 0; i < invalid.used; ++i) {
- fl_print_format("%02_uii", print.to, (uint8_t) invalid.string[i]);
- } // for
-
- fl_print_format("%]", print.to, print.set->notable);
- }
-
- if (F_status_set_fine(setting->state.status) == F_utf_not) {
- fl_print_format("%[', not a valid UTF-8 character sequence.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
- }
- else if (F_status_set_fine(setting->state.status) == F_complete_not_utf) {
- fl_print_format("%[', invalid UTF-8 (truncated).%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
- }
- else if (F_status_set_fine(setting->state.status) == F_utf_fragment) {
- fl_print_format("%[', invalid UTF-8 fragment.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
- }
- else {
- fl_print_format("%[', error status code%] ", print.to, print.set->error, print.set->error, f_string_eol_s);
- fl_print_format("%[%ui%]", print.to, print.set->notable, F_status_set_fine(setting->state.status), print.set->notable);
- fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
- }
-
- return F_none;
- }
-#endif // _di_utf8_print_error_decode_
-
-#ifndef _di_utf8_print_error_encode_
- f_status_t utf8_print_error_encode(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- utf8_print_line_first_unlocked(setting, print);
-
- fl_print_format("%[%QFailed to encode Unicode codepoint '%]", print.to, print.set->error, print.prefix, print.set->error);
- fl_print_format("%[U+%_U%]", print.to, print.set->notable, codepoint, print.set->notable);
-
- if (F_status_set_fine(setting->state.status) == F_utf_not) {
- fl_print_format("%[', not a valid Unicode codepoint.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
- }
- else {
- fl_print_format("%[', error status code%] ", print.to, print.set->error, print.set->error, f_string_eol_s);
- fl_print_format("%[%ui%]", print.to, print.set->notable, F_status_set_fine(setting->state.status), print.set->notable);
- fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
- }
-
- return F_none;
- }
-#endif // _di_utf8_print_error_encode_
-
-#ifndef _di_utf8_print_error_file_
- f_status_t utf8_print_error_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- utf8_print_line_first_locked(setting, print);
- fll_error_file_print(print, F_status_set_fine(setting->state.status), function, fll_error_file_flag_fallback_e, name, operation, type);
-
- return F_none;
- }
-#endif // _di_utf8_print_error_file_
-
-#ifndef _di_utf8_print_error_no_from_
- f_status_t utf8_print_error_no_from(utf8_setting_t * const setting, const fl_print_t print) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- fll_print_format("%[%QNo from sources are specified, please pipe data, designate a file, or add parameters.%]%r", print.to, print.set->error, print.prefix, print.set->error, f_string_eol_s);
-
- return F_none;
- }
-#endif // _di_utf8_print_error_no_from_
-
-#ifndef _di_utf8_print_error_parameter_file_name_empty_
- f_status_t utf8_print_error_parameter_file_name_empty(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print.to);
-
- utf8_print_line_first_unlocked(setting, print);
-
- fl_print_format("%[%QNo file specified at parameter index%] ", print.to, print.set->error, print.prefix, print.set->error);
- fl_print_format("%[%ul%]", print.to, print.set->notable, index, print.set->notable);
- fl_print_format("%[.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
-
- f_file_stream_unlock(print.to);
-
- return F_none;
- }
-#endif // _di_utf8_print_error_parameter_file_name_empty_
-
-#ifndef _di_utf8_print_error_parameter_file_not_found_
- f_status_t utf8_print_error_parameter_file_not_found(utf8_setting_t * const setting, const fl_print_t print, const bool from, const f_string_static_t name) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print.to);
-
- utf8_print_line_first_unlocked(setting, print);
-
- fl_print_format("%[%QFailed to find the %r file '%]", print.to, print.set->error, print.prefix, from ? utf8_string_from_s : utf8_string_to_s, print.set->error);
- fl_print_format("%[%Q%]", print.to, print.set->notable, name, print.set->notable);
- fl_print_format("%['.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s);
-
- f_file_stream_unlock(print.to);
-
- return F_none;
- }
-#endif // _di_utf8_print_error_parameter_file_not_found_
-
-#ifndef _di_utf8_print_error_parameter_file_to_too_many_
- f_status_t utf8_print_error_parameter_file_to_too_many(utf8_setting_t * const setting, const fl_print_t print) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- utf8_print_line_first_locked(setting, print);
-
- fll_print_format("%[%QToo many '%r' files specified, there may only be one '%r' file.%]%r", print.to, print.set->error, print.prefix, utf8_string_to_s, utf8_string_to_s, print.set->error, f_string_eol_s);
-
- return F_none;
- }
-#endif // _di_utf8_print_error_parameter_file_to_too_many_
-
-#ifndef _di_utf8_print_bytesequence_
- f_status_t utf8_print_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) {
-
- if (!setting) return F_output_not;
-
- fl_print_format("%r%r%r", print.to, setting->prepend, sequence, setting->append);
-
- return F_none;
- }
-#endif // _di_utf8_print_bytesequence_
-
-#ifndef _di_utf8_print_character_invalid_
- f_status_t utf8_print_character_invalid(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid) {
-
- if (!setting) return F_output_not;
- if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
- if (!invalid.used) return F_output_not;
-
- if ((setting->mode & utf8_mode_to_combining_e) || (setting->mode & utf8_mode_to_width_e)) {
- utf8_print_combining_or_width(setting, print, invalid);
- }
- else if (setting->mode & utf8_mode_to_bytesequence_e) {
- fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, invalid, setting->valid_not, setting->append);
- }
- else if (setting->mode & utf8_mode_from_codepoint_e) {
- fl_print_format("%r%[%Q%]%r", print.to, setting->prepend, setting->valid_not, invalid, setting->valid_not, setting->append);
- }
- else {
- fl_print_format("%r%[0x", print.to, setting->prepend, setting->valid_not);
-
- for (uint8_t i = 0; i < invalid.used; ++i) {
- fl_print_format("%02_uii", print.to, (uint8_t) invalid.string[i]);
- } // for
-
- fl_print_format("%]%r", print.to, setting->valid_not, setting->append);
- }
-
- return F_none;
- }
-#endif // _di_utf8_print_character_invalid_
-
-#ifndef _di_utf8_print_codepoint_
- f_status_t utf8_print_codepoint(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint) {
-
- if (!setting) return F_output_not;
-
- if (codepoint < 0x10000) {
- fl_print_format("%rU+%04_U%r", print.to, setting->prepend, codepoint, setting->append);
- }
- else if (codepoint < 0x100000) {
- fl_print_format("%rU+%05_U%r", print.to, setting->prepend, codepoint, setting->append);
- }
- else {
- fl_print_format("%rU+%06_U%r", print.to, setting->prepend, codepoint, setting->append);
- }
-
- return F_none;
- }
-#endif // _di_utf8_print_codepoint_
-
-#ifndef _di_utf8_print_combining_or_width_
- f_status_t utf8_print_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) {
-
- if (!setting) return F_output_not;
-
- if (setting->mode & utf8_mode_to_combining_e) {
- f_status_t status = f_utf_is_combining(sequence.string, sequence.used);
-
- if (status == F_true) {
- fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_combining_is_s, setting->append);
- }
- else if (status == F_false) {
- status = f_utf_is_private(sequence.string, sequence.used);
-
- if (status == F_true) {
- fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_unknown_s, setting->append);
- }
- else if (setting->mode & utf8_mode_to_width_e) {
- utf8_print_width(setting, print, sequence);
- }
- else {
- fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_combining_not_s, setting->append);
- }
- }
- else {
- utf8_print_combining_or_width_invalid(setting, print);
- }
- }
- else if (setting->mode & utf8_mode_to_width_e) {
- utf8_print_width(setting, print, sequence);
- }
-
- return F_none;
- }
-#endif // _di_utf8_print_combining_or_width_
-
-#ifndef _di_utf8_print_combining_or_width_invalid_
- f_status_t utf8_print_combining_or_width_invalid(utf8_setting_t * const setting, const fl_print_t print) {
-
- if (!setting) return F_output_not;
- if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
-
- fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, utf8_string_unknown_s, setting->valid_not, setting->append);
-
- return F_none;
- }
-#endif // _di_utf8_print_combining_or_width_invalid_
-
#ifndef _di_utf8_print_help_
f_status_t utf8_print_help(utf8_setting_t * const setting, const fl_print_t print) {
}
#endif // _di_utf8_print_help_
-#ifndef _di_utf8_print_line_first_locked_
- f_status_t utf8_print_line_first_locked(utf8_setting_t * const setting, const fl_print_t print) {
+#ifndef _di_utf8_print_line_first_
+ f_status_t utf8_print_line_first(utf8_setting_t * const setting, const fl_print_t print) {
if (!setting) return F_status_set_error(F_output_not);
if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
- if (F_status_is_error_not(setting->state.status)) {
- if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
- if (setting->flag & (utf8_main_flag_verify_e | utf8_main_flag_file_to_e)) return F_output_not;
- }
-
- f_print_dynamic_raw(setting->line_first, print.to);
+ if (setting->flag & utf8_main_flag_print_first_e) {
+ fll_print_dynamic_raw(setting->line_first, print.to);
- return F_none;
- }
-#endif // _di_utf8_print_line_first_locked_
-
-#ifndef _di_utf8_print_line_first_unlocked_
- f_status_t utf8_print_line_first_unlocked(utf8_setting_t * const setting, const fl_print_t print) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- if (F_status_is_error_not(setting->state.status)) {
- if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
- if (setting->flag & (utf8_main_flag_verify_e | utf8_main_flag_file_to_e)) return F_output_not;
+ setting->flag -= utf8_main_flag_print_first_e;
}
- fll_print_dynamic_raw(setting->line_first, print.to);
-
return F_none;
}
-#endif // _di_utf8_print_line_first_unlocked_
+#endif // _di_utf8_print_line_first_
-#ifndef _di_utf8_print_line_last_locked_
- f_status_t utf8_print_line_last_locked(utf8_setting_t * const setting, const fl_print_t print) {
+#ifndef _di_utf8_print_line_last_
+ f_status_t utf8_print_line_last(utf8_setting_t * const setting, const fl_print_t print) {
if (!setting) return F_status_set_error(F_output_not);
if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
fll_print_dynamic_raw(setting->line_last, print.to);
- // Two lines are printed because the normal final end of line is never printed by design.
- // If this is an error or the header flag is set, then the normal end of line is printed by design so do not print this second new line.
- if (F_status_is_error_not(setting->state.status) && !(setting->flag & utf8_main_flag_header_e)) {
- fll_print_dynamic_raw(setting->line_last, print.to);
- }
-
- return F_none;
- }
-#endif // _di_utf8_print_line_last_locked_
-
-#ifndef _di_utf8_print_line_last_unlocked_
- f_status_t utf8_print_line_last_unlocked(utf8_setting_t * const setting, const fl_print_t print) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- if (F_status_is_error_not(setting->state.status)) {
- if (print.verbosity < f_console_verbosity_normal_e) return F_output_not;
- if (setting->flag & (utf8_main_flag_verify_e | utf8_main_flag_file_to_e)) return F_output_not;
- }
-
- f_print_dynamic_raw(setting->line_last, print.to);
-
- return F_none;
- }
-#endif // _di_utf8_print_line_last_unlocked_
-
-#ifndef _di_utf8_print_raw_bytesequence_
- f_status_t utf8_print_raw_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_utf_char_t raw, const uint8_t width) {
-
- if (!setting) return F_output_not;
- if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
-
- f_string_static_t character = macro_f_string_static_t_initialize(0, 0, width);
-
- f_char_t byte[character.used + 1];
- character.string = byte;
- byte[character.used] = 0;
-
- if (raw) {
- if (width == 1) {
- byte[0] = macro_f_utf_char_t_to_char_4_be(raw);
- }
- else if (width == 2) {
- byte[0] = macro_f_utf_char_t_to_char_3_be(raw);
- byte[1] = macro_f_utf_char_t_to_char_4_be(raw);
- }
- else if (width == 3) {
- byte[0] = macro_f_utf_char_t_to_char_2_be(raw);
- byte[1] = macro_f_utf_char_t_to_char_3_be(raw);
- byte[2] = macro_f_utf_char_t_to_char_4_be(raw);
- }
- else {
- byte[0] = macro_f_utf_char_t_to_char_1_be(raw);
- byte[1] = macro_f_utf_char_t_to_char_2_be(raw);
- byte[2] = macro_f_utf_char_t_to_char_3_be(raw);
- byte[3] = macro_f_utf_char_t_to_char_4_be(raw);
- }
- }
- else {
- memset(byte, 0, sizeof(f_char_t) * width);
- }
-
- fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, character, setting->valid_not, setting->append);
-
- return F_none;
- }
-#endif // _di_utf8_print_raw_bytesequence_
-
-#ifndef _di_utf8_print_raw_codepoint_
- f_status_t utf8_print_raw_codepoint(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t raw) {
-
- if (!setting) return F_output_not;
- if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
-
- fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, raw, setting->valid_not, setting->append);
-
- return F_none;
- }
-#endif // _di_utf8_print_raw_codepoint_
-
-#ifndef _di_utf8_print_raw_combining_or_width_
- f_status_t utf8_print_raw_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const uint8_t width) {
-
- if (!setting) return F_output_not;
- if (setting->flag & (utf8_main_flag_strip_invalid_e | utf8_main_flag_verify_e)) return F_output_not;
-
- if (setting->mode & utf8_mode_to_combining_e) {
- utf8_print_combining_or_width_invalid(setting, print);
- }
- else if (setting->mode & utf8_mode_to_width_e) {
- const f_string_static_t *character = 0;
-
- switch (width) {
- case 1:
- character = &utf8_string_width_1_s;
- break;
-
- case 2:
- character = &utf8_string_width_2_s;
- break;
-
- case 3:
- character = &utf8_string_width_3_s;
- break;
-
- case 4:
- character = &utf8_string_width_4_s;
- break;
-
- default:
- character = &utf8_string_width_0_s;
- }
-
- fl_print_format("%r%[%r%]%r", print.to, setting->prepend, setting->valid_not, *character, setting->valid_not, setting->append);
- }
-
- return F_none;
- }
-#endif // _di_utf8_print_raw_combining_or_width_
-
-#ifndef _di_utf8_print_section_header_file_
- f_status_t utf8_print_section_header_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t name, const f_array_length_t index) {
-
- if (!setting) return F_output_not;
- if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not;
- if (setting->flag & utf8_main_flag_verify_e) return F_output_not;
-
- f_file_stream_lock(print.to);
-
-
- if ((setting->flag & utf8_main_flag_pipe_e) || index) {
- f_print_dynamic_raw(f_string_eol_s, print.to);
- }
- else {
- f_print_dynamic_raw(setting->line_first, print.to);
- }
-
- if (setting->flag & utf8_main_flag_header_e) {
- fl_print_format("%[File%] ", print.to, print.set->title, print.set->title);
-
- if (setting->flag & utf8_main_flag_file_to_e) {
- fl_print_format("%[%Q%]: %Q.%r", print.to, print.set->notable, name, print.set->notable, setting->path_files_to.array[0], f_string_eol_s);
- }
- else {
- fl_print_format("%[%Q%]:%r", print.to, print.set->notable, name, print.set->notable, f_string_eol_s);
- }
- }
-
- f_file_stream_unlock(print.to);
-
- return F_none;
- }
-#endif // _di_utf8_print_section_header_file_
-
-#ifndef _di_utf8_print_section_header_parameter_
- f_status_t utf8_print_section_header_parameter(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index) {
-
- if (!setting) return F_output_not;
- if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not;
- if (setting->flag & utf8_main_flag_verify_e) return F_output_not;
-
- f_file_stream_lock(print.to);
-
- if ((setting->flag & utf8_main_flag_pipe_e) || (setting->flag & utf8_main_flag_file_from_e) || index) {
- f_print_dynamic_raw(f_string_eol_s, print.to);
- }
- else {
- f_print_dynamic_raw(setting->line_first, print.to);
- }
-
- if (setting->flag & utf8_main_flag_header_e) {
- fl_print_format("%[Parameter%] ", print.to, print.set->title, print.set->title);
- fl_print_format("%[%ul%]:%r", print.to, print.set->notable, index, print.set->notable, f_string_eol_s);
- }
-
- f_file_stream_unlock(print.to);
-
- return F_none;
- }
-#endif // _di_utf8_print_section_header_parameter_
-
-#ifndef _di_utf8_print_section_header_pipe_
- f_status_t utf8_print_section_header_pipe(utf8_setting_t * const setting, const fl_print_t print) {
-
- if (!setting) return F_output_not;
- if (!(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) return F_output_not;
- if (setting->flag & utf8_main_flag_verify_e) return F_output_not;
-
- f_file_stream_lock(print.to);
-
- f_print_dynamic_raw(setting->line_first, print.to);
-
- if (setting->flag & utf8_main_flag_header_e) {
- fl_print_format("%[Pipe%]:%r", print.to, print.set->title, print.set->title, f_string_eol_s);
- }
-
- f_file_stream_unlock(print.to);
-
- return F_none;
- }
-#endif // _di_utf8_print_section_header_pipe_
-
-#ifndef _di_utf8_print_width_
- f_status_t utf8_print_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence) {
-
- if (!setting) return F_status_set_error(F_output_not);
- if (print.verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_status_t status = f_utf_is_wide(sequence.string, sequence.used);
-
- if (status == F_true) {
- fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_width_2_s, setting->append);
-
- return F_output_not;
- }
-
- if (status == F_false) {
- status = f_utf_is_graph(sequence.string, sequence.used);
-
- if (status == F_true) {
- fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_width_1_s, setting->append);
-
- return F_output_not;
- }
-
- if (status == F_false) {
- fl_print_format("%r%r%r", print.to, setting->prepend, utf8_string_width_0_s, setting->append);
-
- return F_output_not;
- }
- }
-
- utf8_print_combining_or_width_invalid(setting, print);
-
return F_none;
}
-#endif // _di_utf8_print_width_
+#endif // _di_utf8_print_line_last_
#ifdef __cplusplus
} // extern "C"
#endif
/**
- * Print generic error message regarding a function failing in some way.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see fll_error_print()
- */
-#ifndef _di_utf8_print_error_
- extern f_status_t utf8_print_error(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function);
-#endif // _di_utf8_print_error_
-
-/**
- * Print error message when attempt to decode the character failed.
- *
- * @param main
- * The main program data.
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param invalid
- * The byte sequence string or unicode codepoint string representing a single character to print.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_error_decode_
- extern f_status_t utf8_print_error_decode(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid);
-#endif // _di_utf8_print_error_decode_
-
-/**
- * Print error message when attempt to encode the character failed.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- * @param codepoint
- * The codepoint that is invalid.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_error_encode_
- extern f_status_t utf8_print_error_encode(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint);
-#endif // _di_utf8_print_error_encode_
-
-/**
- * Print file related error or warning messages.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- * @param function
- * The name of the function where the error happened.
- * Set to 0 to disable.
- * @param name
- * The name of the file or directory.
- * @param operation
- * The operation that fails, such as 'create' or 'access'.
- * @param type
- * A valid file type code from the fll_error_file_type enum.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see fll_error_file_print()
- */
-#ifndef _di_utf8_print_error_file_
- extern f_status_t utf8_print_error_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type);
-#endif // _di_utf8_print_error_file_
-
-/**
- * Print error message for when no sources are provided.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_error_no_from_
- extern f_status_t utf8_print_error_no_from(utf8_setting_t * const setting, const fl_print_t print);
-#endif // _di_utf8_print_error_no_from_
-
-/**
- * Print error message for when the file parameter is an empty string.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- * @param index
- * The index within the argv[] array where the empty string is found.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_error_parameter_file_name_empty_
- extern f_status_t utf8_print_error_parameter_file_name_empty(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index);
-#endif // _di_utf8_print_error_parameter_file_name_empty_
-
-/**
- * Print error message for when no sources are provided in the main program parameters.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- * @param from
- * If TRUE, then this is a from file (source file).
- * If FALSE, then this is a to file (destination file).
- * @param name
- * The file path name.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_error_parameter_file_not_found_
- extern f_status_t utf8_print_error_parameter_file_not_found(utf8_setting_t * const setting, const fl_print_t print, const bool from, const f_string_static_t name);
-#endif // _di_utf8_print_error_parameter_file_not_found_
-
-/**
- * Print error message for when too many 'to' destinations are specified.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_error_parameter_file_to_too_many_
- extern f_status_t utf8_print_error_parameter_file_to_too_many(utf8_setting_t * const setting, const fl_print_t print);
-#endif // _di_utf8_print_error_parameter_file_to_too_many_
-
-/**
- * Print the byte sequence character (such as '豸').
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- * @param sequence
- * A byte sequences representing a single character to print.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_bytesequence_
- extern f_status_t utf8_print_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence);
-#endif // _di_utf8_print_bytesequence_
-
-/**
- * Print an invalid character either as a Unicode codeblock or as a byte sequence.
- *
- * This handles whether or not the invalid character should be printed or not based on program parameters.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- * @param invalid
- * The byte sequence string or unicode codepoint string representing a single character to print.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see utf8_print_combining_or_width()
- */
-#ifndef _di_utf8_print_character_invalid_
- extern f_status_t utf8_print_character_invalid(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t invalid);
-#endif // _di_utf8_print_character_invalid_
-
-/**
- * Print the codepoint number as a codepoint string (such as U+8C78).
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- * @param codepoint
- * The codepoint to print.
- * This is the code that represents a single character.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_codepoint_
- extern f_status_t utf8_print_codepoint(utf8_setting_t * const setting, const fl_print_t print, const uint32_t codepoint);
-#endif // _di_utf8_print_codepoint_
-
-/**
- * Print the width or combining state of the given character.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- * @param sequence
- * A byte sequences representing a single character to print.
- *
- * @see utf8_print_width()
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_combining_or_width_
- extern f_status_t utf8_print_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence);
-#endif // _di_utf8_print_combining_or_width_
-
-/**
- * Print an error regarding the width or combining state of a some character.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates how printing is to be performed.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_combining_or_width_invalid_
- extern f_status_t utf8_print_combining_or_width_invalid(utf8_setting_t * const setting, const fl_print_t print);
-#endif // _di_utf8_print_combining_or_width_invalid_
-
-/**
* Print help.
*
* @param setting
* F_output_not on success, but no printing is performed.
*
* F_output_not (with error bit) if setting is NULL.
+ *
+ * @see f_file_stream_flush()
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see f_print_dynamic_raw()
+ * @see fl_print_format()
+ *
+ * @see fll_program_print_help_header()
+ * @see fll_program_print_help_option()
+ * @see fll_program_print_help_option_standard()
+ * @see fll_program_print_help_usage()
*/
#ifndef _di_utf8_print_help_
extern f_status_t utf8_print_help(utf8_setting_t * const setting, const fl_print_t print);
* F_output_not on success, but no printing is performed.
*
* F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_line_first_locked_
- extern f_status_t utf8_print_line_first_locked(utf8_setting_t * const setting, const fl_print_t print);
-#endif // _di_utf8_print_line_first_locked_
-
-/**
- * Print first new line, unless verbosity says otherwise.
- *
- * This is generally either the first line in the program or the first line printed before an error message.
- *
- * This function neither locks nor unlocks the input stream.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
*
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
+ * @see fll_print_dynamic_raw()
*/
-#ifndef _di_utf8_print_line_first_unlocked_
- extern f_status_t utf8_print_line_first_unlocked(utf8_setting_t * const setting, const fl_print_t print);
-#endif // _di_utf8_print_line_first_unlocked_
+#ifndef _di_utf8_print_line_first_
+ extern f_status_t utf8_print_line_first(utf8_setting_t * const setting, const fl_print_t print);
+#endif // _di_utf8_print_line_first_
/**
* Print last new line when the main is complete, unless verbosity says otherwise.
* F_output_not on success, but no printing is performed.
*
* F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_line_last_locked_
- extern f_status_t utf8_print_line_last_locked(utf8_setting_t * const setting, const fl_print_t print);
-#endif // _di_utf8_print_line_last_locked_
-
-/**
- * Print last new line when the main is complete, unless verbosity says otherwise.
- *
- * This is generally the very last line printed in the program.
- *
- * This function neither locks nor unlocks the input stream.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_line_last_unlocked_
- extern f_status_t utf8_print_line_last_unlocked(utf8_setting_t * const setting, const fl_print_t print);
-#endif // _di_utf8_print_line_last_unlocked_
-
-/**
- * Print the raw character data (binary / byte sequence).
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- * @param raw
- * The raw string in integer format.
- * @param width
- * The width the raw character represents (a value inclusively from 1 to 4).
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_raw_bytesequence_
- extern f_status_t utf8_print_raw_bytesequence(utf8_setting_t * const setting, const fl_print_t print, const f_utf_char_t raw, const uint8_t width);
-#endif // _di_utf8_print_raw_bytesequence_
-
-/**
- * Print the raw character data (codepoint).
*
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- * @param raw
- * The raw string already in codepoint format.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_raw_codepoint_
- extern f_status_t utf8_print_raw_codepoint(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t raw);
-#endif // _di_utf8_print_raw_codepoint_
-
-/**
- * Print the width or combining state of the for a raw character.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- * @param width
- * The pre-calculated width.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see utf8_print_width()
- */
-#ifndef _di_utf8_print_raw_combining_or_width_
- extern f_status_t utf8_print_raw_combining_or_width(utf8_setting_t * const setting, const fl_print_t print, const uint8_t width);
-#endif // _di_utf8_print_raw_combining_or_width_
-
-/**
- * Print the input file section header.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- * @param name
- * The name of the file.
- * @param index
- * The index position of the file.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_section_header_file_
- extern f_status_t utf8_print_section_header_file(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t name, const f_array_length_t index);
-#endif // _di_utf8_print_section_header_file_
-
-/**
- * Print the input parameter section header.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- * @param index
- * The index position of the parameter.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_section_header_parameter_
- extern f_status_t utf8_print_section_header_parameter(utf8_setting_t * const setting, const fl_print_t print, const f_array_length_t index);
-#endif // _di_utf8_print_section_header_parameter_
-
-/**
- * Print the input pipe section header.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- */
-#ifndef _di_utf8_print_section_header_pipe_
- extern f_status_t utf8_print_section_header_pipe(utf8_setting_t * const setting, const fl_print_t print);
-#endif // _di_utf8_print_section_header_pipe_
-
-/**
- * Print the width of the given character.
- *
- * @param setting
- * The main program settings.
- *
- * This does not alter setting.state.status.
- * @param print
- * Designates the how and where to print.
- * @param sequence
- * A byte sequences representing a single character whose width is to be printed.
- *
- * @return
- * F_none on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
+ * @see fll_print_dynamic_raw()
*/
-#ifndef _di_utf8_print_width_
- extern f_status_t utf8_print_width(utf8_setting_t * const setting, const fl_print_t print, const f_string_static_t sequence);
-#endif // _di_utf8_print_width_
+#ifndef _di_utf8_print_line_last_
+ extern f_status_t utf8_print_line_last(utf8_setting_t * const setting, const fl_print_t print);
+#endif // _di_utf8_print_line_last_
#ifdef __cplusplus
} // extern "C"
+++ /dev/null
-#include "utf8.h"
-#include "private-common.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 3
- *
- * Project: UTF8
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- */
-#ifndef _PRIVATE_common_h
-#define _PRIVATE_common_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _PRIVATE_common_h
utf8_detect_codepoint(main, setting, text, &mode_codepoint);
if (F_status_is_error(setting->state.status)) {
- utf8_print_line_first_locked(setting, main->error);
fll_error_print(main->error, F_status_set_fine(setting->state.status), macro_utf8_f(utf8_detect_codepoint), fll_error_file_flag_fallback_e);
break;
if (!main || !setting) return;
if (F_status_is_error(setting->state.status)) {
- utf8_print_line_last_locked(setting, main->error);
+ utf8_print_line_last(setting, main->message);
return;
}
return;
}
- if (!(setting->flag & utf8_main_flag_header_e)) {
- utf8_print_line_first_locked(setting, main->message);
- }
+ utf8_print_line_first(setting, main->message);
f_status_t valid = F_true;
if (main->pipe & fll_program_data_pipe_input_e) {
const f_file_t file = macro_f_file_t_initialize(F_type_input_d, F_type_descriptor_input_d, F_file_flag_read_only_d, 32768, F_file_default_write_size_d);
- utf8_print_section_header_pipe(setting, main->output);
+ utf8_print_data_section_header_pipe(setting, main->output);
if (setting->mode & utf8_mode_from_bytesequence_e) {
utf8_process_file_bytesequence(main, setting, file);
main->signal_check = 0;
}
- utf8_print_section_header_file(setting, main->output, setting->path_files_from.array[i], i);
+ utf8_print_data_section_header_file(setting, main->output, setting->path_files_from.array[i], i);
setting->state.status = f_file_stream_open(setting->path_files_from.array[i], f_string_empty_s, &file);
main->signal_check = 0;
}
- utf8_print_section_header_parameter(setting, main->output, main->parameters.remaining.array[i]);
+ utf8_print_data_section_header_parameter(setting, main->output, i);
utf8_process_text(main, setting, main->parameters.arguments.array[main->parameters.remaining.array[i]]);
} // for
}
- if (F_status_is_error(setting->state.status)) {
- if (F_status_set_fine(setting->state.status) == F_interrupt) return;
-
- utf8_print_line_last_locked(setting, main->error);
+ if (F_status_set_fine(setting->state.status) == F_interrupt) return;
- return;
+ // Two lines are printed because the normal final end of line is never printed by design.
+ // If this is an error or the header flag is set, then the normal end of line is printed by design so do not print this second new line.
+ if (F_status_is_error_not(setting->state.status) && main->message.verbosity > f_console_verbosity_error_e && !(setting->flag & (utf8_main_flag_header_e | utf8_main_flag_separate_e))) {
+ fll_print_dynamic_raw(f_string_eol_s, main->message.to);
}
- utf8_print_line_last_locked(setting, main->message);
+ utf8_print_line_last(setting, main->message);
+
+ if (F_status_is_error(setting->state.status)) return;
if (setting->flag & utf8_main_flag_verify_e) {
setting->state.status = valid;
#include <fll/level_2/program.h>
// UTF-8 includes.
-#include <program/utf8/main/common-print.h>
-#include <program/utf8/main/common-string.h>
-#include <program/utf8/main/common-type.h>
+#include <program/utf8/main/common/print.h>
+#include <program/utf8/main/common/string.h>
+#include <program/utf8/main/common/type.h>
#include <program/utf8/main/common.h>
#include <program/utf8/main/bytesequence.h>
#include <program/utf8/main/codepoint.h>
#include <program/utf8/main/print.h>
+#include <program/utf8/main/print-data.h>
+#include <program/utf8/main/print-error.h>
#include <program/utf8/main/process.h>
#ifdef __cplusplus
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
-build_sources_library main/common.c main/common-print.c main/common-string.c main/common-type.c main/bytesequence.c main/codepoint.c main/print.c main/process.c main/utf8.c
+build_sources_library main/common.c main/common/print.c main/common/string.c main/common/type.c main/bytesequence.c main/codepoint.c main/print.c main/print-error.c main/print-data.c main/process.c main/utf8.c
build_sources_program main/main.c
-build_sources_headers main/common.h main/common-print.h main/common-string.h main/common-type.h main/bytesequence.h main/codepoint.h main/print.h main/process.h main/utf8.h
+build_sources_headers main/common.h main/common/print.h main/common/string.h main/common/type.h main/bytesequence.h main/codepoint.h main/print.h main/print-error.h main/print-data.h main/process.h main/utf8.h
build_sources_documentation man