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

Function cbm_parse_dotenv_source

src/pipeline/pass_infrascan.c:635–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635int cbm_parse_dotenv_source(const char *source, cbm_dotenv_result_t *out) {
636 if (!source || !out) {
637 return CBM_NOT_FOUND;
638 }
639 memset(out, 0, sizeof(*out));
640
641 const char *p = source;
642 char line[CBM_SZ_4K];
643
644 while (*p) {
645 const char *eol = strchr(p, '\n');
646 size_t line_len = eol ? (size_t)(eol - p) : strlen(p);
647 if (line_len >= sizeof(line)) {
648 line_len = sizeof(line) - SKIP_ONE;
649 }
650 memcpy(line, p, line_len);
651 line[line_len] = '\0';
652 p = eol ? eol + SKIP_ONE : p + line_len;
653
654 char *trimmed = line;
655 while (*trimmed == ' ' || *trimmed == '\t') {
656 trimmed++;
657 }
658 rtrim(trimmed);
659
660 if (*trimmed == '\0' || *trimmed == '#') {
661 continue;
662 }
663
664 parse_dotenv_line(trimmed, out);
665 }
666
667 return (out->env_count > 0) ? 0 : IS_NOT_FOUND;
668}
669
670/* ── Shell script parser ────────────────────────────────────────── */
671

Callers 1

test_pipeline.cFile · 0.85

Calls 2

rtrimFunction · 0.85
parse_dotenv_lineFunction · 0.85

Tested by

no test coverage detected