From: Kevin Day Date: Fri, 12 Jul 2024 03:27:43 +0000 (-0500) Subject: Progress: Continue migrating the project, and do some restructuring. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=1f67b4a86713a83c4a9c8dcc9803366d6bcf7c80;p=controller Progress: Continue migrating the project, and do some restructuring. Don't provide default examples as the settings. Move all of these into an examples directory. The examples directory is placed under a data directory that is intended to be for files such as those under the /usr/share directory. This shows that the Featureless Make build settings specification is missing the "build_sources_data" which is a /usr/share equivalent of "-build_sources_setting" (aka /etc). --- diff --git a/data/build/settings b/data/build/settings index 4d81f0f..b5c1f44 100644 --- a/data/build/settings +++ b/data/build/settings @@ -49,11 +49,11 @@ build_sources_library file.c lock.c path.c process.c build_sources_library rule.c rule/action.c rule/execute.c rule/expand.c rule/instance.c rule/is.c rule/item.c rule/parameter.c rule/read.c rule/setting.c rule/wait.c build_sources_library perform.c build_sources_library print/data.c -build_sources_library print/debug.c print/debug/rule/action.c print/debug/rule/execute.c print/debug/perform/control.c print/debug/perform/pid.c +build_sources_library print/debug.c print/debug/rule/action.c print/debug/rule/execute.c print/debug/rule/instance.c print/debug/perform/control.c print/debug/perform/pid.c build_sources_library print/error.c build_sources_library print/error/entry.c print/error/entry/action.c print/error/entry/item.c print/error/entry/setting.c build_sources_library print/error/perform/pid.c -build_sources_library print/error/rule.c print/error/rule/action.c print/error/rule/item.c print/error/rule/setting.c +build_sources_library print/error/rule.c print/error/rule/action.c print/error/rule/instance.c print/error/rule/item.c print/error/rule/setting.c build_sources_library print/lock.c print/error/lock.c build_sources_library print/output/entry/setting.c print/output/rule/execute.c print/output/rule/setting.c print/output/rule/validate.c build_sources_library print/message.c print/message/entry.c print/message/entry/action.c print/message/entry/item.c @@ -74,11 +74,11 @@ build_sources_headers file.h lock.h path.h process.h build_sources_headers rule.h rule/action.h rule/execute.h rule/expand.h rule/instance.h rule/is.h rule/item.h rule/parameter.h rule/read.h rule/setting.h rule/wait.h build_sources_headers perform.h build_sources_headers print/data.h -build_sources_headers print/debug.h print/debug/rule/action.h print/debug/rule/execute.h print/debug/perform/control.h print/debug/perform/pid.h +build_sources_headers print/debug.h print/debug/rule/action.h print/debug/rule/execute.h print/debug/rule/instance.h print/debug/perform/control.h print/debug/perform/pid.h build_sources_headers print/error.h build_sources_headers print/error/entry.h print/error/entry/action.h print/error/entry/item.h print/error/entry/setting.h build_sources_headers print/error/perform/pid.h -build_sources_headers print/error/rule.h print/error/rule/action.h print/error/rule/item.h print/error/rule/setting.h +build_sources_headers print/error/rule.h print/error/rule/action.h print/error/rule/instance.h print/error/rule/item.h print/error/rule/setting.h build_sources_headers print/lock.h print/error/lock.h build_sources_headers print/output/entry/setting.h print/output/rule/execute.h print/output/rule/setting.h print/output/rule/validate.h build_sources_headers print/message.h print/message/entry.h print/message/entry/action.h print/message/entry/item.h @@ -90,8 +90,6 @@ build_sources_headers validate.h build_sources_documentation man -build_sources_setting controller - build_script yes build_shared yes build_static no diff --git a/data/settings/controller/example/cgroup_example/entries/chromium.entry b/data/data/controller/example/cgroup/entries/chromium.entry similarity index 100% rename from data/settings/controller/example/cgroup_example/entries/chromium.entry rename to data/data/controller/example/cgroup/entries/chromium.entry diff --git a/data/settings/controller/example/cgroup_example/entries/eclipse.entry b/data/data/controller/example/cgroup/entries/eclipse.entry similarity index 100% rename from data/settings/controller/example/cgroup_example/entries/eclipse.entry rename to data/data/controller/example/cgroup/entries/eclipse.entry diff --git a/data/settings/controller/example/cgroup_example/entries/firefox.entry b/data/data/controller/example/cgroup/entries/firefox.entry similarity index 100% rename from data/settings/controller/example/cgroup_example/entries/firefox.entry rename to data/data/controller/example/cgroup/entries/firefox.entry diff --git a/data/settings/controller/example/cgroup_example/entries/setup_cgroups.entry b/data/data/controller/example/cgroup/entries/setup_cgroups.entry similarity index 100% rename from data/settings/controller/example/cgroup_example/entries/setup_cgroups.entry rename to data/data/controller/example/cgroup/entries/setup_cgroups.entry diff --git a/data/settings/controller/example/cgroup_example/rules/program/chromium.rule b/data/data/controller/example/cgroup/rules/program/chromium.rule similarity index 100% rename from data/settings/controller/example/cgroup_example/rules/program/chromium.rule rename to data/data/controller/example/cgroup/rules/program/chromium.rule diff --git a/data/settings/controller/example/cgroup_example/rules/program/eclipse.rule b/data/data/controller/example/cgroup/rules/program/eclipse.rule similarity index 100% rename from data/settings/controller/example/cgroup_example/rules/program/eclipse.rule rename to data/data/controller/example/cgroup/rules/program/eclipse.rule diff --git a/data/settings/controller/example/cgroup_example/rules/program/firefox.rule b/data/data/controller/example/cgroup/rules/program/firefox.rule similarity index 100% rename from data/settings/controller/example/cgroup_example/rules/program/firefox.rule rename to data/data/controller/example/cgroup/rules/program/firefox.rule diff --git a/data/settings/controller/example/cgroup_example/rules/setup/cgroups.rule b/data/data/controller/example/cgroup/rules/setup/cgroups.rule similarity index 100% rename from data/settings/controller/example/cgroup_example/rules/setup/cgroups.rule rename to data/data/controller/example/cgroup/rules/setup/cgroups.rule diff --git a/data/settings/controller/entries/default.entry b/data/data/controller/example/init/entries/default.entry similarity index 100% rename from data/settings/controller/entries/default.entry rename to data/data/controller/example/init/entries/default.entry diff --git a/data/settings/controller/entries/maintenance.entry b/data/data/controller/example/init/entries/maintenance.entry similarity index 100% rename from data/settings/controller/entries/maintenance.entry rename to data/data/controller/example/init/entries/maintenance.entry diff --git a/data/settings/controller/rules/boot/devices.rule b/data/data/controller/example/init/rules/boot/devices.rule similarity index 100% rename from data/settings/controller/rules/boot/devices.rule rename to data/data/controller/example/init/rules/boot/devices.rule diff --git a/data/settings/controller/rules/boot/file_system.rule b/data/data/controller/example/init/rules/boot/file_system.rule similarity index 100% rename from data/settings/controller/rules/boot/file_system.rule rename to data/data/controller/example/init/rules/boot/file_system.rule diff --git a/data/settings/controller/rules/boot/modules.rule b/data/data/controller/example/init/rules/boot/modules.rule similarity index 100% rename from data/settings/controller/rules/boot/modules.rule rename to data/data/controller/example/init/rules/boot/modules.rule diff --git a/data/settings/controller/rules/boot/proc.rule b/data/data/controller/example/init/rules/boot/proc.rule similarity index 100% rename from data/settings/controller/rules/boot/proc.rule rename to data/data/controller/example/init/rules/boot/proc.rule diff --git a/data/settings/controller/rules/boot/root.rule b/data/data/controller/example/init/rules/boot/root.rule similarity index 100% rename from data/settings/controller/rules/boot/root.rule rename to data/data/controller/example/init/rules/boot/root.rule diff --git a/data/settings/controller/rules/maintenance/console.rule b/data/data/controller/example/init/rules/maintenance/console.rule similarity index 100% rename from data/settings/controller/rules/maintenance/console.rule rename to data/data/controller/example/init/rules/maintenance/console.rule diff --git a/data/settings/controller/rules/net/all.rule b/data/data/controller/example/init/rules/net/all.rule similarity index 100% rename from data/settings/controller/rules/net/all.rule rename to data/data/controller/example/init/rules/net/all.rule diff --git a/data/settings/controller/rules/net/loopback.rule b/data/data/controller/example/init/rules/net/loopback.rule similarity index 100% rename from data/settings/controller/rules/net/loopback.rule rename to data/data/controller/example/init/rules/net/loopback.rule diff --git a/data/settings/controller/rules/service/dbus.rule b/data/data/controller/example/init/rules/service/dbus.rule similarity index 100% rename from data/settings/controller/rules/service/dbus.rule rename to data/data/controller/example/init/rules/service/dbus.rule diff --git a/data/settings/controller/rules/service/logger.rule b/data/data/controller/example/init/rules/service/logger.rule similarity index 100% rename from data/settings/controller/rules/service/logger.rule rename to data/data/controller/example/init/rules/service/logger.rule diff --git a/data/settings/controller/rules/service/mouse.rule b/data/data/controller/example/init/rules/service/mouse.rule similarity index 100% rename from data/settings/controller/rules/service/mouse.rule rename to data/data/controller/example/init/rules/service/mouse.rule diff --git a/data/settings/controller/rules/task/clock.rule b/data/data/controller/example/init/rules/task/clock.rule similarity index 100% rename from data/settings/controller/rules/task/clock.rule rename to data/data/controller/example/init/rules/task/clock.rule diff --git a/data/settings/controller/rules/task/keyboard.rule b/data/data/controller/example/init/rules/task/keyboard.rule similarity index 100% rename from data/settings/controller/rules/task/keyboard.rule rename to data/data/controller/example/init/rules/task/keyboard.rule diff --git a/data/settings/controller/rules/task/ntpdate.rule b/data/data/controller/example/init/rules/task/ntpdate.rule similarity index 100% rename from data/settings/controller/rules/task/ntpdate.rule rename to data/data/controller/example/init/rules/task/ntpdate.rule diff --git a/data/settings/controller/rules/terminal/four.rule b/data/data/controller/example/init/rules/terminal/four.rule similarity index 100% rename from data/settings/controller/rules/terminal/four.rule rename to data/data/controller/example/init/rules/terminal/four.rule diff --git a/data/settings/controller/rules/terminal/one.rule b/data/data/controller/example/init/rules/terminal/one.rule similarity index 100% rename from data/settings/controller/rules/terminal/one.rule rename to data/data/controller/example/init/rules/terminal/one.rule diff --git a/data/settings/controller/rules/terminal/three.rule b/data/data/controller/example/init/rules/terminal/three.rule similarity index 100% rename from data/settings/controller/rules/terminal/three.rule rename to data/data/controller/example/init/rules/terminal/three.rule diff --git a/data/settings/controller/rules/terminal/two.rule b/data/data/controller/example/init/rules/terminal/two.rule similarity index 100% rename from data/settings/controller/rules/terminal/two.rule rename to data/data/controller/example/init/rules/terminal/two.rule diff --git a/data/settings/controller/example/entries/asynchronous-serial.entry b/data/data/controller/example/miscellaneous/entries/asynchronous-serial.entry similarity index 100% rename from data/settings/controller/example/entries/asynchronous-serial.entry rename to data/data/controller/example/miscellaneous/entries/asynchronous-serial.entry diff --git a/data/settings/controller/example/entries/asynchronous.entry b/data/data/controller/example/miscellaneous/entries/asynchronous.entry similarity index 100% rename from data/settings/controller/example/entries/asynchronous.entry rename to data/data/controller/example/miscellaneous/entries/asynchronous.entry diff --git a/data/settings/controller/example/entries/delay-program.entry b/data/data/controller/example/miscellaneous/entries/delay-program.entry similarity index 100% rename from data/settings/controller/example/entries/delay-program.entry rename to data/data/controller/example/miscellaneous/entries/delay-program.entry diff --git a/data/settings/controller/example/entries/delay-service.entry b/data/data/controller/example/miscellaneous/entries/delay-service.entry similarity index 100% rename from data/settings/controller/example/entries/delay-service.entry rename to data/data/controller/example/miscellaneous/entries/delay-service.entry diff --git a/data/settings/controller/example/entries/environment.entry b/data/data/controller/example/miscellaneous/entries/environment.entry similarity index 100% rename from data/settings/controller/example/entries/environment.entry rename to data/data/controller/example/miscellaneous/entries/environment.entry diff --git a/data/settings/controller/example/entries/htop-alternate.entry b/data/data/controller/example/miscellaneous/entries/htop-alternate.entry similarity index 100% rename from data/settings/controller/example/entries/htop-alternate.entry rename to data/data/controller/example/miscellaneous/entries/htop-alternate.entry diff --git a/data/settings/controller/example/entries/htop-command.entry b/data/data/controller/example/miscellaneous/entries/htop-command.entry similarity index 100% rename from data/settings/controller/example/entries/htop-command.entry rename to data/data/controller/example/miscellaneous/entries/htop-command.entry diff --git a/data/settings/controller/example/entries/htop.entry b/data/data/controller/example/miscellaneous/entries/htop.entry similarity index 100% rename from data/settings/controller/example/entries/htop.entry rename to data/data/controller/example/miscellaneous/entries/htop.entry diff --git a/data/settings/controller/example/entries/iki.entry b/data/data/controller/example/miscellaneous/entries/iki.entry similarity index 100% rename from data/settings/controller/example/entries/iki.entry rename to data/data/controller/example/miscellaneous/entries/iki.entry diff --git a/data/settings/controller/example/entries/serial-alternate.entry b/data/data/controller/example/miscellaneous/entries/serial-alternate.entry similarity index 100% rename from data/settings/controller/example/entries/serial-alternate.entry rename to data/data/controller/example/miscellaneous/entries/serial-alternate.entry diff --git a/data/settings/controller/example/entries/serial.entry b/data/data/controller/example/miscellaneous/entries/serial.entry similarity index 100% rename from data/settings/controller/example/entries/serial.entry rename to data/data/controller/example/miscellaneous/entries/serial.entry diff --git a/data/settings/controller/example/entries/sshd.entry b/data/data/controller/example/miscellaneous/entries/sshd.entry similarity index 100% rename from data/settings/controller/example/entries/sshd.entry rename to data/data/controller/example/miscellaneous/entries/sshd.entry diff --git a/data/settings/controller/example/entries/test.entry b/data/data/controller/example/miscellaneous/entries/test.entry similarity index 100% rename from data/settings/controller/example/entries/test.entry rename to data/data/controller/example/miscellaneous/entries/test.entry diff --git a/data/settings/controller/example/entries/up.entry b/data/data/controller/example/miscellaneous/entries/up.entry similarity index 100% rename from data/settings/controller/example/entries/up.entry rename to data/data/controller/example/miscellaneous/entries/up.entry diff --git a/data/settings/controller/example/entries/utility.entry b/data/data/controller/example/miscellaneous/entries/utility.entry similarity index 100% rename from data/settings/controller/example/entries/utility.entry rename to data/data/controller/example/miscellaneous/entries/utility.entry diff --git a/data/settings/controller/example/exits/htop-alternate.exit b/data/data/controller/example/miscellaneous/exits/htop-alternate.exit similarity index 100% rename from data/settings/controller/example/exits/htop-alternate.exit rename to data/data/controller/example/miscellaneous/exits/htop-alternate.exit diff --git a/data/settings/controller/example/exits/serial.exit b/data/data/controller/example/miscellaneous/exits/serial.exit similarity index 100% rename from data/settings/controller/example/exits/serial.exit rename to data/data/controller/example/miscellaneous/exits/serial.exit diff --git a/data/settings/controller/example/exits/sshd.exit b/data/data/controller/example/miscellaneous/exits/sshd.exit similarity index 100% rename from data/settings/controller/example/exits/sshd.exit rename to data/data/controller/example/miscellaneous/exits/sshd.exit diff --git a/data/settings/controller/example/rules/asynchronous/sleep_1.rule b/data/data/controller/example/miscellaneous/rules/asynchronous/sleep_1.rule similarity index 100% rename from data/settings/controller/example/rules/asynchronous/sleep_1.rule rename to data/data/controller/example/miscellaneous/rules/asynchronous/sleep_1.rule diff --git a/data/settings/controller/example/rules/asynchronous/sleep_10.rule b/data/data/controller/example/miscellaneous/rules/asynchronous/sleep_10.rule similarity index 100% rename from data/settings/controller/example/rules/asynchronous/sleep_10.rule rename to data/data/controller/example/miscellaneous/rules/asynchronous/sleep_10.rule diff --git a/data/settings/controller/example/rules/asynchronous/sleep_2.rule b/data/data/controller/example/miscellaneous/rules/asynchronous/sleep_2.rule similarity index 100% rename from data/settings/controller/example/rules/asynchronous/sleep_2.rule rename to data/data/controller/example/miscellaneous/rules/asynchronous/sleep_2.rule diff --git a/data/settings/controller/example/rules/asynchronous/sleep_3.rule b/data/data/controller/example/miscellaneous/rules/asynchronous/sleep_3.rule similarity index 100% rename from data/settings/controller/example/rules/asynchronous/sleep_3.rule rename to data/data/controller/example/miscellaneous/rules/asynchronous/sleep_3.rule diff --git a/data/settings/controller/example/rules/asynchronous/sleep_5.rule b/data/data/controller/example/miscellaneous/rules/asynchronous/sleep_5.rule similarity index 100% rename from data/settings/controller/example/rules/asynchronous/sleep_5.rule rename to data/data/controller/example/miscellaneous/rules/asynchronous/sleep_5.rule diff --git a/data/settings/controller/example/rules/asynchronous/sleep_8.rule b/data/data/controller/example/miscellaneous/rules/asynchronous/sleep_8.rule similarity index 100% rename from data/settings/controller/example/rules/asynchronous/sleep_8.rule rename to data/data/controller/example/miscellaneous/rules/asynchronous/sleep_8.rule diff --git a/data/settings/controller/example/rules/command/htop.rule b/data/data/controller/example/miscellaneous/rules/command/htop.rule similarity index 100% rename from data/settings/controller/example/rules/command/htop.rule rename to data/data/controller/example/miscellaneous/rules/command/htop.rule diff --git a/data/settings/controller/example/rules/command/multiple.rule b/data/data/controller/example/miscellaneous/rules/command/multiple.rule similarity index 100% rename from data/settings/controller/example/rules/command/multiple.rule rename to data/data/controller/example/miscellaneous/rules/command/multiple.rule diff --git a/data/settings/controller/example/rules/delay/long.rule b/data/data/controller/example/miscellaneous/rules/delay/long.rule similarity index 100% rename from data/settings/controller/example/rules/delay/long.rule rename to data/data/controller/example/miscellaneous/rules/delay/long.rule diff --git a/data/settings/controller/example/rules/delay/short.rule b/data/data/controller/example/miscellaneous/rules/delay/short.rule similarity index 100% rename from data/settings/controller/example/rules/delay/short.rule rename to data/data/controller/example/miscellaneous/rules/delay/short.rule diff --git a/data/settings/controller/example/rules/environment/default.rule b/data/data/controller/example/miscellaneous/rules/environment/default.rule similarity index 100% rename from data/settings/controller/example/rules/environment/default.rule rename to data/data/controller/example/miscellaneous/rules/environment/default.rule diff --git a/data/settings/controller/example/rules/environment/empty.rule b/data/data/controller/example/miscellaneous/rules/environment/empty.rule similarity index 100% rename from data/settings/controller/example/rules/environment/empty.rule rename to data/data/controller/example/miscellaneous/rules/environment/empty.rule diff --git a/data/settings/controller/example/rules/environment/exported.rule b/data/data/controller/example/miscellaneous/rules/environment/exported.rule similarity index 100% rename from data/settings/controller/example/rules/environment/exported.rule rename to data/data/controller/example/miscellaneous/rules/environment/exported.rule diff --git a/data/settings/controller/example/rules/environment/exporting.rule b/data/data/controller/example/miscellaneous/rules/environment/exporting.rule similarity index 100% rename from data/settings/controller/example/rules/environment/exporting.rule rename to data/data/controller/example/miscellaneous/rules/environment/exporting.rule diff --git a/data/settings/controller/example/rules/environment/fake-nothing.rule b/data/data/controller/example/miscellaneous/rules/environment/fake-nothing.rule similarity index 100% rename from data/settings/controller/example/rules/environment/fake-nothing.rule rename to data/data/controller/example/miscellaneous/rules/environment/fake-nothing.rule diff --git a/data/settings/controller/example/rules/environment/fake-something.rule b/data/data/controller/example/miscellaneous/rules/environment/fake-something.rule similarity index 100% rename from data/settings/controller/example/rules/environment/fake-something.rule rename to data/data/controller/example/miscellaneous/rules/environment/fake-something.rule diff --git a/data/settings/controller/example/rules/maintenance/boom.rule b/data/data/controller/example/miscellaneous/rules/maintenance/boom.rule similarity index 100% rename from data/settings/controller/example/rules/maintenance/boom.rule rename to data/data/controller/example/miscellaneous/rules/maintenance/boom.rule diff --git a/data/settings/controller/example/rules/print/newline.rule b/data/data/controller/example/miscellaneous/rules/print/newline.rule similarity index 100% rename from data/settings/controller/example/rules/print/newline.rule rename to data/data/controller/example/miscellaneous/rules/print/newline.rule diff --git a/data/settings/controller/example/rules/script/create_socket_path.rule b/data/data/controller/example/miscellaneous/rules/script/create_socket_path.rule similarity index 100% rename from data/settings/controller/example/rules/script/create_socket_path.rule rename to data/data/controller/example/miscellaneous/rules/script/create_socket_path.rule diff --git a/data/settings/controller/example/rules/script/fail.rule b/data/data/controller/example/miscellaneous/rules/script/fail.rule similarity index 100% rename from data/settings/controller/example/rules/script/fail.rule rename to data/data/controller/example/miscellaneous/rules/script/fail.rule diff --git a/data/settings/controller/example/rules/script/iki.rule b/data/data/controller/example/miscellaneous/rules/script/iki.rule similarity index 100% rename from data/settings/controller/example/rules/script/iki.rule rename to data/data/controller/example/miscellaneous/rules/script/iki.rule diff --git a/data/settings/controller/example/rules/script/php.rule b/data/data/controller/example/miscellaneous/rules/script/php.rule similarity index 100% rename from data/settings/controller/example/rules/script/php.rule rename to data/data/controller/example/miscellaneous/rules/script/php.rule diff --git a/data/settings/controller/example/rules/script/python.rule b/data/data/controller/example/miscellaneous/rules/script/python.rule similarity index 100% rename from data/settings/controller/example/rules/script/python.rule rename to data/data/controller/example/miscellaneous/rules/script/python.rule diff --git a/data/settings/controller/example/rules/script/require_me.rule b/data/data/controller/example/miscellaneous/rules/script/require_me.rule similarity index 100% rename from data/settings/controller/example/rules/script/require_me.rule rename to data/data/controller/example/miscellaneous/rules/script/require_me.rule diff --git a/data/settings/controller/example/rules/script/succeed.rule b/data/data/controller/example/miscellaneous/rules/script/succeed.rule similarity index 100% rename from data/settings/controller/example/rules/script/succeed.rule rename to data/data/controller/example/miscellaneous/rules/script/succeed.rule diff --git a/data/settings/controller/example/rules/serial/s_1.rule b/data/data/controller/example/miscellaneous/rules/serial/s_1.rule similarity index 100% rename from data/settings/controller/example/rules/serial/s_1.rule rename to data/data/controller/example/miscellaneous/rules/serial/s_1.rule diff --git a/data/settings/controller/example/rules/serial/s_2.rule b/data/data/controller/example/miscellaneous/rules/serial/s_2.rule similarity index 100% rename from data/settings/controller/example/rules/serial/s_2.rule rename to data/data/controller/example/miscellaneous/rules/serial/s_2.rule diff --git a/data/settings/controller/example/rules/serial/s_3.rule b/data/data/controller/example/miscellaneous/rules/serial/s_3.rule similarity index 100% rename from data/settings/controller/example/rules/serial/s_3.rule rename to data/data/controller/example/miscellaneous/rules/serial/s_3.rule diff --git a/data/settings/controller/example/rules/serial/s_4.rule b/data/data/controller/example/miscellaneous/rules/serial/s_4.rule similarity index 100% rename from data/settings/controller/example/rules/serial/s_4.rule rename to data/data/controller/example/miscellaneous/rules/serial/s_4.rule diff --git a/data/settings/controller/example/rules/serial/s_5.rule b/data/data/controller/example/miscellaneous/rules/serial/s_5.rule similarity index 100% rename from data/settings/controller/example/rules/serial/s_5.rule rename to data/data/controller/example/miscellaneous/rules/serial/s_5.rule diff --git a/data/settings/controller/example/rules/serial/s_6.rule b/data/data/controller/example/miscellaneous/rules/serial/s_6.rule similarity index 100% rename from data/settings/controller/example/rules/serial/s_6.rule rename to data/data/controller/example/miscellaneous/rules/serial/s_6.rule diff --git a/data/settings/controller/example/rules/service/sshd.rule b/data/data/controller/example/miscellaneous/rules/service/sshd.rule similarity index 100% rename from data/settings/controller/example/rules/service/sshd.rule rename to data/data/controller/example/miscellaneous/rules/service/sshd.rule diff --git a/data/settings/controller/example/rules/utility/sleeper_1.rule b/data/data/controller/example/miscellaneous/rules/utility/sleeper_1.rule similarity index 100% rename from data/settings/controller/example/rules/utility/sleeper_1.rule rename to data/data/controller/example/miscellaneous/rules/utility/sleeper_1.rule diff --git a/data/settings/controller/example/rules/utility/sleeper_2.rule b/data/data/controller/example/miscellaneous/rules/utility/sleeper_2.rule similarity index 100% rename from data/settings/controller/example/rules/utility/sleeper_2.rule rename to data/data/controller/example/miscellaneous/rules/utility/sleeper_2.rule diff --git a/data/settings/controller/example/rules/utility/sleeper_3.rule b/data/data/controller/example/miscellaneous/rules/utility/sleeper_3.rule similarity index 100% rename from data/settings/controller/example/rules/utility/sleeper_3.rule rename to data/data/controller/example/miscellaneous/rules/utility/sleeper_3.rule diff --git a/sources/c/main/controller.h b/sources/c/main/controller.h index 9f3ac71..848db82 100644 --- a/sources/c/main/controller.h +++ b/sources/c/main/controller.h @@ -116,6 +116,7 @@ #include #include #include +#include #include #include #include @@ -125,6 +126,7 @@ #include #include #include +#include #include #include #include diff --git a/sources/c/main/print/debug/rule/action.h b/sources/c/main/print/debug/rule/action.h index 73db9a6..8d07879 100644 --- a/sources/c/main/print/debug/rule/action.h +++ b/sources/c/main/print/debug/rule/action.h @@ -5,12 +5,12 @@ * API Version: 0.7 * Licenses: lgpl-2.1-or-later * - * Provides the print Entry Action debug functionality. + * Provides the print Entry Rule Action debug functionality. * * This is auto-included and should not need to be explicitly included. */ -#ifndef _controller_main_print_debug_entry_action_h -#define _controller_main_print_debug_entry_action_h +#ifndef _controller_main_print_debug_rule_action_h +#define _controller_main_print_debug_rule_action_h #ifdef __cplusplus extern "C" { @@ -46,4 +46,4 @@ extern "C" { } // extern "C" #endif -#endif // _controller_main_print_debug_entry_action_h +#endif // _controller_main_print_debug_rule_action_h diff --git a/sources/c/main/print/debug/rule/execute.h b/sources/c/main/print/debug/rule/execute.h index 94f2bac..c9b4346 100644 --- a/sources/c/main/print/debug/rule/execute.h +++ b/sources/c/main/print/debug/rule/execute.h @@ -5,7 +5,7 @@ * API Version: 0.7 * Licenses: lgpl-2.1-or-later * - * Provides the print Entry Action debug functionality. + * Provides the print Entry Rule execute debug functionality. * * This is auto-included and should not need to be explicitly included. */ diff --git a/sources/c/main/print/debug/rule/instance.c b/sources/c/main/print/debug/rule/instance.c new file mode 100644 index 0000000..3714a9c --- /dev/null +++ b/sources/c/main/print/debug/rule/instance.c @@ -0,0 +1,29 @@ +#include "../../../controller.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_controller_print_debug_rule_instance_need_want_wish_ + f_status_t controller_print_debug_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) { + + if (!print || !print->custom || !instance) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_debug_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + controller_print_error_rule_item_need_want_wish(print, need_want_wish, value, why); + + controller_print_error_rule_cache(print, &instance->cache.action, F_true); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_debug_rule_instance_need_want_wish_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/main/print/debug/rule/instance.h b/sources/c/main/print/debug/rule/instance.h new file mode 100644 index 0000000..6a0f3ed --- /dev/null +++ b/sources/c/main/print/debug/rule/instance.h @@ -0,0 +1,56 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print Entry Rule Instance debug functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_main_print_debug_rule_instance_h +#define _controller_main_print_debug_rule_instance_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print a warning message related to need/want/wish settings of some Rule for some Instance. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param instance + * The Controller Instance. + * + * Must not be NULL. + * @param need_want_wish + * The appropriate string, such as "needs", "wants", or "wishes for" to output when describing this error/warning. + * This string is expected to already be "safe" (no control characters, etc..). + * @param value + * The value that is the error or warning. + * @param why + * A short explanation on why this is an error or warning. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_debug_rule_instance_need_want_wish_ + extern f_status_t controller_print_debug_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why); +#endif // #ifndef _di_controller_print_debug_rule_instance_need_want_wish_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_main_print_debug_rule_instance_h diff --git a/sources/c/main/print/error/rule/instance.c b/sources/c/main/print/error/rule/instance.c new file mode 100644 index 0000000..b49eac4 --- /dev/null +++ b/sources/c/main/print/error/rule/instance.c @@ -0,0 +1,29 @@ +#include "../../../controller.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_controller_print_error_rule_instance_need_want_wish_ + f_status_t controller_print_error_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) { + + if (!print || !print->custom || !instance) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_debug_e) return F_output_not; + + controller_t * const main = (controller_t *) print->custom; + + controller_lock_print(print->to, &main->thread); + + controller_print_error_rule_item_need_want_wish(print, need_want_wish, value, why); + + controller_print_error_rule_cache(print, &instance->cache.action, F_true); + + controller_unlock_print_flush(print->to, &main->thread); + + return F_okay; + } +#endif // _di_controller_print_error_rule_instance_need_want_wish_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sources/c/main/print/error/rule/instance.h b/sources/c/main/print/error/rule/instance.h new file mode 100644 index 0000000..bb792e4 --- /dev/null +++ b/sources/c/main/print/error/rule/instance.h @@ -0,0 +1,56 @@ +/** + * FLL - Level 3 + * + * Project: Controller + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Provides the print Entry Rule Instance error functionality. + * + * This is auto-included and should not need to be explicitly included. + */ +#ifndef _controller_main_print_error_rule_instance_h +#define _controller_main_print_error_rule_instance_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Print a error message related to need/want/wish settings of some Rule for some Instance. + * + * @param print + * The output structure to print to. + * + * This requires print.custom to be controller_t. + * + * This does not alter print.custom.setting.state.status. + * + * Must not be NULL. + * @param instance + * The Controller Instance. + * + * Must not be NULL. + * @param need_want_wish + * The appropriate string, such as "needs", "wants", or "wishes for" to output when describing this error/warning. + * This string is expected to already be "safe" (no control characters, etc..). + * @param value + * The value that is the error or warning. + * @param why + * A short explanation on why this is an error or warning. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_controller_print_error_rule_instance_need_want_wish_ + extern f_status_t controller_print_error_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why); +#endif // _di_controller_print_error_rule_instance_need_want_wish_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _controller_main_print_error_rule_instance_h diff --git a/sources/c/main/rule/execute.c b/sources/c/main/rule/execute.c index d7598be..c179053 100644 --- a/sources/c/main/rule/execute.c +++ b/sources/c/main/rule/execute.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_controller_rule_execute_ - f_status_t controller_rule_execute(controller_t * const main, const uint8_t action, const uint8_t options, controller_instance_t * const instance) { + f_status_t controller_rule_execute(controller_t * const main, controller_instance_t * const instance, const uint8_t action, const uint8_t options) { if (!main || !instance) return F_status_set_error(F_parameter); @@ -247,14 +247,14 @@ extern "C" { } do { - status = controller_rule_execute_foreground(instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, &execute_set, instance); + status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, &execute_set); - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; } while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0); - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break; if (F_status_is_error(status)) { instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); @@ -285,18 +285,18 @@ extern "C" { do { if (instance->rule.engine.used) { - status = controller_rule_execute_foreground(instance->rule.items.array[i].type, instance->rule.engine, instance->rule.engine_arguments, options, &execute_set, instance); + status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, instance->rule.engine, instance->rule.engine_arguments, options, &execute_set); } else { - status = controller_rule_execute_foreground(instance->rule.items.array[i].type, controller_default_engine_s, instance->rule.engine_arguments, options, &execute_set, instance); + status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, controller_default_engine_s, instance->rule.engine_arguments, options, &execute_set); } - if (status == F_child || F_status_set_fine(status) == F_lock) break; + if (status == F_child || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; } while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0); - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break; if (F_status_is_error(status)) { instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); @@ -322,12 +322,12 @@ extern "C" { do { status = controller_rule_execute_pid_with(instance, instance->rule.items.array[i].pid_file, instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, instance->rule.items.array[i].with, &execute_set); - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; } while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0); - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break; if (F_status_is_error(status)) { instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); @@ -366,12 +366,12 @@ extern "C" { do { status = controller_rule_execute_pid_with(instance, instance->rule.items.array[i].pid_file, instance->rule.items.array[i].type, instance->rule.engine.used ? instance->rule.engine : controller_default_engine_s, instance->rule.engine_arguments, options, instance->rule.items.array[i].with, &execute_set); - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break; if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break; } while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0); - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break; + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break; if (F_status_is_error(status)) { instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure); @@ -406,11 +406,15 @@ extern "C" { } // for // Lock failed, attempt to re-establish lock before returning. - if (F_status_set_fine(status) == F_lock) { - status = controller_lock_read(instance->type != controller_instance_type_exit_e, F_true, &main->thread, &instance->lock); - if (F_status_is_error(status)) return F_status_set_error(F_lock); - + if (F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) { success = F_false; + + if (F_status_set_fine(status) == F_lock_read) { + status = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock); + if (F_status_is_error(status)) return F_status_set_error(F_lock_read); + + status = F_status_set_error(F_lock); + } } if (success == false && !instance->rule.items.used) { @@ -427,7 +431,7 @@ extern "C" { #endif // _di_controller_rule_execute_ #ifndef _di_controller_rule_execute_foreground_ - f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance) { + f_status_t controller_rule_execute_foreground(controller_instance_t * const instance, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set) { if (!instance || !instance->main) return F_status_set_error(F_parameter); @@ -488,7 +492,7 @@ extern "C" { status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock); if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read); - return F_status_set_error(F_lock_write); + return F_status_set_error(F_lock); } instance->result = result.status; @@ -504,7 +508,7 @@ extern "C" { // Try again, after the first interrupt. if (F_status_set_fine(status_lock) == F_interrupt) { - status_lock = controller_lock_read_instance(instance, &instance->lock); + status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock); } if (F_status_is_error(status_lock)) { @@ -514,12 +518,7 @@ extern "C" { } } - if (WIFEXITED(result.status) ? WEXITSTATUS(result.status) : 0) { - status = F_status_set_error(F_failure); - } - else { - status = F_okay; - } + status = WIFEXITED(result.status) && WEXITSTATUS(result.status) ? F_status_set_error(F_failure) : F_okay; } else { main->program.child = result.status; @@ -689,7 +688,7 @@ extern "C" { status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock); if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read); - return F_status_set_error(F_lock_write); + return F_status_set_error(F_lock); } // Assign the child instance id to allow for the cancel instance to send appropriate termination signals to the child instance. @@ -714,7 +713,7 @@ extern "C" { status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock); if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read); - return F_status_set_error(F_lock_write); + return F_status_set_error(F_lock); } instance->result = result.status; @@ -732,12 +731,7 @@ extern "C" { return F_status_set_error(F_lock); } - if (WIFEXITED(result.status) ? WEXITSTATUS(result.status) : 0) { - status = F_status_set_error(F_failure); - } - else { - status = F_okay; - } + status = WIFEXITED(result.status) && WEXITSTATUS(result.status) ? F_status_set_error(F_failure) : F_okay; } else { main->program.child = result.status; @@ -780,7 +774,7 @@ extern "C" { if (!instance || !instance->main || !item) return F_false; - const int result = WIFEXITED(instance->result) ? WEXITSTATUS(instance->result) : 0; + const int result = WIFEXITED(instance->result) && WEXITSTATUS(instance->result); if (item->reruns[action].is & (result ? controller_rule_rerun_is_failure_d : controller_rule_rerun_is_success_d)) { controller_t * const main = instance->main; diff --git a/sources/c/main/rule/execute.h b/sources/c/main/rule/execute.h index 6648e20..afb2570 100644 --- a/sources/c/main/rule/execute.h +++ b/sources/c/main/rule/execute.h @@ -19,7 +19,7 @@ extern "C" { /** * Perform an execution of the given Rule. * - * This requires that a read lock be set on process->lock before being called. + * This requires that a read lock be set on instance->lock before being called. * * @param main * The main program data. @@ -27,6 +27,10 @@ extern "C" { * Must not be NULL. * * This does not alter main.setting.state.status. + * @param instance + * The instance data. + * + * Must not be NULL. * @param action * The Action to perform based on the Action type codes. * @@ -41,10 +45,6 @@ extern "C" { * @param options * Process options to consider when executing. * If bit controller_instance_option_simulate_e, then the Rule execution is in simulation mode (printing a message that the Rule would be executed but does not execute the rule). - * @param instance - * The instance data. - * - * Must not be NULL. * * @return * F_okay on success. @@ -53,21 +53,26 @@ extern "C" { * * F_failure (with error bit) if failed to execute. * F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal. - * F_lock (with error bit) if failed to re-establish read lock on process->lock while returning. + * F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored. + * F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning. * * On success and the Rule is run synchronously, then the individual status for the Rule is set to F_complete. * On success and the Rule is run asynchronously, then the individual status for the Rule is set to F_busy. * On failure, the individual status for the Rule is set to an appropriate error status. */ #ifndef _di_controller_rule_execute_ - extern f_status_t controller_rule_execute(controller_t * const main, const uint8_t action, const uint8_t options, controller_instance_t * const instance); + extern f_status_t controller_rule_execute(controller_t * const main, controller_instance_t * const instance, const uint8_t action, const uint8_t options); #endif // _di_controller_rule_execute_ /** * Perform an execution of the given Rule in the foreground. * - * This requires that a read lock be set on process->lock before being called. + * This requires that a read lock be set on instance->lock before being called. + * + * @param instance + * The instance data. * + * Must not be NULL. * @param type * The item type code. * @param program @@ -81,25 +86,21 @@ extern "C" { * The execute parameter and as settings. * * Must not be NULL. - * @param instance - * The instance data. - * - * Must not be NULL. * * @return * F_okay on success. * F_child on child process exiting. * * F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal. - * F_lock_read (with error bit) if failed to re-establish read lock on process->lock while returning. - * F_lock_write (with error bit) if failed to establish write lock on process->lock, and the read lock is able to be restored. + * F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored. + * F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning. * * Errors (with error bit) from: fll_execute_program(). * * @see fll_execute_program() */ #ifndef _di_controller_rule_execute_foreground_ - extern f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance); + extern f_status_t controller_rule_execute_foreground(controller_instance_t * const instance, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set); #endif // _di_controller_rule_execute_foreground_ /** @@ -143,11 +144,15 @@ extern "C" { /** * Perform an execution of the given Rule in the foreground or background and creating a PID file. * - * This requires that a read lock be set on process->lock before being called. + * This requires that a read lock be set on instance->lock before being called. * * When this is synchronous, this will wait for the PID file to be generated before continuing. * When this is asynchronous, this will continue on adding the Rule id and Action to the asynchronous list. * + * @param instance + * The instance data. + * + * Must not be NULL. * @param pid_file * The path to the PID file. * @param type @@ -165,10 +170,6 @@ extern "C" { * The execute parameter and as settings. * * Must not be NULL. - * @param instance - * The instance data. - * - * Must not be NULL. * * @return * F_okay on success. @@ -176,8 +177,8 @@ extern "C" { * * F_file_found (with error bit) if the PID file already exists. * F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal. - * F_lock_read (with error bit) if failed to re-establish read lock on process->lock while returning. - * F_lock_write (with error bit) if failed to establish write lock on process->lock, and the read lock is able to be restored. + * F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored. + * F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning. * * Errors (with error bit) from: fll_execute_program(). * diff --git a/sources/c/main/rule/instance.c b/sources/c/main/rule/instance.c index e0b805d..af28dc6 100644 --- a/sources/c/main/rule/instance.c +++ b/sources/c/main/rule/instance.c @@ -97,10 +97,9 @@ extern "C" { f_number_unsigned_t id_rule = 0; f_number_unsigned_t id_dependency = 0; - bool found = F_false; - controller_instance_t *dependency = 0; + uint8_t found = F_false; uint8_t options_instance = 0; const f_string_static_t strings[3] = { @@ -113,7 +112,6 @@ extern "C" { f_string_dynamics_t *dynamics[3] = { &empty, &empty, &empty }; if (instance->action) { - for (i = 0; i < instance->rule.ons.used; ++i) { if (instance->rule.ons.array[i].action == instance->action) { @@ -154,12 +152,7 @@ extern "C" { return status; } - status = F_true; - } - - if (status == F_true) { - found = F_true; - + status = found = F_true; dependency = main->thread.instances.array[id_dependency]; status_lock = controller_lock_read_instance(instance, &dependency->active); @@ -189,24 +182,19 @@ extern "C" { } } } - else { - f_thread_unlock(&main->thread.lock.instance); - } if (status != F_true) { found = F_false; id_rule = 0; - if (i == 0) { - controller_lock_print(main->program.error.to, &main->thread); - - controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], dynamics[i]->array[j], "is not found"); - controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - + if (i) { + controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], dynamics[i]->array[j], "is not found"); + } + else { status = F_status_set_error(F_found_not); + controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], dynamics[i]->array[j], "is not found"); + if (!(instance->options & controller_instance_option_simulate_e)) { if (dependency) { f_thread_unlock(&dependency->active); @@ -215,17 +203,6 @@ extern "C" { break; } } - else { - if (main->program.warning.verbosity == f_console_verbosity_debug_e) { - controller_lock_print(main->program.warning.to, &main->thread); - - controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], dynamics[i]->array[j], "is not found"); - - controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true); - - controller_unlock_print_flush(main->program.warning.to, &main->thread); - } - } } else if (found) { status_lock = controller_lock_read_instance(instance, &main->thread.lock.rule); @@ -303,12 +280,7 @@ extern "C" { if (F_status_is_error(status)) { if (i == 0 || i == 1 || F_status_set_fine(status) == F_memory_not) { - controller_lock_print(main->program.error.to, &main->thread); - - controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "failed during execution"); - controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true); - - controller_unlock_print_flush(main->program.error.to, &main->thread); + controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "failed during execution"); if (!(dependency->options & controller_instance_option_simulate_e) || F_status_set_fine(status) == F_memory_not) { f_thread_unlock(&dependency->active); @@ -317,15 +289,7 @@ extern "C" { } } else { - if (main->program.warning.verbosity == f_console_verbosity_debug_e) { - controller_lock_print(main->program.warning.to, &main->thread); - - controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], alias_other_buffer, "failed during execution"); - - controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true); - - controller_unlock_print_flush(main->program.warning.to, &main->thread); - } + controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], alias_other_buffer, "failed during execution"); } } } @@ -352,26 +316,18 @@ extern "C" { } if (F_status_is_error(status_lock)) { - if (F_status_is_error(status_lock)) { - controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "due to lock failure"); - } - status = status_lock; + + controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "due to lock failure"); } else if (controller_rule_status_is_error(instance->action, main->process.rules.array[id_rule])) { f_thread_unlock(&main->thread.lock.rule); if (i == 0 || i == 1) { - controller_lock_print(main->program.error.to, &main->thread); - - controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "is in a failed state"); - - controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true); - - controller_unlock_print_flush(main->program.error.to, &main->thread); - status = F_status_set_error(F_found_not); + controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "is in a failed state"); + if (!(dependency->options & controller_instance_option_simulate_e)) { f_thread_unlock(&dependency->active); @@ -379,15 +335,7 @@ extern "C" { } } else { - if (main->program.warning.verbosity == f_console_verbosity_debug_e) { - controller_lock_print(main->program.warning.to, &main->thread); - - controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], alias_other_buffer, "is in a failed state"); - - controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true); - - controller_unlock_print_flush(main->program.warning.to, &main->thread); - } + controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], alias_other_buffer, "is in a failed state"); } } else { @@ -441,9 +389,9 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = controller_rule_execute(main, instance->action, instance->options, instance); + status = controller_rule_execute(main, instance, instance->action, instance->options); - if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) return status; + if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) return status; if (F_status_is_error(status)) { controller_print_error_rule_item(&main->program.error, &instance->cache.action, F_true, F_status_set_fine(status)); @@ -460,10 +408,8 @@ extern "C" { if (F_status_is_error(status_lock)) { controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_false); - if (F_status_set_fine(status) != F_interrupt) { - status = controller_lock_read_instance(instance, &instance->lock); - if (F_status_is_error_not(status)) return status_lock; - } + status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock); + if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read); return F_status_set_error(F_lock); } @@ -480,10 +426,11 @@ extern "C" { if (F_status_is_error(status_lock)) { controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_false); + // Remove the write lock and restore the read lock. f_thread_unlock(&instance->lock); - status = controller_lock_read_instance(instance, &instance->lock); - if (F_status_is_error_not(status)) return status_lock; + status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock); + if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read); return F_status_set_error(F_lock); } @@ -496,15 +443,11 @@ extern "C" { f_number_unsigned_t j = 0; - controller_rule_item_t *rule_item = 0; - // Copy all Rule Item Action statuses from the Rule instance to the Rule. for (i = 0; i < rule->items.used; ++i) { - rule_item = &rule->items.array[i]; - - for (j = 0; j < rule_item->actions.used; ++j) { - rule_item->actions.array[j].status = instance->rule.items.array[i].actions.array[j].status; + for (j = 0; j < rule->items.array[i].actions.used; ++j) { + rule->items.array[i].actions.array[j].status = instance->rule.items.array[i].actions.array[j].status; } // for } // for } @@ -517,6 +460,9 @@ extern "C" { if (F_status_is_error(status_lock)) { controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_true); + status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock); + if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read); + return F_status_set_error(F_lock); } diff --git a/sources/c/main/rule/instance.h b/sources/c/main/rule/instance.h index 71b9455..f2dd83b 100644 --- a/sources/c/main/rule/instance.h +++ b/sources/c/main/rule/instance.h @@ -39,7 +39,8 @@ extern "C" { * F_failure on execution failure. * * F_interrupt (with error bit) on receiving a instance signal, such as an interrupt signal. - * F_lock (with error bit) if failed to re-establish read lock on instance->lock while returning. + * F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored. + * F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning. * * Errors (with error bit) from: controller_lock_read(). * Errors (with error bit) from: controller_lock_write().