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

Function extract_kv

src/cli/progress_sink.c:221–242  ·  view source on GitHub ↗

Extract a field from either structured text or JSON worker logs. */

Source from the content-addressed store, hash-verified

219
220/* Extract a field from either structured text or JSON worker logs. */
221static const char *extract_kv(const char *line, const char *key, char *buf, int buf_len) {
222 if (!line || !key || !buf || buf_len <= 0) {
223 return NULL;
224 }
225 size_t klen = strlen(key);
226 const char *p = line;
227 while (*p) {
228 if ((p == line || p[-SKIP_ONE] == ' ') && strncmp(p, key, klen) == 0 && p[klen] == '=') {
229 const char *val = p + klen + SKIP_ONE;
230 int i = 0;
231 while (val[i] && val[i] != ' ' && i < buf_len - SKIP_ONE) {
232 buf[i] = val[i];
233 i++;
234 }
235 buf[i] = '\0';
236 return buf;
237 }
238 p++;
239 }
240 const char *json_key = strcmp(key, "msg") == 0 ? "event" : key;
241 return extract_json_field(line, json_key, buf, buf_len);
242}
243
244void cbm_progress_sink_init(FILE *out) {
245 progress_sink_mutex_ensure();

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 1

extract_json_fieldFunction · 0.85

Tested by

no test coverage detected