| 7778 | } |
| 7779 | |
| 7780 | int cbm_adr_validate_content(const char *content, char *errbuf, int errbuf_size) { |
| 7781 | cbm_adr_sections_t sections = cbm_adr_parse_sections(content); |
| 7782 | char missing[CBM_SZ_256] = ""; |
| 7783 | int mlen = 0; |
| 7784 | int nmissing = 0; |
| 7785 | |
| 7786 | for (int c = 0; c < canonical_section_count; c++) { |
| 7787 | bool found = false; |
| 7788 | for (int i = 0; i < sections.count; i++) { |
| 7789 | if (strcmp(sections.keys[i], canonical_sections[c]) == 0) { |
| 7790 | found = true; |
| 7791 | break; |
| 7792 | } |
| 7793 | } |
| 7794 | if (!found) { |
| 7795 | if (mlen > 0) { |
| 7796 | mlen += snprintf(missing + mlen, sizeof(missing) - mlen, ", "); |
| 7797 | } |
| 7798 | mlen += snprintf(missing + mlen, sizeof(missing) - mlen, "%s", canonical_sections[c]); |
| 7799 | nmissing++; |
| 7800 | } |
| 7801 | } |
| 7802 | cbm_adr_sections_free(§ions); |
| 7803 | |
| 7804 | if (nmissing > 0) { |
| 7805 | snprintf(errbuf, errbuf_size, |
| 7806 | "missing required sections: %s. All 6 required: PURPOSE, STACK, ARCHITECTURE, " |
| 7807 | "PATTERNS, TRADEOFFS, PHILOSOPHY", |
| 7808 | missing); |
| 7809 | return CBM_STORE_ERR; |
| 7810 | } |
| 7811 | return CBM_STORE_OK; |
| 7812 | } |
| 7813 | |
| 7814 | int cbm_adr_validate_section_keys(const char **keys, int count, char *errbuf, int errbuf_size) { |
| 7815 | char invalid[CBM_SZ_256] = ""; |
no test coverage detected