| 5101 | } |
| 5102 | |
| 5103 | static int cbm_upsert_session_hooks(const char *settings_path) { |
| 5104 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
| 5105 | char command[CLI_BUF_8K]; |
| 5106 | char previous_command[CLI_BUF_8K]; |
| 5107 | char released_command[CLI_BUF_8K]; |
| 5108 | char previous_legacy_command[CLI_BUF_8K]; |
| 5109 | char released_legacy_command[CLI_BUF_8K]; |
| 5110 | if (cbm_resolve_hook_command(CMM_SESSION_REMINDER_SCRIPT, command, sizeof(command)) != CLI_OK || |
| 5111 | cbm_resolve_previous_hook_command(CMM_SESSION_REMINDER_SCRIPT, previous_command, |
| 5112 | sizeof(previous_command)) != CLI_OK || |
| 5113 | cbm_resolve_released_hook_command(CMM_SESSION_REMINDER_SCRIPT, released_command, |
| 5114 | sizeof(released_command)) != CLI_OK || |
| 5115 | cbm_resolve_previous_hook_command(CMM_SESSION_REMINDER_SCRIPT_LEGACY, |
| 5116 | previous_legacy_command, |
| 5117 | sizeof(previous_legacy_command)) != CLI_OK || |
| 5118 | cbm_resolve_released_hook_command(CMM_SESSION_REMINDER_SCRIPT_LEGACY, |
| 5119 | released_legacy_command, |
| 5120 | sizeof(released_legacy_command)) != CLI_OK) { |
| 5121 | return CLI_ERR; |
| 5122 | } |
| 5123 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 5124 | previous_legacy_command, NULL}; |
| 5125 | int rc = 0; |
| 5126 | for (int i = 0; i < NUM_DIRS; i++) { |
| 5127 | if (upsert_hooks_json((hooks_upsert_args_t){.settings_path = settings_path, |
| 5128 | .hook_event = "SessionStart", |
| 5129 | .matcher_str = matchers[i], |
| 5130 | .command_str = command, |
| 5131 | .old_commands = old_commands, |
| 5132 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5133 | .match_command_exact = command}) != 0) { |
| 5134 | rc = CLI_ERR; |
| 5135 | } |
| 5136 | } |
| 5137 | return rc; |
| 5138 | } |
| 5139 | |
| 5140 | static int cbm_remove_session_hooks(const char *settings_path) { |
| 5141 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
no test coverage detected