I decided to start at least clean up some of the compile errors, but this was simply too much of a mess.
Instead, just comment out code and deal with it later.
// version printed may be used by scripts, so this will only print the version number and a newline, no extra information or colors
#ifndef _di_init_print_version_
- f_return_status init_print_version(const init_argument argument) {
+ f_return_status init_print_version(const init_data data) {
printf("%s\n", init_version);
return f_none;
#endif // _di_init_print_version_
#ifndef _di_init_print_help_
- f_return_status init_print_help(const init_argument argument) {
+ f_return_status init_print_help(const init_data data) {
fll_program_print_help_header(data.context, init_name_long, init_version);
fll_program_print_help_option(data.context, f_console_standard_short_help, f_console_standard_long_help, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print this help message.");
#endif // _di_init_print_help_
#ifndef _di_init_main_
- f_return_status init_main(const f_console_arguments arguments, init_argument *argument) {
+ f_return_status init_main(const f_console_arguments arguments, init_data *data) {
f_status status = f_none;
- f_autochar run_level[init_kernel_runlevel_buffer];
+ int8_t run_level[init_kernel_runlevel_buffer];
- memset(run_level, 0, sizeof(f_autochar) * init_kernel_runlevel_buffer);
+ memset(run_level, 0, init_kernel_runlevel_buffer);
unsigned short do_socket_file = f_true;
unsigned short do_socket_port = f_false;
}
if (f_status_is_error(status)) {
- init_delete_data(data);
+ // @todo: init_delete_data(data);
return f_status_set_error(status);
}
status = f_none;
- if (argument->parameters[init_parameter_runlevel].result == f_console_result_found) {
- const unsigned int parameter_length = strlen(arguments.argv[argument->parameters[init_parameter_runlevel].additional.array[0]]);
+ if (data->parameters[init_parameter_runlevel].result == f_console_result_found) {
+ const unsigned int parameter_length = strlen(arguments.argv[data->parameters[init_parameter_runlevel].additional.array[0]]);
// if the run_level value is greater than the static buffer size, ignore the entire string rather than process a cut off value.
if (parameter_length > 0 && parameter_length < init_kernel_runlevel_buffer) {
- strncpy(&run_level, arguments.argv[argument->parameters[init_parameter_runlevel].additional.array[0]], parameter_length);
+ strncpy((char *) &run_level, arguments.argv[data->parameters[init_parameter_runlevel].additional.array[0]], parameter_length);
}
}
// before doing anything make sure that the rootfs has been properly setup.
- if (argument->parameters[init_parameter_no_prepare].result == f_console_result_none) {
- init_prepare_system(&run_level);
+ if (data->parameters[init_parameter_no_prepare].result == f_console_result_none) {
+ //init_prepare_system(&run_level);
}
// make sure appropriate required directories exist.
- init_prepare_init();
+ //init_prepare_init();
// attempt to load the main rule before forking and starting child processes.
//f_char stack_control_file[init_stack_size_small_control_file];
init_stack_memory stack_memory = init_stack_memory_initialize;
- status = init_initialize_stack_memory(&stack_memory);
+ //status = init_initialize_stack_memory(&stack_memory);
if (f_status_is_error(status)) {
- init_delete_argument((*argument));
- init_delete_stack_memory(&stack_memory);
+ // @todo: init_delete_data((*data));
+ // @todo: init_delete_stack_memory(&stack_memory);
return status;
}
{
- f_pid_t pid_services = clone(init_handler_child_services, stack_memory.services + init_stack_size_services, init_flags_clone, stack_memory.services);
+ /*
+ pid_t pid_services = clone(init_handler_child_services, stack_memory.services + init_stack_size_small_services, init_flags_clone, stack_memory.services);
if (pid_services < 0) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to clone services process (errno = %i).", errno);
}
- f_pid_t pid_control_file = clone(init_handler_child_control_file, stack_memory.control_file + init_stack_size_control_file, init_flags_clone, stack_memory.control_file);
+ pid_t pid_control_file = clone(init_handler_child_control_file, stack_memory.control_file + init_stack_size_control_file, init_flags_clone, stack_memory.control_file);
if (pid_control_file < 0) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Failed to clone control via file process (errno = %i).", errno);
}
-
+ */
// block signals
- f_sigset_t signal_mask;
- f_siginfo_t signal_information;
+ sigset_t signal_mask;
+ siginfo_t signal_information;
- memset(&signal_mask, 0, sizeof(f_sigset_t));
- memset(&signal_information_parent, 0, sizeof(f_siginfo_t));
+ memset(&signal_mask, 0, sizeof(sigset_t));
+ memset(&signal_information, 0, sizeof(siginfo_t));
// block all signals.
sigfillset(&signal_mask);
sigprocmask(SIG_BLOCK, &signal_mask, 0);
+ int signal_problem_count = 0;
+ const int problem_count_max_signal_size = 10;
// sit and wait for signals.
for (;;) {
- signal_result = sigwaitinfo(&signal_mask, &signal_information);
+ int signal_result = sigwaitinfo(&signal_mask, &signal_information);
if (signal_result < 0) {
if (errno == EAGAIN) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: sigwaitinfo() failed (errno = %i).", errno);
signal_problem_count++;
- if (signal_problem_count > PROBLEM_COUNT_MAX_SIGNAL_SIZE) {
+ if (signal_problem_count > problem_count_max_signal_size) {
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: max signal problem count has been reached, sleeping for a period of time.", errno);
sleep(init_panic_signal_sleep_seconds);
signal_problem_count = 0;
signal_problem_count = 0;
- if (signal_information_parent.si_signo == SIGHUP) {
+ if (signal_information.si_signo == SIGHUP) {
// @todo: close all child process connections? try using small initial memory instead?
}
- else if (signal_information_parent.si_signo == SIGINT {
+ else if (signal_information.si_signo == SIGINT) {
// check the status of processes to see if they are still running, if not, then restart them.
}
- else if (signal_information_parent.si_signo == SIGQUIT || signal_information_parent.si_signo == SIGTERM) {
+ else if (signal_information.si_signo == SIGQUIT || signal_information.si_signo == SIGTERM) {
// @todo: block these or attempt to respawn init process? try using small initial memory instead?
break;
}
- else if (signal_information_parent.si_signo == SIGSEGV || signal_information_parent.si_signo == SIGBUS || signal_information_parent.si_signo == SIGILL || signal_information_parent.si_signo == SIGFPE) {
+ else if (signal_information.si_signo == SIGSEGV || signal_information.si_signo == SIGBUS || signal_information.si_signo == SIGILL || signal_information.si_signo == SIGFPE) {
// @todo: block these or attempt to respawn init process?
}
- else if (signal_information_parent.si_signo == SIGPWR) {
+ else if (signal_information.si_signo == SIGPWR) {
// @todo: shutdown process?
}
- else if (signal_information_parent.si_signo == SIGABRT || signal_information_parent.si_signo == SIGIOT || signal_information_parent.si_signo == SIGXCPU) {
+ else if (signal_information.si_signo == SIGABRT || signal_information.si_signo == SIGIOT || signal_information.si_signo == SIGXCPU) {
// do nothing.
}
- else if (signal_information_parent.si_signo == SIGCHLD) {
+ else if (signal_information.si_signo == SIGCHLD) {
// @todo: restart child processes? try using large initial memory instead?
}
} // for
}
- init_delete_argument((*argument));
- init_delete_stack_memory(&stack_memory);
+ // @todo: init_delete_data((*data));
+ // @todo: init_delete_stack_memory(&stack_memory);
return status;
}
#endif // _di_init_main_
*/
#ifndef _init_h
+#define _GNU_SOURCE
+
// libc includes
+#include <sched.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <malloc.h>
#include <stdlib.h>
+// fll-0 includes
+#include <level_0/console.h>
+#include <level_0/file.h>
+#include <level_0/fss.h>
+#include <level_0/pipe.h>
+#include <level_0/print.h>
+#include <level_0/string.h>
+#include <level_0/type.h>
+
+// fll-1 includes
+#include <level_1/color.h>
+#include <level_1/console.h>
+#include <level_1/directory.h>
+#include <level_1/file.h>
+#include <level_1/fss.h>
+#include <level_1/fss_basic_list.h>
+#include <level_1/fss_extended.h>
+#include <level_1/string.h>
+
+// fll-2 includes
+#include <level_2/execute.h>
+#include <level_2/fss_basic_list.h>
+#include <level_2/fss_extended.h>
+#include <level_2/program.h>
+
#ifdef __cplusplus
extern "C" {
#endif
#endif // _en_init_debug_
#endif // _di_init_defines_
-#ifndef _di_init_argument_
+#ifndef _di_init_data_
typedef struct {
f_console_parameter parameters[init_total_parameters];
+ f_string_lengths remaining;
+ f_bool process_pipe;
+
fl_color_context context;
- } init_argument;
+ } init_data;
#define init_argument_initialize \
{ \
f_console_parameter_initialize_init, \
+ f_string_lengths_initialize, \
+ f_false, \
fl_color_context_initialize, \
}
-
- #define init_delete_argument(status, argument) \
- memset(&argument.parameters, 0, sizeof(f_console_parameter) * init_total_parameters); \
- fl_macro_color_context_delete(status, argument.context);
-
- #define init_destroy_argument(status, argument) \
- memset(&argument.parameters, 0, sizeof(f_console_parameter) * init_total_parameters); \
- fl_macro_color_context_destroy(status, argument.context);
-#endif // _di_init_argument_
+#endif // _di_init_data_
#ifndef _di_init_print_version_
- extern f_return_status init_print_version(const init_argument data);
+ extern f_return_status init_print_version(const init_data data);
#endif // _di_init_print_version_
/**
* f_none on success.
*/
#ifndef _di_init_print_help_
- extern f_return_status init_print_help(const init_argument data);
+ extern f_return_status init_print_help(const init_data data);
#endif // _di_init_print_help_
/**
* Status codes (with error bit) are returned on any problem.
*/
#ifndef _di_init_main_
- extern f_return_status init_main(const f_console_arguments arguments, init_argument *data);
+ extern f_return_status init_main(const f_console_arguments arguments, init_data *data);
#endif // _di_init_main_
#ifdef __cplusplus
int main(const unsigned long argc, const f_string *argv) {
const f_console_arguments arguments = { argc, argv };
- init_argument data = init_argument_initialize;
+ init_data data = init_argument_initialize;
if (f_pipe_exists()) {
data.process_pipe = f_true;
*/
#include <level_3/init.h>
#include "private-init.h"
-
+/*
#ifndef _di_init_rule_buffer_
- f_return_status init_rule_buffer(const f_string filename, f_string_dynamic *buffer, f_fss_objects *objects, f_fss_contents *contents) {
+ f_return_status init_rule_buffer(const init_data data, const f_string filename, f_string_dynamic *buffer, f_fss_objects *objects, f_fss_contents *contents) {
f_file file = f_file_initialize;
f_status status = f_none;
f_file_position file_position = f_file_position_initialize;
if (optional) {
if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
} else if (status != f_file_not_found && status != f_file_open_error && status != f_file_descriptor_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_status_set_error(status));
}
} else {
if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling f_file_open().");
} else if (status == f_file_not_found) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to find the file '%s'.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to find the file '%s'.", filename);
} else if (status == f_file_open_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to open the file '%s'.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Unable to open the file '%s'.", filename);
} else if (status == f_file_descriptor_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: File descriptor error while trying to open the file '%s'.", filename);
} else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open().", f_status_set_error(status));
}
}
status = f_status_set_fine(status);
if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read().");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fl_file_read().");
} else if (status == f_overflow) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: Integer overflow while trying to buffer the file '%s'.", filename);
} else if (status == f_file_not_open) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: The file '%s' is no longer open.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: The file '%s' is no longer open.", filename);
} else if (status == f_file_seek_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A seek error occurred while accessing the file '%s'.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A seek error occurred while accessing the file '%s'.", filename);
} else if (status == f_file_read_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: A read error occurred while accessing the file '%s'.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: A read error occurred while accessing the file '%s'.", filename);
} else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
} else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_read().", f_status_set_error(status));
}
return f_status_set_error(status);
status = f_status_set_fine(status);
if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", filename);
} else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: No relevant data was found within the file '%s'.", filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: No relevant data was found within the file '%s'.", filename);
} else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
} else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", f_status_set_error(status), filename);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", f_status_set_error(status), filename);
}
return f_status_set_error(status);
#endif // _di_init_rule_buffer_
#ifndef _di_init_rules_process_main_
- f_return_status init_rules_process_main(const init_data) {
+ f_return_status init_rules_process_main(const init_data data, const f_string filename, f_string_dynamic *buffer, f_fss_objects *objects, f_fss_contents *contents) {
f_status status = f_none;
f_status status2 = f_none;
status = fll_fss_extended_read(&buffer, input, &local->rule_objects, &local->rule_contents);
if (f_status_is_not_error(status)) {
- status = firewall_perform_commands(*local, *data);
+ //status = init_perform_commands(*local, *data); // @fixme
if (f_status_is_error(status)) {
status = f_status_set_fine(status);
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
} else if (status == f_failure) {
// the error message has already been displayed.
} else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", f_status_set_error(status));
}
f_macro_fss_objects_delete(status2, local->rule_objects);
#endif // _init_rules_process_main_
#ifndef _di_init_handler_child_services_
- f_return_status init_handler_child_services(f_void_p argument) {
- init_local_data *local_data = (init_local_data *) argument;
+ f_return_status init_handler_child_services(void *data) {
+ init_local_data *local_data = (init_local_data *) data;
// load and process rules.
#endif // _di_init_handler_child_services_
#ifndef _di_init_handler_child_control_file_
- f_return_status init_handler_child_control_file(f_void_p argument) {
- init_local_data *local_data = (init_local_data *) argument;
+ f_return_status init_handler_child_control_file(void *data) {
+ init_local_data *local_data = (init_local_data *) data;
return f_none;
}
stack_memory->services = mmap(0, init_stack_size_small_services, init_stack_protections, init_stack_flags, -1, 0);
stack_memory->control_file = mmap(0, init_stack_size_small_control_file, init_stack_protections, init_stack_flags, -1, 0);
- if (stack_memory->services == (f_void_p) -1) {
+ if (stack_memory->services == (void *) -1) {
return f_failure;
}
- if (stack_memory->control_file == (f_void_p) -1) {
+ if (stack_memory->control_file == (void *) -1) {
return f_failure;
}
#endif // _di_init_delete_stack_memory_
#ifndef _di_init_prepare_system_
- f_return_status init_prepare_system(f_autochar *run_level) {
+ f_return_status init_prepare_system(int8_t *run_level) {
f_status status = f_none;
f_stat stat;
#endif // _di_init_prepare_init_
#ifndef _di_init_process_main_rule_
- f_return_status init_process_main_rule(const init_argument argument, f_string_dynamic *buffer, init_data *data) {
+ f_return_status init_process_main_rule(const init_data data, f_string_dynamic *buffer, init_data *settings) {
f_status status = f_none;
f_string_dynamic buffer = f_string_dynamic_initialize;
f_string_location location = f_string_location_initialize;
f_string_length position = 0;
// load the main file into memory.
- status = init_rule_buffer(init_rule_core_file, &buffer, &objects, &contents);
+ status = init_rule_buffer(&data, init_rule_core_file, &buffer, &objects, &contents);
if (f_status_is_error(status)) {
status = f_status_set_fine(status);
if (status == f_invalid_parameter) {
- fl_color_print_line(f_standard_error, argument.context.error, argument.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", init_rule_core_file);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_fss_basic_list_read() for the file '%s'.", init_rule_core_file);
} else if (status == f_no_data_on_eos || status == f_no_data || status == f_no_data_on_stop) {
- fl_color_print_line(f_standard_error, argument.context.error, argument.context.reset, "ERROR: No relevant data was found within the file '%s'.", init_rule_core_file);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "ERROR: No relevant data was found within the file '%s'.", init_rule_core_file);
} else if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, argument.context.error, argument.context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
} else {
- fl_color_print_line(f_standard_error, argument.context.error, argument.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", f_status_set_error(status), init_rule_core_file);
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_basic_list_read() for the file '%s'.", f_status_set_error(status), init_rule_core_file);
}
f_macro_string_dynamic_delete(buffer);
if (f_status_is_error(status_process)) {
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: unable to allocate memory.");
}
else {
- fl_color_print_line(f_standard_error, argument->context.error, argument->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling init_load_main_rule().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling init_load_main_rule().", f_status_set_error(status));
}
- init_delete_argument((*argument));
- init_delete_stack_memory(&stack_memory);
+ // @todo: init_delete_data((*data));
+ // @todo: init_delete_stack_memory(&stack_memory);
return status_process;
}
*/
status = f_status_set_fine(status);
if (status == f_allocation_error || status == f_reallocation_error) {
- fl_color_print_line(f_standard_error, data->context.error, context.reset, "CRITICAL ERROR: unable to allocate memory.");
+ fl_color_print_line(f_standard_error, data.context.error, context.reset, "CRITICAL ERROR: unable to allocate memory.");
} else if (status == f_failure) {
// the error message has already been displayed.
} else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", f_status_set_error(status));
+ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling firewall_perform_commands().", f_status_set_error(status));
}
f_macro_fss_objects_delete(status2, (*rule_objects));
f_macro_fss_objects_delete(status2, (*rule_objects));
f_macro_fss_contents_delete(status2, (*rule_contents));
*/
-
+/*
f_macro_string_dynamic_delete(buffer);
f_macro_fss_objects_delete(objects);
f_macro_fss_contents_delete(contents);
return status;
}
#endif // _di_init_process_main_rule_
+ */
// consider mmap():
// - http://www.evanjones.ca/software/threading.html
// - http://stackoverflow.com/questions/1083172/how-to-mmap-the-stack-for-the-clone-system-call-on-linux
-// - f_void_p stack = mmap(0,initial_stacksize,PROT_WRITE|PROT_READ,MAP_PRIVATE|MAP_GROWSDOWN|MAP_ANONYMOUS,-1,0);
+// - void *stack = mmap(0,initial_stacksize,PROT_WRITE|PROT_READ,MAP_PRIVATE|MAP_GROWSDOWN|MAP_ANONYMOUS,-1,0);
// - http://lwn.net/Articles/294001/
// - http://tiku.io/questions/659065/how-to-mmap-the-stack-for-the-clone-system-call-on-linux
#define init_stack_size_small_services 6144
#define init_stack_size_large_services 12288
#define init_stack_size_large_control_file 8192
+#define init_flags_clone 0
+
#define init_stack_protections PROT_WRITE | PROT_READ
#define init_stack_flags MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS
#define init_rule_initialize \
{ \
- f_string_dynamic_initialize,
- f_string_dynamic_initialize,
- f_string_dynamic_initialize,
- f_bool_initialize,
- f_bool_initialize,
+ f_string_dynamic_initialize, \
+ f_string_dynamic_initialize, \
+ f_string_dynamic_initialize, \
+ f_false, \
+ f_false, \
}
#define delete_init_rule(status, rule) \
delete_init_rule(status, rules.array[rules.size]); \
if (status != f_none) break; \
} \
- if (status == f_none) status = f_memory_delete((f_void_p *) & rules.array, sizeof(init_rule), rules.size); \
+ if (status == f_none) status = f_memory_delete((void **) & rules.array, sizeof(init_rule), rules.size); \
if (status == f_none) rules.used = 0;
#define f_init_rules_destroy(status, rules) \
destroy_init_rule(status, rules.array[rules.size]); \
if (status != f_none) break; \
} \
- if (status == f_none) status = f_memory_destroy((f_void_p *) & rules.array, sizeof(init_rule), rules.size); \
+ if (status == f_none) status = f_memory_destroy((void **) & rules.array, sizeof(init_rule), rules.size); \
if (status == f_none) rules.used = 0;
#define f_init_rules_resize(status, rules, new_length) \
if (status != f_none) break; \
} \
} \
- if (status == f_none) status = f_memory_resize((f_void_p *) & rules.array, sizeof(init_rule), rules.size, new_length); \
+ if (status == f_none) status = f_memory_resize((void **) & rules.array, sizeof(init_rule), rules.size, new_length); \
if (status == f_none) { \
if (new_length > rules.size) { \
f_string_length i = rules.size; \
if (status != f_none) break; \
} \
} \
- if (status == f_none) status = f_memory_adjust((f_void_p *) & rules.array, sizeof(init_rule), rules.size, new_length); \
+ if (status == f_none) status = f_memory_adjust((void **) & rules.array, sizeof(init_rule), rules.size, new_length); \
if (status == f_none) { \
if (new_length > rules.size) { \
f_string_length i = rules.size; \
init_rule last;
} init_category;
- #define init_rule_initialize \
+ #define init_category_initialize \
{ \
- f_string_dynamic_initialize,
- init_rule_initialize,
+ f_string_dynamic_initialize, \
+ init_rule_initialize, \
}
#define delete_init_category(status, category) \
delete_init_category(status, categorys.array[categorys.size]); \
if (status != f_none) break; \
} \
- if (status == f_none) status = f_memory_delete((f_void_p *) & categorys.array, sizeof(init_category), categorys.size); \
+ if (status == f_none) status = f_memory_delete((void **) & categorys.array, sizeof(init_category), categorys.size); \
if (status == f_none) categorys.used = 0;
#define f_init_categorys_destroy(status, categorys) \
destroy_init_category(status, categorys.array[categorys.size]); \
if (status != f_none) break; \
} \
- if (status == f_none) status = f_memory_destroy((f_void_p *) & categorys.array, sizeof(init_category), categorys.size); \
+ if (status == f_none) status = f_memory_destroy((void **) & categorys.array, sizeof(init_category), categorys.size); \
if (status == f_none) categorys.used = 0;
#define f_init_categorys_resize(status, categorys, new_length) \
if (status != f_none) break; \
} \
} \
- if (status == f_none) status = f_memory_resize((f_void_p *) & categorys.array, sizeof(init_category), categorys.size, new_length); \
+ if (status == f_none) status = f_memory_resize((void **) & categorys.array, sizeof(init_category), categorys.size, new_length); \
if (status == f_none) { \
if (new_length > categorys.size) { \
f_string_length i = categorys.size; \
if (status != f_none) break; \
} \
} \
- if (status == f_none) status = f_memory_adjust((f_void_p *) & categorys.array, sizeof(init_category), categorys.size, new_length); \
+ if (status == f_none) status = f_memory_adjust((void **) & categorys.array, sizeof(init_category), categorys.size, new_length); \
if (status == f_none) { \
if (new_length > categorys.size) { \
f_string_length i = categorys.size; \
}
#endif // _di_init_categorys_
-#ifndef _di_init_data_
+#ifndef _di_init_setting_
typedef struct {
f_string socket_file;
unsigned int socket_port;
init_rules main_rules;
init_categorys main_categorys;
init_rule main_failsafe;
- } init_data;
+ } init_setting;
#define init_data_initialize \
{ \
init_categorys_initialize, \
init_rule_initialize, \
}
-#endif // _di_init_data_
+#endif // _di_init_setting_
typedef struct {
- f_void_p services;
- f_void_p reporting;
- f_void_p time;
- f_void_p control_file;
- f_void_p control_port;
- f_void_p login_file;
- f_void_p login_port;
-
- init_argument argument;
- init_data data;
+ void *services;
+ void *reporting;
+ void *time;
+ void *control_file;
+ void *control_port;
+ void *login_file;
+ void *login_port;
+
+ init_data data;
+ init_setting setting;
} init_stack_memory;
#define init_stack_memory_initialize \
#define init_path_processes_cmdline init_paths_processes "cmdline"
#define init_path_processes_mounts init_paths_processes "mounts"
-
+/*
#ifndef _di_init_rule_buffer_
- f_return_status init_rule_buffer(const f_string filename, f_string_dynamic *buffer, f_fss_objects *objects, f_fss_contents *contents) f_gcc_attribute_visibility_internal;
+ f_return_status init_rule_buffer(const init_data data, const f_string filename, f_string_dynamic *buffer, f_fss_objects *objects, f_fss_contents *contents) f_gcc_attribute_visibility_internal;
#endif // _di_init_rule_buffer_
-#ifndef _di_init_handler_child_services_
+#ifndef _di_init_handler_chif_string_dynamic_initializeld_services_
// start, stop, and handle signals to services.
- f_return_status init_handler_child_services(f_void_p argument) f_gcc_attribute_visibility_internal;
+ f_return_status init_handler_child_services(void *argument) f_gcc_attribute_visibility_internal;
#endif // _di_init_handler_child_services_
#ifndef _di_init_handler_child_control_file_
// listens on a socket file and accepts control commands.
- f_return_status init_handler_child_control_file(f_void_p argument) f_gcc_attribute_visibility_internal;
+ f_return_status init_handler_child_control_file(void *argument) f_gcc_attribute_visibility_internal;
#endif // _di_init_handler_child_socket_file_
#ifndef _di_init_initialize_stack_memory_
#endif // _di_init_prepare_init_
#ifndef _di_init_process_main_rule_
- f_return_status init_process_main_rule(const init_argument argument, f_string_dynamic *buffer, init_data *data) f_gcc_attribute_visibility_internal;
+ f_return_status init_process_main_rule(const init_data data, f_string_dynamic *buffer, init_setting *setting) f_gcc_attribute_visibility_internal;
#endif // _di_init_process_main_rule_
-
+*/
#ifdef __cplusplus
} // extern "C"
#endif