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

Function cbm_config_get

src/cli/cli.c:6430–6453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6428}
6429
6430const char *cbm_config_get(cbm_config_t *cfg, const char *key, const char *default_val) {
6431 static CBM_TLS char result_buf[CLI_BUF_4K];
6432 if (!cfg || !key) {
6433 return default_val;
6434 }
6435
6436 sqlite3_stmt *stmt = NULL;
6437 if (sqlite3_prepare_v2(cfg->db, "SELECT value FROM config WHERE key = ?", SQL_NUL_TERM, &stmt,
6438 NULL) != SQLITE_OK) {
6439 return default_val;
6440 }
6441 sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient);
6442
6443 const char *result = default_val;
6444 if (sqlite3_step(stmt) == SQLITE_ROW) {
6445 const char *val = (const char *)sqlite3_column_text(stmt, 0);
6446 if (val) {
6447 snprintf(result_buf, sizeof(result_buf), "%s", val);
6448 result = result_buf;
6449 }
6450 }
6451 sqlite3_finalize(stmt);
6452 return result;
6453}
6454
6455bool cbm_config_get_bool(cbm_config_t *cfg, const char *key, bool default_val) {
6456 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