| 3301 | } |
| 3302 | |
| 3303 | cbm_daemon_runtime_application_status_t cbm_daemon_application_client_tool( |
| 3304 | cbm_daemon_runtime_client_t *client, const char *tool_name, const char *args_json, |
| 3305 | uint8_t **response_out, uint32_t *response_length_out, uint32_t timeout_ms) { |
| 3306 | if (!client || !tool_name || !tool_name[0] || !args_json || !args_json[0]) { |
| 3307 | return CBM_DAEMON_RUNTIME_APPLICATION_REJECTED; |
| 3308 | } |
| 3309 | size_t tool_length = strlen(tool_name); |
| 3310 | size_t args_length = strlen(args_json); |
| 3311 | uint64_t total = (uint64_t)APPLICATION_TOOL_HEADER_SIZE + tool_length + args_length; |
| 3312 | if (tool_length > UINT32_MAX || total > CBM_DAEMON_RUNTIME_APPLICATION_PAYLOAD_MAX) { |
| 3313 | return CBM_DAEMON_RUNTIME_APPLICATION_REJECTED; |
| 3314 | } |
| 3315 | uint8_t *request = malloc((size_t)total); |
| 3316 | if (!request) { |
| 3317 | return CBM_DAEMON_RUNTIME_APPLICATION_TRANSPORT_ERROR; |
| 3318 | } |
| 3319 | request[0] = CBM_DAEMON_APPLICATION_REQUEST_TOOL; |
| 3320 | application_put_u32(request + 1, (uint32_t)tool_length); |
| 3321 | memcpy(request + APPLICATION_TOOL_HEADER_SIZE, tool_name, tool_length); |
| 3322 | memcpy(request + APPLICATION_TOOL_HEADER_SIZE + tool_length, args_json, args_length); |
| 3323 | return application_client_exchange(client, request, (uint32_t)total, response_out, |
| 3324 | response_length_out, timeout_ms); |
| 3325 | } |
| 3326 | |
| 3327 | cbm_daemon_runtime_application_status_t cbm_daemon_application_client_hook_augment( |
| 3328 | cbm_daemon_runtime_client_t *client, const char *input_json, uint8_t **response_out, |