| 1675 | } |
| 1676 | |
| 1677 | static int main_run_hook_frontend(cbm_daemon_runtime_client_t *client, const char *hook_event, |
| 1678 | const char *hook_dialect) { |
| 1679 | char *input = cbm_hook_augment_read_stdin(); |
| 1680 | if (!input) { |
| 1681 | return 0; |
| 1682 | } |
| 1683 | char *hook_cwd = main_hook_cwd(input); |
| 1684 | bool context_set = |
| 1685 | main_set_client_context(client, hook_cwd, CBM_MCP_TOOL_PROFILE_ALL, hook_event, |
| 1686 | hook_dialect, MAIN_HOOK_CONNECT_TIMEOUT_MS); |
| 1687 | free(hook_cwd); |
| 1688 | if (!context_set) { |
| 1689 | free(input); |
| 1690 | return 0; |
| 1691 | } |
| 1692 | uint8_t *response = NULL; |
| 1693 | uint32_t response_length = 0; |
| 1694 | cbm_daemon_runtime_application_status_t status = cbm_daemon_application_client_hook_augment( |
| 1695 | client, input, &response, &response_length, MAIN_HOOK_REQUEST_TIMEOUT_MS); |
| 1696 | free(input); |
| 1697 | if (status == CBM_DAEMON_RUNTIME_APPLICATION_OK && response && response_length > 0) { |
| 1698 | (void)fwrite(response, 1, response_length, stdout); |
| 1699 | (void)fflush(stdout); |
| 1700 | } |
| 1701 | free(response); |
| 1702 | return 0; /* hooks always fail open */ |
| 1703 | } |
| 1704 | |
| 1705 | static bool main_hook_options(int argc, char **argv, const char **event_out, |
| 1706 | const char **dialect_out) { |
no test coverage detected