| 4859 | |
| 4860 | #ifdef _WIN32 |
| 4861 | static int cbm_escape_batch_value(const char *value, char *escaped, size_t escaped_size) { |
| 4862 | if (!value || !escaped || escaped_size == 0U) { |
| 4863 | return CLI_ERR; |
| 4864 | } |
| 4865 | size_t out = 0U; |
| 4866 | for (const unsigned char *cursor = (const unsigned char *)value; *cursor; cursor++) { |
| 4867 | if (*cursor < 0x20U || *cursor == 0x7fU || *cursor == '"') { |
| 4868 | return CLI_ERR; |
| 4869 | } |
| 4870 | size_t needed = (*cursor == '%' || *cursor == '^') ? 2U : 1U; |
| 4871 | if (out + needed >= escaped_size) { |
| 4872 | return CLI_ERR; |
| 4873 | } |
| 4874 | if (needed == 2U) { |
| 4875 | escaped[out++] = (char)*cursor; |
| 4876 | } |
| 4877 | escaped[out++] = (char)*cursor; |
| 4878 | } |
| 4879 | escaped[out] = '\0'; |
| 4880 | return CLI_OK; |
| 4881 | } |
| 4882 | #endif |
| 4883 | |
| 4884 | static int cbm_build_current_hook_script(const char *prefix, const char *binary_path, char *script, |
no outgoing calls
no test coverage detected