| 4921 | |
| 4922 | #ifdef _WIN32 |
| 4923 | static int cbm_escape_batch_value(const char *value, char *escaped, size_t escaped_size) { |
| 4924 | if (!value || !escaped || escaped_size == 0U) { |
| 4925 | return CLI_ERR; |
| 4926 | } |
| 4927 | size_t out = 0U; |
| 4928 | for (const unsigned char *cursor = (const unsigned char *)value; *cursor; cursor++) { |
| 4929 | if (*cursor < 0x20U || *cursor == 0x7fU || *cursor == '"') { |
| 4930 | return CLI_ERR; |
| 4931 | } |
| 4932 | size_t needed = (*cursor == '%' || *cursor == '^') ? 2U : 1U; |
| 4933 | if (out + needed >= escaped_size) { |
| 4934 | return CLI_ERR; |
| 4935 | } |
| 4936 | if (needed == 2U) { |
| 4937 | escaped[out++] = (char)*cursor; |
| 4938 | } |
| 4939 | escaped[out++] = (char)*cursor; |
| 4940 | } |
| 4941 | escaped[out] = '\0'; |
| 4942 | return CLI_OK; |
| 4943 | } |
| 4944 | #endif |
| 4945 | |
| 4946 | static int cbm_build_current_hook_script(const char *prefix, const char *binary_path, char *script, |
no outgoing calls
no test coverage detected