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

Function cbm_config_get

src/cli/cli.c:6486–6509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6484}
6485
6486const char *cbm_config_get(cbm_config_t *cfg, const char *key, const char *default_val) {
6487 static CBM_TLS char result_buf[CLI_BUF_4K];
6488 if (!cfg || !key) {
6489 return default_val;
6490 }
6491
6492 sqlite3_stmt *stmt = NULL;
6493 if (sqlite3_prepare_v2(cfg->db, "SELECT value FROM config WHERE key = ?", SQL_NUL_TERM, &stmt,
6494 NULL) != SQLITE_OK) {
6495 return default_val;
6496 }
6497 sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient);
6498
6499 const char *result = default_val;
6500 if (sqlite3_step(stmt) == SQLITE_ROW) {
6501 const char *val = (const char *)sqlite3_column_text(stmt, 0);
6502 if (val) {
6503 snprintf(result_buf, sizeof(result_buf), "%s", val);
6504 result = result_buf;
6505 }
6506 }
6507 sqlite3_finalize(stmt);
6508 return result;
6509}
6510
6511bool cbm_config_get_bool(cbm_config_t *cfg, const char *key, bool default_val) {
6512 const char *val = cbm_config_get(cfg, key, NULL);

Callers 6

cbm_config_get_boolFunction · 0.85
cbm_config_get_intFunction · 0.85
cbm_cmd_configFunction · 0.85
handle_ui_configFunction · 0.85
test_cli.cFile · 0.85

Calls

no outgoing calls

Tested by 1