| 11161 | } |
| 11162 | |
| 11163 | int cbm_adr_validate_content(const char *content, char *errbuf, int errbuf_size) { |
| 11164 | cbm_adr_sections_t sections = cbm_adr_parse_sections(content); |
| 11165 | char missing[CBM_SZ_256] = ""; |
| 11166 | int mlen = 0; |
| 11167 | int nmissing = 0; |
| 11168 | |
| 11169 | for (int c = 0; c < canonical_section_count; c++) { |
| 11170 | bool found = false; |
| 11171 | for (int i = 0; i < sections.count; i++) { |
| 11172 | if (strcmp(sections.keys[i], canonical_sections[c]) == 0) { |
| 11173 | found = true; |
| 11174 | break; |
| 11175 | } |
| 11176 | } |
| 11177 | if (!found) { |
| 11178 | if (mlen > 0) { |
| 11179 | mlen += snprintf(missing + mlen, sizeof(missing) - mlen, ", "); |
| 11180 | } |
| 11181 | mlen += snprintf(missing + mlen, sizeof(missing) - mlen, "%s", canonical_sections[c]); |
| 11182 | nmissing++; |
| 11183 | } |
| 11184 | } |
| 11185 | cbm_adr_sections_free(§ions); |
| 11186 | |
| 11187 | if (nmissing > 0) { |
| 11188 | snprintf(errbuf, errbuf_size, |
| 11189 | "missing required sections: %s. All 6 required: PURPOSE, STACK, ARCHITECTURE, " |
| 11190 | "PATTERNS, TRADEOFFS, PHILOSOPHY", |
| 11191 | missing); |
| 11192 | return CBM_STORE_ERR; |
| 11193 | } |
| 11194 | return CBM_STORE_OK; |
| 11195 | } |
| 11196 | |
| 11197 | /* ── ADR heading scanning and splicing ──────────────────────────── */ |
| 11198 |
no test coverage detected