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

Function adr_header_field

internal/cbm/doc_adr.c:925–947  ·  view source on GitHub ↗

The value of header field `key` between the title and the first body * heading (the first lines when there is no heading). */

Source from the content-addressed store, hash-verified

923/* The value of header field `key` between the title and the first body
924 * heading (the first lines when there is no heading). */
925static char *adr_header_field(CBMArena *a, const adr_doc_t *d, const char *key) {
926 int from = d->title_head >= 0 ? d->heads[d->title_head].line + SKIP_ONE : d->L.fm_end;
927 int to = d->L.count;
928 for (int h = 0; h < d->nheads; h++) {
929 if (h != d->title_head && d->heads[h].line >= from) {
930 to = d->heads[h].line;
931 break;
932 }
933 }
934 if (to == d->L.count && to - from > ADR_HEAD_SCAN) {
935 to = from + ADR_HEAD_SCAN;
936 }
937 for (int k = from; k < to; k++) {
938 if (!d->L.v[k].text) {
939 continue;
940 }
941 char *v = adr_field(a, &d->L.v[k], key);
942 if (v) {
943 return v;
944 }
945 }
946 return NULL;
947}
948
949/* ── Relations ───────────────────────────────────────────────────── */
950

Callers 1

cbm_adr_extractFunction · 0.85

Calls 1

adr_fieldFunction · 0.85

Tested by

no test coverage detected