* A Rule.
*
* controller_rule_setting_type_*:
- * - affinity: Setting type representing a affinity.
- * - capability: Setting type representing a capability.
- * - cgroup: Setting type representing a control group.
- * - define: Setting type representing a define.
- * - engine: Setting type representing a engine.
- * - environment: Setting type representing a environment.
- * - group: Setting type representing a group.
- * - limit: Setting type representing a limit.
- * - name: Setting type representing a name.
- * - nice: Setting type representing a nice.
- * - on: Setting type representing a on.
- * - parameter: Setting type representing a parameter.
- * - path: Setting type representing a path.
- * - scheduler: Setting type representing a scheduler.
- * - user: Setting type representing a user.
+ * - affinity: Setting type representing a affinity.
+ * - capability: Setting type representing a capability.
+ * - cgroup: Setting type representing a control group.
+ * - define: Setting type representing a define.
+ * - engine: Setting type representing a engine.
+ * - engine_arguments: Setting type representing a engine.
+ * - environment: Setting type representing a environment.
+ * - group: Setting type representing a group.
+ * - limit: Setting type representing a limit.
+ * - name: Setting type representing a name.
+ * - nice: Setting type representing a nice.
+ * - on: Setting type representing a on.
+ * - parameter: Setting type representing a parameter.
+ * - path: Setting type representing a path.
+ * - scheduler: Setting type representing a scheduler.
+ * - user: Setting type representing a user.
*
* controller_rule_has_*:
* - cgroup: Has type representing a control group.
* - scheduler: Has type representing a scheduler.
* - user: Has type representing a user.
*
- * affinity: The cpu affinity to be used when executing the Rule.
- * alias: The distinct ID (machine name) of the Rule, such as "service/ssh".
- * capability: The capability setting if the Rule "has" a capability.
- * cgroup: The control group setting if the Rule "has" a control group.
- * define: Any defines (environment variables) made available to the Rule for IKI substitution or just as environment variables.
- * engine: The program or path to the program of the scripting engine to use when processing scripts in this Rule.
- * environment: All environment variables allowed to be exposed to the Rule when processing.
- * group: The group ID if the Rule "has" a group.
- * groups: A set of group IDs to run the process with (first specified group is the primary group).
- * has: Bitwise set of "has" codes representing what the Rule has.
- * items: All items associated with the Rule.
- * limits: The cpu/resource limits to use when executing the Rule.
- * name: A human name for the Rule (does not have to be distinct), such as "Bash Script".
- * nice: The niceness value if the Rule "has" nice.
- * on: A set of parameters for defining dependencies and how they are needed, wanted, or wished for.
- * parameter: Any parameters made available to the Rule for IKI substitution.
- * path: The path to the Rule file.
- * scheduler: The scheduler setting if the Rule "has" a scheduler.
- * status: A set of action-specific success/failure status of the Rule. Each index represents a controller_rule_action_type_* enum value. Index 0 represents a global status.
- * timeout_kill: The timeout to wait relating to using a kill signal.
- * timeout_start: The timeout to wait relating to starting a process.
- * timeout_stop: The timeout to wait relating to stopping a process.
- * timestamp: The timestamp when the Rule was loaded.
- * user: The User ID if the Rule "has" a user.
+ * affinity: The cpu affinity to be used when executing the Rule.
+ * alias: The distinct ID (machine name) of the Rule, such as "service/ssh".
+ * capability: The capability setting if the Rule "has" a capability.
+ * cgroup: The control group setting if the Rule "has" a control group.
+ * define: Any defines (environment variables) made available to the Rule for IKI substitution or just as environment variables.
+ * engine: The program or path to the program of the scripting engine to use when processing scripts in this Rule.
+ * engine_arguments: Any arguments to pass to the engine program.
+ * environment: All environment variables allowed to be exposed to the Rule when processing.
+ * group: The group ID if the Rule "has" a group.
+ * groups: A set of group IDs to run the process with (first specified group is the primary group).
+ * has: Bitwise set of "has" codes representing what the Rule has.
+ * items: All items associated with the Rule.
+ * limits: The cpu/resource limits to use when executing the Rule.
+ * name: A human name for the Rule (does not have to be distinct), such as "Bash Script".
+ * nice: The niceness value if the Rule "has" nice.
+ * on: A set of parameters for defining dependencies and how they are needed, wanted, or wished for.
+ * parameter: Any parameters made available to the Rule for IKI substitution.
+ * path: The path to the Rule file.
+ * scheduler: The scheduler setting if the Rule "has" a scheduler.
+ * status: A set of action-specific success/failure status of the Rule. Each index represents a controller_rule_action_type_* enum value. Index 0 represents a global status.
+ * timeout_kill: The timeout to wait relating to using a kill signal.
+ * timeout_start: The timeout to wait relating to starting a process.
+ * timeout_stop: The timeout to wait relating to stopping a process.
+ * timestamp: The timestamp when the Rule was loaded.
+ * user: The User ID if the Rule "has" a user.
*/
#ifndef _di_controller_rule_t_
enum {
f_string_maps_t define;
f_string_maps_t parameter;
+ f_string_dynamics_t engine_arguments;
f_string_dynamics_t environment;
f_int32s_t affinity;
f_string_maps_t_initialize, \
f_string_maps_t_initialize, \
f_string_dynamics_t_initialize, \
+ f_string_dynamics_t_initialize, \
f_int32s_t_initialize, \
f_capability_t_initialize, \
f_control_group_t_initialize, \
destination->alias.used = 0;
destination->engine.used = 0;
+ destination->engine_arguments.used = 0;
destination->name.used = 0;
destination->path.used = 0;
destination->scheduler.policy = source.scheduler.policy;
destination->scheduler.priority = source.scheduler.priority;
- for (f_array_length_t i = 0; i < destination->ons.size; ++i) {
+ {
+ f_array_length_t i = 0;
- destination->ons.array[i].action = 0;
- destination->ons.array[i].need.used = 0;
- destination->ons.array[i].want.used = 0;
- destination->ons.array[i].wish.used = 0;
- } // for
+ for (; i < destination->ons.size; ++i) {
+
+ destination->ons.array[i].action = 0;
+ destination->ons.array[i].need.used = 0;
+ destination->ons.array[i].want.used = 0;
+ destination->ons.array[i].wish.used = 0;
+ } // for
+
+ for (i = 0; i < destination->engine_arguments.size; ++i) {
+ destination->engine_arguments.array[i].used = 0;
+ } // for
+ }
destination->ons.used = 0;
destination->items.used = 0;
status = f_string_maps_append_all(source.parameter, &destination->parameter);
if (F_status_is_error(status)) return status;
+ status = f_string_dynamics_append_all(source.engine_arguments, &destination->engine_arguments);
+ if (F_status_is_error(status)) return status;
+
status = f_string_dynamics_append_all(source.environment, &destination->environment);
if (F_status_is_error(status)) return status;
do {
if (process->rule.engine.used) {
- status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.engine, arguments_none, options, &execute_set, process);
+ status = controller_rule_execute_foreground(process->rule.items.array[i].type, process->rule.engine, process->rule.engine_arguments, options, &execute_set, process);
}
else {
- status = controller_rule_execute_foreground(process->rule.items.array[i].type, *global.main->default_engine, arguments_none, options, &execute_set, process);
+ status = controller_rule_execute_foreground(process->rule.items.array[i].type, *global.main->default_engine, process->rule.engine_arguments, options, &execute_set, process);
}
if (status == F_child || F_status_set_fine(status) == F_lock) break;
}
do {
- status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, process->rule.engine.used ? process->rule.engine : *global.main->default_engine, arguments_none, options, process->rule.items.array[i].with, &execute_set, process);
+ status = controller_rule_execute_pid_with(process->rule.items.array[i].pid_file, process->rule.items.array[i].type, process->rule.engine.used ? process->rule.engine : *global.main->default_engine, process->rule.engine_arguments, options, process->rule.items.array[i].with, &execute_set, process);
if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
}
if (F_status_set_fine(status) != F_interrupt) {
- const f_string_statics_t simulated_arguments = f_string_statics_t_initialize;
fl_execute_parameter_t simulated_parameter = macro_fl_execute_parameter_t_initialize(execute_set->parameter.option, execute_set->parameter.wait, process->rule.has & controller_rule_has_environment_d ? execute_set->parameter.environment : 0, execute_set->parameter.signals, &f_string_empty_s);
- status = fll_execute_program(*main->default_engine, simulated_arguments, &simulated_parameter, &execute_set->as, (void *) &result);
+ status = fll_execute_program(*main->default_engine, process->rule.engine_arguments, &simulated_parameter, &execute_set->as, (void *) &result);
}
}
else {
bool for_item = F_true;
- for (f_array_length_t i = 0; i < controller_rule_action_type__enum_size_e; ++i) {
- rule->status[i] = F_known_not;
- } // for
-
rule->timeout_kill = entry->timeout_kill ? entry->timeout_kill : 0;
rule->timeout_start = entry->timeout_start ? entry->timeout_start : 0;
rule->timeout_stop = entry->timeout_stop ? entry->timeout_stop : 0;
rule->alias.used = 0;
rule->engine.used = 0;
+ rule->engine_arguments.used = 0;
rule->name.used = 0;
rule->path.used = 0;
rule->capability = 0;
}
- for (f_array_length_t i = 0; i < rule->cgroup.groups.size; ++i) {
- rule->cgroup.groups.array[i].used = 0;
- } // for
-
rule->cgroup.as_new = F_false;
rule->cgroup.path.used = 0;
rule->cgroup.groups.used = 0;
rule->scheduler.policy = 0;
rule->scheduler.priority = 0;
- for (f_array_length_t i = 0; i < rule->ons.size; ++i) {
- rule->ons.array[i].need.used = 0;
- rule->ons.array[i].want.used = 0;
- rule->ons.array[i].wish.used = 0;
- } // for
-
rule->ons.used = 0;
rule->items.used = 0;
cache->buffer_item.used = 0;
cache->buffer_path.used = 0;
- for (f_array_length_t i = 0; i < cache->content_items.used; ++i) {
- cache->content_items.array[i].used = 0;
- } // for
-
cache->content_items.used = 0;
cache->object_items.used = 0;
cache->action.name_file.used = 0;
cache->action.name_item.used = 0;
+ {
+ f_array_length_t i = 0;
+
+ for (i = 0; i < rule->cgroup.groups.size; ++i) {
+ rule->cgroup.groups.array[i].used = 0;
+ } // for
+
+ for (; i < controller_rule_action_type__enum_size_e; ++i) {
+ rule->status[i] = F_known_not;
+ } // for
+
+ for (i = 0; i < cache->content_items.used; ++i) {
+ cache->content_items.array[i].used = 0;
+ } // for
+
+ for (i = 0; i < rule->engine_arguments.size; ++i) {
+ rule->engine_arguments.array[i].used = 0;
+ } // for
+
+ for (i = 0; i < rule->ons.size; ++i) {
+ rule->ons.array[i].need.used = 0;
+ rule->ons.array[i].want.used = 0;
+ rule->ons.array[i].wish.used = 0;
+ } // for
+ }
+
status = f_string_dynamic_append_nulless(alias, &rule->alias);
if (F_status_is_error(status)) {
setting_value = &rule->engine;
}
- if (setting_value->used || cache->content_actions.array[i].used != 1) {
- controller_rule_setting_read_print_error(global.main->error, "requires exactly one Content", i, line_item, global.thread, cache);
+ if (setting_value->used || !cache->content_actions.array[i].used) {
+ controller_rule_setting_read_print_error(global.main->error, "requires one or more Content", i, line_item, global.thread, cache);
if (F_status_is_error_not(status_return)) {
status_return = F_status_set_error(F_valid_not);
if (type == controller_rule_setting_type_name_e || type == controller_rule_setting_type_engine_e) {
status = fl_string_dynamic_partial_rip_nulless(cache->buffer_item, cache->content_actions.array[i].array[0], setting_value);
+ if (type == controller_rule_setting_type_engine_e) {
+ rule->engine_arguments.used = 0;
+
+ if (cache->content_actions.array[i].used > 1) {
+ status = f_string_dynamics_increase_by(cache->content_actions.array[i].used - 1, &rule->engine_arguments);
+
+ for (j = 1; F_status_is_error_not(status) && j < cache->content_actions.array[i].used; ++j, ++rule->engine_arguments.used) {
+
+ rule->engine_arguments.array[rule->engine_arguments.used].used = 0;
+
+ status = f_string_dynamic_partial_append(cache->buffer_item, cache->content_actions.array[i].array[j], &rule->engine_arguments.array[rule->engine_arguments.used]);
+ } // for
+ }
+ }
+
if (F_status_is_error(status)) {
setting_value->used = 0;
+ if (type == controller_rule_setting_type_engine_e) {
+ rule->engine_arguments.used = 0;
+ }
+
if (F_status_set_fine(status) == F_memory_not) {
status_return = status;
status_return = status;
}
- // get the current line number within the settings item.
+ // Get the current line number within the settings item.
cache->action.line_item = line_item;
f_fss_count_lines(state, cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item);
if (status == F_false || F_status_set_fine(status) == F_complete_not_utf) {
if (global.main->error.verbosity != f_console_verbosity_quiet_e) {
- // get the current line number within the settings item.
+ // Get the current line number within the settings item.
cache->action.line_item = line_item;
f_fss_count_lines(state, cache->buffer_item, cache->object_actions.array[i].start, &cache->action.line_item);
f_print_dynamic_raw(f_string_eol_s, main->output.to.stream);
// Engine.
- fl_print_format(" %[%r%] %Q%r", main->output.to.stream, main->context.set.important, controller_engine_s, main->context.set.important, rule.engine, f_string_eol_s);
+ if (rule.engine_arguments.used) {
+ fl_print_format(" %[%r%] %Q", main->output.to.stream, main->context.set.important, controller_engine_s, main->context.set.important, rule.engine);
+
+ for (i = 0; i < rule.engine_arguments.used; ++i) {
+
+ if (rule.engine_arguments.array[i].used) {
+ fl_print_format(" %Q", main->output.to.stream, rule.engine_arguments.array[i]);
+ }
+ } // for
+
+ fl_print_format("%r", main->output.to.stream, f_string_eol_s);
+ }
+ else {
+ fl_print_format(" %[%r%] %Q%r", main->output.to.stream, main->context.set.important, controller_engine_s, main->context.set.important, rule.engine, f_string_eol_s);
+ }
// User.
fl_print_format(" %[%r%]", main->output.to.stream, main->context.set.important, controller_user_s, main->context.set.important);