| 6700 | } |
| 6701 | |
| 6702 | int cbm_config_set(cbm_config_t *cfg, const char *key, const char *value) { |
| 6703 | if (!cfg || !key || !value) { |
| 6704 | return CLI_ERR; |
| 6705 | } |
| 6706 | |
| 6707 | sqlite3_stmt *stmt = NULL; |
| 6708 | if (sqlite3_prepare_v2(cfg->db, "INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)", |
| 6709 | SQL_NUL_TERM, &stmt, NULL) != SQLITE_OK) { |
| 6710 | return CLI_ERR; |
| 6711 | } |
| 6712 | sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient); |
| 6713 | sqlite3_bind_text(stmt, SQL_PARAM_2, value, SQL_NUL_TERM, cbm_sqlite_transient); |
| 6714 | |
| 6715 | int rc = sqlite3_step(stmt) == SQLITE_DONE ? 0 : CLI_ERR; |
| 6716 | sqlite3_finalize(stmt); |
| 6717 | return rc; |
| 6718 | } |
| 6719 | |
| 6720 | int cbm_config_delete(cbm_config_t *cfg, const char *key) { |
| 6721 | if (!cfg || !key) { |
no outgoing calls