extern "C" {
#endif
-#ifndef _di_controller_entry_read_
- f_status_t controller_entry_read(controller_t * const main, const uint8_t is_entry) {
-
- if (!main) return F_status_set_error(F_parameter);
-
- f_status_t status = controller_mutex_lock_standard(is_entry, controller_lock_check_flag_yes_d, &main->thread, &main->thread.lock.entry);
- if (F_status_is_error(status)) return status;
-
- status = controller_entry_read_do(main, is_entry);
-
- f_thread_mutex_unlock(&main->thread.lock.entry.mutex);
-
- return status;
- }
-#endif // _di_controller_entry_read_
-
-#ifndef _di_controller_entry_read_do_
- f_status_t controller_entry_read_do(controller_t * const main, const uint8_t is_entry) {
+#ifndef _di_controller_entry_extract_
+ f_status_t controller_entry_extract(controller_t * const main, const uint8_t is_entry) {
if (!main) return F_status_set_error(F_parameter);
controller_entry_t * const entry = is_entry ? &main->process.entry : &main->process.exit;
- controller_interrupt_t custom = macro_controller_interrupt_t_initialize_1(is_entry, main);
- f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_thread_signal_state_fss, 0, 0, 0);
-
- f_number_unsigned_t i = 0;
-
- entry->status = F_known_not;
- entry->items.used = 0;
- entry->session = controller_entry_session_same_e;
-
- if (main->callback.process_entry_setup) {
- state.status = main->callback.process_entry_setup(main, entry);
- }
-
- main->thread.cache.action.line_action = 0;
- main->thread.cache.action.line_item = 0;
-
- main->thread.cache.timestamp.seconds = 0;
- main->thread.cache.timestamp.seconds_nano = 0;
-
- main->thread.cache.comments.used = 0;
- main->thread.cache.delimits.used = 0;
-
- main->thread.cache.content_action.used = 0;
-
- for (; i < main->thread.cache.content_actions.used; ++i) {
- main->thread.cache.content_actions.array[i].used = 0;
- } // for
-
- for (i = 0; i < main->thread.cache.content_items.used; ++i) {
- main->thread.cache.content_items.array[i].used = 0;
- } // for
-
- main->thread.cache.content_actions.used = 0;
- main->thread.cache.content_items.used = 0;
-
- main->thread.cache.object_actions.used = 0;
- main->thread.cache.object_items.used = 0;
-
- main->thread.cache.buffer_file.used = 0;
- main->thread.cache.buffer_path.used = 0;
-
- main->thread.cache.action.name_file.used = 0;
- main->thread.cache.action.name_action.used = 0;
- main->thread.cache.action.name_item.used = 0;
-
- // @todo Check if controlfile, then load that using the prefix, otherwise, operate normally. The full controlfile will be loaded once. Maybe make the file load a callback?
- if (F_status_is_error_not(state.status)) {
- if (is_entry) {
- state.status = controller_file_load(main, F_true, controller_entries_s, main->process.name_entry, controller_entry_s);
- }
- else {
- state.status = controller_file_load(main, F_false, controller_exits_s, main->process.name_entry, controller_exit_s);
-
- // Immediately return on error whole loading the Exit.
- if (state.status == F_file_found_not) {
- entry->status = controller_status_simplify_error(F_file_found_not);
-
- return F_status_set_error(F_file_found_not);
- }
- }
- }
-
- if (F_status_is_error_not(state.status)) {
- if (main->thread.cache.buffer_file.used) {
- f_range_t range = macro_f_range_t_initialize_2(main->thread.cache.buffer_file.used);
-
- fll_fss_basic_list_read(main->thread.cache.buffer_file, &range, &main->thread.cache.object_items, &main->thread.cache.content_items, &main->thread.cache.delimits, 0, &main->thread.cache.comments, &state);
+ entry->status = F_okay;
- if (F_status_is_error(state.status)) {
- controller_print_error_status(&main->program.error, F_status_debug_source_d, F_status_set_fine(state.status));
- }
- else {
- f_fss_apply_delimit(main->thread.cache.delimits, &main->thread.cache.buffer_file, &state);
+ if (main->thread.cache.object_items.used) {
+ f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_thread_signal_state_fss, 0, 0, 0);
- if (F_status_is_error(state.status)) {
- controller_print_error_entry(&main->program.error, is_entry, F_status_set_fine(state.status), F_status_debug_source_d, F_true, F_status_debug_source_d);
- }
- }
- }
- else {
- controller_print_error_file_status(&main->program.error, F_status_debug_source_d, is_entry ? controller_entry_s : controller_exit_s, f_file_operation_read_s, fll_error_file_type_file_e, F_status_set_fine(state.status));
- }
- }
-
- if (F_status_is_error_not(state.status) && main->thread.cache.object_items.used) {
state.status = f_memory_array_increase_by(main->thread.cache.object_items.used, sizeof(f_range_t), (void **) &main->thread.cache.object_items.array, &main->thread.cache.object_items.used, &main->thread.cache.object_items.size);
if (F_status_is_error(state.status)) {
controller_print_error_entry(&main->program.error, is_entry, F_status_set_fine(state.status), F_status_debug_source_d, F_true, F_status_debug_source_d);
}
else {
-
- // 0x1 = main found, 0x2 = found existing.
- uint8_t code = 0;
-
f_range_t *range = 0;
f_number_unsigned_t at = 0;
+ f_number_unsigned_t i = 0;
f_number_unsigned_t j = 0;
+ // 0x1 = main found, 0x2 = found existing.
+ uint8_t code = 0;
+
for (i = 0; i < main->thread.cache.object_items.used && controller_thread_enable_is_normal(&main->thread, is_entry); ++i) {
code &= ~0x2;
}
}
}
+
+ if (F_status_is_error(state.status)) {
+ entry->status = controller_status_simplify_error(F_status_set_fine(state.status));
+
+ if (F_status_set_fine(state.status) != F_interrupt) {
+ controller_print_error_entry_cache(&main->program.error, &main->thread.cache.action, is_entry, F_status_debug_source_d);
+ }
+ }
+ else {
+ entry->status = F_okay;
+ }
+ }
+
+ return entry->status;
+ }
+#endif // _di_controller_entry_extract_
+
+#ifndef _di_controller_entry_read_
+ f_status_t controller_entry_read(controller_t * const main, const uint8_t is_entry) {
+
+ if (!main) return F_status_set_error(F_parameter);
+
+ f_status_t status = controller_mutex_lock_standard(is_entry, controller_lock_check_flag_yes_d, &main->thread, &main->thread.lock.entry);
+ if (F_status_is_error(status)) return status;
+
+ if (F_status_is_error_not(status)) {
+ status = controller_entry_setup(main, is_entry ? &main->process.entry : &main->process.exit);
+ }
+
+ if (F_status_is_error_not(status) && !(main->setting.flag & controller_main_flag_loaded_d)) {
+ status = controller_entry_load(main, is_entry);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = controller_entry_extract(main, is_entry);
+ }
+
+ f_thread_mutex_unlock(&main->thread.lock.entry.mutex);
+
+ return status;
+ }
+#endif // _di_controller_entry_read_
+
+#ifndef _di_controller_entry_load_
+ f_status_t controller_entry_load(controller_t * const main, const uint8_t is_entry) {
+
+ if (!main) return F_status_set_error(F_parameter);
+
+ controller_entry_t * const entry = is_entry ? &main->process.entry : &main->process.exit;
+ f_state_t state = macro_f_state_t_initialize_1(controller_allocation_large_d, controller_allocation_small_d, F_okay, 0, 0, 0, &controller_thread_signal_state_fss, 0, 0, 0);
+
+ f_number_unsigned_t i = 0;
+
+ for (i = 0; i < main->thread.cache.content_items.used; ++i) {
+ main->thread.cache.content_items.array[i].used = 0;
+ } // for
+
+ main->thread.cache.content_items.used = 0;
+ main->thread.cache.object_items.used = 0;
+
+ main->thread.cache.comments.used = 0;
+ main->thread.cache.delimits.used = 0;
+
+ main->thread.cache.buffer_file.used = 0;
+
+ if (F_status_is_error_not(state.status)) {
+ if (is_entry) {
+ state.status = controller_file_load(main, F_true, controller_entries_s, main->process.name_entry, controller_entry_s);
+ }
+ else {
+ state.status = controller_file_load(main, F_false, controller_exits_s, main->process.name_entry, controller_exit_s);
+
+ // Immediately return on error whole loading the Exit.
+ if (state.status == F_file_found_not) {
+ entry->status = controller_status_simplify_error(F_file_found_not);
+
+ return F_status_set_error(F_file_found_not);
+ }
+ }
+ }
+
+ if (F_status_is_error_not(state.status)) {
+ if (main->thread.cache.buffer_file.used) {
+ f_range_t range = macro_f_range_t_initialize_2(main->thread.cache.buffer_file.used);
+
+ fll_fss_basic_list_read(main->thread.cache.buffer_file, &range, &main->thread.cache.object_items, &main->thread.cache.content_items, &main->thread.cache.delimits, 0, &main->thread.cache.comments, &state);
+
+ if (F_status_is_error(state.status)) {
+ controller_print_error_status(&main->program.error, F_status_debug_source_d, F_status_set_fine(state.status));
+ }
+ else {
+ f_fss_apply_delimit(main->thread.cache.delimits, &main->thread.cache.buffer_file, &state);
+
+ if (F_status_is_error(state.status)) {
+ controller_print_error_entry(&main->program.error, is_entry, F_status_set_fine(state.status), F_status_debug_source_d, F_true, F_status_debug_source_d);
+ }
+ }
+ }
+ else {
+ controller_print_error_file_status(&main->program.error, F_status_debug_source_d, is_entry ? controller_entry_s : controller_exit_s, f_file_operation_read_s, fll_error_file_type_file_e, F_status_set_fine(state.status));
+ }
}
if (F_status_is_error(state.status)) {
return entry->status;
}
-#endif // _di_controller_entry_read_do_
+#endif // _di_controller_entry_load_
+
+#ifndef _di_controller_entry_setup_
+ f_status_t controller_entry_setup(controller_t * const main, controller_entry_t * const entry) {
+
+ if (!main || !entry) return F_status_set_error(F_parameter);
+
+ entry->status = F_known_not;
+ entry->items.used = 0;
+ entry->session = controller_entry_session_same_e;
+
+ if (main->callback.process_entry_setup) {
+ const f_status_t status = main->callback.process_entry_setup(main, entry);
+ if (F_status_is_error(status)) return status;
+ }
+
+ main->thread.cache.action.line_action = 0;
+ main->thread.cache.action.line_item = 0;
+
+ main->thread.cache.timestamp.seconds = 0;
+ main->thread.cache.timestamp.seconds_nano = 0;
+
+ main->thread.cache.content_action.used = 0;
+
+ for (f_number_unsigned_t i = 0; i < main->thread.cache.content_actions.used; ++i) {
+ main->thread.cache.content_actions.array[i].used = 0;
+ } // for
+
+ main->thread.cache.content_actions.used = 0;
+ main->thread.cache.object_actions.used = 0;
+
+ main->thread.cache.action.name_file.used = 0;
+ main->thread.cache.action.name_action.used = 0;
+ main->thread.cache.action.name_item.used = 0;
+
+ main->thread.cache.buffer_path.used = 0;
+
+ return F_okay;
+ }
+#endif // _di_controller_entry_setup_
#ifdef __cplusplus
} // extern "C"
#endif
/**
- * Read the entry, extracting all lists, with locking.
- *
- * This wraps controller_entry_read_do() with a mutex lock to prevent double execution.
+ * Read the entry or exit, extracting all lists.
*
* @param main
* The main program data.
* If FALSE, then this operates as an Exit.
*
* @return
- * Success from controller_entry_read_do().
+ * F_okay on success.
*
- * Errors (with error bit) from: controller_entry_read_do().
- * Errors (with error bit) from: controller_mutex_lock_standard().
+ * F_found_not (with error bit) if entry action item is not found.
+ * F_interrupt (with error bit) on interrupt.
+ * F_parameter (with error bit) if a parameter is invalid.
*
- * @see controller_entry_read_do()
- * @see controller_mutex_lock_standard()
+ * Errors (with error bit) from: controller_entry_action_read().
+ * Errors (with error bit) from: controller_entry_setting_read().
+ * Errors (with error bit) from: controller_status_simplify_error().
+ *
+ * Errors (with error bit) from: f_fss_count_lines().
+ * Errors (with error bit) from: f_memory_array_increase().
+ * Errors (with error bit) from: f_memory_array_increase_by().
+ * Errors (with error bit) from: f_memory_array_resize().
+ * Errors (with error bit) from: f_string_dynamic_append().
+ * Errors (with error bit) from: f_string_dynamic_append_nulless().
+ * Errors (with error bit) from: f_string_dynamic_partial_append().
+ *
+ * @see controller_entry_action_read()
+ * @see controller_entry_setting_read()
+ * @see controller_status_simplify_error()
+ *
+ * @see f_fss_count_lines()
+ * @see f_memory_array_increase()
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ * @see f_string_dynamic_append()
+ * @see f_string_dynamic_append_nulless()
+ * @see f_string_dynamic_partial_append()
*/
-#ifndef _di_controller_entry_read_
- extern f_status_t controller_entry_read(controller_t * const main, const uint8_t is_entry);
-#endif // _di_controller_entry_read_
+#ifndef _di_controller_entry_extract_
+ extern f_status_t controller_entry_extract(controller_t * const main, const uint8_t is_entry);
+#endif // _di_controller_entry_extract_
/**
- * Read the entry, extracting all lists.
+ * Load the entry or exit file.
*
* @param main
* The main program data.
* F_parameter (with error bit) if a parameter is invalid.
*
* Errors (with error bit) from: controller_entry_action_read().
- * Errors (with error bit) from: controller_entry_items_increase_by().
* Errors (with error bit) from: controller_file_load().
* Errors (with error bit) from: controller_status_simplify_error().
*
- * Errors (with error bit) from: f_fss_count_lines().
- * Errors (with error bit) from: f_string_dynamic_append().
- * Errors (with error bit) from: f_string_dynamic_append_nulless().
- * Errors (with error bit) from: f_string_dynamic_partial_append().
- * Errors (with error bit) from: f_string_dynamic_partial_append_nulless().
- * Errors (with error bit) from: f_string_dynamic_terminate().
* Errors (with error bit) from: f_fss_apply_delimit().
* Errors (with error bit) from: fll_fss_basic_list_read().
*
- * @see controller_entry_action_read()
- * @see controller_entry_items_increase_by()
* @see controller_file_load()
* @see controller_status_simplify_error()
*
- * @see f_fss_count_lines()
- * @see f_string_dynamic_append()
- * @see f_string_dynamic_append_nulless()
- * @see f_string_dynamic_partial_append()
- * @see f_string_dynamic_partial_append_nulless()
- * @see f_string_dynamic_terminate()
* @see f_fss_apply_delimit()
* @see fll_fss_basic_list_read()
*/
-#ifndef _di_controller_entry_read_do_
- extern f_status_t controller_entry_read_do(controller_t * const main, const uint8_t is_entry);
-#endif // _di_controller_entry_read_do_
+#ifndef _di_controller_entry_load_
+ extern f_status_t controller_entry_load(controller_t * const main, const uint8_t is_entry);
+#endif // _di_controller_entry_load_
+
+/**
+ * Read the entry or exit, extracting all lists, with locking.
+ *
+ * This utilizes a mutex lock to prevent double execution.
+ *
+ * @param main
+ * The main program data.
+ *
+ * This does not alter main.setting.state.status.
+ *
+ * Must not be NULL.
+ * @param is_entry
+ * If TRUE, then this operates as an Entry.
+ * If FALSE, then this operates as an Exit.
+ *
+ * @return
+ * Success from controller_entry_extract().
+ *
+ * Errors (with error bit) from: controller_entry_extract().
+ * Errors (with error bit) from: controller_entry_load().
+ * Errors (with error bit) from: controller_entry_setup().
+ * Errors (with error bit) from: controller_mutex_lock_standard().
+ *
+ * @see controller_entry_extract()
+ * @see controller_entry_load()
+ * @see controller_entry_setup()
+ * @see controller_mutex_lock_standard()
+ */
+#ifndef _di_controller_entry_read_
+ extern f_status_t controller_entry_read(controller_t * const main, const uint8_t is_entry);
+#endif // _di_controller_entry_read_
+
+/**
+ * Set up the entry or exit.
+ *
+ * @param main
+ * The main program data.
+ *
+ * This does not alter main.setting.state.status.
+ *
+ * Must not be NULL.
+ * @param entry
+ * The entry or exit structure to setup.
+ *
+ * Must not be NULL.
+ *
+ * @return
+ * F_okay on success.
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: main->callback.process_entry_setup().
+ */
+#ifndef _di_controller_entry_setup_
+ extern f_status_t controller_entry_setup(controller_t * const main, controller_entry_t * const entry);
+#endif // _di_controller_entry_setup_
#ifdef __cplusplus
} // extern "C"