From 8aca0a57708a2d206322e442db8111cb1f70e8a5 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 27 Apr 2021 18:55:14 -0500 Subject: [PATCH] Update: Remove init program. The controller program can fully operate as a init program. The pre_init/pivot_root will likely have its own dedicated program and/or scripts. --- level_3/init/c/init.c | 132 ------------- level_3/init/c/init.h | 331 ------------------------------- level_3/init/c/main.c | 45 ----- level_3/init/c/private-init.c | 374 ----------------------------------- level_3/init/c/private-init.h | 49 ----- level_3/init/data/build/defines | 2 - level_3/init/data/build/dependencies | 19 -- level_3/init/data/build/settings | 57 ------ 8 files changed, 1009 deletions(-) delete mode 100644 level_3/init/c/init.c delete mode 100644 level_3/init/c/init.h delete mode 100644 level_3/init/c/main.c delete mode 100644 level_3/init/c/private-init.c delete mode 100644 level_3/init/c/private-init.h delete mode 100644 level_3/init/data/build/defines delete mode 100644 level_3/init/data/build/dependencies delete mode 100644 level_3/init/data/build/settings diff --git a/level_3/init/c/init.c b/level_3/init/c/init.c deleted file mode 100644 index 97feec0..0000000 --- a/level_3/init/c/init.c +++ /dev/null @@ -1,132 +0,0 @@ -#include "init.h" -#include "private-init.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_init_print_help_ - f_status_t init_print_help(const f_file_t output, const f_color_context_t context) { - - fll_program_print_help_header(output, context, init_name_long, init_version); - - fll_program_print_help_option(output, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); - fll_program_print_help_option(output, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); - fll_program_print_help_option(output, context, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on light backgrounds."); - fll_program_print_help_option(output, context, f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, "Do not output in color."); - fll_program_print_help_option(output, context, f_console_standard_short_version_s, f_console_standard_long_version_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Print only the version number."); - - fll_program_print_help_usage(output, context, init_name, f_string_empty_s); - - f_color_print(output.stream, context.set.important, " Notes:"); - fprintf(output.stream, "%c", f_string_eol_s[0]); - - fprintf(output.stream, " This program is intended to be directly called by the kernel during boot.%c", f_string_eol_s[0]); - fprintf(output.stream, "%c", f_string_eol_s[0]); - - // @todo: this should still print the kernel command options. - - return F_none; - } -#endif // _di_init_print_help_ - -#ifndef _di_init_main_ - f_status_t init_main(const f_console_arguments_t arguments, init_data_t *data) { - f_status_t status = F_none; - - { - const f_console_parameters_t parameters = f_macro_console_parameters_t_initialize(data->parameters, init_total_parameters); - - { - f_console_parameter_id_t ids[3] = { init_parameter_no_color, init_parameter_light, init_parameter_dark }; - const f_console_parameter_ids_t choices = f_macro_console_parameter_ids_t_initialize(ids, 3); - - status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context); - - if (data->context.set.error.before) { - data->error.context = data->context.set.error; - data->error.notable = data->context.set.notable; - } - else { - data->context.set.warning = f_color_set_empty_s; - data->context.set.error = f_color_set_empty_s; - data->context.set.title = f_color_set_empty_s; - data->context.set.notable = f_color_set_empty_s; - data->context.set.important = f_color_set_empty_s; - data->context.set.standout = f_color_set_empty_s; - data->context.set.normal = f_color_set_empty_s; - data->context.set.normal_reset = f_color_set_empty_s; - - data->error.context = f_color_set_empty_s; - data->error.notable = f_color_set_empty_s; - } - - if (F_status_is_error(status)) { - if (data->error.verbosity != f_console_verbosity_quiet) { - fll_error_print(data->error, F_status_set_fine(status), "fll_program_parameter_process", F_true); - fprintf(data->error.to.stream, "%c", f_string_eol_s[0]); - } - - init_delete_data(data); - return F_status_set_error(status); - } - } - - status = F_none; - } - - if (data->parameters[init_parameter_help].result == f_console_result_found) { - init_print_help(data->output, data->context); - - init_delete_data(data); - return F_none; - } - - if (data->parameters[init_parameter_version].result == f_console_result_found) { - fll_program_print_version(data->output, init_version); - - init_delete_data(data); - return F_none; - } - - // @todo - - // ensure a newline is always put at the end of the program execution, unless in quiet mode. - if (data->error.verbosity != f_console_verbosity_quiet) { - if (F_status_is_error(status)) { - fprintf(data->error.to.stream, "%c", f_string_eol_s[0]); - } - } - - init_delete_data(data); - return status; - } -#endif // _di_init_main_ - -#ifndef _di_init_delete_data_ - f_status_t init_delete_data(init_data_t *data) { - - for (f_array_length_t i = 0; i < init_total_parameters; i++) { - f_macro_array_lengths_t_delete_simple(data->parameters[i].locations); - f_macro_array_lengths_t_delete_simple(data->parameters[i].locations_sub); - f_macro_array_lengths_t_delete_simple(data->parameters[i].values); - } // for - - f_macro_array_lengths_t_delete_simple(data->remaining); - - f_macro_string_dynamic_t_delete_simple(data->setting_kernel.root); - f_macro_string_dynamic_t_delete_simple(data->setting_kernel.root_group); - f_macro_string_dynamic_t_delete_simple(data->setting_kernel.root_sub); - f_macro_string_dynamic_t_delete_simple(data->setting_kernel.run); - f_macro_string_dynamic_t_delete_simple(data->setting_kernel.settings); - f_macro_string_dynamic_t_delete_simple(data->setting_kernel.settings_name); - - f_macro_color_context_t_delete_simple(data->context); - - return F_none; - } -#endif // _di_init_delete_data_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_3/init/c/init.h b/level_3/init/c/init.h deleted file mode 100644 index 446b780..0000000 --- a/level_3/init/c/init.h +++ /dev/null @@ -1,331 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: Init - * API Version: 0.5 - * Licenses: lgplv2.1 - * - * This is the Init program. - * - * This program utilizes the Featureless Linux Library. - * This program performs the basic system boot operations. - * - * This program does the following: - * 1) perform all initial filesystem setup tasks (creating directories, mounting, setting permissions, populated device files, etc..). - * 2) finding the desired/wanted boot partition, mounting it (and any other mount points). - * 3) booting into target partition using a given target program (controller, bash, etc..). - * 4) falling back into a failsafe environment on error (such as bash). - */ -#ifndef _init_h - -// libc includes -#include -#include - -// fll-0 includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// fll-1 includes -#include -#include - -// fll-2 includes -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_init_version_ - #define init_major_version "0" - #define init_minor_version "5" - #define init_micro_version "3" - #define init_version init_major_version f_string_ascii_period init_minor_version f_string_ascii_period init_micro_version -#endif // _di_init_version_ - -#ifndef _di_init_name_ - #define init_name "init" - #define init_name_long "Init Program" -#endif // _di_init_name_ - -#ifndef _di_init_defines_ - #define init_string_classic "classic" - #define init_string_color "color" // for specifying color mode. - #define init_string_custom "custom" - #define init_string_dark "dark" - #define init_string_debug "debug" - #define init_string_failsafe "failsafe" // default to /bin/bash if provided failsafe is invalid, or prompt for valid??. - #define init_string_light "light" - #define init_string_maintenance "maintenance" - #define init_string_mode "mode" - #define init_string_no "no" - #define init_string_normal "normal" - #define init_string_quiet "quiet" - #define init_string_root "root" - #define init_string_root_group "root_group" // floating root group id (such as d_root). - #define init_string_root_mode "root_mode" // floating root mode (such as 2751). - #define init_string_root_size "root_size" - #define init_string_root_sub "root_sub" // was "subroot". - #define init_string_run "run" - #define init_string_settings "settings" - #define init_string_settings_name "settings_name" - #define init_string_squash "squash" - #define init_string_squish "squish" - #define init_string_verbose "verbose" - #define init_string_verbosity "verbosity" // quite, normal, verbose, debug - #define init_string_yes "yes" - - #define init_string_classic_length 7 - #define init_string_color_length 5 - #define init_string_custom_length 6 - #define init_string_dark_length 4 - #define init_string_debug_length 5 - #define init_string_failsafe_length 8 - #define init_string_light_length 5 - #define init_string_maintenance_length 11 - #define init_string_mode_length 4 - #define init_string_no_length 2 - #define init_string_normal_length 6 - #define init_string_quiet_length 5 - #define init_string_root_length 4 - #define init_string_root_group_length 10 - #define init_string_root_mode_length 9 - #define init_string_root_size_length 9 - #define init_string_root_sub_length 8 - #define init_string_run_length 3 - #define init_string_settings_length 8 - #define init_string_settings_name_length 13 - #define init_string_squash_length 6 - #define init_string_squish_length 6 - #define init_string_verbose_length 7 - #define init_string_verbosity_length 9 - #define init_string_yes_length 3 - - #define init_path_proc "/proc" - #define init_path_proc_cmdline "/proc/cmdline" - #define init_path_settings_0 "settings" - #define init_path_settings_1 ".settings" - - #define init_path_proc_lenght 5 - #define init_path_proc_cmdline_length 13 - #define init_path_settings_0_length 8 - #define init_path_settings_1_length 9 - - #define init_path_extension_device ".device" - #define init_path_extension_lock ".lock" - #define init_path_extension_squash ".sfs" - - #define init_path_extension_device_length 7 - #define init_path_extension_lock_length 5 - #define init_path_extension_squash_length 3 - - #define init_device_by_device "device" // such as: "pci-0000:00:1.0-ata-1" - #define init_device_by_id "id" // such as: "ata-WIN_SSD_1234567890123" - #define init_device_by_label "label" // such as: "my_usb" from LABEL="my_usb" - #define init_device_by_path "path" // such as: "sda1" - #define init_device_by_type "type" // such as: "ext4" - #define init_device_by_uuid "uuid" // such as: "80a2a094-8536-46d9-aa54-cd34c142422b" from UUID="80a2a094-8536-46d9-aa54-cd34c142422b" - #define init_device_by_uuid_part "partuuid" // such as: "0abcdef1-23" from PARTUUID="0abcdef1-34" - - #define init_device_by_device_length 6 - #define init_device_by_id_length 2 - #define init_device_by_label_length 5 - #define init_device_by_path_length 4 - #define init_device_by_type_length 4 - #define init_device_by_uuid_length 4 - #define init_device_by_uuid_part_length 8 - - enum { - init_mode_classic = 1, - init_mode_custom, - init_mode_maintenance, - init_mode_normal, - init_mode_squash, - init_mode_squish, - }; - - enum { - init_parameter_help, - init_parameter_light, - init_parameter_dark, - init_parameter_no_color, - init_parameter_version, - }; - - #define init_console_parameter_t_initialize \ - { \ - f_console_parameter_t_initialize(f_console_standard_short_help_s, f_console_standard_long_help_s, 0, 0, f_console_type_normal), \ - f_console_parameter_t_initialize(f_console_standard_short_light_s, f_console_standard_long_light_s, 0, 0, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_dark_s, f_console_standard_long_dark_s, 0, 0, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_no_color_s, f_console_standard_long_no_color_s, 0, 0, f_console_type_inverse), \ - f_console_parameter_t_initialize(f_console_standard_short_version_s, f_console_standard_long_version_s, 0, 0, f_console_type_inverse), \ - } - - #define init_total_parameters 5 -#endif // _di_init_defines_ - -#ifndef _di_init_setting_kernel_t_ - typedef struct { - bool failsafe; - - bool lock_color; - bool lock_devices; - bool lock_failsafe; - bool lock_mode; - bool lock_root; - bool lock_root_group; - bool lock_root_mode; - bool lock_root_size; - bool lock_root_sub; - bool lock_run; - bool lock_settings; - bool lock_settings_name; - bool lock_verbosity; - - uint8_t color; - uint8_t mode; - uint8_t root_mode; - uint8_t verbosity; - - f_number_unsigned_t root_size; - - f_string_dynamic_t root; - f_string_dynamic_t root_group; - f_string_dynamic_t root_sub; - f_string_dynamic_t run; - f_string_dynamic_t settings; - f_string_dynamic_t settings_name; - } init_setting_kernel_t; - - #define init_setting_kernel_t_initialize \ - { \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - F_false, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - } -#endif // _di_init_setting_kernel_ - -#ifndef _di_init_data_t_ - typedef struct { - f_console_parameter_t parameters[init_total_parameters]; - - f_array_lengths_t remaining; - - f_file_t output; - fll_error_print_t error; - - mode_t umask; - f_signal_t signal; - - init_setting_kernel_t setting_kernel; - - f_color_context_t context; - } init_data_t; - - #define init_data_initialize \ - { \ - init_console_parameter_t_initialize, \ - f_array_lengths_t_initialize, \ - f_macro_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ - fll_error_print_t_initialize, \ - 0, \ - f_signal_t_initialize, \ - init_setting_kernel_t_initialize, \ - f_color_context_t_initialize, \ - } -#endif // _di_init_data_t_ - -/** - * Print help. - * - * @param output - * The file to print to. - * @param context - * The color context settings. - * - * @return - * F_none on success. - */ -#ifndef _di_init_print_help_ - extern f_status_t init_print_help(const f_file_t output, const f_color_context_t context); -#endif // _di_init_print_help_ - -/** - * Execute main program. - * - * Be sure to call init_delete_data() after executing this. - * - * @param arguments - * The parameters passed to the process. - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - * - * @see init_delete_data() - */ -#ifndef _di_init_main_ - extern f_status_t init_main(const f_console_arguments_t arguments, init_data_t *data); -#endif // _di_init_main_ - -/** - * Deallocate data. - * - * Be sure to call this after executing init_main(). - * - * @param data - * The program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - * - * @see init_main() - */ -#ifndef _di_init_delete_data_ - extern f_status_t init_delete_data(init_data_t *data); -#endif // _di_init_delete_data_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _init_h diff --git a/level_3/init/c/main.c b/level_3/init/c/main.c deleted file mode 100644 index 45878cf..0000000 --- a/level_3/init/c/main.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "init.h" - -int main(const unsigned long argc, const f_string_t *argv) { - const f_console_arguments_t arguments = { argc, argv }; - init_data_t data = init_data_initialize; - - f_signal_set_empty(&data.signal.set); - f_signal_set_add(F_signal_abort, &data.signal.set); - f_signal_set_add(F_signal_hangup, &data.signal.set); - f_signal_set_add(F_signal_interrupt, &data.signal.set); - f_signal_set_add(F_signal_quit, &data.signal.set); - f_signal_set_add(F_signal_termination, &data.signal.set); - f_signal_mask(SIG_BLOCK, &data.signal.set, 0); - - // if there is an error opening a signal descriptor, then do not handle signals. - if (F_status_is_error(f_signal_open(&data.signal))) { - f_signal_mask(SIG_UNBLOCK, &data.signal.set, 0); - f_signal_close(&data.signal); - } - - // @fixme: bad design in POSIX where there is no get umask without setting it. - data.umask = umask(0); - - // restore umask. - umask(data.umask); - - const f_status_t status = init_main(arguments, &data); - - f_signal_close(&data.signal); - - // flush output pipes before closing. - fflush(f_type_output); - fflush(f_type_error); - - // close all open file descriptors. - close(f_type_descriptor_output); - close(f_type_descriptor_input); - close(f_type_descriptor_error); - - if (F_status_is_error(status)) { - return 1; - } - - return 0; -} diff --git a/level_3/init/c/private-init.c b/level_3/init/c/private-init.c deleted file mode 100644 index b0b2c29..0000000 --- a/level_3/init/c/private-init.c +++ /dev/null @@ -1,374 +0,0 @@ -#include "init.h" -#include "private-init.h" - -/* -Use the initrd_init source to base this project off, but be a little more generic than Kevux specific. -1: mount temporary proc -2: read kernel command line, look for (use IKI syntax?): - - setting:"" - - failsafe:"" (such as failsafe:"/bin/bash") - - root:"" (such as root:"" (for floating root), root:"/dev/abc", root:"UUID:0000") - - subroot:"" - - mode:"" (such as mode:"squash", mode:"squish", mode:"maintenance", mode:"classic", mode:"install") - - run:"" (was "finalinit", such as run:"/sbin/init" or run:"/bin/bash") - - setting_name="" (such as a name fo the settings file). -3: act based on those options. -4: create and mount floating root. -5: unmount temporary proc and anything else that is temporary. -6: perform pivot root. -7: perform chroot. -8: perform any setup tasks. -9: execute program from run:"". -10: at any point on error, print error the execute failsafe:"". - -Settings should utilize/process: -- blkid, find devices (is there a blkid library?). -- mdadm, for mounting any raid devices. -- cryptsetup, for decrypting a device. -- squashfs, unsquashfs - -Support ".lock" files to lock out adding custom command line parameters (such as home.lock to prevent home_device:"" from being used). -Support "settings/" or ".settings/". -Support ".sfs" loopback mounting. - -process /proc/partitions, and support things like: LABEL=. -consider matching partition types as well. -Consider the "*.device" files such that they are also use IKI. -*/ - -#ifndef _di_init_load_failsafe_ - f_status_t init_load_failsafe(const init_data_t data) { - - return F_none; - } -#endif // _di_init_load_failsafe_ - -#ifndef _di_init_load_kernel_setting_ - f_status_t init_load_kernel_setting(const init_data_t data, init_setting_kernel_t *setting_kernel) { - f_status_t status = F_none; - - status = f_directory_exists(init_path_proc_cmdline); - - if (F_status_is_error(status)) { - fll_error_file_print(data.error, F_status_set_fine(status), "f_directory_exists", F_true, init_path_proc_cmdline, "exists", fll_error_file_type_directory); - return status; - } - - if (status == F_false) { - status = f_directory_create(init_path_proc_cmdline, f_file_mode_user_directory); - - if (F_status_is_error(status)) { - fll_error_file_print(data.error, F_status_set_fine(status), "f_directory_create", F_true, init_path_proc_cmdline, "create", fll_error_file_type_directory); - return status; - } - } - - f_file_t command_line = f_file_t_initialize; - - // Note: this will specifically not be unmounted on error. - mount("proc", init_path_proc_cmdline, "proc", 0, ""); - - status = f_file_stream_open(init_path_proc_cmdline, 0, &command_line); - - if (F_status_is_error(status)) { - fll_error_file_print(data.error, F_status_set_fine(status), "f_file_stream_open", F_true, init_path_proc_cmdline, "open", fll_error_file_type_file); - return status; - } - - if (init_signal_received(data)) { - f_file_stream_close(F_true, &command_line); - return F_signal; - } - - f_string_dynamic_t buffer = f_string_dynamic_t_initialize; - - status = f_file_stream_read(command_line, 1, &buffer); - - if (F_status_is_error(status)) { - fll_error_file_print(data.error, F_status_set_fine(status), "f_file_stream_read", F_true, init_path_proc_cmdline, "read", fll_error_file_type_file); - } - - if (F_status_is_error_not(status)) { - f_string_dynamic_t cache = f_string_dynamic_t_initialize; - - // set used to 1 with size of 0 to represent that the parameter was not specified via the kernel command line. - setting_kernel->root.used = 1; - setting_kernel->root_group.used = 1; - setting_kernel->root_sub.used = 1; - setting_kernel->run.used = 1; - setting_kernel->settings.used = 1; - setting_kernel->settings_name.used = 1; - - const f_string_t parameter_name[] = { - init_string_color, - init_string_failsafe, - init_string_mode, - init_string_root, - init_string_root_group, - init_string_root_mode, - init_string_root_size, - init_string_root_sub, - init_string_run, - init_string_settings, - init_string_settings_name, - init_string_verbosity, - }; - - const f_array_length_t parameter_length[] = { - init_string_color_length, - init_string_failsafe_length, - init_string_mode_length, - init_string_root_length, - init_string_root_group_length, - init_string_root_mode_length, - init_string_root_size_length, - init_string_root_sub_length, - init_string_run_length, - init_string_settings_length, - init_string_settings_name_length, - init_string_verbosity_length, - }; - - f_string_dynamic_t * const parameter_value[] = { - &cache, - &cache, - &cache, - &setting_kernel->root, - &setting_kernel->root_group, - &cache, - &cache, - &setting_kernel->root_sub, - &setting_kernel->run, - &setting_kernel->settings, - &setting_kernel->settings_name, - &cache, - }; - - bool * const parameter_value_bool[] = { - 0, - &setting_kernel->failsafe, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }; - - uint8_t * const parameter_value_uint8[] = { - &setting_kernel->color, - 0, - &setting_kernel->mode, - 0, - 0, - &setting_kernel->root_mode, - 0, - 0, - 0, - 0, - 0, - &setting_kernel->verbosity, - }; - - // @todo: create f_metric_t, such that it is an f_number_unsigned_t with an exponent type, such as: Y (yotta), Z (zetta), E (exa), P (peta), T (Tera), G (giga), M (mega), k (kilo), h (hecto), da (deca), (none), d (deci), c (centi), m (milli), μ (micro), n (nano), p (pico), f (femto), a (atto), z (zepto), and y (yocto). - f_number_unsigned_t * const parameter_value_number_unsigned[] = { - 0, - 0, - 0, - 0, - 0, - 0, - &setting_kernel->root_size, - 0, - 0, - 0, - 0, - 0, - }; - - // 0 = string, 1 = yes/no, 2 = file mode, 3 = quiet, normal, verbose, or debug, 4 = light, dark, or no, 5 = init mode, 6 = size. - const uint8_t parameter_type[] = { - 4, - 1, - 5, - 0, - 0, - 2, - 6, - 0, - 0, - 0, - 0, - 3, - }; - - f_iki_variable_t variable = f_iki_variable_t_initialize; - f_iki_vocabulary_t vocabulary = f_iki_vocabulary_t_initialize; - f_iki_content_t content = f_iki_content_t_initialize; - - { - f_string_range_t range = f_macro_string_range_t_initialize(buffer.used); - - status = fl_iki_read(&buffer, &range, &variable, &vocabulary, &content); - } - - { - f_array_length_t i = 0; - f_array_length_t j = 0; - - for (; i < variable.used; ++i) { - - for (j = 0; j < 12; ++j) { - - if (fl_string_dynamic_partial_compare_string(parameter_name[i], buffer, parameter_length[i], vocabulary.array[j]) == F_equal_to) { - parameter_value[j]->used = 0; - - if (content.array[j].start <= content.array[j].stop) { - status = f_string_dynamic_partial_append(buffer, content.array[j], parameter_value[j]); - - if (F_status_is_error(status)) { - fll_error_print(data.error, F_status_set_fine(status), "f_string_dynamic_partial_append", F_true); - - i = variable.used; - break; - } - } - - if (parameter_type[i] == 0) { - // nothing to do. - } - else if (parameter_type[i] == 1) { - - if (fl_string_dynamic_compare_string(init_string_yes, *parameter_value[j], init_string_yes_length) == F_equal_to) { - *parameter_value_bool[i] = F_true; - } - else if (fl_string_dynamic_compare_string(init_string_yes, *parameter_value[j], init_string_no_length) == F_equal_to) { - *parameter_value_bool[i] = F_false; - } - else { - // @todo: warning about invalid value (save to an array and then print after settings are processed?) - } - } - else if (parameter_type[i] == 2) { - // @todo: use same kind of logic as used in fake. - } - else if (parameter_type[i] == 3) { - if (fl_string_dynamic_compare_string(init_string_quiet, *parameter_value[j], init_string_quiet_length) == F_equal_to) { - *parameter_value_uint8[i] = f_console_verbosity_quiet; - } - else if (fl_string_dynamic_compare_string(init_string_normal, *parameter_value[j], init_string_normal_length) == F_equal_to) { - *parameter_value_uint8[i] = f_console_verbosity_normal; - } - else if (fl_string_dynamic_compare_string(init_string_verbose, *parameter_value[j], init_string_verbose_length) == F_equal_to) { - *parameter_value_uint8[i] = f_console_verbosity_verbose; - } - else if (fl_string_dynamic_compare_string(init_string_debug, *parameter_value[j], init_string_debug_length) == F_equal_to) { - *parameter_value_uint8[i] = f_console_verbosity_debug; - } - else { - // @todo: warning about invalid value (save to an array and then print after settings are processed?) - } - } - else if (parameter_type[i] == 4) { - if (fl_string_dynamic_compare_string(init_string_dark, *parameter_value[j], init_string_dark_length) == F_equal_to) { - *parameter_value_uint8[i] = f_color_mode_dark; - } - else if (fl_string_dynamic_compare_string(init_string_light, *parameter_value[j], init_string_light_length) == F_equal_to) { - *parameter_value_uint8[i] = f_color_mode_light; - } - else if (fl_string_dynamic_compare_string(init_string_no, *parameter_value[j], init_string_no_length) == F_equal_to) { - *parameter_value_uint8[i] = f_color_mode_no_color; - } - else { - // @todo: warning about invalid value (save to an array and then print after settings are processed?) - } - } - else if (parameter_type[i] == 5) { - if (fl_string_dynamic_compare_string(init_string_classic, *parameter_value[j], init_string_classic_length) == F_equal_to) { - *parameter_value_uint8[i] = init_mode_classic; - } - else if (fl_string_dynamic_compare_string(init_string_custom, *parameter_value[j], init_string_custom_length) == F_equal_to) { - *parameter_value_uint8[i] = init_mode_custom; - } - else if (fl_string_dynamic_compare_string(init_string_maintenance, *parameter_value[j], init_string_maintenance_length) == F_equal_to) { - *parameter_value_uint8[i] = init_mode_maintenance; - } - else if (fl_string_dynamic_compare_string(init_string_normal, *parameter_value[j], init_string_normal_length) == F_equal_to) { - *parameter_value_uint8[i] = init_mode_normal; - } - else if (fl_string_dynamic_compare_string(init_string_squash, *parameter_value[j], init_string_squash_length) == F_equal_to) { - *parameter_value_uint8[i] = init_mode_squash; - } - else if (fl_string_dynamic_compare_string(init_string_squish, *parameter_value[j], init_string_squish_length) == F_equal_to) { - *parameter_value_uint8[i] = init_mode_squish; - } - else { - // @todo: warning about invalid value (save to an array and then print after settings are processed?) - } - } - else if (parameter_type[i] == 6) { - // @todo - // fl_conversion_string_to_number_unsigned - } - else { - // @todo: warning about unknown IKI in verbose mode (save to an array and then print after settings are processed?) - } - } - } // for - } // for - } - - f_macro_iki_variable_t_delete_simple(variable); - f_macro_iki_vocabulary_t_delete_simple(vocabulary); - f_macro_iki_content_t_delete_simple(content); - f_macro_string_dynamic_t_delete_simple(cache); - } - - f_file_stream_close(F_true, &command_line); - - f_macro_string_dynamic_t_delete_simple(buffer); - - return status; - } -#endif // _di_init_load_kernel_setting_ - -#ifndef _di_init_signal_read_ - f_status_t init_signal_received(const init_data_t data) { - - if (!data.signal.id) { - return F_false; - } - - f_status_t status = F_none; - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - status = f_signal_read(data.signal, &information); - - if (status == F_signal) { - switch (information.ssi_signo) { - case F_signal_abort: - case F_signal_hangup: - case F_signal_interrupt: - case F_signal_quit: - case F_signal_termination: - - if (data.error.verbosity != f_console_verbosity_quiet) { - fprintf(data.error.to.stream, "%c", f_string_eol_s[0]); - f_color_print(data.error.to.stream, data.context.set.error, "ALERT: An appropriate exit signal has been received, now aborting."); - fprintf(data.error.to.stream, "%c", f_string_eol_s[0]); - } - - return F_true; - } - } - - return F_false; - } -#endif // _di_init_signal_read_ diff --git a/level_3/init/c/private-init.h b/level_3/init/c/private-init.h deleted file mode 100644 index fc099f7..0000000 --- a/level_3/init/c/private-init.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * FLL - Level 3 - * - * Project: Init - * API Version: 0.5 - * Licenses: lgplv2.1 - */ -#ifndef _PRIVATE_init_h -#define _PRIVATE_init_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @todo - */ -#ifndef _di_init_load_failsafe_ - extern f_status_t init_load_failsafe(const init_data_t data) f_gcc_attribute_visibility_internal; -#endif // _di_init_load_failsafe_ - -/** - * @todo - */ -#ifndef _di_init_load_kernel_setting_ - extern f_status_t init_load_kernel_setting(const init_data_t data, init_setting_kernel_t *setting_kernel) f_gcc_attribute_visibility_internal; -#endif // _di_init_load_kernel_setting_ - -/** - * Check to see if a termination signal has been received. - * - * @param data - * The program data. - * - * @return - * F_true if a termination signal is received. - * F_false if no termination signal is received. - * - * Status codes (with error bit) are returned on any problem. - */ -#ifndef _di_init_signal_read_ - extern f_status_t init_signal_received(const init_data_t data) f_gcc_attribute_visibility_internal; -#endif // _di_init_signal_read_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_init_h diff --git a/level_3/init/data/build/defines b/level_3/init/data/build/defines deleted file mode 100644 index c665317..0000000 --- a/level_3/init/data/build/defines +++ /dev/null @@ -1,2 +0,0 @@ -# fss-0000 - diff --git a/level_3/init/data/build/dependencies b/level_3/init/data/build/dependencies deleted file mode 100644 index 41a8f16..0000000 --- a/level_3/init/data/build/dependencies +++ /dev/null @@ -1,19 +0,0 @@ -# fss-0000 - -f_type -f_status -f_memory -f_string -f_utf -f_color -f_console -f_conversion -f_file -f_iki -f_print -f_signal -fl_conversion -fl_iki -fl_string -fll_error -fll_program diff --git a/level_3/init/data/build/settings b/level_3/init/data/build/settings deleted file mode 100644 index 79cf264..0000000 --- a/level_3/init/data/build/settings +++ /dev/null @@ -1,57 +0,0 @@ -# fss-0001 - -project_name init - -version_major 0 -version_minor 5 -version_micro 3 -version_target major - -environment - -process_pre -process_post - -modes individual level monolithic -modes_default monolithic - -build_compiler gcc -build_indexer ar -build_language c -build_libraries -lc -build_libraries-individual -lfll_error -lfll_program -lfl_conversion -lfl_iki -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_print -lf_signal -lf_string -lf_type_array -lf_utf -build_libraries-level -lfll_2 -lfll_1 -lfll_0 -build_libraries-monolithic -lfll -build_sources_library init.c private-init.c -build_sources_program main.c -build_sources_headers init.h -build_sources_script -build_sources_setting -build_script yes -build_shared yes -build_static no - -path_headers level_3 -path_headers_preserve no -path_library_script script -path_library_shared shared -path_library_static static -path_program_script script -path_program_shared shared -path_program_static static -path_sources -path_standard yes - -search_exclusive yes -search_shared yes -search_static yes - -defines_all -defines_static -defines_shared - -flags_all -z now -g -fdiagnostics-color=always -flags_shared -flags_static -flags_library -fPIC -flags_program -fPIE -- 1.8.3.1