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

Function extract_kv

src/cli/progress_sink.c:26–46  ·  view source on GitHub ↗

Extract value of "key=VALUE" from a structured log line. */

Source from the content-addressed store, hash-verified

24
25/* Extract value of "key=VALUE" from a structured log line. */
26static const char *extract_kv(const char *line, const char *key, char *buf, int buf_len) {
27 if (!line || !key || !buf || buf_len <= 0) {
28 return NULL;
29 }
30 size_t klen = strlen(key);
31 const char *p = line;
32 while (*p) {
33 if ((p == line || p[-SKIP_ONE] == ' ') && strncmp(p, key, klen) == 0 && p[klen] == '=') {
34 const char *val = p + klen + SKIP_ONE;
35 int i = 0;
36 while (val[i] && val[i] != ' ' && i < buf_len - SKIP_ONE) {
37 buf[i] = val[i];
38 i++;
39 }
40 buf[i] = '\0';
41 return buf;
42 }
43 p++;
44 }
45 return NULL;
46}
47
48void cbm_progress_sink_init(FILE *out) {
49 s_out = out ? out : stderr;

Callers 8

on_discoverFunction · 0.85
on_routeFunction · 0.85
on_pass_startFunction · 0.85
on_pass_timingFunction · 0.85
on_gbuf_dumpFunction · 0.85
on_doneFunction · 0.85
on_extract_progressFunction · 0.85
cbm_progress_sink_fnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected