| 5163 | } |
| 5164 | |
| 5165 | static int cbm_upsert_session_hooks(const char *settings_path) { |
| 5166 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
| 5167 | char command[CLI_BUF_8K]; |
| 5168 | char previous_command[CLI_BUF_8K]; |
| 5169 | char released_command[CLI_BUF_8K]; |
| 5170 | char previous_legacy_command[CLI_BUF_8K]; |
| 5171 | char released_legacy_command[CLI_BUF_8K]; |
| 5172 | if (cbm_resolve_hook_command(CMM_SESSION_REMINDER_SCRIPT, command, sizeof(command)) != CLI_OK || |
| 5173 | cbm_resolve_previous_hook_command(CMM_SESSION_REMINDER_SCRIPT, previous_command, |
| 5174 | sizeof(previous_command)) != CLI_OK || |
| 5175 | cbm_resolve_released_hook_command(CMM_SESSION_REMINDER_SCRIPT, released_command, |
| 5176 | sizeof(released_command)) != CLI_OK || |
| 5177 | cbm_resolve_previous_hook_command(CMM_SESSION_REMINDER_SCRIPT_LEGACY, |
| 5178 | previous_legacy_command, |
| 5179 | sizeof(previous_legacy_command)) != CLI_OK || |
| 5180 | cbm_resolve_released_hook_command(CMM_SESSION_REMINDER_SCRIPT_LEGACY, |
| 5181 | released_legacy_command, |
| 5182 | sizeof(released_legacy_command)) != CLI_OK) { |
| 5183 | return CLI_ERR; |
| 5184 | } |
| 5185 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 5186 | previous_legacy_command, NULL}; |
| 5187 | int rc = 0; |
| 5188 | for (int i = 0; i < NUM_DIRS; i++) { |
| 5189 | if (upsert_hooks_json((hooks_upsert_args_t){.settings_path = settings_path, |
| 5190 | .hook_event = "SessionStart", |
| 5191 | .matcher_str = matchers[i], |
| 5192 | .command_str = command, |
| 5193 | .old_commands = old_commands, |
| 5194 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5195 | .match_command_exact = command}) != 0) { |
| 5196 | rc = CLI_ERR; |
| 5197 | } |
| 5198 | } |
| 5199 | return rc; |
| 5200 | } |
| 5201 | |
| 5202 | static int cbm_remove_session_hooks(const char *settings_path) { |
| 5203 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
no test coverage detected