The level_0 f_console_identify function should not be directly called by another function in this project.
Create a private function and call that function.
This is the standard practice for this project
This improves hackability.
build_sources_library account.c private-account.c
build_sources_library capability.c
build_sources_library color.c private-color.c color/common.c
-build_sources_library console.c console/common.c
+build_sources_library console.c console/common.c private-console.c
build_sources_library control_group.c control_group/common.c
build_sources_library conversion.c private-conversion.c conversion/common.c
build_sources_library directory.c directory/common.c private-directory.c
build_sources_headers account.h account/common.h
build_sources_headers capability.h capability/common.h
build_sources_headers color.h color/common.h
-build_sources_headers console.h console/common.h
+build_sources_headers console.h console/common.h private-console.h
build_sources_headers control_group.h control_group/common.h
build_sources_headers conversion.h conversion/common.h
build_sources_headers directory.h directory/common.h directory/type.h
build_sources_library level_0/account.c level_0/private-account.c
build_sources_library level_0/capability.c
build_sources_library level_0/color.c level_0/private-color.c level_0/color/common.c
-build_sources_library level_0/console.c level_0/console/common.c
+build_sources_library level_0/console.c level_0/console/common.c level_0/private-console.c
build_sources_library level_0/control_group.c level_0/control_group/common.c
build_sources_library level_0/conversion.c level_0/private-conversion.c level_0/conversion/common.c
build_sources_library level_0/directory.c level_0/directory/common.c level_0/private-directory.c
build_sources_headers level_0/account.h level_0/account/common.h
build_sources_headers level_0/capability.h level_0/capability/common.h
build_sources_headers level_0/color.h level_0/color/common.h
-build_sources_headers level_0/console.h level_0/console/common.h
+build_sources_headers level_0/console.h level_0/console/common.h level_0/private-console.h
build_sources_headers level_0/control_group.h level_0/control_group/common.h
build_sources_headers level_0/conversion.h level_0/conversion/common.h
build_sources_headers level_0/directory.h level_0/directory/common.h level_0/directory/type.h
build_sources_program fll/level_0/account.c fll/level_0/private-account.c
build_sources_program fll/level_0/capability.c
build_sources_program fll/level_0/color.c fll/level_0/private-color.c fll/level_0/color/common.c
-build_sources_program fll/level_0/console.c fll/level_0/console/common.c
+build_sources_program fll/level_0/console.c fll/level_0/console/common.c fll/level_0/private-console.c
build_sources_program fll/level_0/control_group.c fll/level_0/control_group/common.c
build_sources_program fll/level_0/conversion.c fll/level_0/private-conversion.c fll/level_0/conversion/common.c
build_sources_program fll/level_0/directory.c fll/level_0/directory/common.c fll/level_0/private-directory.c
build_libraries -lc -lcap
build_sources_program fll/level_0/color.c fll/level_0/private-color.c fll/level_0/color/common.c
-build_sources_program fll/level_0/console.c fll/level_0/console/common.c
+build_sources_program fll/level_0/console.c fll/level_0/console/common.c fll/level_0/private-console.c
build_sources_program fll/level_0/conversion.c fll/level_0/private-conversion.c fll/level_0/conversion/common.c
build_sources_program fll/level_0/file.c fll/level_0/private-file.c fll/level_0/file/common.c
build_sources_program fll/level_0/memory.c fll/level_0/private-memory.c fll/level_0/memory/structure.c
#include "console.h"
+#include "private-console.h"
#ifdef __cplusplus
extern "C" {
if (!result) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_f
- if (!input) {
- *result = f_console_none_e;
-
- return F_data_not;
- }
-
- const f_array_length_t length = strnlen(input, 3);
-
- if (!length) {
- *result = f_console_none_e;
-
- return F_data_not;
- }
-
- if (input[0] == f_console_symbol_short_enable_s.string[0]) {
- if (length > 1) {
- if (input[1] == f_console_symbol_short_enable_s.string[0]) {
- if (length > 2) {
- *result = f_console_long_enable_e;
- }
- else *result = f_console_empty_long_enable_e;
- }
- else *result = f_console_short_enable_e;
- }
- else *result = f_console_empty_short_enable_e;
- }
- else if (input[0] == f_console_symbol_short_disable_s.string[0]) {
- if (length > 1) {
- if (input[1] == f_console_symbol_short_disable_s.string[0]) {
- if (length > 2) {
- *result = f_console_long_disable_e;
- }
- else *result = f_console_empty_long_disable_e;
- }
- else *result = f_console_short_disable_e;
- }
- else *result = f_console_empty_short_disable_e;
- }
- else *result = f_console_none_e;
-
- return F_none;
+ return private_f_console_identify(input, result);
}
#endif // _di_f_console_identify_
continue;
}
- f_console_identify(arguments.argv[location], &result);
+ private_f_console_identify(arguments.argv[location], &result);
// Process the current parameter.
if (result == f_console_short_enable_e || result == f_console_short_disable_e) {
* @see f_string_maps_increase_by()
*/
#ifndef _di_f_console_environment_process_
- extern f_status_t f_console_environment_process(const f_console_arguments_t arguments, f_string_maps_t * const environment);
+ extern f_status_t f_console_environment_process(const f_console_arguments_t arguments, f_string_maps_t * const environment) F_attribute_visibility_internal_d;
#endif // _di_f_console_environment_process_
/**
--- /dev/null
+#include "console.h"
+#include "private-console.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_di_f_console_identify_) || !defined(_di_f_console_parameter_process_)
+ f_status_t private_f_console_identify(const f_string_t input, f_console_id_t * const result) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!result) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_f
+
+ if (!input) {
+ *result = f_console_none_e;
+
+ return F_data_not;
+ }
+
+ const f_array_length_t length = strnlen(input, 3);
+
+ if (!length) {
+ *result = f_console_none_e;
+
+ return F_data_not;
+ }
+
+ if (input[0] == f_console_symbol_short_enable_s.string[0]) {
+ if (length > 1) {
+ if (input[1] == f_console_symbol_short_enable_s.string[0]) {
+ if (length > 2) {
+ *result = f_console_long_enable_e;
+ }
+ else *result = f_console_empty_long_enable_e;
+ }
+ else *result = f_console_short_enable_e;
+ }
+ else *result = f_console_empty_short_enable_e;
+ }
+ else if (input[0] == f_console_symbol_short_disable_s.string[0]) {
+ if (length > 1) {
+ if (input[1] == f_console_symbol_short_disable_s.string[0]) {
+ if (length > 2) {
+ *result = f_console_long_disable_e;
+ }
+ else *result = f_console_empty_long_disable_e;
+ }
+ else *result = f_console_short_disable_e;
+ }
+ else *result = f_console_empty_short_disable_e;
+ }
+ else *result = f_console_none_e;
+
+ return F_none;
+ }
+#endif // !defined(_di_f_console_identify_) || !defined(_di_f_console_parameter_process_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Console
+ * API Version: 0.6
+ * Licenses: lgpl-2.1-or-later
+ *
+ * These are provided for internal reduction in redundant code.
+ * These should not be exposed/used outside of this project.
+ */
+#ifndef _PRIVATE_F_console_h
+#define _PRIVATE_F_console_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Private implementation of f_console_identify().
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param input
+ * The input parameter to process.
+ * @param result
+ * The flag with the console type bits determined by this function.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not the input string is empty.
+ *
+ *
+ * @see f_console_identify()
+ * @see f_console_parameter_process()
+ */
+#if !defined(_di_f_console_identify_) || !defined(_di_f_console_parameter_process_)
+ extern f_status_t private_f_console_identify(const f_string_t input, f_console_id_t * const result) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_console_identify_) || !defined(_di_f_console_parameter_process_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_F_console_h
build_libraries -lc
build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_utf
-build_sources_library console.c console/common.c
+build_sources_library console.c console/common.c private-console.c
-build_sources_headers console.h console/common.h
+build_sources_headers console.h console/common.h private-console.h
build_script yes
build_shared yes