MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_escape_batch_value

Function cbm_escape_batch_value

src/cli/cli.c:5683–5703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5681
5682#ifdef _WIN32
5683static 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
5706static int cbm_build_current_hook_script(const char *prefix, const char *binary_path, char *script,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected