Start using the *-common.h practice to move macro definitions out of header files with function declarations.
The *-common.h files are akin to private-* files in that they are special use or special purpose.
Therefore, the "-" is used.
In all other cases, underscores "_" should be used.
Fix files where dashes "-" were incorrectly used, replacing them with underscores "_".
build_libraries-level
build_sources_library account.c console.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c private-file.c fss.c iki.c private-iki.c memory.c path.c private-path.c pipe.c print.c private-print.c serialize.c private-serialize.c signal.c socket.c utf.c private-utf.c
build_sources_program
-build_sources_headers account.h 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-quoted.h fss-set.h iki.h iki-common.h memory.h memory-structure.h path.h pipe.h print.h serialize.h signal.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 account.h account-common.h color.h console.h console-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h file.h file-common.h fss.h fss-common.h fss_named.h fss_nest.h fss_quoted.h fss_set.h iki.h iki-common.h memory.h memory-structure.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.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_libraries-monolithic
build_sources_library level_0/account.c 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/private-iki.c level_0/memory.c level_0/path.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/private-serialize.c level_0/signal.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/environment.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/private-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/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c
build_sources_program
-build_sources_headers level_0/account.h 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-quoted.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/signal.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/environment.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/iki.h level_2/path.h level_2/program.h level_2/status.h
+build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quoted.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/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.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/environment.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/iki.h level_2/path.h level_2/program.h level_2/status.h
build_sources_script
build_sources_setting
build_script yes
Functions defined as private will not be normally exposed through the public headers files.
Such functions will be prefixed with 'private_'.
+
+The header files and source files for these private functions will be prefixed with "private-".
+Normally, this product uses underscores for names, but, as a special name, the dash "-" is used.
+Normally, the names begin with the project name (such as directory_type.h instead of type_directory.h), but as a special case to further separate private files, this is prefixed onto source files (such as private-directory.h).
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Pipe
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by pipe console.
+ *
+ * This is auto-included by pipe.h and should not need to be explicitly included.
+ */
+#ifndef _F_account_common_h
+#define _F_account_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Custom defines for f_account.
+ *
+ * f_account_pwd_length_fallback_first: provide a fallback max length for when sysconf(_SC_GETPW_R_SIZE_MAX) return -1 (aka: infinite).
+ * f_account_pwd_length_fallback_second: provide a fallback max length for when f_account_pwd_length_fallback_first is too small.
+ */
+#ifndef _di_f_account_defines_
+ #define f_account_pwd_length_fallback_first 8192
+ #define f_account_pwd_length_fallback_second 32767
+#endif // _di_f_account_defines_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_account_common_h
#include <level_0/memory.h>
#include <level_0/string.h>
+// fll-0 account includes
+#include <level_0/account-common.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Custom defines for f_account.
- *
- * f_account_pwd_length_fallback_first: provide a fallback max length for when sysconf(_SC_GETPW_R_SIZE_MAX) return -1 (aka: infinite).
- * f_account_pwd_length_fallback_second: provide a fallback max length for when f_account_pwd_length_fallback_first is too small.
- */
-#ifndef _di_f_account_defines_
- #define f_account_pwd_length_fallback_first 8192
- #define f_account_pwd_length_fallback_second 32767
-#endif // _di_f_account_defines_
-
-/**
* Get the group account id by the group name.
*
* @param name
build_libraries-individual -lf_memory
build_sources_library account.c
build_sources_program
-build_sources_headers account.h
+build_sources_headers account.h account-common.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Console
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by project console.
+ *
+ * This is auto-included by console.h and should not need to be explicitly included.
+ */
+#ifndef _F_console_common_h
+#define _F_console_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Result values that represent the type of command found.
+ *
+ * Here "empty" refers to '-', or '++', in that they only have the symbols (whereas '-x', or '++x' would not be empty).
+ */
+#ifndef _di_f_console_ids_
+ enum {
+ f_console_none = 1,
+ f_console_short_enable,
+ f_console_short_disable,
+ f_console_long_enable,
+ f_console_long_disable,
+ f_console_empty_short_enable,
+ f_console_empty_short_disable,
+ f_console_empty_long_enable,
+ f_console_empty_long_disable,
+ };
+#endif // _di_f_console_ids_
+
+/**
+ * The symbols passed to the program for option handling.
+ *
+ * The following will be processed as an integer and therefore must not be string.
+ * - f_console_symbol_enable
+ * - f_console_symbol_disable
+ */
+#ifndef _di_f_console_symbols_
+ #define f_console_symbol_enable '-'
+ #define f_console_symbol_disable '+'
+
+ #define f_console_symbol_short_enable "-"
+ #define f_console_symbol_short_disable "+"
+
+ #define f_console_symbol_short_enable_length 1
+ #define f_console_symbol_short_disable_length 1
+
+ #define f_console_symbol_long_enable "--"
+ #define f_console_symbol_long_disable "++"
+
+ #define f_console_symbol_long_enable_length 2
+ #define f_console_symbol_long_disable_length 2
+#endif // _di_f_console_symbols_
+
+/**
+ * Create some standard command line parameter options required/expected by the kevux/fss/fll specifications.
+ *
+ * It is expected that all of the "+" and "++" console options described below are reserved for these purposes.
+ * This is not a strict requirement as such a thing is non-sense in open-source, but this should be considered a strong recommendation.
+ *
+ * It is acceptable for any of these options, when specified multiple times, for that number of times to represent the "level".
+ * For example, a "+D +D" means more debug output than simply "+D".
+ *
+ * The following options are subjective in interpretation but are expected to follow the general interpretation:
+ * - debug: Enable debugging, which will likely increase output verbosity.
+ * - quiet: Decrease verbosity, print less, in some use cases this could mean printing nothing.
+ * - verbose: Increase verbosity, print more, in some use cases this could mean printing just about everything.
+ *
+ * The following are less subjective in interpretation but do allow some flexibility.
+ * - dark: Do display color intended for dark backgrounds (often the default behavior) when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.)
+ * - help: Display the help text. This does not define how the text is displayed only that the text is displayed.
+ * - light: Do display color intended for light backgrounds when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.)
+ * - no_color: Do not display color when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.)
+ * - version: Should always print only the version number, no colors, but what represents the version number is undefined by this project.
+ *
+ * The following options are for special purposes:
+ * - status: Represents the return status code from another program.
+ * Because it is associated with the status from another program, its structure is very subjective.
+ * The only expectation is that it somehow communicates the fss status codes.
+ * Example of complex use: "failed_program_name:error:123".
+ * Example of simple use: "123".
+ */
+#ifndef _di_f_standard_console_parameters_
+ #define f_console_standard_short_dark "d"
+ #define f_console_standard_short_debug "D"
+ #define f_console_standard_short_help "h"
+ #define f_console_standard_short_light "l"
+ #define f_console_standard_short_no_color "n"
+ #define f_console_standard_short_quiet "q"
+ #define f_console_standard_short_verbose "V"
+ #define f_console_standard_short_version "v"
+
+ #define f_console_standard_short_dark_length 1
+ #define f_console_standard_short_debug_length 1
+ #define f_console_standard_short_help_length 1
+ #define f_console_standard_short_light_length 1
+ #define f_console_standard_short_no_color_length 1
+ #define f_console_standard_short_quiet_length 1
+ #define f_console_standard_short_verbose_length 1
+ #define f_console_standard_short_version_length 1
+
+ #define f_console_standard_long_dark "dark"
+ #define f_console_standard_long_debug "debug"
+ #define f_console_standard_long_help "help"
+ #define f_console_standard_long_light "light"
+ #define f_console_standard_long_no_color "no_color"
+ #define f_console_standard_long_status "status"
+ #define f_console_standard_long_quiet "quiet"
+ #define f_console_standard_long_verbose "verbose"
+ #define f_console_standard_long_version "version"
+
+ #define f_console_standard_long_dark_length 4
+ #define f_console_standard_long_debug_length 5
+ #define f_console_standard_long_help_length 4
+ #define f_console_standard_long_light_length 5
+ #define f_console_standard_long_no_color_length 8
+ #define f_console_standard_long_status_length 6
+ #define f_console_standard_long_quiet_length 5
+ #define f_console_standard_long_verbose_length 7
+ #define f_console_standard_long_version_length 7
+#endif // _di_f_standard_console_parameters_
+
+/**
+ * The maximum size for a single parameter.
+ */
+#ifndef _di_f_console_length_size_
+ #define f_console_length_size f_string_length_t_size
+#endif // _di_f_console_length_size_
+
+/**
+ * Provide a default allocation step.
+ *
+ * For a UTF-8 friendly allocation step, set to at least 4.
+ */
+#ifndef _di_f_console_default_allocation_step_
+ #define f_console_default_allocation_step 4
+#endif // _di_f_console_default_allocation_step_
+
+/**
+ * Provide console type enumerations:
+ *
+ * - none: parameter not found.
+ * - found: parameter found.
+ * - additional: parameter found, extra data exists (such as '-f filename', 'filename' would be the extra data).
+ *
+ * - normal: parameters using minus sign, such as '--help'.
+ * - inverse: parameters using plus sign, such as '++version'.
+ * - other: parameters using neither minus nor plus sign, such as 'build'.
+ */
+#ifndef _di_f_console_types_t_
+ typedef uint16_t f_console_id_t;
+
+ enum {
+ f_console_result_none = 1,
+ f_console_result_found,
+ f_console_result_additional,
+ };
+
+ enum {
+ f_console_type_normal = 1,
+ f_console_type_inverse,
+ f_console_type_other,
+ };
+#endif // _di_f_console_types_t_
+
+/**
+ * Provide a structure for describing console parameters for the console processing functions to use.
+ *
+ * The short parameters are will be prepended with either '-' or '+'.
+ * The long parameters are will be prepended with either '--' or '++'.
+ * The other parameters are for any other parameter that has no prepended characters.
+ *
+ * - symbol_short: The single character string, such as 'h' in '-h'.
+ * - symbol_long: The multi-character string, such as 'help' in '--help'.
+ * - symbol_other: The special meaning parameter, such as 'all' in 'make all'.
+ *
+ * - has_additional: Designates that a parameter will have a given number of additional arguments, such as 'blue' in '--color blue'.
+ * - type: One of the f_console_type_* codes, defining how this parameter is to be processed.
+ *
+ * - result: A code representing that the parameter is found and how it is found ('-h' vs '--help').
+ * - total: A number representing the total number of times this parameter is found ('-h -h' would result in a total of 2).
+ *
+ * - location: The last location in argv[] where this parameter is found.
+ * - location_sub: The last sub-location at location in argv (only used by short parameters, such as -h or +l).
+ * - locations: All locations within argv where this parameter is found (order is preserved).
+ * - additional: An array of locations representing where in the argv[] the additional arguments are found.
+ */
+#ifndef _di_f_console_parameter_t_
+ typedef struct {
+ const int8_t *symbol_short;
+ const int8_t *symbol_long;
+ const int8_t *symbol_other;
+
+ const uint8_t has_additional;
+ const uint8_t type;
+
+ uint8_t result;
+ uint8_t total;
+
+ f_string_length_t location;
+ f_string_length_t location_sub;
+ f_string_lengths_t locations;
+ f_string_lengths_t additional;
+ } f_console_parameter_t;
+
+ #define f_console_parameter_t_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value) { symbol_short, symbol_long, symbol_other, has_additional, type_value, f_console_result_none, 0, 0, 0, f_string_lengths_t_initialize, f_string_lengths_t_initialize }
+#endif // _di_f_console_parameter_t_
+
+/**
+ * Provide a helper structure for references and processing parameters.
+ *
+ * Designed for passing this to a function as a single argument.
+ *
+ * parameter: Intended to be populated with an array of f_console_parameter_id_t whose size is defined by the "used" property.
+ * This is not intended to be dynamically allocated, so there is no "size" property.
+ * order:
+ */
+#ifndef _di_f_console_parameters_t_
+ typedef struct {
+ f_console_parameter_t *parameter;
+
+ f_array_length_t used;
+ } f_console_parameters_t;
+
+ #define f_console_parameters_t_initialize { 0, 0 }
+#endif // _di_f_console_parameters_t_
+
+/**
+ * Provide a helper structure for references and processing standard C main() arguments.
+ *
+ * The f_console_parameter_id_t is designed to be used for the enums to represent a any given parameter by the ID.
+ *
+ * The f_console_parameter_ids_t is designed for passing this to a function as a single argument.
+ * The "id" property is intended to be populated with an aray of f_console_parameter_id_t whose size is defined by the "used" property.
+ * This follows the idea of f_string_dynamic_t and has a "used" instead of length, but because this is not intended to be dynamically allocated there is no "size" property.
+ */
+#ifndef _di_f_console_parameter_id_t_
+ typedef uint16_t f_console_parameter_id_t;
+
+ typedef struct {
+ f_console_parameter_id_t *id;
+
+ f_array_length_t used;
+ } f_console_parameter_ids_t;
+
+ #define f_console_parameter_ids_t_initialize { 0, 0 }
+#endif // _di_f_console_parameter_id_t_
+
+/**
+ * Provide a helper structure for referencing the argc and argv standard main arguments.
+ *
+ * This is intended to only store the argc and argv and should not be treated as dynamic.
+ *
+ * No structure initializer is provided due to the use of constant properties.
+ */
+#ifndef _di_f_console_arguments_t_
+ typedef struct {
+ const f_number_unsigned_t argc;
+
+ const f_string_t *argv;
+ } f_console_arguments_t;
+#endif // _di_f_console_arguments_t_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_console_common_h
#include <level_0/string.h>
#include <level_0/utf.h>
+// fll-0 console includes
+#include <level_0/console-common.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Result values that represent the type of command found.
- *
- * Here "empty" refers to '-', or '++', in that they only have the symbols (whereas '-x', or '++x' would not be empty).
- */
-#ifndef _di_f_console_ids_
- enum {
- f_console_none = 1,
- f_console_short_enable,
- f_console_short_disable,
- f_console_long_enable,
- f_console_long_disable,
- f_console_empty_short_enable,
- f_console_empty_short_disable,
- f_console_empty_long_enable,
- f_console_empty_long_disable,
- };
-#endif // _di_f_console_ids_
-
-/**
- * The symbols passed to the program for option handling.
- *
- * The following will be processed as an integer and therefore must not be string.
- * - f_console_symbol_enable
- * - f_console_symbol_disable
- */
-#ifndef _di_f_console_symbols_
- #define f_console_symbol_enable '-'
- #define f_console_symbol_disable '+'
-
- #define f_console_symbol_short_enable "-"
- #define f_console_symbol_short_disable "+"
-
- #define f_console_symbol_short_enable_length 1
- #define f_console_symbol_short_disable_length 1
-
- #define f_console_symbol_long_enable "--"
- #define f_console_symbol_long_disable "++"
-
- #define f_console_symbol_long_enable_length 2
- #define f_console_symbol_long_disable_length 2
-#endif // _di_f_console_symbols_
-
-/**
- * Create some standard command line parameter options required/expected by the kevux/fss/fll specifications.
- *
- * It is expected that all of the "+" and "++" console options described below are reserved for these purposes.
- * This is not a strict requirement as such a thing is non-sense in open-source, but this should be considered a strong recommendation.
- *
- * It is acceptable for any of these options, when specified multiple times, for that number of times to represent the "level".
- * For example, a "+D +D" means more debug output than simply "+D".
- *
- * The following options are subjective in interpretation but are expected to follow the general interpretation:
- * - debug: Enable debugging, which will likely increase output verbosity.
- * - quiet: Decrease verbosity, print less, in some use cases this could mean printing nothing.
- * - verbose: Increase verbosity, print more, in some use cases this could mean printing just about everything.
- *
- * The following are less subjective in interpretation but do allow some flexibility.
- * - dark: Do display color intended for dark backgrounds (often the default behavior) when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.)
- * - help: Display the help text. This does not define how the text is displayed only that the text is displayed.
- * - light: Do display color intended for light backgrounds when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.)
- * - no_color: Do not display color when printing to the console. Other contexts may be acceptable (such as voice inflections, or lack-thereof) for audio.)
- * - version: Should always print only the version number, no colors, but what represents the version number is undefined by this project.
- *
- * The following options are for special purposes:
- * - status: Represents the return status code from another program.
- * Because it is associated with the status from another program, its structure is very subjective.
- * The only expectation is that it somehow communicates the fss status codes.
- * Example of complex use: "failed_program_name:error:123".
- * Example of simple use: "123".
- */
-#ifndef _di_f_standard_console_parameters_
- #define f_console_standard_short_dark "d"
- #define f_console_standard_short_debug "D"
- #define f_console_standard_short_help "h"
- #define f_console_standard_short_light "l"
- #define f_console_standard_short_no_color "n"
- #define f_console_standard_short_quiet "q"
- #define f_console_standard_short_verbose "V"
- #define f_console_standard_short_version "v"
-
- #define f_console_standard_short_dark_length 1
- #define f_console_standard_short_debug_length 1
- #define f_console_standard_short_help_length 1
- #define f_console_standard_short_light_length 1
- #define f_console_standard_short_no_color_length 1
- #define f_console_standard_short_quiet_length 1
- #define f_console_standard_short_verbose_length 1
- #define f_console_standard_short_version_length 1
-
- #define f_console_standard_long_dark "dark"
- #define f_console_standard_long_debug "debug"
- #define f_console_standard_long_help "help"
- #define f_console_standard_long_light "light"
- #define f_console_standard_long_no_color "no_color"
- #define f_console_standard_long_status "status"
- #define f_console_standard_long_quiet "quiet"
- #define f_console_standard_long_verbose "verbose"
- #define f_console_standard_long_version "version"
-
- #define f_console_standard_long_dark_length 4
- #define f_console_standard_long_debug_length 5
- #define f_console_standard_long_help_length 4
- #define f_console_standard_long_light_length 5
- #define f_console_standard_long_no_color_length 8
- #define f_console_standard_long_status_length 6
- #define f_console_standard_long_quiet_length 5
- #define f_console_standard_long_verbose_length 7
- #define f_console_standard_long_version_length 7
-#endif // _di_f_standard_console_parameters_
-
-/**
- * The maximum size for a single parameter.
- */
-#ifndef _di_f_console_length_size_
- #define f_console_length_size f_string_length_t_size
-#endif // _di_f_console_length_size_
-
-/**
- * Provide a default allocation step.
- *
- * For a UTF-8 friendly allocation step, set to at least 4.
- */
-#ifndef _di_f_console_default_allocation_step_
- #define f_console_default_allocation_step 4
-#endif // _di_f_console_default_allocation_step_
-
-/**
- * Provide console type enumerations:
- *
- * - none: parameter not found.
- * - found: parameter found.
- * - additional: parameter found, extra data exists (such as '-f filename', 'filename' would be the extra data).
- *
- * - normal: parameters using minus sign, such as '--help'.
- * - inverse: parameters using plus sign, such as '++version'.
- * - other: parameters using neither minus nor plus sign, such as 'build'.
- */
-#ifndef _di_f_console_types_t_
- typedef uint16_t f_console_id_t;
-
- enum {
- f_console_result_none = 1,
- f_console_result_found,
- f_console_result_additional,
- };
-
- enum {
- f_console_type_normal = 1,
- f_console_type_inverse,
- f_console_type_other,
- };
-#endif // _di_f_console_types_t_
-
-/**
- * Provide a structure for describing console parameters for the console processing functions to use.
- *
- * The short parameters are will be prepended with either '-' or '+'.
- * The long parameters are will be prepended with either '--' or '++'.
- * The other parameters are for any other parameter that has no prepended characters.
- *
- * - symbol_short: The single character string, such as 'h' in '-h'.
- * - symbol_long: The multi-character string, such as 'help' in '--help'.
- * - symbol_other: The special meaning parameter, such as 'all' in 'make all'.
- *
- * - has_additional: Designates that a parameter will have a given number of additional arguments, such as 'blue' in '--color blue'.
- * - type: One of the f_console_type_* codes, defining how this parameter is to be processed.
- *
- * - result: A code representing that the parameter is found and how it is found ('-h' vs '--help').
- * - total: A number representing the total number of times this parameter is found ('-h -h' would result in a total of 2).
- *
- * - location: The last location in argv[] where this parameter is found.
- * - location_sub: The last sub-location at location in argv (only used by short parameters, such as -h or +l).
- * - locations: All locations within argv where this parameter is found (order is preserved).
- * - additional: An array of locations representing where in the argv[] the additional arguments are found.
- */
-#ifndef _di_f_console_parameter_t_
- typedef struct {
- const int8_t *symbol_short;
- const int8_t *symbol_long;
- const int8_t *symbol_other;
-
- const uint8_t has_additional;
- const uint8_t type;
-
- uint8_t result;
- uint8_t total;
-
- f_string_length_t location;
- f_string_length_t location_sub;
- f_string_lengths_t locations;
- f_string_lengths_t additional;
- } f_console_parameter_t;
-
- #define f_console_parameter_t_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value) { symbol_short, symbol_long, symbol_other, has_additional, type_value, f_console_result_none, 0, 0, 0, f_string_lengths_t_initialize, f_string_lengths_t_initialize }
-#endif // _di_f_console_parameter_t_
-
-/**
- * Provide a helper structure for references and processing parameters.
- *
- * Designed for passing this to a function as a single argument.
- *
- * parameter: Intended to be populated with an array of f_console_parameter_id_t whose size is defined by the "used" property.
- * This is not intended to be dynamically allocated, so there is no "size" property.
- * order:
- */
-#ifndef _di_f_console_parameters_t_
- typedef struct {
- f_console_parameter_t *parameter;
-
- f_array_length_t used;
- } f_console_parameters_t;
-
- #define f_console_parameters_t_initialize { 0, 0 }
-#endif // _di_f_console_parameters_t_
-
-/**
- * Provide a helper structure for references and processing standard C main() arguments.
- *
- * The f_console_parameter_id_t is designed to be used for the enums to represent a any given parameter by the ID.
- *
- * The f_console_parameter_ids_t is designed for passing this to a function as a single argument.
- * The "id" property is intended to be populated with an aray of f_console_parameter_id_t whose size is defined by the "used" property.
- * This follows the idea of f_string_dynamic_t and has a "used" instead of length, but because this is not intended to be dynamically allocated there is no "size" property.
- */
-#ifndef _di_f_console_parameter_id_t_
- typedef uint16_t f_console_parameter_id_t;
-
- typedef struct {
- f_console_parameter_id_t *id;
-
- f_array_length_t used;
- } f_console_parameter_ids_t;
-
- #define f_console_parameter_ids_t_initialize { 0, 0 }
-#endif // _di_f_console_parameter_id_t_
-
-/**
- * Provide a helper structure for referencing the argc and argv standard main arguments.
- *
- * This is intended to only store the argc and argv and should not be treated as dynamic.
- *
- * No structure initializer is provided due to the use of constant properties.
- */
-#ifndef _di_f_console_arguments_t_
- typedef struct {
- const f_number_unsigned_t argc;
-
- const f_string_t *argv;
- } f_console_arguments_t;
-#endif // _di_f_console_arguments_t_
-
-/**
* Determine the type code the given input parameter represents.
*
* @param input
build_libraries-individual -lf_utf -lf_memory
build_sources_library console.c
build_sources_program
-build_sources_headers console.h
+build_sources_headers console.h console-common.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Conversion
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by project conversion.
+ *
+ * This is auto-included by conversion.h and should not need to be explicitly included.
+ */
+#ifndef _F_conversion_common_h
+#define _F_conversion_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Provide custom conversion scale limits based on selected type sizes.
+ *
+ * Utilize the f_type_number_* defines to determine the expected sizes to use for the scales.
+ *
+ * 64-bit is the designed default.
+ */
+#ifndef _di_f_type_number_64_t_
+ #define f_conversion_scale_binary_unsigned 64
+ #define f_conversion_scale_binary_signed 63
+
+ #define f_conversion_scale_octal_unsigned 21
+ #define f_conversion_scale_octal_signed 20
+
+ #define f_conversion_scale_decimal_unsigned 19
+ #define f_conversion_scale_decimal_signed 18
+
+ #define f_conversion_scale_duodecimal_unsigned 17
+ #define f_conversion_scale_duodecimal_signed 17
+
+ #define f_conversion_scale_hexidecimal_unsigned 15
+ #define f_conversion_scale_hexidecimal_signed 15
+#endif // _di_f_type_number_64_t_
+
+#ifdef _en_f_type_number_32_t_
+ #define f_conversion_scale_binary_unsigned 32
+ #define f_conversion_scale_binary_signed 31
+
+ #define f_conversion_scale_octal_unsigned 10
+ #define f_conversion_scale_octal_signed 10
+
+ #define f_conversion_scale_decimal_unsigned 9
+ #define f_conversion_scale_decimal_signed 9
+
+ #define f_conversion_scale_duodecimal_unsigned 8
+ #define f_conversion_scale_duodecimal_signed 8
+
+ #define f_conversion_scale_hexidecimal_unsigned 7
+ #define f_conversion_scale_hexidecimal_signed 7
+#endif // _en_f_type_number_32_t_
+
+#ifdef _en_f_type_number_128_t_
+ #define f_conversion_scale_binary_unsigned 128
+ #define f_conversion_scale_binary_signed 127
+
+ #define f_conversion_scale_octal_unsigned 42
+ #define f_conversion_scale_octal_signed 42
+
+ #define f_conversion_scale_decimal_unsigned 38
+ #define f_conversion_scale_decimal_signed 38
+
+ #define f_conversion_scale_duodecimal_unsigned 35
+ #define f_conversion_scale_duodecimal_signed 35
+
+ #define f_conversion_scale_hexidecimal_unsigned 31
+ #define f_conversion_scale_hexidecimal_signed 31
+#endif // _en_f_type_number_128_t_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_conversion_common_h
#include <level_0/string.h>
#include <level_0/utf.h>
+// fll-0 conversion includes
+#include <level_0/conversion-common.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Provide custom conversion scale limits based on selected type sizes.
- *
- * Utilize the f_type_number_* defines to determine the expected sizes to use for the scales.
- *
- * 64-bit is the designed default.
- */
-#ifndef _di_f_type_number_64_t_
- #define f_conversion_scale_binary_unsigned 64
- #define f_conversion_scale_binary_signed 63
-
- #define f_conversion_scale_octal_unsigned 21
- #define f_conversion_scale_octal_signed 20
-
- #define f_conversion_scale_decimal_unsigned 19
- #define f_conversion_scale_decimal_signed 18
-
- #define f_conversion_scale_duodecimal_unsigned 17
- #define f_conversion_scale_duodecimal_signed 17
-
- #define f_conversion_scale_hexidecimal_unsigned 15
- #define f_conversion_scale_hexidecimal_signed 15
-#endif // _di_f_type_number_64_t_
-
-#ifdef _en_f_type_number_32_t_
- #define f_conversion_scale_binary_unsigned 32
- #define f_conversion_scale_binary_signed 31
-
- #define f_conversion_scale_octal_unsigned 10
- #define f_conversion_scale_octal_signed 10
-
- #define f_conversion_scale_decimal_unsigned 9
- #define f_conversion_scale_decimal_signed 9
-
- #define f_conversion_scale_duodecimal_unsigned 8
- #define f_conversion_scale_duodecimal_signed 8
-
- #define f_conversion_scale_hexidecimal_unsigned 7
- #define f_conversion_scale_hexidecimal_signed 7
-#endif // _en_f_type_number_32_t_
-
-#ifdef _en_f_type_number_128_t_
- #define f_conversion_scale_binary_unsigned 128
- #define f_conversion_scale_binary_signed 127
-
- #define f_conversion_scale_octal_unsigned 42
- #define f_conversion_scale_octal_signed 42
-
- #define f_conversion_scale_decimal_unsigned 38
- #define f_conversion_scale_decimal_signed 38
-
- #define f_conversion_scale_duodecimal_unsigned 35
- #define f_conversion_scale_duodecimal_signed 35
-
- #define f_conversion_scale_hexidecimal_unsigned 31
- #define f_conversion_scale_hexidecimal_signed 31
-#endif // _en_f_type_number_128_t_
-
-/**
* Convert a single character into the binary digit that it represents.
*
* @param character
build_libraries-individual -lf_utf -lf_memory
build_sources_library conversion.c
build_sources_program
-build_sources_headers conversion.h
+build_sources_headers conversion.h conversion-common.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Directory
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by project directory.
+ *
+ * This is auto-included by directory.h and should not need to be explicitly included.
+ */
+#ifndef _F_directory_common_h
+#define _F_directory_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Directory AT_* define related functionality.
+ */
+#ifndef _di_f_directory_at_
+ #define f_directory_at_current_working -100
+ #define f_directory_at_symlink_follow 0x400
+ #define f_directory_at_symlink_follow_no 0x100
+ #define f_directory_at_remove_directory 0x200
+ #define f_directory_at_automount_no 0x800
+ #define f_directory_at_path_empty 0x1000
+ #define f_directory_at_statx_sync_type 0x6000
+ #define f_directory_at_statx_sync_as_stat 0x0000
+ #define f_directory_at_statx_sync_force 0x2000
+ #define f_directory_at_statx_sync_no 0x4000
+#endif // _di_f_directory_at_
+
+/**
+ * Directory flag related functionality.
+ */
+#ifndef _di_f_directory_flag_
+
+ // directory open flags
+ #define f_directory_flag_append O_APPEND
+ #define f_directory_flag_asynchronous O_ASYNC
+ #define f_directory_flag_create O_CREAT
+ #define f_directory_flag_close_execute O_CLOEXEC
+ #define f_directory_flag_direct O_DIRECT
+ #define f_directory_flag_directory O_DIRECTORY
+ #define f_directory_flag_exclusive O_EXCL
+ #define f_directory_flag_large_file O_LARGEFILE
+ #define f_directory_flag_no_access_time O_NOATIME
+ #define f_directory_flag_no_follow O_NOFOLLOW
+ #define f_directory_flag_no_tty O_NOCTTY
+ #define f_directory_flag_non_blocking O_NONBLOCK
+ #define f_directory_flag_path 010000000
+ #define f_directory_flag_read_only O_RDONLY
+ #define f_directory_flag_read_write O_RDWR
+ #define f_directory_flag_synchronous O_SYNC
+ #define f_directory_flag_synchronous_direct O_DSYNC
+ #define f_directory_flag_temporary O_TMPFILE
+ #define f_directory_flag_truncate O_TRUNC
+ #define f_directory_flag_write_only O_WRONLY
+#endif // _di_f_directory_flag_
+
+/**
+ * Provide limitations and related defines.
+ *
+ * The directory max descriptors is more of a default than a rule.
+ * This is generally used for nftw() recursive operations to reduce the number of open file descriptors during recursion.
+ */
+#ifndef _di_f_directory_limitations_
+ #define f_directory_default_allocation_step f_memory_default_allocation_step
+
+ #define f_directory_descriptors_max 255
+ #define f_directory_name_max NAME_MAX
+#endif // _di_f_directory_limitations_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_directory_common_h
#include <level_0/string.h>
#include <level_0/directory_type.h>
+// fll-0 directory includes
+#include <level_0/directory-common.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Directory AT_* define related functionality.
- */
-#ifndef _di_f_directory_at_
- #define f_directory_at_current_working -100
- #define f_directory_at_symlink_follow 0x400
- #define f_directory_at_symlink_follow_no 0x100
- #define f_directory_at_remove_directory 0x200
- #define f_directory_at_automount_no 0x800
- #define f_directory_at_path_empty 0x1000
- #define f_directory_at_statx_sync_type 0x6000
- #define f_directory_at_statx_sync_as_stat 0x0000
- #define f_directory_at_statx_sync_force 0x2000
- #define f_directory_at_statx_sync_no 0x4000
-#endif // _di_f_directory_at_
-
-/**
- * Directory flag related functionality.
- */
-#ifndef _di_f_directory_flag_
-
- // directory open flags
- #define f_directory_flag_append O_APPEND
- #define f_directory_flag_asynchronous O_ASYNC
- #define f_directory_flag_create O_CREAT
- #define f_directory_flag_close_execute O_CLOEXEC
- #define f_directory_flag_direct O_DIRECT
- #define f_directory_flag_directory O_DIRECTORY
- #define f_directory_flag_exclusive O_EXCL
- #define f_directory_flag_large_file O_LARGEFILE
- #define f_directory_flag_no_access_time O_NOATIME
- #define f_directory_flag_no_follow O_NOFOLLOW
- #define f_directory_flag_no_tty O_NOCTTY
- #define f_directory_flag_non_blocking O_NONBLOCK
- #define f_directory_flag_path 010000000
- #define f_directory_flag_read_only O_RDONLY
- #define f_directory_flag_read_write O_RDWR
- #define f_directory_flag_synchronous O_SYNC
- #define f_directory_flag_synchronous_direct O_DSYNC
- #define f_directory_flag_temporary O_TMPFILE
- #define f_directory_flag_truncate O_TRUNC
- #define f_directory_flag_write_only O_WRONLY
-#endif // _di_f_directory_flag_
-
-/**
- * Provide limitations and related defines.
- *
- * The directory max descriptors is more of a default than a rule.
- * This is generally used for nftw() recursive operations to reduce the number of open file descriptors during recursion.
- */
-#ifndef _di_f_directory_limitations_
- #define f_directory_default_allocation_step f_memory_default_allocation_step
-
- #define f_directory_descriptors_max 255
- #define f_directory_name_max NAME_MAX
-#endif // _di_f_directory_limitations_
-
-/**
* Create a directory at the given path.
*
* @param path
build_libraries-individual -lf_memory
build_sources_library directory.c private-directory.c
build_sources_program
-build_sources_headers directory.h directory_type.h
+build_sources_headers directory.h directory_type.h directory-common.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Environment
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by environment console.
+ *
+ * This is auto-included by environment.h and should not need to be explicitly included.
+ */
+#ifndef _F_environment_common_h
+#define _F_environment_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Environment related defines.
+ */
+#ifndef _di_f_environment_defines_
+ #define f_environment_max_length f_string_length_t_size
+#endif // _di_f_environment_defines_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_environment_common_h
#include <level_0/memory.h>
#include <level_0/string.h>
+// fll-0 environment includes
+#include <level_0/environment-common.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Environment related defines.
- */
-#ifndef _di_f_environment_defines_
- #define f_environment_max_length f_string_length_t_size
-#endif // _di_f_environment_defines_
-
-/**
* Delete all environment variables.
*
* @return
build_libraries-individual -lf_memory
build_sources_library environment.c private-environment.c
build_sources_program
-build_sources_headers environment.h
+build_sources_headers environment.h environment-common.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: File
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by project file.
+ *
+ * This is auto-included by file.h and should not need to be explicitly included.
+ */
+#ifndef _F_file_common_h
+#define _F_file_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Provide common file-typ specific data types.
+ */
+#ifndef _di_f_file_types_
+ #define f_file_default_read_size 8192 // default to 8k read sizes. // @fixme: rename and move into _di_f_file_type_
+ #define f_file_default_write_size 8192 // default to 8k write sizes. // @fixme: rename and move into _di_f_file_type_
+#endif // _di_f_file_types_
+
+/**
+ * Provide macros for file-seek operations.
+ *
+ * The fseek() function parameters can be confusing, so provide a hopefully more readibly code via these macros.
+ *
+ * The f_macro_file_seek_begin() sets the file pointer from this many bytes from the beginning of the file.
+ * The f_macro_file_seek_data() sets the file pointer from this many bytes from the end of the file, relative to the next data.
+ * The f_macro_file_seek_end() sets the file pointer from this many bytes from the end of the file.
+ * The f_macro_file_seek_hole() sets the file pointer from this many bytes from the end of the file, relative to the next hole.
+ * The f_macro_file_seek_to() sets the file pointer from this many bytes relative to the current position.
+ */
+#ifndef _di_f_file_seeks_
+ #define f_macro_file_seek_begin(file, bytes) fseek(file, bytes, SEEK_SET)
+ #define f_macro_file_seek_data(file, bytes) fseek(file, bytes, SEEK_DATA)
+ #define f_macro_file_seek_end(file) fseek(file, bytes, SEEK_END)
+ #define f_macro_file_seek_hole(file, bytes) fseek(file, bytes, SEEK_HOLE)
+ #define f_macro_file_seek_to(file, bytes) fseek(file, bytes, SEEK_CUR)
+#endif // _di_f_file_seeks_
+
+/**
+ * Provide file type macros.
+ *
+ * These type macros are of size 32-bit (int32_t).
+ */
+#ifndef _di_f_file_type_
+ #define f_file_type_mask S_IFMT
+
+ #define f_file_type_block S_IFBLK
+ #define f_file_type_character S_IFCHR
+ #define f_file_type_directory S_IFDIR
+ #define f_file_type_fifo S_IFIFO
+ #define f_file_type_link S_IFLNK
+ #define f_file_type_regular S_IFREG
+ #define f_file_type_socket S_IFSOCK
+
+ #define f_file_type_name_block "block"
+ #define f_file_type_name_character "character"
+ #define f_file_type_name_directory "directory"
+ #define f_file_type_name_fifo "fifo"
+ #define f_file_type_name_link "link"
+ #define f_file_type_name_regular "regular"
+ #define f_file_type_name_socket "socket"
+
+ #define f_file_type_name_block_length 5
+ #define f_file_type_name_character_length 9
+ #define f_file_type_name_directory_length 9
+ #define f_file_type_name_fifo_length 4
+ #define f_file_type_name_link_length 4
+ #define f_file_type_name_regular_length 7
+ #define f_file_type_name_socket_length 6
+
+ #define f_macro_file_type_get(mode) (f_file_type_mask & mode)
+
+ #define f_macro_file_type_is_block(mode) f_macro_file_type_get(mode) == f_file_type_block
+ #define f_macro_file_type_is_character(mode) f_macro_file_type_get(mode) == f_file_type_character
+ #define f_macro_file_type_is_directory(mode) f_macro_file_type_get(mode) == f_file_type_directory
+ #define f_macro_file_type_is_fifo(mode) f_macro_file_type_get(mode) == f_file_type_fifo
+ #define f_macro_file_type_is_link(mode) f_macro_file_type_get(mode) == f_file_type_link
+ #define f_macro_file_type_is_regular(mode) f_macro_file_type_get(mode) == f_file_type_regular
+ #define f_macro_file_type_is_socket(mode) f_macro_file_type_get(mode) == f_file_type_socket
+#endif // _di_f_file_type_
+
+/**
+ * Commonly used file related properties.
+ *
+ * id: File descriptor, with a value of -1 represents a closed file.
+ * flag: Flags used for opening the file.
+ * size_read: The default number of 1-byte characters to read at a time and is often used for the read buffer size.
+ * size_write: The default number of 1-byte characters to read at a time and is often used for the write buffer size.
+ */
+#ifndef _di_f_file_t_
+ typedef struct {
+ int id;
+ int flag;
+ size_t size_read;
+ size_t size_write;
+ } f_file_t;
+
+ #define f_file_t_initialize { -1, f_file_flag_read_only, f_file_default_read_size, f_file_default_write_size }
+
+ #define f_macro_file_t_clear(file) \
+ file.id = -1; \
+ file.flag = 0; \
+ file.size_read = 0; \
+ file.size_write = 0;
+
+ #define f_macro_file_t_reset(file) \
+ file.id = -1; \
+ file.flag = f_file_flag_read_only; \
+ file.size_read = f_file_default_read_size; \
+ file.size_write = f_file_default_write_size;
+#endif // _di_f_file_t_
+
+/**
+ * File AT_* define related functionality.
+ */
+#ifndef _di_f_file_at_
+ #define f_file_at_current_working -100
+ #define f_file_at_symlink_follow 0x400
+ #define f_file_at_symlink_follow_no 0x100
+ #define f_file_at_remove_directory 0x200
+ #define f_file_at_automount_no 0x800
+ #define f_file_at_path_empty 0x1000
+ #define f_file_at_statx_sync_type 0x6000
+ #define f_file_at_statx_sync_as_stat 0x0000
+ #define f_file_at_statx_sync_force 0x2000
+ #define f_file_at_statx_sync_no 0x4000
+#endif // _di_f_file_at_
+
+/**
+ * File flag related functionality.
+ */
+#ifndef _di_f_file_flag_
+
+ // file open flags
+ #define f_file_flag_append O_APPEND
+ #define f_file_flag_asynchronous O_ASYNC
+ #define f_file_flag_create O_CREAT
+ #define f_file_flag_close_execute O_CLOEXEC
+ #define f_file_flag_direct O_DIRECT
+ #define f_file_flag_directory O_DIRECTORY
+ #define f_file_flag_exclusive O_EXCL
+ #define f_file_flag_large_file O_LARGEFILE
+ #define f_file_flag_no_access_time O_NOATIME
+ #define f_file_flag_no_follow O_NOFOLLOW
+ #define f_file_flag_no_tty O_NOCTTY
+ #define f_file_flag_non_blocking O_NONBLOCK
+ #define f_file_flag_path 010000000
+ #define f_file_flag_read_only O_RDONLY
+ #define f_file_flag_read_write O_RDWR
+ #define f_file_flag_synchronous O_SYNC
+ #define f_file_flag_synchronous_direct O_DSYNC
+ #define f_file_flag_temporary O_TMPFILE
+ #define f_file_flag_truncate O_TRUNC
+ #define f_file_flag_write_only O_WRONLY
+
+ // file open flags pre-combined with create.
+ #define f_file_flag_create_ro (O_CREAT | O_RDONLY)
+ #define f_file_flag_create_wo (O_CREAT | O_WRONLY)
+ #define f_file_flag_create_rw (O_CREAT | O_RDRW)
+
+ // file open flags pre-combined will fail if file exists.
+ #define f_file_flag_create_new_ro (O_CREAT | O_EXCL | O_RDONLY)
+ #define f_file_flag_create_new_wo (O_CREAT | O_EXCL | O_WRONLY)
+ #define f_file_flag_create_new_rw (O_CREAT | O_EXCL | O_RDRW)
+
+ // file open flags pre-combined will truncate any existing files to 0.
+ #define f_file_flag_truncate_ro (O_CREAT | O_TRUNC | O_RDONLY)
+ #define f_file_flag_truncate_rw (O_CREAT | O_TRUNC | O_RDRW)
+ #define f_file_flag_truncate_wo (O_CREAT | O_TRUNC | O_WRONLY)
+
+ // file open flags pre-combined will truncate any existing files to 0.
+ #define f_file_flag_append_rw (O_CREAT | O_APPEND | O_RDRW)
+ #define f_file_flag_append_wo (O_CREAT | O_APPEND | O_WRONLY)
+
+ // file open flags pre-combined with synchronous io.
+ #define f_file_flag_sync_ro (O_SYNC | O_RDONLY)
+ #define f_file_flag_sync_wo (O_SYNC | O_WRONLY)
+ #define f_file_flag_sync_rw (O_SYNC | O_RDRW)
+ #define f_file_flag_sync_create_ro (O_SYNC | O_CREAT | O_RDONLY)
+ #define f_file_flag_sync_create_wo (O_SYNC | O_CREAT | O_WRONLY)
+ #define f_file_flag_sync_create_rw (O_SYNC | O_CREAT | O_RDRW)
+ #define f_file_flag_sync_create_new_ro (O_SYNC | O_CREAT | O_EXCL | O_RDONLY)
+ #define f_file_flag_sync_create_new_wo (O_SYNC | O_CREAT | O_EXCL | O_WRONLY)
+ #define f_file_flag_sync_create_new_rw (O_SYNC | O_CREAT | O_EXCL | O_RDRW)
+
+ // file open flags pre-combined with asynchronous io.
+ #define f_file_flag_async_ro (O_ASYNC | O_RDONLY)
+ #define f_file_flag_async_wo (O_ASYNC | O_WRONLY)
+ #define f_file_flag_async_rw (O_ASYNC | O_RDRW)
+ #define f_file_flag_async_create_ro (O_ASYNC | O_CREAT | O_RDONLY)
+ #define f_file_flag_async_create_wo (O_ASYNC | O_CREAT | O_WRONLY)
+ #define f_file_flag_async_create_rw (O_ASYNC | O_CREAT | O_RDRW)
+ #define f_file_flag_async_create_new_ro (O_ASYNC | O_CREAT | O_EXCL | O_RDONLY)
+ #define f_file_flag_async_create_new_wo (O_ASYNC | O_CREAT | O_EXCL | O_WRONLY)
+ #define f_file_flag_async_create_new_rw (O_ASYNC | O_CREAT | O_EXCL | O_RDRW)
+
+ // file open flags pre-combined with direct io (which works synchronously).
+ #define f_file_flag_direct_ro (O_DIRECT | O_RDONLY)
+ #define f_file_flag_direct_wo (O_DIRECT | O_WRONLY)
+ #define f_file_flag_direct_rw (O_DIRECT | O_RDRW)
+ #define f_file_flag_direct_create_ro (O_DIRECT | O_CREAT | O_RDONLY)
+ #define f_file_flag_direct_create_wo (O_DIRECT | O_CREAT | O_WRONLY)
+ #define f_file_flag_direct_create_rw (O_DIRECT | O_CREAT | O_RDRW)
+ #define f_file_flag_direct_create_new_ro (O_DIRECT | O_CREAT | O_EXCL | O_RDONLY)
+ #define f_file_flag_direct_create_new_wo (O_DIRECT | O_CREAT | O_EXCL | O_WRONLY)
+ #define f_file_flag_direct_create_new_rw (O_DIRECT | O_CREAT | O_EXCL | O_RDRW)
+
+ // file open flags pre-combined with large_file.
+ #define f_file_flag_large_ro (O_LARGEFILE | O_RDONLY)
+ #define f_file_flag_large_wo (O_LARGEFILE | O_WRONLY)
+ #define f_file_flag_large_rw (O_LARGEFILE | O_RDRW)
+ #define f_file_flag_large_sync_ro (O_LARGEFILE | O_SYNC | O_RDONLY)
+ #define f_file_flag_large_sync_wo (O_LARGEFILE | O_SYNC | O_WRONLY)
+ #define f_file_flag_large_sync_rw (O_LARGEFILE | O_SYNC | O_RDRW)
+ #define f_file_flag_large_sync_create_ro (O_LARGEFILE | O_SYNC | O_CREAT | O_RDONLY)
+ #define f_file_flag_large_sync_create_wo (O_LARGEFILE | O_SYNC | O_CREAT | O_WRONLY)
+ #define f_file_flag_large_sync_create_rw (O_LARGEFILE | O_SYNC | O_CREAT | O_RDRW)
+ #define f_file_flag_large_sync_create_new_ro (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_RDONLY)
+ #define f_file_flag_large_sync_create_new_wo (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_WRONLY)
+ #define f_file_flag_large_sync_create_new_rw (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_RDRW)
+ #define f_file_flag_large_async_ro (O_LARGEFILE | O_ASYNC | O_RDONLY)
+ #define f_file_flag_large_async_wo (O_LARGEFILE | O_ASYNC | O_WRONLY)
+ #define f_file_flag_large_async_rw (O_LARGEFILE | O_ASYNC | O_RDRW)
+ #define f_file_flag_large_async_create_ro (O_LARGEFILE | O_ASYNC | O_CREAT | O_RDONLY)
+ #define f_file_flag_large_async_create_wo (O_LARGEFILE | O_ASYNC | O_CREAT | O_WRONLY)
+ #define f_file_flag_large_async_create_rw (O_LARGEFILE | O_ASYNC | O_CREAT | O_RDRW)
+ #define f_file_flag_large_async_create_new_ro (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_RDONLY)
+ #define f_file_flag_large_async_create_new_wo (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_WRONLY)
+ #define f_file_flag_large_async_create_new_rw (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_RDRW)
+#endif // _di_f_file_flag_
+
+/**
+ * File mode related functionality.
+ *
+ * There are two types of file modes the f_file_mode_t macros associate with.
+ *
+ * The first type is the traditional mode type, associated with mode_t.
+ *
+ * The second type is f_file_mode_t, which utilizes 8-bit types with the following structure:
+ *
+ * There should only be a single bit for each 'r', 'w', 'x', and 'X' bit (as well as 'S', 's', and 't'):
+ * 'r' = read bit.
+ * 'w' = write bit.
+ * 'x' = execute bit.
+ * 'X' = execute only if already execute bit.
+ * 'S' = set user bit (setuid).
+ * 's' = set group bit (setgid).
+ * 't' = sticky bit.
+ *
+ * The file mode macros with "f_file_mode_" prefix (has no "_t") refer to the first type (mode_t).
+ * The file mode macros with "f_file_mode_t" prefix refer to the second type (f_file_mode_t).
+ */
+#ifndef _di_f_file_mode_
+ typedef uint32_t f_file_mode_t;
+
+ #define f_file_mode_t_block_special 0x77000000 // 0111 0111 0000 0000 0000 0000 0000 0000
+ #define f_file_mode_t_block_owner 0x00ff0000 // 0000 0000 1111 1111 0000 0000 0000 0000
+ #define f_file_mode_t_block_group 0x0000ff00 // 0000 0000 0000 0000 1111 1111 0000 0000
+ #define f_file_mode_t_block_world 0x000000ff // 0000 0000 0000 0000 0000 0000 1111 1111
+
+ #define f_file_mode_t_block_all 0x77ffffff // 0111 0111 1111 1111 1111 1111 1111 1111
+ #define f_file_mode_t_block_standard 0x00ffffff // 0000 0000 1111 1111 1111 1111 1111 1111
+
+ #define f_file_mode_t_mask_how_add 0x070f0f0f // 0000 0111 0000 1111 0000 1111 0000 1111
+ #define f_file_mode_t_mask_how_subtract 0x70f0f0f0 // 0111 0000 1111 0000 1111 0000 1111 0000
+
+ #define f_file_mode_t_mask_bit_execute 0x00111111 // 0000 0000 0001 0001 0001 0001 0001 0001
+ #define f_file_mode_t_mask_bit_execute_only 0x00888888 // 0000 0000 1000 1000 1000 1000 1000 1000
+ #define f_file_mode_t_mask_bit_read 0x00444444 // 0000 0000 0100 0100 0100 0100 0100 0100
+ #define f_file_mode_t_mask_bit_set_group 0x22000000 // 0010 0010 0000 0000 0000 0000 0000 0000
+ #define f_file_mode_t_mask_bit_set_owner 0x44000000 // 0100 0100 0000 0000 0000 0000 0000 0000
+ #define f_file_mode_t_mask_bit_sticky 0x11000000 // 0001 0001 0000 0000 0000 0000 0000 0000
+ #define f_file_mode_t_mask_bit_write 0x00222222 // 0000 0000 0010 0010 0010 0010 0010 0010
+
+ #define f_file_mode_t_replace_owner 0x1 // 0000 0001
+ #define f_file_mode_t_replace_group 0x2 // 0000 0010
+ #define f_file_mode_t_replace_world 0x4 // 0000 0100
+ #define f_file_mode_t_replace_special 0x8 // 0000 1000
+ #define f_file_mode_t_replace_directory 0x10 // 0001 0000
+
+ #define f_file_mode_t_replace_all 0x1f // 0001 1111
+ #define f_file_mode_t_replace_other 0x18 // 0001 1000
+ #define f_file_mode_t_replace_standard 0x7 // 0000 0111
+
+ // file permission modes (mode_t).
+ #define f_file_mode_owner_rwx S_IRWXU
+ #define f_file_mode_owner_r S_IRUSR
+ #define f_file_mode_owner_w S_IWUSR
+ #define f_file_mode_owner_x S_IXUSR
+ #define f_file_mode_owner_rw (S_IRUSR | S_IWUSR)
+ #define f_file_mode_owner_rx (S_IRUSR | S_IXUSR)
+ #define f_file_mode_owner_wx (S_IWUSR | S_IXUSR)
+ #define f_file_mode_group_rwx S_IRWXG
+ #define f_file_mode_group_r S_IRGRP
+ #define f_file_mode_group_w S_IWGRP
+ #define f_file_mode_group_x S_IXGRP
+ #define f_file_mode_group_rw (S_IRGRP | S_IWGRP)
+ #define f_file_mode_group_rx (S_IRGRP | S_IXGRP)
+ #define f_file_mode_group_wx (S_IWGRP | S_IXGRP)
+ #define f_file_mode_world_rwx S_IRWXO
+ #define f_file_mode_world_r S_IROTH
+ #define f_file_mode_world_w S_IWOTH
+ #define f_file_mode_world_x S_IXOTH
+ #define f_file_mode_world_rw (S_IROTH | S_IWOTH)
+ #define f_file_mode_world_rx (S_IROTH | S_IXOTH)
+ #define f_file_mode_world_wx (S_IWOTH | S_IXOTH)
+
+ #define f_file_mode_all_rwx (f_file_mode_owner_rwx | f_file_mode_group_rwx | f_file_mode_world_rwx)
+ #define f_file_mode_all_rw (f_file_mode_owner_rw | f_file_mode_group_rw | f_file_mode_world_rw)
+ #define f_file_mode_all_wx (f_file_mode_owner_wx | f_file_mode_group_wx | f_file_mode_world_wx)
+ #define f_file_mode_all_rx (f_file_mode_owner_rx | f_file_mode_group_rx | f_file_mode_world_rx)
+ #define f_file_mode_all_r (f_file_mode_owner_r | f_file_mode_group_r | f_file_mode_world_r)
+ #define f_file_mode_all_w (f_file_mode_owner_w | f_file_mode_group_w | f_file_mode_world_w)
+ #define f_file_mode_all_x (f_file_mode_owner_x | f_file_mode_group_x | f_file_mode_world_x)
+
+ // file mode set-uid/set-gid/sticky-bits and all bits (mode_t).
+ #define f_file_mode_special_set_user S_ISUID
+ #define f_file_mode_special_set_group S_ISGID
+ #define f_file_mode_special_sticky S_ISVTX
+ #define f_file_mode_special_all (S_ISUID | S_ISGID | S_ISVTX)
+
+ // all permissions modes and special modes (mode_t).
+ #define f_file_mode_all (f_file_mode_special_all | f_file_mode_all_rwx)
+
+ // special file mode combinations (mode_t).
+ #define f_file_mode_user_access (f_file_mode_owner_rwx | f_file_mode_group_rwx | f_file_mode_world_x)
+ #define f_file_mode_user_directory (f_file_mode_owner_rwx | f_file_mode_group_rwx)
+ #define f_file_mode_user_file (f_file_mode_owner_rw | f_file_mode_group_rw)
+ #define f_file_mode_user_program (f_file_mode_owner_rx | f_file_mode_group_rx)
+ #define f_file_mode_user_protected (f_file_mode_owner_r | f_file_mode_group_r)
+#endif // _di_f_file_mode_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_file_h
#include <level_0/memory.h>
#include <level_0/string.h>
+// fll-0 file includes
+#include <level_0/file-common.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Provide common file-typ specific data types.
- */
-#ifndef _di_f_file_types_
- #define f_file_default_read_size 8192 // default to 8k read sizes. // @fixme: rename and move into _di_f_file_type_
- #define f_file_default_write_size 8192 // default to 8k write sizes. // @fixme: rename and move into _di_f_file_type_
-#endif // _di_f_file_types_
-
-/**
- * Provide macros for file-seek operations.
- *
- * The fseek() function parameters can be confusing, so provide a hopefully more readibly code via these macros.
- *
- * The f_macro_file_seek_begin() sets the file pointer from this many bytes from the beginning of the file.
- * The f_macro_file_seek_data() sets the file pointer from this many bytes from the end of the file, relative to the next data.
- * The f_macro_file_seek_end() sets the file pointer from this many bytes from the end of the file.
- * The f_macro_file_seek_hole() sets the file pointer from this many bytes from the end of the file, relative to the next hole.
- * The f_macro_file_seek_to() sets the file pointer from this many bytes relative to the current position.
- */
-#ifndef _di_f_file_seeks_
- #define f_macro_file_seek_begin(file, bytes) fseek(file, bytes, SEEK_SET)
- #define f_macro_file_seek_data(file, bytes) fseek(file, bytes, SEEK_DATA)
- #define f_macro_file_seek_end(file) fseek(file, bytes, SEEK_END)
- #define f_macro_file_seek_hole(file, bytes) fseek(file, bytes, SEEK_HOLE)
- #define f_macro_file_seek_to(file, bytes) fseek(file, bytes, SEEK_CUR)
-#endif // _di_f_file_seeks_
-
-/**
- * Provide file type macros.
- *
- * These type macros are of size 32-bit (int32_t).
- */
-#ifndef _di_f_file_type_
- #define f_file_type_mask S_IFMT
-
- #define f_file_type_block S_IFBLK
- #define f_file_type_character S_IFCHR
- #define f_file_type_directory S_IFDIR
- #define f_file_type_fifo S_IFIFO
- #define f_file_type_link S_IFLNK
- #define f_file_type_regular S_IFREG
- #define f_file_type_socket S_IFSOCK
-
- #define f_file_type_name_block "block"
- #define f_file_type_name_character "character"
- #define f_file_type_name_directory "directory"
- #define f_file_type_name_fifo "fifo"
- #define f_file_type_name_link "link"
- #define f_file_type_name_regular "regular"
- #define f_file_type_name_socket "socket"
-
- #define f_file_type_name_block_length 5
- #define f_file_type_name_character_length 9
- #define f_file_type_name_directory_length 9
- #define f_file_type_name_fifo_length 4
- #define f_file_type_name_link_length 4
- #define f_file_type_name_regular_length 7
- #define f_file_type_name_socket_length 6
-
- #define f_macro_file_type_get(mode) (f_file_type_mask & mode)
-
- #define f_macro_file_type_is_block(mode) f_macro_file_type_get(mode) == f_file_type_block
- #define f_macro_file_type_is_character(mode) f_macro_file_type_get(mode) == f_file_type_character
- #define f_macro_file_type_is_directory(mode) f_macro_file_type_get(mode) == f_file_type_directory
- #define f_macro_file_type_is_fifo(mode) f_macro_file_type_get(mode) == f_file_type_fifo
- #define f_macro_file_type_is_link(mode) f_macro_file_type_get(mode) == f_file_type_link
- #define f_macro_file_type_is_regular(mode) f_macro_file_type_get(mode) == f_file_type_regular
- #define f_macro_file_type_is_socket(mode) f_macro_file_type_get(mode) == f_file_type_socket
-#endif // _di_f_file_type_
-
-/**
- * Commonly used file related properties.
- *
- * id: File descriptor, with a value of -1 represents a closed file.
- * flag: Flags used for opening the file.
- * size_read: The default number of 1-byte characters to read at a time and is often used for the read buffer size.
- * size_write: The default number of 1-byte characters to read at a time and is often used for the write buffer size.
- */
-#ifndef _di_f_file_t_
- typedef struct {
- int id;
- int flag;
- size_t size_read;
- size_t size_write;
- } f_file_t;
-
- #define f_file_t_initialize { -1, f_file_flag_read_only, f_file_default_read_size, f_file_default_write_size }
-
- #define f_macro_file_t_clear(file) \
- file.id = -1; \
- file.flag = 0; \
- file.size_read = 0; \
- file.size_write = 0;
-
- #define f_macro_file_t_reset(file) \
- file.id = -1; \
- file.flag = f_file_flag_read_only; \
- file.size_read = f_file_default_read_size; \
- file.size_write = f_file_default_write_size;
-#endif // _di_f_file_t_
-
-/**
- * File AT_* define related functionality.
- */
-#ifndef _di_f_file_at_
- #define f_file_at_current_working -100
- #define f_file_at_symlink_follow 0x400
- #define f_file_at_symlink_follow_no 0x100
- #define f_file_at_remove_directory 0x200
- #define f_file_at_automount_no 0x800
- #define f_file_at_path_empty 0x1000
- #define f_file_at_statx_sync_type 0x6000
- #define f_file_at_statx_sync_as_stat 0x0000
- #define f_file_at_statx_sync_force 0x2000
- #define f_file_at_statx_sync_no 0x4000
-#endif // _di_f_file_at_
-
-/**
- * File flag related functionality.
- */
-#ifndef _di_f_file_flag_
-
- // file open flags
- #define f_file_flag_append O_APPEND
- #define f_file_flag_asynchronous O_ASYNC
- #define f_file_flag_create O_CREAT
- #define f_file_flag_close_execute O_CLOEXEC
- #define f_file_flag_direct O_DIRECT
- #define f_file_flag_directory O_DIRECTORY
- #define f_file_flag_exclusive O_EXCL
- #define f_file_flag_large_file O_LARGEFILE
- #define f_file_flag_no_access_time O_NOATIME
- #define f_file_flag_no_follow O_NOFOLLOW
- #define f_file_flag_no_tty O_NOCTTY
- #define f_file_flag_non_blocking O_NONBLOCK
- #define f_file_flag_path 010000000
- #define f_file_flag_read_only O_RDONLY
- #define f_file_flag_read_write O_RDWR
- #define f_file_flag_synchronous O_SYNC
- #define f_file_flag_synchronous_direct O_DSYNC
- #define f_file_flag_temporary O_TMPFILE
- #define f_file_flag_truncate O_TRUNC
- #define f_file_flag_write_only O_WRONLY
-
- // file open flags pre-combined with create.
- #define f_file_flag_create_ro (O_CREAT | O_RDONLY)
- #define f_file_flag_create_wo (O_CREAT | O_WRONLY)
- #define f_file_flag_create_rw (O_CREAT | O_RDRW)
-
- // file open flags pre-combined will fail if file exists.
- #define f_file_flag_create_new_ro (O_CREAT | O_EXCL | O_RDONLY)
- #define f_file_flag_create_new_wo (O_CREAT | O_EXCL | O_WRONLY)
- #define f_file_flag_create_new_rw (O_CREAT | O_EXCL | O_RDRW)
-
- // file open flags pre-combined will truncate any existing files to 0.
- #define f_file_flag_truncate_ro (O_CREAT | O_TRUNC | O_RDONLY)
- #define f_file_flag_truncate_rw (O_CREAT | O_TRUNC | O_RDRW)
- #define f_file_flag_truncate_wo (O_CREAT | O_TRUNC | O_WRONLY)
-
- // file open flags pre-combined will truncate any existing files to 0.
- #define f_file_flag_append_rw (O_CREAT | O_APPEND | O_RDRW)
- #define f_file_flag_append_wo (O_CREAT | O_APPEND | O_WRONLY)
-
- // file open flags pre-combined with synchronous io.
- #define f_file_flag_sync_ro (O_SYNC | O_RDONLY)
- #define f_file_flag_sync_wo (O_SYNC | O_WRONLY)
- #define f_file_flag_sync_rw (O_SYNC | O_RDRW)
- #define f_file_flag_sync_create_ro (O_SYNC | O_CREAT | O_RDONLY)
- #define f_file_flag_sync_create_wo (O_SYNC | O_CREAT | O_WRONLY)
- #define f_file_flag_sync_create_rw (O_SYNC | O_CREAT | O_RDRW)
- #define f_file_flag_sync_create_new_ro (O_SYNC | O_CREAT | O_EXCL | O_RDONLY)
- #define f_file_flag_sync_create_new_wo (O_SYNC | O_CREAT | O_EXCL | O_WRONLY)
- #define f_file_flag_sync_create_new_rw (O_SYNC | O_CREAT | O_EXCL | O_RDRW)
-
- // file open flags pre-combined with asynchronous io.
- #define f_file_flag_async_ro (O_ASYNC | O_RDONLY)
- #define f_file_flag_async_wo (O_ASYNC | O_WRONLY)
- #define f_file_flag_async_rw (O_ASYNC | O_RDRW)
- #define f_file_flag_async_create_ro (O_ASYNC | O_CREAT | O_RDONLY)
- #define f_file_flag_async_create_wo (O_ASYNC | O_CREAT | O_WRONLY)
- #define f_file_flag_async_create_rw (O_ASYNC | O_CREAT | O_RDRW)
- #define f_file_flag_async_create_new_ro (O_ASYNC | O_CREAT | O_EXCL | O_RDONLY)
- #define f_file_flag_async_create_new_wo (O_ASYNC | O_CREAT | O_EXCL | O_WRONLY)
- #define f_file_flag_async_create_new_rw (O_ASYNC | O_CREAT | O_EXCL | O_RDRW)
-
- // file open flags pre-combined with direct io (which works synchronously).
- #define f_file_flag_direct_ro (O_DIRECT | O_RDONLY)
- #define f_file_flag_direct_wo (O_DIRECT | O_WRONLY)
- #define f_file_flag_direct_rw (O_DIRECT | O_RDRW)
- #define f_file_flag_direct_create_ro (O_DIRECT | O_CREAT | O_RDONLY)
- #define f_file_flag_direct_create_wo (O_DIRECT | O_CREAT | O_WRONLY)
- #define f_file_flag_direct_create_rw (O_DIRECT | O_CREAT | O_RDRW)
- #define f_file_flag_direct_create_new_ro (O_DIRECT | O_CREAT | O_EXCL | O_RDONLY)
- #define f_file_flag_direct_create_new_wo (O_DIRECT | O_CREAT | O_EXCL | O_WRONLY)
- #define f_file_flag_direct_create_new_rw (O_DIRECT | O_CREAT | O_EXCL | O_RDRW)
-
- // file open flags pre-combined with large_file.
- #define f_file_flag_large_ro (O_LARGEFILE | O_RDONLY)
- #define f_file_flag_large_wo (O_LARGEFILE | O_WRONLY)
- #define f_file_flag_large_rw (O_LARGEFILE | O_RDRW)
- #define f_file_flag_large_sync_ro (O_LARGEFILE | O_SYNC | O_RDONLY)
- #define f_file_flag_large_sync_wo (O_LARGEFILE | O_SYNC | O_WRONLY)
- #define f_file_flag_large_sync_rw (O_LARGEFILE | O_SYNC | O_RDRW)
- #define f_file_flag_large_sync_create_ro (O_LARGEFILE | O_SYNC | O_CREAT | O_RDONLY)
- #define f_file_flag_large_sync_create_wo (O_LARGEFILE | O_SYNC | O_CREAT | O_WRONLY)
- #define f_file_flag_large_sync_create_rw (O_LARGEFILE | O_SYNC | O_CREAT | O_RDRW)
- #define f_file_flag_large_sync_create_new_ro (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_RDONLY)
- #define f_file_flag_large_sync_create_new_wo (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_WRONLY)
- #define f_file_flag_large_sync_create_new_rw (O_LARGEFILE | O_SYNC | O_CREAT | O_EXCL | O_RDRW)
- #define f_file_flag_large_async_ro (O_LARGEFILE | O_ASYNC | O_RDONLY)
- #define f_file_flag_large_async_wo (O_LARGEFILE | O_ASYNC | O_WRONLY)
- #define f_file_flag_large_async_rw (O_LARGEFILE | O_ASYNC | O_RDRW)
- #define f_file_flag_large_async_create_ro (O_LARGEFILE | O_ASYNC | O_CREAT | O_RDONLY)
- #define f_file_flag_large_async_create_wo (O_LARGEFILE | O_ASYNC | O_CREAT | O_WRONLY)
- #define f_file_flag_large_async_create_rw (O_LARGEFILE | O_ASYNC | O_CREAT | O_RDRW)
- #define f_file_flag_large_async_create_new_ro (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_RDONLY)
- #define f_file_flag_large_async_create_new_wo (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_WRONLY)
- #define f_file_flag_large_async_create_new_rw (O_LARGEFILE | O_ASYNC | O_CREAT | O_EXCL | O_RDRW)
-#endif // _di_f_file_flag_
-
-/**
- * File mode related functionality.
- *
- * There are two types of file modes the f_file_mode_t macros associate with.
- *
- * The first type is the traditional mode type, associated with mode_t.
- *
- * The second type is f_file_mode_t, which utilizes 8-bit types with the following structure:
- *
- * There should only be a single bit for each 'r', 'w', 'x', and 'X' bit (as well as 'S', 's', and 't'):
- * 'r' = read bit.
- * 'w' = write bit.
- * 'x' = execute bit.
- * 'X' = execute only if already execute bit.
- * 'S' = set user bit (setuid).
- * 's' = set group bit (setgid).
- * 't' = sticky bit.
- *
- * The file mode macros with "f_file_mode_" prefix (has no "_t") refer to the first type (mode_t).
- * The file mode macros with "f_file_mode_t" prefix refer to the second type (f_file_mode_t).
- */
-#ifndef _di_f_file_mode_
- typedef uint32_t f_file_mode_t;
-
- #define f_file_mode_t_block_special 0x77000000 // 0111 0111 0000 0000 0000 0000 0000 0000
- #define f_file_mode_t_block_owner 0x00ff0000 // 0000 0000 1111 1111 0000 0000 0000 0000
- #define f_file_mode_t_block_group 0x0000ff00 // 0000 0000 0000 0000 1111 1111 0000 0000
- #define f_file_mode_t_block_world 0x000000ff // 0000 0000 0000 0000 0000 0000 1111 1111
-
- #define f_file_mode_t_block_all 0x77ffffff // 0111 0111 1111 1111 1111 1111 1111 1111
- #define f_file_mode_t_block_standard 0x00ffffff // 0000 0000 1111 1111 1111 1111 1111 1111
-
- #define f_file_mode_t_mask_how_add 0x070f0f0f // 0000 0111 0000 1111 0000 1111 0000 1111
- #define f_file_mode_t_mask_how_subtract 0x70f0f0f0 // 0111 0000 1111 0000 1111 0000 1111 0000
-
- #define f_file_mode_t_mask_bit_execute 0x00111111 // 0000 0000 0001 0001 0001 0001 0001 0001
- #define f_file_mode_t_mask_bit_execute_only 0x00888888 // 0000 0000 1000 1000 1000 1000 1000 1000
- #define f_file_mode_t_mask_bit_read 0x00444444 // 0000 0000 0100 0100 0100 0100 0100 0100
- #define f_file_mode_t_mask_bit_set_group 0x22000000 // 0010 0010 0000 0000 0000 0000 0000 0000
- #define f_file_mode_t_mask_bit_set_owner 0x44000000 // 0100 0100 0000 0000 0000 0000 0000 0000
- #define f_file_mode_t_mask_bit_sticky 0x11000000 // 0001 0001 0000 0000 0000 0000 0000 0000
- #define f_file_mode_t_mask_bit_write 0x00222222 // 0000 0000 0010 0010 0010 0010 0010 0010
-
- #define f_file_mode_t_replace_owner 0x1 // 0000 0001
- #define f_file_mode_t_replace_group 0x2 // 0000 0010
- #define f_file_mode_t_replace_world 0x4 // 0000 0100
- #define f_file_mode_t_replace_special 0x8 // 0000 1000
- #define f_file_mode_t_replace_directory 0x10 // 0001 0000
-
- #define f_file_mode_t_replace_all 0x1f // 0001 1111
- #define f_file_mode_t_replace_other 0x18 // 0001 1000
- #define f_file_mode_t_replace_standard 0x7 // 0000 0111
-
- // file permission modes (mode_t).
- #define f_file_mode_owner_rwx S_IRWXU
- #define f_file_mode_owner_r S_IRUSR
- #define f_file_mode_owner_w S_IWUSR
- #define f_file_mode_owner_x S_IXUSR
- #define f_file_mode_owner_rw (S_IRUSR | S_IWUSR)
- #define f_file_mode_owner_rx (S_IRUSR | S_IXUSR)
- #define f_file_mode_owner_wx (S_IWUSR | S_IXUSR)
- #define f_file_mode_group_rwx S_IRWXG
- #define f_file_mode_group_r S_IRGRP
- #define f_file_mode_group_w S_IWGRP
- #define f_file_mode_group_x S_IXGRP
- #define f_file_mode_group_rw (S_IRGRP | S_IWGRP)
- #define f_file_mode_group_rx (S_IRGRP | S_IXGRP)
- #define f_file_mode_group_wx (S_IWGRP | S_IXGRP)
- #define f_file_mode_world_rwx S_IRWXO
- #define f_file_mode_world_r S_IROTH
- #define f_file_mode_world_w S_IWOTH
- #define f_file_mode_world_x S_IXOTH
- #define f_file_mode_world_rw (S_IROTH | S_IWOTH)
- #define f_file_mode_world_rx (S_IROTH | S_IXOTH)
- #define f_file_mode_world_wx (S_IWOTH | S_IXOTH)
-
- #define f_file_mode_all_rwx (f_file_mode_owner_rwx | f_file_mode_group_rwx | f_file_mode_world_rwx)
- #define f_file_mode_all_rw (f_file_mode_owner_rw | f_file_mode_group_rw | f_file_mode_world_rw)
- #define f_file_mode_all_wx (f_file_mode_owner_wx | f_file_mode_group_wx | f_file_mode_world_wx)
- #define f_file_mode_all_rx (f_file_mode_owner_rx | f_file_mode_group_rx | f_file_mode_world_rx)
- #define f_file_mode_all_r (f_file_mode_owner_r | f_file_mode_group_r | f_file_mode_world_r)
- #define f_file_mode_all_w (f_file_mode_owner_w | f_file_mode_group_w | f_file_mode_world_w)
- #define f_file_mode_all_x (f_file_mode_owner_x | f_file_mode_group_x | f_file_mode_world_x)
-
- // file mode set-uid/set-gid/sticky-bits and all bits (mode_t).
- #define f_file_mode_special_set_user S_ISUID
- #define f_file_mode_special_set_group S_ISGID
- #define f_file_mode_special_sticky S_ISVTX
- #define f_file_mode_special_all (S_ISUID | S_ISGID | S_ISVTX)
-
- // all permissions modes and special modes (mode_t).
- #define f_file_mode_all (f_file_mode_special_all | f_file_mode_all_rwx)
-
- // special file mode combinations (mode_t).
- #define f_file_mode_user_access (f_file_mode_owner_rwx | f_file_mode_group_rwx | f_file_mode_world_x)
- #define f_file_mode_user_directory (f_file_mode_owner_rwx | f_file_mode_group_rwx)
- #define f_file_mode_user_file (f_file_mode_owner_rw | f_file_mode_group_rw)
- #define f_file_mode_user_program (f_file_mode_owner_rx | f_file_mode_group_rx)
- #define f_file_mode_user_protected (f_file_mode_owner_r | f_file_mode_group_r)
-#endif // _di_f_file_mode_
-
-/**
* Check if a file can be accessed.
*
* @param path
build_libraries-individual -lf_memory
build_sources_library file.c private-file.c
build_sources_program
-build_sources_headers file.h
+build_sources_headers file.h file-common.h
build_sources_script
build_sources_setting
build_script yes
// fll-0 fss includes
#include <level_0/fss-common.h>
-#include <level_0/fss-quoted.h>
-#include <level_0/fss-named.h>
-#include <level_0/fss-nest.h>
-#include <level_0/fss-set.h>
+#include <level_0/fss_quoted.h>
+#include <level_0/fss_named.h>
+#include <level_0/fss_nest.h>
+#include <level_0/fss_set.h>
#ifdef __cplusplus
extern "C" {
build_libraries-individual -lf_utf -lf_memory
build_sources_library fss.c
build_sources_program
-build_sources_headers fss.h fss-common.h fss-named.h fss-nest.h fss-quoted.h fss-set.h
+build_sources_headers fss.h fss-common.h fss_named.h fss_nest.h fss_quoted.h fss_set.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Path
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by project path.
+ *
+ * This is auto-included by path.h and should not need to be explicitly included.
+ */
+#ifndef _F_path_common_h
+#define _F_path_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Standard path defines.
+ *
+ * The path separator, intended to be represented as a single character.
+ * The path separator length must be a 1-byte wide character.
+ *
+ * The "current" path separator "." represents a part of the path that potentially may represent the current path.
+ * This is expected to be followed by a separator "/".
+ *
+ * The path variable separator is intended to represent the path separator used in the PATH environment variable.
+ * PATH="/bin:/usr/bin", the path variable separator is ':'.
+ * The path variable separator must be a 1-byte wide character.
+ *
+ * The path extension separator is for the separator that separates the main part of a file path with its extension (which is generally a '.').
+ */
+#ifndef _di_f_path_defines_
+ #define f_path_separator "/"
+ #define f_path_separator_current "."
+ #define f_path_separator_variable ":"
+
+ #define f_path_separator_length 1
+ #define f_path_separator_current_length 1
+ #define f_path_separator_variable_length 1
+
+ #define f_path_extension_separator "."
+
+ #define f_path_extension_separator_length 1
+
+ #define f_path_environment "PATH"
+ #define f_path_home_wildcard "~"
+ #define f_path_present_working "PWD"
+ #define f_path_present_working_old "OLDPWD"
+
+ #define f_path_environment_length 4
+ #define f_path_home_wildcard_length 1
+ #define f_path_present_working_length 3
+ #define f_path_present_working_old_length 6
+
+ #define f_path_max PATH_MAX
+#endif // _di_f_path_defines_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_path_common_h
#include <level_0/memory.h>
#include <level_0/string.h>
+// fll-0 path includes
+#include <level_0/path-common.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Standard path defines.
- *
- * The path separator, intended to be represented as a single character.
- * The path separator length must be a 1-byte wide character.
- *
- * The "current" path separator "." represents a part of the path that potentially may represent the current path.
- * This is expected to be followed by a separator "/".
- *
- * The path variable separator is intended to represent the path separator used in the PATH environment variable.
- * PATH="/bin:/usr/bin", the path variable separator is ':'.
- * The path variable separator must be a 1-byte wide character.
- *
- * The path extension separator is for the separator that separates the main part of a file path with its extension (which is generally a '.').
- */
-#ifndef _di_f_path_defines_
- #define f_path_separator "/"
- #define f_path_separator_current "."
- #define f_path_separator_variable ":"
-
- #define f_path_separator_length 1
- #define f_path_separator_current_length 1
- #define f_path_separator_variable_length 1
-
- #define f_path_extension_separator "."
-
- #define f_path_extension_separator_length 1
-
- #define f_path_environment "PATH"
- #define f_path_home_wildcard "~"
- #define f_path_present_working "PWD"
- #define f_path_present_working_old "OLDPWD"
-
- #define f_path_environment_length 4
- #define f_path_home_wildcard_length 1
- #define f_path_present_working_length 3
- #define f_path_present_working_old_length 6
-
- #define f_path_max PATH_MAX
-#endif // _di_f_path_defines_
-
-/**
* Change to a path.
*
* @param path
build_libraries-individual -lf_memory
build_sources_library path.c private-path.c
build_sources_program
-build_sources_headers path.h
+build_sources_headers path.h path-common.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Serialize
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by project serialize.
+ *
+ * This is auto-included by serialize.h and should not need to be explicitly included.
+ */
+#ifndef _F_serialize_common_h
+#define _F_serialize_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_serialize_splitters_
+ #define f_serialize_simple_splitter ':'
+ #define f_serialize_delimited_splitter '\''
+ #define f_serialize_delimited_delimiter '\\'
+
+ #define f_serialize_simple_splitter_string ":"
+ #define f_serialize_delimited_splitter_string "'"
+ #define f_serialize_delimited_delimiter_string "\\"
+#endif // _di_f_serialize_splitters_
+
+#ifndef _di_f_serialize_default_allocation_step_
+ // provide a UTF-8 friendly allocation step.
+ #define f_serialize_default_allocation_step 4
+#endif // _di_f_serialize_default_allocation_step_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_serialize_common_h
#include <level_0/string.h>
#include <level_0/utf.h>
+// fll-0 serialize includes
+#include <level_0/serialize-common.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef _di_f_serialize_splitters_
- #define f_serialize_simple_splitter ':'
- #define f_serialize_delimited_splitter '\''
- #define f_serialize_delimited_delimiter '\\'
-
- #define f_serialize_simple_splitter_string ":"
- #define f_serialize_delimited_splitter_string "'"
- #define f_serialize_delimited_delimiter_string "\\"
-#endif // _di_f_serialize_splitters_
-
-#ifndef _di_f_serialize_default_allocation_step_
- // provide a UTF-8 friendly allocation step.
- #define f_serialize_default_allocation_step 4
-#endif // _di_f_serialize_default_allocation_step_
-
/**
* Serialized a string using the Simple serialize algorithm.
*
build_libraries-individual -lf_utf -lf_memory
build_sources_library serialize.c private-serialize.c
build_sources_program
-build_sources_headers serialize.h
+build_sources_headers serialize.h serialize-common.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Signal
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by project signal.
+ *
+ * This is auto-included by signal.h and should not need to be explicitly included.
+ */
+#ifndef _F_signal_common_h
+#define _F_signal_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This holds a signal type.
+ *
+ * flags: The signal flags associated with this.
+ * id: The signal descriptor.
+ * set: The signal set.
+ */
+#ifndef _di_f_signal_t_
+ typedef struct {
+ int flags;
+ int id;
+ sigset_t set;
+ } f_signal_t;
+
+ #define f_signal_t_initialize {0, 0, { 0 } }
+
+ #define f_macro_signal_t_initialize(flags, id, set) { flags, id, set }
+#endif // _di_f_signal_t_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_signal_common_h
build_libraries-individual
build_sources_library signal.c
build_sources_program
-build_sources_headers signal.h
+build_sources_headers signal.h signal-common.h
build_sources_script
build_sources_setting
build_script yes
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Socket
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines common data to be used for/by project socket.
+ *
+ * This is auto-included by socket.h and should not need to be explicitly included.
+ */
+#ifndef _F_socket_common_h
+#define _F_socket_common_h
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+/**
+ * Socket Types.
+ */
+#ifndef _di_f_socket_types_
+ enum {
+ f_socket_close_fast = 1, // As in close();
+ f_socket_close_read, // As in shutdown(, SHUT_RD);
+ f_socket_close_write, // As in shutdown(, SHUT_WR);
+ f_socket_close_read_write, // As in shutdown(, SHUT_RDWR);
+ };
+#endif // _di_f_socket_types_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_socket_common_h
#include <sys/un.h>
#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>
+// fll-0 socket includes
+#include <level_0/socket-common.h>
+
#ifdef __cplusplus
extern "C"{
#endif
/**
- * Socket Types.
- */
-#ifndef _di_f_socket_types_
- enum {
- f_socket_close_fast = 1, // As in close();
- f_socket_close_read, // As in shutdown(, SHUT_RD);
- f_socket_close_write, // As in shutdown(, SHUT_WR);
- f_socket_close_read_write, // As in shutdown(, SHUT_RDWR);
- };
-#endif // _di_f_socket_types_
-
-/**
* Bind a UNIX socket.
*
* @param path
build_libraries-individual -lf_memory
build_sources_library socket.c
build_sources_program
-build_sources_headers socket.h
+build_sources_headers socket.h socket-common.h
build_sources_script
build_sources_setting
build_script yes
#include <level_0/type.h>
// fll-0 string includes
-#include <level_0/string_common.h>
+#include <level_0/string-common.h>
#include <level_0/string_dynamic.h>
#include <level_0/string_map.h>
#include <level_0/string_quantity.h>
build_libraries-individual -lf_memory
build_sources_library
build_sources_program
-build_sources_headers string.h string_common.h string_dynamic.h string_map.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