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

Function resolve_from_path

src/ui/http_server.c:883–906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

881}
882
883static bool resolve_from_path(const char *name, char *out, size_t outsz) {
884 const char *path = getenv("PATH");
885 if (!name || !name[0] || strchr(name, '/') || !path || !path[0]) {
886 return false;
887 }
888
889 const char *cur = path;
890 while (*cur) {
891 const char *colon = strchr(cur, ':');
892 size_t dir_len = colon ? (size_t)(colon - cur) : strlen(cur);
893 if (dir_len > 0 && dir_len < 900) {
894 char candidate[1024];
895 int n = snprintf(candidate, sizeof(candidate), "%.*s/%s", (int)dir_len, cur, name);
896 if (n > 0 && (size_t)n < sizeof(candidate) && is_executable_file(candidate)) {
897 return copy_path(out, outsz, candidate);
898 }
899 }
900 if (!colon) {
901 break;
902 }
903 cur = colon + 1;
904 }
905 return false;
906}
907
908static bool resolve_self_executable(char *out, size_t outsz) {
909#if defined(__APPLE__)

Callers 1

Calls 2

is_executable_fileFunction · 0.85
copy_pathFunction · 0.85

Tested by

no test coverage detected