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

Function cbm_adr_parse_sections

src/store/store.c:5721–5753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5719}
5720
5721cbm_adr_sections_t cbm_adr_parse_sections(const char *content) {
5722 cbm_adr_sections_t result;
5723 memset(&result, 0, sizeof(result));
5724 if (!content || !content[0]) {
5725 return result;
5726 }
5727
5728 const char *p = content;
5729 char *current_section = NULL;
5730 char current_content[ST_SQL_BUF] = "";
5731 int content_len = 0;
5732
5733 while (*p) {
5734 const char *eol = strchr(p, '\n');
5735 int line_len = eol ? (int)(eol - p) : (int)strlen(p);
5736
5737 char *new_section = adr_try_section_header(p, line_len);
5738 if (new_section) {
5739 adr_save_section(&result, current_section, current_content, content_len);
5740 current_section = new_section;
5741 current_content[0] = '\0';
5742 content_len = 0;
5743 } else if (current_section && (content_len > 0 || line_len > 0)) {
5744 adr_append_line(current_content, (int)sizeof(current_content), &content_len, p,
5745 line_len);
5746 }
5747
5748 p = eol ? eol + SKIP_ONE : p + line_len;
5749 }
5750
5751 adr_save_section(&result, current_section, current_content, content_len);
5752 return result;
5753}
5754
5755/* Append a section to the render buffer. */
5756static int adr_render_section(char *buf, int buf_sz, int pos, const char *key, const char *value) {

Callers 3

cbm_adr_validate_contentFunction · 0.85
test_store_arch.cFile · 0.85

Calls 3

adr_try_section_headerFunction · 0.85
adr_save_sectionFunction · 0.85
adr_append_lineFunction · 0.85

Tested by

no test coverage detected