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

Function resolve_snippet_source

src/mcp/mcp.c:8337–8352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8335}
8336
8337static char *resolve_snippet_source(const char *root_path, const char *file_path, int start,
8338 int end, char **out_abs_path) {
8339 *out_abs_path = NULL;
8340 if (!root_path || !file_path) {
8341 return NULL;
8342 }
8343 size_t apsz = strlen(root_path) + strlen(file_path) + MCP_SEPARATOR;
8344 char *abs_path = malloc(apsz);
8345 snprintf(abs_path, apsz, "%s/%s", root_path, file_path);
8346
8347 *out_abs_path = abs_path;
8348 if (cbm_path_within_root(root_path, abs_path)) {
8349 return read_file_lines(abs_path, start, end);
8350 }
8351 return NULL;
8352}
8353
8354static bool utf8_is_cont(unsigned char c) {
8355 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