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

Function cbm_config_open

src/cli/cli.c:7265–7300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7263};
7264
7265cbm_config_t *cbm_config_open(const char *cache_dir) {
7266 if (!cache_dir) {
7267 return NULL;
7268 }
7269
7270 char dbpath[CLI_BUF_1K];
7271 snprintf(dbpath, sizeof(dbpath), "%s/_config.db", cache_dir);
7272
7273 /* Ensure directory exists */
7274 mkdirp(cache_dir, DIR_PERMS);
7275
7276 sqlite3 *db = NULL;
7277 if (sqlite3_open(dbpath, &db) != SQLITE_OK) {
7278 if (db) {
7279 sqlite3_close(db);
7280 }
7281 return NULL;
7282 }
7283
7284 /* Create table if not exists */
7285 const char *sql = "CREATE TABLE IF NOT EXISTS config (key TEXT PRIMARY KEY, value TEXT)";
7286 char *err_msg = NULL;
7287 if (sqlite3_exec(db, sql, NULL, NULL, &err_msg) != SQLITE_OK) {
7288 sqlite3_free(err_msg);
7289 sqlite3_close(db);
7290 return NULL;
7291 }
7292
7293 cbm_config_t *cfg = calloc(CBM_ALLOC_ONE, sizeof(*cfg));
7294 if (!cfg) {
7295 sqlite3_close(db);
7296 return NULL;
7297 }
7298 cfg->db = db;
7299 return cfg;
7300}
7301
7302void cbm_config_close(cbm_config_t *cfg) {
7303 if (!cfg) {

Callers 10

cbm_cmd_configFunction · 0.85
handle_ui_configFunction · 0.85
host_state_prepareFunction · 0.85
test_cli.cFile · 0.85
autoindex_limit_probeFunction · 0.85
test_httpd.cFile · 0.85

Calls 1

mkdirpFunction · 0.85