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