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

Function resolve_header_include

src/pipeline/pass_pkgmap.c:1649–1685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1647}
1648
1649static const cbm_gbuf_node_t *resolve_header_include(const cbm_pipeline_ctx_t *ctx,
1650 const char *source_rel,
1651 const char *source_file_qn,
1652 const char *module_path) {
1653 if (!is_c_family_source(source_rel) || !is_header_include(module_path)) {
1654 return NULL;
1655 }
1656
1657 const char *base = module_path;
1658 if (base[0] == '.' && base[1] == '/') {
1659 base += 2;
1660 }
1661
1662 const cbm_gbuf_node_t *exact = resolve_exact_file_node(ctx, base, source_file_qn);
1663 if (exact) {
1664 return exact;
1665 }
1666
1667 if (source_rel && source_rel[0]) {
1668 char *dir = path_dirname(source_rel);
1669 if (dir) {
1670 char candidate[PKGMAP_PATH_BUF];
1671 if (dir[0]) {
1672 snprintf(candidate, sizeof(candidate), "%s/%s", dir, base);
1673 } else {
1674 snprintf(candidate, sizeof(candidate), "%s", base);
1675 }
1676 free(dir);
1677 exact = resolve_exact_file_node(ctx, candidate, source_file_qn);
1678 if (exact) {
1679 return exact;
1680 }
1681 }
1682 }
1683
1684 return NULL;
1685}
1686
1687/* Resolve a sibling-file import: a bare path/name (no leading "./") that names
1688 * 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