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

Function resolve_snippet_source

src/mcp/mcp.c:8280–8295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8278}
8279
8280static char *resolve_snippet_source(const char *root_path, const char *file_path, int start,
8281 int end, char **out_abs_path) {
8282 *out_abs_path = NULL;
8283 if (!root_path || !file_path) {
8284 return NULL;
8285 }
8286 size_t apsz = strlen(root_path) + strlen(file_path) + MCP_SEPARATOR;
8287 char *abs_path = malloc(apsz);
8288 snprintf(abs_path, apsz, "%s/%s", root_path, file_path);
8289
8290 *out_abs_path = abs_path;
8291 if (cbm_path_within_root(root_path, abs_path)) {
8292 return read_file_lines(abs_path, start, end);
8293 }
8294 return NULL;
8295}
8296
8297static bool utf8_is_cont(unsigned char c) {
8298 return (c & 0xC0) == 0x80;

Callers 1

build_snippet_responseFunction · 0.85

Calls 2

cbm_path_within_rootFunction · 0.85
read_file_linesFunction · 0.85

Tested by

no test coverage detected