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

Function sphinx_load

src/discover/discover.c:1046–1068  ·  view source on GitHub ↗

The documentation set this directory starts, if it has a conf.py. */

Source from the content-addressed store, hash-verified

1044
1045/* The documentation set this directory starts, if it has a conf.py. */
1046static bool sphinx_load(const char *dir, sphinx_suffixes_t *out) {
1047 char conf[CBM_SZ_4K];
1048 if (snprintf(conf, sizeof(conf), "%s/conf.py", dir) >= (int)sizeof(conf)) {
1049 return false;
1050 }
1051 struct stat st;
1052 if (wide_stat(conf, &st) != 0 || !S_ISREG(st.st_mode)) {
1053 return false;
1054 }
1055 FILE *f = cbm_fopen(conf, "rb");
1056 if (!f) {
1057 return false;
1058 }
1059 char *buf = (char *)cbm_alloc(CBM_MEM_CLASS_OTHER, SPHINX_CONF_READ);
1060 size_t n = buf ? fread(buf, SKIP_ONE, SPHINX_CONF_READ, f) : 0;
1061 (void)fclose(f);
1062 memset(out, 0, sizeof(*out));
1063 if (buf) {
1064 sphinx_parse(buf, n, out);
1065 }
1066 cbm_free(CBM_MEM_CLASS_OTHER, buf);
1067 return true;
1068}
1069
1070static bool sphinx_is_rst(const sphinx_suffixes_t *set, const char *name) {
1071 size_t nl = strlen(name);

Callers 1

walk_dirFunction · 0.85

Calls 6

wide_statFunction · 0.85
cbm_fopenFunction · 0.85
cbm_allocFunction · 0.85
freadFunction · 0.85
sphinx_parseFunction · 0.85
cbm_freeFunction · 0.85

Tested by

no test coverage detected