| 5327 | } |
| 5328 | |
| 5329 | static int cbm_upsert_session_hooks(const char *settings_path) { |
| 5330 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
| 5331 | char command[CLI_BUF_8K]; |
| 5332 | char previous_command[CLI_BUF_8K]; |
| 5333 | char released_command[CLI_BUF_8K]; |
| 5334 | char previous_legacy_command[CLI_BUF_8K]; |
| 5335 | char released_legacy_command[CLI_BUF_8K]; |
| 5336 | if (cbm_resolve_hook_command(CMM_SESSION_REMINDER_SCRIPT, command, sizeof(command)) != CLI_OK || |
| 5337 | cbm_resolve_previous_hook_command(CMM_SESSION_REMINDER_SCRIPT, previous_command, |
| 5338 | sizeof(previous_command)) != CLI_OK || |
| 5339 | cbm_resolve_released_hook_command(CMM_SESSION_REMINDER_SCRIPT, released_command, |
| 5340 | sizeof(released_command)) != CLI_OK || |
| 5341 | cbm_resolve_previous_hook_command(CMM_SESSION_REMINDER_SCRIPT_LEGACY, |
| 5342 | previous_legacy_command, |
| 5343 | sizeof(previous_legacy_command)) != CLI_OK || |
| 5344 | cbm_resolve_released_hook_command(CMM_SESSION_REMINDER_SCRIPT_LEGACY, |
| 5345 | released_legacy_command, |
| 5346 | sizeof(released_legacy_command)) != CLI_OK) { |
| 5347 | return CLI_ERR; |
| 5348 | } |
| 5349 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 5350 | previous_legacy_command, NULL}; |
| 5351 | int rc = 0; |
| 5352 | for (int i = 0; i < NUM_DIRS; i++) { |
| 5353 | if (upsert_hooks_json((hooks_upsert_args_t){.settings_path = settings_path, |
| 5354 | .hook_event = "SessionStart", |
| 5355 | .matcher_str = matchers[i], |
| 5356 | .command_str = command, |
| 5357 | .old_commands = old_commands, |
| 5358 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 5359 | .match_command_exact = command}) != 0) { |
| 5360 | rc = CLI_ERR; |
| 5361 | } |
| 5362 | } |
| 5363 | return rc; |
| 5364 | } |
| 5365 | |
| 5366 | static int cbm_remove_session_hooks(const char *settings_path) { |
| 5367 | static const char *matchers[] = {"startup", "resume", "clear", "compact"}; |
no test coverage detected