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

Function resolve_from_path

src/ui/http_server.c:899–922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

897}
898
899static bool resolve_from_path(const char *name, char *out, size_t outsz) {
900 const char *path = getenv("PATH");
901 if (!name || !name[0] || strchr(name, '/') || !path || !path[0]) {
902 return false;
903 }
904
905 const char *cur = path;
906 while (*cur) {
907 const char *colon = strchr(cur, ':');
908 size_t dir_len = colon ? (size_t)(colon - cur) : strlen(cur);
909 if (dir_len > 0 && dir_len < 900) {
910 char candidate[1024];
911 int n = snprintf(candidate, sizeof(candidate), "%.*s/%s", (int)dir_len, cur, name);
912 if (n > 0 && (size_t)n < sizeof(candidate) && is_executable_file(candidate)) {
913 return copy_path(out, outsz, candidate);
914 }
915 }
916 if (!colon) {
917 break;
918 }
919 cur = colon + 1;
920 }
921 return false;
922}
923
924static bool resolve_self_executable(char *out, size_t outsz) {
925#if defined(__APPLE__)

Callers 1

Calls 2

is_executable_fileFunction · 0.85
copy_pathFunction · 0.85

Tested by

no test coverage detected