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

Function resolve_header_include

src/pipeline/pass_pkgmap.c:1970–2006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1968}
1969
1970static const cbm_gbuf_node_t *resolve_header_include(const cbm_pipeline_ctx_t *ctx,
1971 const char *source_rel,
1972 const char *source_file_qn,
1973 const char *module_path) {
1974 if (!is_c_family_source(source_rel) || !is_header_include(module_path)) {
1975 return NULL;
1976 }
1977
1978 const char *base = module_path;
1979 if (base[0] == '.' && base[1] == '/') {
1980 base += 2;
1981 }
1982
1983 const cbm_gbuf_node_t *exact = resolve_exact_file_node(ctx, base, source_file_qn);
1984 if (exact) {
1985 return exact;
1986 }
1987
1988 if (source_rel && source_rel[0]) {
1989 char *dir = path_dirname(source_rel);
1990 if (dir) {
1991 char candidate[PKGMAP_PATH_BUF];
1992 if (dir[0]) {
1993 snprintf(candidate, sizeof(candidate), "%s/%s", dir, base);
1994 } else {
1995 snprintf(candidate, sizeof(candidate), "%s", base);
1996 }
1997 free(dir);
1998 exact = resolve_exact_file_node(ctx, candidate, source_file_qn);
1999 if (exact) {
2000 return exact;
2001 }
2002 }
2003 }
2004
2005 return NULL;
2006}
2007
2008/* Resolve a sibling-file import: a bare path/name (no leading "./") that names
2009 * a file relative to the importer's directory. This covers build/markup

Callers 1

Calls 4

is_c_family_sourceFunction · 0.85
is_header_includeFunction · 0.85
resolve_exact_file_nodeFunction · 0.85
path_dirnameFunction · 0.85

Tested by

no test coverage detected