Review the current dependencies and fix them.
There are some cases where some dependencies are not necessary, such as f_utf.
There are some cases where some dependencies are missing (or newly added).
f_conversion split into f_conversion and fl_conversion.
Update dependencies accordingly.
For simplicity, include the core level_0 project headers, except in a small number of cases.
Add fss header comment in dependencies files.
Add comments in *_array.h headers for level_0 core projects.
Add missing header in f_string.
Replace _di_level_0_parameter_checking_ with _di_level_1_parameter_checking_ where incorrect.
The fl_fss identify functions should instead be in the fll_fss project.
Make sure the IKI projects are in the bootstrap example script.
Remove the fl_console_parameter_to_number_unsigned() and similar functions.
These are just wrappers to another call and is therefore a waste.
Instead, just call the fl_conversion_string_to_number_unsigned() and similar functions.
build_libraries-level
build_sources_library console.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c private-file.c fss.c iki.c memory.c path.c pipe.c print.c serialize.c private-serialize.c socket.c utf.c private-utf.c
build_sources_program
-build_sources_headers color.h console.h conversion.h directory.h directory_type.h environment.h file.h fss.h fss-common.h fss-named.h fss-nest.h fss-set.h iki.h iki-common.h iki-common.h memory.h memory-structure.h path.h pipe.h print.h serialize.h socket.h status.h status_array.h string.h string-common.h string-dynamic.h string-map.h string-quantity.h string-range.h type.h type_array.h utf.h utf-common.h
+build_sources_headers color.h console.h conversion.h directory.h directory_type.h environment.h file.h fss.h fss-common.h fss-named.h fss-nest.h fss-set.h iki.h iki-common.h memory.h memory-structure.h path.h pipe.h print.h serialize.h socket.h status.h status_array.h string.h string-common.h string-dynamic.h string-map.h string-quantity.h string-range.h type.h type_array.h utf.h utf-common.h
build_sources_script
build_sources_setting
build_script yes
build_linker ar
build_libraries -lc
build_libraries-level -lfll_0
-build_sources_library color.c console.c directory.c private-directory.c fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c iki.c print.c status.c string.c private-string.c utf.c private-utf.c utf_file.c private-utf_file.c
+build_sources_library color.c console.c conversion.c directory.c private-directory.c fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c iki.c print.c status.c string.c private-string.c utf.c private-utf.c utf_file.c private-utf_file.c
build_sources_program
-build_sources_headers color.h console.h directory.h fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_macro.h fss_status.h iki.h print.h status.h string.h utf.h utf_file.h
+build_sources_headers color.h console.h conversion.h directory.h fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_macro.h fss_status.h iki.h print.h status.h string.h utf.h utf_file.h
build_sources_script
build_sources_setting
build_script yes
build_linker ar
build_libraries -lc
build_libraries-level -lfll_1 -lfll_0
-build_sources_library execute.c private-execute.c file.c fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c fss_status.c program.c status.c
+build_sources_library execute.c private-execute.c file.c fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c fss_status.c program.c status.c
build_sources_program
build_sources_headers execute.h file.h fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_status.h program.h status.h
build_sources_script
build_linker ar
build_libraries -lc
build_libraries-monolithic
-build_sources_library level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/memory.c level_0/path.c level_0/pipe.c level_0/print.c level_0/serialize.c level_0/private-serialize.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/directory.c level_1/private-directory.c level_1/fss.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/print.c level_1/iki.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/program.c level_2/status.c
+build_sources_library level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/memory.c level_0/path.c level_0/pipe.c level_0/print.c level_0/serialize.c level_0/private-serialize.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/fss.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/program.c level_2/status.c
build_sources_program
-build_sources_headers level_0/color.h level_0/console.h level_0/conversion.h level_0/directory.h level_0/directory_type.h level_0/environment.h level_0/file.h level_0/fss.h level_0/fss-common.h level_0/fss-named.h level_0/fss-nest.h level_0/fss-set.h level_0/iki.h level_0/iki-common.h level_0/iki-common.h level_0/memory.h level_0/memory-structure.h level_0/path.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/socket.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string-dynamic.h level_0/string-map.h level_0/string-quantity.h level_0/string-range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/directory.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/print.h level_1/iki.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/program.h level_2/status.h
+build_sources_headers level_0/color.h level_0/console.h level_0/conversion.h level_0/directory.h level_0/directory_type.h level_0/environment.h level_0/file.h level_0/fss.h level_0/fss-common.h level_0/fss-named.h level_0/fss-nest.h level_0/fss-set.h level_0/iki.h level_0/iki-common.h level_0/memory.h level_0/memory-structure.h level_0/path.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/socket.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string-dynamic.h level_0/string-map.h level_0/string-quantity.h level_0/string-range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/program.h level_2/status.h
build_sources_script
build_sources_setting
build_script yes
bash build/scripts/package.sh build -i
if [[ $? -eq 0 ]] ; then
- for i in f_type f_status f_memory f_string f_utf f_color f_console f_conversion f_directory f_environment f_file f_fss f_path f_pipe f_print f_serialize f_socket fl_color fl_console fl_directory fl_fss fl_print fl_status fl_string fl_utf fl_utf_file fll_execute fll_file fll_fss fll_program fll_status ; do
+ for i in f_type f_status f_memory f_string f_utf f_color f_console f_conversion f_directory f_environment f_file f_fss f_iki f_path f_pipe f_print f_serialize f_socket fl_color fl_console fl_conversion fl_directory fl_fss fl_iki fl_print fl_status fl_string fl_utf fl_utf_file fll_execute fll_file fll_fss fll_program fll_status ; do
echo && echo "Processing $i." &&
cd package/individual/$i-$2/ &&
#define _F_color_h
// fll-0 includes
-#include <level_0/string.h>
#include <level_0/type.h>
#ifdef __cplusplus
+# fss-0000
+
f_type
-f_memory
-f_string
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lf_memory
+build_libraries-individual
build_sources_library
build_sources_program
build_sources_headers color.h
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#ifdef __cplusplus
+# fss-0000
+
f_type
f_status
f_memory
}
#endif // _di_f_conversion_character_to_octal_
-#ifndef _di_f_conversion_string_to_binary_signed_
- f_return_status f_conversion_string_to_binary_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_binary(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
-
- if (negative) {
- if (scale > f_conversion_scale_binary_signed) {
- return F_status_set_error(F_number_underflow);
- }
-
- converted <<= 1;
- converted -= digit;
- }
- else {
- if (scale > f_conversion_scale_binary_signed) {
- return F_status_set_error(F_number_overflow);
- }
-
- converted <<= 1;
- converted += digit;
- }
- }
- else if (digit != 0) {
- scale = 1;
-
- if (negative) {
- converted = 0 - digit;
- }
- else {
- converted = digit;
- }
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_binary_signed_
-
-#ifndef _di_f_conversion_string_to_binary_unsigned_
- f_return_status f_conversion_string_to_binary_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_binary(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
-
- if (scale > f_conversion_scale_binary_unsigned) {
- return F_status_set_error(F_number_overflow);
- }
-
- converted <<= 1;
- converted += digit;
- }
- else if (digit != 0) {
- scale = 1;
- converted = digit;
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_binary_unsigned_
-
-#ifndef _di_f_conversion_string_to_decimal_signed_
- f_return_status f_conversion_string_to_decimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_decimal(string[i], &digit) == F_none) {
-
- if (scale) {
- scale++;
-
- if (negative) {
- if (scale > f_conversion_scale_decimal_signed) {
- if ((converted * 10) - digit < f_type_number_size_negative || (converted * 10) - digit > converted) {
- return F_status_set_error(F_number_underflow);
- }
- }
-
- converted *= 10;
- converted -= digit;
- }
- else {
- if (scale > f_conversion_scale_decimal_signed) {
- if ((converted * 10) + digit > f_type_number_size_positive || (converted * 10) + digit < converted) {
- return F_status_set_error(F_number_overflow);
- }
- }
-
- converted *= 10;
- converted += digit;
- }
- }
- else if (digit != 0) {
- scale = 1;
-
- if (negative) {
- converted = 0 - digit;
- }
- else {
- converted = digit;
- }
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_decimal_signed_
-
-#ifndef _di_f_conversion_string_to_decimal_unsigned_
- f_return_status f_conversion_string_to_decimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_decimal(string[i], &digit) == F_none) {
-
- if (scale) {
- scale++;
-
- if (scale > f_conversion_scale_decimal_unsigned) {
- if ((converted * 10) + digit > f_type_number_size_unsigned || (converted * 10) + digit < converted) {
- return F_status_set_error(F_number_overflow);
- }
- }
-
- converted *= 10;
- converted += digit;
- }
- else if (digit != 0) {
- scale = 1;
- converted = digit;
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_decimal_unsigned_
-
-#ifndef _di_f_conversion_string_to_duodecimal_signed_
- f_return_status f_conversion_string_to_duodecimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_duodecimal(string[i], &digit) == F_none) {
-
- if (scale) {
- scale++;
-
- if (negative) {
- if (scale > f_conversion_scale_duodecimal_signed) {
- if ((converted * 12) - digit < f_type_number_size_negative || (converted * 12) - digit > converted) {
- return F_status_set_error(F_number_underflow);
- }
- }
-
- converted *= 12;
- converted -= digit;
- }
- else {
- if (scale > f_conversion_scale_duodecimal_signed) {
- if ((converted * 12) + digit > f_type_number_size_positive || (converted * 12) + digit < converted) {
- return F_status_set_error(F_number_overflow);
- }
- }
-
- converted *= 12;
- converted += digit;
- }
- }
- else if (digit != 0) {
- scale = 1;
-
- if (negative) {
- converted = 0 - digit;
- }
- else {
- converted = digit;
- }
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_duodecimal_signed_
-
-#ifndef _di_f_conversion_string_to_duodecimal_unsigned_
- f_return_status f_conversion_string_to_duodecimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_duodecimal(string[i], &digit) == F_none) {
-
- if (scale) {
- scale++;
-
- if (scale > f_conversion_scale_duodecimal_unsigned) {
- if ((converted * 12) + digit > f_type_number_size_unsigned || (converted * 12) + digit < converted) {
- return F_status_set_error(F_number_overflow);
- }
- }
-
- converted *= 12;
- converted += digit;
- }
- else if (digit != 0) {
- scale = 1;
- converted = digit;
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_duodecimal_unsigned_
-
-#ifndef _di_f_conversion_string_to_hexidecimal_signed_
- f_return_status f_conversion_string_to_hexidecimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_hexidecimal(string[i], &digit) == F_none) {
-
- if (scale) {
- scale++;
-
- if (negative) {
- if (scale > f_conversion_scale_hexidecimal_signed) {
- if ((converted << 4) - digit < f_type_number_size_negative || (converted << 4) - digit > converted) {
- return F_status_set_error(F_number_underflow);
- }
- }
-
- converted <<= 4;
- converted -= digit;
- }
- else {
- if (scale > f_conversion_scale_hexidecimal_signed) {
- if ((converted << 4) + digit > f_type_number_size_positive || (converted << 4) + digit < converted) {
- return F_status_set_error(F_number_overflow);
- }
- }
-
- converted <<= 4;
- converted += digit;
- }
- }
- else if (digit != 0) {
- scale = 1;
-
- if (negative) {
- converted = 0 - digit;
- }
- else {
- converted = digit;
- }
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_hexidecimal_signed_
-
-#ifndef _di_f_conversion_string_to_hexidecimal_unsigned_
- f_return_status f_conversion_string_to_hexidecimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_hexidecimal(string[i], &digit) == F_none) {
-
- if (scale) {
- scale++;
-
- if (scale > f_conversion_scale_hexidecimal_unsigned) {
- if ((converted << 4) + digit > f_type_number_size_unsigned || (converted << 4) + digit < converted) {
- return F_status_set_error(F_number_overflow);
- }
- }
-
- converted <<= 4;
- converted += digit;
- }
- else if (digit != 0) {
- scale = 1;
- converted = digit;
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_hexidecimal_unsigned_
-
-#ifndef _di_f_conversion_string_to_octal_signed_
- f_return_status f_conversion_string_to_octal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_octal(string[i], &digit) == F_none) {
-
- if (scale) {
- scale++;
-
- if (negative) {
- if (scale > f_conversion_scale_octal_signed) {
- if ((converted << 3) - digit < f_type_number_size_negative || (converted << 3) - digit > converted) {
- return F_status_set_error(F_number_underflow);
- }
- }
-
- converted <<= 3;
- converted -= digit;
- }
- else {
- if (scale > f_conversion_scale_octal_signed) {
- if ((converted << 3) + digit > f_type_number_size_positive || (converted << 3) + digit < converted) {
- return F_status_set_error(F_number_overflow);
- }
- }
-
- converted <<= 3;
- converted += digit;
- }
- }
- else if (digit != 0) {
- scale = 1;
-
- if (negative) {
- converted = 0 - digit;
- }
- else {
- converted = digit;
- }
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_octal_signed_
-
-#ifndef _di_f_conversion_string_to_octal_unsigned_
- f_return_status f_conversion_string_to_octal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t scale = 0;
- f_number_unsigned digit = 0;
- f_number_unsigned converted = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- if (f_conversion_character_to_octal(string[i], &digit) == F_none) {
-
- if (scale) {
- scale++;
-
- if (scale > f_conversion_scale_octal_unsigned) {
- if ((converted << 3) + digit > f_type_number_size_unsigned || (converted << 3) + digit < converted) {
- return F_status_set_error(F_number_overflow);
- }
- }
-
- converted <<= 3;
- converted += digit;
- }
- else if (digit != 0) {
- scale = 1;
- converted = digit;
- }
- }
- else if (string[i] != 0) {
- return F_status_set_error(F_number);
- }
- } // for
-
- *number = converted;
- return F_none;
- }
-#endif // _di_f_conversion_string_to_octal_unsigned_
-
-#ifndef _di_f_conversion_string_to_number_signed_
- f_return_status f_conversion_string_to_number_signed(const f_string string, f_number_signed *number, const f_string_range range) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start < 0) return F_status_set_error(F_parameter);
- if (range.stop < range.start) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t width = 0;
- uint8_t width_max = 0;
- uint8_t mode = 0;
- int8_t vector = 0; // 0 for assumed positive, 1 for explicit positive, -1 for negative.
- f_string_length j = 0;
- f_string_length offset = 0;
- f_status status = F_none;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- width = f_macro_utf_byte_width_is(string[i]);
-
- if (width == 0) {
- if (isspace(string[i])) {
- if (mode == 0 && vector == 0) {
- offset++;
- continue;
- }
-
- return F_status_set_error(F_number);
- }
- }
- else {
- if (mode == 0 && vector == 0) {
- width_max = (range.stop - i) + 1;
-
- status = f_utf_is_whitespace(string + i, width_max);
-
- if (status == F_true) {
- offset = i + 1;
- continue;
- }
-
- if (F_status_is_error(status)) {
- if (status == F_status_set_error(F_maybe)) {
- status = F_status_set_error(F_incomplete_utf);
- }
-
- return status;
- }
- }
-
- return F_status_set_error(F_number);
- }
-
- if (string[i] == 0x30) {
- j = i + 1;
-
- // Immediate next value must be either a number, 'x', 'X', 'd', 'D', 'o', 'O', 'b', or 'B'.
- if (j > range.stop) {
- *number = 0;
- return F_none;
- }
- else if (string[j] > 0x29 && string[j] < 0x3a) {
- mode = 10;
- }
- else if (string[j] == 0x78 || string[j] == 0x58) {
- mode = 16;
- offset += 2;
- }
- else if (string[j] == 0x44 || string[j] == 0x64) {
- mode = 12;
- offset += 2;
- }
- else if (string[j] == 0x6f || string[j] == 0x4f) {
- mode = 8;
- offset += 2;
- }
- else if (string[j] == 0x62 || string[j] == 0x42) {
- mode = 2;
- offset += 2;
- }
- else {
- return F_status_set_error(F_number);
- }
-
- break;
- }
-
- // plus sign is only allowed as the first non-whitespace character.
- if (string[i] == 0x2b) {
- if (mode == 0 && vector == 0) {
- vector = 1;
- offset++;
- }
- else {
- return F_status_set_error(F_number);
- }
- }
-
- // negative sign is not allowed.
- if (string[i] == 0x2d) {
- if (mode == 0 && vector == 0) {
- vector = -1;
- offset++;
- }
- else {
- return F_status_set_error(F_number);
- }
- }
-
- if (f_conversion_character_is_decimal(string[i]) == F_true) {
- mode = 10;
- break;
- }
-
- return F_status_set_error(F_number);
- } // for
-
- if (mode == 0) {
- return F_status_set_error(F_number);
- }
-
- f_string_range location_offset = f_string_range_initialize;
- location_offset.start = range.start + offset;
- location_offset.stop = range.stop;
-
- if (mode == 10) {
- return f_conversion_string_to_decimal_signed(string, number, location_offset, vector == -1);
- }
-
- if (mode == 16) {
- return f_conversion_string_to_hexidecimal_signed(string, number, location_offset, vector == -1);
- }
-
- if (mode == 12) {
- return f_conversion_string_to_duodecimal_signed(string, number, location_offset, vector == -1);
- }
-
- if (mode == 8) {
- return f_conversion_string_to_octal_signed(string, number, location_offset, vector == -1);
- }
-
- return f_conversion_string_to_binary_signed(string, number, location_offset, vector == -1);
- }
-#endif // _di_f_conversion_string_to_number_signed_
-
-#ifndef _di_f_conversion_string_to_number_unsigned_
- f_return_status f_conversion_string_to_number_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
- #ifndef _di_level_0_parameter_checking_
- if (string == 0) return F_status_set_error(F_parameter);
- if (number == 0) return F_status_set_error(F_parameter);
- if (range.start > range.stop) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (string[0] == 0) {
- return F_data_not;
- }
-
- uint8_t width = 0;
- uint8_t width_max = 0;
- uint8_t mode = 0;
- f_string_length j = 0;
- f_string_length offset = 0;
- f_status status = F_none;
- int8_t sign_found = 0;
-
- for (f_string_length i = range.start; i <= range.stop; i++) {
- width = f_macro_utf_byte_width_is(string[i]);
-
- if (width == 0) {
- if (isspace(string[i])) {
- if (mode == 0) {
- offset++;
- continue;
- }
-
- return F_status_set_error(F_number);
- }
- }
- else {
- if (mode == 0) {
- width_max = (range.stop - i) + 1;
-
- status = f_utf_is_whitespace(string + i, width_max);
-
- if (status == F_true) {
- offset = i + 1;
- continue;
- }
-
- if (F_status_is_error(status)) {
- if (status == F_status_set_error(F_maybe)) {
- status = F_status_set_error(F_incomplete_utf);
- }
-
- return status;
- }
- }
-
- return F_status_set_error(F_number);
- }
-
- if (string[i] == 0x30) {
- j = i + 1;
-
- // Immediate next value must be either a number, 'x', 'X', 'd', 'D', 'o', 'O', 'b', or 'B'.
- if (j > range.stop) {
- *number = 0;
- return F_none;
- }
- else if (string[j] > 0x29 && string[j] < 0x3a) {
- mode = 10;
- }
- else if (string[j] == 0x78 || string[j] == 0x58) {
- mode = 16;
- offset += 2;
- }
- else if (string[j] == 0x44 || string[j] == 0x64) {
- mode = 12;
- offset += 2;
- }
- else if (string[j] == 0x6f || string[j] == 0x4f) {
- mode = 8;
- offset += 2;
- }
- else if (string[j] == 0x62 || string[j] == 0x42) {
- mode = 2;
- offset += 2;
- }
- else {
- return F_status_set_error(F_number);
- }
-
- break;
- }
-
- if (string[i] == 0x2b) {
- offset++;
- sign_found = 1;
- }
-
- if (string[i] == 0x2d) {
- offset++;
- sign_found = -1;
- }
-
- if (f_conversion_character_is_decimal(string[i]) == F_true) {
- mode = 10;
- break;
- }
-
- return F_status_set_error(F_number);
- } // for
-
- if (mode == 0) {
- return F_status_set_error(F_number);
- }
-
- f_string_range location_offset = f_string_range_initialize;
- location_offset.start = range.start + offset;
- location_offset.stop = range.stop;
-
- if (range.start + offset > range.stop) {
- return F_status_set_error(F_number);
- }
-
- if (mode == 10) {
- status = f_conversion_string_to_decimal_unsigned(string, number, location_offset);
- }
- else if (mode == 16) {
- status = f_conversion_string_to_hexidecimal_unsigned(string, number, location_offset);
- }
- else if (mode == 12) {
- status = f_conversion_string_to_duodecimal_unsigned(string, number, location_offset);
- }
- else if (mode == 8) {
- status = f_conversion_string_to_octal_unsigned(string, number, location_offset);
- }
- else {
- status = f_conversion_string_to_binary_unsigned(string, number, location_offset);
- }
-
- // +/- signs are not allowed.
- if (sign_found) {
- if (status == F_none) {
- if (sign_found == -1) {
- return F_status_set_error(F_number_negative);
- }
-
- return F_status_set_error(F_number_positive);
- }
-
- return F_status_set_error(F_number);
- }
-
- return status;
- }
-#endif // _di_f_conversion_string_to_number_unsigned_
-
#ifdef __cplusplus
} // extern "C"
#endif
#include <stdlib.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#ifdef __cplusplus
extern f_return_status f_conversion_character_to_octal(const int8_t character, f_number_unsigned *number);
#endif // _di_f_conversion_character_to_octal_
-/**
- * Convert a series of positive or negative binary number characters into a f_number_signed.
- *
- * This will stop at one of the following: location.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param location
- * The start/stop range to convert.
- * @param negative
- * Set to 0 to treat string as a positive number, 1 for as a negative number.
- *
- * @return
- * F_none if the binary string was converted to an signed long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-binary values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_number_underflow (with error bit) on integer underflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_binary_signed_
- extern f_return_status f_conversion_string_to_binary_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
-#endif // _di_f_conversion_string_to_binary_signed_
-
-/**
- * Convert a series of positive binary number characters into a f_number_unsigned.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- *
- * @return
- * F_none if the binary string was converted to an unsigned long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-binary values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_binary_unsigned_
- extern f_return_status f_conversion_string_to_binary_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
-#endif // _di_f_conversion_string_to_binary_unsigned_
-
-/**
- * Convert a series of positive or negative decimal number characters into an f_number_signed.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- * @param negative
- * Set to 0 to treat string as a positive number, 1 for as a negative number.
- *
- * @return
- * F_none if the decimal string was converted to an signed long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-decimal values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_number_underflow (with error bit) on integer underflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_decimal_signed_
- extern f_return_status f_conversion_string_to_decimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
-#endif // _di_f_conversion_string_to_decimal_signed_
-
-/**
- * Convert a series of positive decimal number characters into an f_number_unsigned.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- *
- * @return
- * F_none if the decimal string was converted to an unsigned long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-decimal values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_decimal_unsigned_
- extern f_return_status f_conversion_string_to_decimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
-#endif // _di_f_conversion_string_to_decimal_unsigned_
-
-/**
- * Convert a series of positive or negative duodecimal number characters into an f_number_signed.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- * @param negative
- * Set to 0 to treat string as a positive number, 1 for as a negative number.
- *
- * @return
- * F_none if the duodecimal string was converted to an signed long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-duodecimal values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_number_underflow (with error bit) on integer underflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_duodecimal_signed_
- extern f_return_status f_conversion_string_to_duodecimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
-#endif // _di_f_conversion_string_to_duodecimal_signed_
-
-/**
- * Convert a series of positive duodecimal number characters into an f_number_unsigned.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- *
- * @return
- * F_none if the duodecimal string was converted to an unsigned long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-duodecimal values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_duodecimal_unsigned_
- extern f_return_status f_conversion_string_to_duodecimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
-#endif // _di_f_conversion_string_to_duodecimal_unsigned_
-
-/**
- * Convert a series of positive or negative hexidecimal number characters into an f_number_signed.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- * @param negative
- * Set to 0 to treat string as a positive number, 1 for as a negative number.
- *
- * @return
- * F_none if the hexidecimal string was converted to an signed long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-hexidecimal values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_number_underflow (with error bit) on integer underflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_hexidecimal_signed_
- extern f_return_status f_conversion_string_to_hexidecimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
-#endif // _di_f_conversion_string_to_hexidecimal_signed_
-
-/**
- * Convert a series of positive hexidecimal number characters into an f_number_unsigned.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- *
- * @return
- * F_none if the hexidecimal string was converted to an unsigned long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-hexidecimal values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_hexidecimal_unsigned_
- extern f_return_status f_conversion_string_to_hexidecimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
-#endif // _di_f_conversion_string_to_hexidecimal_unsigned_
-
-/**
- * Convert a series of positive or negative octal number characters into an f_number_signed.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- * @param negative
- * Set to 0 to treat string as a positive number, 1 for as a negative number.
- *
- * @return
- * F_none if the octal string was converted to an signed long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-octal values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_octal_signed_
- extern f_return_status f_conversion_string_to_octal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
-#endif // _di_f_conversion_string_to_octal_signed_
-
-/**
- * Convert a series of positive octal number characters into an f_number_unsigned.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- *
- * @return
- * F_none if the octal string was converted to an unsigned long.
- * F_data_not if string starts with a null (length is 0).
- * F_number (with error bit) if no conversion was made due to non-octal values being found.
- * F_number_overflow (with error bit) on integer overflow.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_conversion_string_to_octal_unsigned_
- extern f_return_status f_conversion_string_to_octal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
-#endif // _di_f_conversion_string_to_octal_unsigned_
-
-/**
- * Convert a series of positive or negative number characters into an f_number_signed.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will process signed statuses (+/-).
- * This will detect based types as follows:
- * - hexidecimals begin with either '0x' or '0X'.
- * - duodecimals begin with either '0d' or '0D'.
- * - octals begin with either '0o' or '0O'.
- * - binaries begin with either '0b' or '0B'.
- * - decimal is used for all other cases.
- *
- * Leading 0's and whitespace are ignored.
- * Whitespace after the first digit is considered invalid.
- *
- * This function is similar to strtoll(), but the behavior of error handling and special bases are different.
- * In particular, octals are specified here with '0b' prefix or '0B' prefix instead of the ridiculous '0' prefix.
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- *
- * @return
- * F_none on success.
- * F_data_not if string starts with a null (length is 0).
- * F_incomplete_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_overflow (with error bit) on integer overflow.
- * F_number_underflow (with error bit) on integer underflow.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * @see strtoll()
- */
-#ifndef _di_f_conversion_string_to_number_signed_
- extern f_return_status f_conversion_string_to_number_signed(const f_string string, f_number_signed *number, const f_string_range range);
-#endif // _di_f_conversion_string_to_number_signed_
-
-/**
- * Convert a series of positive number characters into an f_number_unsigned.
- *
- * This will stop at one of the following: range.stop or a non-digit.
- * This will ignore NULL values.
- * This will not process signed statuses (+/-).
- * This will detect based types as follows:
- * - hexidecimals begin with either '0x' or '0X'.
- * - duodecimals begin with either '0d' or '0D'.
- * - octals begin with either '0o' or '0O'.
- * - binaries begin with either '0b' or '0B'.
- * - decimal is used for all other cases.
- *
- * Leading 0's and whitespace are ignored.
- * Whitespace after the first digit is considered invalid.
- *
- * This function is similar to strtoull(), but the behavior of error handling and special bases are different.
- * In particular, octals are specified here with '0b' prefix or '0B' prefix instead of the ridiculous '0' prefix.
- * Negative values are reported as such instead of being converted into the unsigned equivalent.
- *
- * @param string
- * The string to convert.
- * @param number
- * This will store the value of the converted string.
- * This value is only changed on success.
- * @param range
- * The start/stop range to convert.
- *
- * @return
- * F_none on success.
- * F_data_not if string starts with a null (length is 0).
- * F_incomplete_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_positive (with error bit) on positive value (has a +, such as '+1', when only '1' is valid here).
- * F_number_overflow (with error bit) on integer overflow.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * @see strtoull()
- */
-#ifndef _di_f_conversion_string_to_number_unsigned_
- extern f_return_status f_conversion_string_to_number_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
-#endif // _di_f_conversion_string_to_number_unsigned_
-
#ifdef __cplusplus
} // extern "C"
#endif
+# fss-0000
+
f_type
f_status
f_memory
#endif // __USE_XOPEN_EXTENDED
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/directory_type.h>
#ifdef __cplusplus
+# fss-0000
+
f_type
f_status
f_memory
#include <sys/stat.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#ifdef __cplusplus
extern "C" {
+# fss-0000
+
f_type
f_status
f_memory
#include <sys/sysmacros.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#ifdef __cplusplus
extern "C" {
+# fss-0000
+
f_type
f_status
f_memory
+# fss-0000
+
f_type
f_status
f_memory
#include <sys/stat.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
// fll-0 iki includes
+# fss-0000
+
f_type
f_status
f_memory
#include <string.h>
// fll-0 includes
-#include <level_0/status.h>
#include <level_0/type.h>
+#include <level_0/status.h>
// fll-0 memory includes
#include <level_0/memory-structure.h>
+# fss-0000
+
f_type
f_status
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
-#include <level_0/utf.h>
#ifdef __cplusplus
extern "C" {
+# fss-0000
+
f_type
f_status
f_memory
f_string
-f_utf
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lf_utf -lf_memory
+build_libraries-individual -lf_memory
build_sources_library path.c
build_sources_program
build_sources_headers path.h
+# fss-0000
+
f_type
f_status
#include <sys/stat.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#ifdef __cplusplus
extern "C" {
+# fss-0000
+
f_type
f_status
f_memory
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
-#include <level_0/serialize.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#ifdef __cplusplus
-f_memory
+# fss-0000
+
+f_type
f_status
+f_memory
f_string
-f_type
f_utf
// fll-0 includes
#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
#ifdef __cplusplus
-f_memory
+# fss-0000
+
+f_type
f_status
+f_memory
f_string
-f_type
* Licenses: lgplv2.1
*
* Provides status arrays that require memory operations.
+ *
+ * Because memory requires status.h, this is moved to a separate file to reduce potential circular dependency issues.
*/
#ifndef _F_status_array_h
#define _F_status_array_h
+# fss-0000
+
f_type
f_status
f_memory
build_libraries-individual -lf_memory
build_sources_library
build_sources_program
-build_sources_headers string.h string-common.h string-dynamic.h string-quantity.h string-range.h
+build_sources_headers string.h string-common.h string-dynamic.h string-map.h string-quantity.h string-range.h
build_sources_script
build_sources_setting
build_script yes
* Licenses: lgplv2.1
*
* Provides datatypes that require memory operations.
+ *
+ * Because memory requires status.h, this is moved to a separate file to reduce potential circular dependency issues.
*/
#ifndef _F_type_array_h
#define _F_type_array_h
// fll-0 includes
-#include <level_0/memory.h>
#include <level_0/type.h>
+#include <level_0/memory.h>
#ifdef __cplusplus
extern "C" {
#include <string.h>
// fll-0 includes
-#include <level_0/status.h>
#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
// fll-0 utf includes
+# fss-0000
+
f_type
f_status
f_memory
#include <string.h>
// fll-0 includes
-#include <level_0/color.h>
+#include <level_0/type.h>
#include <level_0/status.h>
-#include <level_0/file.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
+#include <level_0/color.h>
+#include <level_0/file.h>
#include <level_0/print.h>
#ifdef __cplusplus
+# fss-0000
+
f_type
f_status
f_memory
#ifndef _fl_console_parameter_to_string_dynamic_directory_
f_return_status fl_console_parameter_to_string_dynamic_directory(const f_string argument, f_string_dynamic *directory) {
- #ifndef _di_level_0_parameter_checking_
+ #ifndef _di_level_1_parameter_checking_
if (argument == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_f
+ #endif // _di_level_1_parameter_checking_
f_status status = F_none;
f_string_length length = strlen(argument);
}
#endif // _fl_console_parameter_to_string_dynamic_directory_
-#ifndef _fl_console_parameter_to_number_signed_
- f_return_status fl_console_parameter_to_number_signed(const f_string argument, f_number_signed *number) {
- #ifndef _di_level_0_parameter_checking_
- if (argument == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_f
-
- if (argument[0] == 0) {
- return F_data_not;
- }
-
- f_string_range range = f_string_range_initialize;
- range.start = 0;
- range.stop = strlen(argument) - 1;
-
- return f_conversion_string_to_number_signed(argument, number, range);
- }
-#endif // _fl_console_parameter_to_number_signed_
-
-#ifndef _fl_console_parameter_to_number_unsigned_
- f_return_status fl_console_parameter_to_number_unsigned(const f_string argument, f_number_unsigned *number) {
- #ifndef _di_level_0_parameter_checking_
- if (argument == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_f
-
- if (argument[0] == 0) {
- return F_data_not;
- }
-
- f_string_range range = f_string_range_initialize;
- range.start = 0;
- range.stop = strlen(argument) - 1;
-
- return f_conversion_string_to_number_unsigned(argument, number, range);
- }
-#endif // _fl_console_parameter_to_number_unsigned_
-
#ifdef __cplusplus
} // extern "C"
#endif
#include <sys/stat.h>
// fll-0 includes
-#include <level_0/console.h>
-#include <level_0/conversion.h>
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
+#include <level_0/console.h>
+#include <level_0/conversion.h>
#ifdef __cplusplus
extern "C" {
extern f_return_status fl_console_parameter_to_string_dynamic_directory(const f_string argument, f_string_dynamic *directory);
#endif // _fl_console_parameter_to_string_dynamic_directory_
-/**
- * Convert a console parameter additional argument to a signed integer.
- *
- * This will detect based types as follows:
- * - hexidecimals begin with either '0x' or '0X'.
- * - duodecimals begin with either '0d' or '0D'.
- * - octals begin with either '0o' or '0O'.
- * - binaries begin with either '0b' or '0B'.
- * - decimal is used for all other cases.
- *
- * Leading 0's and whitespace are ignored.
- * Whitespace after the first digit is considered invalid.
- *
- * @param argv
- * The argument string expected to be a number.
- * This is generally passed from the argv[].
- * @param number
- * The converted number is stored here.
- * This only gets modified on success.
- *
- * @return
- * F_none on success.
- * F_data_not if string starts wth a null (length is 0).
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors from (with error bit): f_conversion_string_to_number_signed().
- *
- * @see f_conversion_string_to_number_signed()
- */
-#ifndef _fl_console_parameter_to_number_signed_
- extern f_return_status fl_console_parameter_to_number_signed(const f_string argument, f_number_signed *number);
-#endif // _fl_console_parameter_to_number_signed_
-
-/**
- * Convert a console parameter additional argument to an unsigned integer.
- *
- * This will detect based types as follows:
- * - hexidecimals begin with either '0x' or '0X'.
- * - duodecimals begin with either '0d' or '0D'.
- * - octals begin with either '0o' or '0O'.
- * - binaries begin with either '0b' or '0B'.
- * - decimal is used for all other cases.
- *
- * Leading 0's and whitespace are ignored.
- * Whitespace after the first digit is considered invalid.
- *
- * @param argv
- * The argument string expected to be a number.
- * This is generally passed from the argv[].
- * @param number
- * The converted number is stored here.
- * This only gets modified on success.
- *
- * @return
- * F_none on success.
- * F_data_not if string starts wth a null (length is 0).
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors from (with error bit): f_conversion_string_to_number_unsigned().
- *
- * @see f_conversion_string_to_number_unsigned()
- */
-#ifndef _fl_console_parameter_to_number_unsigned_
- extern f_return_status fl_console_parameter_to_number_unsigned(const f_string argument, f_number_unsigned *number);
-#endif // _fl_console_parameter_to_number_unsigned_
-
#ifdef __cplusplus
} // extern "C"
#endif
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_console
f_conversion
-f_utf
--- /dev/null
+#include <level_1/conversion.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_fl_conversion_string_to_binary_signed_
+ f_return_status fl_conversion_string_to_binary_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_binary(string[i], &digit) == F_none) {
+ if (scale) {
+ scale++;
+
+ if (negative) {
+ if (scale > f_conversion_scale_binary_signed) {
+ return F_status_set_error(F_number_underflow);
+ }
+
+ converted <<= 1;
+ converted -= digit;
+ }
+ else {
+ if (scale > f_conversion_scale_binary_signed) {
+ return F_status_set_error(F_number_overflow);
+ }
+
+ converted <<= 1;
+ converted += digit;
+ }
+ }
+ else if (digit != 0) {
+ scale = 1;
+
+ if (negative) {
+ converted = 0 - digit;
+ }
+ else {
+ converted = digit;
+ }
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_binary_signed_
+
+#ifndef _di_fl_conversion_string_to_binary_unsigned_
+ f_return_status fl_conversion_string_to_binary_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_binary(string[i], &digit) == F_none) {
+ if (scale) {
+ scale++;
+
+ if (scale > f_conversion_scale_binary_unsigned) {
+ return F_status_set_error(F_number_overflow);
+ }
+
+ converted <<= 1;
+ converted += digit;
+ }
+ else if (digit != 0) {
+ scale = 1;
+ converted = digit;
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_binary_unsigned_
+
+#ifndef _di_fl_conversion_string_to_decimal_signed_
+ f_return_status fl_conversion_string_to_decimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_decimal(string[i], &digit) == F_none) {
+
+ if (scale) {
+ scale++;
+
+ if (negative) {
+ if (scale > f_conversion_scale_decimal_signed) {
+ if ((converted * 10) - digit < f_type_number_size_negative || (converted * 10) - digit > converted) {
+ return F_status_set_error(F_number_underflow);
+ }
+ }
+
+ converted *= 10;
+ converted -= digit;
+ }
+ else {
+ if (scale > f_conversion_scale_decimal_signed) {
+ if ((converted * 10) + digit > f_type_number_size_positive || (converted * 10) + digit < converted) {
+ return F_status_set_error(F_number_overflow);
+ }
+ }
+
+ converted *= 10;
+ converted += digit;
+ }
+ }
+ else if (digit != 0) {
+ scale = 1;
+
+ if (negative) {
+ converted = 0 - digit;
+ }
+ else {
+ converted = digit;
+ }
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_decimal_signed_
+
+#ifndef _di_fl_conversion_string_to_decimal_unsigned_
+ f_return_status fl_conversion_string_to_decimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_decimal(string[i], &digit) == F_none) {
+
+ if (scale) {
+ scale++;
+
+ if (scale > f_conversion_scale_decimal_unsigned) {
+ if ((converted * 10) + digit > f_type_number_size_unsigned || (converted * 10) + digit < converted) {
+ return F_status_set_error(F_number_overflow);
+ }
+ }
+
+ converted *= 10;
+ converted += digit;
+ }
+ else if (digit != 0) {
+ scale = 1;
+ converted = digit;
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_decimal_unsigned_
+
+#ifndef _di_fl_conversion_string_to_duodecimal_signed_
+ f_return_status fl_conversion_string_to_duodecimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_duodecimal(string[i], &digit) == F_none) {
+
+ if (scale) {
+ scale++;
+
+ if (negative) {
+ if (scale > f_conversion_scale_duodecimal_signed) {
+ if ((converted * 12) - digit < f_type_number_size_negative || (converted * 12) - digit > converted) {
+ return F_status_set_error(F_number_underflow);
+ }
+ }
+
+ converted *= 12;
+ converted -= digit;
+ }
+ else {
+ if (scale > f_conversion_scale_duodecimal_signed) {
+ if ((converted * 12) + digit > f_type_number_size_positive || (converted * 12) + digit < converted) {
+ return F_status_set_error(F_number_overflow);
+ }
+ }
+
+ converted *= 12;
+ converted += digit;
+ }
+ }
+ else if (digit != 0) {
+ scale = 1;
+
+ if (negative) {
+ converted = 0 - digit;
+ }
+ else {
+ converted = digit;
+ }
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_duodecimal_signed_
+
+#ifndef _di_fl_conversion_string_to_duodecimal_unsigned_
+ f_return_status fl_conversion_string_to_duodecimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_duodecimal(string[i], &digit) == F_none) {
+
+ if (scale) {
+ scale++;
+
+ if (scale > f_conversion_scale_duodecimal_unsigned) {
+ if ((converted * 12) + digit > f_type_number_size_unsigned || (converted * 12) + digit < converted) {
+ return F_status_set_error(F_number_overflow);
+ }
+ }
+
+ converted *= 12;
+ converted += digit;
+ }
+ else if (digit != 0) {
+ scale = 1;
+ converted = digit;
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_duodecimal_unsigned_
+
+#ifndef _di_fl_conversion_string_to_hexidecimal_signed_
+ f_return_status fl_conversion_string_to_hexidecimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_hexidecimal(string[i], &digit) == F_none) {
+
+ if (scale) {
+ scale++;
+
+ if (negative) {
+ if (scale > f_conversion_scale_hexidecimal_signed) {
+ if ((converted << 4) - digit < f_type_number_size_negative || (converted << 4) - digit > converted) {
+ return F_status_set_error(F_number_underflow);
+ }
+ }
+
+ converted <<= 4;
+ converted -= digit;
+ }
+ else {
+ if (scale > f_conversion_scale_hexidecimal_signed) {
+ if ((converted << 4) + digit > f_type_number_size_positive || (converted << 4) + digit < converted) {
+ return F_status_set_error(F_number_overflow);
+ }
+ }
+
+ converted <<= 4;
+ converted += digit;
+ }
+ }
+ else if (digit != 0) {
+ scale = 1;
+
+ if (negative) {
+ converted = 0 - digit;
+ }
+ else {
+ converted = digit;
+ }
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_hexidecimal_signed_
+
+#ifndef _di_fl_conversion_string_to_hexidecimal_unsigned_
+ f_return_status fl_conversion_string_to_hexidecimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_hexidecimal(string[i], &digit) == F_none) {
+
+ if (scale) {
+ scale++;
+
+ if (scale > f_conversion_scale_hexidecimal_unsigned) {
+ if ((converted << 4) + digit > f_type_number_size_unsigned || (converted << 4) + digit < converted) {
+ return F_status_set_error(F_number_overflow);
+ }
+ }
+
+ converted <<= 4;
+ converted += digit;
+ }
+ else if (digit != 0) {
+ scale = 1;
+ converted = digit;
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_hexidecimal_unsigned_
+
+#ifndef _di_fl_conversion_string_to_octal_signed_
+ f_return_status fl_conversion_string_to_octal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_octal(string[i], &digit) == F_none) {
+
+ if (scale) {
+ scale++;
+
+ if (negative) {
+ if (scale > f_conversion_scale_octal_signed) {
+ if ((converted << 3) - digit < f_type_number_size_negative || (converted << 3) - digit > converted) {
+ return F_status_set_error(F_number_underflow);
+ }
+ }
+
+ converted <<= 3;
+ converted -= digit;
+ }
+ else {
+ if (scale > f_conversion_scale_octal_signed) {
+ if ((converted << 3) + digit > f_type_number_size_positive || (converted << 3) + digit < converted) {
+ return F_status_set_error(F_number_overflow);
+ }
+ }
+
+ converted <<= 3;
+ converted += digit;
+ }
+ }
+ else if (digit != 0) {
+ scale = 1;
+
+ if (negative) {
+ converted = 0 - digit;
+ }
+ else {
+ converted = digit;
+ }
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_octal_signed_
+
+#ifndef _di_fl_conversion_string_to_octal_unsigned_
+ f_return_status fl_conversion_string_to_octal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t scale = 0;
+ f_number_unsigned digit = 0;
+ f_number_unsigned converted = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ if (f_conversion_character_to_octal(string[i], &digit) == F_none) {
+
+ if (scale) {
+ scale++;
+
+ if (scale > f_conversion_scale_octal_unsigned) {
+ if ((converted << 3) + digit > f_type_number_size_unsigned || (converted << 3) + digit < converted) {
+ return F_status_set_error(F_number_overflow);
+ }
+ }
+
+ converted <<= 3;
+ converted += digit;
+ }
+ else if (digit != 0) {
+ scale = 1;
+ converted = digit;
+ }
+ }
+ else if (string[i] != 0) {
+ return F_status_set_error(F_number);
+ }
+ } // for
+
+ *number = converted;
+ return F_none;
+ }
+#endif // _di_fl_conversion_string_to_octal_unsigned_
+
+#ifndef _di_fl_conversion_string_to_number_signed_
+ f_return_status fl_conversion_string_to_number_signed(const f_string string, f_number_signed *number, const f_string_range range) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t width = 0;
+ uint8_t width_max = 0;
+ uint8_t mode = 0;
+ int8_t vector = 0; // 0 for assumed positive, 1 for explicit positive, -1 for negative.
+ f_string_length j = 0;
+ f_string_length offset = 0;
+ f_status status = F_none;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ width = f_macro_utf_byte_width_is(string[i]);
+
+ if (width == 0) {
+ if (isspace(string[i])) {
+ if (mode == 0 && vector == 0) {
+ offset++;
+ continue;
+ }
+
+ return F_status_set_error(F_number);
+ }
+ }
+ else {
+ if (mode == 0 && vector == 0) {
+ width_max = (range.stop - i) + 1;
+
+ status = f_utf_is_whitespace(string + i, width_max);
+
+ if (status == F_true) {
+ offset = i + 1;
+ continue;
+ }
+
+ if (F_status_is_error(status)) {
+ if (status == F_status_set_error(F_maybe)) {
+ status = F_status_set_error(F_incomplete_utf);
+ }
+
+ return status;
+ }
+ }
+
+ return F_status_set_error(F_number);
+ }
+
+ if (string[i] == 0x30) {
+ j = i + 1;
+
+ // Immediate next value must be either a number, 'x', 'X', 'd', 'D', 'o', 'O', 'b', or 'B'.
+ if (j > range.stop) {
+ *number = 0;
+ return F_none;
+ }
+ else if (string[j] > 0x29 && string[j] < 0x3a) {
+ mode = 10;
+ }
+ else if (string[j] == 0x78 || string[j] == 0x58) {
+ mode = 16;
+ offset += 2;
+ }
+ else if (string[j] == 0x44 || string[j] == 0x64) {
+ mode = 12;
+ offset += 2;
+ }
+ else if (string[j] == 0x6f || string[j] == 0x4f) {
+ mode = 8;
+ offset += 2;
+ }
+ else if (string[j] == 0x62 || string[j] == 0x42) {
+ mode = 2;
+ offset += 2;
+ }
+ else {
+ return F_status_set_error(F_number);
+ }
+
+ break;
+ }
+
+ // plus sign is only allowed as the first non-whitespace character.
+ if (string[i] == 0x2b) {
+ if (mode == 0 && vector == 0) {
+ vector = 1;
+ offset++;
+ }
+ else {
+ return F_status_set_error(F_number);
+ }
+ }
+
+ // negative sign is not allowed.
+ if (string[i] == 0x2d) {
+ if (mode == 0 && vector == 0) {
+ vector = -1;
+ offset++;
+ }
+ else {
+ return F_status_set_error(F_number);
+ }
+ }
+
+ if (f_conversion_character_is_decimal(string[i]) == F_true) {
+ mode = 10;
+ break;
+ }
+
+ return F_status_set_error(F_number);
+ } // for
+
+ if (mode == 0) {
+ return F_status_set_error(F_number);
+ }
+
+ f_string_range location_offset = f_string_range_initialize;
+ location_offset.start = range.start + offset;
+ location_offset.stop = range.stop;
+
+ if (range.start + offset > range.stop) {
+ return F_status_set_error(F_number);
+ }
+
+ if (mode == 10) {
+ return fl_conversion_string_to_decimal_signed(string, number, location_offset, vector == -1);
+ }
+
+ if (mode == 16) {
+ return fl_conversion_string_to_hexidecimal_signed(string, number, location_offset, vector == -1);
+ }
+
+ if (mode == 12) {
+ return fl_conversion_string_to_duodecimal_signed(string, number, location_offset, vector == -1);
+ }
+
+ if (mode == 8) {
+ return fl_conversion_string_to_octal_signed(string, number, location_offset, vector == -1);
+ }
+
+ return fl_conversion_string_to_binary_signed(string, number, location_offset, vector == -1);
+ }
+#endif // _di_fl_conversion_string_to_number_signed_
+
+#ifndef _di_fl_conversion_string_to_number_unsigned_
+ f_return_status fl_conversion_string_to_number_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range) {
+ #ifndef _di_level_1_parameter_checking_
+ if (string == 0) return F_status_set_error(F_parameter);
+ if (number == 0) return F_status_set_error(F_parameter);
+ if (range.start > range.stop) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (string[0] == 0) {
+ return F_data_not;
+ }
+
+ uint8_t width = 0;
+ uint8_t width_max = 0;
+ uint8_t mode = 0;
+ f_string_length j = 0;
+ f_string_length offset = 0;
+ f_status status = F_none;
+ int8_t sign_found = 0;
+
+ for (f_string_length i = range.start; i <= range.stop; i++) {
+ width = f_macro_utf_byte_width_is(string[i]);
+
+ if (width == 0) {
+ if (isspace(string[i])) {
+ if (mode == 0) {
+ offset++;
+ continue;
+ }
+
+ return F_status_set_error(F_number);
+ }
+ }
+ else {
+ if (mode == 0) {
+ width_max = (range.stop - i) + 1;
+
+ status = f_utf_is_whitespace(string + i, width_max);
+
+ if (status == F_true) {
+ offset = i + 1;
+ continue;
+ }
+
+ if (F_status_is_error(status)) {
+ if (status == F_status_set_error(F_maybe)) {
+ status = F_status_set_error(F_incomplete_utf);
+ }
+
+ return status;
+ }
+ }
+
+ return F_status_set_error(F_number);
+ }
+
+ if (string[i] == 0x30) {
+ j = i + 1;
+
+ // Immediate next value must be either a number, 'x', 'X', 'd', 'D', 'o', 'O', 'b', or 'B'.
+ if (j > range.stop) {
+ *number = 0;
+ return F_none;
+ }
+ else if (string[j] > 0x29 && string[j] < 0x3a) {
+ mode = 10;
+ }
+ else if (string[j] == 0x78 || string[j] == 0x58) {
+ mode = 16;
+ offset += 2;
+ }
+ else if (string[j] == 0x44 || string[j] == 0x64) {
+ mode = 12;
+ offset += 2;
+ }
+ else if (string[j] == 0x6f || string[j] == 0x4f) {
+ mode = 8;
+ offset += 2;
+ }
+ else if (string[j] == 0x62 || string[j] == 0x42) {
+ mode = 2;
+ offset += 2;
+ }
+ else {
+ return F_status_set_error(F_number);
+ }
+
+ break;
+ }
+
+ if (string[i] == 0x2b) {
+ offset++;
+ sign_found = 1;
+ }
+
+ if (string[i] == 0x2d) {
+ offset++;
+ sign_found = -1;
+ }
+
+ if (f_conversion_character_is_decimal(string[i]) == F_true) {
+ mode = 10;
+ break;
+ }
+
+ return F_status_set_error(F_number);
+ } // for
+
+ if (mode == 0) {
+ return F_status_set_error(F_number);
+ }
+
+ f_string_range location_offset = f_string_range_initialize;
+ location_offset.start = range.start + offset;
+ location_offset.stop = range.stop;
+
+ if (range.start + offset > range.stop) {
+ return F_status_set_error(F_number);
+ }
+
+ if (mode == 10) {
+ status = fl_conversion_string_to_decimal_unsigned(string, number, location_offset);
+ }
+ else if (mode == 16) {
+ status = fl_conversion_string_to_hexidecimal_unsigned(string, number, location_offset);
+ }
+ else if (mode == 12) {
+ status = fl_conversion_string_to_duodecimal_unsigned(string, number, location_offset);
+ }
+ else if (mode == 8) {
+ status = fl_conversion_string_to_octal_unsigned(string, number, location_offset);
+ }
+ else {
+ status = fl_conversion_string_to_binary_unsigned(string, number, location_offset);
+ }
+
+ // +/- signs are not allowed.
+ if (sign_found) {
+ if (status == F_none) {
+ if (sign_found == -1) {
+ return F_status_set_error(F_number_negative);
+ }
+
+ return F_status_set_error(F_number_positive);
+ }
+
+ return F_status_set_error(F_number);
+ }
+
+ return status;
+ }
+#endif // _di_fl_conversion_string_to_number_unsigned_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Conversion
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Provide means to convert one data type to another, such as a string to an integer.
+ */
+#ifndef _FL_conversion_h
+#define _FL_conversion_h
+
+// libc includes
+#include <ctype.h>
+#include <stdlib.h>
+
+// fll-0 includes
+#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/utf.h>
+#include <level_0/conversion.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Convert a series of positive or negative binary number characters into a f_number_signed.
+ *
+ * This will stop at one of the following: location.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param location
+ * The start/stop range to convert.
+ * @param negative
+ * Set to 0 to treat string as a positive number, 1 for as a negative number.
+ *
+ * @return
+ * F_none if the binary string was converted to an signed long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-binary values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_number_underflow (with error bit) on integer underflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_binary_signed_
+ extern f_return_status fl_conversion_string_to_binary_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
+#endif // _di_fl_conversion_string_to_binary_signed_
+
+/**
+ * Convert a series of positive binary number characters into a f_number_unsigned.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ *
+ * @return
+ * F_none if the binary string was converted to an unsigned long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-binary values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_binary_unsigned_
+ extern f_return_status fl_conversion_string_to_binary_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
+#endif // _di_fl_conversion_string_to_binary_unsigned_
+
+/**
+ * Convert a series of positive or negative decimal number characters into an f_number_signed.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ * @param negative
+ * Set to 0 to treat string as a positive number, 1 for as a negative number.
+ *
+ * @return
+ * F_none if the decimal string was converted to an signed long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-decimal values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_number_underflow (with error bit) on integer underflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_decimal_signed_
+ extern f_return_status fl_conversion_string_to_decimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
+#endif // _di_fl_conversion_string_to_decimal_signed_
+
+/**
+ * Convert a series of positive decimal number characters into an f_number_unsigned.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ *
+ * @return
+ * F_none if the decimal string was converted to an unsigned long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-decimal values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_decimal_unsigned_
+ extern f_return_status fl_conversion_string_to_decimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
+#endif // _di_fl_conversion_string_to_decimal_unsigned_
+
+/**
+ * Convert a series of positive or negative duodecimal number characters into an f_number_signed.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ * @param negative
+ * Set to 0 to treat string as a positive number, 1 for as a negative number.
+ *
+ * @return
+ * F_none if the duodecimal string was converted to an signed long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-duodecimal values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_number_underflow (with error bit) on integer underflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_duodecimal_signed_
+ extern f_return_status fl_conversion_string_to_duodecimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
+#endif // _di_fl_conversion_string_to_duodecimal_signed_
+
+/**
+ * Convert a series of positive duodecimal number characters into an f_number_unsigned.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ *
+ * @return
+ * F_none if the duodecimal string was converted to an unsigned long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-duodecimal values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_duodecimal_unsigned_
+ extern f_return_status fl_conversion_string_to_duodecimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
+#endif // _di_fl_conversion_string_to_duodecimal_unsigned_
+
+/**
+ * Convert a series of positive or negative hexidecimal number characters into an f_number_signed.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ * @param negative
+ * Set to 0 to treat string as a positive number, 1 for as a negative number.
+ *
+ * @return
+ * F_none if the hexidecimal string was converted to an signed long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-hexidecimal values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_number_underflow (with error bit) on integer underflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_hexidecimal_signed_
+ extern f_return_status fl_conversion_string_to_hexidecimal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
+#endif // _di_fl_conversion_string_to_hexidecimal_signed_
+
+/**
+ * Convert a series of positive hexidecimal number characters into an f_number_unsigned.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ *
+ * @return
+ * F_none if the hexidecimal string was converted to an unsigned long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-hexidecimal values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_hexidecimal_unsigned_
+ extern f_return_status fl_conversion_string_to_hexidecimal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
+#endif // _di_fl_conversion_string_to_hexidecimal_unsigned_
+
+/**
+ * Convert a series of positive or negative octal number characters into an f_number_signed.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ * @param negative
+ * Set to 0 to treat string as a positive number, 1 for as a negative number.
+ *
+ * @return
+ * F_none if the octal string was converted to an signed long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-octal values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_octal_signed_
+ extern f_return_status fl_conversion_string_to_octal_signed(const f_string string, f_number_signed *number, const f_string_range range, const bool negative);
+#endif // _di_fl_conversion_string_to_octal_signed_
+
+/**
+ * Convert a series of positive octal number characters into an f_number_unsigned.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ *
+ * @return
+ * F_none if the octal string was converted to an unsigned long.
+ * F_data_not if string starts with a null (length is 0).
+ * F_number (with error bit) if no conversion was made due to non-octal values being found.
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_conversion_string_to_octal_unsigned_
+ extern f_return_status fl_conversion_string_to_octal_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
+#endif // _di_fl_conversion_string_to_octal_unsigned_
+
+/**
+ * Convert a series of positive or negative number characters into an f_number_signed.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will process signed statuses (+/-).
+ * This will detect based types as follows:
+ * - hexidecimals begin with either '0x' or '0X'.
+ * - duodecimals begin with either '0d' or '0D'.
+ * - octals begin with either '0o' or '0O'.
+ * - binaries begin with either '0b' or '0B'.
+ * - decimal is used for all other cases.
+ *
+ * Leading 0's and whitespace are ignored.
+ * Whitespace after the first digit is considered invalid.
+ *
+ * This function is similar to strtoll(), but the behavior of error handling and special bases are different.
+ * In particular, octals are specified here with '0b' prefix or '0B' prefix instead of the ridiculous '0' prefix.
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if string starts with a null (length is 0).
+ * F_incomplete_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_overflow (with error bit) on integer overflow.
+ * F_number_underflow (with error bit) on integer underflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * @see strtoll()
+ */
+#ifndef _di_fl_conversion_string_to_number_signed_
+ extern f_return_status fl_conversion_string_to_number_signed(const f_string string, f_number_signed *number, const f_string_range range);
+#endif // _di_fl_conversion_string_to_number_signed_
+
+/**
+ * Convert a series of positive number characters into an f_number_unsigned.
+ *
+ * This will stop at one of the following: range.stop or a non-digit.
+ * This will ignore NULL values.
+ * This will not process signed statuses (+/-).
+ * This will detect based types as follows:
+ * - hexidecimals begin with either '0x' or '0X'.
+ * - duodecimals begin with either '0d' or '0D'.
+ * - octals begin with either '0o' or '0O'.
+ * - binaries begin with either '0b' or '0B'.
+ * - decimal is used for all other cases.
+ *
+ * Leading 0's and whitespace are ignored.
+ * Whitespace after the first digit is considered invalid.
+ *
+ * This function is similar to strtoull(), but the behavior of error handling and special bases are different.
+ * In particular, octals are specified here with '0b' prefix or '0B' prefix instead of the ridiculous '0' prefix.
+ * Negative values are reported as such instead of being converted into the unsigned equivalent.
+ *
+ * @param string
+ * The string to convert.
+ * @param number
+ * This will store the value of the converted string.
+ * This value is only changed on success.
+ * @param range
+ * The start/stop range to convert.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if string starts with a null (length is 0).
+ * F_incomplete_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_positive (with error bit) on positive value (has a +, such as '+1', when only '1' is valid here).
+ * F_number_overflow (with error bit) on integer overflow.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * @see strtoull()
+ */
+#ifndef _di_fl_conversion_string_to_number_unsigned_
+ extern f_return_status fl_conversion_string_to_number_unsigned(const f_string string, f_number_unsigned *number, const f_string_range range);
+#endif // _di_fl_conversion_string_to_number_unsigned_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _FL_conversion_h
--- /dev/null
+# fss-0000
+
--- /dev/null
+# fss-0000
+
+f_type
+f_status
+f_memory
+f_string
+f_utf
+f_conversion
--- /dev/null
+# fss-0001
+
+project_name fl_conversion
+
+version_major 0
+version_minor 5
+version_micro 0
+version_target major
+
+environment
+
+process_pre
+process_post
+
+modes individual
+modes_default individual
+
+build_compiler gcc
+build_language c
+build_linker ar
+build_libraries -lc
+build_libraries-individual -lf_conversion -lf_utf -lf_memory
+build_sources_library conversion.c
+build_sources_program
+build_sources_headers conversion.h
+build_sources_script
+build_sources_setting
+build_script yes
+build_shared yes
+build_static yes
+
+path_headers level_1
+path_library_script script
+path_library_shared shared
+path_library_static static
+path_program_script script
+path_program_shared shared
+path_program_static static
+
+search_exclusive yes
+search_shared yes
+search_static yes
+
+defines_all
+defines_static
+defines_shared
+
+flags_all -z now -g
+flags_shared
+flags_static
+flags_library -fPIC
+flags_program -fPIE
#endif // __USE_XOPEN_EXTENDED
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/status_array.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#include <level_0/directory.h>
#include <level_0/file.h>
+# fss-0000
+
f_type
f_status
f_memory
extern "C" {
#endif
-#ifndef _di_fl_fss_identify_
- f_return_status fl_fss_identify(const f_string_static buffer, f_fss_header *header) {
- #ifndef _di_level_1_parameter_checking_
- if (header == 0) return F_status_set_error(F_parameter);
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
- #endif // _di_level_1_parameter_checking_
-
- return private_fl_fss_identify(buffer, header);
- }
-#endif // _di_fl_fss_identify_
-
-#ifndef _di_fl_fss_identify_file_
- f_return_status fl_fss_identify_file(f_file *file, f_fss_header *header) {
- #ifndef _di_level_1_parameter_checking_
- if (file == 0) return F_status_set_error(F_parameter);
- if (header == 0) return F_status_set_error(F_parameter);
- if (file->id == 0) return F_status_set_error(F_file_closed);
- if (file->id < 0) return F_status_set_error(F_file);
- #endif // _di_level_1_parameter_checking_
-
- {
- f_string_length seeked = 0;
- if (F_status_is_error(f_file_seek(file->id, SEEK_SET, 0, &seeked))) {
- return F_status_set_error(F_file_seek);
- }
- }
-
- f_status status = F_none;
- f_string_dynamic buffer = f_string_dynamic_initialize;
-
- f_macro_string_dynamic_resize(status, buffer, f_fss_max_header_length + 1);
- if (F_status_is_error(status)) return status;
-
- status = f_file_read_until(*file, &buffer, f_fss_max_header_length + 1);
- if (F_status_is_error(status)) return status;
-
- return private_fl_fss_identify(buffer, header);
- }
-#endif // _di_fl_fss_identify_file_
-
#ifdef __cplusplus
} // extern "C"
#endif
#include <string.h>
// fll-0 includes
-#include <level_0/conversion.h>
+#include <level_0/type.h>
#include <level_0/status.h>
-#include <level_0/file.h>
-#include <level_0/fss.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
+#include <level_0/file.h>
+#include <level_0/fss.h>
// fll-1 includes
#include <level_1/fss_status.h>
extern "C" {
#endif
-/**
- * Identify FSS type from a buffered string.
- *
- * @param buffer
- * The string to process.
- * @param header
- * The header data to populate with results of this function.
- *
- * @return
- * F_none on success
- * FL_fss_header_not if no header is found.
- * FL_fss_accepted_invalid (with warning bit) if header is technically invalid but can be identified.
- * FL_fss_header_not (with error bit) if the an error occurred prior to identifying a valid header.
- *
- * Errors from (with error bit): f_conversion_string_to_hexidecimal_unsigned().
- */
-#ifndef _di_fl_fss_identify_
- extern f_return_status fl_fss_identify(const f_string_static buffer, f_fss_header *header);
-#endif // _di_fl_fss_identify_
-
-/**
- * Identify FSS type from a file.
- *
- * @param file
- * The file information.
- * @param header
- * The header data to populate with results of this function.
- *
- * @return
- * F_none on success.
- * FL_fss_header_not if no header is found.
- * FL_fss_accepted_invalid (with warning bit) if header is technically invalid but can be identified.
- * F_memory_reallocation (with error bit) on memory reallocation error.
- * F_parameter (with error bit) if a parameter is invalid.
- * FL_fss_header_not (with error bit) if the an error occurred prior to identifying a valid header.
- *
- * Errors from (with error bit): f_conversion_string_to_hexidecimal_unsigned().
- * Errors from (with error bit): f_file_read_until().
- * Errors from (with error bit): f_file_seek().
- *
- * @see f_file_read_until()
- * @see fl_fss_identify()
- */
-#ifndef _di_fl_fss_identify_file_
- extern f_return_status fl_fss_identify_file(f_file *file, f_fss_header *header);
-#endif // _di_fl_fss_identify_file_
-
#ifdef __cplusplus
} // extern "C"
#endif
extern "C" {
#endif
-#if !defined(_di_fl_fss_identify_) || !defined(_di_fl_fss_identify_file_)
- f_return_status private_fl_fss_identify(const f_string_static buffer, f_fss_header *header) {
- register f_string_length i = 0;
-
- if (buffer.used < 10) {
- // "# fss-0000" is always at least 10 characters.
- return FL_fss_header_not;
- }
-
- // If this correctly follows the FSS specification, then this should be all that needs to be done (as well as atoh for ascii to hex).
- // All characters used in the identifier are only in the ascii equivalents of the characters, any similarly looking character or number representing in UTF-8 is considered invalid.
- if (buffer.string[i] == f_fss_type_header_open) {
- i++;
-
- if (buffer.string[i] == f_fss_type_header_part1) {
- i++;
-
- if (buffer.string[i] == f_fss_type_header_part2) {
- i++;
-
- if (buffer.string[i] == f_fss_type_header_part3) {
- i++;
-
- if (buffer.string[i] == f_fss_type_header_part4) {
- i++;
-
- if (buffer.string[i] == f_fss_type_header_part5) {
- i++;
-
- if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
- i++;
-
- if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
- i++;
-
- if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
- i++;
-
- if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
- i++;
-
- f_string_range range = f_string_range_initialize;
-
- range.start = i - 4;
- range.stop = i;
-
- // 1: A possibly valid header type was found, now convert it into its proper format and save the header type.
- const f_status status = f_conversion_string_to_hexidecimal_unsigned(buffer.string, &header->type, range);
- if (F_status_is_error(status)) return status;
-
- if (status == F_none) {
- // 2: At this point, we can still know the proper format for the file and still have a invalid header, handle accordingly.
- if (buffer.string[i] == f_fss_type_header_close) {
- header->length = i + 1;
-
- return F_none;
- }
- else {
- // if "# fss-0000" is there, regardless of whats next, we can guess this to be of fss-0000, even if its fss-00001 (this is a guess afterall).
- header->length = i + 1;
-
- return F_status_set_warning(FL_fss_accepted_invalid);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- // people can miss spaces, so lets accept in an attempt to interpret the file anyway, but return values at this point are to be flagged as invalid.
- else if (buffer.string[i] == f_fss_type_header_part2) {
- i++;
-
- if (buffer.string[i] == f_fss_type_header_part3) {
- i++;
-
- if (buffer.string[i] == f_fss_type_header_part4) {
- i++;
-
- if (buffer.string[i] == f_fss_type_header_part5) {
- i++;
-
- if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
- i++;
-
- if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
- i++;
-
- if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
- i++;
-
- if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
- i++;
-
- f_string_range range = f_string_range_initialize;
-
- range.start = i - 4;
- range.stop = i;
-
- const f_status status = f_conversion_string_to_hexidecimal_unsigned(buffer.string, &header->type, range);
- if (F_status_is_error(status)) return status;
-
- header->length = i + 1;
-
- return F_status_set_warning(FL_fss_accepted_invalid);
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- // @todo At some point add checksum and compressions checks here, but the above statements will have to be adjusted accordingly.
- // 3: eventually this will be processing the checksum and 4: will be processing the compression.
-
- return FL_fss_header_not;
- }
-#endif // !defined(_di_fl_fss_identify_) || !defined(_di_fl_fss_identify_file_)
-
#if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_)
f_return_status private_fl_fss_basic_object_read(const bool is_basic, f_string_dynamic *buffer, f_string_range *range, f_fss_object *found) {
f_status status = F_none;
#endif
/**
- * Private implementation of fl_fss_identify().
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param buffer
- * The string to process.
- * @param header
- * The header data to populate with results of this function.
- *
- * @return
- * F_none on success
- * FL_fss_header_not if no header is found.
- * FL_fss_accepted_invalid (with warning bit) if header is technically invalid but can be identified.
- * FL_fss_header_not (with error bit) if the an error occurred prior to identifying a valid header.
- *
- * Errors from (with error bit): f_conversion_string_to_hexidecimal_unsigned().
- *
- * @see fl_fss_identify()
- * @see fl_fss_identify_file()
- */
-#if !defined(_di_fl_fss_identify_) || !defined(_di_fl_fss_identify_file_)
- extern f_return_status private_fl_fss_identify(const f_string_static buffer, f_fss_header *header) f_gcc_attribute_visibility_internal;
-#endif // !defined(_di_fl_fss_identify_) || !defined(_di_fl_fss_identify_file_)
-
-/**
* Private implementation of fl_fss_basic_object_read().
*
* Intended to be shared to each of the different implementation variations.
+# fss-0000
+
f_type
f_status
f_memory
f_string
f_utf
-f_conversion
f_file
f_fss
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lf_fss -lf_file -lf_conversion -lf_utf -lf_memory
+build_libraries-individual -lf_fss -lf_file -lf_utf -lf_memory
build_sources_library fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c
build_sources_program
build_sources_headers fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_macro.h fss_status.h
#include <sys/stat.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#include <level_0/iki.h>
#endif
/**
- * Read all iki Vocabulary and Content in the given range of the given buffer.
+ * Read all IKI Vocabulary and Content in the given range of the given buffer.
*
* This does not verify if any vocabulary name is known.
* This only finds complete vocabulary names and their respective content.
+# fss-0000
+
f_type
f_status
f_memory
build_shared yes
build_static yes
-path_headers level_0
+path_headers level_1
path_library_script script
path_library_shared shared
path_library_static static
#define _FL_print_h
// fll-0 includes
-#include <level_0/conversion.h>
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
+#include <level_0/conversion.h>
#ifdef __cplusplus
extern "C" {
+# fss-0000
+
f_type
f_status
f_memory
#define _FL_status_h
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#ifdef __cplusplus
+# fss-0000
+
f_type
f_status
+f_memory
f_string
f_utf
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#ifdef __cplusplus
+# fss-0000
+
f_type
f_status
f_memory
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#ifdef __cplusplus
+# fss-0000
+
f_type
f_status
f_memory
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
#include <level_0/file.h>
+# fss-0000
+
f_type
f_status
f_memory
#include <unistd.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
+#include <level_0/utf.h>
#include <level_0/environment.h>
#include <level_0/file.h>
#include <level_0/path.h>
+# fss-0000
+
f_type
f_status
f_memory
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfl_string -lf_path -lf_utf -lf_file -lf_environment -lf_memory
+build_libraries-individual -lfl_string -lf_utf -lf_path -lf_file -lf_environment -lf_memory
build_sources_library execute.c private-execute.c
build_sources_program
build_sources_headers execute.h
#include <stdio.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
-#include <level_0/utf.h>
// fll-1 includes
#include <level_1/color.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
-f_utf
fl_color
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfl_color -lf_print -lf_file -lf_utf -lf_memory
+build_libraries-individual -lfl_color -lf_print -lf_file -lf_memory
build_sources_library file.c
build_sources_program
build_sources_headers file.h
#include <level_2/fss.h>
+#include "private-fss.h"
#ifdef __cplusplus
extern "C" {
#endif
+#ifndef _di_fll_fss_identify_
+ f_return_status fll_fss_identify(const f_string_static buffer, f_fss_header *header) {
+ #ifndef _di_level_2_parameter_checking_
+ if (header == 0) return F_status_set_error(F_parameter);
+ if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ #endif // _di_level_2_parameter_checking_
+
+ return private_fll_fss_identify(buffer, header);
+ }
+#endif // _di_fll_fss_identify_
+
+#ifndef _di_fll_fss_identify_file_
+ f_return_status fll_fss_identify_file(f_file *file, f_fss_header *header) {
+ #ifndef _di_level_2_parameter_checking_
+ if (file == 0) return F_status_set_error(F_parameter);
+ if (header == 0) return F_status_set_error(F_parameter);
+ if (file->id == 0) return F_status_set_error(F_file_closed);
+ if (file->id < 0) return F_status_set_error(F_file);
+ #endif // _di_level_2_parameter_checking_
+
+ {
+ f_string_length seeked = 0;
+ if (F_status_is_error(f_file_seek(file->id, SEEK_SET, 0, &seeked))) {
+ return F_status_set_error(F_file_seek);
+ }
+ }
+
+ f_status status = F_none;
+ f_string_dynamic buffer = f_string_dynamic_initialize;
+
+ f_macro_string_dynamic_resize(status, buffer, f_fss_max_header_length + 1);
+ if (F_status_is_error(status)) return status;
+
+ status = f_file_read_until(*file, &buffer, f_fss_max_header_length + 1);
+ if (F_status_is_error(status)) return status;
+
+ return private_fll_fss_identify(buffer, header);
+ }
+#endif // _di_fll_fss_identify_file_
+
#ifndef _di_fll_fss_snatch_
f_return_status fll_fss_snatch(const f_string_static buffer, const f_fss_objects objects, const f_fss_contents contents, const f_string names[], const f_string_length lengths[], const f_string_length size, f_string_dynamic *values[]) {
#ifndef _di_level_2_parameter_checking_
#define _FLL_fss_h
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
-#include <level_0/fss.h>
#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
+#include <level_0/fss.h>
// fll-1 includes
+#include <level_1/conversion.h>
#include <level_1/fss.h>
#include <level_1/fss_macro.h>
#include <level_1/fss_status.h>
#endif
/**
+ * Identify FSS type from a buffered string.
+ *
+ * @param buffer
+ * The string to process.
+ * @param header
+ * The header data to populate with results of this function.
+ *
+ * @return
+ * F_none on success
+ * FL_fss_header_not if no header is found.
+ * FL_fss_accepted_invalid (with warning bit) if header is technically invalid but can be identified.
+ * FL_fss_header_not (with error bit) if the an error occurred prior to identifying a valid header.
+ *
+ * Errors from (with error bit): fl_conversion_string_to_hexidecimal_unsigned().
+ */
+#ifndef _di_fll_fss_identify_
+ extern f_return_status fll_fss_identify(const f_string_static buffer, f_fss_header *header);
+#endif // _di_fll_fss_identify_
+
+/**
+ * Identify FSS type from a file.
+ *
+ * @param file
+ * The file information.
+ * @param header
+ * The header data to populate with results of this function.
+ *
+ * @return
+ * F_none on success.
+ * FL_fss_header_not if no header is found.
+ * FL_fss_accepted_invalid (with warning bit) if header is technically invalid but can be identified.
+ * F_memory_reallocation (with error bit) on memory reallocation error.
+ * F_parameter (with error bit) if a parameter is invalid.
+ * FL_fss_header_not (with error bit) if the an error occurred prior to identifying a valid header.
+ *
+ * Errors from (with error bit): fl_conversion_string_to_hexidecimal_unsigned().
+ * Errors from (with error bit): f_file_read_until().
+ * Errors from (with error bit): f_file_seek().
+ *
+ * @see f_file_read_until()
+ */
+#ifndef _di_fll_fss_identify_file_
+ extern f_return_status fll_fss_identify_file(f_file *file, f_fss_header *header);
+#endif // _di_fll_fss_identify_file_
+
+/**
* Perform simple search through all objects against the given set, saving all values when matched.
*
* Only the first match for each distinct object is snatched.
--- /dev/null
+#include <level_2/fss.h>
+#include "private-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_di_fll_fss_identify_) || !defined(_di_fll_fss_identify_file_)
+ f_return_status private_fll_fss_identify(const f_string_static buffer, f_fss_header *header) {
+ register f_string_length i = 0;
+
+ if (buffer.used < 10) {
+ // "# fss-0000" is always at least 10 characters.
+ return FL_fss_header_not;
+ }
+
+ // If this correctly follows the FSS specification, then this should be all that needs to be done (as well as atoh for ascii to hex).
+ // All characters used in the identifier are only in the ascii equivalents of the characters, any similarly looking character or number representing in UTF-8 is considered invalid.
+ if (buffer.string[i] == f_fss_type_header_open) {
+ i++;
+
+ if (buffer.string[i] == f_fss_type_header_part1) {
+ i++;
+
+ if (buffer.string[i] == f_fss_type_header_part2) {
+ i++;
+
+ if (buffer.string[i] == f_fss_type_header_part3) {
+ i++;
+
+ if (buffer.string[i] == f_fss_type_header_part4) {
+ i++;
+
+ if (buffer.string[i] == f_fss_type_header_part5) {
+ i++;
+
+ if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
+ i++;
+
+ if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
+ i++;
+
+ if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
+ i++;
+
+ if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
+ i++;
+
+ f_string_range range = f_string_range_initialize;
+
+ range.start = i - 4;
+ range.stop = i;
+
+ // 1: A possibly valid header type was found, now convert it into its proper format and save the header type.
+ const f_status status = fl_conversion_string_to_hexidecimal_unsigned(buffer.string, &header->type, range);
+ if (F_status_is_error(status)) return status;
+
+ if (status == F_none) {
+ // 2: At this point, we can still know the proper format for the file and still have a invalid header, handle accordingly.
+ if (buffer.string[i] == f_fss_type_header_close) {
+ header->length = i + 1;
+
+ return F_none;
+ }
+ else {
+ // @todo this needs to be changed to support sub-headers (maybe something like FL_fss_accepted_additional).
+ // if "# fss-0000" is there, regardless of whats next, we can guess this to be of fss-0000, even if its fss-00001 (this is a guess afterall).
+ header->length = i + 1;
+
+ return F_status_set_warning(FL_fss_accepted_invalid);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ // people can miss spaces, so lets accept in an attempt to interpret the file anyway, but return values at this point are to be flagged as invalid.
+ else if (buffer.string[i] == f_fss_type_header_part2) {
+ i++;
+
+ if (buffer.string[i] == f_fss_type_header_part3) {
+ i++;
+
+ if (buffer.string[i] == f_fss_type_header_part4) {
+ i++;
+
+ if (buffer.string[i] == f_fss_type_header_part5) {
+ i++;
+
+ if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
+ i++;
+
+ if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
+ i++;
+
+ if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
+ i++;
+
+ if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
+ // @todo this needs to be changed to support sub-headers (maybe something like FL_fss_accepted_additional).
+ i++;
+
+ f_string_range range = f_string_range_initialize;
+
+ range.start = i - 4;
+ range.stop = i;
+
+ const f_status status = fl_conversion_string_to_hexidecimal_unsigned(buffer.string, &header->type, range);
+ if (F_status_is_error(status)) return status;
+
+ header->length = i + 1;
+
+ return F_status_set_warning(FL_fss_accepted_invalid);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // @todo At some point add checksum and compressions checks here, but the above statements will have to be adjusted accordingly.
+ // 3: eventually this will be processing the checksum and 4: will be processing the compression.
+
+ return FL_fss_header_not;
+ }
+#endif // !defined(_di_fll_fss_identify_) || !defined(_di_fll_fss_identify_file_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 2
+ *
+ * Project: FSS
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * These are provided for internal reduction in redundant code.
+ * These should not be exposed/used outside of this project.
+ */
+#ifndef _PRIVATE_FLL_fss_h
+#define _PRIVATE_FLL_fss_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Private implementation of fll_fss_identify().
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param buffer
+ * The string to process.
+ * @param header
+ * The header data to populate with results of this function.
+ *
+ * @return
+ * F_none on success
+ * FL_fss_header_not if no header is found.
+ * FL_fss_accepted_invalid (with warning bit) if header is technically invalid but can be identified.
+ * FL_fss_header_not (with error bit) if the an error occurred prior to identifying a valid header.
+ *
+ * Errors from (with error bit): fl_conversion_string_to_hexidecimal_unsigned().
+ *
+ * @see fll_fss_identify()
+ * @see fll_fss_identify_file()
+ */
+#if !defined(_di_fll_fss_identify_) || !defined(_di_fll_fss_identify_file_)
+ extern f_return_status private_fll_fss_identify(const f_string_static buffer, f_fss_header *header) f_gcc_attribute_visibility_internal;
+#endif // !defined(_di_fll_fss_identify_) || !defined(_di_fll_fss_identify_file_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_FLL_fss_h
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_conversion
f_fss
-f_utf
+fl_conversion
fl_fss
fl_status
fl_string
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfl_string -lfl_status -lfl_fss -lf_file -lf_fss -lf_conversion -lf_utf -lf_memory
-build_sources_library fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c fss_status.c
+build_libraries-individual -lfl_string -lfl_status -lfl_fss -lf_file -lfl_conversion -lf_fss -lf_conversion -lf_utf -lf_memory
+build_sources_library fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c fss_status.c
build_sources_program
build_sources_headers fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_status.h
build_sources_script
#include <stdio.h>
// fll-0 includes
-#include <level_0/console.h>
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
+#include <level_0/utf.h>
+#include <level_0/console.h>
// fll-1 includes
#include <level_1/color.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_console
fl_color
fl_string
#define _FLL_status_h
// fll-0 includes
-#include <level_0/conversion.h>
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
#include <level_0/utf.h>
+#include <level_0/conversion.h>
// fll-1 includes
#include <level_1/string.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
-f_conversion
f_utf
+f_conversion
fl_status
fl_string
return F_status_set_error(status);
}
else if (data->parameters[byte_dump_parameter_width].result == f_console_result_additional) {
+ const f_string_length index = data->parameters[byte_dump_parameter_width].additional.array[data->parameters[byte_dump_parameter_width].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+
f_number_unsigned number = 0;
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[byte_dump_parameter_width].additional.array[data->parameters[byte_dump_parameter_width].additional.used - 1]], &number);
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range);
if (F_status_is_error(status) || number < 1 || number >= 0xfb) {
fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '");
fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_width);
return F_status_set_error(status);
}
else if (data->parameters[byte_dump_parameter_first].result == f_console_result_additional) {
+ const f_string_length index = data->parameters[byte_dump_parameter_first].additional.array[data->parameters[byte_dump_parameter_first].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+
f_number_unsigned number = 0;
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[byte_dump_parameter_first].additional.array[data->parameters[byte_dump_parameter_first].additional.used - 1]], &number);
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range);
if (F_status_is_error(status) || number > f_type_number_size_unsigned) {
fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '");
fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_first);
return F_status_set_error(status);
}
else if (data->parameters[byte_dump_parameter_last].result == f_console_result_additional) {
+ const f_string_length index = data->parameters[byte_dump_parameter_last].additional.array[data->parameters[byte_dump_parameter_last].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+
f_number_unsigned number = 0;
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[byte_dump_parameter_last].additional.array[data->parameters[byte_dump_parameter_last].additional.used - 1]], &number);
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range);
if (F_status_is_error(status) || number < 0 || number > f_type_number_size_unsigned) {
fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The parameter '");
fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, byte_dump_long_last);
#include <unistd.h>
// fll-0 includes
+#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/conversion.h>
#include <level_0/file.h>
#include <level_0/pipe.h>
#include <level_0/print.h>
-#include <level_0/status.h>
-#include <level_0/string.h>
-#include <level_0/type.h>
-#include <level_0/utf.h>
// fll-1 includes
#include <level_1/color.h>
#include <level_1/console.h>
+#include <level_1/conversion.h>
#include <level_1/string.h>
#include <level_1/utf.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_conversion
f_file
f_pipe
f_print
-f_utf
fl_color
fl_console
+fl_conversion
fl_string
fl_utf
fll_program
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfl_utf -lfl_string -lfl_console -lfl_color -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfl_utf -lfl_string -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library byte_dump.c private-byte_dump.c
#include <unistd.h>
// fll-0 includes
+#include <level_0/type.h>
#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
-#include <level_0/type.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/directory.h>
#include <level_0/file.h>
f_print
fl_color
fl_console
+fl_conversion
fl_directory
fl_fss
fl_iki
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_execute -lfll_fss -lfl_utf -lfl_string -lfl_status -lfl_iki -lfl_fss -lfl_directory -lfl_console -lfl_color -lf_print -lf_path -lf_iki -lf_file -lf_fss -lf_environment -lf_directory -lf_conversion -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_execute -lfll_fss -lfl_utf -lfl_string -lfl_status -lfl_iki -lfl_fss -lfl_directory -lfl_conversion -lfl_console -lfl_color -lf_print -lf_path -lf_iki -lf_file -lf_fss -lf_environment -lf_directory -lf_conversion -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fake.c private-fake.c private-clean.c private-build.c private-make.c private-print.c private-skeleton.c
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
+#include <level_0/type_array.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/directory.h>
#include <level_0/file.h>
#include <level_0/pipe.h>
#include <level_0/print.h>
-#include <level_0/string.h>
-#include <level_0/type.h>
-#include <level_0/type_array.h>
// fll-1 includes
#include <level_1/color.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_path
f_pipe
f_print
-f_utf
fl_color
fl_console
+fl_conversion
fl_fss
fl_status
fl_string
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_path -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_path -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library firewall.c private-firewall.c
// fll-0 includes
#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/directory.h>
#include <level_0/file.h>
// fll-1 includes
#include <level_1/color.h>
#include <level_1/console.h>
+#include <level_1/conversion.h>
#include <level_1/print.h>
#include <level_1/string.h>
else {
position_depth = data.parameters[fss_basic_list_read_parameter_depth].additional.array[i];
- status = fl_console_parameter_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth);
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[position_depth]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range);
if (F_status_is_error(status)) {
- fss_basic_list_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_basic_list_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status));
+ fss_basic_list_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_basic_list_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status));
return status;
}
}
depths->array[i].index_at = data.parameters[fss_basic_list_read_parameter_at].additional.array[position_at];
- status = fl_console_parameter_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at);
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[depths->array[i].index_at]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range);
if (F_status_is_error(status)) {
- fss_basic_list_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_basic_list_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status));
+ fss_basic_list_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_basic_list_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status));
return status;
}
} // for
f_string_length select = 0;
if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_basic_list_read_parameter_select].additional.array[data->parameters[fss_basic_list_read_parameter_select].additional.used - 1]], &select);
+ const f_string_length index = data->parameters[fss_basic_list_read_parameter_select].additional.array[data->parameters[fss_basic_list_read_parameter_select].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
if (F_status_is_error(status)) {
- fss_basic_list_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_basic_list_read_long_select, arguments.argv[data->parameters[fss_basic_list_read_parameter_select].additional.array[0]], F_status_set_fine(status));
+ fss_basic_list_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_basic_list_read_long_select, arguments.argv[index], F_status_set_fine(status));
return status;
}
f_string_length line = 0;
if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[data->parameters[fss_basic_list_read_parameter_line].additional.used - 1]], &line);
+ const f_string_length index = data->parameters[fss_basic_list_read_parameter_line].additional.array[data->parameters[fss_basic_list_read_parameter_line].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
if (F_status_is_error(status)) {
- fss_basic_list_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_basic_list_read_long_line, arguments.argv[data->parameters[fss_basic_list_read_parameter_line].additional.array[0]], F_status_set_fine(status));
+ fss_basic_list_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_basic_list_read_long_line, arguments.argv[index], F_status_set_fine(status));
return status;
}
}
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_print
fl_color
fl_console
+fl_conversion
fl_fss
fl_print
fl_status
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fss_basic_list_read.c private-fss_basic_list_read.c
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/file.h>
#include <level_0/pipe.h>
#include <level_0/print.h>
-#include <level_0/string.h>
-#include <level_0/type.h>
// fll-1 includes
#include <level_1/color.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_print
fl_color
fl_console
+fl_conversion
fl_fss
fl_status
fl_string
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fss_basic_list_write.c
// fll-0 includes
#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/directory.h>
#include <level_0/file.h>
// fll-1 includes
#include <level_1/color.h>
#include <level_1/console.h>
+#include <level_1/conversion.h>
#include <level_1/print.h>
#include <level_1/string.h>
else {
position_depth = data.parameters[fss_basic_read_parameter_depth].additional.array[i];
- status = fl_console_parameter_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth);
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[position_depth]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range);
if (F_status_is_error(status)) {
- fss_basic_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_basic_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status));
+ fss_basic_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_basic_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status));
return status;
}
}
depths->array[i].index_at = data.parameters[fss_basic_read_parameter_at].additional.array[position_at];
- status = fl_console_parameter_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at);
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[depths->array[i].index_at]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range);
if (F_status_is_error(status)) {
- fss_basic_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_basic_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status));
+ fss_basic_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_basic_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status));
return status;
}
} // for
f_string_length select = 0;
if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_basic_read_parameter_select].additional.array[data->parameters[fss_basic_read_parameter_select].additional.used - 1]], &select);
+ const f_string_length index = data->parameters[fss_basic_read_parameter_select].additional.array[data->parameters[fss_basic_read_parameter_select].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
if (F_status_is_error(status)) {
- fss_basic_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_basic_read_long_select, arguments.argv[data->parameters[fss_basic_read_parameter_select].additional.array[0]], F_status_set_fine(status));
+ fss_basic_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_basic_read_long_select, arguments.argv[index], F_status_set_fine(status));
return status;
}
f_string_length line = 0;
if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_basic_read_parameter_line].additional.array[data->parameters[fss_basic_read_parameter_line].additional.used - 1]], &line);
+ const f_string_length index = data->parameters[fss_basic_read_parameter_line].additional.array[data->parameters[fss_basic_read_parameter_line].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
if (F_status_is_error(status)) {
- fss_basic_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_basic_read_long_line, arguments.argv[data->parameters[fss_basic_read_parameter_line].additional.array[0]], F_status_set_fine(status));
+ fss_basic_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_basic_read_long_line, arguments.argv[index], F_status_set_fine(status));
return status;
}
}
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_print
fl_color
fl_console
+fl_conversion
fl_fss
fl_print
fl_status
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fss_basic_read.c private-fss_basic_read.c
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/file.h>
#include <level_0/pipe.h>
#include <level_0/print.h>
-#include <level_0/string.h>
-#include <level_0/type.h>
// fll-1 includes
#include <level_1/color.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_print
fl_color
fl_console
+fl_conversion
fl_fss
fl_status
fl_string
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fss_basic_write.c
// fll-0 includes
#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/directory.h>
#include <level_0/file.h>
// fll-1 includes
#include <level_1/color.h>
#include <level_1/console.h>
+#include <level_1/conversion.h>
#include <level_1/print.h>
#include <level_1/string.h>
else {
position_depth = data.parameters[fss_extended_list_read_parameter_depth].additional.array[i];
- status = fl_console_parameter_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth);
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[position_depth]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range);
if (F_status_is_error(status)) {
- fss_extended_list_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_extended_list_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status));
+ fss_extended_list_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_extended_list_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status));
return status;
}
}
depths->array[i].index_at = data.parameters[fss_extended_list_read_parameter_at].additional.array[position_at];
- status = fl_console_parameter_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at);
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[depths->array[i].index_at]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range);
if (F_status_is_error(status)) {
- fss_extended_list_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_extended_list_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status));
+ fss_extended_list_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_extended_list_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status));
return status;
}
} // for
f_string_length select = 0;
if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_extended_list_read_parameter_select].additional.array[data->parameters[fss_extended_list_read_parameter_select].additional.used - 1]], &select);
+ const f_string_length index = data->parameters[fss_extended_list_read_parameter_select].additional.array[data->parameters[fss_extended_list_read_parameter_select].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
if (F_status_is_error(status)) {
- fss_extended_list_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_extended_list_read_long_select, arguments.argv[data->parameters[fss_extended_list_read_parameter_select].additional.array[0]], F_status_set_fine(status));
+ fss_extended_list_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_extended_list_read_long_select, arguments.argv[index], F_status_set_fine(status));
return status;
}
f_string_length line = 0;
if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_extended_list_read_parameter_line].additional.array[data->parameters[fss_extended_list_read_parameter_line].additional.used - 1]], &line);
+ const f_string_length index = data->parameters[fss_extended_list_read_parameter_line].additional.array[data->parameters[fss_extended_list_read_parameter_line].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ f_number_unsigned number = 0;
+
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range);
if (F_status_is_error(status)) {
- fss_extended_list_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_extended_list_read_long_line, arguments.argv[data->parameters[fss_extended_list_read_parameter_line].additional.array[0]], F_status_set_fine(status));
+ fss_extended_list_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_extended_list_read_long_line, arguments.argv[index], F_status_set_fine(status));
return status;
}
}
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_print
fl_color
fl_console
+fl_conversion
fl_fss
fl_print
fl_status
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_conversion -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fss_extended_list_read.c private-fss_extended_list_read.c
// fll-0 includes
#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/directory.h>
#include <level_0/file.h>
// fll-1 includes
#include <level_1/color.h>
#include <level_1/console.h>
+#include <level_1/conversion.h>
#include <level_1/print.h>
#include <level_1/string.h>
else {
position_depth = data.parameters[fss_extended_read_parameter_depth].additional.array[i];
- status = fl_console_parameter_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth);
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[position_depth]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range);
if (F_status_is_error(status)) {
- fss_extended_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_extended_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status));
+ fss_extended_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_extended_read_long_depth, arguments.argv[position_depth], F_status_set_fine(status));
return status;
}
}
depths->array[i].index_at = data.parameters[fss_extended_read_parameter_at].additional.array[position_at];
- status = fl_console_parameter_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at);
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[depths->array[i].index_at]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range);
if (F_status_is_error(status)) {
- fss_extended_read_print_number_argument_error(data.context, "fl_console_parameter_to_number_unsigned", fss_extended_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status));
+ fss_extended_read_print_number_argument_error(data.context, "fl_conversion_string_to_number_unsigned", fss_extended_read_long_at, arguments.argv[depths->array[i].index_at], F_status_set_fine(status));
return status;
}
} // for
f_string_length select = 0;
if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_extended_read_parameter_select].additional.array[data->parameters[fss_extended_read_parameter_select].additional.used - 1]], &select);
+ const f_string_length index = data->parameters[fss_extended_read_parameter_select].additional.array[data->parameters[fss_extended_read_parameter_select].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
if (F_status_is_error(status)) {
- fss_extended_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_extended_read_long_select, arguments.argv[data->parameters[fss_extended_read_parameter_select].additional.array[0]], F_status_set_fine(status));
+ fss_extended_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_extended_read_long_select, arguments.argv[index], F_status_set_fine(status));
return status;
}
}
f_string_length line = 0;
if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) {
- status = fl_console_parameter_to_number_unsigned(arguments.argv[data->parameters[fss_extended_read_parameter_line].additional.array[data->parameters[fss_extended_read_parameter_line].additional.used - 1]], &line);
+ const f_string_length index = data->parameters[fss_extended_read_parameter_line].additional.array[data->parameters[fss_extended_read_parameter_line].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
if (F_status_is_error(status)) {
- fss_extended_read_print_number_argument_error(data->context, "fl_console_parameter_to_number_unsigned", fss_extended_read_long_line, arguments.argv[data->parameters[fss_extended_read_parameter_line].additional.array[0]], F_status_set_fine(status));
+ fss_extended_read_print_number_argument_error(data->context, "fl_conversion_string_to_number_unsigned", fss_extended_read_long_line, arguments.argv[index], F_status_set_fine(status));
return status;
}
}
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_pipe
f_print
fl_color
+fl_conversion
fl_console
fl_fss
fl_print
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_print -lfl_fss -lfl_console -lfl_conversion -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fss_extended_read.c private-fss_extended_read.c
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/file.h>
#include <level_0/pipe.h>
#include <level_0/print.h>
-#include <level_0/string.h>
-#include <level_0/type.h>
// fll-1 includes
#include <level_1/color.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_pipe
f_print
fl_color
+fl_conversion
fl_fss
fl_status
fl_string
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_string -lfl_status -lfl_fss -lfl_conversion -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fss_extended_write.c
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/conversion.h>
#include <level_0/console.h>
#include <level_0/pipe.h>
#include <level_0/print.h>
-#include <level_0/status.h>
-#include <level_0/string.h>
-#include <level_0/type.h>
// fll-1 includes
#include <level_1/color.h>
#include <level_1/console.h>
+#include <level_1/conversion.h>
#include <level_1/status.h>
#include <level_1/string.h>
f_status status = F_none;
{
+ const f_string_range range = f_macro_string_range_initialize(strlen(value));
+
f_number_unsigned number = 0;
- status = fl_console_parameter_to_number_unsigned(value, &number);
+ status = fl_conversion_string_to_number_unsigned(value, &number, range);
if (status == F_none) {
fl_color_print_line(f_type_output, data.context.error, data.context.reset, "invalid name");
#ifndef _di_fss_status_code_convert_number_
f_return_status fss_status_code_convert_number(const fss_status_code_data data, const f_string value, f_number_unsigned *number) {
- f_status status = fl_console_parameter_to_number_unsigned(value, number);
+ const f_string_range range = f_macro_string_range_initialize(strlen(value));
+
+ f_status status = fl_conversion_string_to_number_unsigned(value, number, range);
if (*number > F_status_size_max_with_signal) {
fl_color_print_line(f_type_output, data.context.error, data.context.reset, "out of range");
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_conversion
f_fss
f_pipe
f_print
-f_utf
fl_color
fl_console
+fl_conversion
fl_fss
fl_status
fl_string
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_status -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_utf -lfl_string -lfl_status -lfl_fss -lfl_console -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_conversion -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_status -lfll_program -lfll_fss -lfll_file -lfll_execute -lf_path -lfl_utf -lfl_string -lfl_status -lfl_fss -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_conversion -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library fss_status_code.c private-fss_status_code.c
}
else if (data->parameters[iki_read_parameter_line].result == f_console_result_additional) {
const f_string_length index = data->parameters[iki_read_parameter_line].additional.array[data->parameters[iki_read_parameter_line].additional.used - 1];
+ const f_string_range range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
- status = fl_console_parameter_to_number_unsigned(arguments.argv[index], &data->line);
+ f_number_unsigned number = 0;
+
+ status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range);
if (F_status_is_error(status)) {
- iki_read_print_error_number_argument(data->context, data->verbosity, F_status_set_fine(status), "fl_console_parameter_to_number_unsigned", iki_read_long_line, arguments.argv[index]);
+ iki_read_print_error_number_argument(data->context, data->verbosity, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", iki_read_long_line, arguments.argv[index]);
fprintf(f_type_error, "%c", f_string_eol[0]);
iki_read_delete_data(data);
return F_status_set_error(F_parameter);
}
- // additional
+ data->line = number;
+
+ // additional @todo
}
if (data->parameters[iki_read_parameter_name].result == f_console_result_found) {
// fll-0 includes
#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/conversion.h>
#include <level_0/file.h>
// fll-1 includes
#include <level_1/color.h>
#include <level_1/console.h>
+#include <level_1/conversion.h>
#include <level_1/iki.h>
#include <level_1/print.h>
#include <level_1/string.h>
+# fss-0000
+
f_type
f_status
f_memory
f_print
fl_color
fl_console
+fl_conversion
fl_iki
fl_string
fl_utf
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_file -lfl_string -lfl_status -lfl_print -lfl_iki -lfl_fss -lfl_console -lfl_color -lf_print -lf_pipe -lf_path -lf_iki -lf_fss -lf_file -lf_environment -lf_conversion -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_file -lfl_utf -lfl_string -lfl_iki -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_iki -lf_file -lf_conversion -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library iki_read.c private-iki_read.c
// fll-0 includes
#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/console.h>
#include <level_0/directory.h>
#include <level_0/file.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_directory
f_fss
f_pipe
f_print
-f_utf
fl_color
fl_console
fl_fss
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_program -lfll_fss -lfll_execute -lf_path -lfl_string -lfl_status -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_program -lfll_fss -lfl_conversion -lfll_execute -lf_path -lfl_string -lfl_status -lfl_fss -lfl_console -lf_conversion -lfl_color -lf_print -lf_pipe -lf_fss -lf_file -lf_environment -lf_directory -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library init.c private-init.c
f_status status = F_none;
{
+ const f_string_range range = f_macro_string_range_initialize(strlen(value));
+
f_number_unsigned number = 0;
- status = fl_console_parameter_to_number_unsigned(value, &number);
+ status = fl_conversion_string_to_number_unsigned(value, &number, range);
if (status == F_none) {
fl_color_print_line(f_type_output, data.context.error, data.context.reset, "invalid name");
#ifndef _di_status_code_convert_number_
f_return_status status_code_convert_number(const status_code_data data, const f_string value, f_number_unsigned *number) {
- f_status status = fl_console_parameter_to_number_unsigned(value, number);
+ const f_string_range range = f_macro_string_range_initialize(strlen(value));
+
+ f_status status = fl_conversion_string_to_number_unsigned(value, number, range);
if (*number > F_status_size_max_with_signal) {
fl_color_print_line(f_type_output, data.context.error, data.context.reset, "out of range");
#include <string.h>
// fll-0 includes
+#include <level_0/type.h>
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/utf.h>
#include <level_0/conversion.h>
#include <level_0/console.h>
#include <level_0/pipe.h>
#include <level_0/print.h>
-#include <level_0/status.h>
-#include <level_0/string.h>
-#include <level_0/type.h>
// fll-1 includes
#include <level_1/color.h>
#include <level_1/console.h>
+#include <level_1/conversion.h>
#include <level_1/status.h>
#include <level_1/string.h>
+# fss-0000
+
f_type
f_status
f_memory
f_string
+f_utf
f_color
f_console
f_conversion
f_file
f_pipe
f_print
-f_utf
fl_color
fl_console
+fl_conversion
fl_status
fl_string
fl_utf
build_language c
build_linker ar
build_libraries -lc
-build_libraries-individual -lfll_status -lfll_program -lfl_utf -lfl_string -lfl_status -lfl_console -lfl_color -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_utf -lf_memory
+build_libraries-individual -lfll_status -lfll_program -lfl_utf -lfl_string -lfl_status -lfl_conversion -lfl_console -lfl_color -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_utf -lf_memory
build_libraries-level -lfll_2 -lfll_1 -lfll_0
build_libraries-monolithic -lfll
build_sources_library status_code.c private-status_code.c