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