| 4942 | |
| 4943 | #ifdef _WIN32 |
| 4944 | static int cbm_escape_batch_value(const char *value, char *escaped, size_t escaped_size) { |
| 4945 | if (!value || !escaped || escaped_size == 0U) { |
| 4946 | return CLI_ERR; |
| 4947 | } |
| 4948 | size_t out = 0U; |
| 4949 | for (const unsigned char *cursor = (const unsigned char *)value; *cursor; cursor++) { |
| 4950 | if (*cursor < 0x20U || *cursor == 0x7fU || *cursor == '"') { |
| 4951 | return CLI_ERR; |
| 4952 | } |
| 4953 | size_t needed = (*cursor == '%' || *cursor == '^') ? 2U : 1U; |
| 4954 | if (out + needed >= escaped_size) { |
| 4955 | return CLI_ERR; |
| 4956 | } |
| 4957 | if (needed == 2U) { |
| 4958 | escaped[out++] = (char)*cursor; |
| 4959 | } |
| 4960 | escaped[out++] = (char)*cursor; |
| 4961 | } |
| 4962 | escaped[out] = '\0'; |
| 4963 | return CLI_OK; |
| 4964 | } |
| 4965 | #endif |
| 4966 | |
| 4967 | static int cbm_build_current_hook_script(const char *prefix, const char *binary_path, char *script, |
no outgoing calls
no test coverage detected