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

Function cbm_escape_batch_value

src/cli/cli.c:5087–5107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5085
5086#ifdef _WIN32
5087static int cbm_escape_batch_value(const char *value, char *escaped, size_t escaped_size) {
5088 if (!value || !escaped || escaped_size == 0U) {
5089 return CLI_ERR;
5090 }
5091 size_t out = 0U;
5092 for (const unsigned char *cursor = (const unsigned char *)value; *cursor; cursor++) {
5093 if (*cursor < 0x20U || *cursor == 0x7fU || *cursor == '"') {
5094 return CLI_ERR;
5095 }
5096 size_t needed = (*cursor == '%' || *cursor == '^') ? 2U : 1U;
5097 if (out + needed >= escaped_size) {
5098 return CLI_ERR;
5099 }
5100 if (needed == 2U) {
5101 escaped[out++] = (char)*cursor;
5102 }
5103 escaped[out++] = (char)*cursor;
5104 }
5105 escaped[out] = '\0';
5106 return CLI_OK;
5107}
5108#endif
5109
5110static 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