| 5681 | |
| 5682 | #ifdef _WIN32 |
| 5683 | static int cbm_escape_batch_value(const char *value, char *escaped, size_t escaped_size) { |
| 5684 | if (!value || !escaped || escaped_size == 0U) { |
| 5685 | return CLI_ERR; |
| 5686 | } |
| 5687 | size_t out = 0U; |
| 5688 | for (const unsigned char *cursor = (const unsigned char *)value; *cursor; cursor++) { |
| 5689 | if (*cursor < 0x20U || *cursor == 0x7fU || *cursor == '"') { |
| 5690 | return CLI_ERR; |
| 5691 | } |
| 5692 | size_t needed = (*cursor == '%' || *cursor == '^') ? 2U : 1U; |
| 5693 | if (out + needed >= escaped_size) { |
| 5694 | return CLI_ERR; |
| 5695 | } |
| 5696 | if (needed == 2U) { |
| 5697 | escaped[out++] = (char)*cursor; |
| 5698 | } |
| 5699 | escaped[out++] = (char)*cursor; |
| 5700 | } |
| 5701 | escaped[out] = '\0'; |
| 5702 | return CLI_OK; |
| 5703 | } |
| 5704 | #endif |
| 5705 | |
| 5706 | static int cbm_build_current_hook_script(const char *prefix, const char *binary_path, char *script, |
no outgoing calls
no test coverage detected