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

Function cbm_config_get

src/cli/cli.c:6650–6673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6648}
6649
6650const char *cbm_config_get(cbm_config_t *cfg, const char *key, const char *default_val) {
6651 static CBM_TLS char result_buf[CLI_BUF_4K];
6652 if (!cfg || !key) {
6653 return default_val;
6654 }
6655
6656 sqlite3_stmt *stmt = NULL;
6657 if (sqlite3_prepare_v2(cfg->db, "SELECT value FROM config WHERE key = ?", SQL_NUL_TERM, &stmt,
6658 NULL) != SQLITE_OK) {
6659 return default_val;
6660 }
6661 sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient);
6662
6663 const char *result = default_val;
6664 if (sqlite3_step(stmt) == SQLITE_ROW) {
6665 const char *val = (const char *)sqlite3_column_text(stmt, 0);
6666 if (val) {
6667 snprintf(result_buf, sizeof(result_buf), "%s", val);
6668 result = result_buf;
6669 }
6670 }
6671 sqlite3_finalize(stmt);
6672 return result;
6673}
6674
6675bool cbm_config_get_bool(cbm_config_t *cfg, const char *key, bool default_val) {
6676 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