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

Function navigate

src/foundation/yaml.c:329–365  ·  view source on GitHub ↗

Navigate to a node by dot-separated path. */

Source from the content-addressed store, hash-verified

327
328/* Navigate to a node by dot-separated path. */
329static const cbm_yaml_node_t *navigate(const cbm_yaml_node_t *root, const char *path) {
330 if (!root || !path) {
331 return NULL;
332 }
333
334 const cbm_yaml_node_t *cur = root;
335 char buf[CBM_SZ_256];
336 const char *p = path;
337
338 while (*p) {
339 const char *dot = strchr(p, '.');
340 int seg_len;
341 if (dot) {
342 seg_len = (int)(dot - p);
343 } else {
344 seg_len = (int)strlen(p);
345 }
346 if (seg_len <= 0 || seg_len >= (int)sizeof(buf)) {
347 return NULL;
348 }
349
350 memcpy(buf, p, (size_t)seg_len);
351 buf[seg_len] = '\0';
352
353 cur = find_child(cur, buf);
354 if (!cur) {
355 return NULL;
356 }
357
358 p += seg_len;
359 if (*p == '.') {
360 p++;
361 }
362 }
363
364 return cur;
365}
366
367const char *cbm_yaml_get_str(const cbm_yaml_node_t *root, const char *path) {
368 const cbm_yaml_node_t *node = navigate(root, path);

Callers 4

AppFunction · 0.85
cbm_yaml_get_strFunction · 0.85
cbm_yaml_get_str_listFunction · 0.85
cbm_yaml_hasFunction · 0.85

Calls 1

find_childFunction · 0.85

Tested by

no test coverage detected